Skip to content

Commit ea753a8

Browse files
committed
added a test to prove a zeebe worker value picks up the tenant ids
1 parent c1e1ed5 commit ea753a8

File tree

2 files changed

+62
-41
lines changed

2 files changed

+62
-41
lines changed

spring-client-zeebe/src/test/java/io/camunda/zeebe/spring/client/bean/ClassInfoTest.java

+46-41
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,46 @@
88

99
public class ClassInfoTest {
1010

11+
@Test
12+
public void getBeanInfo() throws Exception {
13+
final WithDeploymentAnnotation withDeploymentAnnotation = new WithDeploymentAnnotation();
14+
15+
final ClassInfo beanInfo = beanInfo(withDeploymentAnnotation);
16+
17+
assertThat(beanInfo.getBean()).isEqualTo(withDeploymentAnnotation);
18+
assertThat(beanInfo.getBeanName()).isEqualTo("withDeploymentAnnotation");
19+
assertThat(beanInfo.getTargetClass()).isEqualTo(WithDeploymentAnnotation.class);
20+
}
21+
22+
@Test
23+
public void hasZeebeeDeploymentAnnotation() throws Exception {
24+
assertThat(beanInfo(new WithDeploymentAnnotation()).hasClassAnnotation(Deployment.class))
25+
.isTrue();
26+
}
27+
28+
@Test
29+
public void hasNoZeebeeDeploymentAnnotation() throws Exception {
30+
assertThat(beanInfo(new WithoutDeploymentAnnotation()).hasClassAnnotation(Deployment.class))
31+
.isFalse();
32+
}
33+
34+
@Test
35+
public void hasZeebeWorkerMethod() throws Exception {
36+
assertThat(beanInfo(new WithZeebeWorker()).hasMethodAnnotation(JobWorker.class)).isTrue();
37+
}
38+
39+
@Test
40+
public void hasNotZeebeWorkerMethod() throws Exception {
41+
assertThat(beanInfo("normal String").hasMethodAnnotation(JobWorker.class)).isFalse();
42+
}
43+
44+
private ClassInfo beanInfo(final Object bean) {
45+
return ClassInfo.builder()
46+
.bean(bean)
47+
.beanName(Introspector.decapitalize(bean.getClass().getSimpleName()))
48+
.build();
49+
}
50+
1151
@Deployment(resources = "classpath*:/1.bpmn")
1252
public static class WithDeploymentAnnotation {}
1353

@@ -45,57 +85,22 @@ public void handle(@Variable String var1, @Variable int var2) {}
4585
}
4686

4787
public static class WithZeebeWorkerVariablesComplexType {
88+
@JobWorker(type = "bar", timeout = 100L, fetchVariables = "var2", autoComplete = false)
89+
public void handle(@Variable String var1, @Variable ComplexTypeDTO var2) {}
90+
4891
public static class ComplexTypeDTO {
4992
private String var1;
5093
private String var2;
5194
}
52-
53-
@JobWorker(type = "bar", timeout = 100L, fetchVariables = "var2", autoComplete = false)
54-
public void handle(@Variable String var1, @Variable ComplexTypeDTO var2) {}
5595
}
5696

5797
public static class NoPropertiesSet {
5898
@JobWorker
5999
public void handle() {}
60100
}
61101

62-
@Test
63-
public void getBeanInfo() throws Exception {
64-
final WithDeploymentAnnotation withDeploymentAnnotation = new WithDeploymentAnnotation();
65-
66-
final ClassInfo beanInfo = beanInfo(withDeploymentAnnotation);
67-
68-
assertThat(beanInfo.getBean()).isEqualTo(withDeploymentAnnotation);
69-
assertThat(beanInfo.getBeanName()).isEqualTo("withDeploymentAnnotation");
70-
assertThat(beanInfo.getTargetClass()).isEqualTo(WithDeploymentAnnotation.class);
71-
}
72-
73-
@Test
74-
public void hasZeebeeDeploymentAnnotation() throws Exception {
75-
assertThat(beanInfo(new WithDeploymentAnnotation()).hasClassAnnotation(Deployment.class))
76-
.isTrue();
77-
}
78-
79-
@Test
80-
public void hasNoZeebeeDeploymentAnnotation() throws Exception {
81-
assertThat(beanInfo(new WithoutDeploymentAnnotation()).hasClassAnnotation(Deployment.class))
82-
.isFalse();
83-
}
84-
85-
@Test
86-
public void hasZeebeWorkerMethod() throws Exception {
87-
assertThat(beanInfo(new WithZeebeWorker()).hasMethodAnnotation(JobWorker.class)).isTrue();
88-
}
89-
90-
@Test
91-
public void hasNotZeebeWorkerMethod() throws Exception {
92-
assertThat(beanInfo("normal String").hasMethodAnnotation(JobWorker.class)).isFalse();
93-
}
94-
95-
private ClassInfo beanInfo(final Object bean) {
96-
return ClassInfo.builder()
97-
.bean(bean)
98-
.beanName(Introspector.decapitalize(bean.getClass().getSimpleName()))
99-
.build();
102+
public static class TenantBound {
103+
@JobWorker(tenantIds = "tenant-1")
104+
public void handle() {}
100105
}
101106
}

spring-client-zeebe/src/test/java/io/camunda/zeebe/spring/client/bean/value/factory/ReadZeebeWorkerValueTest.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.camunda.zeebe.spring.client.bean.value.factory;
22

3+
import static org.assertj.core.api.Assertions.*;
34
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
45
import static org.junit.jupiter.api.Assertions.assertEquals;
56
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -43,6 +44,21 @@ public void applyOnWithZeebeWorker() {
4344
assertEquals(methodInfo, zeebeWorkerValue.get().getMethodInfo());
4445
}
4546

47+
@Test
48+
void shouldReadTenantIds() {
49+
// given
50+
final ZeebeWorkerAnnotationProcessor annotationProcessor = createDefaultAnnotationProcessor();
51+
final MethodInfo methodInfo = extract(ClassInfoTest.TenantBound.class);
52+
53+
// when
54+
final Optional<ZeebeWorkerValue> zeebeWorkerValue =
55+
annotationProcessor.readJobWorkerAnnotationForMethod(methodInfo);
56+
57+
// then
58+
assertTrue(zeebeWorkerValue.isPresent());
59+
assertThat(zeebeWorkerValue.get().getTenantIds()).containsOnly("tenant-1");
60+
}
61+
4662
@Test
4763
public void applyOnWithZeebeWorkerAllValues() {
4864
// given

0 commit comments

Comments
 (0)