Search in sources :

Example 26 with QueryContext

use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.

the class CaseRuntimeDataServiceDefinitionImplTest method testGetCaseDefinitionsSorted.

@Test
public void testGetCaseDefinitionsSorted() {
    Collection<CaseDefinition> cases = caseRuntimeDataService.getCases(new QueryContext(0, 1, SORT_BY_CASE_DEFINITION_NAME, true));
    assertNotNull(cases);
    assertEquals(1, cases.size());
    assertEquals("CaseWithTwoStages", cases.iterator().next().getId());
    cases = caseRuntimeDataService.getCases(new QueryContext(1, 1, SORT_BY_CASE_DEFINITION_NAME, true));
    assertNotNull(cases);
    assertEquals(1, cases.size());
    assertEquals("EmptyCase", cases.iterator().next().getId());
    cases = caseRuntimeDataService.getCases(new QueryContext(2, 1, SORT_BY_CASE_DEFINITION_NAME, true));
    assertNotNull(cases);
    assertEquals(1, cases.size());
    assertEquals("UserTaskCase", cases.iterator().next().getId());
    cases = caseRuntimeDataService.getCases(new QueryContext(SORT_BY_CASE_DEFINITION_NAME, false));
    assertNotNull(cases);
    assertEquals(5, cases.size());
    List<CaseDefinition> sortedCases = new ArrayList<>(cases);
    assertEquals("UserTaskWithStageCase", sortedCases.get(0).getId());
    assertEquals("UserTaskCaseBoundary", sortedCases.get(1).getId());
    assertEquals("UserTaskCase", sortedCases.get(2).getId());
    assertEquals("EmptyCase", sortedCases.get(3).getId());
}
Also used : CaseDefinition(org.jbpm.casemgmt.api.model.CaseDefinition) ArrayList(java.util.ArrayList) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 27 with QueryContext

use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.

the class CaseRuntimeDataServiceDefinitionImplTest method testGetCaseDefinitionsByFilterSorted.

@Test
public void testGetCaseDefinitionsByFilterSorted() {
    Collection<CaseDefinition> cases = caseRuntimeDataService.getCases("User", new QueryContext(0, 1, SORT_BY_CASE_DEFINITION_NAME, true));
    assertNotNull(cases);
    assertEquals(1, cases.size());
    assertEquals("UserTaskCase", cases.iterator().next().getId());
    cases = caseRuntimeDataService.getCases("User", new QueryContext(1, 1, SORT_BY_CASE_DEFINITION_NAME, true));
    assertNotNull(cases);
    assertEquals(1, cases.size());
    assertEquals("UserTaskCaseBoundary", cases.iterator().next().getId());
    cases = caseRuntimeDataService.getCases("User", new QueryContext(SORT_BY_CASE_DEFINITION_NAME, false));
    assertNotNull(cases);
    assertEquals(3, cases.size());
    List<CaseDefinition> sortedCases = new ArrayList<>(cases);
    assertEquals("UserTaskWithStageCase", sortedCases.get(0).getId());
    assertEquals("UserTaskCaseBoundary", sortedCases.get(1).getId());
    assertEquals("UserTaskCase", sortedCases.get(2).getId());
}
Also used : CaseDefinition(org.jbpm.casemgmt.api.model.CaseDefinition) ArrayList(java.util.ArrayList) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 28 with QueryContext

use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.

the class CaseRuntimeDataServiceDefinitionImplTest method testGetCaseDefinitions.

@Test
public void testGetCaseDefinitions() {
    Collection<CaseDefinition> cases = caseRuntimeDataService.getCases(new QueryContext());
    assertNotNull(cases);
    assertEquals(5, cases.size());
    Map<String, CaseDefinition> mappedCases = mapCases(cases);
    assertTrue(mappedCases.containsKey("EmptyCase"));
    assertTrue(mappedCases.containsKey("UserTaskCase"));
    assertTrue(mappedCases.containsKey("UserTaskCaseBoundary"));
    assertTrue(mappedCases.containsKey("UserTaskWithStageCase"));
    // EmptyCase asserts
    CaseDefinition caseDef = mappedCases.get("EmptyCase");
    assertNotNull(caseDef);
    assertEquals("EmptyCase", caseDef.getId());
    assertEquals("New Case", caseDef.getName());
    assertEquals("", caseDef.getVersion());
    assertEquals(CaseDefinition.DEFAULT_PREFIX, caseDef.getIdentifierPrefix());
    assertNotNull(caseDef.getCaseMilestones());
    assertTrue(caseDef.getCaseMilestones().isEmpty());
    assertNotNull(caseDef.getCaseStages());
    assertTrue(caseDef.getCaseStages().isEmpty());
    assertNotNull(caseDef.getCaseRoles());
    assertTrue(caseDef.getCaseRoles().isEmpty());
    assertEquals(deploymentUnit.getIdentifier(), caseDef.getDeploymentId());
    // UserTaskCase asserts
    caseDef = mappedCases.get("UserTaskCase");
    assertNotNull(caseDef);
    assertEquals("UserTaskCase", caseDef.getId());
    assertEquals("Simple Case with User Tasks", caseDef.getName());
    assertEquals("1.0", caseDef.getVersion());
    assertEquals("HR", caseDef.getIdentifierPrefix());
    assertNotNull(caseDef.getCaseMilestones());
    assertEquals(2, caseDef.getCaseMilestones().size());
    Map<String, CaseMilestone> mappedMilestones = mapMilestones(caseDef.getCaseMilestones());
    assertTrue(mappedMilestones.containsKey("Milestone1"));
    assertTrue(mappedMilestones.containsKey("Milestone2"));
    CaseMilestone milestone = mappedMilestones.get("Milestone1");
    assertEquals("_SomeID4", milestone.getId());
    assertEquals("Milestone1", milestone.getName());
    assertEquals("", milestone.getAchievementCondition());
    assertEquals(false, milestone.isMandatory());
    milestone = mappedMilestones.get("Milestone2");
    assertEquals("_5", milestone.getId());
    assertEquals("Milestone2", milestone.getName());
    assertEquals("org.kie.api.runtime.process.CaseData(data.get(\"dataComplete\") == true)", milestone.getAchievementCondition());
    assertEquals(false, milestone.isMandatory());
    assertNotNull(caseDef.getCaseStages());
    assertEquals(0, caseDef.getCaseStages().size());
    assertNotNull(caseDef.getCaseRoles());
    assertEquals(3, caseDef.getCaseRoles().size());
    Map<String, CaseRole> mappedRoles = mapRoles(caseDef.getCaseRoles());
    assertTrue(mappedRoles.containsKey("owner"));
    assertTrue(mappedRoles.containsKey("contact"));
    assertTrue(mappedRoles.containsKey("participant"));
    assertEquals(1, mappedRoles.get("owner").getCardinality().intValue());
    assertEquals(2, mappedRoles.get("contact").getCardinality().intValue());
    assertEquals(-1, mappedRoles.get("participant").getCardinality().intValue());
    // UserTaskWithStageCase asserts
    caseDef = mappedCases.get("UserTaskWithStageCase");
    assertNotNull(caseDef);
    assertEquals("UserTaskWithStageCase", caseDef.getId());
    assertEquals("UserTaskWithStageCase", caseDef.getName());
    assertEquals("1.0", caseDef.getVersion());
    assertEquals(CaseDefinition.DEFAULT_PREFIX, caseDef.getIdentifierPrefix());
    assertNotNull(caseDef.getCaseMilestones());
    assertEquals(0, caseDef.getCaseMilestones().size());
    assertEquals(deploymentUnit.getIdentifier(), caseDef.getDeploymentId());
    assertNotNull(caseDef.getCaseStages());
    assertEquals(1, caseDef.getCaseStages().size());
    Map<String, CaseStage> mappedStages = mapStages(caseDef.getCaseStages());
    assertTrue(mappedStages.containsKey("Collect input"));
    CaseStage caseStage = mappedStages.get("Collect input");
    assertNotNull(caseStage);
    assertEquals("Collect input", caseStage.getName());
    assertEquals(2, caseStage.getAdHocFragments().size());
    Map<String, AdHocFragment> mappedFragments = mapAdHocFragments(caseStage.getAdHocFragments());
    assertTrue(mappedFragments.containsKey("Missing data"));
    assertEquals("HumanTaskNode", mappedFragments.get("Missing data").getType());
    assertTrue(mappedFragments.containsKey("Verification of data"));
    assertEquals("SubProcessNode", mappedFragments.get("Verification of data").getType());
    assertNotNull(caseDef.getCaseRoles());
    assertEquals(3, caseDef.getCaseRoles().size());
    mappedRoles = mapRoles(caseDef.getCaseRoles());
    assertTrue(mappedRoles.containsKey("owner"));
    assertTrue(mappedRoles.containsKey("contact"));
    assertTrue(mappedRoles.containsKey("participant"));
    assertEquals(1, mappedRoles.get("owner").getCardinality().intValue());
    assertEquals(2, mappedRoles.get("contact").getCardinality().intValue());
    assertEquals(-1, mappedRoles.get("participant").getCardinality().intValue());
}
Also used : CaseMilestone(org.jbpm.casemgmt.api.model.CaseMilestone) CaseStage(org.jbpm.casemgmt.api.model.CaseStage) QueryContext(org.kie.api.runtime.query.QueryContext) AdHocFragment(org.jbpm.casemgmt.api.model.AdHocFragment) CaseDefinition(org.jbpm.casemgmt.api.model.CaseDefinition) CaseRole(org.jbpm.casemgmt.api.model.CaseRole) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 29 with QueryContext

use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.

the class CaseRuntimeDataServiceDefinitionImplTest method testGetCaseDefinitionsByFilter.

@Test
public void testGetCaseDefinitionsByFilter() {
    Collection<CaseDefinition> cases = caseRuntimeDataService.getCases("empty", new QueryContext());
    assertNotNull(cases);
    assertEquals(1, cases.size());
    Map<String, CaseDefinition> mappedCases = mapCases(cases);
    assertTrue(mappedCases.containsKey("EmptyCase"));
    cases = caseRuntimeDataService.getCases("User", new QueryContext());
    assertNotNull(cases);
    assertEquals(3, cases.size());
    mappedCases = mapCases(cases);
    assertTrue(mappedCases.containsKey("UserTaskCase"));
    assertTrue(mappedCases.containsKey("UserTaskCaseBoundary"));
    assertTrue(mappedCases.containsKey("UserTaskWithStageCase"));
    cases = caseRuntimeDataService.getCases("nomatch", new QueryContext());
    assertNotNull(cases);
    assertEquals(0, cases.size());
}
Also used : CaseDefinition(org.jbpm.casemgmt.api.model.CaseDefinition) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 30 with QueryContext

use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.

the class CaseRuntimeDataServiceDefinitionImplTest method testGetCaseDefinitionsByDeploymentIdSorted.

@Test
public void testGetCaseDefinitionsByDeploymentIdSorted() {
    Collection<CaseDefinition> cases = caseRuntimeDataService.getCasesByDeployment(deploymentUnit.getIdentifier(), new QueryContext(0, 1, SORT_BY_CASE_DEFINITION_NAME, true));
    assertNotNull(cases);
    assertEquals(1, cases.size());
    assertEquals("CaseWithTwoStages", cases.iterator().next().getId());
    cases = caseRuntimeDataService.getCasesByDeployment(deploymentUnit.getIdentifier(), new QueryContext(1, 1, SORT_BY_CASE_DEFINITION_NAME, true));
    assertNotNull(cases);
    assertEquals(1, cases.size());
    assertEquals("EmptyCase", cases.iterator().next().getId());
    cases = caseRuntimeDataService.getCasesByDeployment(deploymentUnit.getIdentifier(), new QueryContext(2, 1, SORT_BY_CASE_DEFINITION_NAME, true));
    assertNotNull(cases);
    assertEquals(1, cases.size());
    assertEquals("UserTaskCase", cases.iterator().next().getId());
    cases = caseRuntimeDataService.getCasesByDeployment(deploymentUnit.getIdentifier(), new QueryContext(SORT_BY_CASE_DEFINITION_NAME, false));
    assertNotNull(cases);
    assertEquals(5, cases.size());
    List<CaseDefinition> sortedCases = new ArrayList<>(cases);
    assertEquals("UserTaskWithStageCase", sortedCases.get(0).getId());
    assertEquals("UserTaskCaseBoundary", sortedCases.get(1).getId());
    assertEquals("UserTaskCase", sortedCases.get(2).getId());
    assertEquals("EmptyCase", sortedCases.get(3).getId());
}
Also used : CaseDefinition(org.jbpm.casemgmt.api.model.CaseDefinition) ArrayList(java.util.ArrayList) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Aggregations

QueryContext (org.kie.api.runtime.query.QueryContext)315 Test (org.junit.Test)299 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)131 HashMap (java.util.HashMap)115 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)109 ArrayList (java.util.ArrayList)99 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)67 RequestInfo (org.kie.api.executor.RequestInfo)53 TaskSummary (org.kie.api.task.model.TaskSummary)53 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)51 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)49 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)45 CommandContext (org.kie.api.executor.CommandContext)39 SqlQueryDefinition (org.jbpm.kie.services.impl.query.SqlQueryDefinition)37 UserImpl (org.jbpm.services.task.impl.model.UserImpl)37 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)36 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)34 QueryFilter (org.kie.internal.query.QueryFilter)30 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)29 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)29