XmlRecordMarshaller implements RecordMarshaller<P, String> { @Override public XmlRecord processRecord(final Record<P> record) throws Exception { StringWriter stringWriter = new StringWriter(); marshaller.marshal(record.getPayload(), stringWriter); return new XmlRecord(record.getHeader(), stringWriter.toString()); } XmlRecordMarshaller(final Class<P> type);  XmlRecordMarshaller(final JAXBContext jaxbContext); @Override XmlRecord processRecord(final Record<P> record);  }
@Test public void testRecordMarshalling() throws Exception { Person person = new Person(1, "foo", "bar", null, false); when(record.getHeader()).thenReturn(header); when(record.getPayload()).thenReturn(person); XmlRecordMarshaller<Person> xmlRecordMarshaller = new XmlRecordMarshaller<>(Person.class); String expected = "<person><firstName>foo</firstName><id>1</id><lastName>bar</lastName><married>false</married></person>"; XmlRecord actual = xmlRecordMarshaller.processRecord(record); assertThat(actual.getHeader()).isEqualTo(header); assertThat(actual.getPayload()).isXmlEqualTo(expected); }