Search in sources :

Example 21 with ProcessDefinition

use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.

the class KieCamelRemoteIntegrationTest method testGetProcessDefinition.

@Test
public void testGetProcessDefinition() {
    final Map<String, Object> parameters = new HashMap<>();
    parameters.put("containerId", KieServerConstants.containerId);
    parameters.put("processId", KieServerConstants.processId);
    final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
    executionServerCommand.setClient("process");
    executionServerCommand.setOperation("getProcessDefinition");
    executionServerCommand.setParameters(parameters);
    final Object response = remoteExecutionService.runOnExecServer(executionServerCommand);
    Assert.assertNotNull(response);
    Assert.assertTrue(response instanceof ProcessDefinition);
    final ProcessDefinition processDefinition = (ProcessDefinition) response;
    Assert.assertEquals("Evaluation", processDefinition.getName());
    Assert.assertEquals("1", processDefinition.getVersion());
}
Also used : HashMap(java.util.HashMap) ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition) ExecutionServerCommand(org.kie.karaf.itest.camel.kiecamel.tools.ExecutionServerCommand) AbstractKarafIntegrationTest(org.kie.karaf.itest.AbstractKarafIntegrationTest) Test(org.junit.Test)

Example 22 with ProcessDefinition

use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.

the class ProcessServicesClientImpl method getProcessDefinition.

@Override
public ProcessDefinition getProcessDefinition(String containerId, String processId) {
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(PROCESS_ID, processId);
        return makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), PROCESS_DEF_URI + "/" + PROCESS_DEF_GET_URI, valuesMap), ProcessDefinition.class);
    } else {
        CommandScript script = new CommandScript(singletonList((KieServerCommand) new DescriptorCommand("DefinitionService", "getProcessDefinition", new Object[] { containerId, processId })));
        ServiceResponse<ProcessDefinition> response = (ServiceResponse<ProcessDefinition>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        return response.getResult();
    }
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript) ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition)

Example 23 with ProcessDefinition

use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.

the class KieServerRouterMultiNodeTest method testFalseAggregatableMultipleResponseRouter.

@Test
public void testFalseAggregatableMultipleResponseRouter() throws Exception {
    ResponseDefinitionBuilder resp1 = aResponse().withHeader(CONTENT_TYPE, MEDIA_TYPE_AGGREGATABLE_FALSE).withBody(bodyProcessDefinition1);
    ResponseDefinitionBuilder resp2 = aResponse().withHeader(CONTENT_TYPE, MEDIA_TYPE_AGGREGATABLE_FALSE).withBody(bodyProcessDefinition2);
    server1.stubFor(get(urlEqualTo(PROCESSES_DEFINITIONS_PATH)).willReturn(resp1));
    server2.stubFor(get(urlEqualTo(PROCESSES_DEFINITIONS_PATH)).willReturn(resp2));
    QueryServicesClient queries = initRouterClient();
    List<ProcessDefinition> lpi = queries.findProcesses(0, 10);
    assertNotNull(lpi);
    assertThat(lpi).hasSize(1);
}
Also used : ResponseDefinitionBuilder(com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder) QueryServicesClient(org.kie.server.client.QueryServicesClient) ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition) Test(org.junit.Test)

Example 24 with ProcessDefinition

use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.

the class KieServerRouterMultiNodeTest method testAggregates.

private void testAggregates() {
    QueryServicesClient queries = initRouterClient();
    List<ProcessDefinition> lpi = queries.findProcesses(0, 10);
    assertNotNull(lpi);
    assertThat(lpi).hasSize(2);
    List<String> names = lpi.stream().map(ni -> ni.getName()).collect(Collectors.toList());
    assertThat(names).contains("Evaluation updated", "Other evaluation process");
}
Also used : HttpURLConnection(java.net.HttpURLConnection) KieServerRouterConstants(org.kie.server.router.KieServerRouterConstants) KieServicesConfiguration(org.kie.server.client.KieServicesConfiguration) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) Configuration(org.kie.server.router.Configuration) URISyntaxException(java.net.URISyntaxException) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition) MappingBuilder(com.github.tomakehurst.wiremock.client.MappingBuilder) ArrayList(java.util.ArrayList) WireMock(com.github.tomakehurst.wiremock.client.WireMock) ServerSocket(java.net.ServerSocket) WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) KieServicesClient(org.kie.server.client.KieServicesClient) WireMockRule(com.github.tomakehurst.wiremock.junit.WireMockRule) JSONObject(org.json.JSONObject) QueryServicesClient(org.kie.server.client.QueryServicesClient) After(org.junit.After) MarshallingFormat(org.kie.server.api.marshalling.MarshallingFormat) URI(java.net.URI) Before(org.junit.Before) OutputStream(java.io.OutputStream) KieServerRouter(org.kie.server.router.KieServerRouter) ResponseDefinitionBuilder(com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder) Files(java.nio.file.Files) Assert.assertNotNull(org.junit.Assert.assertNotNull) IOException(java.io.IOException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) KieServerRouterEnvironment(org.kie.server.router.KieServerRouterEnvironment) File(java.io.File) List(java.util.List) Stream(java.util.stream.Stream) Rule(org.junit.Rule) Paths(java.nio.file.Paths) KieServicesFactory(org.kie.server.client.KieServicesFactory) KieServerRouterClient(org.kie.server.integrationtests.router.client.KieServerRouterClient) QueryServicesClient(org.kie.server.client.QueryServicesClient) ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition)

Aggregations

ProcessDefinition (org.kie.server.api.model.definition.ProcessDefinition)24 Test (org.junit.Test)19 HashMap (java.util.HashMap)16 ProcessInstance (org.kie.server.api.model.instance.ProcessInstance)10 QueryServicesClient (org.kie.server.client.QueryServicesClient)8 List (java.util.List)6 ExecutionServerCommand (org.kie.camel.container.api.ExecutionServerCommand)6 ProcessServicesClient (org.kie.server.client.ProcessServicesClient)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 Collectors (java.util.stream.Collectors)4 Arrays (java.util.Arrays)3 Map (java.util.Map)3 Assertions (org.assertj.core.api.Assertions)3 ServiceResponse (org.kie.server.api.model.ServiceResponse)3 QueryDefinition (org.kie.server.api.model.definition.QueryDefinition)3 ResponseDefinitionBuilder (com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder)2 ArrayList (java.util.ArrayList)2 CommandScript (org.kie.server.api.commands.CommandScript)2 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)2 KieServerCommand (org.kie.server.api.model.KieServerCommand)2