Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: Merging property overrides did not work #628

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
zeebe.client.broker.gateway-address=127.0.0.1:26500
zeebe.client.security.plaintext=true
zeebe.client.security.plaintext=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.camunda.zeebe.spring.client.properties;

import io.camunda.zeebe.spring.client.annotation.value.ZeebeWorkerValue;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.*;

public class PropertyBasedZeebeWorkerValueCustomizerTest {
@Test
void shouldApplyOverrides(){
ZeebeClientConfigurationProperties properties = new ZeebeClientConfigurationProperties(null);
properties.applyOverrides();
properties.getWorker().getOverride().put("someWorker",new ZeebeWorkerValue().enabled(false));
PropertyBasedZeebeWorkerValueCustomizer customizer = new PropertyBasedZeebeWorkerValueCustomizer(properties);
ZeebeWorkerValue original = new ZeebeWorkerValue().type("someWorker").enabled(true);
customizer.customize(original);
assertThat(original.getEnabled()).isEqualTo(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ public Optional<ZeebeWorkerValue> readJobWorkerAnnotationForMethod(final MethodI
if (methodAnnotation.isPresent()) {
JobWorker annotation = methodAnnotation.get();
return Optional.of(new ZeebeWorkerValue()
.setMethodInfo(methodInfo)
.setType(annotation.type())
.setTimeout(annotation.timeout())
.setMaxJobsActive(annotation.maxJobsActive())
.setPollInterval(annotation.pollInterval())
.setAutoComplete(annotation.autoComplete())
.setRequestTimeout(annotation.requestTimeout())
.setEnabled(annotation.enabled())
.methodInfo(methodInfo)
.type(annotation.type())
.timeout(annotation.timeout())
.maxJobsActive(annotation.maxJobsActive())
.pollInterval(annotation.pollInterval())
.autoComplete(annotation.autoComplete())
.requestTimeout(annotation.requestTimeout())
.enabled(annotation.enabled())

// 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
.initializeName(annotation.name(), methodInfo, defaultWorkerName)
Expand All @@ -86,14 +86,14 @@ public Optional<ZeebeWorkerValue> readJobWorkerAnnotationForMethod(final MethodI
if (legacyAnnotation.isPresent()) {
ZeebeWorker annotation = legacyAnnotation.get();
return Optional.of(new ZeebeWorkerValue()
.setMethodInfo(methodInfo)
.setType(annotation.type())
.setTimeout(annotation.timeout())
.setMaxJobsActive(annotation.maxJobsActive())
.setPollInterval(annotation.pollInterval())
.setAutoComplete(annotation.autoComplete())
.setRequestTimeout(annotation.requestTimeout())
.setEnabled(annotation.enabled())
.methodInfo(methodInfo)
.type(annotation.type())
.timeout(annotation.timeout())
.maxJobsActive(annotation.maxJobsActive())
.pollInterval(annotation.pollInterval())
.autoComplete(annotation.autoComplete())
.requestTimeout(annotation.requestTimeout())
.enabled(annotation.enabled())

// 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
.initializeName(annotation.name(), methodInfo, defaultWorkerName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,52 @@ public Boolean getEnabled() {
return enabled;
}

public ZeebeWorkerValue setEnabled(Boolean enabled) {
public void setType(String type) {
this.type = type;
}

public void setName(String name) {
this.name = name;
}

public void setTimeout(Long timeout) {
this.timeout = timeout;
}

public void setMaxJobsActive(Integer maxJobsActive) {
this.maxJobsActive = maxJobsActive;
}

public void setRequestTimeout(Long requestTimeout) {
this.requestTimeout = requestTimeout;
}

public void setPollInterval(Long pollInterval) {
this.pollInterval = pollInterval;
}

public void setAutoComplete(Boolean autoComplete) {
this.autoComplete = autoComplete;
}

public void setFetchVariables(String[] fetchVariables) {
this.fetchVariables = fetchVariables;
}

public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}

public void setMethodInfo(MethodInfo methodInfo) {
this.methodInfo = methodInfo;
}

public ZeebeWorkerValue enabled(Boolean enabled) {
this.enabled = enabled;
return this;
}

public ZeebeWorkerValue setType(String type) {
public ZeebeWorkerValue type(String type) {
this.type = type;
// You can only set a type of a worker - in this case the name is set equals to the type
if (name==null) {
Expand All @@ -122,42 +162,42 @@ public ZeebeWorkerValue setType(String type) {
return this;
}

public ZeebeWorkerValue setName(String name) {
public ZeebeWorkerValue name(String name) {
this.name = name;
return this;
}

public ZeebeWorkerValue setTimeout(Long timeout) {
public ZeebeWorkerValue timeout(Long timeout) {
this.timeout = timeout;
return this;
}

public ZeebeWorkerValue setMaxJobsActive(Integer maxJobsActive) {
public ZeebeWorkerValue maxJobsActive(Integer maxJobsActive) {
this.maxJobsActive = maxJobsActive;
return this;
}

public ZeebeWorkerValue setRequestTimeout(Long requestTimeout) {
public ZeebeWorkerValue requestTimeout(Long requestTimeout) {
this.requestTimeout = requestTimeout;
return this;
}

public ZeebeWorkerValue setPollInterval(Long pollInterval) {
public ZeebeWorkerValue pollInterval(Long pollInterval) {
this.pollInterval = pollInterval;
return this;
}

public ZeebeWorkerValue setAutoComplete(Boolean autoComplete) {
public ZeebeWorkerValue autoComplete(Boolean autoComplete) {
this.autoComplete = autoComplete;
return this;
}

public ZeebeWorkerValue setFetchVariables(String[] fetchVariables) {
public ZeebeWorkerValue fetchVariables(String[] fetchVariables) {
this.fetchVariables = fetchVariables;
return this;
}

public ZeebeWorkerValue setMethodInfo(MethodInfo methodInfo) {
public ZeebeWorkerValue methodInfo(MethodInfo methodInfo) {
this.methodInfo = methodInfo;
return this;
}
Expand Down
Loading