.createCaseDefinitionQuery()
.singleResult()
.getId();
// when
CaseInstance caseInstance = caseService
.withCaseDefinitionByKey("oneTaskCase")
.businessKey("aBusinessKey")
.create();
// then
assertNotNull(caseInstance);
// check properties
assertEquals("aBusinessKey", caseInstance.getBusinessKey());
assertEquals(caseDefinitionId, caseInstance.getCaseDefinitionId());
assertEquals(caseInstance.getId(), caseInstance.getCaseInstanceId());
assertTrue(caseInstance.isActive());
assertFalse(caseInstance.isEnabled());
// get persistend case instance
CaseInstance instance = caseService
.createCaseInstanceQuery()
.singleResult();
// should have the same properties
assertEquals(caseInstance.getId(), instance.getId());
assertEquals(caseInstance.getBusinessKey(), instance.getBusinessKey());
assertEquals(caseInstance.getCaseDefinitionId(), instance.getCaseDefinitionId());
assertEquals(caseInstance.getCaseInstanceId(), instance.getCaseInstanceId());
assertEquals(caseInstance.isActive(), instance.isActive());
assertEquals(caseInstance.isEnabled(), instance.isEnabled());
}