org.camunda.bpm.engine.RepositoryService.getDecisionRequirementsDefinition()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(15.5k)|赞(0)|评价(0)|浏览(95)

本文整理了Java中org.camunda.bpm.engine.RepositoryService.getDecisionRequirementsDefinition方法的一些代码示例,展示了RepositoryService.getDecisionRequirementsDefinition的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RepositoryService.getDecisionRequirementsDefinition方法的具体详情如下:
包路径:org.camunda.bpm.engine.RepositoryService
类名称:RepositoryService
方法名:getDecisionRequirementsDefinition

RepositoryService.getDecisionRequirementsDefinition介绍

[英]Returns the DecisionRequirementsDefinition.
[中]返回DecisionRequirementsDefinition。

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

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

代码示例来源:origin: camunda/camunda-bpm-platform

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

代码示例来源:origin: camunda/camunda-bpm-platform

protected void setUpRuntimeData(DecisionRequirementsDefinition mockDecisionRequirementsDefinition) throws FileNotFoundException, URISyntaxException {
 repositoryServiceMock = mock(RepositoryService.class);
 when(processEngine.getRepositoryService()).thenReturn(repositoryServiceMock);
 when(repositoryServiceMock.getDecisionRequirementsDefinition(eq(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID))).thenReturn(mockDecisionRequirementsDefinition);
 when(repositoryServiceMock.getDecisionRequirementsModel(eq(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID))).thenReturn(createMockDecisionRequirementsDefinitionDmnXml());
 when(repositoryServiceMock.getDecisionRequirementsDiagram(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID)).thenReturn(createMockDecisionRequirementsDiagram());
 decisionRequirementsDefinitionQueryMock = mock(DecisionRequirementsDefinitionQuery.class);
 when(decisionRequirementsDefinitionQueryMock.decisionRequirementsDefinitionKey(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_KEY)).thenReturn(decisionRequirementsDefinitionQueryMock);
 when(decisionRequirementsDefinitionQueryMock.tenantIdIn(anyString())).thenReturn(decisionRequirementsDefinitionQueryMock);
 when(decisionRequirementsDefinitionQueryMock.withoutTenantId()).thenReturn(decisionRequirementsDefinitionQueryMock);
 when(decisionRequirementsDefinitionQueryMock.latestVersion()).thenReturn(decisionRequirementsDefinitionQueryMock);
 when(decisionRequirementsDefinitionQueryMock.singleResult()).thenReturn(mockDecisionRequirementsDefinition);
 when(decisionRequirementsDefinitionQueryMock.list()).thenReturn(Collections.singletonList(mockDecisionRequirementsDefinition));
 when(repositoryServiceMock.createDecisionRequirementsDefinitionQuery()).thenReturn(decisionRequirementsDefinitionQueryMock);
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testGetDecisionRequirementsDefinitionByInvalidId() {
 try {
  repositoryService.getDecisionRequirementsDefinition("invalid");
  fail();
 } catch (Exception e) {
  assertTextPresent("no deployed decision requirements definition found with id 'invalid'", e.getMessage());
 }
 try {
  repositoryService.getDecisionRequirementsDefinition(null);
  fail();
 } catch (NotValidException e) {
  assertTextPresent("decisionRequirementsDefinitionId is null", e.getMessage());
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void getDecisionRequirementsDefinitionWithAuthenticatedTenant() {
 identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
 DecisionRequirementsDefinition definition = repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId);
 assertThat(definition.getTenantId(), is(TENANT_ONE));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@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);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@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);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void getDecisionRequirementsDefinitionDisabledTenantCheck() {
 processEngineConfiguration.setTenantCheckEnabled(false);
 identityService.setAuthentication("user", null, null);
 DecisionRequirementsDefinition definition = repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId);
 assertThat(definition.getTenantId(), is(TENANT_ONE));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void nonExistingDecisionRequirementsDefinitionRetrieval() {
 String nonExistingId = "aNonExistingDefinitionId";
 when(repositoryServiceMock.getDecisionRequirementsDefinition(eq(nonExistingId))).thenThrow(new ProcessEngineException("No matching decision requirements definition"));
 given()
  .pathParam("id", "aNonExistingDefinitionId")
 .then()
  .expect()
  .statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).contentType(ContentType.JSON)
  .body("type", is(RestException.class.getSimpleName()))
  .body("message", containsString("No matching decision requirements definition"))
 .when().get(SINGLE_DECISION_REQUIREMENTS_DEFINITION_ID_URL);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void failToGetDecisionRequirementsDefinitionNoAuthenticatedTenants() {
 identityService.setAuthentication("user", null, null);
 // declare expected exception
 thrown.expect(ProcessEngineException.class);
 thrown.expectMessage("Cannot get the decision requirements definition");
 repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void decisionRequirementsDefinitionRetrievalById() {
 given()
  .pathParam("id", MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_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(null))
 .when()
  .get(SINGLE_DECISION_REQUIREMENTS_DEFINITION_ID_URL);
 verify(repositoryServiceMock).getDecisionRequirementsDefinition(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void decisionRequirementsDefinitionRetrievalByKey() {
 given()
  .pathParam("key", MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_KEY)
 .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(null))
 .when()
  .get(SINGLE_DECISION_REQUIREMENTS_DEFINITION_KEY_URL);
 verify(repositoryServiceMock).getDecisionRequirementsDefinition(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@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);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void decisionRequirementsDiagramRetrieval() throws FileNotFoundException, URISyntaxException {
 byte[] actual = given().pathParam("id", MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID)
  .expect()
   .statusCode(Status.OK.getStatusCode())
   .contentType("image/png")
   .header("Content-Disposition", "attachment; filename=" +
     MockProvider.EXAMPLE_DECISION_DEFINITION_DIAGRAM_RESOURCE_NAME)
  .when().get(DIAGRAM_DEFINITION_URL).getBody().asByteArray();
 verify(repositoryServiceMock).getDecisionRequirementsDefinition(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID);
 verify(repositoryServiceMock).getDecisionRequirementsDiagram(MockProvider.EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID);
 byte[] expected = IoUtil.readInputStream(new FileInputStream(getFile()), "decision requirements diagram");
 Assert.assertArrayEquals(expected, actual);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources = { "org/camunda/bpm/engine/test/repository/drg.dmn" })
public void testGetDecisionRequirementsDefinition() {
 DecisionRequirementsDefinitionQuery query = repositoryService.createDecisionRequirementsDefinitionQuery();
 DecisionRequirementsDefinition decisionRequirementsDefinition = query.singleResult();
 String decisionRequirementsDefinitionId = decisionRequirementsDefinition.getId();
 DecisionRequirementsDefinition definition = repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId);
 assertNotNull(definition);
 assertEquals(decisionRequirementsDefinitionId, definition.getId());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
@Deployment(resources = { DMN_FILE })
public void getDecisionRequirementsDefinition() {
 String decisionRequirementsDefinitionId = repositoryService
  .createDecisionRequirementsDefinitionQuery()
  .decisionRequirementsDefinitionKey(DEFINITION_KEY)
  .singleResult().getId();
 
 // when
 authRule.init(scenario).withUser("userId").bindResource("decisionRequirementsDefinitionKey", DEFINITION_KEY).start();
 DecisionRequirementsDefinition decisionRequirementsDefinition = repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId);
 if (authRule.assertScenario(scenario)) {
  assertNotNull(decisionRequirementsDefinition);
 }
}

代码示例来源:origin: org.camunda.bpm/camunda-engine

@Test
public void getDecisionRequirementsDefinitionWithAuthenticatedTenant() {
 identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
 DecisionRequirementsDefinition definition = repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId);
 assertThat(definition.getTenantId(), is(TENANT_ONE));
}

代码示例来源:origin: org.camunda.bpm/camunda-engine

@Test
public void getDecisionRequirementsDefinitionDisabledTenantCheck() {
 processEngineConfiguration.setTenantCheckEnabled(false);
 identityService.setAuthentication("user", null, null);
 DecisionRequirementsDefinition definition = repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId);
 assertThat(definition.getTenantId(), is(TENANT_ONE));
}

代码示例来源:origin: org.camunda.bpm/camunda-engine

@Test
public void failToGetDecisionRequirementsDefinitionNoAuthenticatedTenants() {
 identityService.setAuthentication("user", null, null);
 // declare expected exception
 thrown.expect(ProcessEngineException.class);
 thrown.expectMessage("Cannot get the decision requirements definition");
 repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId);
}

代码示例来源:origin: org.camunda.bpm/camunda-engine

@Deployment(resources = { "org/camunda/bpm/engine/test/repository/drg.dmn" })
public void testGetDecisionRequirementsDefinition() {
 DecisionRequirementsDefinitionQuery query = repositoryService.createDecisionRequirementsDefinitionQuery();
 DecisionRequirementsDefinition decisionRequirementsDefinition = query.singleResult();
 String decisionRequirementsDefinitionId = decisionRequirementsDefinition.getId();
 DecisionRequirementsDefinition definition = repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId);
 assertNotNull(definition);
 assertEquals(decisionRequirementsDefinitionId, definition.getId());
}

相关文章

微信公众号

最新文章

更多

RepositoryService类方法