use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class DecisionDefinitionRestServiceInteractionTest method testDefinitionRetrieval_ByKeyAndTenantId.
@Test
public void testDefinitionRetrieval_ByKeyAndTenantId() {
DecisionDefinition mockDefinition = MockProvider.mockDecisionDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build();
setUpRuntimeData(mockDefinition);
given().pathParam("key", MockProvider.EXAMPLE_DECISION_DEFINITION_KEY).pathParam("tenant-id", MockProvider.EXAMPLE_TENANT_ID).then().expect().statusCode(Status.OK.getStatusCode()).body("id", equalTo(MockProvider.EXAMPLE_DECISION_DEFINITION_ID)).body("key", equalTo(MockProvider.EXAMPLE_DECISION_DEFINITION_KEY)).body("category", equalTo(MockProvider.EXAMPLE_DECISION_DEFINITION_CATEGORY)).body("name", equalTo(MockProvider.EXAMPLE_DECISION_DEFINITION_NAME)).body("deploymentId", equalTo(MockProvider.EXAMPLE_DEPLOYMENT_ID)).body("version", equalTo(MockProvider.EXAMPLE_DECISION_DEFINITION_VERSION)).body("resource", equalTo(MockProvider.EXAMPLE_DECISION_DEFINITION_RESOURCE_NAME)).body("decisionRequirementsDefinitionId", equalTo(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID)).body("decisionRequirementsDefinitionKey", equalTo(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_KEY)).body("tenantId", equalTo(MockProvider.EXAMPLE_TENANT_ID)).when().get(SINGLE_DECISION_DEFINITION_BY_KEY_AND_TENANT_ID_URL);
verify(decisionDefinitionQueryMock).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
verify(repositoryServiceMock).getDecisionDefinition(MockProvider.EXAMPLE_DECISION_DEFINITION_ID);
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class DecisionDefinitionRestServiceInteractionTest method testEvaluateDecisionByKeyAndTenantId.
@Test
public void testEvaluateDecisionByKeyAndTenantId() {
DecisionDefinition mockDefinition = MockProvider.mockDecisionDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build();
setUpRuntimeData(mockDefinition);
DmnDecisionResult decisionResult = MockProvider.createMockDecisionResult();
when(decisionEvaluationBuilderMock.evaluate()).thenReturn(decisionResult);
Map<String, Object> json = new HashMap<String, Object>();
json.put("variables", VariablesBuilder.create().variable("amount", 420).variable("invoiceCategory", "MISC").getVariables());
given().pathParam("key", MockProvider.EXAMPLE_DECISION_DEFINITION_KEY).pathParam("tenant-id", MockProvider.EXAMPLE_TENANT_ID).contentType(POST_JSON_CONTENT_TYPE).body(json).then().expect().statusCode(Status.OK.getStatusCode()).when().post(EVALUATE_DECISION_BY_KEY_AND_TENANT_ID_URL);
Map<String, Object> expectedVariables = new HashMap<String, Object>();
expectedVariables.put("amount", 420);
expectedVariables.put("invoiceCategory", "MISC");
verify(decisionDefinitionQueryMock).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
verify(decisionEvaluationBuilderMock).variables(expectedVariables);
verify(decisionEvaluationBuilderMock).evaluate();
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class MockDecisionDefinitionBuilder method build.
public DecisionDefinition build() {
DecisionDefinition mockDefinition = mock(DecisionDefinition.class);
when(mockDefinition.getId()).thenReturn(id);
when(mockDefinition.getCategory()).thenReturn(category);
when(mockDefinition.getName()).thenReturn(name);
when(mockDefinition.getKey()).thenReturn(key);
when(mockDefinition.getVersion()).thenReturn(version);
when(mockDefinition.getResourceName()).thenReturn(resource);
when(mockDefinition.getDiagramResourceName()).thenReturn(diagramResource);
when(mockDefinition.getDeploymentId()).thenReturn(deploymentId);
when(mockDefinition.getTenantId()).thenReturn(tenantId);
when(mockDefinition.getDecisionRequirementsDefinitionId()).thenReturn(decisionRequirementsDefinitionId);
when(mockDefinition.getDecisionRequirementsDefinitionKey()).thenReturn(decisionRequirementsDefinitionKey);
when(mockDefinition.getVersionTag()).thenReturn(versionTag);
return mockDefinition;
}
Aggregations