use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.
the class CaseServiceRestOnlyIntegrationTest method testAddDynamicWorkItemTaskNotExistingContainer.
@Test
public void testAddDynamicWorkItemTaskNotExistingContainer() {
Marshaller marshaller = MarshallerFactory.getMarshaller(marshallingFormat, ClassLoader.getSystemClassLoader());
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(RestURI.CONTAINER_ID, "not-existing-id");
valuesMap.put(RestURI.CASE_ID, "not-existing-id");
Map<String, Object> taskSpecMap = new HashMap<String, Object>();
taskSpecMap.put(KieServerConstants.CASE_DYNAMIC_NAME_PROP, "Contact car producer");
taskSpecMap.put(KieServerConstants.CASE_DYNAMIC_NODE_TYPE_PROP, "ContactCarProducer");
WebTarget clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), RestURI.CASE_URI + "/" + RestURI.CASE_DYNAMIC_TASK_POST_URI, valuesMap));
logger.debug("Add dynamic work item: [POST] " + clientRequest.getUri());
response = clientRequest.request(getMediaType()).post(createEntity(marshaller.marshall(taskSpecMap)));
Assert.assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
}
use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.
the class MarshallerHelper method unmarshal.
public <T> T unmarshal(String data, String marshallingFormat, Class<T> unmarshalType) {
if (data == null || data.isEmpty()) {
return null;
}
MarshallingFormat format = getFormat(marshallingFormat);
Marshaller marshaller = serverMarshallers.get(format);
if (marshaller == null) {
marshaller = MarshallerFactory.getMarshaller(getExtraClasses(registry), format, this.getClass().getClassLoader());
serverMarshallers.put(format, marshaller);
}
Object instance = marshaller.unmarshall(data, unmarshalType, MarshallingFormat.buildParameters(marshallingFormat));
if (instance instanceof Wrapped) {
return (T) ((Wrapped) instance).unwrap();
}
return (T) instance;
}
use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.
the class TaskAssigningRuntimeResourceTest method executeFindTasksQuery.
@Test
public void executeFindTasksQuery() {
Marshaller marshaller = MarshallerFactory.getMarshaller(XSTREAM, this.getClass().getClassLoader());
Map<String, Object> params = new HashMap<>();
params.put("param", "value");
String payload = marshaller.marshall(params);
List<TaskData> expectedResult = new ArrayList<>();
expectedResult.add(TaskData.builder().taskId(1L).name("SomeTask").build());
when(runtimeServiceBase.executeFindTasksQuery(eq(params))).thenReturn(expectedResult);
String rawResult = resource.executeTasksQuery(httpHeaders, payload).getEntity().toString();
TaskDataList unMarshalledResult = marshaller.unmarshall(rawResult, TaskDataList.class);
assertEquals(expectedResult, unMarshalledResult.getItems());
}
use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.
the class TaskAssigningRuntimeResourceTest method executePlanning.
@Test
public void executePlanning() {
Marshaller marshaller = MarshallerFactory.getMarshaller(XSTREAM, this.getClass().getClassLoader());
PlanningItemList planningItemList = new PlanningItemList();
String payload = marshaller.marshall(planningItemList);
PlanningExecutionResult expectedResult = PlanningExecutionResult.builder().build();
when(runtimeServiceBase.executePlanning(eq(planningItemList), eq(USER_ID))).thenReturn(expectedResult);
String rawResult = resource.executePlanning(httpHeaders, USER_ID, payload).getEntity().toString();
String expectedResultInRawFormat = marshaller.marshall(expectedResult);
assertEquals(expectedResultInRawFormat, rawResult);
}
use of org.kie.server.api.marshalling.Marshaller in project droolsjbpm-integration by kiegroup.
the class TaskAssigningRuntimeKieServerExtension method registerQueries.
private void registerQueries() throws IOException {
try (InputStream stream = this.getClass().getResourceAsStream(TASK_ASSIGNING_QUERY_DEFINITIONS_RESOURCE)) {
if (stream == null) {
throw new FileNotFoundException(QUERIES_RESOURCE_NOT_FOUND);
}
final Marshaller marshaller = MarshallerFactory.getMarshaller(MarshallingFormat.JSON, getClass().getClassLoader());
final String queriesString = IOUtils.toString(stream, StandardCharsets.UTF_8);
final QueryDefinition[] queries = marshaller.unmarshall(queriesString, QueryDefinition[].class);
if (queries == null || queries.length == 0) {
LOGGER.info("No queries were found");
return;
}
registerQueries(queries);
}
}
Aggregations