diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/GenericTypesTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/GenericTypesTest.java index 0a24e1fc3..c3cce62cf 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/GenericTypesTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/GenericTypesTest.java @@ -167,6 +167,30 @@ public int hashCode() { } } + static final class Generic { + + private final T t; + + public Generic(T t) { + this.t = t; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Generic)) { + return false; + } + @SuppressWarnings("unchecked") + Generic other = (Generic) obj; + return Objects.equals(t, other.t); + } + + @Override + public int hashCode() { + return Objects.hash(t); + } + } + static final class JavaGenericTypeContainer { private final Optional optional; @@ -218,30 +242,6 @@ public String toString() { } } - static final class Generic { - - private final T t; - - public Generic(T t) { - this.t = t; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof Generic)) { - return false; - } - @SuppressWarnings("unchecked") - Generic other = (Generic) obj; - return Objects.equals(t, other.t); - } - - @Override - public int hashCode() { - return Objects.hash(t); - } - } - static final class ListContainer { private final List list; diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ConfiguredEqualsVerifierMultipleTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ConfiguredEqualsVerifierMultipleTest.java index 94ce5f16d..8600efe44 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ConfiguredEqualsVerifierMultipleTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ConfiguredEqualsVerifierMultipleTest.java @@ -156,6 +156,27 @@ public void individuallySuppressedWarningsAreNotAddedGlobally() { public void individuallyAddedPrefabValuesAreNotAddedGlobally() { ConfiguredEqualsVerifier ev = EqualsVerifier.configure(); + // should succeed + ev + .forClasses(RecursiveTypeContainer.class, A.class) + .withPrefabValues( + RecursiveType.class, + new RecursiveType(null), + new RecursiveType(new RecursiveType(null)) + ) + .verify(); + + // PrefabValues are not added to configuration, so should fail + ExpectedException + .when(() -> ev.forClasses(RecursiveTypeContainer.class, A.class).verify()) + .assertFailure() + .assertMessageContains("Recursive datastructure"); + } + + @Test + public void individuallyAddedGenericPrefabValuesAreNotAddedGlobally() { + ConfiguredEqualsVerifier ev = EqualsVerifier.configure(); + // should succeed ev .forClasses(SingleGenericContainerContainer.class, A.class) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ConfiguredEqualsVerifierSingleTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ConfiguredEqualsVerifierSingleTest.java index 16cd8f8a9..7ace3f1ae 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ConfiguredEqualsVerifierSingleTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ConfiguredEqualsVerifierSingleTest.java @@ -117,6 +117,27 @@ public void individuallySuppressedWarningsAreNotAddedGlobally() { public void individuallyAddedPrefabValuesAreNotAddedGlobally() { ConfiguredEqualsVerifier ev = EqualsVerifier.configure(); + // should succeed + ev + .forClass(RecursiveTypeContainer.class) + .withPrefabValues( + RecursiveType.class, + new RecursiveType(null), + new RecursiveType(new RecursiveType(null)) + ) + .verify(); + + // PrefabValues are not added to configuration, so should fail + ExpectedException + .when(() -> ev.forClass(RecursiveTypeContainer.class).verify()) + .assertFailure() + .assertMessageContains("Recursive datastructure"); + } + + @Test + public void individuallyAddedGenericPrefabValuesAreNotAddedGlobally() { + ConfiguredEqualsVerifier ev = EqualsVerifier.configure(); + // should succeed ev .forClass(SingleGenericContainerContainer.class)