ConsumerTypeImporter { public ConsumerType createObject(ObjectMapper mapper, Reader reader) throws IOException { ConsumerTypeDTO consumerTypeDTO = mapper.readValue(reader, ConsumerTypeDTO.class); ConsumerType consumerType = new ConsumerType(); consumerType.setManifest( consumerTypeDTO.isManifest() != null ? consumerTypeDTO.isManifest() : false); consumerType.setLabel(consumerTypeDTO.getLabel()); consumerType.setId(null); return consumerType; } ConsumerTypeImporter(ConsumerTypeCurator curator); ConsumerType createObject(ObjectMapper mapper, Reader reader); void store(Set<ConsumerType> consumerTypes);  }
@Test public void testDeserialize() throws IOException { String consumerTypeString = "{\"id\":15, \"label\":\"prosumer\"}"; Reader reader = new StringReader(consumerTypeString); ConsumerType consumerType = new ConsumerTypeImporter(null).createObject( TestSyncUtils.getTestSyncUtils(config), reader); assertEquals("prosumer", consumerType.getLabel()); }
@Test public void testDeserializeIdIsNull() throws IOException { String consumerTypeString = "{\"id\":15, \"label\":\"prosumer\"}"; Reader reader = new StringReader(consumerTypeString); ConsumerType consumerType = new ConsumerTypeImporter(null).createObject( TestSyncUtils.getTestSyncUtils(config), reader); assertEquals(null, consumerType.getId()); }