Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 13 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>4.0.4</version>
<version>4.0.7</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand All @@ -16,16 +17,16 @@

<properties>
<java.version>25</java.version>
<errorprone.version>2.48.0</errorprone.version>
<nullaway.version>0.13.1</nullaway.version>
<errorprone.version>2.50.0</errorprone.version>
<nullaway.version>0.13.7</nullaway.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>it.aboutbits</groupId>
<artifactId>spring-boot-toolbox</artifactId>
<version>2.4.4</version>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>it.aboutbits</groupId>
Expand Down Expand Up @@ -59,6 +60,13 @@
<optional>true</optional>
</dependency>

<!-- Source: https://mvnrepository.com/artifact/com.google.errorprone/error_prone_annotations -->
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
<version>${errorprone.version}</version>
</dependency>

<!-- Testing -->
<dependency>
<groupId>org.springframework.security</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.testing.persistence;

import com.google.errorprone.annotations.CheckReturnValue;
import it.aboutbits.springboot.testing.spring.BeanAccessor;
import it.aboutbits.springboot.toolbox.persistence.ChangeAware;
import it.aboutbits.springboot.toolbox.type.identity.EntityId;
Expand Down Expand Up @@ -28,6 +29,7 @@ private static EntityManager getEntityManager() {
}

@SuppressWarnings("unused")
@CheckReturnValue
public static <ID extends EntityId<?>, E extends Identified<ID> & ChangeAware, M extends Identified<ID> & ChangeAware> WriteOperationAsserter<ID, E, M> assertThatEntity(
E before,
Class<M> modelClass
Expand All @@ -36,6 +38,7 @@ public static <ID extends EntityId<?>, E extends Identified<ID> & ChangeAware, M
}

@SuppressWarnings("unused")
@CheckReturnValue
public static <ID extends EntityId<?>, E extends Identified<ID> & ChangeAware, M extends Identified<ID> & ChangeAware> WriteOperationAsserter<ID, E, M> assertThatEntity(
Collection<E> before,
Class<M> modelClass
Expand All @@ -44,6 +47,7 @@ public static <ID extends EntityId<?>, E extends Identified<ID> & ChangeAware, M
}

@SuppressWarnings("unused")
@CheckReturnValue
public static <ID extends EntityId<?>, M extends Identified<ID>> WriteOperationIdAsserter<ID, M> assertThatEntityId(
ID id,
Class<M> modelClass
Expand All @@ -52,6 +56,7 @@ public static <ID extends EntityId<?>, M extends Identified<ID>> WriteOperationI
}

@SuppressWarnings("unused")
@CheckReturnValue
public static <ID extends EntityId<?>, M extends Identified<ID>> WriteOperationIdAsserter<ID, M> assertThatEntityId(
Collection<ID> id,
Class<M> modelClass
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.testing.testdata.base;

import com.google.errorprone.annotations.CheckReturnValue;
import org.jspecify.annotations.NullMarked;

import java.util.Comparator;
Expand All @@ -24,6 +25,7 @@ public List<ITEM> returnAll() {

@SafeVarargs
@SuppressWarnings("unused")
@CheckReturnValue
public final List<ITEM> returnSorted(Comparator<ITEM>... comparators) {
if (comparators.length == 0) {
throw new IllegalArgumentException("At least one comparator must be provided");
Expand All @@ -39,6 +41,7 @@ public final List<ITEM> returnSorted(Comparator<ITEM>... comparators) {

@SafeVarargs
@SuppressWarnings({"unchecked", "unused"})
@CheckReturnValue
public final <U extends Comparable<? super U>> List<ITEM> returnSorted(Function<ITEM, ? extends Comparable<?>>... comparators) {
if (comparators.length == 0) {
throw new IllegalArgumentException("At least one comparator must be provided");
Expand All @@ -53,6 +56,7 @@ public final <U extends Comparable<? super U>> List<ITEM> returnSorted(Function<
}

@SuppressWarnings("unused")
@CheckReturnValue
public <U extends Comparable<? super U>> AllAndFiltered<ITEM> returnFiltered(Predicate<ITEM> predicate) {
var all = this.returnAll();
return new AllAndFiltered<>(
Expand All @@ -63,6 +67,7 @@ public <U extends Comparable<? super U>> AllAndFiltered<ITEM> returnFiltered(Pre
}

@SuppressWarnings("unused")
@CheckReturnValue
public Set<ITEM> returnSet() {
return new HashSet<>(this.returnAll());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.testing.testdata.base;

import com.google.errorprone.annotations.CheckReturnValue;
import lombok.extern.slf4j.Slf4j;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
Expand Down Expand Up @@ -31,6 +32,7 @@ protected ModifiableTestDataCreator(int count) {
}

@SuppressWarnings({"unchecked", "unused"})
@CheckReturnValue
public CREATOR modifyParameter(BiFunction<PARAMETER, Integer, PARAMETER> parameterMutator) {
this.parameterMutator = (parameter, index) -> {
mutatorCalled = true;
Expand All @@ -41,6 +43,7 @@ public CREATOR modifyParameter(BiFunction<PARAMETER, Integer, PARAMETER> paramet
}

@SuppressWarnings({"unchecked", "unused"})
@CheckReturnValue
public CREATOR modifyParameter(UnaryOperator<PARAMETER> parameterMutator) {
this.parameterMutator = (parameter, index) -> {
mutatorCalled = true;
Expand All @@ -51,12 +54,14 @@ public CREATOR modifyParameter(UnaryOperator<PARAMETER> parameterMutator) {
}

@SuppressWarnings({"unchecked", "unused"})
@CheckReturnValue
public CREATOR modifyResult(ObjIntConsumer<ITEM> resultMutator) {
this.resultMutator = resultMutator;
return (CREATOR) this;
}

@SuppressWarnings({"unchecked", "unused"})
@CheckReturnValue
public CREATOR modifyResult(Consumer<ITEM> resultMutator) {
this.resultMutator = (item, index) -> resultMutator.accept(item);
return (CREATOR) this;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.testing.testdata.base;

import com.google.errorprone.annotations.CheckReturnValue;
import it.aboutbits.springboot.testing.testdata.FakerExtended;
import org.jspecify.annotations.NullMarked;

Expand Down Expand Up @@ -28,17 +29,20 @@ public void commit() {
}

@SuppressWarnings("unused")
@CheckReturnValue
public ITEM returnFirst() {
return create().getFirst();
}

@SuppressWarnings("unused")
@CheckReturnValue
public List<ITEM> returnAll() {
return create();
}

@SafeVarargs
@SuppressWarnings("unused")
@CheckReturnValue
public final List<ITEM> returnSorted(Comparator<ITEM>... comparators) {
if (comparators.length == 0) {
throw new IllegalArgumentException("At least one comparator must be provided");
Expand All @@ -54,6 +58,7 @@ public final List<ITEM> returnSorted(Comparator<ITEM>... comparators) {

@SafeVarargs
@SuppressWarnings({"unchecked", "unused"})
@CheckReturnValue
public final <U extends Comparable<? super U>> List<ITEM> returnSorted(Function<ITEM, ? extends Comparable<?>>... comparators) {
if (comparators.length == 0) {
throw new IllegalArgumentException("At least one comparator must be provided");
Expand All @@ -68,6 +73,7 @@ public final <U extends Comparable<? super U>> List<ITEM> returnSorted(Function<
}

@SuppressWarnings("unused")
@CheckReturnValue
public Set<ITEM> returnSet() {
return new HashSet<>(create());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.testing.validation.core;

import com.google.errorprone.annotations.CheckReturnValue;
import it.aboutbits.springboot.toolbox.type.CustomType;
import jakarta.validation.Valid;
import lombok.AccessLevel;
Expand Down Expand Up @@ -49,13 +50,15 @@ public static void registerNonBeanType(Class<?> type) {
NON_BEAN_TYPES.add(type);
}

@CheckReturnValue
public <P> CallBuilder<R, P> of(P parameterUnderTest) {
this.parameterUnderTest = parameterUnderTest;
ruleBuilder.setTriggerValidation(this::assertValidation);
return new CallBuilder<>(this);
}

@SuppressWarnings("unused")
@CheckReturnValue
public AnnotationChecker calling(
Class<?> classUnderTest,
String methodName,
Expand Down Expand Up @@ -97,17 +100,20 @@ public static final class CallBuilder<R extends BaseRuleBuilder<?>, P> {
private final BaseValidationAssert<R> parent;

@SuppressWarnings("unused")
@CheckReturnValue
public R calling(Consumer<P> functionToCallWithParameter) {
parent.setFunctionToCallWithParameter(functionToCallWithParameter);
return parent.ruleBuilder;
}

@SuppressWarnings("unused")
@CheckReturnValue
public R usingBeanValidation() {
return parent.ruleBuilder;
}

@SuppressWarnings({"unused", "unchecked"})
@CheckReturnValue
public <ID> R calling(
BiConsumer<ID, P> functionToCallWithParameter,
ID id
Expand All @@ -119,6 +125,7 @@ public <ID> R calling(
}

@SuppressWarnings({"unused", "unchecked"})
@CheckReturnValue
public <A, B> R calling(
TriConsumer<A, B, P> functionToCallWithParameter,
A a,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.testing.validation.rule;

import com.google.errorprone.annotations.CheckReturnValue;
import it.aboutbits.springboot.testing.validation.core.BaseRuleBuilder;
import it.aboutbits.springboot.testing.validation.core.Rule;
import it.aboutbits.springboot.testing.validation.core.ValidationRulesData;
Expand All @@ -10,6 +11,7 @@
@SuppressWarnings("unchecked")
@NullMarked
public interface BetweenRule<V extends BaseRuleBuilder<?>> extends ValidationRulesData {
@CheckReturnValue
default V between(String property, long min, long max) {
addRule(
new Rule(property, BiggerThanValueSource.class, max)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.testing.validation.rule;

import com.google.errorprone.annotations.CheckReturnValue;
import it.aboutbits.springboot.testing.validation.core.BaseRuleBuilder;
import it.aboutbits.springboot.testing.validation.core.Rule;
import it.aboutbits.springboot.testing.validation.core.ValidationRulesData;
Expand All @@ -9,6 +10,7 @@
@SuppressWarnings("unchecked")
@NullMarked
public interface FutureRule<V extends BaseRuleBuilder<?>> extends ValidationRulesData {
@CheckReturnValue
default V future(String property) {
addRule(
new Rule(property, PastValueSource.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.testing.validation.rule;

import com.google.errorprone.annotations.CheckReturnValue;
import it.aboutbits.springboot.testing.validation.core.BaseRuleBuilder;
import it.aboutbits.springboot.testing.validation.core.Rule;
import it.aboutbits.springboot.testing.validation.core.ValidationRulesData;
Expand All @@ -9,6 +10,7 @@
@SuppressWarnings("unchecked")
@NullMarked
public interface MaxRule<V extends BaseRuleBuilder<?>> extends ValidationRulesData {
@CheckReturnValue
default V max(String property, long max) {
addRule(
new Rule(property, BiggerThanValueSource.class, max)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.testing.validation.rule;

import com.google.errorprone.annotations.CheckReturnValue;
import it.aboutbits.springboot.testing.validation.core.BaseRuleBuilder;
import it.aboutbits.springboot.testing.validation.core.Rule;
import it.aboutbits.springboot.testing.validation.core.ValidationRulesData;
Expand All @@ -9,6 +10,7 @@
@SuppressWarnings("unchecked")
@NullMarked
public interface MinRule<V extends BaseRuleBuilder<?>> extends ValidationRulesData {
@CheckReturnValue
default V min(String property, long min) {
addRule(
new Rule(property, LessThanValueSource.class, min)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.testing.validation.rule;

import com.google.errorprone.annotations.CheckReturnValue;
import it.aboutbits.springboot.testing.validation.core.BaseRuleBuilder;
import it.aboutbits.springboot.testing.validation.core.Rule;
import it.aboutbits.springboot.testing.validation.core.ValidationRulesData;
Expand All @@ -9,6 +10,7 @@
@SuppressWarnings("unchecked")
@NullMarked
public interface NegativeOrZeroRule<V extends BaseRuleBuilder<?>> extends ValidationRulesData {
@CheckReturnValue
default V negativeOrZero(String property) {
addRule(
new Rule(property, BiggerThanValueSource.class, 0L)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.testing.validation.rule;

import com.google.errorprone.annotations.CheckReturnValue;
import it.aboutbits.springboot.testing.validation.core.BaseRuleBuilder;
import it.aboutbits.springboot.testing.validation.core.Rule;
import it.aboutbits.springboot.testing.validation.core.ValidationRulesData;
Expand All @@ -10,6 +11,7 @@
@SuppressWarnings("unchecked")
@NullMarked
public interface NegativeRule<V extends BaseRuleBuilder<?>> extends ValidationRulesData {
@CheckReturnValue
default V negative(String property) {
addRule(
new Rule(property, BiggerThanValueSource.class, 0L)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.testing.validation.rule;

import com.google.errorprone.annotations.CheckReturnValue;
import it.aboutbits.springboot.testing.validation.core.BaseRuleBuilder;
import it.aboutbits.springboot.testing.validation.core.Rule;
import it.aboutbits.springboot.testing.validation.core.ValidationRulesData;
Expand All @@ -10,6 +11,7 @@
@SuppressWarnings("unchecked")
@NullMarked
public interface NotBlankRule<V extends BaseRuleBuilder<?>> extends ValidationRulesData {
@CheckReturnValue
default V notBlank(String property) {
addRule(
new Rule(property, BlankValueSource.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.testing.validation.rule;

import com.google.errorprone.annotations.CheckReturnValue;
import it.aboutbits.springboot.testing.validation.core.BaseRuleBuilder;
import it.aboutbits.springboot.testing.validation.core.Rule;
import it.aboutbits.springboot.testing.validation.core.ValidationRulesData;
Expand All @@ -10,6 +11,7 @@
@SuppressWarnings("unchecked")
@NullMarked
public interface NotEmptyRule<V extends BaseRuleBuilder<?>> extends ValidationRulesData {
@CheckReturnValue
default V notEmpty(String property) {
addRule(
new Rule(property, EmptyValueSource.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.testing.validation.rule;

import com.google.errorprone.annotations.CheckReturnValue;
import it.aboutbits.springboot.testing.validation.core.BaseRuleBuilder;
import it.aboutbits.springboot.testing.validation.core.Rule;
import it.aboutbits.springboot.testing.validation.core.ValidationRulesData;
Expand All @@ -9,6 +10,7 @@
@SuppressWarnings("unchecked")
@NullMarked
public interface NotNullRule<V extends BaseRuleBuilder<?>> extends ValidationRulesData {
@CheckReturnValue
default V notNull(String property) {
addRule(
new Rule(property, NullValueSource.class)
Expand Down
Loading