Search in sources :

Example 1 with DecisionRequirementsDefinition

use of org.camunda.bpm.engine.repository.DecisionRequirementsDefinition in project camunda-bpm-platform by camunda.

the class DecisionRequirementsDefinitionRestServiceInteractionTest method decisionRequirementsDefinitionRetrievalByKeyAndTenantId.

@Test
public void decisionRequirementsDefinitionRetrievalByKeyAndTenantId() throws FileNotFoundException, URISyntaxException {
    DecisionRequirementsDefinition mockDefinition = MockProvider.mockDecisionRequirementsDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build();
    setUpRuntimeData(mockDefinition);
    given().pathParam("key", MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_KEY).pathParam("tenant-id", MockProvider.EXAMPLE_TENANT_ID).then().expect().statusCode(Status.OK.getStatusCode()).body("id", equalTo(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID)).body("key", equalTo(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_KEY)).body("category", equalTo(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_CATEGORY)).body("name", equalTo(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_NAME)).body("deploymentId", equalTo(MockProvider.EXAMPLE_DEPLOYMENT_ID)).body("version", equalTo(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_VERSION)).body("resource", equalTo(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_RESOURCE_NAME)).body("tenantId", equalTo(MockProvider.EXAMPLE_TENANT_ID)).when().get(SINGLE_DECISION_REQUIREMENTS_DEFINITION_KEY_AND_TENANT_ID_URL);
    verify(decisionRequirementsDefinitionQueryMock).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
    verify(repositoryServiceMock).getDecisionRequirementsDefinition(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID);
}
Also used : DecisionRequirementsDefinition(org.camunda.bpm.engine.repository.DecisionRequirementsDefinition) Test(org.junit.Test)

Example 2 with DecisionRequirementsDefinition

use of org.camunda.bpm.engine.repository.DecisionRequirementsDefinition in project camunda-bpm-platform by camunda.

the class DecisionRequirementsDefinitionRestServiceQueryTest method setUpRuntime.

@Before
public void setUpRuntime() {
    DecisionRequirementsDefinition mockDecisionRequirementsDefinition = MockProvider.createMockDecisionRequirementsDefinition();
    mockedQuery = createMockQuery(Collections.singletonList(mockDecisionRequirementsDefinition));
}
Also used : DecisionRequirementsDefinition(org.camunda.bpm.engine.repository.DecisionRequirementsDefinition) Before(org.junit.Before)

Example 3 with DecisionRequirementsDefinition

use of org.camunda.bpm.engine.repository.DecisionRequirementsDefinition in project camunda-bpm-platform by camunda.

the class DecisionRequirementsDefinitionRestServiceQueryTest method testDecisionRequirementsDefinitionTenantIdIncludeDefinitionsWithoutTenantid.

@Test
public void testDecisionRequirementsDefinitionTenantIdIncludeDefinitionsWithoutTenantid() {
    List<DecisionRequirementsDefinition> decisionDefinitions = Arrays.asList(MockProvider.mockDecisionRequirementsDefinition().tenantId(null).build(), MockProvider.mockDecisionRequirementsDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build());
    mockedQuery = createMockQuery(decisionDefinitions);
    Response response = given().queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID).queryParam("includeDecisionRequirementsDefinitionsWithoutTenantId", true).then().expect().statusCode(Status.OK.getStatusCode()).when().get(DECISION_REQUIREMENTS_DEFINITION_QUERY_URL);
    verify(mockedQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
    verify(mockedQuery).includeDecisionRequirementsDefinitionsWithoutTenantId();
    verify(mockedQuery).list();
    String content = response.asString();
    List<String> definitions = from(content).getList("");
    assertThat(definitions).hasSize(2);
    String returnedTenantId1 = from(content).getString("[0].tenantId");
    String returnedTenantId2 = from(content).getString("[1].tenantId");
    assertThat(returnedTenantId1).isEqualTo(null);
    assertThat(returnedTenantId2).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
}
Also used : Response(com.jayway.restassured.response.Response) DecisionRequirementsDefinition(org.camunda.bpm.engine.repository.DecisionRequirementsDefinition) Test(org.junit.Test)

Example 4 with DecisionRequirementsDefinition

use of org.camunda.bpm.engine.repository.DecisionRequirementsDefinition in project camunda-bpm-platform by camunda.

the class DecisionRequirementsDefinitionResourceImpl method getDecisionRequirementsDefinition.

@Override
public DecisionRequirementsDefinitionDto getDecisionRequirementsDefinition() {
    RepositoryService repositoryService = engine.getRepositoryService();
    DecisionRequirementsDefinition definition = null;
    try {
        definition = repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId);
    } catch (NotFoundException e) {
        throw new InvalidRequestException(Status.NOT_FOUND, e, e.getMessage());
    } catch (NotValidException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e, e.getMessage());
    } catch (ProcessEngineException e) {
        throw new RestException(Status.INTERNAL_SERVER_ERROR, e);
    }
    return DecisionRequirementsDefinitionDto.fromDecisionRequirementsDefinition(definition);
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) DecisionRequirementsDefinition(org.camunda.bpm.engine.repository.DecisionRequirementsDefinition) RestException(org.camunda.bpm.engine.rest.exception.RestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 5 with DecisionRequirementsDefinition

use of org.camunda.bpm.engine.repository.DecisionRequirementsDefinition in project camunda-bpm-platform by camunda.

the class DecisionRequirementsDefinitionResourceImpl method getDecisionRequirementsDefinitionDiagram.

@Override
public Response getDecisionRequirementsDefinitionDiagram() {
    DecisionRequirementsDefinition definition = engine.getRepositoryService().getDecisionRequirementsDefinition(decisionRequirementsDefinitionId);
    InputStream decisionRequirementsDiagram = engine.getRepositoryService().getDecisionRequirementsDiagram(decisionRequirementsDefinitionId);
    if (decisionRequirementsDiagram == null) {
        return Response.noContent().build();
    } else {
        String fileName = definition.getDiagramResourceName();
        return Response.ok(decisionRequirementsDiagram).header("Content-Disposition", "attachment; filename=" + fileName).type(ProcessDefinitionResourceImpl.getMediaTypeForFileSuffix(fileName)).build();
    }
}
Also used : DecisionRequirementsDefinition(org.camunda.bpm.engine.repository.DecisionRequirementsDefinition) InputStream(java.io.InputStream)

Aggregations

DecisionRequirementsDefinition (org.camunda.bpm.engine.repository.DecisionRequirementsDefinition)40 Test (org.junit.Test)25 HistoricDecisionInstanceStatisticsQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceStatisticsQuery)13 DecisionRequirementsDefinitionQuery (org.camunda.bpm.engine.repository.DecisionRequirementsDefinitionQuery)9 Deployment (org.camunda.bpm.engine.test.Deployment)6 InputStream (java.io.InputStream)5 Response (com.jayway.restassured.response.Response)2 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)2 GetDeploymentResourceCmd (org.camunda.bpm.engine.impl.cmd.GetDeploymentResourceCmd)2 Before (org.junit.Before)2 ArrayList (java.util.ArrayList)1 DecisionService (org.camunda.bpm.engine.DecisionService)1 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 RepositoryService (org.camunda.bpm.engine.RepositoryService)1 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)1 NotValidException (org.camunda.bpm.engine.exception.NotValidException)1 NullValueException (org.camunda.bpm.engine.exception.NullValueException)1 HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)1 NativeHistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.NativeHistoricDecisionInstanceQuery)1