Java Code Examples for org.camunda.bpm.engine.repository.CaseDefinitionQuery#singleResult()

The following examples show how to use org.camunda.bpm.engine.repository.CaseDefinitionQuery#singleResult() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiTenancyCaseDefinitionQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testQueryByLatestWithoutTenantId() {
  // deploy a second version without tenant id
  deployment(CMMN);

  CaseDefinitionQuery query = repositoryService
      .createCaseDefinitionQuery()
      .caseDefinitionKey(CASE_DEFINITION_KEY)
      .latestVersion()
      .withoutTenantId();

  assertThat(query.count(), is(1L));

  CaseDefinition cDefinition = query.singleResult();
  assertThat(cDefinition.getTenantId(), is(nullValue()));
  assertThat(cDefinition.getVersion(), is(2));
}
 
Example 2
Source File: MultiTenancyCaseDefinitionQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testQueryByLatestWithTenantId() {
  // deploy a second version for tenant one
  deploymentForTenant(TENANT_ONE, CMMN);

  CaseDefinitionQuery query = repositoryService
      .createCaseDefinitionQuery()
      .caseDefinitionKey(CASE_DEFINITION_KEY)
      .latestVersion()
      .tenantIdIn(TENANT_ONE);

  assertThat(query.count(), is(1L));

  CaseDefinition caseDefinition = query.singleResult();
  assertThat(caseDefinition.getTenantId(), is(TENANT_ONE));
  assertThat(caseDefinition.getVersion(), is(2));

  query = repositoryService
      .createCaseDefinitionQuery()
      .caseDefinitionKey(CASE_DEFINITION_KEY)
      .latestVersion()
      .tenantIdIn(TENANT_TWO);

  assertThat(query.count(), is(1L));

  caseDefinition = query.singleResult();
  assertThat(caseDefinition.getTenantId(), is(TENANT_TWO));
  assertThat(caseDefinition.getVersion(), is(1));
}
 
Example 3
Source File: RepositoryServiceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = { "org/camunda/bpm/engine/test/repository/one.cmmn" })
public void testGetCaseDefinition() {
  CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery();

  CaseDefinition caseDefinition = query.singleResult();
  String caseDefinitionId = caseDefinition.getId();

  CaseDefinition definition = repositoryService.getCaseDefinition(caseDefinitionId);

  assertNotNull(definition);
  assertEquals(caseDefinitionId, definition.getId());
}
 
Example 4
Source File: RepositoryServiceTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@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);
}