ConsumerImporter { public ConsumerDTO createObject(ObjectMapper mapper, Reader reader) throws IOException { return mapper.readValue(reader, ConsumerDTO.class); } ConsumerImporter(OwnerCurator curator, IdentityCertificateCurator idCertCurator, I18n i18n,
        CertificateSerialCurator serialCurator); ConsumerDTO createObject(ObjectMapper mapper, Reader reader); void store(Owner owner, ConsumerDTO consumer, ConflictOverrides forcedConflicts,
        IdentityCertificate idcert);  }
@Test public void importShouldCreateAValidConsumer() throws IOException { ConsumerDTO consumer = importer.createObject(mapper, new StringReader("{\"uuid\":\"test-uuid\",\"name\":\"test-name\"}")); assertEquals("test-uuid", consumer.getUuid()); assertEquals("test-name", consumer.getName()); }
@Test public void importHandlesUnknownPropertiesGracefully() throws Exception { Map<String, String> configProps = new HashMap<>(); configProps.put(ConfigProperties.FAIL_ON_UNKNOWN_IMPORT_PROPERTIES, "false"); mapper = TestSyncUtils.getTestSyncUtils(new MapConfiguration(configProps)); ConsumerDTO consumer = importer.createObject( mapper, new StringReader("{\"uuid\":\"test-uuid\", \"unknown\":\"notreal\"}")); assertEquals("test-uuid", consumer.getUuid()); }
@Test(expected = JsonMappingException.class) public void importFailsOnUnknownPropertiesWithNonDefaultConfig() throws Exception { Map<String, String> configProps = new HashMap<>(); configProps.put(ConfigProperties.FAIL_ON_UNKNOWN_IMPORT_PROPERTIES, "true"); mapper = TestSyncUtils.getTestSyncUtils(new MapConfiguration(configProps)); importer.createObject(mapper, new StringReader( "{\"uuid\":\"test-uuid\", \"unknown\":\"notreal\"}")); }