CsvMarshaller implements Marshaller { @Override public void marshal(Object obj, OutputStream out) { String result = marshal(obj); OutputStreamWriter writer = new OutputStreamWriter(out); try { writer.write(result); } catch (Exception e) { LOGGER.warn("Can't marshal on the output stream", e); } }  @Activate void activate(ComponentContext componentContext); @Override void marshal(Object obj, OutputStream out); @Override String marshal(Object obj);  }
@Test public void testMarshal() throws Exception { Marshaller marshaller = new CsvMarshaller(); Map<String, Object> map = new HashMap<>(); map.put(EventConstants.TIMESTAMP, EXPECTED_TIMESTAMP); map.put("c", "d"); String marshalled = marshaller.marshal(new Event(EXPECTED_TOPIC, map)); System.out.println(marshalled); Assert.assertEquals("c=d,timestamp=1454428780634,event.topics=testTopic", marshalled); }
@Test public void testInnerMap() throws Exception { Marshaller marshaller = new CsvMarshaller(); Map<String, Object> map = new HashMap<>(); map.put(EventConstants.TIMESTAMP, EXPECTED_TIMESTAMP); map.put("test", "test"); Map<String, Object> inner = new HashMap<>(); inner.put("other", "other"); map.put("inner", inner); String marshalled = marshaller.marshal(new Event(EXPECTED_TOPIC, map)); System.out.println(marshalled); Assert.assertEquals("test=test,inner={other=other},timestamp=1454428780634,event.topics=testTopic", marshalled); }