.tenantId(TEST_TENANT_ID)
.deploy()
.getId();
// verify job (timer start)
Job job = managementService.createJobQuery().singleResult();
assertEquals(TEST_TENANT_ID, job.getTenantId());
managementService.executeJob(job.getId());
// Verify Job tenancy (process intermediary timer)
job = managementService.createJobQuery().singleResult();
assertEquals(TEST_TENANT_ID, job.getTenantId());
// Start process, and verify async job has correct tenant id
managementService.executeJob(job.getId());
job = managementService.createJobQuery().singleResult();
assertEquals(TEST_TENANT_ID, job.getTenantId());
// Finish process
managementService.executeJob(job.getId());
// Do the same, but now without a tenant
String deploymentId2 = repositoryService.createDeployment()
.addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testJobTenancy.bpmn20.xml")
.deploy()
.getId();
job = managementService.createJobQuery().singleResult();
assertEquals("", job.getTenantId());
managementService.executeJob(job.getId());
job = managementService.createJobQuery().singleResult();
assertEquals("", job.getTenantId());
managementService.executeJob(job.getId());
job = managementService.createJobQuery().singleResult();
assertEquals("", job.getTenantId());
// clean up
repositoryService.deleteDeployment(deploymentId, true);
repositoryService.deleteDeployment(deploymentId2, true);
}