ProductExporter { public void export(ObjectMapper mapper, Writer writer, Product product) throws IOException { mapper.writeValue(writer, this.translator.translate(product, ProductDTO.class)); } @Inject  ProductExporter(ModelTranslator translator); void export(ObjectMapper mapper, Writer writer, Product product);  }
@Test public void testProductExport() throws IOException { ObjectMapper mapper = TestSyncUtils.getTestSyncUtils(new MapConfiguration( new HashMap<String, String>() { { put(ConfigProperties.FAIL_ON_UNKNOWN_IMPORT_PROPERTIES, "false"); } } )); ProductExporter exporter = new ProductExporter( new StandardTranslator(new ConsumerTypeCurator(), new EnvironmentCurator(), new OwnerCurator())); StringWriter writer = new StringWriter(); Owner owner = TestUtil.createOwner("Example-Corporation"); Product product = TestUtil.createProduct("my-id", "product name"); exporter.export(mapper, writer, product); String s = writer.toString(); assertTrue(s.contains("\"name\":\"product name\"")); assertTrue(s.contains("\"id\":\"my-id\"")); assertTrue(s.contains("\"productContent\":[]")); assertTrue(s.contains("\"attributes\":[]")); assertTrue(s.contains("\"multiplier\":1")); }