diff --git a/commons-testing/src/main/java/be/sddevelopment/commons/testing/ReplaceUnderscoredCamelCasing.java b/commons-testing/src/main/java/be/sddevelopment/commons/testing/ReplaceUnderscoredCamelCasing.java index 4be3b38..4c838db 100755 --- a/commons-testing/src/main/java/be/sddevelopment/commons/testing/ReplaceUnderscoredCamelCasing.java +++ b/commons-testing/src/main/java/be/sddevelopment/commons/testing/ReplaceUnderscoredCamelCasing.java @@ -68,7 +68,7 @@ public String generateDisplayNameForMethod(Class testClass, Method testMethod private String replaceCapitals(String name) { name = name.replaceAll("([A-Z])", " $1").toLowerCase(); - name = name.replaceAll("([0-9]+)", " $1"); + name = name.replaceAll("(\\d+)", " $1"); name = name.replace("given", "GIVEN"); name = name.replace("when", "WHEN"); name = name.replace("then", "THEN"); diff --git a/commons/src/main/java/be/sddevelopment/commons/validation/Fallible.java b/commons/src/main/java/be/sddevelopment/commons/validation/Fallible.java index c6228df..2dee30c 100755 --- a/commons/src/main/java/be/sddevelopment/commons/validation/Fallible.java +++ b/commons/src/main/java/be/sddevelopment/commons/validation/Fallible.java @@ -29,7 +29,6 @@ import java.util.Objects; import java.util.function.Consumer; import java.util.function.Function; -import java.util.stream.Collectors; /** *

@@ -181,7 +180,7 @@ private void validate() { .apply(this.data) .apply(errorTemplate.failure(this.data))) .map(FailureBuilder::build) - .collect(Collectors.toList()); + .toList(); } } diff --git a/commons/src/test/java/be/sddevelopment/commons/validation/FallibleTest.java b/commons/src/test/java/be/sddevelopment/commons/validation/FallibleTest.java index 8a4dc8b..f06bef4 100755 --- a/commons/src/test/java/be/sddevelopment/commons/validation/FallibleTest.java +++ b/commons/src/test/java/be/sddevelopment/commons/validation/FallibleTest.java @@ -45,7 +45,7 @@ class FallibleTest { public final List NAUGHTY_WORDS = singletonList("string"); - public final String NAUGHTY_ERROR = "Your word seems to contain a naughty bit [%s]"; + public static final String NAUGHTY_ERROR = "Your word seems to contain a naughty bit [%s]"; static class ConsumerServiceStub { @@ -110,7 +110,7 @@ void givenAConditionWithAnErrorCode_whenContitionIsNotMet_thenTheFailureContains List errors = Fallible .of("StringToCheck") .ensure(FallibleTest.this::mayNotContainNaughtyWords, - d -> b -> b.errorCode("NAUGHTY_ERROR") + d -> b -> b.errorCode(NAUGHTY_ERROR) ) .ensure(StringUtils::isNotBlank, d -> b -> b.errorCode("MUST_BE_FILLED_IN") @@ -118,7 +118,7 @@ void givenAConditionWithAnErrorCode_whenContitionIsNotMet_thenTheFailureContains .failures(); assertThat(errors).hasSize(1); - assertThat(errors).extracting(Failure::getErrorCode).containsExactly("NAUGHTY_ERROR"); + assertThat(errors).extracting(Failure::getErrorCode).containsExactly(NAUGHTY_ERROR); } @Test @@ -126,7 +126,7 @@ void givenMultipleConditionsWithErrorCodes_whenContitionsAreNotMet_thenTheFailur List errors = Fallible .of("") .ensure(FallibleTest.this::mayNotContainNaughtyWords, - d -> b -> b.errorCode("NAUGHTY_ERROR") + d -> b -> b.errorCode(NAUGHTY_ERROR) ) .ensure(StringUtils::isNotBlank, d -> b -> b.errorCode("MUST_BE_FILLED_IN") @@ -175,7 +175,7 @@ void givenAConditionWithAnErrorCode_whenContitionIsNotMet_thenTheFailureContains .data() .compliesTo( FallibleTest.this::mayNotContainNaughtyWords) - .elseFail(withCode("NAUGHTY_ERROR"))) + .elseFail(withCode(NAUGHTY_ERROR))) .ensure(FieldValidationRule .data() .compliesTo(StringUtils::isNotBlank) @@ -183,7 +183,7 @@ void givenAConditionWithAnErrorCode_whenContitionIsNotMet_thenTheFailureContains .failures(); assertThat(errors).hasSize(1); - assertThat(errors).extracting(Failure::getErrorCode).containsExactly("NAUGHTY_ERROR"); + assertThat(errors).extracting(Failure::getErrorCode).containsExactly(NAUGHTY_ERROR); } } @@ -191,7 +191,7 @@ void givenAConditionWithAnErrorCode_whenContitionIsNotMet_thenTheFailureContains @DisplayName("Fallible conditional menthod executions when failure") class FallibleFailedConditionalTests { - public final Condition> NOT_YET_CALLED = new Condition<>( + public static final Condition> NOT_YET_CALLED = new Condition<>( c -> !c.isCalled(), "Precondition: Service is not yet called"); private ConsumerServiceStub stringConsumer; @@ -241,7 +241,7 @@ void givenAFailureActionIsDefined_andMultipleConditionsAreChained_whenTheFirstCo @DisplayName("Fallible conditional menthod executions when succesful") class FallibleConditionalExecutionsTests { - public final Condition> NOT_YET_CALLED = new Condition<>( + public static final Condition> NOT_YET_CALLED = new Condition<>( c -> !c.isCalled(), "Precondition: Service is not yet called"); private ConsumerServiceStub stringConsumer; @@ -381,24 +381,6 @@ void givenThatNoTemplateIsProvided_andAReasonIsProvided_whenAFailureOccurs_theRe assertThat(failures).extracting(Failure::getReason).contains("Input can not be blank"); } - @Test - void givenATemplateWithoutDataReference_whenAFailureOccurs_thenAFailureExistsWithADerivativeMessage() { - - List failures = Fallible - .of("") - .errorTemplate(template( - s -> "The string [" + s + "] does not match rule: {%s}")) - .ensure(StringUtils::isNotBlank, - s -> b -> b.reason("Input can not be blank") - ) - .failures(); - - assertThat(failures).hasSize(1); - assertThat(failures) - .extracting(Failure::getReason) - .contains("The string [] does not match rule: {Input can not be blank}"); - } - } Boolean mayNotContainNaughtyWords(String toCheck) {