本文整理了Java中org.camunda.bpm.engine.RepositoryService.getCaseModel
方法的一些代码示例,展示了RepositoryService.getCaseModel
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RepositoryService.getCaseModel
方法的具体详情如下:
包路径:org.camunda.bpm.engine.RepositoryService
类名称:RepositoryService
方法名:getCaseModel
[英]Gives access to a deployed case model, e.g., a CMMN 1.0 XML file, through a stream of bytes.
[中]通过字节流访问已部署的案例模型,例如CMMN 1.0 XML文件。
代码示例来源:origin: camunda/camunda-bpm-platform
private void setUpRuntimeData(CaseDefinition mockCaseDefinition) {
repositoryServiceMock = mock(RepositoryService.class);
when(processEngine.getRepositoryService()).thenReturn(repositoryServiceMock);
when(repositoryServiceMock.getCaseDefinition(eq(MockProvider.EXAMPLE_CASE_DEFINITION_ID))).thenReturn(mockCaseDefinition);
when(repositoryServiceMock.getCaseModel(eq(MockProvider.EXAMPLE_CASE_DEFINITION_ID))).thenReturn(createMockCaseDefinitionCmmnXml());
caseDefinitionQueryMock = mock(CaseDefinitionQuery.class);
when(caseDefinitionQueryMock.caseDefinitionKey(MockProvider.EXAMPLE_CASE_DEFINITION_KEY)).thenReturn(caseDefinitionQueryMock);
when(caseDefinitionQueryMock.tenantIdIn(anyString())).thenReturn(caseDefinitionQueryMock);
when(caseDefinitionQueryMock.withoutTenantId()).thenReturn(caseDefinitionQueryMock);
when(caseDefinitionQueryMock.latestVersion()).thenReturn(caseDefinitionQueryMock);
when(caseDefinitionQueryMock.singleResult()).thenReturn(mockCaseDefinition);
when(caseDefinitionQueryMock.list()).thenReturn(Collections.singletonList(mockCaseDefinition));
when(repositoryServiceMock.createCaseDefinitionQuery()).thenReturn(caseDefinitionQueryMock);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void getCaseModelWithAuthenticatedTenant() {
identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
InputStream inputStream = repositoryService.getCaseModel(caseDefinitionId);
assertThat(inputStream, notNullValue());
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void testGetCaseModelByInvalidId() throws Exception {
try {
repositoryService.getCaseModel("invalid");
} catch (ProcessEngineException e) {
assertTextPresent("no deployed case definition found with id 'invalid'", e.getMessage());
}
try {
repositoryService.getCaseModel(null);
fail();
} catch (NotValidException e) {
assertTextPresent("caseDefinitionId is null", e.getMessage());
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void getCaseModelDisabledTenantCheck() {
processEngineConfiguration.setTenantCheckEnabled(false);
identityService.setAuthentication("user", null, null);
InputStream inputStream = repositoryService.getCaseModel(caseDefinitionId);
assertThat(inputStream, notNullValue());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void failToGetCaseModelNoAuthenticatedTenants() {
identityService.setAuthentication("user", null, null);
// declare expected exception
thrown.expect(ProcessEngineException.class);
thrown.expectMessage("Cannot get the case definition");
repositoryService.getCaseModel(caseDefinitionId);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public CaseDefinitionDiagramDto getCaseDefinitionCmmnXml() {
InputStream caseModelInputStream = null;
try {
caseModelInputStream = engine.getRepositoryService().getCaseModel(caseDefinitionId);
byte[] caseModel = IoUtil.readInputStream(caseModelInputStream, "caseModelCmmnXml");
return CaseDefinitionDiagramDto.create(caseDefinitionId, new String(caseModel, "UTF-8"));
} 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);
} catch (UnsupportedEncodingException e) {
throw new RestException(Status.INTERNAL_SERVER_ERROR, e);
} finally {
IoUtil.closeSilently(caseModelInputStream);
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public CaseDefinitionDiagramDto getCaseDefinitionCmmnXml() {
InputStream caseModelInputStream = null;
try {
caseModelInputStream = engine.getRepositoryService().getCaseModel(caseDefinitionId);
byte[] caseModel = IoUtil.readInputStream(caseModelInputStream, "caseModelCmmnXml");
return CaseDefinitionDiagramDto.create(caseDefinitionId, new String(caseModel, "UTF-8"));
} 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);
} catch (UnsupportedEncodingException e) {
throw new RestException(Status.INTERNAL_SERVER_ERROR, e);
} finally {
IoUtil.closeSilently(caseModelInputStream);
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = { "org/camunda/bpm/engine/test/repository/one.cmmn" })
public void testGetCaseModel() throws Exception {
CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery();
CaseDefinition caseDefinition = query.singleResult();
String caseDefinitionId = caseDefinition.getId();
InputStream caseModel = repositoryService.getCaseModel(caseDefinitionId);
assertNotNull(caseModel);
byte[] readInputStream = IoUtil.readInputStream(caseModel, "caseModel");
String model = new String(readInputStream, "UTF-8");
assertTrue(model.contains("<case id=\"one\" name=\"One\">"));
IoUtil.closeSilently(caseModel);
}
代码示例来源:origin: org.camunda.bpm/camunda-engine
@Test
public void getCaseModelWithAuthenticatedTenant() {
identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
InputStream inputStream = repositoryService.getCaseModel(caseDefinitionId);
assertThat(inputStream, notNullValue());
}
代码示例来源:origin: org.camunda.bpm/camunda-engine
public void testGetCaseModelByInvalidId() throws Exception {
try {
repositoryService.getCaseModel("invalid");
} catch (ProcessEngineException e) {
assertTextPresent("no deployed case definition found with id 'invalid'", e.getMessage());
}
try {
repositoryService.getCaseModel(null);
fail();
} catch (NotValidException e) {
assertTextPresent("caseDefinitionId is null", e.getMessage());
}
}
代码示例来源:origin: org.camunda.bpm/camunda-engine
@Test
public void getCaseModelDisabledTenantCheck() {
processEngineConfiguration.setTenantCheckEnabled(false);
identityService.setAuthentication("user", null, null);
InputStream inputStream = repositoryService.getCaseModel(caseDefinitionId);
assertThat(inputStream, notNullValue());
}
代码示例来源:origin: org.camunda.bpm/camunda-engine-rest-jaxrs2
@Override
public CaseDefinitionDiagramDto getCaseDefinitionCmmnXml() {
InputStream caseModelInputStream = null;
try {
caseModelInputStream = engine.getRepositoryService().getCaseModel(caseDefinitionId);
byte[] caseModel = IoUtil.readInputStream(caseModelInputStream, "caseModelCmmnXml");
return CaseDefinitionDiagramDto.create(caseDefinitionId, new String(caseModel, "UTF-8"));
} 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);
} catch (UnsupportedEncodingException e) {
throw new RestException(Status.INTERNAL_SERVER_ERROR, e);
} finally {
IoUtil.closeSilently(caseModelInputStream);
}
}
代码示例来源:origin: org.camunda.bpm/camunda-engine
@Test
public void failToGetCaseModelNoAuthenticatedTenants() {
identityService.setAuthentication("user", null, null);
// declare expected exception
thrown.expect(ProcessEngineException.class);
thrown.expectMessage("Cannot get the case definition");
repositoryService.getCaseModel(caseDefinitionId);
}
代码示例来源:origin: org.camunda.bpm/camunda-engine
@Deployment(resources = { "org/camunda/bpm/engine/test/repository/one.cmmn" })
public void testGetCaseModel() throws Exception {
CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery();
CaseDefinition caseDefinition = query.singleResult();
String caseDefinitionId = caseDefinition.getId();
InputStream caseModel = repositoryService.getCaseModel(caseDefinitionId);
assertNotNull(caseModel);
byte[] readInputStream = IoUtil.readInputStream(caseModel, "caseModel");
String model = new String(readInputStream, "UTF-8");
assertTrue(model.contains("<case id=\"one\" name=\"One\">"));
IoUtil.closeSilently(caseModel);
}
内容来源于网络,如有侵权,请联系作者删除!