### Question:
MarshallerHelper { public String marshal(String containerId, String marshallingFormat, Object entity) { return marshal(containerId, marshallingFormat, entity, ContainerLocatorProvider.get().getLocator()); } MarshallerHelper(KieServerRegistry registry); KieServerRegistry getRegistry(); String marshal(String containerId, String marshallingFormat, Object entity); String marshal(String containerId, String marshallingFormat, Object entity, ContainerLocator locator); String marshal(String marshallingFormat, Object entity); T unmarshal(String containerId, String data, String marshallingFormat, Class<T> unmarshalType); T unmarshal(String containerId, String data, String marshallingFormat, Class<T> unmarshalType, ContainerLocator locator); T unmarshal(String data, String marshallingFormat, Class<T> unmarshalType); static MarshallingFormat getFormat(String descriptor);  }### Answer:
@Test public void testMarshallWithoutContainer() { KieServerRegistry kieServerRegistryMock = Mockito.mock(KieServerRegistry.class); MarshallerHelper helper = new MarshallerHelper(kieServerRegistryMock); QueryFilterSpec queryFilterSpec = new QueryFilterSpecBuilder().get(); String marshalledQFS = helper.marshal(MarshallingFormat.JAXB.toString(), queryFilterSpec); String expectedMarshalledQFS = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<query-filter-spec>" + "<order-asc>false</order-asc>" + "</query-filter-spec>"; assertThat(marshalledQFS, CompareMatcher.isIdenticalTo(expectedMarshalledQFS).ignoreWhitespace()); }
@Test public void testJsonMarshallWithNullRegistry() throws Exception { MarshallerHelper helper = new MarshallerHelper(null); QueryFilterSpec queryFilterSpec = new QueryFilterSpecBuilder().get(); String marshalledQFS = helper.marshal(MarshallingFormat.JSON.toString(), queryFilterSpec); System.out.println(marshalledQFS); String expectedMarshalledTEC = "{\"order-by\" : null, \"order-asc\" : false, \"query-params\" : null, \"result-column-mapping\" : null}"; JSONAssert.assertEquals(expectedMarshalledTEC, marshalledQFS, false); }
@Test public void testMarshallWithNullRegistry() { MarshallerHelper helper = new MarshallerHelper(null); QueryFilterSpec queryFilterSpec = new QueryFilterSpecBuilder().get(); String marshalledQFS = helper.marshal(MarshallingFormat.JAXB.toString(), queryFilterSpec); String expectedMarshalledQFS = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<query-filter-spec>" + "<order-asc>false</order-asc>" + "</query-filter-spec>"; assertThat(marshalledQFS, CompareMatcher.isIdenticalTo(expectedMarshalledQFS).ignoreWhitespace()); }