Search in sources :

Example 6 with KieServicesException

use of org.kie.server.api.exception.KieServicesException in project droolsjbpm-integration by kiegroup.

the class TaskAssigningPlanningKieServerExtension method init.

/**
 * Invoked by the KieServer initialization procedure for performing current extension initialization.
 */
@Override
public void init(KieServerImpl kieServer, KieServerRegistry registry) {
    LOGGER.debug("Initializing " + EXTENSION_NAME + " extension.");
    this.kieServer = kieServer;
    this.registry = registry;
    KieServerExtension jbpmExtension = registry.getServerExtension(JbpmKieServerExtension.EXTENSION_NAME);
    if (jbpmExtension != null) {
        String msg = String.format(UNDESIRED_EXTENSIONS_RUNNING_ERROR, JbpmKieServerExtension.EXTENSION_NAME);
        LOGGER.warn(msg);
        kieServer.addServerMessage(new Message(Severity.WARN, addExtensionMessagePrefix(msg)));
    }
    initRuntimeClient();
    try {
        validateAndSetSolverConfiguration();
    } catch (TaskAssigningValidationException e) {
        throw new KieServicesException(String.format(SOLVER_CONFIGURATION_ERROR, e.getMessage()), e);
    }
    try {
        validateAndSetUserSystemServiceConfiguration();
    } catch (TaskAssigningValidationException e) {
        throw new KieServicesException(String.format(USER_SYSTEM_CONFIGURATION_ERROR, e.getMessage()), e);
    }
    this.executorService = Executors.newScheduledThreadPool(4);
    try {
        this.taskAssigningService = createTaskAssigningService(readAndValidateTaskAssigningServiceConfig());
        this.services.add(taskAssigningService);
    } catch (TaskAssigningValidationException e) {
        throw new KieServicesException(String.format(String.format(TASK_ASSIGNING_SERVICE_CONFIGURATION_ERROR, e.getMessage()), e));
    }
    this.initialized = true;
}
Also used : Message(org.kie.server.api.model.Message) JbpmKieServerExtension(org.kie.server.services.jbpm.JbpmKieServerExtension) KieServerExtension(org.kie.server.services.api.KieServerExtension) KieServicesException(org.kie.server.api.exception.KieServicesException)

Example 7 with KieServicesException

use of org.kie.server.api.exception.KieServicesException in project droolsjbpm-integration by kiegroup.

the class JobServiceIntegrationTest method testExecutorServiceDisabling.

@Test
public void testExecutorServiceDisabling() throws Exception {
    String command = "invalidCommand";
    Map<String, Object> data = new HashMap<String, Object>();
    data.put("businessKey", BUSINESS_KEY);
    Calendar tomorrow = Calendar.getInstance();
    tomorrow.add(Calendar.DATE, 1);
    JobRequestInstance jobRequestInstance = new JobRequestInstance();
    jobRequestInstance.setCommand(command);
    jobRequestInstance.setData(data);
    jobRequestInstance.setScheduledDate(tomorrow.getTime());
    // Executing fist command.
    try {
        jobServicesClient.scheduleRequest(jobRequestInstance);
    } catch (Exception e) {
        assertTrue(e instanceof KieServicesException);
        assertTrue(e.getMessage().contains("Invalid command type"));
    }
}
Also used : JobRequestInstance(org.kie.server.api.model.instance.JobRequestInstance) HashMap(java.util.HashMap) Calendar(java.util.Calendar) KieServicesException(org.kie.server.api.exception.KieServicesException) KieServicesException(org.kie.server.api.exception.KieServicesException) Test(org.junit.Test)

Example 8 with KieServicesException

use of org.kie.server.api.exception.KieServicesException in project droolsjbpm-integration by kiegroup.

the class DocumentServiceIntegrationTest method testCreateLoadDeleteDocument.

@Test
@Category(Smoke.class)
public void testCreateLoadDeleteDocument() throws Exception {
    String documentId = documentClient.createDocument(document);
    assertNotNull(documentId);
    DocumentInstance fromServer = documentClient.getDocument(documentId);
    assertEquals(documentId, fromServer.getIdentifier());
    assertDocumentInstances(document, fromServer, true);
    documentClient.deleteDocument(documentId);
    try {
        documentClient.getDocument(documentId);
        fail("Document with id " + documentId + " was deleted so should not be found anymore");
    } catch (KieServicesException e) {
    // expected
    }
}
Also used : DocumentInstance(org.kie.server.api.model.instance.DocumentInstance) KieServicesException(org.kie.server.api.exception.KieServicesException) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 9 with KieServicesException

use of org.kie.server.api.exception.KieServicesException in project droolsjbpm-integration by kiegroup.

the class DocumentServiceIntegrationTest method testDeleteDocument.

@Test
public void testDeleteDocument() throws Exception {
    String documentId = documentClient.createDocument(document);
    assertNotNull(documentId);
    DocumentInstance fromServer = documentClient.getDocument(documentId);
    assertNotNull(fromServer);
    documentClient.deleteDocument(documentId);
    try {
        documentClient.getDocument(documentId);
        fail("Document with id " + documentId + " was deleted so should not be found anymore");
    } catch (KieServicesException e) {
    // expected
    }
}
Also used : DocumentInstance(org.kie.server.api.model.instance.DocumentInstance) KieServicesException(org.kie.server.api.exception.KieServicesException) Test(org.junit.Test)

Example 10 with KieServicesException

use of org.kie.server.api.exception.KieServicesException in project droolsjbpm-integration by kiegroup.

the class ProcessInstanceMigrationIntegrationTest method testUpgradeProcessInstanceWithNodeMapping.

@Test
public void testUpgradeProcessInstanceWithNodeMapping() {
    Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_EVALUATION);
    try {
        List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
        assertEquals(1, tasks.size());
        TaskSummary task = tasks.get(0);
        assertEquals("Evaluate items?", tasks.get(0).getName());
        assertEquals(CONTAINER_ID, task.getContainerId());
        assertEquals(PROCESS_ID_EVALUATION, task.getProcessId());
        assertEquals(processInstanceId, task.getProcessInstanceId());
        Map<String, String> nodeMapping = new HashMap<String, String>();
        nodeMapping.put("_4E8E7545-FB70-494E-9136-2B9ABE655889", "_56FB3E50-DEDD-415B-94DD-0357C91836B9");
        // migrate process instance to evaluation 2 in container 2
        MigrationReportInstance report = processAdminClient.migrateProcessInstance(CONTAINER_ID, processInstanceId, CONTAINER_ID_2, PROCESS_ID_EVALUATION_2, nodeMapping);
        assertNotNull(report);
        assertTrue(report.isSuccessful());
        // migrated to Approve user task
        tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
        assertEquals(1, tasks.size());
        task = tasks.get(0);
        assertEquals("Approve", task.getName());
        assertEquals(CONTAINER_ID_2, task.getContainerId());
        assertEquals(PROCESS_ID_EVALUATION_2, task.getProcessId());
        assertEquals(processInstanceId, task.getProcessInstanceId());
    } finally {
        try {
            processClient.getProcessInstance(CONTAINER_ID_2, processInstanceId);
            processClient.abortProcessInstance(CONTAINER_ID_2, processInstanceId);
        } catch (KieServicesException e) {
            processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
        }
    }
}
Also used : HashMap(java.util.HashMap) MigrationReportInstance(org.kie.server.api.model.admin.MigrationReportInstance) TaskSummary(org.kie.server.api.model.instance.TaskSummary) KieServicesException(org.kie.server.api.exception.KieServicesException) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Aggregations

KieServicesException (org.kie.server.api.exception.KieServicesException)28 Test (org.junit.Test)19 HashMap (java.util.HashMap)14 JbpmKieServerBaseIntegrationTest (org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)9 TaskSummary (org.kie.server.api.model.instance.TaskSummary)8 ArrayList (java.util.ArrayList)6 ExecutionErrorInstance (org.kie.server.api.model.admin.ExecutionErrorInstance)5 MigrationReportInstance (org.kie.server.api.model.admin.MigrationReportInstance)4 Map (java.util.Map)3 JMSException (javax.jms.JMSException)3 KieServicesHttpException (org.kie.server.api.exception.KieServicesHttpException)3 ServiceResponse (org.kie.server.api.model.ServiceResponse)3 ServiceResponsesList (org.kie.server.api.model.ServiceResponsesList)3 MessageConsumer (javax.jms.MessageConsumer)2 TextMessage (javax.jms.TextMessage)2 Category (org.junit.experimental.categories.Category)2 QueryDefinition (org.kie.server.api.model.definition.QueryDefinition)2 DocumentInstance (org.kie.server.api.model.instance.DocumentInstance)2 ProcessInstance (org.kie.server.api.model.instance.ProcessInstance)2 SolverInstance (org.kie.server.api.model.instance.SolverInstance)2