### Question:
CustomDataSourceResourceConverter extends ResourceConverterImpl<CustomReportDataSource, ClientCustomDataSource> { @Override protected ClientCustomDataSource resourceSpecificFieldsToClient(ClientCustomDataSource client, CustomReportDataSource serverObject, ToClientConversionOptions options) { client.setDataSourceName(serverObject.getDataSourceName()); client.setServiceClass(serverObject.getServiceClass()); List<ClientProperty> properties = null; final Map propertyMap = serverObject.getPropertyMap(); if(propertyMap != null && !propertyMap.isEmpty()){ properties = new ArrayList<ClientProperty>(propertyMap.size()); final Set<String> set = propertyMap.keySet(); for(String key : set){ if (!propertiesToIgnore.contains(key)) { properties.add(new ClientProperty(key, (String)propertyMap.get(key))); } } } client.setProperties(properties == null || properties.isEmpty() ? null : properties); client.setResources(convertResourcesToClient(serverObject.getResources(), options)); return client; }    }### Answer:
@Test public void resourceSpecificFieldsToClient(){ final String expectedServiceClass = "testServiceClass"; final String expectedDataSourceName = "testDataSourceName"; final String expectedPropertyKey1 = "testPropertyKey1"; final String expectedPropertyKey2 = "testPropertyKey2"; final String expectedPropertyValue1 = "testPropertyValue1"; final String expectedPropertyValue2 = "testPropertyValue2"; final ClientCustomDataSource clientObject = new ClientCustomDataSource(); final CustomReportDataSource serverObject = new CustomReportDataSourceImpl(); serverObject.setServiceClass(expectedServiceClass); serverObject.setDataSourceName(expectedDataSourceName); Map<String, String> properties = new HashMap<String, String>(); properties.put(expectedPropertyKey1, expectedPropertyValue1); properties.put(expectedPropertyKey2, expectedPropertyValue2); serverObject.setPropertyMap(properties); final ClientCustomDataSource result = converter.resourceSpecificFieldsToClient(clientObject, serverObject, null); assertSame(result, clientObject); assertEquals(result.getServiceClass(), expectedServiceClass); assertEquals(result.getDataSourceName(), expectedDataSourceName); final List<ClientProperty> resultProperties = result.getProperties(); assertNotNull(resultProperties); assertEquals(resultProperties.size(), 2); for(ClientProperty property : resultProperties){ if(expectedPropertyKey1.equals(property.getKey())){ assertEquals(property.getValue(), expectedPropertyValue1); } else if(expectedPropertyKey2.equals(property.getKey())){ assertEquals(property.getValue(), expectedPropertyValue2); } else { assertTrue(false); } } }
@Test public void resourceSpecificFieldsToClient_ignore(){ final String expectedServiceClass = "testServiceClass"; final String expectedDataSourceName = "testDataSourceName"; final String expectedPropertyKey1 = "testPropertyKey1"; final String expectedPropertyKey2 = "testPropertyKey2"; final String expectedPropertyValue1 = "testPropertyValue1"; final String expectedPropertyValue2 = "testPropertyValue2"; final ClientCustomDataSource clientObject = new ClientCustomDataSource(); final CustomReportDataSource serverObject = new CustomReportDataSourceImpl(); serverObject.setServiceClass(expectedServiceClass); serverObject.setDataSourceName(expectedDataSourceName); Map<String, String> properties = new HashMap<String, String>(); properties.put(expectedPropertyKey1, expectedPropertyValue1); properties.put(expectedPropertyKey2, expectedPropertyValue2); serverObject.setPropertyMap(properties); propertiesToIgnore.add(expectedPropertyKey2); final ClientCustomDataSource result = converter.resourceSpecificFieldsToClient(clientObject, serverObject, null); assertSame(result, clientObject); assertEquals(result.getServiceClass(), expectedServiceClass); assertEquals(result.getDataSourceName(), expectedDataSourceName); final List<ClientProperty> resultProperties = result.getProperties(); assertNotNull(resultProperties); assertEquals(resultProperties.size(), 1); for(ClientProperty property : resultProperties){ if(expectedPropertyKey1.equals(property.getKey())){ assertEquals(property.getValue(), expectedPropertyValue1); } else { fail("This property should not be here"); } } }