### Question:
ListOfValuesResourceConverter extends ResourceConverterImpl<ListOfValues, ClientListOfValues> { @Override protected ListOfValues resourceSpecificFieldsToServer(ClientListOfValues clientObject, ListOfValues resultToUpdate, List<Exception> exceptions, ToServerConversionOptions options) throws IllegalParameterValueException { for (ListOfValuesItem existing : resultToUpdate.getValues()){ resultToUpdate.removeValue(existing); } final List<ClientListOfValuesItem> items = clientObject.getItems(); if(items != null){ for(ClientListOfValuesItem currentItem : items){ ListOfValuesItem serverItem = new ListOfValuesItemImpl(); serverItem.setLabel(currentItem.getLabel()); serverItem.setValue(currentItem.getValue()); resultToUpdate.addValue(serverItem); } } return resultToUpdate; }    }### Answer:
@Test public void resourceSpecificFieldsToServer() throws Exception{ final String label1 = "testLabel1"; final String value1 = "testValue1"; final String label2 = "testLabel2"; final String value2 = "testValue2"; final ClientListOfValues clientObject = new ClientListOfValues(); final ListOfValues serverObject = new ListOfValuesImpl(); List<ClientListOfValuesItem> items = new ArrayList<ClientListOfValuesItem>(2); items.add(new ClientListOfValuesItem(label1, value1)); items.add(new ClientListOfValuesItem(label2, value2)); clientObject.setItems(items); final ListOfValues result = converter.resourceSpecificFieldsToServer(clientObject, serverObject, new ArrayList<Exception>(), null); assertNotNull(result); final ListOfValuesItem[] values = result.getValues(); assertNotNull(values); assertEquals(values.length, 2); for(ListOfValuesItem currentItem : values){ if(label1.equals(currentItem.getLabel())){ assertEquals(currentItem.getValue(), value1); } else if(label2.equals(currentItem.getLabel())){ assertEquals(currentItem.getValue(), value2); } else { assertTrue(false); } } }
@Test public void resourceSpecificFieldsToServer_updateItems() throws Exception{ final String label1 = "testLabel1"; final String value1 = "testValue1"; final String label2 = "testLabel2"; final String value2 = "testValue2"; final ClientListOfValues clientObject = new ClientListOfValues(); final ListOfValues serverObject = new ListOfValuesImpl(); List<ClientListOfValuesItem> items = new ArrayList<ClientListOfValuesItem>(2); items.add(new ClientListOfValuesItem(label1, value1)); items.add(new ClientListOfValuesItem(label2, value2)); clientObject.setItems(items); ListOfValuesItemImpl item = new ListOfValuesItemImpl(); item.setLabel("lala"); item.setValue("ada"); serverObject.addValue(item); final ListOfValues result = converter.resourceSpecificFieldsToServer(clientObject, serverObject, new ArrayList<Exception>(), null); assertNotNull(result); final ListOfValuesItem[] values = result.getValues(); assertNotNull(values); assertEquals(values.length, 2); for(ListOfValuesItem currentItem : values){ if(label1.equals(currentItem.getLabel())){ assertEquals(currentItem.getValue(), value1); } else if(label2.equals(currentItem.getLabel())){ assertEquals(currentItem.getValue(), value2); } else { assertTrue(false); } } }