Search in sources :

Example 66 with DecisionDefinition

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);
}
Also used : DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition) Test(org.junit.Test)

Example 67 with DecisionDefinition

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();
}
Also used : DmnDecisionResult(org.camunda.bpm.dmn.engine.DmnDecisionResult) HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition) Test(org.junit.Test)

Example 68 with DecisionDefinition

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;
}
Also used : DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Aggregations

DecisionDefinition (org.camunda.bpm.engine.repository.DecisionDefinition)68 Test (org.junit.Test)21 Deployment (org.camunda.bpm.engine.test.Deployment)18 DecisionDefinitionQuery (org.camunda.bpm.engine.repository.DecisionDefinitionQuery)10 Date (java.util.Date)6 DmnDecisionTableResult (org.camunda.bpm.dmn.engine.DmnDecisionTableResult)5 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)5 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 HistoricDecisionInstanceEntity (org.camunda.bpm.engine.impl.history.event.HistoricDecisionInstanceEntity)3 Response (com.jayway.restassured.response.Response)2 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)2 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)2 HistoricDecisionOutputInstance (org.camunda.bpm.engine.history.HistoricDecisionOutputInstance)2 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)2 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)2 GetDeploymentResourceCmd (org.camunda.bpm.engine.impl.cmd.GetDeploymentResourceCmd)2 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)2