本文整理了Java中org.camunda.bpm.engine.RepositoryService.getDecisionDefinition
方法的一些代码示例,展示了RepositoryService.getDecisionDefinition
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RepositoryService.getDecisionDefinition
方法的具体详情如下:
包路径:org.camunda.bpm.engine.RepositoryService
类名称:RepositoryService
方法名:getDecisionDefinition
[英]Returns the DecisionDefinition.
[中]返回DecisionDefinition。
代码示例来源: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
private void setUpRuntimeData(DecisionDefinition mockDecisionDefinition) {
repositoryServiceMock = mock(RepositoryService.class);
when(processEngine.getRepositoryService()).thenReturn(repositoryServiceMock);
when(repositoryServiceMock.getDecisionDefinition(eq(MockProvider.EXAMPLE_DECISION_DEFINITION_ID))).thenReturn(mockDecisionDefinition);
when(repositoryServiceMock.getDecisionModel(eq(MockProvider.EXAMPLE_DECISION_DEFINITION_ID))).thenReturn(createMockDecisionDefinitionDmnXml());
decisionDefinitionQueryMock = mock(DecisionDefinitionQuery.class);
when(decisionDefinitionQueryMock.decisionDefinitionKey(MockProvider.EXAMPLE_DECISION_DEFINITION_KEY)).thenReturn(decisionDefinitionQueryMock);
when(decisionDefinitionQueryMock.tenantIdIn(anyString())).thenReturn(decisionDefinitionQueryMock);
when(decisionDefinitionQueryMock.withoutTenantId()).thenReturn(decisionDefinitionQueryMock);
when(decisionDefinitionQueryMock.latestVersion()).thenReturn(decisionDefinitionQueryMock);
when(decisionDefinitionQueryMock.singleResult()).thenReturn(mockDecisionDefinition);
when(decisionDefinitionQueryMock.list()).thenReturn(Collections.singletonList(mockDecisionDefinition));
when(repositoryServiceMock.createDecisionDefinitionQuery()).thenReturn(decisionDefinitionQueryMock);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void getDecisionDefinitionWithAuthenticatedTenant() {
identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
DecisionDefinition definition = repositoryService.getDecisionDefinition(decisionDefinitionId);
assertThat(definition.getTenantId(), is(TENANT_ONE));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void updateHistoryTimeToLiveWithAuthenticatedTenant() {
identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinitionId, 6);
DecisionDefinition definition = repositoryService.getDecisionDefinition(decisionDefinitionId);
assertThat(definition.getTenantId(), is(TENANT_ONE));
assertThat(definition.getHistoryTimeToLive(), is(6));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public DecisionDefinitionDto getDecisionDefinition() {
RepositoryService repositoryService = engine.getRepositoryService();
DecisionDefinition definition = null;
try {
definition = repositoryService.getDecisionDefinition(decisionDefinitionId);
} 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 DecisionDefinitionDto.fromDecisionDefinition(definition);
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testGetDecisionDefinitionByInvalidId() {
try {
repositoryService.getDecisionDefinition("invalid");
fail();
} catch (NotFoundException e) {
assertTextPresent("no deployed decision definition found with id 'invalid'", e.getMessage());
}
try {
repositoryService.getDecisionDefinition(null);
fail();
} catch (NotValidException e) {
assertTextPresent("decisionDefinitionId is null", e.getMessage());
}
}
代码示例来源: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
@Override
public DecisionDefinitionDto getDecisionDefinition() {
RepositoryService repositoryService = engine.getRepositoryService();
DecisionDefinition definition = null;
try {
definition = repositoryService.getDecisionDefinition(decisionDefinitionId);
} 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 DecisionDefinitionDto.fromDecisionDefinition(definition);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void getDecisionDefinitionDisabledTenantCheck() {
processEngineConfiguration.setTenantCheckEnabled(false);
identityService.setAuthentication("user", null, null);
DecisionDefinition definition = repositoryService.getDecisionDefinition(decisionDefinitionId);
assertThat(definition.getTenantId(), is(TENANT_ONE));
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testGetDecisionDefinition() {
// given
String decisionDefinitionId = selectDecisionDefinitionByKey(DECISION_DEFINITION_KEY).getId();
createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, READ);
// when
DecisionDefinition decisionDefinition = repositoryService.getDecisionDefinition(decisionDefinitionId);
// then
assertNotNull(decisionDefinition);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void failToGetDecisionDefinitionNoAuthenticatedTenants() {
identityService.setAuthentication("user", null, null);
// declare expected exception
thrown.expect(ProcessEngineException.class);
thrown.expectMessage("Cannot get the decision definition");
repositoryService.getDecisionDefinition(decisionDefinitionId);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testDefinitionRetrieval_ByKey() {
given()
.pathParam("key", MockProvider.EXAMPLE_DECISION_DEFINITION_KEY)
.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(null))
.when()
.get(SINGLE_DECISION_DEFINITION_BY_KEY_URL);
verify(decisionDefinitionQueryMock).withoutTenantId();
verify(repositoryServiceMock).getDecisionDefinition(MockProvider.EXAMPLE_DECISION_DEFINITION_ID);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void updateHistoryTimeToLiveDisabledTenantCheck() {
processEngineConfiguration.setTenantCheckEnabled(false);
identityService.setAuthentication("user", null, null);
repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinitionId, 6);
DecisionDefinition definition = repositoryService.getDecisionDefinition(decisionDefinitionId);
assertThat(definition.getTenantId(), is(TENANT_ONE));
assertThat(definition.getHistoryTimeToLive(), is(6));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testDefinitionRetrieval() {
given()
.pathParam("id", MockProvider.EXAMPLE_DECISION_DEFINITION_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(null))
.when()
.get(SINGLE_DECISION_DEFINITION_URL);
verify(repositoryServiceMock).getDecisionDefinition(MockProvider.EXAMPLE_DECISION_DEFINITION_ID);
}
代码示例来源: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
@Deployment(resources = { "org/camunda/bpm/engine/test/repository/one.dmn" })
public void testGetDecisionDefinition() {
DecisionDefinitionQuery query = repositoryService.createDecisionDefinitionQuery();
DecisionDefinition decisionDefinition = query.singleResult();
String decisionDefinitionId = decisionDefinition.getId();
DecisionDefinition definition = repositoryService.getDecisionDefinition(decisionDefinitionId);
assertNotNull(definition);
assertEquals(decisionDefinitionId, definition.getId());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = { "org/camunda/bpm/engine/test/api/dmn/Example.dmn"})
public void testDecisionDefinitionUpdateTimeToLiveNull() {
//given
DecisionDefinition decisionDefinition = findOnlyDecisionDefinition();
//when
repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinition.getId(), null);
//then
decisionDefinition = (DecisionDefinitionEntity) repositoryService.getDecisionDefinition(decisionDefinition.getId());
assertEquals(null, decisionDefinition.getHistoryTimeToLive());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testGetDecisionDefinitionWithoutAuthorizations() {
// given
String decisionDefinitionId = selectDecisionDefinitionByKey(DECISION_DEFINITION_KEY).getId();
try {
// when
repositoryService.getDecisionDefinition(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);
}
}
内容来源于网络,如有侵权,请联系作者删除!