### Question:
JsonEntitySerializer implements EntitySerializer { @Override public void serialize(final Object entity, final OutputStream out) throws IOException { final JsonFactory factory = new JsonFactory(); final JsonGenerator generator = factory.createGenerator(out); generator.setCodec(jsonCodec); generator.writeObject(entity); generator.flush(); } JsonEntitySerializer(final ObjectMapper jsonCodec); @Override void serialize(final Object entity, final OutputStream out);  }### Answer:
@Test public void testSerializeProcessor() throws IOException { final ObjectMapper jsonCodec = new ObjectMapper(); jsonCodec.registerModule(new JaxbAnnotationModule()); jsonCodec.setSerializationInclusion(Include.NON_NULL); final JsonEntitySerializer serializer = new JsonEntitySerializer(jsonCodec); try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) { final ProcessorConfigDTO configDto = new ProcessorConfigDTO(); configDto.setProperties(Collections.singletonMap("key", "value")); final ProcessorDTO processorDto = new ProcessorDTO(); processorDto.setConfig(configDto); final ProcessorEntity processor = new ProcessorEntity(); processor.setId("123"); processor.setComponent(processorDto); serializer.serialize(processor, baos); final String serialized = new String(baos.toByteArray(), StandardCharsets.UTF_8); assertEquals("{\"id\":\"123\",\"component\":{\"config\":{\"properties\":{\"key\":\"value\"}}}}", serialized); } }
@Test public void testBulletinEntity() throws Exception { final ObjectMapper jsonCodec = new ObjectMapper(); jsonCodec.registerModule(new JaxbAnnotationModule()); jsonCodec.setSerializationInclusion(Include.NON_NULL); final Date timestamp = new Date(); final TimeAdapter adapter = new TimeAdapter(); final String formattedTimestamp = adapter.marshal(timestamp); final JsonEntitySerializer serializer = new JsonEntitySerializer(jsonCodec); try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) { final BulletinDTO bulletinDto = new BulletinDTO(); bulletinDto.setCategory("test"); bulletinDto.setLevel("INFO"); bulletinDto.setTimestamp(timestamp); final BulletinEntity bulletin = new BulletinEntity(); bulletin.setBulletin(bulletinDto); serializer.serialize(bulletin, baos); final String serialized = new String(baos.toByteArray(), StandardCharsets.UTF_8); assertEquals("{\"bulletin\":{\"category\":\"test\",\"level\":\"INFO\",\"timestamp\":\"" + formattedTimestamp + "\"}}", serialized); } }