AnsweredAssumed Answered

@Deployment and tenant ids?

Question asked by robojeff on Jul 12, 2016
Latest reply on Jul 13, 2016 by martin.grofcik
Hello,

I've written some JUnit tests that make use of the ActivitiRule (using @Rule) and annotating my @Test methods with the @Deployment annotation to deploy my BPM files.  I'm experimenting with writing tests that configure a tenant id.  It appears a tenant ID cannot be specified in the @Deployment declaration, correct?

I found that I had to programmatically deploy the process and define the tenant ID in the same step:


String deploymentId = activitiRule.getRepositoryService()
                                                    .createDeployment()
                                                    .addClasspathResource("diagrams/my-process.bpmn")
                                                    .tenantId(tenantId)
                                                    .deploy()
                                                    .getId();


Is this the best way to deploy a process for a specific tenant in a JUnit test?

Also, slightly related to this topic…When I use @Rule ActivitiRule to bootstrap my JUnit test with a working instance of the BPM engine, the state of the H2 database appears to persist between each @Test method.  I wrote some clean up code at the end of my test method:


activitiRule.getRepositoryService().deleteDeployment(deploymentId, true);


I'm contemplating writing some kind of test harness that could hold on to the deployment ID and remove the deployment in an @After annotated method.  Is there a more elegant solution that someone has come up with to ensure all @Test methods start with a nice clean instance of the repository? I like my unit test cases to be capable of running in any order.

Outcomes