Skip to content

Commit b604693

Browse files
committed
Fix deprecated Assertion usage
1 parent 4a784c2 commit b604693

File tree

6 files changed

+23
-18
lines changed

6 files changed

+23
-18
lines changed

docs/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void givenCheckedWithInvalidData_whenApplyingRule_itIsEvaluatedAsInvalid() {
139139

140140
assertThat(result).is(invalid());
141141
assertThat(result.rationale())
142-
.extracting(Rationale::details).asList()
142+
.extracting(Rationale::details).asInstanceOf(LIST)
143143
.contains(failed("mustn't be blank"));
144144
}
145145
```

pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@
129129
<artifactId>log4j-slf4j2-impl</artifactId>
130130
<version>2.24.0</version>
131131
</dependency>
132-
133-
134-
135132
</dependencies>
136133

137134
<build>

src/main/java/be/sddevelopment/validation/core/Constraint.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
*/
1818
public record Constraint<T>(Predicate<T> rule, String description) {
1919

20+
/**
21+
* Factory method to create a new {@link ConstraintBuilder} instance.
22+
*
23+
* @param <S> type of the object onto which the rule can be applied
24+
* @param ignoredClass class to be ignored, as this method is only used as a type parameter
25+
* to create a new instance of the builder
26+
* @return a new instance of the {@link ConstraintBuilder} class, able to evaluate a rule on an object of type S
27+
*/
2028
public static <S> ConstraintBuilder<S> ruleFor(Class<S> ignoredClass) {
2129
return new ConstraintBuilder<>();
2230
}

src/test/java/be/sddevelopment/validation/core/ConstrainedTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void givenValidData_whenApplyingRule_itsEvaluationIsRemembered() {
3333

3434
assertThat(result).is(valid());
3535
assertThat(result.rationale())
36-
.extracting(Rationale::details).asList()
36+
.extracting(Rationale::details).asInstanceOf(LIST)
3737
.contains(passed("mustn't be blank"));
3838
}
3939

@@ -47,7 +47,7 @@ void givenInvalidData_whenApplyingRule_itIsEvaluatedAsInvalid() {
4747

4848
assertThat(result).is(invalid());
4949
assertThat(result.rationale())
50-
.extracting(Rationale::details).asList()
50+
.extracting(Rationale::details).asInstanceOf(LIST)
5151
.contains(failed("mustn't be blank"));
5252
}
5353

@@ -81,7 +81,7 @@ void ifValid_givenTheDateIsValid_CallsTheProvidedConsumer() {
8181

8282
checked.ifValid(consumer::store);
8383

84-
84+
assertThat(consumer.messages()).containsExactly("I am a real String");
8585
}
8686

8787
@Test
@@ -96,7 +96,7 @@ void guard_failsFastWhenInvalid() {
9696

9797
assertThatExceptionOfType(InvalidObjectException.class)
9898
.isThrownBy(constrainedRecord::guard)
99-
.extracting(InvalidObjectException::errors).asList()
99+
.extracting(InvalidObjectException::errors).asInstanceOf(LIST)
100100
.containsExactly("FAIL: [have a first name]");
101101
}
102102

src/test/java/be/sddevelopment/validation/core/ConstraintTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void rules_areChainable() {
4343

4444
assertThat(result).is(CheckedTestUtils.invalid())
4545
.extracting(Constrained::rationale)
46-
.extracting(Rationale::details).asList()
46+
.extracting(Rationale::details).asInstanceOf(LIST)
4747
.contains(passed("Must be filled in"), failed("Be polite"));
4848
}
4949

src/test/java/be/sddevelopment/validation/specs/code_quality/CodeConventionsTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,33 @@
2626
class CodeConventionsTest implements WithAssertions {
2727

2828
@ArchTest
29-
private final ArchRule no_access_to_standard_streams = NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS;
29+
static final ArchRule CLASSES_DO_NOT_ACCESS_STANDARD_STREAMS = NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS;
3030

3131
@ArchTest
32-
void no_access_to_standard_streams_as_method(JavaClasses classes) {
32+
void noAccessToStandardStreamsAsMethod(JavaClasses classes) {
3333
noClasses().should(ACCESS_STANDARD_STREAMS).check(classes);
3434
}
3535

3636
@ArchTest
37-
private final ArchRule no_classes_should_use_field_injection = NO_CLASSES_SHOULD_USE_FIELD_INJECTION;
37+
static final ArchRule NO_CLASSES_USE_FIELD_INJECTION = NO_CLASSES_SHOULD_USE_FIELD_INJECTION;
3838

3939
@ArchTest
40-
private final ArchRule no_generic_exceptions = NO_CLASSES_SHOULD_THROW_GENERIC_EXCEPTIONS;
40+
static final ArchRule NO_GENERIC_EXCEPTION = NO_CLASSES_SHOULD_THROW_GENERIC_EXCEPTIONS;
4141

4242
@ArchTest
43-
private final ArchRule no_java_util_logging = NO_CLASSES_SHOULD_USE_JAVA_UTIL_LOGGING;
43+
static final ArchRule NO_JAVA_UTIL_LOGGING = NO_CLASSES_SHOULD_USE_JAVA_UTIL_LOGGING;
4444

4545
@ArchTest
46-
private final ArchRule no_jodatime = NO_CLASSES_SHOULD_USE_JODATIME;
46+
static final ArchRule NO_JODATIME = NO_CLASSES_SHOULD_USE_JODATIME;
4747

4848
@ArchTest
49-
private final ArchRule utility_classes_can_not_be_instantiated = noClasses()
49+
static final ArchRule UTILITY_CLASSES_CAN_NOT_BE_INSTANTIATED = noClasses()
5050
.that().haveModifier(FINAL)
5151
.and().haveSimpleNameNotContaining("Test")
5252
.and().areNotEnums()
5353
.should(beInstantiatable());
5454

55-
private ArchCondition<? super JavaClass> beInstantiatable() {
55+
static ArchCondition<? super JavaClass> beInstantiatable() {
5656
return new ArchCondition<>("be instantiatable") {
5757
@Override
5858
public void check(JavaClass item, ConditionEvents events) {
@@ -65,7 +65,7 @@ public void check(JavaClass item, ConditionEvents events) {
6565
};
6666
}
6767

68-
boolean isInstantiatable(JavaClass classToCheck) {
68+
static boolean isInstantiatable(JavaClass classToCheck) {
6969

7070
try {
7171
if (classToCheck.getConstructors().stream()

0 commit comments

Comments
 (0)