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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations