cancel
Showing results for 
Search instead for 
Did you mean: 

@Deployment and tenant ids?

robojeff
Champ in-the-making
Champ in-the-making
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.
1 REPLY 1

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

It appears a tenant ID cannot be specified in the @Deployment declaration, correct?
Yes

Is this the best way to deploy a process for a specific tenant in a JUnit test?
From my point of view with the current code base, yes

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?
Have a look on the @Deployment annotation impl. It is done in the similar way.

Regards
Martin