Skip to content

Commit

Permalink
Merge branch 'version/1.2.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
rnschk committed Mar 22, 2021
2 parents 3af7b5c + a8798fa commit ed2303c
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<description>This tool helps to control the retry-behaviour in external-task-handlers
based on the official java-client provided by Camunda BPM
</description>
<version>1.1.6</version>
<version>1.2.0</version>
<inceptionYear>2021</inceptionYear>

<organization>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,31 @@
import java.util.Objects;


@ConfigurationProperties(prefix = "de.viadee.bpm.camunda.external-task")
@ConfigurationProperties(prefix = "de.viadee.bpm.camunda.external-task.retry-config")
public class ExternalTaskRetryAspectProperties {

//@formatter:off
private String defaultRetryConfig = "R3/PT5M";
private String retryConfigName = "RETRY_CONFIG";
private String defaultBehavior = "R3/PT5M";
private String identifier = "RETRY_CONFIG";
//@formatter:on


public String getDefaultRetryConfig() {
return this.defaultRetryConfig;
public String getDefaultBehavior() {
return this.defaultBehavior;
}

public void setDefaultRetryConfig(final String defaultRetryConfig) {
if (Objects.isNull(defaultRetryConfig) || defaultRetryConfig.trim().isEmpty()) return;
this.defaultRetryConfig = defaultRetryConfig.replace(" ", "").toUpperCase();
public void setDefaultBehavior(final String defaultBehavior) {
if (Objects.isNull(defaultBehavior) || defaultBehavior.trim().isEmpty()) return;
this.defaultBehavior = defaultBehavior.replace(" ", "").toUpperCase();
}

public String getRetryConfigName() {
return this.retryConfigName;
public String getIdentifier() {
return this.identifier;
}

public void setRetryConfigName(final String retryConfigName) {
if (Objects.isNull(retryConfigName) || retryConfigName.trim().isEmpty()) return;
this.retryConfigName = retryConfigName;
public void setIdentifier(final String identifier) {
if (Objects.isNull(identifier) || identifier.trim().isEmpty()) return;
this.identifier = identifier;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ public RetryConfigValues(final ExternalTaskRetryAspectProperties properties) {
}

public String getRetryConfigName() {
return this.properties.getRetryConfigName();
return this.properties.getIdentifier();
}

public String getDefaultRetryConfig() {
return this.properties.getDefaultRetryConfig();
return this.properties.getDefaultBehavior();
}

public Pattern getRetryListPattern() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ public class ExternalTaskRetryAspectPropertiesTest {
@Test
public void propertiesShouldNotBeNullTest() {
ExternalTaskRetryAspectProperties properties = new ExternalTaskRetryAspectProperties();
properties.setRetryConfigName(null);
properties.setDefaultRetryConfig(null);
assertEquals("R3/PT5M", properties.getDefaultRetryConfig());
assertEquals("RETRY_CONFIG", properties.getRetryConfigName());
properties.setIdentifier(null);
properties.setDefaultBehavior(null);
assertEquals("R3/PT5M", properties.getDefaultBehavior());
assertEquals("RETRY_CONFIG", properties.getIdentifier());
}


@Test
public void propertiesShouldNotBeEmptyTest() {
ExternalTaskRetryAspectProperties properties = new ExternalTaskRetryAspectProperties();
properties.setRetryConfigName(" ");
properties.setDefaultRetryConfig(" ");
assertEquals("R3/PT5M", properties.getDefaultRetryConfig());
assertEquals("RETRY_CONFIG", properties.getRetryConfigName());
properties.setIdentifier(" ");
properties.setDefaultBehavior(" ");
assertEquals("R3/PT5M", properties.getDefaultBehavior());
assertEquals("RETRY_CONFIG", properties.getIdentifier());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
import static org.junit.Assert.assertEquals;


@TestPropertySource(properties = "de.viadee.bpm.camunda.external-task.retry-config-name=CUSTOM_SOMETHING")
@TestPropertySource(properties = "de.viadee.bpm.camunda.external-task.retry-config.identifier=CUSTOM_SOMETHING")
public class CustomRetryTimeCycleIdentifierTest extends BaseTest {

@Test
public void customRetryTimeCycleIdentifier() {
assertEquals("CUSTOM_SOMETHING", this.properties.getRetryConfigName());
assertEquals("CUSTOM_SOMETHING", this.properties.getIdentifier());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void runtimeException() {
// prepare
when(this.externalTask.getRetries()).thenReturn(null);
when(this.externalTask
.getExtensionProperty(this.properties.getRetryConfigName()))
.getExtensionProperty(this.properties.getIdentifier()))
.thenReturn("P,P,P"); // sadly, 'P' is matched by the used regex currently -> use hard-wired Fallback 'PT10M' then

// test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

import static org.mockito.Mockito.when;

@TestPropertySource(properties = "de.viadee.bpm.camunda.external-task.default-retry-time-cycle=R3/PT1D")
@TestPropertySource(properties = "de.viadee.bpm.camunda.external-task.retry-config.defaults=R3/PT1D")
public class InvalidDefaultBehaviourTest extends BaseTest {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import static org.mockito.Mockito.when;


@TestPropertySource(properties = "de.viadee.bpm.camunda.external-task.default-retry-config=R3/PT37M")
@TestPropertySource(properties = "de.viadee.bpm.camunda.external-task.retry-config.default-behavior=R3/PT37M")
public class InvalidRetryTimeCycleValuesTest extends BaseTest {


Expand All @@ -59,7 +59,7 @@ public void invalidRetryTimeCycleList() {
public void invalidTimeCycleDetectedByRegularExpression(final String retryTimeCycle) {
// prepare
when(this.externalTask.getRetries()).thenReturn(3);
when(this.externalTask.getExtensionProperty(this.properties.getRetryConfigName())).thenReturn(retryTimeCycle);
when(this.externalTask.getExtensionProperty(this.properties.getIdentifier())).thenReturn(retryTimeCycle);

// test
this.externalTaskRetryAspect.handleErrorAfterThrown(this.joinPoint, new RuntimeException(), this.externalTask, this.externalTaskService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void retryTimeCycleList1Test() {
public void runTestAndReturnNextInterval(final Integer retries) {
// prepare
when(this.externalTask.getRetries()).thenReturn(retries); // 1. retry
when(this.externalTask.getExtensionProperty(this.properties.getRetryConfigName())).thenReturn(RETRY_CYCLE_LIST);
when(this.externalTask.getExtensionProperty(this.properties.getIdentifier())).thenReturn(RETRY_CYCLE_LIST);

// test
this.externalTaskRetryAspect.handleErrorAfterThrown(this.joinPoint, new RuntimeException(), this.externalTask, this.externalTaskService);
Expand Down

0 comments on commit ed2303c

Please sign in to comment.