Search in sources :

Example 6 with CaseDefinition

use of org.jbpm.casemgmt.api.model.CaseDefinition 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 7 with CaseDefinition

use of org.jbpm.casemgmt.api.model.CaseDefinition in project jbpm by kiegroup.

the class CaseRuntimeDataServiceDefinitionImplTest method testGetCaseDefinitionByIdWithBoundaryEvent.

@Test
public void testGetCaseDefinitionByIdWithBoundaryEvent() {
    CaseDefinition caseDef = caseRuntimeDataService.getCase(deploymentUnit.getIdentifier(), "UserTaskCaseBoundary");
    // UserTaskWithStageCase asserts
    assertNotNull(caseDef);
    assertEquals("UserTaskCaseBoundary", caseDef.getId());
    assertEquals("Simple Case with User Tasks and Boundary", caseDef.getName());
    assertEquals("1.0", caseDef.getVersion());
    assertEquals("HR", caseDef.getIdentifierPrefix());
    assertEquals(2, caseDef.getCaseMilestones().size());
    assertEquals(0, caseDef.getCaseStages().size());
    assertEquals(3, caseDef.getAdHocFragments().size());
    assertEquals(deploymentUnit.getIdentifier(), caseDef.getDeploymentId());
    Map<String, CaseMilestone> mappedMilestones = mapMilestones(caseDef.getCaseMilestones());
    assertTrue(mappedMilestones.containsKey("Milestone1"));
    assertTrue(mappedMilestones.containsKey("Milestone2"));
    Map<String, AdHocFragment> mappedFragments = mapAdHocFragments(caseDef.getAdHocFragments());
    assertTrue(mappedFragments.containsKey("Hello2"));
    assertEquals("HumanTaskNode", mappedFragments.get("Hello2").getType());
    assertTrue(mappedFragments.containsKey("Milestone1"));
    assertEquals("MilestoneNode", mappedFragments.get("Milestone1").getType());
    assertTrue(mappedFragments.containsKey("Milestone2"));
    assertEquals("MilestoneNode", mappedFragments.get("Milestone2").getType());
    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());
}
Also used : CaseMilestone(org.jbpm.casemgmt.api.model.CaseMilestone) CaseDefinition(org.jbpm.casemgmt.api.model.CaseDefinition) CaseRole(org.jbpm.casemgmt.api.model.CaseRole) AdHocFragment(org.jbpm.casemgmt.api.model.AdHocFragment) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Example 8 with CaseDefinition

use of org.jbpm.casemgmt.api.model.CaseDefinition 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 9 with CaseDefinition

use of org.jbpm.casemgmt.api.model.CaseDefinition 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 10 with CaseDefinition

use of org.jbpm.casemgmt.api.model.CaseDefinition 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

CaseDefinition (org.jbpm.casemgmt.api.model.CaseDefinition)27 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)17 Test (org.junit.Test)17 QueryContext (org.kie.api.runtime.query.QueryContext)13 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)10 CaseStage (org.jbpm.casemgmt.api.model.CaseStage)10 ArrayList (java.util.ArrayList)9 AdHocFragment (org.jbpm.casemgmt.api.model.AdHocFragment)9 HashMap (java.util.HashMap)7 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)7 AdHocFragmentNotFoundException (org.jbpm.casemgmt.api.AdHocFragmentNotFoundException)6 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)6 TaskSummary (org.kie.api.task.model.TaskSummary)6 CaseActiveException (org.jbpm.casemgmt.api.CaseActiveException)5 CaseCommentNotFoundException (org.jbpm.casemgmt.api.CaseCommentNotFoundException)5 CaseRole (org.jbpm.casemgmt.api.model.CaseRole)5 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)5 CaseStageInstance (org.jbpm.casemgmt.api.model.instance.CaseStageInstance)5 TaskNotFoundException (org.jbpm.services.api.TaskNotFoundException)5 UserImpl (org.jbpm.services.task.impl.model.UserImpl)5