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

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

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

RepositoryService.getDecisionDiagram介绍

[英]Gives access to a deployed decision diagram, e.g., a PNG image, through a stream of bytes.
[中]通过字节流访问已部署的决策图,例如PNG图像。

代码示例

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

@Override
public Response getDecisionDefinitionDiagram() {
 DecisionDefinition definition = engine.getRepositoryService().getDecisionDefinition(decisionDefinitionId);
 InputStream decisionDiagram = engine.getRepositoryService().getDecisionDiagram(decisionDefinitionId);
 if (decisionDiagram == null) {
  return Response.noContent().build();
 } else {
  String fileName = definition.getDiagramResourceName();
  return Response.ok(decisionDiagram).header("Content-Disposition", "attachment; filename=" + fileName)
    .type(ProcessDefinitionResourceImpl.getMediaTypeForFileSuffix(fileName)).build();
 }
}

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

@Override
public Response getDecisionDefinitionDiagram() {
 DecisionDefinition definition = engine.getRepositoryService().getDecisionDefinition(decisionDefinitionId);
 InputStream decisionDiagram = engine.getRepositoryService().getDecisionDiagram(decisionDefinitionId);
 if (decisionDiagram == null) {
  return Response.noContent().build();
 } else {
  String fileName = definition.getDiagramResourceName();
  return Response.ok(decisionDiagram).header("Content-Disposition", "attachment; filename=" + fileName)
    .type(ProcessDefinitionResourceImpl.getMediaTypeForFileSuffix(fileName)).build();
 }
}

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

@Test
public void getDecisionDiagramWithAuthenticatedTenant() {
 identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
 InputStream inputStream = repositoryService.getDecisionDiagram(decisionDefinitionId);
 // inputStream is always null because there is no decision diagram at the moment
 // what should be deployed as a diagram resource for DMN? 
 assertThat(inputStream, nullValue());
}

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

@Test
public void testDecisionDiagramNotExist() {
 // setup additional mock behavior
 when(repositoryServiceMock.getDecisionDiagram(MockProvider.EXAMPLE_DECISION_DEFINITION_ID)).thenReturn(null);
 // call method
 given().pathParam("id", MockProvider.EXAMPLE_DECISION_DEFINITION_ID)
   .expect().statusCode(Status.NO_CONTENT.getStatusCode())
   .when().get(DIAGRAM_DEFINITION_URL);
 // verify service interaction
 verify(repositoryServiceMock).getDecisionDefinition(MockProvider.EXAMPLE_DECISION_DEFINITION_ID);
 verify(repositoryServiceMock).getDecisionDiagram(MockProvider.EXAMPLE_DECISION_DEFINITION_ID);
}

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

@Test
public void getDecisionDiagramDisabledTenantCheck() {
 processEngineConfiguration.setTenantCheckEnabled(false);
 identityService.setAuthentication("user", null, null);
 InputStream inputStream = repositoryService.getDecisionDiagram(decisionDefinitionId);
 // inputStream is always null because there is no decision diagram at the moment
 // what should be deployed as a diagram resource for DMN? 
 assertThat(inputStream, nullValue());
}

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

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

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

public void testGetDecisionDiagram() {
 // given
 String decisionDefinitionId = selectDecisionDefinitionByKey(DECISION_DEFINITION_KEY).getId();
 createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, READ);
 // when
 InputStream stream = repositoryService.getDecisionDiagram(decisionDefinitionId);
 // then
 // no decision diagram deployed
 assertNull(stream);
}

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

@Test
public void testDecisionDiagramNullFilename() throws FileNotFoundException, URISyntaxException {
 // setup additional mock behavior
 File file = getFile("/processes/todo-process.png");
 when(repositoryServiceMock.getDecisionDefinition(MockProvider.EXAMPLE_DECISION_DEFINITION_ID).getDiagramResourceName())
  .thenReturn(null);
 when(repositoryServiceMock.getDecisionDiagram(MockProvider.EXAMPLE_DECISION_DEFINITION_ID))
   .thenReturn(new FileInputStream(file));
 // call method
 byte[] actual = given().pathParam("id", MockProvider.EXAMPLE_DECISION_DEFINITION_ID)
  .expect()
  .statusCode(Status.OK.getStatusCode())
  .contentType("application/octet-stream")
  .header("Content-Disposition", "attachment; filename=" + null)
  .when().get(DIAGRAM_DEFINITION_URL).getBody().asByteArray();
 // verify service interaction
 verify(repositoryServiceMock).getDecisionDiagram(MockProvider.EXAMPLE_DECISION_DEFINITION_ID);
 // compare input stream with response body bytes
 byte[] expected = IoUtil.readInputStream(new FileInputStream(file), "decision diagram");
 Assert.assertArrayEquals(expected, actual);
}

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

@Test
public void testDecisionDiagramRetrieval() throws FileNotFoundException, URISyntaxException {
 // setup additional mock behavior
 File file = getFile("/processes/todo-process.png");
 when(repositoryServiceMock.getDecisionDiagram(MockProvider.EXAMPLE_DECISION_DEFINITION_ID))
   .thenReturn(new FileInputStream(file));
 // call method
 byte[] actual = given().pathParam("id", MockProvider.EXAMPLE_DECISION_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 service interaction
 verify(repositoryServiceMock).getDecisionDefinition(MockProvider.EXAMPLE_DECISION_DEFINITION_ID);
 verify(repositoryServiceMock).getDecisionDiagram(MockProvider.EXAMPLE_DECISION_DEFINITION_ID);
 // compare input stream with response body bytes
 byte[] expected = IoUtil.readInputStream(new FileInputStream(file), "decision diagram");
 Assert.assertArrayEquals(expected, actual);
}

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

public void testGetDecisionDiagramWithoutAuthorizations() {
 // given
 String decisionDefinitionId = selectDecisionDefinitionByKey(DECISION_DEFINITION_KEY).getId();
 try {
  // when
  repositoryService.getDecisionDiagram(decisionDefinitionId);
  fail("Exception expected");
 } catch (AuthorizationException e) {
  // then
  String message = e.getMessage();
  assertTextPresent(userId, message);
  assertTextPresent(READ.getName(), message);
  assertTextPresent(DECISION_DEFINITION_KEY, message);
  assertTextPresent(DECISION_DEFINITION.resourceName(), message);
 }
}

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

@Override
public Response getDecisionDefinitionDiagram() {
 DecisionDefinition definition = engine.getRepositoryService().getDecisionDefinition(decisionDefinitionId);
 InputStream decisionDiagram = engine.getRepositoryService().getDecisionDiagram(decisionDefinitionId);
 if (decisionDiagram == null) {
  return Response.noContent().build();
 } else {
  String fileName = definition.getDiagramResourceName();
  return Response.ok(decisionDiagram).header("Content-Disposition", "attachment; filename=" + fileName)
    .type(ProcessDefinitionResourceImpl.getMediaTypeForFileSuffix(fileName)).build();
 }
}

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

@Test
public void getDecisionDiagramWithAuthenticatedTenant() {
 identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
 InputStream inputStream = repositoryService.getDecisionDiagram(decisionDefinitionId);
 // inputStream is always null because there is no decision diagram at the moment
 // what should be deployed as a diagram resource for DMN? 
 assertThat(inputStream, nullValue());
}

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

@Test
public void getDecisionDiagramDisabledTenantCheck() {
 processEngineConfiguration.setTenantCheckEnabled(false);
 identityService.setAuthentication("user", null, null);
 InputStream inputStream = repositoryService.getDecisionDiagram(decisionDefinitionId);
 // inputStream is always null because there is no decision diagram at the moment
 // what should be deployed as a diagram resource for DMN? 
 assertThat(inputStream, nullValue());
}

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

public void testGetDecisionDiagram() {
 // given
 String decisionDefinitionId = selectDecisionDefinitionByKey(DECISION_DEFINITION_KEY).getId();
 createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, READ);
 // when
 InputStream stream = repositoryService.getDecisionDiagram(decisionDefinitionId);
 // then
 // no decision diagram deployed
 assertNull(stream);
}

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

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

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

public void testGetDecisionDiagramWithoutAuthorizations() {
 // given
 String decisionDefinitionId = selectDecisionDefinitionByKey(DECISION_DEFINITION_KEY).getId();
 try {
  // when
  repositoryService.getDecisionDiagram(decisionDefinitionId);
  fail("Exception expected");
 } catch (AuthorizationException e) {
  // then
  String message = e.getMessage();
  assertTextPresent(userId, message);
  assertTextPresent(READ.getName(), message);
  assertTextPresent(DECISION_DEFINITION_KEY, message);
  assertTextPresent(DECISION_DEFINITION.resourceName(), message);
 }
}

相关文章

微信公众号

最新文章

更多

RepositoryService类方法