Search in sources :

Example 41 with Marshaller

use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.

the class DroolsCommandsMarshallingTest method roundTrip.

private <T> T roundTrip(T obj) {
    Class<T> type = (Class<T>) obj.getClass();
    Marshaller marshaller = marshallerBuilder.build(extraClasses, marshallingFormat, getClass().getClassLoader());
    String strOut = marshaller.marshall(obj);
    return marshaller.unmarshall(strOut, type);
}
Also used : Marshaller(org.kie.server.api.marshalling.Marshaller) BeforeClass(org.junit.BeforeClass)

Example 42 with Marshaller

use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.

the class MarshallingRoundTripCustomClassListTest method testJSONTypeInfoTopLevelOnly.

@Test
public void testJSONTypeInfoTopLevelOnly() {
    Marshaller marshaller = MarshallerFactory.getMarshaller(getCustomClasses(), MarshallingFormat.JSON, getClass().getClassLoader());
    String rawContent = "{\"org.kie.server.api.marshalling.objects.PojoA\": " + "{\"name\": \"A\"," + " \"pojoBList\":" + " [{\"name\": \"B1\"," + "   \"pojoCList\":" + "    [" + "      {\"name\": \"C1\"}, " + "      {\"name\": \"C2\"}" + "    ]" + "  }," + "  {\"name\": \"B2\"," + "   \"pojoCList\":" + "    [" + "     {\"name\": \"C3\"}" + "    ]" + "  }" + " ]," + " \"stringList\":" + "  [\"Hello\", \"Bye\"]" + "}}";
    Object unmarshalledObject = marshaller.unmarshall(rawContent, PojoA.class);
    Assertions.assertThat(unmarshalledObject).isEqualTo(createTestObject());
}
Also used : Marshaller(org.kie.server.api.marshalling.Marshaller) Test(org.junit.Test)

Example 43 with Marshaller

use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.

the class MarshallingRoundTripCustomClassListTest method testXStream.

@Test
public void testXStream() {
    Marshaller marshaller = MarshallerFactory.getMarshaller(getCustomClasses(), MarshallingFormat.XSTREAM, getClass().getClassLoader());
    verifyMarshallingRoundTrip(marshaller, createTestObject());
}
Also used : Marshaller(org.kie.server.api.marshalling.Marshaller) Test(org.junit.Test)

Example 44 with Marshaller

use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.

the class MarshallingRoundTripCustomClassListTest method testJaxb.

@Test
public void testJaxb() {
    Marshaller marshaller = MarshallerFactory.getMarshaller(getCustomClasses(), MarshallingFormat.JAXB, getClass().getClassLoader());
    verifyMarshallingRoundTrip(marshaller, createTestObject());
}
Also used : Marshaller(org.kie.server.api.marshalling.Marshaller) Test(org.junit.Test)

Example 45 with Marshaller

use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.

the class MarshallingRoundTripNestedClassesTest method testJaxb.

@Test
public void testJaxb() {
    Marshaller marshaller = MarshallerFactory.getMarshaller(getCustomClasses(), MarshallingFormat.JAXB, getClass().getClassLoader());
    verifyMarshallingRoundTrip(marshaller, createTestObject());
}
Also used : Marshaller(org.kie.server.api.marshalling.Marshaller) Test(org.junit.Test)

Aggregations

Marshaller (org.kie.server.api.marshalling.Marshaller)65 Test (org.junit.Test)48 HashMap (java.util.HashMap)12 WebTarget (javax.ws.rs.client.WebTarget)11 BeforeClass (org.junit.BeforeClass)10 ArrayList (java.util.ArrayList)9 MarshallingFormat (org.kie.server.api.marshalling.MarshallingFormat)9 Response (javax.ws.rs.core.Response)8 BatchExecutionCommand (org.kie.api.command.BatchExecutionCommand)8 Command (org.kie.api.command.Command)8 ExecutionResults (org.kie.api.runtime.ExecutionResults)8 HashSet (java.util.HashSet)7 JaxbLong (org.kie.server.api.model.type.JaxbLong)6 KieContainerInstance (org.kie.server.services.api.KieContainerInstance)4 CallContainerCommand (org.kie.server.api.commands.CallContainerCommand)3 KieContainerResource (org.kie.server.api.model.KieContainerResource)3 KieServerCommand (org.kie.server.api.model.KieServerCommand)3 ServiceResponse (org.kie.server.api.model.ServiceResponse)3 Date (java.util.Date)2 BatchExecutionCommandImpl (org.drools.core.command.runtime.BatchExecutionCommandImpl)2