Skip to content

Commit d6340ea

Browse files
fixed a bug where merging did not work (#629)
1 parent cde880e commit d6340ea

File tree

4 files changed

+86
-27
lines changed

4 files changed

+86
-27
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
zeebe.client.broker.gateway-address=127.0.0.1:26500
2-
zeebe.client.security.plaintext=true
2+
zeebe.client.security.plaintext=true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package io.camunda.zeebe.spring.client.properties;
2+
3+
import io.camunda.zeebe.spring.client.annotation.value.ZeebeWorkerValue;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static org.assertj.core.api.Assertions.*;
7+
8+
public class PropertyBasedZeebeWorkerValueCustomizerTest {
9+
@Test
10+
void shouldApplyOverrides(){
11+
ZeebeClientConfigurationProperties properties = new ZeebeClientConfigurationProperties(null);
12+
properties.applyOverrides();
13+
properties.getWorker().getOverride().put("someWorker",new ZeebeWorkerValue().enabled(false));
14+
PropertyBasedZeebeWorkerValueCustomizer customizer = new PropertyBasedZeebeWorkerValueCustomizer(properties);
15+
ZeebeWorkerValue original = new ZeebeWorkerValue().type("someWorker").enabled(true);
16+
customizer.customize(original);
17+
assertThat(original.getEnabled()).isEqualTo(false);
18+
}
19+
}

spring-client-zeebe/src/main/java/io/camunda/zeebe/spring/client/annotation/processor/ZeebeWorkerAnnotationProcessor.java

+16-16
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ public Optional<ZeebeWorkerValue> readJobWorkerAnnotationForMethod(final MethodI
6868
if (methodAnnotation.isPresent()) {
6969
JobWorker annotation = methodAnnotation.get();
7070
return Optional.of(new ZeebeWorkerValue()
71-
.setMethodInfo(methodInfo)
72-
.setType(annotation.type())
73-
.setTimeout(annotation.timeout())
74-
.setMaxJobsActive(annotation.maxJobsActive())
75-
.setPollInterval(annotation.pollInterval())
76-
.setAutoComplete(annotation.autoComplete())
77-
.setRequestTimeout(annotation.requestTimeout())
78-
.setEnabled(annotation.enabled())
71+
.methodInfo(methodInfo)
72+
.type(annotation.type())
73+
.timeout(annotation.timeout())
74+
.maxJobsActive(annotation.maxJobsActive())
75+
.pollInterval(annotation.pollInterval())
76+
.autoComplete(annotation.autoComplete())
77+
.requestTimeout(annotation.requestTimeout())
78+
.enabled(annotation.enabled())
7979

8080
// TODO Get rid of those initialize methods but add the attributes as values onto the worker and then auto-initialize stuff when opening the worker
8181
.initializeName(annotation.name(), methodInfo, defaultWorkerName)
@@ -86,14 +86,14 @@ public Optional<ZeebeWorkerValue> readJobWorkerAnnotationForMethod(final MethodI
8686
if (legacyAnnotation.isPresent()) {
8787
ZeebeWorker annotation = legacyAnnotation.get();
8888
return Optional.of(new ZeebeWorkerValue()
89-
.setMethodInfo(methodInfo)
90-
.setType(annotation.type())
91-
.setTimeout(annotation.timeout())
92-
.setMaxJobsActive(annotation.maxJobsActive())
93-
.setPollInterval(annotation.pollInterval())
94-
.setAutoComplete(annotation.autoComplete())
95-
.setRequestTimeout(annotation.requestTimeout())
96-
.setEnabled(annotation.enabled())
89+
.methodInfo(methodInfo)
90+
.type(annotation.type())
91+
.timeout(annotation.timeout())
92+
.maxJobsActive(annotation.maxJobsActive())
93+
.pollInterval(annotation.pollInterval())
94+
.autoComplete(annotation.autoComplete())
95+
.requestTimeout(annotation.requestTimeout())
96+
.enabled(annotation.enabled())
9797

9898
// TODO Get rid of those initialize methods but add the attributes as values onto the worker and then auto-initialize stuff when opening the worker
9999
.initializeName(annotation.name(), methodInfo, defaultWorkerName)

spring-client-zeebe/src/main/java/io/camunda/zeebe/spring/client/annotation/value/ZeebeWorkerValue.java

+50-10
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,52 @@ public Boolean getEnabled() {
108108
return enabled;
109109
}
110110

111-
public ZeebeWorkerValue setEnabled(Boolean enabled) {
111+
public void setType(String type) {
112+
this.type = type;
113+
}
114+
115+
public void setName(String name) {
116+
this.name = name;
117+
}
118+
119+
public void setTimeout(Long timeout) {
120+
this.timeout = timeout;
121+
}
122+
123+
public void setMaxJobsActive(Integer maxJobsActive) {
124+
this.maxJobsActive = maxJobsActive;
125+
}
126+
127+
public void setRequestTimeout(Long requestTimeout) {
128+
this.requestTimeout = requestTimeout;
129+
}
130+
131+
public void setPollInterval(Long pollInterval) {
132+
this.pollInterval = pollInterval;
133+
}
134+
135+
public void setAutoComplete(Boolean autoComplete) {
136+
this.autoComplete = autoComplete;
137+
}
138+
139+
public void setFetchVariables(String[] fetchVariables) {
140+
this.fetchVariables = fetchVariables;
141+
}
142+
143+
public void setEnabled(Boolean enabled) {
144+
this.enabled = enabled;
145+
}
146+
147+
public void setMethodInfo(MethodInfo methodInfo) {
148+
this.methodInfo = methodInfo;
149+
}
150+
151+
public ZeebeWorkerValue enabled(Boolean enabled) {
112152
this.enabled = enabled;
113153
return this;
114154
}
115155

116-
public ZeebeWorkerValue setType(String type) {
156+
public ZeebeWorkerValue type(String type) {
117157
this.type = type;
118158
// You can only set a type of a worker - in this case the name is set equals to the type
119159
if (name==null) {
@@ -122,42 +162,42 @@ public ZeebeWorkerValue setType(String type) {
122162
return this;
123163
}
124164

125-
public ZeebeWorkerValue setName(String name) {
165+
public ZeebeWorkerValue name(String name) {
126166
this.name = name;
127167
return this;
128168
}
129169

130-
public ZeebeWorkerValue setTimeout(Long timeout) {
170+
public ZeebeWorkerValue timeout(Long timeout) {
131171
this.timeout = timeout;
132172
return this;
133173
}
134174

135-
public ZeebeWorkerValue setMaxJobsActive(Integer maxJobsActive) {
175+
public ZeebeWorkerValue maxJobsActive(Integer maxJobsActive) {
136176
this.maxJobsActive = maxJobsActive;
137177
return this;
138178
}
139179

140-
public ZeebeWorkerValue setRequestTimeout(Long requestTimeout) {
180+
public ZeebeWorkerValue requestTimeout(Long requestTimeout) {
141181
this.requestTimeout = requestTimeout;
142182
return this;
143183
}
144184

145-
public ZeebeWorkerValue setPollInterval(Long pollInterval) {
185+
public ZeebeWorkerValue pollInterval(Long pollInterval) {
146186
this.pollInterval = pollInterval;
147187
return this;
148188
}
149189

150-
public ZeebeWorkerValue setAutoComplete(Boolean autoComplete) {
190+
public ZeebeWorkerValue autoComplete(Boolean autoComplete) {
151191
this.autoComplete = autoComplete;
152192
return this;
153193
}
154194

155-
public ZeebeWorkerValue setFetchVariables(String[] fetchVariables) {
195+
public ZeebeWorkerValue fetchVariables(String[] fetchVariables) {
156196
this.fetchVariables = fetchVariables;
157197
return this;
158198
}
159199

160-
public ZeebeWorkerValue setMethodInfo(MethodInfo methodInfo) {
200+
public ZeebeWorkerValue methodInfo(MethodInfo methodInfo) {
161201
this.methodInfo = methodInfo;
162202
return this;
163203
}

0 commit comments

Comments
 (0)