ConsumerTypeImporter { public void store(Set<ConsumerType> consumerTypes) { log.debug("Creating/updating consumer types"); for (ConsumerType consumerType : consumerTypes) { if (curator.getByLabel(consumerType.getLabel()) == null) { curator.create(consumerType); log.debug("Created consumer type: " + consumerType.getLabel()); } } } ConsumerTypeImporter(ConsumerTypeCurator curator); ConsumerType createObject(ObjectMapper mapper, Reader reader); void store(Set<ConsumerType> consumerTypes);  }
@Test public void testSingleConsumerTypeInDbAndListCausesNoChange() { final ConsumerType testType = new ConsumerType(); testType.setLabel("prosumer"); ConsumerTypeCurator curator = mock(ConsumerTypeCurator.class); when(curator.getByLabel("prosumer")).thenReturn(testType); ConsumerTypeImporter importer = new ConsumerTypeImporter(curator); importer.store(new HashSet<ConsumerType>() { { add(testType); } }); verify(curator, never()).create(testType); verify(curator, never()).merge(testType); }
@Test public void testSingleConsumerTypeInListEmptyDbCausesInsert() { final ConsumerType testType = new ConsumerType(); testType.setLabel("prosumer"); ConsumerTypeCurator curator = mock(ConsumerTypeCurator.class); when(curator.getByLabel("prosumer")).thenReturn(null); ConsumerTypeImporter importer = new ConsumerTypeImporter(curator); importer.store(new HashSet<ConsumerType>() { { add(testType); } }); verify(curator).create(testType); verify(curator, never()).merge(testType); }