Search in sources :

Example 1 with ExecutionServerCommand

use of org.kie.camel.container.api.ExecutionServerCommand in project droolsjbpm-integration by kiegroup.

the class AbstractRemoteIntegrationTest method findActiveProcesses.

protected List<ProcessInstance> findActiveProcesses() {
    final List<Integer> statuses = Arrays.asList(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE);
    final Map<String, Object> parameters = new HashMap<>();
    parameters.put("status", statuses);
    parameters.put("page", "0");
    parameters.put("pageSize", "100");
    final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
    executionServerCommand.setClient("query");
    executionServerCommand.setOperation("findProcessInstancesByStatus");
    executionServerCommand.setParameters(parameters);
    final Object response = runOnExecutionServer(executionServerCommand);
    final List<ProcessInstance> processInstances = (List<ProcessInstance>) response;
    return processInstances;
}
Also used : HashMap(java.util.HashMap) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) List(java.util.List) ExecutionServerCommand(org.kie.camel.container.api.ExecutionServerCommand)

Example 2 with ExecutionServerCommand

use of org.kie.camel.container.api.ExecutionServerCommand in project droolsjbpm-integration by kiegroup.

the class AbstractRemoteIntegrationTest method teardown.

@After
public void teardown() {
    final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
    executionServerCommand.setClient("kieServices");
    executionServerCommand.setOperation("disposeContainer");
    executionServerCommand.addParameter("id", CONTAINER_ID);
    runOnExecutionServer(executionServerCommand);
}
Also used : ExecutionServerCommand(org.kie.camel.container.api.ExecutionServerCommand) After(org.junit.After)

Example 3 with ExecutionServerCommand

use of org.kie.camel.container.api.ExecutionServerCommand in project droolsjbpm-integration by kiegroup.

the class AbstractRemoteIntegrationTest method sendSignalToProcessInstance.

protected void sendSignalToProcessInstance(final String containerId, final Long processInstanceId, final String signalName) {
    final Map<String, Object> parameters = new HashMap<>();
    parameters.put("containerId", containerId);
    parameters.put("processInstanceId", processInstanceId);
    parameters.put("signalName", signalName);
    parameters.put("event", null);
    final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
    executionServerCommand.setClient("process");
    executionServerCommand.setOperation("signalProcessInstance");
    executionServerCommand.setParameters(parameters);
    runOnExecutionServer(executionServerCommand);
}
Also used : HashMap(java.util.HashMap) ExecutionServerCommand(org.kie.camel.container.api.ExecutionServerCommand)

Example 4 with ExecutionServerCommand

use of org.kie.camel.container.api.ExecutionServerCommand in project droolsjbpm-integration by kiegroup.

the class AbstractRemoteIntegrationTest method startProcess.

protected Long startProcess(final String containerId, final String processId) {
    final Map<String, Object> parameters = new HashMap<>();
    parameters.put("containerId", containerId);
    parameters.put("processId", processId);
    final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
    executionServerCommand.setClient("process");
    executionServerCommand.setOperation("startProcess");
    executionServerCommand.setParameters(parameters);
    final Object response = runOnExecutionServer(executionServerCommand);
    Assertions.assertThat(response).isNotNull();
    Assertions.assertThat(response).isInstanceOf(Long.class);
    final Long processInstanceId = (Long) response;
    Assertions.assertThat(processInstanceId).isGreaterThan(0);
    return processInstanceId;
}
Also used : HashMap(java.util.HashMap) ExecutionServerCommand(org.kie.camel.container.api.ExecutionServerCommand)

Example 5 with ExecutionServerCommand

use of org.kie.camel.container.api.ExecutionServerCommand in project droolsjbpm-integration by kiegroup.

the class DMNClientIntegrationTest method testEvaluateAll.

@Test
public void testEvaluateAll() {
    final DMNContext dmnContext = createDMNContext();
    dmnContext.set("a", 10);
    dmnContext.set("b", 5);
    final Map<String, Object> parameters = new HashMap<>();
    parameters.put("containerId", CONTAINER_ID);
    final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
    executionServerCommand.setClient("dmn");
    executionServerCommand.setOperation("evaluateAll");
    executionServerCommand.setParameters(parameters);
    executionServerCommand.setBody(dmnContext);
    final Object results = runOnExecutionServer(executionServerCommand);
    Assertions.assertThat(results).isNotNull();
    Assertions.assertThat(results).isInstanceOf(DMNResult.class);
    final DMNResult dmnResult = (DMNResult) results;
    Map<String, Object> map = (Map<String, Object>) dmnResult.getContext().get("Math");
    Assertions.assertThat(map.get("Sum")).isEqualTo(BigDecimal.valueOf(15));
}
Also used : DMNResult(org.kie.dmn.api.core.DMNResult) HashMap(java.util.HashMap) DMNContext(org.kie.dmn.api.core.DMNContext) ExecutionServerCommand(org.kie.camel.container.api.ExecutionServerCommand) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

ExecutionServerCommand (org.kie.camel.container.api.ExecutionServerCommand)40 HashMap (java.util.HashMap)33 Test (org.junit.Test)22 List (java.util.List)13 ProcessDefinition (org.kie.server.api.model.definition.ProcessDefinition)11 Map (java.util.Map)9 QueryDefinition (org.kie.server.api.model.definition.QueryDefinition)9 ProcessInstance (org.kie.server.api.model.instance.ProcessInstance)9 Arrays (java.util.Arrays)8 Collectors (java.util.stream.Collectors)8 Assertions (org.assertj.core.api.Assertions)8 SolverInstance (org.kie.server.api.model.instance.SolverInstance)4 TaskSummary (org.kie.server.api.model.instance.TaskSummary)4 KieContainerResource (org.kie.server.api.model.KieContainerResource)3 After (org.junit.After)2 Before (org.junit.Before)2 DMNContext (org.kie.dmn.api.core.DMNContext)2 ArrayList (java.util.ArrayList)1 BatchExecutionCommandImpl (org.drools.core.command.runtime.BatchExecutionCommandImpl)1 FireAllRulesCommand (org.drools.core.command.runtime.rule.FireAllRulesCommand)1