### Question:
MarshallerHelper { public <T> T unmarshal(String containerId, String data, String marshallingFormat, Class<T> unmarshalType) { return unmarshal(containerId, data, marshallingFormat, unmarshalType, 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 testUnmarshallWithoutContainer() { KieServerRegistry kieServerRegistryMock = Mockito.mock(KieServerRegistry.class); MarshallerHelper helper = new MarshallerHelper(kieServerRegistryMock); QueryFilterSpec expectedQueryFilterSpec = new QueryFilterSpecBuilder().get(); String marshalledQFS = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<query-filter-spec>" + "<order-asc>false</order-asc>" + "</query-filter-spec>"; QueryFilterSpec unmarshalledQFS = helper.unmarshal(marshalledQFS, MarshallingFormat.JAXB.toString(), QueryFilterSpec.class); assertThat(expectedQueryFilterSpec, new ReflectionEquals(unmarshalledQFS)); }
@Test public void testUnmarshallWithoutNullRegistry() { MarshallerHelper helper = new MarshallerHelper(null); QueryFilterSpec expectedQueryFilterSpec = new QueryFilterSpecBuilder().get(); String marshalledQFS = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<query-filter-spec>" + "<order-asc>false</order-asc>" + "</query-filter-spec>"; QueryFilterSpec unmarshalledQFS = helper.unmarshal(marshalledQFS, MarshallingFormat.JAXB.toString(), QueryFilterSpec.class); assertThat(expectedQueryFilterSpec, new ReflectionEquals(unmarshalledQFS)); }
@Test public void testJsonUnmarshallQueryFilterSpec() { MarshallerHelper helper = new MarshallerHelper(null); String marshalledQFS = "{\"order-by\" : null, \"order-asc\" : false, \"query-params\" : null, \"result-column-mapping\" : null}"; QueryFilterSpec qfs = helper.unmarshal(marshalledQFS, MarshallingFormat.JSON.toString(), QueryFilterSpec.class); }
@Test public void testJsonUnmarshallProcessInstanceQueryFilterSpec() { ProcessInstanceQueryFilterSpec expectedPiQfs = new ProcessInstanceQueryFilterSpecBuilder().get(); MarshallerHelper helper = new MarshallerHelper(null); String marshalledQFS = "{\"order-by\" : null,\"order-asc\" : false,\"query-params\" : null}"; ProcessInstanceQueryFilterSpec unmarshalledPiQfs = helper.unmarshal(marshalledQFS, MarshallingFormat.JSON.toString(), ProcessInstanceQueryFilterSpec.class); assertThat(expectedPiQfs, new ReflectionEquals(unmarshalledPiQfs)); }
@Test public void testJsonUnmarshallTaskQueryFilterSpec() { TaskQueryFilterSpec expectedTaskQfs = new TaskQueryFilterSpecBuilder().get(); MarshallerHelper helper = new MarshallerHelper(null); String marshalledQFS = "{\"order-by\" : null, \"order-asc\" : false, \"query-params\" : null}"; TaskQueryFilterSpec unmarshalledTaskQfs = helper.unmarshal(marshalledQFS, MarshallingFormat.JSON.toString(), TaskQueryFilterSpec.class); assertThat(expectedTaskQfs, new ReflectionEquals(unmarshalledTaskQfs)); }