use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceTest method testCaseDecisionInstanceProperties.
@Deployment(resources = { DECISION_CASE, DECISION_SINGLE_OUTPUT_DMN })
public void testCaseDecisionInstanceProperties() {
CaseInstance caseInstance = createCaseInstanceAndEvaluateDecision();
CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionId(caseInstance.getCaseDefinitionId()).singleResult();
String decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().getId();
String activityInstanceId = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_DecisionTask_1").singleResult().getId();
HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();
assertThat(historicDecisionInstance, is(notNullValue()));
assertThat(historicDecisionInstance.getDecisionDefinitionId(), is(decisionDefinitionId));
assertThat(historicDecisionInstance.getDecisionDefinitionKey(), is(DECISION_DEFINITION_KEY));
assertThat(historicDecisionInstance.getDecisionDefinitionName(), is("sample decision"));
assertThat(historicDecisionInstance.getProcessDefinitionKey(), is(nullValue()));
assertThat(historicDecisionInstance.getProcessDefinitionId(), is(nullValue()));
assertThat(historicDecisionInstance.getProcessInstanceId(), is(nullValue()));
assertThat(historicDecisionInstance.getCaseDefinitionKey(), is(caseDefinition.getKey()));
assertThat(historicDecisionInstance.getCaseDefinitionId(), is(caseDefinition.getId()));
assertThat(historicDecisionInstance.getCaseInstanceId(), is(caseInstance.getId()));
assertThat(historicDecisionInstance.getActivityId(), is("PI_DecisionTask_1"));
assertThat(historicDecisionInstance.getActivityInstanceId(), is(activityInstanceId));
assertThat(historicDecisionInstance.getEvaluationTime(), is(notNullValue()));
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceTest method testIfPartEvaluatesDecision.
@Deployment(resources = { DECISION_CASE_WITH_DECISION_SERVICE_INSIDE_IF_PART, DECISION_RETURNS_TRUE })
public void testIfPartEvaluatesDecision() {
CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").setVariable("input1", null).setVariable("myBean", new DecisionServiceDelegate()).create();
String humanTask1 = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
caseService.completeCaseExecution(humanTask1);
CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionId(caseInstance.getCaseDefinitionId()).singleResult();
String decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().getId();
String activityInstanceId = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_1").singleResult().getId();
HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();
assertThat(historicDecisionInstance, is(notNullValue()));
assertThat(historicDecisionInstance.getDecisionDefinitionId(), is(decisionDefinitionId));
assertThat(historicDecisionInstance.getDecisionDefinitionKey(), is(DECISION_DEFINITION_KEY));
assertThat(historicDecisionInstance.getDecisionDefinitionName(), is("sample decision"));
// references to case instance should be set since the decision is evaluated while executing a case instance
assertThat(historicDecisionInstance.getProcessDefinitionKey(), is(nullValue()));
assertThat(historicDecisionInstance.getProcessDefinitionId(), is(nullValue()));
assertThat(historicDecisionInstance.getProcessInstanceId(), is(nullValue()));
assertThat(historicDecisionInstance.getCaseDefinitionKey(), is(caseDefinition.getKey()));
assertThat(historicDecisionInstance.getCaseDefinitionId(), is(caseDefinition.getId()));
assertThat(historicDecisionInstance.getCaseInstanceId(), is(caseInstance.getId()));
assertThat(historicDecisionInstance.getActivityId(), is("PI_HumanTask_1"));
assertThat(historicDecisionInstance.getActivityInstanceId(), is(activityInstanceId));
assertThat(historicDecisionInstance.getEvaluationTime(), is(notNullValue()));
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class HalCaseDefinitionResolver method resolveNotCachedLinks.
protected List<HalResource<?>> resolveNotCachedLinks(String[] linkedIds, ProcessEngine processEngine) {
RepositoryService repositoryService = processEngine.getRepositoryService();
List<CaseDefinition> caseDefinitions = repositoryService.createCaseDefinitionQuery().caseDefinitionIdIn(linkedIds).listPage(0, linkedIds.length);
List<HalResource<?>> resolved = new ArrayList<HalResource<?>>();
for (CaseDefinition caseDefinition : caseDefinitions) {
resolved.add(HalCaseDefinition.fromCaseDefinition(caseDefinition, processEngine));
}
return resolved;
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class CaseDefinitionRestServiceInteractionTest method testCreateCaseInstanceByCaseDefinitionKeyAndTenantId.
@Test
public void testCreateCaseInstanceByCaseDefinitionKeyAndTenantId() {
CaseDefinition mockDefinition = MockProvider.mockCaseDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build();
setUpRuntimeData(mockDefinition);
given().pathParam("key", MockProvider.EXAMPLE_CASE_DEFINITION_KEY).pathParam("tenant-id", MockProvider.EXAMPLE_TENANT_ID).contentType(POST_JSON_CONTENT_TYPE).body(EMPTY_JSON_OBJECT).then().expect().statusCode(Status.OK.getStatusCode()).body("id", equalTo(MockProvider.EXAMPLE_CASE_INSTANCE_ID)).when().post(CREATE_INSTANCE_BY_KEY_AND_TENANT_ID_URL);
verify(caseDefinitionQueryMock).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
verify(caseServiceMock).withCaseDefinition(MockProvider.EXAMPLE_CASE_DEFINITION_ID);
verify(caseInstanceBuilder).create();
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class CaseDefinitionRestServiceInteractionTest method testDefinitionRetrieval_ByKeyAndTenantId.
@Test
public void testDefinitionRetrieval_ByKeyAndTenantId() {
CaseDefinition mockDefinition = MockProvider.mockCaseDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build();
setUpRuntimeData(mockDefinition);
given().pathParam("key", MockProvider.EXAMPLE_CASE_DEFINITION_KEY).pathParam("tenant-id", MockProvider.EXAMPLE_TENANT_ID).then().expect().statusCode(Status.OK.getStatusCode()).body("id", equalTo(MockProvider.EXAMPLE_CASE_DEFINITION_ID)).body("key", equalTo(MockProvider.EXAMPLE_CASE_DEFINITION_KEY)).body("category", equalTo(MockProvider.EXAMPLE_CASE_DEFINITION_CATEGORY)).body("name", equalTo(MockProvider.EXAMPLE_CASE_DEFINITION_NAME)).body("deploymentId", equalTo(MockProvider.EXAMPLE_DEPLOYMENT_ID)).body("version", equalTo(MockProvider.EXAMPLE_CASE_DEFINITION_VERSION)).body("resource", equalTo(MockProvider.EXAMPLE_CASE_DEFINITION_RESOURCE_NAME)).body("tenantId", equalTo(MockProvider.EXAMPLE_TENANT_ID)).when().get(SINGLE_CASE_DEFINITION_BY_KEY_AND_TENANT_ID_URL);
verify(caseDefinitionQueryMock).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
verify(repositoryServiceMock).getCaseDefinition(MockProvider.EXAMPLE_CASE_DEFINITION_ID);
}
Aggregations