PortSchemaFunction implements Function<PortDTO, PortSchema> { @Override public PortSchema apply(PortDTO portDTO) { Map<String, Object> map = new HashMap<>(); map.put(ID_KEY, portDTO.getId()); map.put(NAME_KEY, portDTO.getName()); return new PortSchema(map, wrapperName); } PortSchemaFunction(String wrapperName); @Override PortSchema apply(PortDTO portDTO);  }
@Test public void testFullMap() { PortSchema portSchema = portSchemaFunction.apply(portDTO); assertEquals(testId, portSchema.getId()); assertEquals(testName, portSchema.getName()); assertTrue(portSchema.isValid()); }
@Test public void testNoId() { portDTO.setId(null); PortSchema portSchema = portSchemaFunction.apply(portDTO); assertEquals("", portSchema.getId()); assertEquals(testName, portSchema.getName()); assertFalse(portSchema.isValid()); }
@Test public void testNoName() { portDTO.setName(null); PortSchema portSchema = portSchemaFunction.apply(portDTO); assertEquals(testId, portSchema.getId()); assertEquals("", portSchema.getName()); assertTrue(portSchema.isValid()); }