From 34d992b6598eb1e9c0974b1ea391249c2a8ee32d Mon Sep 17 00:00:00 2001 From: Jan Ouwens Date: Thu, 19 Dec 2024 19:20:00 +0100 Subject: [PATCH] Introduces AssertJ to replace JUnit assertions --- .../extended_contract/JavaFxClassesTest.java | 16 +-- equalsverifier-16/pom.xml | 6 + .../InstanceofPatternMatchTest.java | 2 +- .../PrefabValuesForFieldInRecordTest.java | 12 +- .../extended_contract/RecordsTest.java | 45 ++++--- .../RecordInstanceCreatorTest.java | 12 +- .../factories/RecordFallbackFactoryTest.java | 10 +- .../RecordObjectAccessorCopyingTest.java | 13 +- .../RecordObjectAccessorScramblingTest.java | 12 +- .../reflection/RecordObjectAccessorTest.java | 21 ++-- .../reflection/ClassProbeRecordTest.java | 8 +- .../reflection/RecordInstantiatorTest.java | 8 +- equalsverifier-17/pom.xml | 6 + .../SealedTypesRecursionTest.java | 4 +- .../extended_contract/SealedTypesTest.java | 18 +-- .../SealedTypesFallbackFactoryTest.java | 10 +- .../reflection/ClassProbeSealedTest.java | 13 +- .../SealedTypesHelperTest.java | 14 +-- .../SequencedCollectionsClassesTest.java | 4 +- equalsverifier-core/pom.xml | 10 +- .../coverage/CoverageNoInheritanceTest.java | 6 +- .../coverage/CoverageNonnullTest.java | 4 +- .../coverage/CoverageWithInheritanceTest.java | 6 +- .../basic_contract/HashCodeTest.java | 8 +- .../basic_contract/NonNullityTest.java | 6 +- .../basic_contract/ReflexivityTest.java | 18 +-- .../basic_contract/SymmetryTest.java | 4 +- .../basic_contract/TransitivityTest.java | 22 ++-- .../AbstractDelegationTest.java | 47 ++++---- .../extended_contract/ArrayTest.java | 38 +++--- .../BalancedAbstractnessTest.java | 19 +-- .../extended_contract/BigDecimalTest.java | 10 +- .../DontOverrideEqualsTest.java | 12 +- .../extended_contract/EnumTest.java | 18 +-- .../ExtendedReflexivityTest.java | 30 ++--- .../ExternalApiClassesTest.java | 20 ++-- .../extended_contract/FloatAndDoubleTest.java | 14 +-- .../extended_contract/GenericTypesTest.java | 46 +++---- .../extended_contract/InterfaceTest.java | 6 +- .../extended_contract/JavaApiClassesTest.java | 32 ++--- .../JavaCollectionSubclassTest.java | 4 +- .../extended_contract/ModulesTest.java | 6 +- .../extended_contract/MutableStateTest.java | 20 ++-- .../extended_contract/NullFieldsTest.java | 35 +++--- .../NullFieldsWithExceptionsTest.java | 10 +- .../extended_contract/SignatureTest.java | 16 +-- .../SignificantFieldsTest.java | 90 +++++++------- .../extended_contract/StringTest.java | 8 +- .../SyntheticFieldsTest.java | 17 +-- .../TransientFieldsTest.java | 20 ++-- .../extended_contract/TypeCheckTest.java | 8 +- .../AnnotationImmutableTest.java | 8 +- .../AnnotationNonNullFieldsTest.java | 4 +- .../AnnotationNonnullEclipseTest.java | 26 ++-- .../extra_features/AnnotationNonnullTest.java | 68 +++++------ .../AnnotationNullMarkedTest.java | 16 +-- ...tionParametersAreNonnullByDefaultTest.java | 16 +-- .../extra_features/AnnotationsIgnoreTest.java | 12 +- .../extra_features/CachedHashCodeTest.java | 46 +++---- .../GetClassInEqualityComparisonTest.java | 8 +- .../extra_features/GetClassTest.java | 20 ++-- .../extra_features/JakartaEntityTest.java | 14 +-- .../extra_features/JakartaIdTest.java | 68 +++++------ .../extra_features/JakartaLazyEntityTest.java | 44 +++---- .../extra_features/JpaEntityTest.java | 20 ++-- .../integration/extra_features/JpaIdTest.java | 72 +++++------ .../extra_features/JpaLazyEntityTest.java | 46 +++---- .../LombokLazyEqualsAndHashcodeTest.java | 8 +- .../RelaxedEqualsPreconditionTest.java | 32 ++--- .../extra_features/RelaxedEqualsTest.java | 12 +- .../SimpleEqualsVerifierTest.java | 20 ++-- .../extra_features/VersionedEntityTest.java | 36 +++--- .../extra_features/WarningsMixTest.java | 24 ++-- .../inheritance/AbstractHierarchyTest.java | 14 +-- .../integration/inheritance/FinalityTest.java | 18 +-- .../integration/inheritance/SubclassTest.java | 26 ++-- .../inheritance/SuperclassTest.java | 22 ++-- .../ConfiguredEqualsVerifierMultipleTest.java | 43 ++++--- .../ConfiguredEqualsVerifierSingleTest.java | 28 ++--- .../MultipleTypeEqualsVerifierTest.java | 78 ++++++------ .../operational/OriginalStateTest.java | 38 +++--- .../integration/operational/OutputTest.java | 16 +-- .../operational/RecursionTest.java | 36 +++--- .../integration/operational/ReportTest.java | 35 +++--- .../operational/SignedJarTest.java | 6 +- .../WithGenericPrefabValuesTest.java | 28 ++--- .../WithPrefabValuesForFieldTest.java | 32 ++--- .../operational/WithPrefabValuesTest.java | 16 +-- .../internal/EqualsVerifierTest.java | 4 +- ...qualsVerifierInternalBugExceptionTest.java | 10 +- .../exceptions/NoValueExceptionTest.java | 8 +- .../exceptions/RecursionExceptionTest.java | 8 +- .../instantiation/InstanceCreatorTest.java | 22 ++-- .../instantiation/SubjectCreatorTest.java | 82 ++++++------- .../vintage/FactoryCacheTest.java | 46 +++---- .../vintage/PrefabValuesApiTest.java | 4 +- .../VintageValueProviderCreatorTest.java | 58 ++++----- .../vintage/VintageValueProviderTest.java | 84 ++++++------- .../factories/AbstractGenericFactoryTest.java | 14 +-- .../prefabvalues/factories/FactoriesTest.java | 4 +- .../factories/FallbackFactoryTest.java | 41 ++++--- .../factories/MapFactoryTest.java | 32 ++--- .../factories/SimpleFactoryTest.java | 16 +-- .../factories/SimpleGenericFactoryTest.java | 32 ++--- .../JavaFxFactoryProviderTest.java | 31 +++-- .../vintage/reflection/ClassAccessorTest.java | 48 ++++---- .../vintage/reflection/FieldModifierTest.java | 13 +- .../InPlaceObjectAccessorCopyingTest.java | 21 ++-- .../InPlaceObjectAccessorScramblingTest.java | 60 +++++----- .../reflection/InPlaceObjectAccessorTest.java | 13 +- .../internal/reflection/ClassProbeTest.java | 90 +++++++------- .../ConditionalInstantiatorTest.java | 90 +++++++------- .../internal/reflection/FieldCacheTest.java | 32 ++--- .../reflection/FieldIterableTest.java | 65 +++++----- .../internal/reflection/FieldMutatorTest.java | 28 ++--- .../internal/reflection/FieldProbeTest.java | 112 +++++++++--------- .../internal/reflection/InstantiatorTest.java | 51 ++++---- .../reflection/PackageScannerTest.java | 74 ++++++------ .../reflection/SuperclassIterableTest.java | 38 +++--- .../internal/reflection/TupleTest.java | 22 ++-- .../reflection/TypeTagParameterizedTest.java | 10 +- .../internal/reflection/TypeTagTest.java | 60 +++++----- .../internal/reflection/UtilTest.java | 34 +++--- .../AnnotationCacheBuilderTest.java | 76 ++++++------ .../annotations/SupportedAnnotationsTest.java | 25 ++-- .../internal/util/AssertTest.java | 18 +-- .../internal/util/FieldNameExtractorTest.java | 29 ++--- .../internal/util/FormatterTest.java | 66 +++++------ .../internal/util/ListBuildersTest.java | 4 +- .../internal/util/RethrowTest.java | 28 ++--- .../internal/util/ValidationsTest.java | 8 +- equalsverifier-release-verify/pom.xml | 6 + .../jar/MainClassesJarTest.java | 16 +-- .../jar/MainJavadocJarTest.java | 8 +- .../jar/MainSourcesJarTest.java | 8 +- .../jar/NodepClassesJarTest.java | 18 +-- .../jar/NodepJavadocJarTest.java | 8 +- .../jar/NodepSourcesJarTest.java | 8 +- .../jar/helper/JarAsserter.java | 17 ++- .../verify_release/pom/MainPomTest.java | 10 +- .../verify_release/pom/NodepPomTest.java | 10 +- .../verify_release/pom/helper/PomReader.java | 22 ++-- pom.xml | 1 + 143 files changed, 1825 insertions(+), 1818 deletions(-) diff --git a/equalsverifier-11/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/JavaFxClassesTest.java b/equalsverifier-11/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/JavaFxClassesTest.java index 45528b321..9a0db5857 100644 --- a/equalsverifier-11/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/JavaFxClassesTest.java +++ b/equalsverifier-11/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/JavaFxClassesTest.java @@ -25,40 +25,40 @@ // CHECKSTYLE OFF: ParameterNumber -public class JavaFxClassesTest { +class JavaFxClassesTest { @Test - public void successfullyInstantiatesAJavaFxClass_whenJavaFxIsAvailable() { + void successfullyInstantiatesAJavaFxClass_whenJavaFxIsAvailable() { EqualsVerifier.forClass(JavaFxApiClassesContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtObservableListFieldsGenericContent() { + void succeed_whenEqualsLooksAtObservableListFieldsGenericContent() { EqualsVerifier.forClass(JavaFxObservableListContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtObservableMapFieldsGenericContent() { + void succeed_whenEqualsLooksAtObservableMapFieldsGenericContent() { EqualsVerifier.forClass(JavaFxObservableMapContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtObservableSetFieldsGenericContent() { + void succeed_whenEqualsLooksAtObservableSetFieldsGenericContent() { EqualsVerifier.forClass(JavaFxObservableSetContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtListPropertyFieldsGenericContent() { + void succeed_whenEqualsLooksAtListPropertyFieldsGenericContent() { EqualsVerifier.forClass(JavaFxListPropertyContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtMapPropertyFieldsGenericContent() { + void succeed_whenEqualsLooksAtMapPropertyFieldsGenericContent() { EqualsVerifier.forClass(JavaFxMapPropertyContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtSetPropertyFieldsGenericContent() { + void succeed_whenEqualsLooksAtSetPropertyFieldsGenericContent() { EqualsVerifier.forClass(JavaFxSetPropertyContainer.class).verify(); } diff --git a/equalsverifier-16/pom.xml b/equalsverifier-16/pom.xml index 1dc77f1f0..af2125d3f 100644 --- a/equalsverifier-16/pom.xml +++ b/equalsverifier-16/pom.xml @@ -29,5 +29,11 @@ ${version.junit-jupiter} test + + org.assertj + assertj-core + ${version.assertj} + test + diff --git a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/InstanceofPatternMatchTest.java b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/InstanceofPatternMatchTest.java index 516dc7d5b..30d2933bf 100644 --- a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/InstanceofPatternMatchTest.java +++ b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/InstanceofPatternMatchTest.java @@ -4,7 +4,7 @@ import nl.jqno.equalsverifier.internal.testhelpers.Util; import org.junit.jupiter.api.Test; -public class InstanceofPatternMatchTest { +class InstanceofPatternMatchTest { @Test void succeed_whenEqualsUsesInstanceofPatternMatch() { diff --git a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/PrefabValuesForFieldInRecordTest.java b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/PrefabValuesForFieldInRecordTest.java index affdab7ba..083a07fe0 100644 --- a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/PrefabValuesForFieldInRecordTest.java +++ b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/PrefabValuesForFieldInRecordTest.java @@ -4,10 +4,10 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class PrefabValuesForFieldInRecordTest { +class PrefabValuesForFieldInRecordTest { @Test - public void fail_whenRecordHasSinglePrecondition() { + void fail_whenRecordHasSinglePrecondition() { ExpectedException .when(() -> EqualsVerifier.forClass(SinglePrecondition.class).verify()) .assertFailure() @@ -15,12 +15,12 @@ public void fail_whenRecordHasSinglePrecondition() { } @Test - public void succeed_whenRecordHasSinglePrecondition_givenPrefabValuesForField() { + void succeed_whenRecordHasSinglePrecondition_givenPrefabValuesForField() { EqualsVerifier.forClass(SinglePrecondition.class).withPrefabValuesForField("i", 111, 142).verify(); } @Test - public void fail_whenRecordHasDualPrecondition() { + void fail_whenRecordHasDualPrecondition() { ExpectedException .when(() -> EqualsVerifier.forClass(DualPrecondition.class).verify()) .assertFailure() @@ -28,7 +28,7 @@ public void fail_whenRecordHasDualPrecondition() { } @Test - public void fail_whenRecordHasDualPrecondition_givenPrefabValuesForOnlyOneField() { + void fail_whenRecordHasDualPrecondition_givenPrefabValuesForOnlyOneField() { ExpectedException .when( () -> EqualsVerifier @@ -40,7 +40,7 @@ public void fail_whenRecordHasDualPrecondition_givenPrefabValuesForOnlyOneField( } @Test - public void succeed_whenRecordHasDualPrecondition_givenPrefabValueForBothFields() { + void succeed_whenRecordHasDualPrecondition_givenPrefabValueForBothFields() { EqualsVerifier .forClass(DualPrecondition.class) .withPrefabValuesForField("x", 111, 142) diff --git a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/RecordsTest.java b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/RecordsTest.java index 90764d228..911ce950f 100644 --- a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/RecordsTest.java +++ b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/RecordsTest.java @@ -1,8 +1,7 @@ package nl.jqno.equalsverifier.integration.extended_contract; import static nl.jqno.equalsverifier.internal.testhelpers.Util.defaultEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import java.io.Serializable; import java.util.Objects; @@ -13,26 +12,26 @@ import nl.jqno.equalsverifier.internal.versionspecific.RecordsHelper; import org.junit.jupiter.api.Test; -public class RecordsTest { +class RecordsTest { @Test - public void sanityCheckForRecordsHelper() { - assertTrue(RecordsHelper.isRecord(SimpleRecord.class)); - assertFalse(RecordsHelper.isRecord(String.class)); + void sanityCheckForRecordsHelper() { + assertThat(RecordsHelper.isRecord(SimpleRecord.class)).isTrue(); + assertThat(RecordsHelper.isRecord(String.class)).isFalse(); } @Test - public void succeed_whenClassIsARecord() { + void succeed_whenClassIsARecord() { EqualsVerifier.forClass(SimpleRecord.class).verify(); } @Test - public void succeed_whenClassIsAPrivateRecord() { + void succeed_whenClassIsAPrivateRecord() { EqualsVerifier.forClass(PrivateSimpleRecord.class).verify(); } @Test - public void fail_whenConstructorChecksNull() { + void fail_whenConstructorChecksNull() { ExpectedException .when(() -> EqualsVerifier.forClass(NullCheckingRecord.class).verify()) .assertFailure() @@ -40,12 +39,12 @@ public void fail_whenConstructorChecksNull() { } @Test - public void succeed_whenConstructorChecksNull_givenSuppressedWarning() { + void succeed_whenConstructorChecksNull_givenSuppressedWarning() { EqualsVerifier.forClass(NullCheckingRecord.class).suppress(Warning.NULL_FIELDS).verify(); } @Test - public void fail_whenConstructorChecksValue() { + void fail_whenConstructorChecksValue() { ExpectedException .when(() -> EqualsVerifier.forClass(ValueCheckingRecord.class).verify()) .assertFailure() @@ -53,7 +52,7 @@ public void fail_whenConstructorChecksValue() { } @Test - public void fail_whenRecordInvariantIsViolated_givenIntFieldIsModifiedInConstructor() { + void fail_whenRecordInvariantIsViolated_givenIntFieldIsModifiedInConstructor() { ExpectedException .when(() -> EqualsVerifier.forClass(BrokenInvariantIntFieldRecord.class).verify()) .assertFailure() @@ -61,7 +60,7 @@ public void fail_whenRecordInvariantIsViolated_givenIntFieldIsModifiedInConstruc } @Test - public void fail_whenRecordInvariantIsViolated_givenStringFieldIsModifiedInConstructor() { + void fail_whenRecordInvariantIsViolated_givenStringFieldIsModifiedInConstructor() { ExpectedException .when(() -> EqualsVerifier.forClass(BrokenInvariantStringFieldRecord.class).verify()) .assertFailure() @@ -69,7 +68,7 @@ public void fail_whenRecordInvariantIsViolated_givenStringFieldIsModifiedInConst } @Test - public void fail_whenRecordInvariantIsViolated_givenBothFieldsAreModifiedInConstructor() { + void fail_whenRecordInvariantIsViolated_givenBothFieldsAreModifiedInConstructor() { ExpectedException .when(() -> EqualsVerifier.forClass(BrokenInvariantBothRecord.class).verify()) .assertFailure() @@ -77,12 +76,12 @@ public void fail_whenRecordInvariantIsViolated_givenBothFieldsAreModifiedInConst } @Test - public void succeed_whenRecordImplementsItsOwnEquals() { + void succeed_whenRecordImplementsItsOwnEquals() { EqualsVerifier.forClass(EqualsRecord.class).verify(); } @Test - public void fail_whenRecordImplementsItsOwnEquals_givenNotAllFieldsAreUsed() { + void fail_whenRecordImplementsItsOwnEquals_givenNotAllFieldsAreUsed() { ExpectedException .when(() -> EqualsVerifier.forClass(NotAllFieldsRecord.class).verify()) .assertFailure() @@ -90,7 +89,7 @@ public void fail_whenRecordImplementsItsOwnEquals_givenNotAllFieldsAreUsed() { } @Test - public void fail_whenRecordConstructorThrows() { + void fail_whenRecordConstructorThrows() { ExpectedException .when(() -> EqualsVerifier.forClass(ThrowingConstructorRecord.class).verify()) .assertFailure() @@ -98,7 +97,7 @@ public void fail_whenRecordConstructorThrows() { } @Test - public void fail_whenRecordConstructorThrowsNpe() { + void fail_whenRecordConstructorThrowsNpe() { ExpectedException .when(() -> EqualsVerifier.forClass(NullFieldRecord.class).verify()) .assertFailure() @@ -106,7 +105,7 @@ public void fail_whenRecordConstructorThrowsNpe() { } @Test - public void fail_whenRecordAccessorThrows() { + void fail_whenRecordAccessorThrows() { ExpectedException .when(() -> EqualsVerifier.forClass(ThrowingAccessorRecord.class).verify()) .assertFailure() @@ -114,7 +113,7 @@ public void fail_whenRecordAccessorThrows() { } @Test - public void fail_whenRecordAccessorThrowsNpe() { + void fail_whenRecordAccessorThrowsNpe() { ExpectedException .when(() -> EqualsVerifier.forClass(NullAccessorRecord.class).verify()) .assertFailure() @@ -122,12 +121,12 @@ public void fail_whenRecordAccessorThrowsNpe() { } @Test - public void succeed_whenRecordContainsStaticField() { + void succeed_whenRecordContainsStaticField() { EqualsVerifier.forClass(StaticFieldRecord.class).verify(); } @Test - public void succeed_whenRecordValidatesInput_givenValidPrefabValues() { + void succeed_whenRecordValidatesInput_givenValidPrefabValues() { EqualsVerifier .forClass(ValidatingConstructorRecord.class) .withPrefabValues(String.class, "valid-1", "valid-2") @@ -135,7 +134,7 @@ public void succeed_whenRecordValidatesInput_givenValidPrefabValues() { } @Test - public void succeed_whenRecordHasBoundedWildcardGeneric() { + void succeed_whenRecordHasBoundedWildcardGeneric() { EqualsVerifier.forClass(WildcardGenericRecordContainer.class).verify(); } diff --git a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/RecordInstanceCreatorTest.java b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/RecordInstanceCreatorTest.java index 0a8e71527..709dbfdf4 100644 --- a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/RecordInstanceCreatorTest.java +++ b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/RecordInstanceCreatorTest.java @@ -1,6 +1,6 @@ package nl.jqno.equalsverifier.internal.instantiation; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import java.lang.reflect.Field; import java.util.HashMap; @@ -10,10 +10,10 @@ import org.junit.jupiter.api.Test; import org.objenesis.ObjenesisStd; -public class RecordInstanceCreatorTest { +class RecordInstanceCreatorTest { @Test - public void instanceCreator() throws NoSuchFieldException { + void instanceCreator() throws NoSuchFieldException { ClassProbe probe = ClassProbe.of(SomeRecord.class); InstanceCreator sut = new InstanceCreator<>(probe, new ObjenesisStd()); @@ -25,9 +25,9 @@ public void instanceCreator() throws NoSuchFieldException { SomeRecord actual = sut.instantiate(values); - assertEquals(42, actual.x); - assertEquals(0, actual.y); - assertEquals("42", actual.z); + assertThat(actual.x).isEqualTo(42); + assertThat(actual.y).isEqualTo(0); + assertThat(actual.z).isEqualTo("42"); } record SomeRecord(int x, int y, String z) {} diff --git a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/RecordFallbackFactoryTest.java b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/RecordFallbackFactoryTest.java index 03190df2e..6c4a2f2d6 100644 --- a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/RecordFallbackFactoryTest.java +++ b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/RecordFallbackFactoryTest.java @@ -1,7 +1,7 @@ package nl.jqno.equalsverifier.internal.instantiation.vintage.prefabvalues.factories; import static nl.jqno.equalsverifier.internal.instantiation.vintage.prefabvalues.factories.Factories.values; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertNotSame; import java.util.LinkedHashSet; @@ -15,14 +15,14 @@ import org.objenesis.Objenesis; import org.objenesis.ObjenesisStd; -public class RecordFallbackFactoryTest { +class RecordFallbackFactoryTest { private FallbackFactory factory; private VintageValueProvider valueProvider; private LinkedHashSet typeStack; @BeforeEach - public void setUp() { + void setUp() { Objenesis objenesis = new ObjenesisStd(); factory = new FallbackFactory<>(objenesis); FactoryCache factoryCache = new FactoryCache(); @@ -32,10 +32,10 @@ public void setUp() { } @Test - public void redCopyHasTheSameValuesAsRed_whenSutContainsGenericValueThatNeedsToBeIdenticalInRedAndRedCopy() { + void redCopyHasTheSameValuesAsRed_whenSutContainsGenericValueThatNeedsToBeIdenticalInRedAndRedCopy() { Tuple tuple = factory.createValues(new TypeTag(GenericRecordContainer.class), valueProvider, typeStack); - assertEquals(tuple.getRed(), tuple.getRedCopy()); + assertThat(tuple.getRedCopy()).isEqualTo(tuple.getRed()); assertNotSame(tuple.getRed(), tuple.getRedCopy()); } diff --git a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorCopyingTest.java b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorCopyingTest.java index 06696b42b..b378fd2ce 100644 --- a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorCopyingTest.java +++ b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorCopyingTest.java @@ -1,8 +1,7 @@ package nl.jqno.equalsverifier.internal.instantiation.vintage.reflection; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertNotSame; -import static org.junit.jupiter.api.Assertions.assertSame; import nl.jqno.equalsverifier.internal.reflection.FieldIterable; import nl.jqno.equalsverifier.internal.reflection.FieldProbe; @@ -11,21 +10,21 @@ import org.objenesis.Objenesis; import org.objenesis.ObjenesisStd; -public class RecordObjectAccessorCopyingTest { +class RecordObjectAccessorCopyingTest { private Objenesis objenesis = new ObjenesisStd(); @Test - public void copyHappyPath() { + void copyHappyPath() { Object original = instantiate(SimpleRecord.class); Object copy = copyOf(original); assertNotSame(original, copy); - assertEquals(original, copy); + assertThat(copy).isEqualTo(original); } @Test - public void shallowCopy() { + void shallowCopy() { Object original = instantiate(RecordContainer.class); Object copy = copyOf(original); RecordObjectAccessor originalAccessor = create(original); @@ -35,7 +34,7 @@ public void shallowCopy() { for (FieldProbe p : FieldIterable.of(original.getClass())) { Object a = originalAccessor.getField(p); Object b = copyAccessor.getField(p); - assertSame(a, b); + assertThat(b).isSameAs(a); } } diff --git a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorScramblingTest.java b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorScramblingTest.java index b85de0f78..c8a88c2a7 100644 --- a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorScramblingTest.java +++ b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorScramblingTest.java @@ -1,7 +1,7 @@ package nl.jqno.equalsverifier.internal.instantiation.vintage.reflection; import static nl.jqno.equalsverifier.internal.instantiation.vintage.prefabvalues.factories.Factories.values; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertNotSame; import java.lang.reflect.Constructor; @@ -15,20 +15,20 @@ import org.junit.jupiter.api.Test; import org.objenesis.ObjenesisStd; -public class RecordObjectAccessorScramblingTest { +class RecordObjectAccessorScramblingTest { private static final LinkedHashSet EMPTY_TYPE_STACK = new LinkedHashSet<>(); private FactoryCache factoryCache; private VintageValueProvider valueProvider; @BeforeEach - public void setup() throws Exception { + void setup() throws Exception { factoryCache = JavaApiPrefabValues.build(); valueProvider = new VintageValueProvider(factoryCache, new ObjenesisStd()); } @Test - public void scrambleLeavesOriginalUnaffected() throws Exception { + void scrambleLeavesOriginalUnaffected() throws Exception { Constructor c = Point.class.getDeclaredConstructor(int.class, int.class); Object original = c.newInstance(2, 3); Object copy = doScramble(original).get(); @@ -36,7 +36,7 @@ public void scrambleLeavesOriginalUnaffected() throws Exception { } @Test - public void scramble() throws Exception { + void scramble() throws Exception { Constructor constructor = Point.class.getDeclaredConstructor(int.class, int.class); factoryCache .put( @@ -48,7 +48,7 @@ public void scramble() throws Exception { Object original = constructor.newInstance(1, 2); Object scrambled = doScramble(original); - assertFalse(original.equals(scrambled)); + assertThat(scrambled).isNotEqualTo(original); } @SuppressWarnings("unchecked") diff --git a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorTest.java b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorTest.java index 5380532f0..4f8779c11 100644 --- a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorTest.java +++ b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/RecordObjectAccessorTest.java @@ -1,7 +1,6 @@ package nl.jqno.equalsverifier.internal.instantiation.vintage.reflection; -import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import java.lang.reflect.Constructor; import java.util.LinkedHashSet; @@ -18,14 +17,14 @@ import org.objenesis.Objenesis; import org.objenesis.ObjenesisStd; -public class RecordObjectAccessorTest { +class RecordObjectAccessorTest { private static final LinkedHashSet EMPTY_TYPE_STACK = new LinkedHashSet<>(); private Objenesis objenesis; private Object recordInstance; @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { Constructor constructor = SimpleRecord.class.getDeclaredConstructor(int.class, String.class); constructor.setAccessible(true); objenesis = new ObjenesisStd(); @@ -33,19 +32,19 @@ public void setUp() throws Exception { } @Test - public void of() { + void of() { ObjectAccessor actual = ObjectAccessor.of(recordInstance); - assertTrue(actual instanceof RecordObjectAccessor); + assertThat(actual instanceof RecordObjectAccessor).isTrue(); } @Test - public void get() { + void get() { RecordObjectAccessor accessor = accessorFor(recordInstance); - assertSame(recordInstance, accessor.get()); + assertThat(accessor.get()).isSameAs(recordInstance); } @Test - public void fail_whenConstructorThrowsNpe() { + void fail_whenConstructorThrowsNpe() { Object instance = Instantiator.of(NpeThrowingConstructorRecord.class, objenesis).instantiate(); ExpectedException @@ -55,7 +54,7 @@ public void fail_whenConstructorThrowsNpe() { } @Test - public void fail_whenConstructorThrowsOnZero() { + void fail_whenConstructorThrowsOnZero() { Object instance = Instantiator.of(ZeroThrowingConstructorRecord.class, objenesis).instantiate(); ExpectedException @@ -65,7 +64,7 @@ public void fail_whenConstructorThrowsOnZero() { } @Test - public void fail_whenConstructorThrowsOnSomethingElse() { + void fail_whenConstructorThrowsOnSomethingElse() { Object instance = Instantiator.of(OtherThrowingConstructorRecord.class, objenesis).instantiate(); VintageValueProvider vp = new VintageValueProvider(JavaApiPrefabValues.build(), objenesis); diff --git a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/reflection/ClassProbeRecordTest.java b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/reflection/ClassProbeRecordTest.java index 63d51771c..81b6009ef 100644 --- a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/reflection/ClassProbeRecordTest.java +++ b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/reflection/ClassProbeRecordTest.java @@ -1,15 +1,15 @@ package nl.jqno.equalsverifier.internal.reflection; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; -public class ClassProbeRecordTest { +class ClassProbeRecordTest { @Test - public void isRecord() { + void isRecord() { var probe = ClassProbe.of(SimpleRecord.class); - assertTrue(probe.isRecord()); + assertThat(probe.isRecord()).isTrue(); } record SimpleRecord(int i) {} diff --git a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/reflection/RecordInstantiatorTest.java b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/reflection/RecordInstantiatorTest.java index be0c04dcf..dbf927f26 100644 --- a/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/reflection/RecordInstantiatorTest.java +++ b/equalsverifier-16/src/test/java/nl/jqno/equalsverifier/internal/reflection/RecordInstantiatorTest.java @@ -1,17 +1,17 @@ package nl.jqno.equalsverifier.internal.reflection; -import static org.junit.jupiter.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; import org.objenesis.ObjenesisStd; -public class RecordInstantiatorTest { +class RecordInstantiatorTest { @Test - public void instantiateRecord() { + void instantiateRecord() { Instantiator instantiator = Instantiator.of(SimpleRecord.class, new ObjenesisStd()); Object simpleRecord = instantiator.instantiate(); - assertEquals(SimpleRecord.class, simpleRecord.getClass()); + assertThat(simpleRecord.getClass()).isEqualTo(SimpleRecord.class); } record SimpleRecord(int i) {} diff --git a/equalsverifier-17/pom.xml b/equalsverifier-17/pom.xml index 596d3448e..f368921f1 100644 --- a/equalsverifier-17/pom.xml +++ b/equalsverifier-17/pom.xml @@ -28,5 +28,11 @@ ${version.junit-jupiter} test + + org.assertj + assertj-core + ${version.assertj} + test + diff --git a/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SealedTypesRecursionTest.java b/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SealedTypesRecursionTest.java index 1241ff2e0..e8697ed35 100644 --- a/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SealedTypesRecursionTest.java +++ b/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SealedTypesRecursionTest.java @@ -9,7 +9,7 @@ class SealedTypesRecursionTest { @Test - public void dontThrowStackOverflowError_whenOnlyPermittedSubclassInSealedInterfaceRefersBackToContainer() { + void dontThrowStackOverflowError_whenOnlyPermittedSubclassInSealedInterfaceRefersBackToContainer() { // A container with a field of a sealed interface. // The sealed interface permits only 1 type, which refers back to the container. ExpectedException @@ -23,7 +23,7 @@ public void dontThrowStackOverflowError_whenOnlyPermittedSubclassInSealedInterfa } @Test - public void dontThrowStackOverflowError_whenOnlyPermittedRecordInSealedInterfaceRefersBackToContainer() { + void dontThrowStackOverflowError_whenOnlyPermittedRecordInSealedInterfaceRefersBackToContainer() { // A container with a field of a sealed interface. // The sealed interface permits only 1 type, which is a record that refers back to the container. ExpectedException diff --git a/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SealedTypesTest.java b/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SealedTypesTest.java index 3c10b7843..8acd26c88 100644 --- a/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SealedTypesTest.java +++ b/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SealedTypesTest.java @@ -6,10 +6,10 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class SealedTypesTest { +class SealedTypesTest { @Test - public void succeed_whenSealedParentHasAFinalChild_givenItHasCorrectEqualsAndHashCode() { + void succeed_whenSealedParentHasAFinalChild_givenItHasCorrectEqualsAndHashCode() { EqualsVerifier .forClass(SealedParentWithFinalChild.class) .withRedefinedSubclass(FinalSealedChild.class) @@ -17,19 +17,19 @@ public void succeed_whenSealedParentHasAFinalChild_givenItHasCorrectEqualsAndHas } @Test - public void fail_whenSealedParentHasAFinalChild_givenEqualsVerifierIsCalledIncorrectly() { + void fail_whenSealedParentHasAFinalChild_givenEqualsVerifierIsCalledIncorrectly() { ExpectedException .when(() -> EqualsVerifier.forClass(SealedParentWithFinalChild.class).verify()) .assertFailure(); } @Test - public void succeed_whenFinalChildHasCorrectEqualsAndHashCode() { + void succeed_whenFinalChildHasCorrectEqualsAndHashCode() { EqualsVerifier.forClass(FinalSealedChild.class).withRedefinedSuperclass().verify(); } @Test - public void succeed_whenSealedParentHasANonsealedChild_givenItHasCorrectEqualsAndHashCode() { + void succeed_whenSealedParentHasANonsealedChild_givenItHasCorrectEqualsAndHashCode() { EqualsVerifier .forClass(SealedParentWithNonsealedChild.class) .withRedefinedSubclass(NonsealedSealedChild.class) @@ -37,24 +37,24 @@ public void succeed_whenSealedParentHasANonsealedChild_givenItHasCorrectEqualsAn } @Test - public void fail_whenSealedParentHasANonsealedChild_givenEqualsVerifierIsCalledIncorrectly() { + void fail_whenSealedParentHasANonsealedChild_givenEqualsVerifierIsCalledIncorrectly() { ExpectedException .when(() -> EqualsVerifier.forClass(SealedParentWithNonsealedChild.class).verify()) .assertFailure(); } @Test - public void succeed_whenNonsealedChildHasCorrectEqualsAndHashCode() { + void succeed_whenNonsealedChildHasCorrectEqualsAndHashCode() { EqualsVerifier.forClass(NonsealedSealedChild.class).withRedefinedSuperclass().verify(); } @Test - public void succeed_whenClassContainsASealedType() { + void succeed_whenClassContainsASealedType() { EqualsVerifier.forClass(SealedTypeContainer.class).verify(); } @Test - public void fail_whenSealeadParentHasAnIncorrectImplementationOfEquals() { + void fail_whenSealeadParentHasAnIncorrectImplementationOfEquals() { ExpectedException .when( () -> EqualsVerifier diff --git a/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SealedTypesFallbackFactoryTest.java b/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SealedTypesFallbackFactoryTest.java index 554090488..1bbcaa332 100644 --- a/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SealedTypesFallbackFactoryTest.java +++ b/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SealedTypesFallbackFactoryTest.java @@ -1,7 +1,7 @@ package nl.jqno.equalsverifier.internal.instantiation.vintage.prefabvalues.factories; import static nl.jqno.equalsverifier.internal.instantiation.vintage.prefabvalues.factories.Factories.values; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertNotSame; import java.util.LinkedHashSet; @@ -16,14 +16,14 @@ import org.objenesis.Objenesis; import org.objenesis.ObjenesisStd; -public class SealedTypesFallbackFactoryTest { +class SealedTypesFallbackFactoryTest { private FallbackFactory factory; private VintageValueProvider valueProvider; private LinkedHashSet typeStack; @BeforeEach - public void setUp() { + void setUp() { Objenesis objenesis = new ObjenesisStd(); factory = new FallbackFactory<>(objenesis); FactoryCache factoryCache = new FactoryCache(); @@ -33,10 +33,10 @@ public void setUp() { } @Test - public void redCopyHasTheSameValuesAsRed_whenSutIsAbstractSealedAndPermittedTypeAddsField() { + void redCopyHasTheSameValuesAsRed_whenSutIsAbstractSealedAndPermittedTypeAddsField() { Tuple tuple = factory.createValues(new TypeTag(SealedParentWithFinalChild.class), valueProvider, typeStack); - assertEquals(tuple.getRed(), tuple.getRedCopy()); + assertThat(tuple.getRedCopy()).isEqualTo(tuple.getRed()); assertNotSame(tuple.getRed(), tuple.getRedCopy()); } diff --git a/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/internal/reflection/ClassProbeSealedTest.java b/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/internal/reflection/ClassProbeSealedTest.java index 76e8e3f50..769065d66 100644 --- a/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/internal/reflection/ClassProbeSealedTest.java +++ b/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/internal/reflection/ClassProbeSealedTest.java @@ -1,22 +1,21 @@ package nl.jqno.equalsverifier.internal.reflection; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; -public class ClassProbeSealedTest { +class ClassProbeSealedTest { @Test - public void isNotSealed() { + void isNotSealed() { var probe = ClassProbe.of(SealedChild.class); - assertFalse(probe.isSealed()); + assertThat(probe.isSealed()).isFalse(); } @Test - public void isSealed() { + void isSealed() { var probe = ClassProbe.of(SealedParent.class); - assertTrue(probe.isSealed()); + assertThat(probe.isSealed()).isTrue(); } public abstract static sealed class SealedParent {} diff --git a/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/internal/versionspecific/SealedTypesHelperTest.java b/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/internal/versionspecific/SealedTypesHelperTest.java index cdfe19d2a..f769efe46 100644 --- a/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/internal/versionspecific/SealedTypesHelperTest.java +++ b/equalsverifier-17/src/test/java/nl/jqno/equalsverifier/internal/versionspecific/SealedTypesHelperTest.java @@ -1,17 +1,17 @@ package nl.jqno.equalsverifier.internal.versionspecific; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import java.util.Optional; import org.junit.jupiter.api.Test; -public class SealedTypesHelperTest { +class SealedTypesHelperTest { @Test void twoLevels() { var actual = SealedTypesHelper.findInstantiableSubclass(TwoLevelParent.class); - assertEquals(TwoLevelChild.class, actual.get()); + assertThat(actual.get()).isEqualTo(TwoLevelChild.class); } sealed interface TwoLevelParent {} @@ -21,7 +21,7 @@ final class TwoLevelChild implements TwoLevelParent {} @Test void fourLevels() { var actual = SealedTypesHelper.findInstantiableSubclass(FourLevelParent.class); - assertEquals(FourLevelChild.class, actual.get()); + assertThat(actual.get()).isEqualTo(FourLevelChild.class); } sealed interface FourLevelParent {} @@ -35,7 +35,7 @@ final class FourLevelChild implements FourLevelMiddle2 {} @Test void allConcrete() { var actual = SealedTypesHelper.findInstantiableSubclass(AllConcreteParent.class); - assertEquals(AllConcreteMiddle.class, actual.get()); + assertThat(actual.get()).isEqualTo(AllConcreteMiddle.class); } sealed class AllConcreteParent {} @@ -47,7 +47,7 @@ final class AllConcreteChild extends AllConcreteMiddle {} @Test void nonSealedAtTheBottom() { var actual = SealedTypesHelper.findInstantiableSubclass(NonSealedAtTheBottomParent.class); - assertEquals(NonSealedAtTheBottomChild.class, actual.get()); + assertThat(actual.get()).isEqualTo(NonSealedAtTheBottomChild.class); } sealed interface NonSealedAtTheBottomParent {} @@ -57,6 +57,6 @@ non-sealed interface NonSealedAtTheBottomChild extends NonSealedAtTheBottomParen @Test void notSealed() { var actual = SealedTypesHelper.findInstantiableSubclass(Object.class); - assertEquals(Optional.empty(), actual); + assertThat(actual).isEqualTo(Optional.empty()); } } diff --git a/equalsverifier-21/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SequencedCollectionsClassesTest.java b/equalsverifier-21/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SequencedCollectionsClassesTest.java index 214e9b7b4..14ad72750 100644 --- a/equalsverifier-21/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SequencedCollectionsClassesTest.java +++ b/equalsverifier-21/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SequencedCollectionsClassesTest.java @@ -5,10 +5,10 @@ import nl.jqno.equalsverifier.EqualsVerifier; import org.junit.jupiter.api.Test; -public class SequencedCollectionsClassesTest { +class SequencedCollectionsClassesTest { @Test - public void succeed_whenClassContainsSequencedCollections() { + void succeed_whenClassContainsSequencedCollections() { EqualsVerifier.forClass(SequencedCollectionContainer.class).verify(); } diff --git a/equalsverifier-core/pom.xml b/equalsverifier-core/pom.xml index c13750785..04ce4981b 100644 --- a/equalsverifier-core/pom.xml +++ b/equalsverifier-core/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 @@ -99,6 +101,12 @@ ${version.hamcrest} test + + org.assertj + assertj-core + ${version.assertj} + test + org.apache.commons commons-lang3 diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/CoverageNoInheritanceTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/CoverageNoInheritanceTest.java index 342d80e0f..d45e8e9c2 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/CoverageNoInheritanceTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/CoverageNoInheritanceTest.java @@ -9,7 +9,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -public class CoverageNoInheritanceTest { +class CoverageNoInheritanceTest { private static Stream data() { return Stream @@ -26,13 +26,13 @@ private static Stream data() { @ParameterizedTest @MethodSource("data") - public void testCoverage(Class type) { + void coverage(Class type) { EqualsVerifier.forClass(type).verify(); } @ParameterizedTest @MethodSource("data") - public void callTheConstructor(Class type) throws Exception { + void callTheConstructor(Class type) throws Exception { Constructor constructor = type.getConstructor(int.class, int.class, Color.class); constructor.newInstance(0, 0, Color.INDIGO); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/CoverageNonnullTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/CoverageNonnullTest.java index 0d593207e..a88489156 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/CoverageNonnullTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/CoverageNonnullTest.java @@ -7,10 +7,10 @@ // CHECKSTYLE OFF: LocalFinalVariableName // CHECKSTYLE OFF: NeedBraces -public class CoverageNonnullTest { +class CoverageNonnullTest { @Test - public void lombokCoverage() { + void lombokCoverage() { EqualsVerifier.forClass(LombokNonnullStringContainer.class).withIgnoredAnnotations(Nonnull.class).verify(); // Also cover the constructor diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/CoverageWithInheritanceTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/CoverageWithInheritanceTest.java index b23b1f690..cea899911 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/CoverageWithInheritanceTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/coverage/CoverageWithInheritanceTest.java @@ -16,13 +16,13 @@ public static Stream data() { @ParameterizedTest @MethodSource("data") - public void testSuperCoverage(Classes classes) { + void superCoverage(Classes classes) { EqualsVerifier.forClass(classes.superType).withRedefinedSubclass(classes.subType).verify(); } @ParameterizedTest @MethodSource("data") - public void testSubCoverage(Classes classes) { + void subCoverage(Classes classes) { EqualsVerifier .forClass(classes.subType) .withRedefinedSuperclass() @@ -32,7 +32,7 @@ public void testSubCoverage(Classes classes) { @ParameterizedTest @MethodSource("data") - public void callTheConstructors(Classes classes) throws Exception { + void callTheConstructors(Classes classes) throws Exception { classes.containerType.getConstructor().newInstance(); classes.superType.getConstructor(int.class, int.class).newInstance(0, 0); classes.subType.getConstructor(int.class, int.class, Color.class).newInstance(0, 0, Color.INDIGO); diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/HashCodeTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/HashCodeTest.java index c15f3c72d..c3dd4bf01 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/HashCodeTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/HashCodeTest.java @@ -4,10 +4,10 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class HashCodeTest { +class HashCodeTest { @Test - public void fail_whenHashCodesAreInconsistent() { + void fail_whenHashCodesAreInconsistent() { ExpectedException .when(() -> EqualsVerifier.forClass(RandomHashCode.class).verify()) .assertFailure() @@ -15,7 +15,7 @@ public void fail_whenHashCodesAreInconsistent() { } @Test - public void fail_whenHashCodesAreUnequal_givenEqualObjects() { + void fail_whenHashCodesAreUnequal_givenEqualObjects() { ExpectedException .when(() -> EqualsVerifier.forClass(NoHashCode.class).verify()) .assertFailure() @@ -23,7 +23,7 @@ public void fail_whenHashCodesAreUnequal_givenEqualObjects() { } @Test - public void succeed_whenEqualsShortCircuitsOnHashCode() { + void succeed_whenEqualsShortCircuitsOnHashCode() { EqualsVerifier.forClass(ShortCircuitOnHashCode.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/NonNullityTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/NonNullityTest.java index d34a722ad..d0c965db4 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/NonNullityTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/NonNullityTest.java @@ -5,10 +5,10 @@ import nl.jqno.equalsverifier.testhelpers.types.Point; import org.junit.jupiter.api.Test; -public class NonNullityTest { +class NonNullityTest { @Test - public void fail_whenNullPointerExceptionIsThrown_givenNullInput() { + void fail_whenNullPointerExceptionIsThrown_givenNullInput() { ExpectedException .when(() -> EqualsVerifier.forClass(NullPointerExceptionThrower.class).verify()) .assertFailure() @@ -16,7 +16,7 @@ public void fail_whenNullPointerExceptionIsThrown_givenNullInput() { } @Test - public void fail_whenEqualsReturnsTrue_givenNullInput() { + void fail_whenEqualsReturnsTrue_givenNullInput() { ExpectedException .when(() -> EqualsVerifier.forClass(NullReturnsTrue.class).verify()) .assertFailure() diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/ReflexivityTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/ReflexivityTest.java index 3c992dde0..32a48bb1c 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/ReflexivityTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/ReflexivityTest.java @@ -11,10 +11,10 @@ import nl.jqno.equalsverifier.testhelpers.types.Point; import org.junit.jupiter.api.Test; -public class ReflexivityTest { +class ReflexivityTest { @Test - public void fail_whenReferencesAreNotEqual() { + void fail_whenReferencesAreNotEqual() { ExpectedException .when(() -> EqualsVerifier.forClass(ReflexivityIntentionallyBroken.class).verify()) .assertFailure() @@ -25,7 +25,7 @@ public void fail_whenReferencesAreNotEqual() { } @Test - public void fail_whenTheWrongFieldsAreComparedInEquals() { + void fail_whenTheWrongFieldsAreComparedInEquals() { ExpectedException .when(() -> EqualsVerifier.forClass(FieldsMixedUpInEquals.class).verify()) .assertFailure() @@ -36,7 +36,7 @@ public void fail_whenTheWrongFieldsAreComparedInEquals() { } @Test - public void fail_whenReferencesAreNotEqual_givenFieldsThatAreNull() { + void fail_whenReferencesAreNotEqual_givenFieldsThatAreNull() { ExpectedException .when(() -> EqualsVerifier.forClass(ReflexivityBrokenOnNullFields.class).verify()) .assertFailure() @@ -44,12 +44,12 @@ public void fail_whenReferencesAreNotEqual_givenFieldsThatAreNull() { } @Test - public void succeed_whenReferencesAreNotEqual_givenFieldsThatAreNullAndWarningIsSuppressed() { + void succeed_whenReferencesAreNotEqual_givenFieldsThatAreNullAndWarningIsSuppressed() { EqualsVerifier.forClass(ReflexivityBrokenOnNullFields.class).suppress(Warning.NULL_FIELDS).verify(); } @Test - public void fail_whenObjectIsInstanceofCheckedWithWrongClass() { + void fail_whenObjectIsInstanceofCheckedWithWrongClass() { ExpectedException .when(() -> EqualsVerifier.forClass(WrongInstanceofCheck.class).verify()) .assertFailure() @@ -60,7 +60,7 @@ public void fail_whenObjectIsInstanceofCheckedWithWrongClass() { } @Test - public void fail_whenEqualsReturnsFalse_givenObjectsThatAreIdentical() { + void fail_whenEqualsReturnsFalse_givenObjectsThatAreIdentical() { ExpectedException .when(() -> EqualsVerifier.forClass(SuperCallerWithUnusedField.class).verify()) .assertFailure() @@ -68,7 +68,7 @@ public void fail_whenEqualsReturnsFalse_givenObjectsThatAreIdentical() { } @Test - public void succeed_whenEqualsReturnsFalse_givenObjectsThatAreIdenticalAndWarningIsSuppressed() { + void succeed_whenEqualsReturnsFalse_givenObjectsThatAreIdenticalAndWarningIsSuppressed() { EqualsVerifier .forClass(SuperCallerWithUnusedField.class) .suppress(Warning.IDENTICAL_COPY, Warning.ALL_FIELDS_SHOULD_BE_USED) @@ -76,7 +76,7 @@ public void succeed_whenEqualsReturnsFalse_givenObjectsThatAreIdenticalAndWarnin } @Test - public void fail_whenIdenticalCopyWarningIsSuppressedUnnecessarily() { + void fail_whenIdenticalCopyWarningIsSuppressedUnnecessarily() { ExpectedException .when(() -> EqualsVerifier.forClass(FinalPoint.class).suppress(Warning.IDENTICAL_COPY).verify()) .assertFailure() diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/SymmetryTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/SymmetryTest.java index 0682b8f22..79af0ecf5 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/SymmetryTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/SymmetryTest.java @@ -6,14 +6,14 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class SymmetryTest { +class SymmetryTest { private static final String SYMMETRY = "Symmetry"; private static final String NOT_SYMMETRIC = "objects are not symmetric"; private static final String AND = "and"; @Test - public void fail_whenEqualsIsNotSymmetrical() { + void fail_whenEqualsIsNotSymmetrical() { ExpectedException .when(() -> EqualsVerifier.forClass(SymmetryIntentionallyBroken.class).verify()) .assertFailure() diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/TransitivityTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/TransitivityTest.java index b686f9c12..9ff377515 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/TransitivityTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/basic_contract/TransitivityTest.java @@ -10,15 +10,15 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -public class TransitivityTest { +class TransitivityTest { @Test - public void succeed_whenEqualityForTwoFieldsIsCombinedUsingAnd() { + void succeed_whenEqualityForTwoFieldsIsCombinedUsingAnd() { EqualsVerifier.forClass(TwoFieldsUsingAnd.class).verify(); } @Test - public void fail_whenEqualityForTwoFieldsIsCombinedUsingOr() { + void fail_whenEqualityForTwoFieldsIsCombinedUsingOr() { ExpectedException .when( () -> EqualsVerifier @@ -33,12 +33,12 @@ public void fail_whenEqualityForTwoFieldsIsCombinedUsingOr() { } @Test - public void succeed_whenEqualityForThreeFieldsIsCombinedUsingAnd() { + void succeed_whenEqualityForThreeFieldsIsCombinedUsingAnd() { EqualsVerifier.forClass(ThreeFieldsUsingAnd.class).verify(); } @Test - public void fail_whenEqualityForThreeFieldsIsCombinedUsingOr() { + void fail_whenEqualityForThreeFieldsIsCombinedUsingOr() { ExpectedException .when( () -> EqualsVerifier @@ -50,7 +50,7 @@ public void fail_whenEqualityForThreeFieldsIsCombinedUsingOr() { } @Test - public void fail_whenEqualityForThreeFieldsIsCombinedUsingOr_givenRelaxedEqualExamples() { + void fail_whenEqualityForThreeFieldsIsCombinedUsingOr_givenRelaxedEqualExamples() { ThreeFieldsUsingOr one = new ThreeFieldsUsingOr("a", "1", "alpha"); ThreeFieldsUsingOr two = new ThreeFieldsUsingOr("b", "1", "alpha"); ThreeFieldsUsingOr three = new ThreeFieldsUsingOr("c", "1", "alpha"); @@ -68,7 +68,7 @@ public void fail_whenEqualityForThreeFieldsIsCombinedUsingOr_givenRelaxedEqualEx } @Test - public void fail_whenEqualityForThreeFieldsIsCombinedUsingAndAndOr() { + void fail_whenEqualityForThreeFieldsIsCombinedUsingAndAndOr() { ExpectedException .when( () -> EqualsVerifier @@ -80,7 +80,7 @@ public void fail_whenEqualityForThreeFieldsIsCombinedUsingAndAndOr() { } @Test - public void fail_whenEqualityForThreeFieldsIsCombinedUsingOrAndAnd() { + void fail_whenEqualityForThreeFieldsIsCombinedUsingOrAndAnd() { ExpectedException .when( () -> EqualsVerifier @@ -92,7 +92,7 @@ public void fail_whenEqualityForThreeFieldsIsCombinedUsingOrAndAnd() { } @Test - public void fail_whenEqualityForFiveFieldsIsCombinedUsingOr() { + void fail_whenEqualityForFiveFieldsIsCombinedUsingOr() { ExpectedException .when( () -> EqualsVerifier @@ -104,7 +104,7 @@ public void fail_whenEqualityForFiveFieldsIsCombinedUsingOr() { } @Test - public void fail_whenEqualityForFiveFieldsIsCombinedUsingAndsAndOrs() { + void fail_whenEqualityForFiveFieldsIsCombinedUsingAndsAndOrs() { ExpectedException .when( () -> EqualsVerifier @@ -117,7 +117,7 @@ public void fail_whenEqualityForFiveFieldsIsCombinedUsingAndsAndOrs() { @Disabled("This class is not transitive, and it should fail. See issue 78.") @Test - public void fail_whenInstancesAreEqualIfAtLeastTwoFieldsAreEqual() { + void fail_whenInstancesAreEqualIfAtLeastTwoFieldsAreEqual() { ExpectedException .when( () -> EqualsVerifier diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/AbstractDelegationTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/AbstractDelegationTest.java index eb14304d3..e2178843e 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/AbstractDelegationTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/AbstractDelegationTest.java @@ -9,8 +9,9 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -@SuppressWarnings("unused") // because of the use of defaultEquals and defaultHashCode -public class AbstractDelegationTest { +// because of the use of defaultEquals and defaultHashCode +@SuppressWarnings("unused") +class AbstractDelegationTest { private static final String ABSTRACT_DELEGATION = "Abstract delegation"; private static final String EQUALS_DELEGATES = "equals method delegates to an abstract method"; @@ -18,12 +19,12 @@ public class AbstractDelegationTest { private static final String PREFAB = "Add prefab values for"; @Test - public void succeed_whenClassHasAFieldOfAnAbstractClass() { + void succeed_whenClassHasAFieldOfAnAbstractClass() { EqualsVerifier.forClass(AbstractContainer.class).verify(); } @Test - public void failGracefully_whenEqualsCallsAnAbstractMethod() { + void failGracefully_whenEqualsCallsAnAbstractMethod() { ExpectedException .when(() -> EqualsVerifier.forClass(AbstractEqualsDelegator.class).verify()) .assertFailure() @@ -35,7 +36,7 @@ public void failGracefully_whenEqualsCallsAnAbstractMethod() { } @Test - public void failGracefully_whenHashCodeCallsAnAbstractMethod() { + void failGracefully_whenHashCodeCallsAnAbstractMethod() { ExpectedException .when(() -> EqualsVerifier.forClass(AbstractHashCodeDelegator.class).verify()) .assertFailure() @@ -47,12 +48,12 @@ public void failGracefully_whenHashCodeCallsAnAbstractMethod() { } @Test - public void succeed_whenToStringCallsAnAbstractMethod() { + void succeed_whenToStringCallsAnAbstractMethod() { EqualsVerifier.forClass(AbstractToStringDelegator.class).verify(); } @Test - public void failGracefully_whenEqualsCallsAnAbstractFieldsAbstractMethod() { + void failGracefully_whenEqualsCallsAnAbstractFieldsAbstractMethod() { ExpectedException .when(() -> EqualsVerifier.forClass(EqualsDelegatesToAbstractMethodInField.class).verify()) .assertFailure() @@ -64,7 +65,7 @@ public void failGracefully_whenEqualsCallsAnAbstractFieldsAbstractMethod() { } @Test - public void succeed_whenEqualsCallsAnAbstractFieldsAbstactMethod_givenAConcretePrefabImplementationOfSaidAbstractField() { + void succeed_whenEqualsCallsAnAbstractFieldsAbstactMethod_givenAConcretePrefabImplementationOfSaidAbstractField() { EqualsVerifier .forClass(EqualsDelegatesToAbstractMethodInField.class) .withPrefabValues(AbstractDelegator.class, new AbstractDelegatorImpl(1), new AbstractDelegatorImpl(2)) @@ -72,7 +73,7 @@ public void succeed_whenEqualsCallsAnAbstractFieldsAbstactMethod_givenAConcreteP } @Test - public void failGracefully_whenHashCodeCallsAnAbstractFieldsAbstactMethod() { + void failGracefully_whenHashCodeCallsAnAbstractFieldsAbstactMethod() { ExpectedException .when(() -> EqualsVerifier.forClass(HashCodeDelegatesToAbstractMethodInField.class).verify()) .assertFailure() @@ -84,7 +85,7 @@ public void failGracefully_whenHashCodeCallsAnAbstractFieldsAbstactMethod() { } @Test - public void succeed_whenHashCodeCallsAnAbstractFieldsAbstactMethod_givenAConcretePrefabImplementationOfSaidAbstractField() { + void succeed_whenHashCodeCallsAnAbstractFieldsAbstactMethod_givenAConcretePrefabImplementationOfSaidAbstractField() { EqualsVerifier .forClass(HashCodeDelegatesToAbstractMethodInField.class) .withPrefabValues(AbstractDelegator.class, new AbstractDelegatorImpl(1), new AbstractDelegatorImpl(2)) @@ -92,12 +93,12 @@ public void succeed_whenHashCodeCallsAnAbstractFieldsAbstactMethod_givenAConcret } @Test - public void succeed_whenToStringCallsAnAbstractFieldsAbstractMethod() { + void succeed_whenToStringCallsAnAbstractFieldsAbstractMethod() { EqualsVerifier.forClass(ToStringDelegatesToAbstractMethodInField.class).verify(); } @Test - public void failGracefully_whenAFieldsEqualsMethodCallsAnAbstractField() { + void failGracefully_whenAFieldsEqualsMethodCallsAnAbstractField() { ExpectedException .when(() -> EqualsVerifier.forClass(EqualsInFieldDelegatesToAbstractMethod.class).verify()) .assertFailure() @@ -110,7 +111,7 @@ public void failGracefully_whenAFieldsEqualsMethodCallsAnAbstractField() { } @Test - public void succeed_whenAFieldsEqualsMethodCallsAnAbstractField_givenAConcretePrefabImplementationOfSaidField() { + void succeed_whenAFieldsEqualsMethodCallsAnAbstractField_givenAConcretePrefabImplementationOfSaidField() { EqualsVerifier .forClass(EqualsInFieldDelegatesToAbstractMethod.class) .withPrefabValues( @@ -121,7 +122,7 @@ public void succeed_whenAFieldsEqualsMethodCallsAnAbstractField_givenAConcretePr } @Test - public void failGracefully_whenAFieldsHashCodeMethodCallsAnAbstractField() { + void failGracefully_whenAFieldsHashCodeMethodCallsAnAbstractField() { ExpectedException .when(() -> EqualsVerifier.forClass(HashCodeInFieldDelegatesToAbstractMethod.class).verify()) .assertFailure() @@ -134,7 +135,7 @@ public void failGracefully_whenAFieldsHashCodeMethodCallsAnAbstractField() { } @Test - public void succeed_whenAFieldsHashCodeMethodCallsAnAbstractField_givenAConcretePrefabImplementationOfSaidField() { + void succeed_whenAFieldsHashCodeMethodCallsAnAbstractField_givenAConcretePrefabImplementationOfSaidField() { EqualsVerifier .forClass(HashCodeInFieldDelegatesToAbstractMethod.class) .withPrefabValues( @@ -145,32 +146,32 @@ public void succeed_whenAFieldsHashCodeMethodCallsAnAbstractField_givenAConcrete } @Test - public void succeed_whenAFieldsToStringMethodCallsAnAbstractField() { + void succeed_whenAFieldsToStringMethodCallsAnAbstractField() { EqualsVerifier.forClass(ToStringInFieldDelegatesToAbstractMethod.class).verify(); } @Test - public void succeed_evenThoughEqualsInSuperclassCallsAnAbstractMethod() { + void succeed_evenThoughEqualsInSuperclassCallsAnAbstractMethod() { EqualsVerifier.forClass(AbstractEqualsDelegatorImpl.class).verify(); } @Test - public void succeed_evenThoughHashCodeInSuperclassCallsAnAbstractMethod() { + void succeed_evenThoughHashCodeInSuperclassCallsAnAbstractMethod() { EqualsVerifier.forClass(AbstractHashCodeDelegatorImpl.class).verify(); } @Test - public void succeed_evenThoughToStringInSuperclassCallsAnAbstractMethod() { + void succeed_evenThoughToStringInSuperclassCallsAnAbstractMethod() { EqualsVerifier.forClass(AbstractToStringDelegatorImpl.class).verify(); } @Test - public void succeed_evenThoughEqualsInSuperclassCallsAnAbstractMethod_givenUsingGetClass() { + void succeed_evenThoughEqualsInSuperclassCallsAnAbstractMethod_givenUsingGetClass() { EqualsVerifier.forClass(AbstractEqualsUsingGetClassDelegatorImpl.class).usingGetClass().verify(); } @Test - public void originalMessageIsIncludedInErrorMessage_whenEqualsVerifierSignalsAnAbstractDelegationIssue() { + void originalMessageIsIncludedInErrorMessage_whenEqualsVerifierSignalsAnAbstractDelegationIssue() { ExpectedException .when(() -> EqualsVerifier.forClass(ThrowsAbstractMethodErrorWithMessage.class).verify()) .assertFailure() @@ -178,7 +179,7 @@ public void originalMessageIsIncludedInErrorMessage_whenEqualsVerifierSignalsAnA } @Test - public void failGracefully_whenAFieldsEqualsMethodDoesntDoAnIdentityCheckButCallsAnAbstractField() { + void failGracefully_whenAFieldsEqualsMethodDoesntDoAnIdentityCheckButCallsAnAbstractField() { ExpectedException .when( () -> EqualsVerifier @@ -194,7 +195,7 @@ public void failGracefully_whenAFieldsEqualsMethodDoesntDoAnIdentityCheckButCall } @Test - public void succeed_whenAFieldsEqualsMethodDoesntDoAnIdentityCheckButCallsAnAbstractField_givenAConcretePrefabImplementationOfSaidField() { + void succeed_whenAFieldsEqualsMethodDoesntDoAnIdentityCheckButCallsAnAbstractField_givenAConcretePrefabImplementationOfSaidField() { EqualsVerifier .forClass(EqualsInFieldWithoutIdentityCheckDelegatesToAbstractMethod.class) .withPrefabValues( diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ArrayTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ArrayTest.java index 9386a7e22..4a822a055 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ArrayTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ArrayTest.java @@ -11,7 +11,7 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class ArrayTest { +class ArrayTest { private static final String REGULAR_EQUALS = "Array: == or regular equals() used instead of Arrays.equals() for field"; @@ -24,7 +24,7 @@ public class ArrayTest { private static final String FIELD_NAME = "array"; @Test - public void fail_whenRegularEqualsIsUsedInsteadOfArraysEquals_givenAPrimitiveArray() { + void fail_whenRegularEqualsIsUsedInsteadOfArraysEquals_givenAPrimitiveArray() { ExpectedException .when(() -> EqualsVerifier.forClass(PrimitiveArrayRegularEquals.class).verify()) .assertFailure() @@ -32,7 +32,7 @@ public void fail_whenRegularEqualsIsUsedInsteadOfArraysEquals_givenAPrimitiveArr } @Test - public void fail_whenRegularHashCodeIsUsedInsteadOfArraysHashCode_givenAPrimitiveArray() { + void fail_whenRegularHashCodeIsUsedInsteadOfArraysHashCode_givenAPrimitiveArray() { ExpectedException .when(() -> EqualsVerifier.forClass(PrimitiveArrayRegularHashCode.class).verify()) .assertFailure() @@ -40,12 +40,12 @@ public void fail_whenRegularHashCodeIsUsedInsteadOfArraysHashCode_givenAPrimitiv } @Test - public void succeed_whenCorrectMethodsAreUsed_givenAPrimitiveArray() { + void succeed_whenCorrectMethodsAreUsed_givenAPrimitiveArray() { EqualsVerifier.forClass(PrimitiveArrayCorrect.class).verify(); } @Test - public void fail_whenArraysEqualsIsUsedInsteadOfDeepEquals_givenAMultidimensionalArray() { + void fail_whenArraysEqualsIsUsedInsteadOfDeepEquals_givenAMultidimensionalArray() { ExpectedException .when(() -> EqualsVerifier.forClass(MultidimensionalArrayArraysEquals.class).verify()) .assertFailure() @@ -53,7 +53,7 @@ public void fail_whenArraysEqualsIsUsedInsteadOfDeepEquals_givenAMultidimensiona } @Test - public void fail_whenRegularHashCodeIsUsedInsteadOfDeepHashCode_givenAMultidimensionalArray() { + void fail_whenRegularHashCodeIsUsedInsteadOfDeepHashCode_givenAMultidimensionalArray() { ExpectedException .when(() -> EqualsVerifier.forClass(MultidimensionalArrayRegularHashCode.class).verify()) .assertFailure() @@ -61,7 +61,7 @@ public void fail_whenRegularHashCodeIsUsedInsteadOfDeepHashCode_givenAMultidimen } @Test - public void fail_whenArraysHashCodeIsUsedInsteadOfDeepHashCode_givenAMultidimensionalArray() { + void fail_whenArraysHashCodeIsUsedInsteadOfDeepHashCode_givenAMultidimensionalArray() { ExpectedException .when(() -> EqualsVerifier.forClass(MultidimensionalArrayArraysHashCode.class).verify()) .assertFailure() @@ -69,12 +69,12 @@ public void fail_whenArraysHashCodeIsUsedInsteadOfDeepHashCode_givenAMultidimens } @Test - public void succeed_whenCorrectMethodsAreUsed_givenAMultidimensionalArray() { + void succeed_whenCorrectMethodsAreUsed_givenAMultidimensionalArray() { EqualsVerifier.forClass(MultidimensionalArrayCorrect.class).verify(); } @Test - public void failWithCorrectMessage_whenShallowHashCodeIsUsedOnSecondArray_givenTwoMultidimensionalArrays() { + void failWithCorrectMessage_whenShallowHashCodeIsUsedOnSecondArray_givenTwoMultidimensionalArrays() { ExpectedException .when(() -> EqualsVerifier.forClass(TwoMultidimensionalArraysShallowHashCodeForSecond.class).verify()) .assertFailure() @@ -82,12 +82,12 @@ public void failWithCorrectMessage_whenShallowHashCodeIsUsedOnSecondArray_givenT } @Test - public void succeed_whenCorrectMethodsAreUsed_givenAThreedimensionalArray() { + void succeed_whenCorrectMethodsAreUsed_givenAThreedimensionalArray() { EqualsVerifier.forClass(ThreeDimensionalArrayCorrect.class).verify(); } @Test - public void failWithRecursionError_whenClassContainsARecursionButAlsoAMutltiDimensionalArray() { + void failWithRecursionError_whenClassContainsARecursionButAlsoAMutltiDimensionalArray() { ExpectedException .when(() -> EqualsVerifier.forClass(MultiDimensionalArrayAndRecursion.Board.class).verify()) .assertThrows(AssertionError.class) @@ -95,7 +95,7 @@ public void failWithRecursionError_whenClassContainsARecursionButAlsoAMutltiDime } @Test - public void fail_whenRegularEqualsIsUsedInsteadOfArraysEquals_givenAnObjectArray() { + void fail_whenRegularEqualsIsUsedInsteadOfArraysEquals_givenAnObjectArray() { ExpectedException .when(() -> EqualsVerifier.forClass(ObjectArrayRegularEquals.class).verify()) .assertFailure() @@ -103,7 +103,7 @@ public void fail_whenRegularEqualsIsUsedInsteadOfArraysEquals_givenAnObjectArray } @Test - public void fail_whenRegularHashCodeIsUsedInsteadOfArraysHashCode_givenAnObjectArray() { + void fail_whenRegularHashCodeIsUsedInsteadOfArraysHashCode_givenAnObjectArray() { ExpectedException .when(() -> EqualsVerifier.forClass(ObjectArrayRegularHashCode.class).verify()) .assertFailure() @@ -111,17 +111,17 @@ public void fail_whenRegularHashCodeIsUsedInsteadOfArraysHashCode_givenAnObjectA } @Test - public void succeed_whenCorrectMethodsAreUsed_givenAnObjectArray() { + void succeed_whenCorrectMethodsAreUsed_givenAnObjectArray() { EqualsVerifier.forClass(ObjectArrayCorrect.class).verify(); } @Test - public void succeed_whenCorrectMethodsAreUsed_givenAnArrayAndAnUnusedField() { + void succeed_whenCorrectMethodsAreUsed_givenAnArrayAndAnUnusedField() { EqualsVerifier.forClass(ArrayAndSomethingUnused.class).suppress(Warning.ALL_FIELDS_SHOULD_BE_USED).verify(); } @Test - public void succeed_whenArraysAreNotUsedInEquals_givenArrayFields() { + void succeed_whenArraysAreNotUsedInEquals_givenArrayFields() { EqualsVerifier .forClass(ArraysAreUnused.class) .suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT, Warning.ALL_FIELDS_SHOULD_BE_USED) @@ -129,17 +129,17 @@ public void succeed_whenArraysAreNotUsedInEquals_givenArrayFields() { } @Test - public void succeed_whenStaticFinalArrayIsEmpty() { + void succeed_whenStaticFinalArrayIsEmpty() { EqualsVerifier.forClass(EmptyStaticFinalArrayContainer.class).verify(); } @Test - public void succeed_whenStaticArrayIsUninitialized() { + void succeed_whenStaticArrayIsUninitialized() { EqualsVerifier.forClass(UninitializedStaticArrayContainer.class).verify(); } @Test - public void succeed_whenArrayLengthIsInvariant() { + void succeed_whenArrayLengthIsInvariant() { int[] a = { 1, 2, 3 }; int[] b = { 4, 5, 6 }; int[][] x = { a, a, a }; diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/BalancedAbstractnessTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/BalancedAbstractnessTest.java index b303e1f63..289825d55 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/BalancedAbstractnessTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/BalancedAbstractnessTest.java @@ -8,8 +8,9 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -@SuppressWarnings("unused") // because of the use of defaultEquals and defaultHashCode -public class BalancedAbstractnessTest { +// because of the use of defaultEquals and defaultHashCode +@SuppressWarnings("unused") +class BalancedAbstractnessTest { private static final String ABSTRACT_DELEGATION = "Abstract delegation"; private static final String BOTH_ARE_ABSTRACT = "equals and hashCode methods are both abstract"; @@ -21,7 +22,7 @@ public class BalancedAbstractnessTest { private static final String BOTH_SHOULD_BE_SAME = "Both should be either abstract or concrete"; @Test - public void fail_whenBothEqualsAndHashCodeAreAbstract() { + void fail_whenBothEqualsAndHashCodeAreAbstract() { ExpectedException .when( () -> EqualsVerifier @@ -33,7 +34,7 @@ public void fail_whenBothEqualsAndHashCodeAreAbstract() { } @Test - public void fail_whenEqualsIsAbstract() { + void fail_whenEqualsIsAbstract() { ExpectedException .when( () -> EqualsVerifier @@ -49,7 +50,7 @@ public void fail_whenEqualsIsAbstract() { } @Test - public void fail_whenHashCodeIsAbstract() { + void fail_whenHashCodeIsAbstract() { ExpectedException .when(() -> EqualsVerifier.forClass(AbstractHashCode.class).verify()) .assertFailure() @@ -61,22 +62,22 @@ public void fail_whenHashCodeIsAbstract() { } @Test - public void succeed_whenBothAreAbstractInSuperclass() { + void succeed_whenBothAreAbstractInSuperclass() { EqualsVerifier.forClass(SubclassOfAbstractBoth.class).verify(); } @Test - public void succeed_whenOnlyEqualsIsAbstractInSuperclass() { + void succeed_whenOnlyEqualsIsAbstractInSuperclass() { EqualsVerifier.forClass(SubclassOfAbstractEqualsButNotHashCode.class).verify(); } @Test - public void succeed_whenOnlyHashCodeIsAbstractInSuperclass() { + void succeed_whenOnlyHashCodeIsAbstractInSuperclass() { EqualsVerifier.forClass(SubclassOfAbstractHashCodeButNotEquals.class).verify(); } @Test - public void succeed_whenBothAreAbstractInSuperclassOfSuperclass() { + void succeed_whenBothAreAbstractInSuperclassOfSuperclass() { EqualsVerifier.forClass(SubclassOfSubclassOfAbstractBoth.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/BigDecimalTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/BigDecimalTest.java index edefd1398..1ad5c6278 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/BigDecimalTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/BigDecimalTest.java @@ -11,10 +11,10 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class BigDecimalTest { +class BigDecimalTest { @Test - public void fail_whenBigDecimalsComparedUsingEqualsWithComparablyConsistentHashCode() { + void fail_whenBigDecimalsComparedUsingEqualsWithComparablyConsistentHashCode() { ExpectedException .when(() -> EqualsVerifier.forClass(BigDecimalEqualsWithComparablyConsistentHashCode.class).verify()) .assertFailure() @@ -28,7 +28,7 @@ public void fail_whenBigDecimalsComparedUsingEqualsWithComparablyConsistentHashC } @Test - public void fail_whenBigDecimalsComparedUsingCompareToWithInconsistentHashCode() { + void fail_whenBigDecimalsComparedUsingCompareToWithInconsistentHashCode() { ExpectedException .when(() -> EqualsVerifier.forClass(BigDecimalInconsistentHashCode.class).verify()) .assertFailure() @@ -42,12 +42,12 @@ public void fail_whenBigDecimalsComparedUsingCompareToWithInconsistentHashCode() } @Test - public void succeed_whenBigDecimalsComparedUsingEquals_givenBigDecimalEqualsWarningIsSuppressed() { + void succeed_whenBigDecimalsComparedUsingEquals_givenBigDecimalEqualsWarningIsSuppressed() { EqualsVerifier.forClass(BigDecimalEquals.class).suppress(Warning.BIGDECIMAL_EQUALITY).verify(); } @Test - public void succeed_whenBigDecimalsComparedUsingCompareTo() { + void succeed_whenBigDecimalsComparedUsingCompareTo() { EqualsVerifier.forClass(BigDecimalCompareTo.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/DontOverrideEqualsTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/DontOverrideEqualsTest.java index 26081de7b..03f8d009f 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/DontOverrideEqualsTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/DontOverrideEqualsTest.java @@ -6,10 +6,10 @@ import nl.jqno.equalsverifier.testhelpers.types.Point; import org.junit.jupiter.api.Test; -public class DontOverrideEqualsTest { +class DontOverrideEqualsTest { @Test - public void fail_whenEqualsIsInheritedDirectlyFromObject() { + void fail_whenEqualsIsInheritedDirectlyFromObject() { ExpectedException .when(() -> EqualsVerifier.forClass(NoEqualsNoHashCodeMethod.class).verify()) .assertFailure() @@ -17,7 +17,7 @@ public void fail_whenEqualsIsInheritedDirectlyFromObject() { } @Test - public void succeed_whenEqualsIsInheritedDirectlyFromObject_givenDirectlyInheritedWarningIsSuppressed() { + void succeed_whenEqualsIsInheritedDirectlyFromObject_givenDirectlyInheritedWarningIsSuppressed() { EqualsVerifier .forClass(NoEqualsNoHashCodeMethod.class) .suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT) @@ -25,12 +25,12 @@ public void succeed_whenEqualsIsInheritedDirectlyFromObject_givenDirectlyInherit } @Test - public void succeed_whenEqualsIsInheritedButNotFromObject() { + void succeed_whenEqualsIsInheritedButNotFromObject() { EqualsVerifier.forClass(InheritedEqualsAndHashCodeMethod.class).verify(); } @Test - public void succeed_whenClassIsAPojoAndEqualsIsInheritedDirectlyFromObject_givenVariousWarningsAreSuppressed() { + void succeed_whenClassIsAPojoAndEqualsIsInheritedDirectlyFromObject_givenVariousWarningsAreSuppressed() { EqualsVerifier .forClass(Pojo.class) .suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT) @@ -39,7 +39,7 @@ public void succeed_whenClassIsAPojoAndEqualsIsInheritedDirectlyFromObject_given } @Test - public void succeed_whenClassInheritsFromSomethingWithStateAndEqualsIsInheritedDirectlyFromObject_givenDetailMessageIsIgnored() { + void succeed_whenClassInheritsFromSomethingWithStateAndEqualsIsInheritedDirectlyFromObject_givenDetailMessageIsIgnored() { EqualsVerifier .forClass(SubclassWithoutEqualsButWithStateFromSuper.class) .suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/EnumTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/EnumTest.java index e5d5d010f..a7b33fba4 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/EnumTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/EnumTest.java @@ -11,45 +11,45 @@ import nl.jqno.equalsverifier.Warning; import org.junit.jupiter.api.Test; -public class EnumTest { +class EnumTest { @Test - public void succeed_whenClassIsAnEnum() { + void succeed_whenClassIsAnEnum() { EqualsVerifier.forClass(Enum.class).verify(); } @Test - public void succeed_whenClassHasAnEmptyEnumButIgnoresIt() { + void succeed_whenClassHasAnEmptyEnumButIgnoresIt() { EqualsVerifier.forClass(EmptyEnumContainer.class).verify(); } @Test - public void succeed_whenClassHasASingletonEnumButIgnoresIt() { + void succeed_whenClassHasASingletonEnumButIgnoresIt() { EqualsVerifier.forClass(SingletonContainer.class).verify(); } @Test - public void succeed_whenClassHasASingletonEnumAndUsesItInEquals() { + void succeed_whenClassHasASingletonEnumAndUsesItInEquals() { EqualsVerifier.forClass(SingletonUser.class).verify(); } @Test - public void succeed_whenSingletonIsUsedWithoutNullCheck_givenNullFieldsWarningIsSuppressed() { + void succeed_whenSingletonIsUsedWithoutNullCheck_givenNullFieldsWarningIsSuppressed() { EqualsVerifier.forClass(NullThrowingSingletonUser.class).suppress(Warning.NULL_FIELDS).verify(); } @Test - public void succeed_whenClassHasSingletonCollection() { + void succeed_whenClassHasSingletonCollection() { EqualsVerifier.forClass(SingletonCollectionContainer.class).verify(); } @Test - public void succeed_whenClassHasMapWithSingletonKey() { + void succeed_whenClassHasMapWithSingletonKey() { EqualsVerifier.forClass(SingletonKeyMapContainer.class).verify(); } @Test - public void succeed_whenClassHasSingletonOptional() { + void succeed_whenClassHasSingletonOptional() { EqualsVerifier.forClass(SingletonOptionalContainer.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ExtendedReflexivityTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ExtendedReflexivityTest.java index 89d70ac83..01cc47476 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ExtendedReflexivityTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ExtendedReflexivityTest.java @@ -10,15 +10,15 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class ExtendedReflexivityTest { +class ExtendedReflexivityTest { @Test - public void succeed_whenEqualsUsesEqualsMethodForObjects() { + void succeed_whenEqualsUsesEqualsMethodForObjects() { EqualsVerifier.forClass(UsesEqualsMethod.class).verify(); } @Test - public void fail_whenEqualsUsesDoubleEqualSignForObjects() { + void fail_whenEqualsUsesDoubleEqualSignForObjects() { ExpectedException .when(() -> EqualsVerifier.forClass(UsesDoubleEqualSign.class).verify()) .assertFailure() @@ -26,12 +26,12 @@ public void fail_whenEqualsUsesDoubleEqualSignForObjects() { } @Test - public void succeed_whenEqualsUsesDoubleEqualSignForObject_givenDoubleEqualWarningIsSuppressed() { + void succeed_whenEqualsUsesDoubleEqualSignForObject_givenDoubleEqualWarningIsSuppressed() { EqualsVerifier.forClass(UsesDoubleEqualSign.class).suppress(Warning.REFERENCE_EQUALITY).verify(); } @Test - public void fail_whenEqualsUsesDoubleEqualSignForBoxedCharacterPrimitives() { + void fail_whenEqualsUsesDoubleEqualSignForBoxedCharacterPrimitives() { ExpectedException .when(() -> EqualsVerifier.forClass(UsesDoubleEqualSignOnBoxedCharacterPrimitive.class).verify()) .assertFailure() @@ -39,7 +39,7 @@ public void fail_whenEqualsUsesDoubleEqualSignForBoxedCharacterPrimitives() { } @Test - public void succeed_whenEqualsUsesDoubleEqualSignForBoxedCharacterPrimitives_givenDoubleEqualWarningIsSuppressed() { + void succeed_whenEqualsUsesDoubleEqualSignForBoxedCharacterPrimitives_givenDoubleEqualWarningIsSuppressed() { EqualsVerifier .forClass(UsesDoubleEqualSignOnBoxedCharacterPrimitive.class) .suppress(Warning.REFERENCE_EQUALITY) @@ -47,7 +47,7 @@ public void succeed_whenEqualsUsesDoubleEqualSignForBoxedCharacterPrimitives_giv } @Test - public void fail_whenEqualsUsesDoubleEqualSignForBoxedIntegerPrimitives() { + void fail_whenEqualsUsesDoubleEqualSignForBoxedIntegerPrimitives() { ExpectedException .when(() -> EqualsVerifier.forClass(UsesDoubleEqualSignOnBoxedIntegerPrimitive.class).verify()) .assertFailure() @@ -55,7 +55,7 @@ public void fail_whenEqualsUsesDoubleEqualSignForBoxedIntegerPrimitives() { } @Test - public void succeed_whenEqualsUsesDoubleEqualSignForBoxedIntegerPrimitives_givenDoubleEqualWarningIsSuppressed() { + void succeed_whenEqualsUsesDoubleEqualSignForBoxedIntegerPrimitives_givenDoubleEqualWarningIsSuppressed() { EqualsVerifier .forClass(UsesDoubleEqualSignOnBoxedIntegerPrimitive.class) .suppress(Warning.REFERENCE_EQUALITY) @@ -63,7 +63,7 @@ public void succeed_whenEqualsUsesDoubleEqualSignForBoxedIntegerPrimitives_given } @Test - public void fail_whenEqualsUsesDoubleEqualSignForBoxedLongPrimitives() { + void fail_whenEqualsUsesDoubleEqualSignForBoxedLongPrimitives() { ExpectedException .when(() -> EqualsVerifier.forClass(UsesDoubleEqualSignOnBoxedLongPrimitive.class).verify()) .assertFailure() @@ -71,7 +71,7 @@ public void fail_whenEqualsUsesDoubleEqualSignForBoxedLongPrimitives() { } @Test - public void succeed_whenEqualsUsesDoubleEqualSignForBoxedLongPrimitives_givenDoubleEqualWarningIsSuppressed() { + void succeed_whenEqualsUsesDoubleEqualSignForBoxedLongPrimitives_givenDoubleEqualWarningIsSuppressed() { EqualsVerifier .forClass(UsesDoubleEqualSignOnBoxedLongPrimitive.class) .suppress(Warning.REFERENCE_EQUALITY) @@ -79,7 +79,7 @@ public void succeed_whenEqualsUsesDoubleEqualSignForBoxedLongPrimitives_givenDou } @Test - public void fail_whenEqualsUsesDoubleEqualSignForBoxedShortPrimitives() { + void fail_whenEqualsUsesDoubleEqualSignForBoxedShortPrimitives() { ExpectedException .when(() -> EqualsVerifier.forClass(UsesDoubleEqualSignOnBoxedShortPrimitive.class).verify()) .assertFailure() @@ -87,7 +87,7 @@ public void fail_whenEqualsUsesDoubleEqualSignForBoxedShortPrimitives() { } @Test - public void succeed_whenEqualsUsesDoubleEqualSignForBoxedShortPrimitives_givenDoubleEqualWarningIsSuppressed() { + void succeed_whenEqualsUsesDoubleEqualSignForBoxedShortPrimitives_givenDoubleEqualWarningIsSuppressed() { EqualsVerifier .forClass(UsesDoubleEqualSignOnBoxedShortPrimitive.class) .suppress(Warning.REFERENCE_EQUALITY) @@ -95,17 +95,17 @@ public void succeed_whenEqualsUsesDoubleEqualSignForBoxedShortPrimitives_givenDo } @Test - public void succeed_whenEqualsUsesDoubleEqualSignForObject_givenObjectDoesntDeclareEquals() { + void succeed_whenEqualsUsesDoubleEqualSignForObject_givenObjectDoesntDeclareEquals() { EqualsVerifier.forClass(FieldHasNoEquals.class).verify(); } @Test - public void succeed_whenEqualsUsesDoubleEqualSignForObject_givenObjectIsAnInterface() { + void succeed_whenEqualsUsesDoubleEqualSignForObject_givenObjectIsAnInterface() { EqualsVerifier.forClass(FieldIsInterface.class).verify(); } @Test - public void succeed_whenEqualsUsesDoubleEqualSignForObject_givenObjectIsAnInterfaceWithEquals() { + void succeed_whenEqualsUsesDoubleEqualSignForObject_givenObjectIsAnInterfaceWithEquals() { EqualsVerifier.forClass(FieldIsInterfaceWithEquals.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ExternalApiClassesTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ExternalApiClassesTest.java index 8ba378da3..f327c1ff6 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ExternalApiClassesTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ExternalApiClassesTest.java @@ -16,50 +16,50 @@ // CHECKSTYLE OFF: ParameterNumber -public class ExternalApiClassesTest { +class ExternalApiClassesTest { @Test - public void succeed_whenClassUsesJavaxClasses() { + void succeed_whenClassUsesJavaxClasses() { EqualsVerifier.forClass(JavaxContainer.class).verify(); } @Test - public void succeed_whenClassUsesGoogleGuavaMultiset() { + void succeed_whenClassUsesGoogleGuavaMultiset() { EqualsVerifier.forClass(GuavaMultisetContainer.class).verify(); } @Test - public void succeed_whenClassUsesGoogleGuavaMultimap() { + void succeed_whenClassUsesGoogleGuavaMultimap() { EqualsVerifier.forClass(GuavaMultimapContainer.class).verify(); } @Test - public void succeed_whenClassUsesGoogleGuavaBiMap() { + void succeed_whenClassUsesGoogleGuavaBiMap() { EqualsVerifier.forClass(GuavaBiMapContainer.class).verify(); } @Test - public void succeed_whenClassUsesGoogleGuavaTable() { + void succeed_whenClassUsesGoogleGuavaTable() { EqualsVerifier.forClass(GuavaTableContainer.class).verify(); } @Test - public void succeed_whenClassUsesGoogleGuavaImmutableCollection() { + void succeed_whenClassUsesGoogleGuavaImmutableCollection() { EqualsVerifier.forClass(GuavaImmutableContainer.class).verify(); } @Test - public void succeed_whenClassUsesGoogleGuavaRegularCollection() { + void succeed_whenClassUsesGoogleGuavaRegularCollection() { EqualsVerifier.forClass(GuavaRegularCollectionsContainer.class).verify(); } @Test - public void succeed_whenClassUsesOtherGoogleGuavaClass() { + void succeed_whenClassUsesOtherGoogleGuavaClass() { EqualsVerifier.forClass(GuavaOtherContainer.class).verify(); } @Test - public void succeed_whenClassUsesJodaTimeClass() { + void succeed_whenClassUsesJodaTimeClass() { EqualsVerifier.forClass(JodaTimeContainer.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/FloatAndDoubleTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/FloatAndDoubleTest.java index ce4cb8c64..3fb276362 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/FloatAndDoubleTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/FloatAndDoubleTest.java @@ -6,13 +6,13 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class FloatAndDoubleTest { +class FloatAndDoubleTest { private static final String FLOAT = "Float: equals doesn't use Float.compare for field"; private static final String DOUBLE = "Double: equals doesn't use Double.compare for field"; @Test - public void fail_whenFloatsAreComparedByReference() { + void fail_whenFloatsAreComparedByReference() { ExpectedException .when(() -> EqualsVerifier.forClass(ComparePrimitiveFloatsByReference.class).verify()) .assertFailure() @@ -20,7 +20,7 @@ public void fail_whenFloatsAreComparedByReference() { } @Test - public void fail_whenObjectFloatsAreComparedByReference() { + void fail_whenObjectFloatsAreComparedByReference() { ExpectedException .when(() -> EqualsVerifier.forClass(CompareObjectFloatByReference.class).verify()) .assertFailure() @@ -28,12 +28,12 @@ public void fail_whenObjectFloatsAreComparedByReference() { } @Test - public void succeed_whenFloatsAreComparedWithFloatCompare() { + void succeed_whenFloatsAreComparedWithFloatCompare() { EqualsVerifier.forClass(CompareFloatCorrectly.class).verify(); } @Test - public void fail_whenDoublesAreComparedByReference() { + void fail_whenDoublesAreComparedByReference() { ExpectedException .when(() -> EqualsVerifier.forClass(ComparePrimitiveDoubleByReference.class).verify()) .assertFailure() @@ -41,7 +41,7 @@ public void fail_whenDoublesAreComparedByReference() { } @Test - public void fail_whenObjectDoublesAreComparedByReference() { + void fail_whenObjectDoublesAreComparedByReference() { ExpectedException .when(() -> EqualsVerifier.forClass(CompareObjectDoubleByReference.class).verify()) .assertFailure() @@ -49,7 +49,7 @@ public void fail_whenObjectDoublesAreComparedByReference() { } @Test - public void succeed_whenDoublesAreComparedWithDoubleCompare() { + void succeed_whenDoublesAreComparedWithDoubleCompare() { EqualsVerifier.forClass(CompareDoubleCorrectly.class).verify(); } 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 fa57f2eda..16e06c949 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 @@ -14,100 +14,100 @@ import nl.jqno.equalsverifier.testhelpers.types.Point; import org.junit.jupiter.api.Test; -public class GenericTypesTest { +class GenericTypesTest { @Test - public void succeed_whenClassHasGenericFieldThatsSpecifiedToABuiltinGeneric() { + void succeed_whenClassHasGenericFieldThatsSpecifiedToABuiltinGeneric() { EqualsVerifier.forClass(GenericContainerWithBuiltin.class).verify(); } @Test - public void succeed_whenEqualsLooksAtJava8TypesGenericContent() { + void succeed_whenEqualsLooksAtJava8TypesGenericContent() { EqualsVerifier.forClass(JavaGenericTypeContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtListFieldsGenericContent() { + void succeed_whenEqualsLooksAtListFieldsGenericContent() { EqualsVerifier.forClass(ListContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtSetFieldsGenericContent() { + void succeed_whenEqualsLooksAtSetFieldsGenericContent() { EqualsVerifier.forClass(SetContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtMapFieldsGenericContent() { + void succeed_whenEqualsLooksAtMapFieldsGenericContent() { EqualsVerifier.forClass(MapContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtListOfTFieldsGenericContent() { + void succeed_whenEqualsLooksAtListOfTFieldsGenericContent() { EqualsVerifier.forClass(ListOfTContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtArrayOfTFieldsGenericContent() { + void succeed_whenEqualsLooksAtArrayOfTFieldsGenericContent() { EqualsVerifier.forClass(ArrayOfTContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtImmutableCollectionFieldsGenericContent() { + void succeed_whenEqualsLooksAtImmutableCollectionFieldsGenericContent() { EqualsVerifier.forClass(ImmutableCollectionContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtImmutableListFieldsGenericContent() { + void succeed_whenEqualsLooksAtImmutableListFieldsGenericContent() { EqualsVerifier.forClass(ImmutableListContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtImmutableMapFieldsGenericContent() { + void succeed_whenEqualsLooksAtImmutableMapFieldsGenericContent() { EqualsVerifier.forClass(ImmutableMapContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtBiMapFieldsGenericContent() { + void succeed_whenEqualsLooksAtBiMapFieldsGenericContent() { EqualsVerifier.forClass(BiMapContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtRangeEndpointGenericContent() { + void succeed_whenEqualsLooksAtRangeEndpointGenericContent() { EqualsVerifier.forClass(RangeContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtNonCollectionGenericContent() { + void succeed_whenEqualsLooksAtNonCollectionGenericContent() { EqualsVerifier.forClass(SparseArrayEqualsContainer.class).verify(); } @Test - public void succeed_whenHashCodeLooksAtNonCollectionGenericContent() { + void succeed_whenHashCodeLooksAtNonCollectionGenericContent() { EqualsVerifier.forClass(SparseArrayHashCodeContainer.class).verify(); } @Test - public void succeed_whenToStringLooksAtNonCollectionGenericContent() { + void succeed_whenToStringLooksAtNonCollectionGenericContent() { EqualsVerifier.forClass(SparseArrayToStringContainer.class).verify(); } @Test - public void succeed_whenEqualsLooksAtGenericContent_givenTwoGenericFields() { + void succeed_whenEqualsLooksAtGenericContent_givenTwoGenericFields() { EqualsVerifier.forClass(TwoGenericsContainerWithIntrospection.class).verify(); } @Test - public void succeed_whenClassHasTypeVariableThatExtendsSomething() { + void succeed_whenClassHasTypeVariableThatExtendsSomething() { EqualsVerifier.forClass(TypeVariableExtendsContainer.class).verify(); } @Test - public void succeed_whenClassHasTypeVariableThatExtendsSomethingThatSupersSomething() { + void succeed_whenClassHasTypeVariableThatExtendsSomethingThatSupersSomething() { EqualsVerifier.forClass(TypeVariableExtendsWithSuperContainer.class).verify(); } @Test - public void failGracefully_whenClassHasASelfReferenceGenericParameter() { + void failGracefully_whenClassHasASelfReferenceGenericParameter() { ExpectedException .when(() -> EqualsVerifier.forClass(SelfReferringGenericType.class).verify()) .assertFailure() @@ -119,7 +119,7 @@ public void failGracefully_whenClassHasASelfReferenceGenericParameter() { } @Test - public void succeed_whenClassHasASelfReferenceGenericParameter_givenPrefabValues() { + void succeed_whenClassHasASelfReferenceGenericParameter_givenPrefabValues() { EqualsVerifier .forClass(SelfReferringGenericType.class) .withPrefabValues( @@ -131,12 +131,12 @@ public void succeed_whenClassHasASelfReferenceGenericParameter_givenPrefabValues } @Test - public void succeed_whenClassContainsAMapWithAnArray() { + void succeed_whenClassContainsAMapWithAnArray() { EqualsVerifier.forClass(ArrayMapContainer.class).withNonnullFields("map").verify(); } @Test - public void succeed_whenClassContainsAClassThatContainsAMapWithArray() { + void succeed_whenClassContainsAClassThatContainsAMapWithArray() { EqualsVerifier.forClass(ArrayMapContainerContainer.class).withNonnullFields("mapContainer").verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/InterfaceTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/InterfaceTest.java index 2cd3d65d4..404783ebf 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/InterfaceTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/InterfaceTest.java @@ -3,15 +3,15 @@ import nl.jqno.equalsverifier.EqualsVerifier; import org.junit.jupiter.api.Test; -public class InterfaceTest { +class InterfaceTest { @Test - public void succeed_whenClassIsAnInterface() { + void succeed_whenClassIsAnInterface() { EqualsVerifier.forClass(CharSequence.class).verify(); } @Test - public void succeed_whenClassIsAnEmptyInterface() { + void succeed_whenClassIsAnEmptyInterface() { EqualsVerifier.forClass(Interface.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/JavaApiClassesTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/JavaApiClassesTest.java index 0b7ad9275..2e4675762 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/JavaApiClassesTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/JavaApiClassesTest.java @@ -31,50 +31,50 @@ // CHECKSTYLE OFF: ParameterNumber -public class JavaApiClassesTest { +class JavaApiClassesTest { @Test - public void succeed_whenClassContainsASuperCollection() { + void succeed_whenClassContainsASuperCollection() { EqualsVerifier.forClass(SuperCollectionContainer.class).verify(); } @Test - public void succeed_whenClassContainsAList() { + void succeed_whenClassContainsAList() { EqualsVerifier.forClass(ListContainer.class).verify(); } @Test - public void succeed_whenClassContainsASet() { + void succeed_whenClassContainsASet() { EqualsVerifier.forClass(SetContainer.class).verify(); } @Test - public void succeed_whenClassContainsAQueue() { + void succeed_whenClassContainsAQueue() { EqualsVerifier.forClass(QueueContainer.class).verify(); } @Test - public void succeed_whenClassContainsAMap() { + void succeed_whenClassContainsAMap() { EqualsVerifier.forClass(MapContainer.class).verify(); } @Test - public void succeed_whenClassContainsANioBuffer() { + void succeed_whenClassContainsANioBuffer() { EqualsVerifier.forClass(NioBufferContainer.class).verify(); } @Test - public void succeed_whenClassContainsACommonJavaApiClass() { + void succeed_whenClassContainsACommonJavaApiClass() { EqualsVerifier.forClass(CommonClassesContainer.class).verify(); } @Test - public void succeed_whenClassContainsExceptions() { + void succeed_whenClassContainsExceptions() { EqualsVerifier.forClass(ExceptionsContainer.class).verify(); } @Test - public void succeed_whenClassContainsReflectionApiClass() { + void succeed_whenClassContainsReflectionApiClass() { EqualsVerifier .forClass(ReflectionClassesContainer.class) // Because java.lang.reflect.Constructor's hashCode() is unhelpful @@ -83,32 +83,32 @@ public void succeed_whenClassContainsReflectionApiClass() { } @Test - public void succeed_whenClassContainsACommonJava8ApiClass() { + void succeed_whenClassContainsACommonJava8ApiClass() { EqualsVerifier.forClass(Java8ApiClassesContainer.class).verify(); } @Test - public void succeed_whenClassContainsAnAtomicValue() { + void succeed_whenClassContainsAnAtomicValue() { EqualsVerifier.forClass(AtomicClassesContainer.class).verify(); } @Test - public void succeed_whenClassContainsAnAncientJavaApiClass() { + void succeed_whenClassContainsAnAncientJavaApiClass() { EqualsVerifier.forClass(AncientJavaApiClassesContainer.class).verify(); } @Test - public void succeed_whenClassContainsAThreadLocalField() { + void succeed_whenClassContainsAThreadLocalField() { EqualsVerifier.forClass(ThreadLocalContainer.class).verify(); } @Test - public void succeed_whenClassContainsStringBuilderThatCallsToStringInEquals() { + void succeed_whenClassContainsStringBuilderThatCallsToStringInEquals() { EqualsVerifier.forClass(StringBuilderContainer.class).suppress(Warning.NULL_FIELDS).verify(); } @Test - public void succeed_whenClassContainsClassesButDoesntUseThemInEquals() { + void succeed_whenClassContainsClassesButDoesntUseThemInEquals() { EqualsVerifier .forClass(UnusedInEqualsButPresentInClassContainer.class) .suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT, Warning.ALL_FIELDS_SHOULD_BE_USED) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/JavaCollectionSubclassTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/JavaCollectionSubclassTest.java index 3c5371c33..7f7197aa9 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/JavaCollectionSubclassTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/JavaCollectionSubclassTest.java @@ -6,12 +6,12 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class JavaCollectionSubclassTest { +class JavaCollectionSubclassTest { private static final String MESSAGE_FRAGMENT = "cannot verify subclasses of"; @Test - public void failWithHelpfulMessage_whenVerifyingArrayListSubclass() { + void failWithHelpfulMessage_whenVerifyingArrayListSubclass() { ExpectedException .when(() -> EqualsVerifier.forClass(CustomArrayList.class).verify()) .assertFailure() diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ModulesTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ModulesTest.java index c8d2373b4..715b74899 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ModulesTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/ModulesTest.java @@ -14,11 +14,11 @@ * Let's hope nobody needs prefab values for `java.text.AttributedString`, because we need a class here from je Java * APIs that doesn't already have prefab values. */ -public class ModulesTest { +class ModulesTest { @Test @DisabledForJreRange(max = JRE.JAVA_11) - public void giveProperErrorMessage_whenClassUnderTestIsInaccessible() { + void giveProperErrorMessage_whenClassUnderTestIsInaccessible() { ExpectedException .when( () -> EqualsVerifier @@ -31,7 +31,7 @@ public void giveProperErrorMessage_whenClassUnderTestIsInaccessible() { @Test @DisabledForJreRange(max = JRE.JAVA_11) - public void giveProperErrorMessage_whenFieldIsInaccessible() { + void giveProperErrorMessage_whenFieldIsInaccessible() { ExpectedException .when(() -> EqualsVerifier.forClass(InaccessibleContainer.class).verify()) .assertFailure() diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/MutableStateTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/MutableStateTest.java index cb362291f..ade850771 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/MutableStateTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/MutableStateTest.java @@ -10,13 +10,13 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class MutableStateTest { +class MutableStateTest { private static final String MUTABILITY = "Mutability: equals depends on mutable field"; private static final String FIELD_NAME = "field"; @Test - public void fail_whenClassHasAMutablePrimitiveField() { + void fail_whenClassHasAMutablePrimitiveField() { ExpectedException .when(() -> EqualsVerifier.forClass(PrimitiveMutableField.class).verify()) .assertFailure() @@ -24,17 +24,17 @@ public void fail_whenClassHasAMutablePrimitiveField() { } @Test - public void succeed_whenClassHasAMutablePrimitiveField_givenItDoesNotUseThatFieldInEquals() { + void succeed_whenClassHasAMutablePrimitiveField_givenItDoesNotUseThatFieldInEquals() { EqualsVerifier.forClass(UnusedPrimitiveMutableField.class).suppress(Warning.ALL_FIELDS_SHOULD_BE_USED).verify(); } @Test - public void succeed_whenClassHasAMutablePrimitiveField_givenWarningIsSuppressed() { + void succeed_whenClassHasAMutablePrimitiveField_givenWarningIsSuppressed() { EqualsVerifier.forClass(PrimitiveMutableField.class).suppress(Warning.NONFINAL_FIELDS).verify(); } @Test - public void fail_whenClassHasAMutableObjectField() { + void fail_whenClassHasAMutableObjectField() { ExpectedException .when(() -> EqualsVerifier.forClass(ObjectMutableField.class).verify()) .assertFailure() @@ -42,12 +42,12 @@ public void fail_whenClassHasAMutableObjectField() { } @Test - public void succeed_whenClassHasAMutableObjectField_givenWarningIsSuppressed() { + void succeed_whenClassHasAMutableObjectField_givenWarningIsSuppressed() { EqualsVerifier.forClass(ObjectMutableField.class).suppress(Warning.NONFINAL_FIELDS).verify(); } @Test - public void fail_whenClassHasAMutableEnumField() { + void fail_whenClassHasAMutableEnumField() { ExpectedException .when(() -> EqualsVerifier.forClass(EnumMutableField.class).verify()) .assertFailure() @@ -55,12 +55,12 @@ public void fail_whenClassHasAMutableEnumField() { } @Test - public void succeed_whenClassHasAMutableEnumField_givenWarningIsSuppressed() { + void succeed_whenClassHasAMutableEnumField_givenWarningIsSuppressed() { EqualsVerifier.forClass(EnumMutableField.class).suppress(Warning.NONFINAL_FIELDS).verify(); } @Test - public void fail_whenClassHasAMutableArrayField() { + void fail_whenClassHasAMutableArrayField() { ExpectedException .when(() -> EqualsVerifier.forClass(ArrayMutableField.class).verify()) .assertFailure() @@ -68,7 +68,7 @@ public void fail_whenClassHasAMutableArrayField() { } @Test - public void succeed_whenClassHasAMutableArrayField_givenWarningIsSuppressed() { + void succeed_whenClassHasAMutableArrayField_givenWarningIsSuppressed() { EqualsVerifier.forClass(ArrayMutableField.class).suppress(Warning.NONFINAL_FIELDS).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/NullFieldsTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/NullFieldsTest.java index 2a4b7ffbc..fe52ab393 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/NullFieldsTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/NullFieldsTest.java @@ -9,8 +9,9 @@ import nl.jqno.equalsverifier.testhelpers.types.Color; import org.junit.jupiter.api.Test; -@SuppressWarnings("unused") // because of the use of defaultEquals and defaultHashCode -public class NullFieldsTest { +// because of the use of defaultEquals and defaultHashCode +@SuppressWarnings("unused") +class NullFieldsTest { private static final String NON_NULLITY = "Non-nullity"; private static final String EQUALS = "equals throws NullPointerException"; @@ -19,7 +20,7 @@ public class NullFieldsTest { private static final String ON_THE_OTHER_FIELD = "on the parameter's"; @Test - public void fail_whenEqualsThrowsNpeOnThissField() { + void fail_whenEqualsThrowsNpeOnThissField() { ExpectedException .when(() -> EqualsVerifier.forClass(EqualsThrowsNpeOnThis.class).verify()) .assertFailure() @@ -28,7 +29,7 @@ public void fail_whenEqualsThrowsNpeOnThissField() { } @Test - public void fail_whenEqualsThrowsNpeOnOthersField() { + void fail_whenEqualsThrowsNpeOnOthersField() { ExpectedException .when(() -> EqualsVerifier.forClass(EqualsThrowsNpeOnOther.class).verify()) .assertFailure() @@ -37,7 +38,7 @@ public void fail_whenEqualsThrowsNpeOnOthersField() { } @Test - public void fail_whenEqualsThrowsNpeOnStaticField() { + void fail_whenEqualsThrowsNpeOnStaticField() { ExpectedException .when(() -> EqualsVerifier.forClass(EqualsThrowsNpeOnStatic.class).verify()) .assertFailure() @@ -46,7 +47,7 @@ public void fail_whenEqualsThrowsNpeOnStaticField() { } @Test - public void fail_whenHashCodeThrowsNpe() { + void fail_whenHashCodeThrowsNpe() { ExpectedException .when(() -> EqualsVerifier.forClass(HashCodeThrowsNpe.class).verify()) .assertFailure() @@ -55,32 +56,32 @@ public void fail_whenHashCodeThrowsNpe() { } @Test - public void succeed_whenEqualsThrowsNpeOnThissField_givenWarningIsSuppressed() { + void succeed_whenEqualsThrowsNpeOnThissField_givenWarningIsSuppressed() { EqualsVerifier.forClass(EqualsThrowsNpeOnThis.class).suppress(Warning.NULL_FIELDS).verify(); } @Test - public void succeed_whenEqualsTestFieldWhichThrowsNpe() { + void succeed_whenEqualsTestFieldWhichThrowsNpe() { EqualsVerifier.forClass(CheckedDeepNullA.class).verify(); } @Test - public void succeed_whenEqualsThrowsNpeOnFieldWhichAlsoThrowsNpe_givenWarningIsSuppressed() { + void succeed_whenEqualsThrowsNpeOnFieldWhichAlsoThrowsNpe_givenWarningIsSuppressed() { EqualsVerifier.forClass(DeepNullA.class).suppress(Warning.NULL_FIELDS).verify(); } @Test - public void succeed_whenDoingASanityCheckOnTheFieldUsedInThePreviousTests_givenWarningIsSuppressed() { + void succeed_whenDoingASanityCheckOnTheFieldUsedInThePreviousTests_givenWarningIsSuppressed() { EqualsVerifier.forClass(DeepNullB.class).suppress(Warning.NULL_FIELDS).verify(); } @Test - public void succeed_whenConstantFieldIsNull() { + void succeed_whenConstantFieldIsNull() { EqualsVerifier.forClass(ConstantFieldIsNull.class).verify(); } @Test - public void fail_whenClassHasNullChecksForOnlySomeFields() { + void fail_whenClassHasNullChecksForOnlySomeFields() { ExpectedException .when(() -> EqualsVerifier.forClass(MixedNullFields.class).verify()) .assertFailure() @@ -89,17 +90,17 @@ public void fail_whenClassHasNullChecksForOnlySomeFields() { } @Test - public void succeed_whenClassHasNullChecksForOnlySomeFields_givenWarningIsSuppressed() { + void succeed_whenClassHasNullChecksForOnlySomeFields_givenWarningIsSuppressed() { EqualsVerifier.forClass(MixedNullFields.class).suppress(Warning.NULL_FIELDS).verify(); } @Test - public void succeed_whenClassHasNullChecksForOnlySomeFields_givenTheOtherFieldIsFlagged() { + void succeed_whenClassHasNullChecksForOnlySomeFields_givenTheOtherFieldIsFlagged() { EqualsVerifier.forClass(MixedNullFields.class).withNonnullFields("o").verify(); } @Test - public void anExceptionIsThrown_whenANonExistingFieldIsGivenToWithNonnullFields() { + void anExceptionIsThrown_whenANonExistingFieldIsGivenToWithNonnullFields() { ExpectedException .when(() -> EqualsVerifier.forClass(MixedNullFields.class).withNonnullFields("thisFieldDoesNotExist")) .assertThrows(IllegalStateException.class) @@ -109,7 +110,7 @@ public void anExceptionIsThrown_whenANonExistingFieldIsGivenToWithNonnullFields( } @Test - public void anExceptionIsThrown_whenWithNonnullFieldsOverlapsWithSuppressWarnings() { + void anExceptionIsThrown_whenWithNonnullFieldsOverlapsWithSuppressWarnings() { ExpectedException .when( () -> EqualsVerifier @@ -123,7 +124,7 @@ public void anExceptionIsThrown_whenWithNonnullFieldsOverlapsWithSuppressWarning } @Test - public void anExceptionIsThrown_whenSuppressWarningsOverlapsWithWithNonnullFields() { + void anExceptionIsThrown_whenSuppressWarningsOverlapsWithWithNonnullFields() { ExpectedException .when( () -> EqualsVerifier diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/NullFieldsWithExceptionsTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/NullFieldsWithExceptionsTest.java index d7010a750..c84650c99 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/NullFieldsWithExceptionsTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/NullFieldsWithExceptionsTest.java @@ -9,7 +9,7 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class NullFieldsWithExceptionsTest { +class NullFieldsWithExceptionsTest { private static final String EQUALS = "equals"; private static final String HASH_CODE = "hashCode"; @@ -19,7 +19,7 @@ public class NullFieldsWithExceptionsTest { private static final String WHEN_FOO_IS_NULL = "when field foo is null"; @Test - public void recogniseUnderlyingNpe_whenIllegalArgumentExceptionIsThrownInEquals_givenFieldIsNull() { + void recogniseUnderlyingNpe_whenIllegalArgumentExceptionIsThrownInEquals_givenFieldIsNull() { ExpectedException .when(() -> EqualsVerifier.forClass(EqualsIllegalArgumentThrower.class).verify()) .assertFailure() @@ -28,7 +28,7 @@ public void recogniseUnderlyingNpe_whenIllegalArgumentExceptionIsThrownInEquals_ } @Test - public void recogniseUnderlyingNpe_whenIllegalStateExceptionIsThrownInEquals_givenFieldIsNull() { + void recogniseUnderlyingNpe_whenIllegalStateExceptionIsThrownInEquals_givenFieldIsNull() { ExpectedException .when(() -> EqualsVerifier.forClass(EqualsIllegalStateThrower.class).verify()) .assertFailure() @@ -37,7 +37,7 @@ public void recogniseUnderlyingNpe_whenIllegalStateExceptionIsThrownInEquals_giv } @Test - public void recogniseUnderlyingNpe_whenIllegalArgumentExceptionIsThrownInHashCode_givenFieldIsNull() { + void recogniseUnderlyingNpe_whenIllegalArgumentExceptionIsThrownInHashCode_givenFieldIsNull() { ExpectedException .when(() -> EqualsVerifier.forClass(HashCodeIllegalArgumentThrower.class).verify()) .assertFailure() @@ -46,7 +46,7 @@ public void recogniseUnderlyingNpe_whenIllegalArgumentExceptionIsThrownInHashCod } @Test - public void recogniseUnderlyingNpe_whenIllegalStateExceptionIsThrownInHashCode_givenFieldIsNull() { + void recogniseUnderlyingNpe_whenIllegalStateExceptionIsThrownInHashCode_givenFieldIsNull() { ExpectedException .when(() -> EqualsVerifier.forClass(HashCodeIllegalStateThrower.class).verify()) .assertFailure() diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SignatureTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SignatureTest.java index 3c3cb5f55..c0913f137 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SignatureTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SignatureTest.java @@ -9,40 +9,40 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class SignatureTest { +class SignatureTest { private static final String OVERLOADED = "Overloaded"; private static final String SIGNATURE_SHOULD_BE = "Signature should be"; private static final String SIGNATURE = "public boolean equals(Object obj)"; @Test - public void fail_whenEqualsIsOverloadedWithTypeInsteadOfObject() { + void fail_whenEqualsIsOverloadedWithTypeInsteadOfObject() { expectOverloadFailure( "Parameter should be an Object, not " + OverloadedWithOwnType.class.getSimpleName(), () -> EqualsVerifier.forClass(OverloadedWithOwnType.class).verify()); } @Test - public void fail_whenEqualsIsOverloadedWithTwoParameters() { + void fail_whenEqualsIsOverloadedWithTwoParameters() { expectOverloadFailure( "Too many parameters", () -> EqualsVerifier.forClass(OverloadedWithTwoParameters.class).verify()); } @Test - public void fail_whenEqualsIsOverloadedWithNoParameter() { + void fail_whenEqualsIsOverloadedWithNoParameter() { expectOverloadFailure("No parameter", () -> EqualsVerifier.forClass(OverloadedWithNoParameter.class).verify()); } @Test - public void fail_whenEqualsIsOverloadedWithUnrelatedParameter() { + void fail_whenEqualsIsOverloadedWithUnrelatedParameter() { expectOverloadFailure( "Parameter should be an Object", () -> EqualsVerifier.forClass(OverloadedWithUnrelatedParameter.class).verify()); } @Test - public void fail_whenEqualsIsProperlyOverriddenButAlsoOverloaded() { + void fail_whenEqualsIsProperlyOverriddenButAlsoOverloaded() { expectOverloadFailure( "More than one equals method found", () -> EqualsVerifier @@ -52,7 +52,7 @@ public void fail_whenEqualsIsProperlyOverriddenButAlsoOverloaded() { } @Test - public void succeed_whenEqualsIsNeitherOverriddenOrOverloaded_givenInheritedDirectlyWarningIsSuppressed() { + void succeed_whenEqualsIsNeitherOverriddenOrOverloaded_givenInheritedDirectlyWarningIsSuppressed() { EqualsVerifier .forClass(NoEqualsMethod.class) .suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT, Warning.ALL_FIELDS_SHOULD_BE_USED) @@ -60,7 +60,7 @@ public void succeed_whenEqualsIsNeitherOverriddenOrOverloaded_givenInheritedDire } @Test - public void succeed_whenAStaticEqualsExists() { + void succeed_whenAStaticEqualsExists() { EqualsVerifier.forClass(StaticEqualsMethod.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SignificantFieldsTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SignificantFieldsTest.java index 6e336be2a..107d3b1ad 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SignificantFieldsTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SignificantFieldsTest.java @@ -13,10 +13,10 @@ import nl.jqno.equalsverifier.testhelpers.types.Point; import org.junit.jupiter.api.Test; -public class SignificantFieldsTest { +class SignificantFieldsTest { @Test - public void fail_whenEqualsUsesAFieldAndHashCodeDoesnt() { + void fail_whenEqualsUsesAFieldAndHashCodeDoesnt() { ExpectedException .when(() -> EqualsVerifier.forClass(ExtraFieldInEquals.class).verify()) .assertFailure() @@ -24,12 +24,12 @@ public void fail_whenEqualsUsesAFieldAndHashCodeDoesnt() { } @Test - public void succeed_whenEqualsUsesAFieldAndHashCodeDoesnt_givenStrictHashCodeWarningIsSuppressed() { + void succeed_whenEqualsUsesAFieldAndHashCodeDoesnt_givenStrictHashCodeWarningIsSuppressed() { EqualsVerifier.forClass(ExtraFieldInEquals.class).suppress(Warning.STRICT_HASHCODE).verify(); } @Test - public void fail_whenHashCodeIsConstant() { + void fail_whenHashCodeIsConstant() { ExpectedException .when(() -> EqualsVerifier.forClass(ConstantHashCode.class).verify()) .assertFailure() @@ -37,19 +37,19 @@ public void fail_whenHashCodeIsConstant() { } @Test - public void succeed_whenHashCodeIsConstant_givenStrictHashCodeWarningIsSuppressed() { + void succeed_whenHashCodeIsConstant_givenStrictHashCodeWarningIsSuppressed() { EqualsVerifier.forClass(ConstantHashCode.class).suppress(Warning.STRICT_HASHCODE).verify(); } @Test - public void fail_whenHashCodeUsesAFieldAndEqualsDoesnt() { + void fail_whenHashCodeUsesAFieldAndEqualsDoesnt() { ExpectedException .when(() -> EqualsVerifier.forClass(ExtraFieldInHashCode.class).verify()) .assertMessageContains("Significant fields", "hashCode relies on", "yNotUsed", "but equals does not"); } @Test - public void fail_whenHashCodeUsesAFieldAndEqualsDoesnt_givenStrictHashCodeWarningIsSuppressed() { + void fail_whenHashCodeUsesAFieldAndEqualsDoesnt_givenStrictHashCodeWarningIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -61,17 +61,17 @@ public void fail_whenHashCodeUsesAFieldAndEqualsDoesnt_givenStrictHashCodeWarnin } @Test - public void succeed_whenAllFieldsAreUsed_givenAllFieldsShouldBeUsed() { + void succeed_whenAllFieldsAreUsed_givenAllFieldsShouldBeUsed() { EqualsVerifier.forClass(FinalPoint.class).verify(); } @Test - public void succeed_whenAFieldIsUnused_givenAllFieldsWarningIsSuppressed() { + void succeed_whenAFieldIsUnused_givenAllFieldsWarningIsSuppressed() { EqualsVerifier.forClass(OneFieldUnused.class).suppress(Warning.ALL_FIELDS_SHOULD_BE_USED).verify(); } @Test - public void fail_whenAFieldIsUnused() { + void fail_whenAFieldIsUnused() { ExpectedException .when(() -> EqualsVerifier.forClass(OneFieldUnused.class).verify()) .assertFailure() @@ -79,7 +79,7 @@ public void fail_whenAFieldIsUnused() { } @Test - public void fail_whenANonfinalFieldIsUnused() { + void fail_whenANonfinalFieldIsUnused() { ExpectedException .when(() -> EqualsVerifier.forClass(OneNonfinalFieldUnused.class).verify()) .assertFailure() @@ -87,7 +87,7 @@ public void fail_whenANonfinalFieldIsUnused() { } @Test - public void succeed_whenANonfinalFieldIsUnused_givenAllNonfinalFieldsWarningIsSuppressed() { + void succeed_whenANonfinalFieldIsUnused_givenAllNonfinalFieldsWarningIsSuppressed() { EqualsVerifier .forClass(OneNonfinalFieldUnused.class) .suppress(Warning.ALL_NONFINAL_FIELDS_SHOULD_BE_USED) @@ -95,7 +95,7 @@ public void succeed_whenANonfinalFieldIsUnused_givenAllNonfinalFieldsWarningIsSu } @Test - public void fail_whenAFieldIsUnused_givenOnlyAllNonfinalFieldsWarningIsSuppressed() { + void fail_whenAFieldIsUnused_givenOnlyAllNonfinalFieldsWarningIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -107,22 +107,22 @@ public void fail_whenAFieldIsUnused_givenOnlyAllNonfinalFieldsWarningIsSuppresse } @Test - public void succeed_whenATransientFieldIsUnused_givenAllFieldsShouldBeUsed() { + void succeed_whenATransientFieldIsUnused_givenAllFieldsShouldBeUsed() { EqualsVerifier.forClass(OneTransientFieldUnusedColorPoint.class).verify(); } @Test - public void succeed_whenAStaticFieldIsUnused_givenAllFieldsShouldBeUsed() { + void succeed_whenAStaticFieldIsUnused_givenAllFieldsShouldBeUsed() { EqualsVerifier.forClass(OneStaticFieldUnusedColorPoint.class).verify(); } @Test - public void succeed_whenAFieldIsUnusedInASubclass_givenAllFieldsWarningIsSuppressed() { + void succeed_whenAFieldIsUnusedInASubclass_givenAllFieldsWarningIsSuppressed() { EqualsVerifier.forClass(OneFieldUnusedExtended.class).suppress(Warning.ALL_FIELDS_SHOULD_BE_USED).verify(); } @Test - public void fail_whenAFieldIsUnusedInASubclass() { + void fail_whenAFieldIsUnusedInASubclass() { ExpectedException .when(() -> EqualsVerifier.forClass(OneFieldUnusedExtended.class).verify()) .assertFailure() @@ -130,7 +130,7 @@ public void fail_whenAFieldIsUnusedInASubclass() { } @Test - public void succeed_whenNoEqualsMethodPresent_givenAllFieldsWarningIsSuppressed() { + void succeed_whenNoEqualsMethodPresent_givenAllFieldsWarningIsSuppressed() { EqualsVerifier .forClass(NoFieldsUsed.class) .suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT, Warning.ALL_FIELDS_SHOULD_BE_USED) @@ -138,12 +138,12 @@ public void succeed_whenNoEqualsMethodPresent_givenAllFieldsWarningIsSuppressed( } @Test - public void succeed_whenNoFieldsAreAdded_givenAllFieldsShouldBeUsed() { + void succeed_whenNoFieldsAreAdded_givenAllFieldsShouldBeUsed() { EqualsVerifier.forClass(NoFieldsAdded.class).verify(); } @Test - public void fail_whenNoFieldsAreUsed() { + void fail_whenNoFieldsAreUsed() { ExpectedException .when( () -> EqualsVerifier @@ -155,7 +155,7 @@ public void fail_whenNoFieldsAreUsed() { } @Test - public void fail_whenNoFieldsAreUsed_givenUsingGetClass() { + void fail_whenNoFieldsAreUsed_givenUsingGetClass() { ExpectedException .when( () -> EqualsVerifier @@ -168,12 +168,12 @@ public void fail_whenNoFieldsAreUsed_givenUsingGetClass() { } @Test - public void succeed_whenAFieldIsUnused_givenAllFieldsShouldBeUsedExceptThatField() { + void succeed_whenAFieldIsUnused_givenAllFieldsShouldBeUsedExceptThatField() { EqualsVerifier.forClass(OneFieldUnused.class).withIgnoredFields("colorNotUsed").verify(); } @Test - public void succeed_whenTwoFieldsAreUnused_givenAllFieldsShouldBeUsedExceptThoseTwo() { + void succeed_whenTwoFieldsAreUnused_givenAllFieldsShouldBeUsedExceptThoseTwo() { EqualsVerifier .forClass(TwoFieldsUnusedColorPoint.class) .withIgnoredFields("colorNotUsed", "colorAlsoNotUsed") @@ -181,7 +181,7 @@ public void succeed_whenTwoFieldsAreUnused_givenAllFieldsShouldBeUsedExceptThose } @Test - public void succeed_whenRepeatingWithIgnoredFields_givenAllFieldsShouldBeUsedExceptThoseTwo() { + void succeed_whenRepeatingWithIgnoredFields_givenAllFieldsShouldBeUsedExceptThoseTwo() { EqualsVerifier .forClass(TwoFieldsUnusedColorPoint.class) .withIgnoredFields("colorNotUsed") @@ -190,12 +190,12 @@ public void succeed_whenRepeatingWithIgnoredFields_givenAllFieldsShouldBeUsedExc } @Test - public void succeed_whenRepeatingWithOnlyTheseFields_givenAllFieldsShouldBeUsedExceptThoseTwo() { + void succeed_whenRepeatingWithOnlyTheseFields_givenAllFieldsShouldBeUsedExceptThoseTwo() { EqualsVerifier.forClass(OneFieldUnused.class).withOnlyTheseFields("x").withOnlyTheseFields("y").verify(); } @Test - public void fail_whenCombiningWithOnlyTheseFieldsAndWithIgnoredFields() { + void fail_whenCombiningWithOnlyTheseFieldsAndWithIgnoredFields() { ExpectedException .when( () -> EqualsVerifier @@ -210,7 +210,7 @@ public void fail_whenCombiningWithOnlyTheseFieldsAndWithIgnoredFields() { } @Test - public void fail_whenTwoFieldsAreUnUsed_givenAllFieldsShouldBeUsedExceptOneOfThemButNotBoth() { + void fail_whenTwoFieldsAreUnUsed_givenAllFieldsShouldBeUsedExceptOneOfThemButNotBoth() { ExpectedException .when( () -> EqualsVerifier @@ -222,7 +222,7 @@ public void fail_whenTwoFieldsAreUnUsed_givenAllFieldsShouldBeUsedExceptOneOfThe } @Test - public void fail_whenAllFieldsAreUsed_givenAllFieldsShouldBeUsedExceptOneThatActuallyIsUsed() { + void fail_whenAllFieldsAreUsed_givenAllFieldsShouldBeUsedExceptOneThatActuallyIsUsed() { ExpectedException .when(() -> EqualsVerifier.forClass(FinalPoint.class).withIgnoredFields("x").verify()) .assertFailure() @@ -230,7 +230,7 @@ public void fail_whenAllFieldsAreUsed_givenAllFieldsShouldBeUsedExceptOneThatAct } @Test - public void fail_whenOneFieldIsUnused_givenAllFieldsShouldBeUsedExceptTwoFields() { + void fail_whenOneFieldIsUnused_givenAllFieldsShouldBeUsedExceptTwoFields() { ExpectedException .when( () -> EqualsVerifier.forClass(OneFieldUnused.class).withIgnoredFields("x", "colorNotUsed").verify()) @@ -239,7 +239,7 @@ public void fail_whenOneFieldIsUnused_givenAllFieldsShouldBeUsedExceptTwoFields( } @Test - public void anExceptionIsThrown_whenANonExistingFieldIsExcepted() { + void anExceptionIsThrown_whenANonExistingFieldIsExcepted() { ExpectedException .when(() -> EqualsVerifier.forClass(FinalPoint.class).withIgnoredFields("thisFieldDoesNotExist")) .assertThrows(IllegalStateException.class) @@ -249,12 +249,12 @@ public void anExceptionIsThrown_whenANonExistingFieldIsExcepted() { } @Test - public void succeed_whenAFieldIsUnused_givenTheUsedFieldsAreSpecified() { + void succeed_whenAFieldIsUnused_givenTheUsedFieldsAreSpecified() { EqualsVerifier.forClass(OneFieldUnused.class).withOnlyTheseFields("x", "y").verify(); } @Test - public void fail_whenAllFieldsAreUsed_givenTheUsedFieldsAreSpecifiedButWeMissedOne() { + void fail_whenAllFieldsAreUsed_givenTheUsedFieldsAreSpecifiedButWeMissedOne() { ExpectedException .when(() -> EqualsVerifier.forClass(FinalPoint.class).withOnlyTheseFields("x").verify()) .assertFailure() @@ -262,7 +262,7 @@ public void fail_whenAllFieldsAreUsed_givenTheUsedFieldsAreSpecifiedButWeMissedO } @Test - public void fail_whenAFieldIsUnused_givenTheUnusedFieldIsAlsoSpecified() { + void fail_whenAFieldIsUnused_givenTheUnusedFieldIsAlsoSpecified() { ExpectedException .when( () -> EqualsVerifier @@ -274,7 +274,7 @@ public void fail_whenAFieldIsUnused_givenTheUnusedFieldIsAlsoSpecified() { } @Test - public void anExceptionIsThrown_whenANonExistingFieldIsSpecified() { + void anExceptionIsThrown_whenANonExistingFieldIsSpecified() { ExpectedException .when(() -> EqualsVerifier.forClass(FinalPoint.class).withOnlyTheseFields("thisFieldDoesNotExist")) .assertThrows(IllegalStateException.class) @@ -284,7 +284,7 @@ public void anExceptionIsThrown_whenANonExistingFieldIsSpecified() { } @Test - public void anExceptionIsThrown_whenIgnoredFieldsOverlapWithSpecifiedFields() { + void anExceptionIsThrown_whenIgnoredFieldsOverlapWithSpecifiedFields() { ExpectedException .when(() -> EqualsVerifier.forClass(FinalPoint.class).withOnlyTheseFields("x").withIgnoredFields("x")) .assertThrows(IllegalStateException.class) @@ -294,7 +294,7 @@ public void anExceptionIsThrown_whenIgnoredFieldsOverlapWithSpecifiedFields() { } @Test - public void anExceptionIsThrown_whenSpecifiedFieldsOverlapWithIgnoredFields() { + void anExceptionIsThrown_whenSpecifiedFieldsOverlapWithIgnoredFields() { ExpectedException .when(() -> EqualsVerifier.forClass(FinalPoint.class).withIgnoredFields("x").withOnlyTheseFields("x")) .assertThrows(IllegalStateException.class) @@ -304,7 +304,7 @@ public void anExceptionIsThrown_whenSpecifiedFieldsOverlapWithIgnoredFields() { } @Test - public void succeed_whenAUsedFieldHasUnusedStaticFinalMembers_givenAllFieldsWarningIsSuppressed() { + void succeed_whenAUsedFieldHasUnusedStaticFinalMembers_givenAllFieldsWarningIsSuppressed() { EqualsVerifier .forClass(IndirectStaticFinalContainer.class) .suppress(Warning.ALL_FIELDS_SHOULD_BE_USED) @@ -312,7 +312,7 @@ public void succeed_whenAUsedFieldHasUnusedStaticFinalMembers_givenAllFieldsWarn } @Test - public void fail_whenUnusedFieldIsStateless() { + void fail_whenUnusedFieldIsStateless() { ExpectedException .when(() -> EqualsVerifier.forClass(UnusedStatelessContainer.class).verify()) .assertFailure() @@ -320,12 +320,12 @@ public void fail_whenUnusedFieldIsStateless() { } @Test - public void succeed_whenUnusedFieldIsStateless_givenAllFieldsWarningIsSuppressed() { + void succeed_whenUnusedFieldIsStateless_givenAllFieldsWarningIsSuppressed() { EqualsVerifier.forClass(UnusedStatelessContainer.class).suppress(Warning.ALL_FIELDS_SHOULD_BE_USED).verify(); } @Test - public void fail_whenUsedFieldIsStateless() { + void fail_whenUsedFieldIsStateless() { ExpectedException .when(() -> EqualsVerifier.forClass(UsedStatelessContainer.class).verify()) .assertFailure() @@ -333,22 +333,22 @@ public void fail_whenUsedFieldIsStateless() { } @Test - public void succeed_whenUsedFieldIsStateless_givenAllFieldsWarningIsSuppressed() { + void succeed_whenUsedFieldIsStateless_givenAllFieldsWarningIsSuppressed() { EqualsVerifier.forClass(UsedStatelessContainer.class).suppress(Warning.ALL_FIELDS_SHOULD_BE_USED).verify(); } @Test - public void succeed_whenUsedFieldIsStateless_givenStatelessFieldIsIgnored() { + void succeed_whenUsedFieldIsStateless_givenStatelessFieldIsIgnored() { EqualsVerifier.forClass(UsedStatelessContainer.class).withIgnoredFields("statelessField").verify(); } @Test - public void succeed_whenClassIsStateless_givenAllFieldsWarningIsSuppressed() { + void succeed_whenClassIsStateless_givenAllFieldsWarningIsSuppressed() { EqualsVerifier.forClass(Stateless.class).suppress(Warning.ALL_FIELDS_SHOULD_BE_USED).verify(); } @Test - public void fail_whenNonNullFieldIsEqualToNullField() { + void fail_whenNonNullFieldIsEqualToNullField() { ExpectedException .when(() -> EqualsVerifier.forClass(BugWhenFieldIsNull.class).verify()) .assertFailure() @@ -361,7 +361,7 @@ public void fail_whenNonNullFieldIsEqualToNullField() { } @Test - public void giveCorrectMessage_whenStaticFieldIsNotUsed_givenStaticFieldIsFirstField() { + void giveCorrectMessage_whenStaticFieldIsNotUsed_givenStaticFieldIsFirstField() { // See https://github.com/jqno/equalsverifier/issues/159 ExpectedException .when( diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/StringTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/StringTest.java index c9e79d921..c0756ca7f 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/StringTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/StringTest.java @@ -7,10 +7,10 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class StringTest { +class StringTest { @Test - public void fail_whenStringIsComparedUsingEqualsIgnoreCaseAndHashCodeIsCaseSensitive() { + void fail_whenStringIsComparedUsingEqualsIgnoreCaseAndHashCodeIsCaseSensitive() { ExpectedException .when(() -> EqualsVerifier.forClass(IncorrectIgnoreCaseStringEquals.class).verify()) .assertFailure() @@ -23,12 +23,12 @@ public void fail_whenStringIsComparedUsingEqualsIgnoreCaseAndHashCodeIsCaseSensi } @Test - public void succeed_whenStringIsComparedUsingEqualsIgnoreCaseAndHashCodeIsAlsoCaseInsensitive() { + void succeed_whenStringIsComparedUsingEqualsIgnoreCaseAndHashCodeIsAlsoCaseInsensitive() { EqualsVerifier.forClass(CorrectIgnoreCaseStringEquals.class).verify(); } @Test - public void fail_whenStringIsComparedUsingEqualsIgnoreCaseAndHashCodeIsCaseSensitive_givenHashCodeIsCached() { + void fail_whenStringIsComparedUsingEqualsIgnoreCaseAndHashCodeIsCaseSensitive_givenHashCodeIsCached() { ExpectedException .when( () -> EqualsVerifier diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SyntheticFieldsTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SyntheticFieldsTest.java index 8266a3e50..4ecb3fac4 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SyntheticFieldsTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/SyntheticFieldsTest.java @@ -9,36 +9,37 @@ import nl.jqno.equalsverifier.EqualsVerifier; import org.junit.jupiter.api.Test; -@SuppressWarnings("unused") // because of the use of defaultEquals and defaultHashCode -public class SyntheticFieldsTest { +// because of the use of defaultEquals and defaultHashCode +@SuppressWarnings("unused") +class SyntheticFieldsTest { @Test - public void succeed_whenClassHasASyntheticClassAsAField() { + void succeed_whenClassHasASyntheticClassAsAField() { EqualsVerifier.forClass(LambdaContainer.class).verify(); } @Test - public void succeed_whenClassHasASyntheticFieldBecauseItsInsideAUnitTestClass() { + void succeed_whenClassHasASyntheticFieldBecauseItsInsideAUnitTestClass() { EqualsVerifier.forClass(Outer.class).verify(); } @Test - public void succeed_whenClassHasASyntheticFieldBecauseItsAnInnerClass() { + void succeed_whenClassHasASyntheticFieldBecauseItsAnInnerClass() { EqualsVerifier.forClass(Outer.Inner.class).verify(); } @Test - public void succeed_whenClassHasAFieldThatHasASyntheticField() { + void succeed_whenClassHasAFieldThatHasASyntheticField() { EqualsVerifier.forClass(OuterContainer.class).verify(); } @Test - public void succeed_whenClassIsInstrumentedByCobertura_givenCoberturaDoesntMarkItsFieldsSynthetic() { + void succeed_whenClassIsInstrumentedByCobertura_givenCoberturaDoesntMarkItsFieldsSynthetic() { EqualsVerifier.forClass(CoberturaContainer.class).verify(); } @Test - public void succeed_whenScalacOptionCheckinitIsEnabled_givenScalaDoesntMarkItsFieldsSynthetic() { + void succeed_whenScalacOptionCheckinitIsEnabled_givenScalaDoesntMarkItsFieldsSynthetic() { EqualsVerifier.forClass(ScalaCheckinit.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/TransientFieldsTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/TransientFieldsTest.java index b220d089c..9dc0b4e14 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/TransientFieldsTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/TransientFieldsTest.java @@ -8,15 +8,15 @@ import nl.jqno.equalsverifier.testhelpers.annotations.javax.persistence.Transient; import org.junit.jupiter.api.Test; -public class TransientFieldsTest { +class TransientFieldsTest { @Test - public void succeed_whenFieldsWithTransientModifierAreNotUsedInEquals() { + void succeed_whenFieldsWithTransientModifierAreNotUsedInEquals() { EqualsVerifier.forClass(NotUsingFieldsWithTransientModifier.class).verify(); } @Test - public void fail_whenFieldsWithTransientModifierAreUsedInEquals() { + void fail_whenFieldsWithTransientModifierAreUsedInEquals() { ExpectedException .when(() -> EqualsVerifier.forClass(UsingFieldsWithTransientModifier.class).verify()) .assertFailure() @@ -24,12 +24,12 @@ public void fail_whenFieldsWithTransientModifierAreUsedInEquals() { } @Test - public void succeed_whenFieldsWithTransientModifierAreUsedInEquals_givenWarningsAreSuppressed() { + void succeed_whenFieldsWithTransientModifierAreUsedInEquals_givenWarningsAreSuppressed() { EqualsVerifier.forClass(UsingFieldsWithTransientModifier.class).suppress(Warning.TRANSIENT_FIELDS).verify(); } @Test - public void fail_whenFieldsWithTransientModifierAreUsedInEquals_givenTheyreDeclaredInSuperclass() { + void fail_whenFieldsWithTransientModifierAreUsedInEquals_givenTheyreDeclaredInSuperclass() { ExpectedException .when(() -> EqualsVerifier.forClass(SubclassUsingFieldsWithTransientModifier.class).verify()) .assertFailure() @@ -37,12 +37,12 @@ public void fail_whenFieldsWithTransientModifierAreUsedInEquals_givenTheyreDecla } @Test - public void succeed_whenFieldsWithTransientAnnotationAreNotUsedInEquals() { + void succeed_whenFieldsWithTransientAnnotationAreNotUsedInEquals() { EqualsVerifier.forClass(NotUsingFieldsWithTransientAnnotation.class).verify(); } @Test - public void fail_whenFieldsWithTransientAnnotationAreUsedInEquals() { + void fail_whenFieldsWithTransientAnnotationAreUsedInEquals() { ExpectedException .when(() -> EqualsVerifier.forClass(UsingFieldsWithTransientAnnotation.class).verify()) .assertFailure() @@ -50,12 +50,12 @@ public void fail_whenFieldsWithTransientAnnotationAreUsedInEquals() { } @Test - public void succeed_whenFieldsWithTransientAnnotationAreUsedInEquals_givenWarningsAreSuppressed() { + void succeed_whenFieldsWithTransientAnnotationAreUsedInEquals_givenWarningsAreSuppressed() { EqualsVerifier.forClass(UsingFieldsWithTransientAnnotation.class).suppress(Warning.TRANSIENT_FIELDS).verify(); } @Test - public void fail_whenFieldsWithTransientAnnotationAreUsedInEquals_givenTheyreDeclaredInSuperclass() { + void fail_whenFieldsWithTransientAnnotationAreUsedInEquals_givenTheyreDeclaredInSuperclass() { ExpectedException .when(() -> EqualsVerifier.forClass(SubclassUsingFieldsWithTransientAnnotation.class).verify()) .assertFailure() @@ -63,7 +63,7 @@ public void fail_whenFieldsWithTransientAnnotationAreUsedInEquals_givenTheyreDec } @Test - public void fail_whenFieldsWithTransientAnnotationAreNotUsedInEquals_givenAnnotationIsNotAJpaAnnotation() { + void fail_whenFieldsWithTransientAnnotationAreNotUsedInEquals_givenAnnotationIsNotAJpaAnnotation() { ExpectedException .when(() -> EqualsVerifier.forClass(NotUsingFieldsWithNonJpaTransientAnnotation.class).verify()) .assertFailure() diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/TypeCheckTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/TypeCheckTest.java index 38abf68c9..1e1c5a1c9 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/TypeCheckTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/TypeCheckTest.java @@ -4,10 +4,10 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class TypeCheckTest { +class TypeCheckTest { @Test - public void fail_whenEqualsReturnsTrueForACompletelyUnrelatedType() { + void fail_whenEqualsReturnsTrueForACompletelyUnrelatedType() { ExpectedException .when(() -> EqualsVerifier.forClass(WrongTypeCheck.class).verify()) .assertFailure() @@ -15,7 +15,7 @@ public void fail_whenEqualsReturnsTrueForACompletelyUnrelatedType() { } @Test - public void fail_whenEqualsDoesNotTypeCheck() { + void fail_whenEqualsDoesNotTypeCheck() { ExpectedException .when(() -> EqualsVerifier.forClass(NoTypeCheck.class).verify()) .assertFailure() @@ -24,7 +24,7 @@ public void fail_whenEqualsDoesNotTypeCheck() { } @Test - public void fail_whenEqualsDoesNotTypeCheckAndThrowsAnExceptionOtherThanClassCastException() { + void fail_whenEqualsDoesNotTypeCheckAndThrowsAnExceptionOtherThanClassCastException() { ExpectedException .when(() -> EqualsVerifier.forClass(NoTypeCheckButNoClassCastExceptionEither.class).verify()) .assertFailure() diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationImmutableTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationImmutableTest.java index fe4a44e79..af54a8b8e 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationImmutableTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationImmutableTest.java @@ -10,15 +10,15 @@ import nl.jqno.equalsverifier.testhelpers.types.MutableCanEqualColorPoint; import org.junit.jupiter.api.Test; -public class AnnotationImmutableTest { +class AnnotationImmutableTest { @Test - public void succeed_whenClassHasNonfinalFields_givenImmutableAnnotation() { + void succeed_whenClassHasNonfinalFields_givenImmutableAnnotation() { EqualsVerifier.forClass(ImmutableByAnnotation.class).verify(); } @Test - public void succeed_whenRedefinableClassHasNonfinalFields_givenImmutableAnnotationAndAppropriateSubclass() { + void succeed_whenRedefinableClassHasNonfinalFields_givenImmutableAnnotationAndAppropriateSubclass() { EqualsVerifier .forClass(ImmutableCanEqualPoint.class) .withRedefinedSubclass(MutableCanEqualColorPoint.class) @@ -26,7 +26,7 @@ public void succeed_whenRedefinableClassHasNonfinalFields_givenImmutableAnnotati } @Test - public void fail_whenSuperclassHasImmutableAnnotationButThisClassDoesnt() { + void fail_whenSuperclassHasImmutableAnnotationButThisClassDoesnt() { ExpectedException .when(() -> EqualsVerifier.forClass(MutableCanEqualColorPoint.class).withRedefinedSuperclass().verify()) .assertFailure() diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNonNullFieldsTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNonNullFieldsTest.java index e2e4e224d..9d0894760 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNonNullFieldsTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNonNullFieldsTest.java @@ -4,10 +4,10 @@ import nl.jqno.equalsverifier.integration.extra_features.nonnull.springframework.NonNullFieldsOnPackage; import org.junit.jupiter.api.Test; -public class AnnotationNonNullFieldsTest { +class AnnotationNonNullFieldsTest { @Test - public void succeed_whenEqualsDoesntCheckForNull_givenNonNullFieldsAnnotationOnPackage() { + void succeed_whenEqualsDoesntCheckForNull_givenNonNullFieldsAnnotationOnPackage() { EqualsVerifier.forClass(NonNullFieldsOnPackage.class).verify(); } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNonnullEclipseTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNonnullEclipseTest.java index 68aa4b001..74702a7a8 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNonnullEclipseTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNonnullEclipseTest.java @@ -12,35 +12,35 @@ import org.eclipse.jdt.annotation.Nullable; import org.junit.jupiter.api.Test; -public class AnnotationNonnullEclipseTest { +class AnnotationNonnullEclipseTest { @Test - public void succeed_whenEqualsDoesntCheckForNull_givenEclipseAnnotationOnFieldType() { + void succeed_whenEqualsDoesntCheckForNull_givenEclipseAnnotationOnFieldType() { EqualsVerifier.forClass(NonnullTypeUse.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnClass() { + void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnClass() { EqualsVerifier.forClass(NonnullEclipseOnClass.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnPackage() { + void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnPackage() { EqualsVerifier.forClass(NonnullEclipseOnPackage.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnOuterClass() { + void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnOuterClass() { EqualsVerifier.forClass(NonnullEclipseOuter.FInner.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnNestedOuterClass() { + void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnNestedOuterClass() { EqualsVerifier.forClass(NonnullEclipseOuter.FMiddle.FInnerInner.class).verify(); } @Test - public void fail_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableAnnotationOnClass() { + void fail_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableAnnotationOnClass() { ExpectedException .when(() -> EqualsVerifier.forClass(NonnullEclipseWithNullableOnClass.class).verify()) .assertFailure() @@ -48,17 +48,17 @@ public void fail_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableAnno } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableAnnotationOnClassAndWarningSuppressed() { + void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableAnnotationOnClassAndWarningSuppressed() { EqualsVerifier.forClass(NonnullEclipseWithNullableOnClass.class).suppress(Warning.NULL_FIELDS).verify(); } @Test - public void succeed_whenEqualsChecksForNull_givenEclipseDefaultAndNullableAnnotationOnClass() { + void succeed_whenEqualsChecksForNull_givenEclipseDefaultAndNullableAnnotationOnClass() { EqualsVerifier.forClass(NonnullEclipseWithNullableOnClassAndNullCheckInEquals.class).verify(); } @Test - public void fail_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableAnnotationOnPackage() { + void fail_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableAnnotationOnPackage() { ExpectedException .when( () -> EqualsVerifier @@ -69,7 +69,7 @@ public void fail_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableAnno } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableAnnotationOnPackageAndWarningIsSuppressed() { + void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableAnnotationOnPackageAndWarningIsSuppressed() { EqualsVerifier .forClass(NonnullEclipseWithNullableOnPackageAndNullCheckInEquals.class) .suppress(Warning.NULL_FIELDS) @@ -77,7 +77,7 @@ public void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableA } @Test - public void fail_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationButInapplicableLocationOnClass() { + void fail_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationButInapplicableLocationOnClass() { ExpectedException .when(() -> EqualsVerifier.forClass(NonnullEclipseWithInapplicableLocationOnClass.class).verify()) .assertFailure() @@ -85,7 +85,7 @@ public void fail_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationButIn } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationWithApplicableLocationOnClass() { + void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationWithApplicableLocationOnClass() { EqualsVerifier.forClass(NonnullEclipseWithApplicableLocationOnClass.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNonnullTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNonnullTest.java index f0b9d04da..95de757ae 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNonnullTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNonnullTest.java @@ -21,15 +21,15 @@ import nl.jqno.equalsverifier.testhelpers.annotations.*; import org.junit.jupiter.api.Test; -public class AnnotationNonnullTest { +class AnnotationNonnullTest { @Test - public void succeed_whenEqualsDoesntCheckForNull_givenFieldsHaveNonnullAnnotation() { + void succeed_whenEqualsDoesntCheckForNull_givenFieldsHaveNonnullAnnotation() { EqualsVerifier.forClass(NonnullManual.class).verify(); } @Test - public void fail_whenEqualsDoesntCheckForNull_givenFieldsHaveNonnullAnnotationButOneDoesnt() { + void fail_whenEqualsDoesntCheckForNull_givenFieldsHaveNonnullAnnotationButOneDoesnt() { ExpectedException .when(() -> EqualsVerifier.forClass(NonnullManualMissedOne.class).verify()) .assertFailure() @@ -41,22 +41,22 @@ public void fail_whenEqualsDoesntCheckForNull_givenFieldsHaveNonnullAnnotationBu } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenFieldsHaveNonnullAnnotationInSuperclass() { + void succeed_whenEqualsDoesntCheckForNull_givenFieldsHaveNonnullAnnotationInSuperclass() { EqualsVerifier.forClass(SubclassNonnullManual.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationWithJavaxNonnullAnnotationOnClass() { + void succeed_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationWithJavaxNonnullAnnotationOnClass() { EqualsVerifier.forClass(NonnullFindbugs1xJavaxOnClass.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationWithCustomNonnullAnnotationOnClass() { + void succeed_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationWithCustomNonnullAnnotationOnClass() { EqualsVerifier.forClass(NonnullFindbugs1xCustomOnClass.class).verify(); } @Test - public void fail_whenEqualsDoesntCheckForNull_givenEmptyFindbugs1xDefaultAnnotationOnClass() { + void fail_whenEqualsDoesntCheckForNull_givenEmptyFindbugs1xDefaultAnnotationOnClass() { ExpectedException .when(() -> EqualsVerifier.forClass(EmptyFindbugs1xCustomOnClass.class).verify()) .assertFailure() @@ -64,7 +64,7 @@ public void fail_whenEqualsDoesntCheckForNull_givenEmptyFindbugs1xDefaultAnnotat } @Test - public void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationWithoutNonnullAnnotationOnClass() { + void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationWithoutNonnullAnnotationOnClass() { ExpectedException .when(() -> EqualsVerifier.forClass(NotNonnullFindbugs1xCustomOnClass.class).verify()) .assertFailure() @@ -72,22 +72,22 @@ public void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationWi } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationWithJavaxNonnullAnnotationOnPackage() { + void succeed_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationWithJavaxNonnullAnnotationOnPackage() { EqualsVerifier.forClass(NonnullFindbugs1xJavaxOnPackage.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationWithCustomNonnullAnnotationOnPackage() { + void succeed_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationWithCustomNonnullAnnotationOnPackage() { EqualsVerifier.forClass(NonnullFindbugs1xCustomOnPackage.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationForFields() { + void succeed_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationForFields() { EqualsVerifier.forClass(NonnullFindbugs1xForFields.class).verify(); } @Test - public void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationForParameters() { + void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationForParameters() { ExpectedException .when(() -> EqualsVerifier.forClass(NonnullFindbugs1xForParameters.class).verify()) .assertFailure() @@ -95,17 +95,17 @@ public void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationFo } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationOnOuterClass() { + void succeed_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationOnOuterClass() { EqualsVerifier.forClass(NonnullFindbugs1xOuter.FInner.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationOnNestedOuterClass() { + void succeed_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAnnotationOnNestedOuterClass() { EqualsVerifier.forClass(NonnullFindbugs1xOuter.FMiddle.FInnerInner.class).verify(); } @Test - public void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAndNullableAnnotationOnClass() { + void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAndNullableAnnotationOnClass() { ExpectedException .when(() -> EqualsVerifier.forClass(NonnullFindbugs1xWithNullableOnClass.class).verify()) .assertFailure() @@ -113,7 +113,7 @@ public void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAndNullableA } @Test - public void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAndCheckForNullAnnotationOnClass() { + void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAndCheckForNullAnnotationOnClass() { ExpectedException .when(() -> EqualsVerifier.forClass(NonnullFindbugs1xWithCheckForNullOnClass.class).verify()) .assertFailure() @@ -121,7 +121,7 @@ public void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAndCheckForN } @Test - public void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAndNullableAnnotationOnPackage() { + void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAndNullableAnnotationOnPackage() { ExpectedException .when(() -> EqualsVerifier.forClass(NonnullFindbugs1xWithNullableOnPackage.class).verify()) .assertFailure() @@ -129,7 +129,7 @@ public void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAndNullableA } @Test - public void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAndCheckForNullAnnotationOnPackage() { + void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAndCheckForNullAnnotationOnPackage() { ExpectedException .when(() -> EqualsVerifier.forClass(NonnullFindbugs1xWithCheckForNullOnPackage.class).verify()) .assertFailure() @@ -137,7 +137,7 @@ public void fail_whenEqualsDoesntCheckForNull_givenFindbugs1xDefaultAndCheckForN } @Test - public void succeed_whenEqualsDoenstCheckForNull_givenJsr305DefaultAndCheckForNullOnPackageAndWarningSuppressed() { + void succeed_whenEqualsDoenstCheckForNull_givenJsr305DefaultAndCheckForNullOnPackageAndWarningSuppressed() { EqualsVerifier .forClass(NonnullFindbugs1xWithCheckForNullOnPackage.class) .suppress(Warning.NULL_FIELDS) @@ -145,22 +145,22 @@ public void succeed_whenEqualsDoenstCheckForNull_givenJsr305DefaultAndCheckForNu } @Test - public void succeed_whenEqualsChecksForNull_givenJsr305DefaultAndNullableAnnotationOnClass() { + void succeed_whenEqualsChecksForNull_givenJsr305DefaultAndNullableAnnotationOnClass() { EqualsVerifier.forClass(NonnullFindbugs1xWithNullableOnClassAndNullCheckInEquals.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationWithJavaxNonnullAnnotationOnClass() { + void succeed_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationWithJavaxNonnullAnnotationOnClass() { EqualsVerifier.forClass(NonnullJsr305JavaxOnClass.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationWithCustomNonnullAnnotationOnClass() { + void succeed_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationWithCustomNonnullAnnotationOnClass() { EqualsVerifier.forClass(NonnullJsr305CustomOnClass.class).verify(); } @Test - public void fail_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationWithInapplicableTypeQualifierDefaultOnClass() { + void fail_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationWithInapplicableTypeQualifierDefaultOnClass() { ExpectedException .when(() -> EqualsVerifier.forClass(NonnullJsr305InapplicableOnClass.class).verify()) .assertFailure() @@ -168,17 +168,17 @@ public void fail_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationWithIn } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationWithJavaxNonnullAnnotationOnPackage() { + void succeed_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationWithJavaxNonnullAnnotationOnPackage() { EqualsVerifier.forClass(NonnullJsr305JavaxOnPackage.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationWithCustomNonnullAnnotationOnPackage() { + void succeed_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationWithCustomNonnullAnnotationOnPackage() { EqualsVerifier.forClass(NonnullJsr305CustomOnPackage.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationWithInapplicableTypeQualifierDefaultOnPackage() { + void succeed_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationWithInapplicableTypeQualifierDefaultOnPackage() { ExpectedException .when(() -> EqualsVerifier.forClass(NonnullJsr305InapplicableOnPackage.class).verify()) .assertFailure() @@ -186,7 +186,7 @@ public void succeed_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationWit } @Test - public void fail_whenEqualsDoesntCheckForNull_givenJsr305DefaultAndNullableAnnotationOnClass() { + void fail_whenEqualsDoesntCheckForNull_givenJsr305DefaultAndNullableAnnotationOnClass() { ExpectedException .when(() -> EqualsVerifier.forClass(NonnullJsr305WithNullableOnClass.class).verify()) .assertFailure() @@ -194,17 +194,17 @@ public void fail_whenEqualsDoesntCheckForNull_givenJsr305DefaultAndNullableAnnot } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationOnOuterClass() { + void succeed_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationOnOuterClass() { EqualsVerifier.forClass(NonnullJsr305Outer.JInner.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationOnNestedOuterClass() { + void succeed_whenEqualsDoesntCheckForNull_givenJsr305DefaultAnnotationOnNestedOuterClass() { EqualsVerifier.forClass(NonnullJsr305Outer.JMiddle.JInnerInner.class).verify(); } @Test - public void fail_whenEqualsDoesntCheckForNull_givenJsr305DefaultAndCheckForNullAnnotationOnClass() { + void fail_whenEqualsDoesntCheckForNull_givenJsr305DefaultAndCheckForNullAnnotationOnClass() { ExpectedException .when(() -> EqualsVerifier.forClass(NonnullJsr305WithCheckForNullOnClass.class).verify()) .assertFailure() @@ -212,7 +212,7 @@ public void fail_whenEqualsDoesntCheckForNull_givenJsr305DefaultAndCheckForNullA } @Test - public void fail_whenEqualsDoesntCheckForNull_givenJsr305DefaultAndNullableAnnotationOnPackage() { + void fail_whenEqualsDoesntCheckForNull_givenJsr305DefaultAndNullableAnnotationOnPackage() { ExpectedException .when(() -> EqualsVerifier.forClass(NonnullJsr305WithNullableOnPackage.class).verify()) .assertFailure() @@ -220,7 +220,7 @@ public void fail_whenEqualsDoesntCheckForNull_givenJsr305DefaultAndNullableAnnot } @Test - public void fail_whenEqualsDoesntCheckForNull_givenJsr305DefaultAndCheckForNullAnnotationOnPackage() { + void fail_whenEqualsDoesntCheckForNull_givenJsr305DefaultAndCheckForNullAnnotationOnPackage() { ExpectedException .when(() -> EqualsVerifier.forClass(NonnullJsr305WithCheckForNullOnPackage.class).verify()) .assertFailure() @@ -228,12 +228,12 @@ public void fail_whenEqualsDoesntCheckForNull_givenJsr305DefaultAndCheckForNullA } @Test - public void succeed_whenEqualsDoenstCheckForNull_givenJsr305DefaultAndNullableOnPackageAndWarningSuppressed() { + void succeed_whenEqualsDoenstCheckForNull_givenJsr305DefaultAndNullableOnPackageAndWarningSuppressed() { EqualsVerifier.forClass(NonnullJsr305WithNullableOnPackage.class).suppress(Warning.NULL_FIELDS).verify(); } @Test - public void succeed_whenEqualsChecksForNull_givenJsr305DefaultAndCheckForNullAnnotationOnClass() { + void succeed_whenEqualsChecksForNull_givenJsr305DefaultAndCheckForNullAnnotationOnClass() { EqualsVerifier.forClass(NonnullJsr305WithCheckForNullOnClassAndNullCheckInEquals.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNullMarkedTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNullMarkedTest.java index e9e3b0670..63c8515ff 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNullMarkedTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationNullMarkedTest.java @@ -10,30 +10,30 @@ import nl.jqno.equalsverifier.testhelpers.annotations.org.jspecify.annotations.Nullable; import org.junit.jupiter.api.Test; -public class AnnotationNullMarkedTest { +class AnnotationNullMarkedTest { @Test - public void succeed_whenEqualsDoesntCheckForNull_givenNullMarkedAnnotationOnClass() { + void succeed_whenEqualsDoesntCheckForNull_givenNullMarkedAnnotationOnClass() { EqualsVerifier.forClass(NullMarkedOnClass.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenNullMarkedAnnotationOnPackage() { + void succeed_whenEqualsDoesntCheckForNull_givenNullMarkedAnnotationOnPackage() { EqualsVerifier.forClass(NullMarkedOnPackage.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenNullMarkedAnnotationOnOuterClass() { + void succeed_whenEqualsDoesntCheckForNull_givenNullMarkedAnnotationOnOuterClass() { EqualsVerifier.forClass(NullMarkedOuter.FInner.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenNullMarkedAnnotationOnNestedOuterClass() { + void succeed_whenEqualsDoesntCheckForNull_givenNullMarkedAnnotationOnNestedOuterClass() { EqualsVerifier.forClass(NullMarkedOuter.FMiddle.FInnerInner.class).verify(); } @Test - public void fail_whenEqualsDoesntCheckForNull_givenNullMarkedAndNullableAnnotationOnClass() { + void fail_whenEqualsDoesntCheckForNull_givenNullMarkedAndNullableAnnotationOnClass() { ExpectedException .when(() -> EqualsVerifier.forClass(NullMarkedWithNullableOnClass.class).verify()) .assertFailure() @@ -41,12 +41,12 @@ public void fail_whenEqualsDoesntCheckForNull_givenNullMarkedAndNullableAnnotati } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenNullMarkedAndNullableAnnotationOnClassAndWarningSuppressed() { + void succeed_whenEqualsDoesntCheckForNull_givenNullMarkedAndNullableAnnotationOnClassAndWarningSuppressed() { EqualsVerifier.forClass(NullMarkedWithNullableOnClass.class).suppress(Warning.NULL_FIELDS).verify(); } @Test - public void succeed_whenEqualsChecksForNull_givenNullMarkedAndNullableAnnotationOnClass() { + void succeed_whenEqualsChecksForNull_givenNullMarkedAndNullableAnnotationOnClass() { EqualsVerifier.forClass(NullMarkedWithNullableOnClassAndNullCheckInEquals.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationParametersAreNonnullByDefaultTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationParametersAreNonnullByDefaultTest.java index 65c8f535c..d5f700b2c 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationParametersAreNonnullByDefaultTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationParametersAreNonnullByDefaultTest.java @@ -10,30 +10,30 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class AnnotationParametersAreNonnullByDefaultTest { +class AnnotationParametersAreNonnullByDefaultTest { @Test - public void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnClass() { + void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnClass() { EqualsVerifier.forClass(ParametersAreNonnullByDefaultOnClass.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnPackage() { + void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnPackage() { EqualsVerifier.forClass(ParametersAreNonnullByDefaultOnPackage.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnOuterClass() { + void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnOuterClass() { EqualsVerifier.forClass(ParametersAreNonnullByDefaultOuter.FInner.class).verify(); } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnNestedOuterClass() { + void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAnnotationOnNestedOuterClass() { EqualsVerifier.forClass(ParametersAreNonnullByDefaultOuter.FMiddle.FInnerInner.class).verify(); } @Test - public void fail_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableAnnotationOnClass() { + void fail_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableAnnotationOnClass() { ExpectedException .when(() -> EqualsVerifier.forClass(ParametersAreNonnullByDefaultWithNullableOnClass.class).verify()) .assertFailure() @@ -41,7 +41,7 @@ public void fail_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableAnno } @Test - public void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableAnnotationOnClassAndWarningSuppressed() { + void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableAnnotationOnClassAndWarningSuppressed() { EqualsVerifier .forClass(ParametersAreNonnullByDefaultWithNullableOnClass.class) .suppress(Warning.NULL_FIELDS) @@ -49,7 +49,7 @@ public void succeed_whenEqualsDoesntCheckForNull_givenEclipseDefaultAndNullableA } @Test - public void succeed_whenEqualsChecksForNull_givenEclipseDefaultAndNullableAnnotationOnClass() { + void succeed_whenEqualsChecksForNull_givenEclipseDefaultAndNullableAnnotationOnClass() { EqualsVerifier.forClass(ParamsNonnullByDefaultWithNullableOnClassAndNullCheckInEquals.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationsIgnoreTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationsIgnoreTest.java index 591c1830f..24d6621df 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationsIgnoreTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/AnnotationsIgnoreTest.java @@ -11,10 +11,10 @@ import nl.jqno.equalsverifier.testhelpers.annotations.javax.annotation.Nonnull; import org.junit.jupiter.api.Test; -public class AnnotationsIgnoreTest { +class AnnotationsIgnoreTest { @Test - public void fail_whenClassHasNonfinalFieldsAndImmutableAnnotation_givenImmutableAnnotationIsIgnored() { + void fail_whenClassHasNonfinalFieldsAndImmutableAnnotation_givenImmutableAnnotationIsIgnored() { ExpectedException .when( () -> EqualsVerifier @@ -26,7 +26,7 @@ public void fail_whenClassHasNonfinalFieldsAndImmutableAnnotation_givenImmutable } @Test - public void fail_whenIgnoringNonnullAnnotation_givenNonnullIsIndirectlyAppliedThroughDefaultAnnotation() { + void fail_whenIgnoringNonnullAnnotation_givenNonnullIsIndirectlyAppliedThroughDefaultAnnotation() { ExpectedException .when( () -> EqualsVerifier @@ -38,7 +38,7 @@ public void fail_whenIgnoringNonnullAnnotation_givenNonnullIsIndirectlyAppliedTh } @Test - public void fail_whenIgnoringNonnullAnnotation_givenNonnullIsIndirectlyAppliedThroughJsr305() { + void fail_whenIgnoringNonnullAnnotation_givenNonnullIsIndirectlyAppliedThroughJsr305() { ExpectedException .when(() -> EqualsVerifier.forClass(Jsr305Nonnull.class).withIgnoredAnnotations(Nonnull.class).verify()) .assertFailure() @@ -46,7 +46,7 @@ public void fail_whenIgnoringNonnullAnnotation_givenNonnullIsIndirectlyAppliedTh } @Test - public void succeed_whenClassHasNonfinalFieldsAndImmutableAnnotation_givenImmutableAnnotationIsIgnored_butItsADifferentImmutableAnnotation() { + void succeed_whenClassHasNonfinalFieldsAndImmutableAnnotation_givenImmutableAnnotationIsIgnored_butItsADifferentImmutableAnnotation() { EqualsVerifier .forClass(ImmutableByAnnotation.class) .withIgnoredAnnotations(net.jcip.annotations.Immutable.class) @@ -54,7 +54,7 @@ public void succeed_whenClassHasNonfinalFieldsAndImmutableAnnotation_givenImmuta } @Test - public void fail_whenIgnoredAnnotationClassIsntAnAnnotation() { + void fail_whenIgnoredAnnotationClassIsntAnAnnotation() { ExpectedException .when(() -> EqualsVerifier.forClass(ImmutableByAnnotation.class).withIgnoredAnnotations(String.class)) .assertThrows(IllegalStateException.class) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/CachedHashCodeTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/CachedHashCodeTest.java index 8ad09ce75..d751e4989 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/CachedHashCodeTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/CachedHashCodeTest.java @@ -7,7 +7,7 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class CachedHashCodeTest { +class CachedHashCodeTest { private static final String SOME_NAME = "some name"; private static final String CACHED_HASHCODE = "Cached hashCode:"; @@ -17,7 +17,7 @@ public class CachedHashCodeTest { "Could not find cachedHashCodeField: must be 'private int"; @Test - public void fail_whenCachedHashCodeIsValid_givenWithCachedHashCodeIsNotUsed() { + void fail_whenCachedHashCodeIsValid_givenWithCachedHashCodeIsNotUsed() { ExpectedException .when(() -> EqualsVerifier.forClass(ObjectWithValidCachedHashCode.class).verify()) .assertFailure() @@ -25,7 +25,7 @@ public void fail_whenCachedHashCodeIsValid_givenWithCachedHashCodeIsNotUsed() { } @Test - public void succeed_whenCachedHashCodeIsValid_givenWithCachedHashCodeIsUsed() { + void succeed_whenCachedHashCodeIsValid_givenWithCachedHashCodeIsUsed() { EqualsVerifier .forClass(ObjectWithValidCachedHashCode.class) .withCachedHashCode("cachedHashCode", "calcHashCode", new ObjectWithValidCachedHashCode(SOME_NAME)) @@ -33,7 +33,7 @@ public void succeed_whenCachedHashCodeIsValid_givenWithCachedHashCodeIsUsed() { } @Test - public void succeed_whenCachedHashCodeIsValidAndLocatedInSuperclass_givenWithCachedHashCodeIsUsed() { + void succeed_whenCachedHashCodeIsValidAndLocatedInSuperclass_givenWithCachedHashCodeIsUsed() { EqualsVerifier .forClass(Subclass.class) .withCachedHashCode("cachedHashCode", "calcHashCode", new Subclass(SOME_NAME)) @@ -41,7 +41,7 @@ public void succeed_whenCachedHashCodeIsValidAndLocatedInSuperclass_givenWithCac } @Test - public void fail_whenCachedHashCodeIsInvalid_givenWithCachedHashCodeIsUsed() { + void fail_whenCachedHashCodeIsInvalid_givenWithCachedHashCodeIsUsed() { ExpectedException .when( () -> EqualsVerifier @@ -56,7 +56,7 @@ public void fail_whenCachedHashCodeIsInvalid_givenWithCachedHashCodeIsUsed() { } @Test - public void fail_whenCachedHashCodeFieldDoesNotExist() { + void fail_whenCachedHashCodeFieldDoesNotExist() { ExpectedException .when( () -> EqualsVerifier @@ -70,7 +70,7 @@ public void fail_whenCachedHashCodeFieldDoesNotExist() { } @Test - public void fail_whenCachedHashCodeFieldIsPublic() { + void fail_whenCachedHashCodeFieldIsPublic() { ExpectedException .when( () -> EqualsVerifier @@ -84,7 +84,7 @@ public void fail_whenCachedHashCodeFieldIsPublic() { } @Test - public void fail_whenCachedHashCodeFieldIsNotAnInt() { + void fail_whenCachedHashCodeFieldIsNotAnInt() { ExpectedException .when( () -> EqualsVerifier @@ -98,7 +98,7 @@ public void fail_whenCachedHashCodeFieldIsNotAnInt() { } @Test - public void fail_whenCalculateHashCodeMethodDoesNotExist() { + void fail_whenCalculateHashCodeMethodDoesNotExist() { ExpectedException .when( () -> EqualsVerifier @@ -112,7 +112,7 @@ public void fail_whenCalculateHashCodeMethodDoesNotExist() { } @Test - public void fail_whenCalculateHashCodeMethodDoesNotReturnInt() { + void fail_whenCalculateHashCodeMethodDoesNotReturnInt() { ExpectedException .when( () -> EqualsVerifier @@ -126,7 +126,7 @@ public void fail_whenCalculateHashCodeMethodDoesNotReturnInt() { } @Test - public void fail_whenCalculateHashCodeMethodTakesParamters() { + void fail_whenCalculateHashCodeMethodTakesParamters() { ExpectedException .when( () -> EqualsVerifier @@ -140,7 +140,7 @@ public void fail_whenCalculateHashCodeMethodTakesParamters() { } @Test - public void fail_whenCalculateHashCodeMethodIsPublic() { + void fail_whenCalculateHashCodeMethodIsPublic() { ExpectedException .when( () -> EqualsVerifier @@ -154,7 +154,7 @@ public void fail_whenCalculateHashCodeMethodIsPublic() { } @Test - public void succeed_whenCalculateHashCodeMethodAndCalcHashCodeFieldAreProtected() { + void succeed_whenCalculateHashCodeMethodAndCalcHashCodeFieldAreProtected() { EqualsVerifier .forClass(ObjectWithProtectedCalculateHashCodeMembers.class) .withCachedHashCode( @@ -165,7 +165,7 @@ public void succeed_whenCalculateHashCodeMethodAndCalcHashCodeFieldAreProtected( } @Test - public void succeed_whenCalculateHashCodeMethodAndCalcHashCodeFieldHaveDefaultVisibility() { + void succeed_whenCalculateHashCodeMethodAndCalcHashCodeFieldHaveDefaultVisibility() { EqualsVerifier .forClass(ObjectWithDefaultVisibilityCalculateHashCodeMembers.class) .withCachedHashCode( @@ -176,7 +176,7 @@ public void succeed_whenCalculateHashCodeMethodAndCalcHashCodeFieldHaveDefaultVi } @Test - public void fail_whenExampleIsNull() { + void fail_whenExampleIsNull() { ExpectedException .when( () -> EqualsVerifier @@ -188,7 +188,7 @@ public void fail_whenExampleIsNull() { } @Test - public void fail_whenCachedHashCodeFieldIsNotInitialized() { + void fail_whenCachedHashCodeFieldIsNotInitialized() { ExpectedException .when( () -> EqualsVerifier @@ -203,7 +203,7 @@ public void fail_whenCachedHashCodeFieldIsNotInitialized() { } @Test - public void fail_whenHashCodeIsZero() { + void fail_whenHashCodeIsZero() { ExpectedException .when( () -> EqualsVerifier @@ -220,7 +220,7 @@ public void fail_whenHashCodeIsZero() { } @Test - public void succeed_whenCachedHashCodeFieldIsNotInitialized_givenExampleIsNullAndNoExampleForCachedHashCodeIsSuppressed() { + void succeed_whenCachedHashCodeFieldIsNotInitialized_givenExampleIsNullAndNoExampleForCachedHashCodeIsSuppressed() { EqualsVerifier .forClass(ObjectWithUninitializedCachedHashCode.class) .withCachedHashCode("cachedHashCode", "calcHashCode", null) @@ -229,7 +229,7 @@ public void succeed_whenCachedHashCodeFieldIsNotInitialized_givenExampleIsNullAn } @Test - public void fail_whenNoExampleForCachedHashCodeIsSuppressedAndExampleIsNotNull() { + void fail_whenNoExampleForCachedHashCodeIsSuppressedAndExampleIsNotNull() { ExpectedException .when( () -> EqualsVerifier @@ -247,7 +247,7 @@ public void fail_whenNoExampleForCachedHashCodeIsSuppressedAndExampleIsNotNull() } @Test - public void fail_whenCachedHashCodeIsValid_givenWithCachedHashCodeIsUsedAndWarningNonfinalFieldsIsSuppressed() { + void fail_whenCachedHashCodeIsValid_givenWithCachedHashCodeIsUsedAndWarningNonfinalFieldsIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -265,7 +265,7 @@ public void fail_whenCachedHashCodeIsValid_givenWithCachedHashCodeIsUsedAndWarni } @Test - public void succeed_whenCachedHashCodeIsLazilyInitialized_givenItIsValid() { + void succeed_whenCachedHashCodeIsLazilyInitialized_givenItIsValid() { EqualsVerifier .forClass(ObjectWithLazilyInitializedCachedHashCode.class) .withCachedHashCode( @@ -276,7 +276,7 @@ public void succeed_whenCachedHashCodeIsLazilyInitialized_givenItIsValid() { } @Test - public void succeed_whenCachedHashCodeIsLazilyInitializedAndCachedHashCodeFieldIsCalledInEquals_givenItIsValid() { + void succeed_whenCachedHashCodeIsLazilyInitializedAndCachedHashCodeFieldIsCalledInEquals_givenItIsValid() { EqualsVerifier .forClass(ObjectWithLazyCachedHashCodeAndFieldIsCalledInEquals.class) .withCachedHashCode( @@ -287,7 +287,7 @@ public void succeed_whenCachedHashCodeIsLazilyInitializedAndCachedHashCodeFieldI } @Test - public void succeed_whenCachedHashCodeIsLazilyInitializedAndHashCodeMethodIsCalledInEquals_givenItIsValid() { + void succeed_whenCachedHashCodeIsLazilyInitializedAndHashCodeMethodIsCalledInEquals_givenItIsValid() { EqualsVerifier .forClass(ObjectWithLazyCachedHashCodeAndMethodIsCalledInEquals.class) .withCachedHashCode( diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/GetClassInEqualityComparisonTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/GetClassInEqualityComparisonTest.java index d0f35b109..79f36233c 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/GetClassInEqualityComparisonTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/GetClassInEqualityComparisonTest.java @@ -3,20 +3,20 @@ import nl.jqno.equalsverifier.EqualsVerifier; import org.junit.jupiter.api.Test; -public class GetClassInEqualityComparisonTest { +class GetClassInEqualityComparisonTest { @Test - public void succeed_whenGetClassIsPartOfEqualityComparison_givenAnAbstractSuperclassAndUsingGetClassIsUsed() { + void succeed_whenGetClassIsPartOfEqualityComparison_givenAnAbstractSuperclassAndUsingGetClassIsUsed() { EqualsVerifier.forClass(Identifiable.class).usingGetClass().verify(); } @Test - public void succeed_whenGetClassIsPartOfEqualityComparison_givenAConcreteImplementationAndUsingGetClassIsUsed() { + void succeed_whenGetClassIsPartOfEqualityComparison_givenAConcreteImplementationAndUsingGetClassIsUsed() { EqualsVerifier.forClass(Person.class).usingGetClass().verify(); } @Test - public void succeed_whenGetClassIsPartOfEqualityComparison_givenAnotherConcreteImplementationAndUsingGetClassIsUsed() { + void succeed_whenGetClassIsPartOfEqualityComparison_givenAnotherConcreteImplementationAndUsingGetClassIsUsed() { EqualsVerifier.forClass(Account.class).usingGetClass().verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/GetClassTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/GetClassTest.java index fbfd75fb0..79067b1be 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/GetClassTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/GetClassTest.java @@ -11,10 +11,10 @@ import nl.jqno.equalsverifier.testhelpers.types.Point; import org.junit.jupiter.api.Test; -public class GetClassTest { +class GetClassTest { @Test - public void fail_whenEqualsUsesGetClassInsteadOfInstanceof() { + void fail_whenEqualsUsesGetClassInsteadOfInstanceof() { ExpectedException .when(() -> EqualsVerifier.forClass(GetClassPoint.class).verify()) .assertFailure() @@ -25,17 +25,17 @@ public void fail_whenEqualsUsesGetClassInsteadOfInstanceof() { } @Test - public void succeed_whenEqualsUsesGetClassInsteadOfInstanceof_givenUsingGetClassIsUsed() { + void succeed_whenEqualsUsesGetClassInsteadOfInstanceof_givenUsingGetClassIsUsed() { EqualsVerifier.forClass(GetClassPoint.class).usingGetClass().verify(); } @Test - public void succeed_whenEqualsUsesGetClassInsteadOfInstanceof_givenWarningStrictInheritanceIsSuppressed() { + void succeed_whenEqualsUsesGetClassInsteadOfInstanceof_givenWarningStrictInheritanceIsSuppressed() { EqualsVerifier.forClass(GetClassPoint.class).suppress(Warning.STRICT_INHERITANCE).verify(); } @Test - public void fail_whenEqualsUsesGetClassButForgetsToCheckNull_givenUsingGetClassIsUsed() { + void fail_whenEqualsUsesGetClassButForgetsToCheckNull_givenUsingGetClassIsUsed() { ExpectedException .when(() -> EqualsVerifier.forClass(GetClassPointNull.class).usingGetClass().verify()) .assertFailure() @@ -44,7 +44,7 @@ public void fail_whenEqualsUsesGetClassButForgetsToCheckNull_givenUsingGetClassI } @Test - public void fail_whenEqualsUsesInstanceof_givenUsingGetClassIsUsed() { + void fail_whenEqualsUsesInstanceof_givenUsingGetClassIsUsed() { ExpectedException .when(() -> EqualsVerifier.forClass(FinalMethodsPoint.class).usingGetClass().verify()) .assertFailure() @@ -55,7 +55,7 @@ public void fail_whenEqualsUsesInstanceof_givenUsingGetClassIsUsed() { } @Test - public void fail_whenSuperclassUsesGetClass() { + void fail_whenSuperclassUsesGetClass() { ExpectedException .when(() -> EqualsVerifier.forClass(GetClassColorPoint.class).verify()) .assertFailure() @@ -63,17 +63,17 @@ public void fail_whenSuperclassUsesGetClass() { } @Test - public void succeed_whenSuperclassUsesGetClass_givenUsingGetClassIsUsed() { + void succeed_whenSuperclassUsesGetClass_givenUsingGetClassIsUsed() { EqualsVerifier.forClass(GetClassColorPoint.class).usingGetClass().verify(); } @Test - public void succeed_whenSuperclassUsesGetClass_givenWarningStrictInheritanceIsSuppressed() { + void succeed_whenSuperclassUsesGetClass_givenWarningStrictInheritanceIsSuppressed() { EqualsVerifier.forClass(GetClassColorPoint.class).suppress(Warning.STRICT_INHERITANCE).verify(); } @Test - public void fail_whenEqualsUsesGetClassButSuperclassUsesInstanceof_givenUsingGetClassIsUsed() { + void fail_whenEqualsUsesGetClassButSuperclassUsesInstanceof_givenUsingGetClassIsUsed() { ExpectedException .when(() -> EqualsVerifier.forClass(GetClassColorPointWithEqualSuper.class).usingGetClass().verify()) .assertFailure() diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JakartaEntityTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JakartaEntityTest.java index 214cb8b3b..9290ccbb0 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JakartaEntityTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JakartaEntityTest.java @@ -8,15 +8,15 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class JakartaEntityTest { +class JakartaEntityTest { @Test - public void succeed_whenClassIsNonFinalAndFieldsAreMutable_givenClassHasJpaEntityAnnotation() { + void succeed_whenClassIsNonFinalAndFieldsAreMutable_givenClassHasJpaEntityAnnotation() { EqualsVerifier.forClass(EntityByJakartaAnnotation.class).verify(); } @Test - public void fail_whenClassIsNonFinalAndFieldsAreMutable_givenSuperclassHasJpaEntityAnnotationButThisClassDoesnt() { + void fail_whenClassIsNonFinalAndFieldsAreMutable_givenSuperclassHasJpaEntityAnnotationButThisClassDoesnt() { ExpectedException .when(() -> EqualsVerifier.forClass(SubclassEntityByJakartaAnnotation.class).verify()) .assertFailure() @@ -24,12 +24,12 @@ public void fail_whenClassIsNonFinalAndFieldsAreMutable_givenSuperclassHasJpaEnt } @Test - public void succeed_whenFieldsAreMutable_givenClassHasJpaEmbeddableAnnotation() { + void succeed_whenFieldsAreMutable_givenClassHasJpaEmbeddableAnnotation() { EqualsVerifier.forClass(EmbeddableByJakartaAnnotation.class).verify(); } @Test - public void fail_whenFieldsAreMutable_givenSuperclassHasJpaEmbeddableAnnotationButThisClassDoesnt() { + void fail_whenFieldsAreMutable_givenSuperclassHasJpaEmbeddableAnnotationButThisClassDoesnt() { ExpectedException .when(() -> EqualsVerifier.forClass(SubclassEmbeddableByJakartaAnnotation.class).verify()) .assertFailure() @@ -37,12 +37,12 @@ public void fail_whenFieldsAreMutable_givenSuperclassHasJpaEmbeddableAnnotationB } @Test - public void succeed_whenFieldsAreMutable_givenClassHasJpaMappedSuperclassAnnotation() { + void succeed_whenFieldsAreMutable_givenClassHasJpaMappedSuperclassAnnotation() { EqualsVerifier.forClass(MappedSuperclassByJakartaAnnotation.class).verify(); } @Test - public void fail_whenFieldsAreMutable_givenSuperclassHasJpaMappedSuperclassAnnotationButThisClassDoesnt() { + void fail_whenFieldsAreMutable_givenSuperclassHasJpaMappedSuperclassAnnotationButThisClassDoesnt() { ExpectedException .when(() -> EqualsVerifier.forClass(SubclassMappedSuperclassByJakartaAnnotation.class).verify()) .assertFailure() diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JakartaIdTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JakartaIdTest.java index 60df9780b..f66345683 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JakartaIdTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JakartaIdTest.java @@ -11,16 +11,16 @@ import org.junit.jupiter.api.Test; @SuppressWarnings("unused") -public class JakartaIdTest { +class JakartaIdTest { @Test - public void succeed_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithId() { + void succeed_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithId() { EqualsVerifier.forClass(JakartaIdBusinessKeyPerson.class).verify(); EqualsVerifier.forClass(JakartaIdBusinessKeyPersonReorderedFields.class).verify(); } @Test - public void succeed_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWarningIsSuppressed() { + void succeed_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWarningIsSuppressed() { EqualsVerifier.forClass(JakartaIdSurrogateKeyPerson.class).suppress(Warning.SURROGATE_KEY).verify(); EqualsVerifier .forClass(JakartaIdSurrogateKeyPersonReorderedFields.class) @@ -29,7 +29,7 @@ public void succeed_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithIdAndSurrogateKe } @Test - public void succeed_whenAllFieldsAreUsed_givenIdIsAnnotatedWithIdAndJpaKeyWarningIsSuppressed() { + void succeed_whenAllFieldsAreUsed_givenIdIsAnnotatedWithIdAndJpaKeyWarningIsSuppressed() { EqualsVerifier.forClass(JakartaIdValueKeyPerson.class).suppress(Warning.SURROGATE_OR_BUSINESS_KEY).verify(); EqualsVerifier .forClass(JakartaIdValueKeyPersonReorderedFields.class) @@ -38,7 +38,7 @@ public void succeed_whenAllFieldsAreUsed_givenIdIsAnnotatedWithIdAndJpaKeyWarnin } @Test - public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdButIdAnnotationIsIgnored() { + void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdButIdAnnotationIsIgnored() { ExpectedException .when( () -> EqualsVerifier @@ -50,7 +50,7 @@ public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdButIdAnnotationIsI } @Test - public void fail_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithId() { + void fail_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithId() { ExpectedException .when(() -> EqualsVerifier.forClass(JakartaIdSurrogateKeyPerson.class).verify()) .assertFailure() @@ -62,7 +62,7 @@ public void fail_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithId() { } @Test - public void fail_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithId2() { + void fail_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithId2() { ExpectedException .when(() -> EqualsVerifier.forClass(JakartaIdSurrogateKeyPersonReorderedFields.class).verify()) .assertFailure() @@ -73,7 +73,7 @@ public void fail_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithId2() { } @Test - public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWarningIsSuppressed() { + void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWarningIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -89,7 +89,7 @@ public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWar } @Test - public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWarningIsSuppressed2() { + void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWarningIsSuppressed2() { ExpectedException .when( () -> EqualsVerifier @@ -105,13 +105,13 @@ public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWar } @Test - public void succeed_whenEmbeddedIdIsUsedCorrectly() { + void succeed_whenEmbeddedIdIsUsedCorrectly() { EqualsVerifier.forClass(JakartaEmbeddedIdBusinessKeyPerson.class).verify(); EqualsVerifier.forClass(JakartaEmbeddedIdSurrogateKeyPerson.class).suppress(Warning.SURROGATE_KEY).verify(); } @Test - public void fail_whenOnlyEmbeddedIdFieldIsUsed_givenIdIsAnnotatedWithEmbeddedId() { + void fail_whenOnlyEmbeddedIdFieldIsUsed_givenIdIsAnnotatedWithEmbeddedId() { ExpectedException .when(() -> EqualsVerifier.forClass(JakartaEmbeddedIdSurrogateKeyPerson.class).verify()) .assertFailure() @@ -123,7 +123,7 @@ public void fail_whenOnlyEmbeddedIdFieldIsUsed_givenIdIsAnnotatedWithEmbeddedId( } @Test - public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithEmbeddedIdAndSurrogateKeyWarningIsSuppressed() { + void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithEmbeddedIdAndSurrogateKeyWarningIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -139,7 +139,7 @@ public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithEmbeddedIdAndSurroga } @Test - public void fail_whenEmbeddedIdFieldIsTheOnlyFieldUsed() { + void fail_whenEmbeddedIdFieldIsTheOnlyFieldUsed() { ExpectedException .when( () -> EqualsVerifier @@ -153,12 +153,12 @@ public void fail_whenEmbeddedIdFieldIsTheOnlyFieldUsed() { } @Test - public void succeed_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWithNaturalId() { + void succeed_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWithNaturalId() { EqualsVerifier.forClass(NaturalIdBusinessKeyPerson.class).verify(); } @Test - public void fail_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWithNaturalIdButIdAnnotationIsIgnored() { + void fail_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWithNaturalIdButIdAnnotationIsIgnored() { ExpectedException .when( () -> EqualsVerifier @@ -170,12 +170,12 @@ public void fail_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWith } @Test - public void succeed_whenIdAndNameFieldsAreNotUsed_givenNameIsIgnored() { + void succeed_whenIdAndNameFieldsAreNotUsed_givenNameIsIgnored() { EqualsVerifier.forClass(JakartaIdBusinessKeyPersonDoesntUseName.class).withIgnoredFields("name").verify(); } @Test - public void succeed_whenIdAndNameFieldsAreNotUsed_givenSocialSecurityAndBirthdateAreOnlyUsed() { + void succeed_whenIdAndNameFieldsAreNotUsed_givenSocialSecurityAndBirthdateAreOnlyUsed() { EqualsVerifier .forClass(JakartaIdBusinessKeyPersonDoesntUseName.class) .withOnlyTheseFields("socialSecurity", "birthdate") @@ -183,17 +183,17 @@ public void succeed_whenIdAndNameFieldsAreNotUsed_givenSocialSecurityAndBirthdat } @Test - public void succeed_whenIdIsPartOfAProperJakartaEntity() { + void succeed_whenIdIsPartOfAProperJakartaEntity() { EqualsVerifier.forClass(JakartaIdBusinessKeyPersonEntity.class).verify(); } @Test - public void succeed_whenNaturalIdIsPartOfAProperJakartaEntity() { + void succeed_whenNaturalIdIsPartOfAProperJakartaEntity() { EqualsVerifier.forClass(NaturalIdBusinessKeyPersonEntity.class).verify(); } @Test - public void succeed_whenEqualsBehavesLikeVersionedEntity_givenIdIsMarkedWithIdAndWarningVersionedEntityIsSuppressed() { + void succeed_whenEqualsBehavesLikeVersionedEntity_givenIdIsMarkedWithIdAndWarningVersionedEntityIsSuppressed() { EqualsVerifier .forClass(JakartaIdVersionedEntity.class) .suppress(Warning.IDENTICAL_COPY_FOR_VERSIONED_ENTITY, Warning.SURROGATE_KEY) @@ -201,12 +201,12 @@ public void succeed_whenEqualsBehavesLikeVersionedEntity_givenIdIsMarkedWithIdAn } @Test - public void succeed_whenMethodsAreAnnotatedInsteadOfFields() { + void succeed_whenMethodsAreAnnotatedInsteadOfFields() { EqualsVerifier.forClass(MethodAnnotatedBusinessKeyPerson.class).verify(); } @Test - public void fail_whenIdFieldIsTheOnlyFieldUsed() { + void fail_whenIdFieldIsTheOnlyFieldUsed() { ExpectedException .when( () -> EqualsVerifier.forClass(JakartaIdBusinessKeyPerson.class).withOnlyTheseFields("id").verify()) @@ -217,7 +217,7 @@ public void fail_whenIdFieldIsTheOnlyFieldUsed() { } @Test - public void fail_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWithNaturalIdButSurrogateKeyWarningIsSuppressed() { + void fail_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWithNaturalIdButSurrogateKeyWarningIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -230,7 +230,7 @@ public void fail_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWith } @Test - public void fail_whenWithOnlyTheseFieldsIsUsed_givenWarningSurrogateKeyIsSuppressed() { + void fail_whenWithOnlyTheseFieldsIsUsed_givenWarningSurrogateKeyIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -244,7 +244,7 @@ public void fail_whenWithOnlyTheseFieldsIsUsed_givenWarningSurrogateKeyIsSuppres } @Test - public void fail_whenWithOnlyTheseFieldsIsUsed_givenWarningSurrogateKeyIsSuppressedInReverse() { + void fail_whenWithOnlyTheseFieldsIsUsed_givenWarningSurrogateKeyIsSuppressedInReverse() { ExpectedException .when( () -> EqualsVerifier @@ -258,7 +258,7 @@ public void fail_whenWithOnlyTheseFieldsIsUsed_givenWarningSurrogateKeyIsSuppres } @Test - public void fail_whenFieldsAreIgnored_givenWarningSurrogateKeyIsSuppressed() { + void fail_whenFieldsAreIgnored_givenWarningSurrogateKeyIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -271,7 +271,7 @@ public void fail_whenFieldsAreIgnored_givenWarningSurrogateKeyIsSuppressed() { } @Test - public void fail_whenFieldsAreIgnored_givenWarningSurrogateKeyIsSuppressedInReverse() { + void fail_whenFieldsAreIgnored_givenWarningSurrogateKeyIsSuppressedInReverse() { ExpectedException .when( () -> EqualsVerifier @@ -284,7 +284,7 @@ public void fail_whenFieldsAreIgnored_givenWarningSurrogateKeyIsSuppressedInReve } @Test - public void fail_whenWithOnlyTheseFieldsIsUsed_givenFieldsAreMarkedWithNaturalId() { + void fail_whenWithOnlyTheseFieldsIsUsed_givenFieldsAreMarkedWithNaturalId() { ExpectedException .when( () -> EqualsVerifier @@ -297,7 +297,7 @@ public void fail_whenWithOnlyTheseFieldsIsUsed_givenFieldsAreMarkedWithNaturalId } @Test - public void fail_whenFieldsAreIgnored_givenFieldsAreMarkedWithNaturalId() { + void fail_whenFieldsAreIgnored_givenFieldsAreMarkedWithNaturalId() { ExpectedException .when( () -> EqualsVerifier @@ -310,7 +310,7 @@ public void fail_whenFieldsAreIgnored_givenFieldsAreMarkedWithNaturalId() { } @Test - public void fail_whenWarningVersionedEntityIsSuppressed_givenAFieldIsAnnotatedWithNaturalId() { + void fail_whenWarningVersionedEntityIsSuppressed_givenAFieldIsAnnotatedWithNaturalId() { ExpectedException .when( () -> EqualsVerifier @@ -323,7 +323,7 @@ public void fail_whenWarningVersionedEntityIsSuppressed_givenAFieldIsAnnotatedWi } @Test - public void fail_whenWarningSurrogateKeyIsSuppressed_givenWarningSurrogateOrBusinessKeyIsAlsoSuppressed() { + void fail_whenWarningSurrogateKeyIsSuppressed_givenWarningSurrogateOrBusinessKeyIsAlsoSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -336,7 +336,7 @@ public void fail_whenWarningSurrogateKeyIsSuppressed_givenWarningSurrogateOrBusi } @Test - public void fail_whenANaturalIdAnnotationFromAnotherPackageIsUsed() { + void fail_whenANaturalIdAnnotationFromAnotherPackageIsUsed() { ExpectedException .when(() -> EqualsVerifier.forClass(NonHibernateNaturalIdBusinessKeyPerson.class).verify()) .assertFailure() @@ -344,12 +344,12 @@ public void fail_whenANaturalIdAnnotationFromAnotherPackageIsUsed() { } @Test - public void succeed_whenEqualsIsImplementedInSuperclass_givenWarningSurrogateKeyIsSuppressed() { + void succeed_whenEqualsIsImplementedInSuperclass_givenWarningSurrogateKeyIsSuppressed() { EqualsVerifier.forClass(SubclassEntity.class).suppress(Warning.SURROGATE_KEY).verify(); } @Test - public void succeed_whenEqualsUsesIdsAndNonIds_givenWarningSurrogateOrBusinessKeyIsSuppressed() { + void succeed_whenEqualsUsesIdsAndNonIds_givenWarningSurrogateOrBusinessKeyIsSuppressed() { EqualsVerifier .forClass(JakartaIdDirtyTrackingPerson.class) .suppress(Warning.SURROGATE_OR_BUSINESS_KEY) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JakartaLazyEntityTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JakartaLazyEntityTest.java index 8c6e18d92..13371354d 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JakartaLazyEntityTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JakartaLazyEntityTest.java @@ -11,15 +11,15 @@ // CHECKSTYLE OFF: HiddenField -public class JakartaLazyEntityTest { +class JakartaLazyEntityTest { @Test - public void gettersAreUsed() { + void gettersAreUsed() { EqualsVerifier.forClass(CorrectJakartaLazyFieldContainer.class).suppress(Warning.NONFINAL_FIELDS).verify(); } @Test - public void basicGetterNotUsed_givenEagerLoading() { + void basicGetterNotUsed_givenEagerLoading() { EqualsVerifier .forClass(CorrectBasicJakartaEagerFieldContainer.class) .suppress(Warning.NONFINAL_FIELDS) @@ -27,7 +27,7 @@ public void basicGetterNotUsed_givenEagerLoading() { } @Test - public void basicGetterNotUsed_givenCorrespondingFieldIgnored() { + void basicGetterNotUsed_givenCorrespondingFieldIgnored() { EqualsVerifier .forClass(CorrectBasicJakartaIgnoredLazyFieldContainer.class) .withIgnoredFields("basic") @@ -36,7 +36,7 @@ public void basicGetterNotUsed_givenCorrespondingFieldIgnored() { } @Test - public void basicGetterNotUsed_givenWarningSuppressed() { + void basicGetterNotUsed_givenWarningSuppressed() { EqualsVerifier .forClass(CorrectBasicJakartaIgnoredLazyFieldContainer.class) .suppress(Warning.ALL_FIELDS_SHOULD_BE_USED) @@ -44,66 +44,66 @@ public void basicGetterNotUsed_givenWarningSuppressed() { } @Test - public void basicGetterNotUsed_givenAnnotationIsOnGetter() { + void basicGetterNotUsed_givenAnnotationIsOnGetter() { getterNotUsed(IncorrectBasicJakartaLazyGetterContainer.class, "equals"); getterNotUsed_warningSuppressed(IncorrectBasicJakartaLazyGetterContainer.class); } @Test - public void basicGetterNotUsedInHashCode() { + void basicGetterNotUsedInHashCode() { getterNotUsed(IncorrectBasicJakartaLazyFieldContainerHashCode.class, "hashCode"); getterNotUsed_warningSuppressed(IncorrectBasicJakartaLazyFieldContainerHashCode.class); } @Test - public void basicGetterNotUsed() { + void basicGetterNotUsed() { getterNotUsed(IncorrectBasicJakartaLazyFieldContainer.class, "equals"); getterNotUsed_warningSuppressed(IncorrectBasicJakartaLazyFieldContainer.class); } @Test - public void oneToOneGetterNotUsed() { + void oneToOneGetterNotUsed() { getterNotUsed(IncorrectOneToOneJakartaLazyFieldContainer.class, "equals"); getterNotUsed_warningSuppressed(IncorrectOneToOneJakartaLazyFieldContainer.class); } @Test - public void oneToManyGetterNotUsed() { + void oneToManyGetterNotUsed() { getterNotUsed(IncorrectOneToManyJakartaLazyFieldContainer.class, "equals"); getterNotUsed_warningSuppressed(IncorrectOneToManyJakartaLazyFieldContainer.class); } @Test - public void manyToOneGetterNotUsed() { + void manyToOneGetterNotUsed() { getterNotUsed(IncorrectManyToOneJakartaLazyFieldContainer.class, "equals"); getterNotUsed_warningSuppressed(IncorrectManyToOneJakartaLazyFieldContainer.class); } @Test - public void manyToManyGetterNotUsed() { + void manyToManyGetterNotUsed() { getterNotUsed(IncorrectManyToManyJakartaLazyFieldContainer.class, "equals"); getterNotUsed_warningSuppressed(IncorrectManyToManyJakartaLazyFieldContainer.class); } @Test - public void elementCollectionGetterNotUsed() { + void elementCollectionGetterNotUsed() { getterNotUsed(IncorrectElementCollectionJakartaLazyFieldContainer.class, "equals"); getterNotUsed_warningSuppressed(IncorrectElementCollectionJakartaLazyFieldContainer.class); } @Test - public void lazyGettersPickedUpInSuper() { + void lazyGettersPickedUpInSuper() { EqualsVerifier.forClass(LazyGetterContainer.class).usingGetClass().verify(); EqualsVerifier.forClass(ChildOfLazyGetterContainer.class).usingGetClass().verify(); } @Test - public void constantHashCode_givenStrictHashCodeSuppressed() { + void constantHashCode_givenStrictHashCodeSuppressed() { EqualsVerifier.forClass(ConstantHashCodeContainer.class).suppress(Warning.STRICT_HASHCODE).verify(); } @Test - public void differentCodingStyle_single() { + void differentCodingStyle_single() { EqualsVerifier .forClass(DifferentCodingStyleContainer.class) .suppress(Warning.NONFINAL_FIELDS) @@ -112,7 +112,7 @@ public void differentCodingStyle_single() { } @Test - public void differentCodingStyle_configured() { + void differentCodingStyle_configured() { EqualsVerifier .configure() .suppress(Warning.NONFINAL_FIELDS) @@ -122,7 +122,7 @@ public void differentCodingStyle_configured() { } @Test - public void differentCodingStyle_multiple() { + void differentCodingStyle_multiple() { EqualsVerifier .forClasses(Arrays.asList(DifferentCodingStyleContainer.class)) .suppress(Warning.NONFINAL_FIELDS) @@ -131,7 +131,7 @@ public void differentCodingStyle_multiple() { } @Test - public void getterUsedForGeneratedId() { + void getterUsedForGeneratedId() { EqualsVerifier.forClass(CorrectGeneratedJakartaIdContainer.class).suppress(Warning.SURROGATE_KEY).verify(); EqualsVerifier .forClass(CorrectGeneratedJakartaIdContainer.class) @@ -140,7 +140,7 @@ public void getterUsedForGeneratedId() { } @Test - public void getterNotUsedForGeneratedId() { + void getterNotUsedForGeneratedId() { getterNotUsed(IncorrectGeneratedJakartaIdContainer.class, "equals", Warning.SURROGATE_KEY); getterNotUsed_warningSuppressed(IncorrectGeneratedJakartaIdContainer.class, Warning.SURROGATE_KEY); getterNotUsed(IncorrectGeneratedJakartaIdContainer.class, "equals", Warning.SURROGATE_OR_BUSINESS_KEY); @@ -148,12 +148,12 @@ public void getterNotUsedForGeneratedId() { } @Test - public void gettersAreUsedAndProtected() { + void gettersAreUsedAndProtected() { EqualsVerifier.forClass(ProtectedJakartaLazyFieldContainer.class).verify(); } @Test - public void finalEntitiesArentLazy() { + void finalEntitiesArentLazy() { EqualsVerifier.forClass(FinalEntity.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JpaEntityTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JpaEntityTest.java index 2848f44c2..476913c9d 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JpaEntityTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JpaEntityTest.java @@ -8,15 +8,15 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class JpaEntityTest { +class JpaEntityTest { @Test - public void succeed_whenClassIsNonFinalAndFieldsAreMutable_givenClassHasJpaEntityAnnotation() { + void succeed_whenClassIsNonFinalAndFieldsAreMutable_givenClassHasJpaEntityAnnotation() { EqualsVerifier.forClass(EntityByJpaAnnotation.class).verify(); } @Test - public void fail_whenClassIsNonFinalAndFieldsAreMutable_givenSuperclassHasJpaEntityAnnotationButThisClassDoesnt() { + void fail_whenClassIsNonFinalAndFieldsAreMutable_givenSuperclassHasJpaEntityAnnotationButThisClassDoesnt() { ExpectedException .when(() -> EqualsVerifier.forClass(SubclassEntityByJpaAnnotation.class).verify()) .assertFailure() @@ -24,7 +24,7 @@ public void fail_whenClassIsNonFinalAndFieldsAreMutable_givenSuperclassHasJpaEnt } @Test - public void fail_whenClassIsJpaEntity_givenEntityAnnotationResidesInWrongPackage() { + void fail_whenClassIsJpaEntity_givenEntityAnnotationResidesInWrongPackage() { ExpectedException .when(() -> EqualsVerifier.forClass(EntityByNonJpaAnnotation.class).verify()) .assertFailure() @@ -32,12 +32,12 @@ public void fail_whenClassIsJpaEntity_givenEntityAnnotationResidesInWrongPackage } @Test - public void succeed_whenFieldsAreMutable_givenClassHasJpaEmbeddableAnnotation() { + void succeed_whenFieldsAreMutable_givenClassHasJpaEmbeddableAnnotation() { EqualsVerifier.forClass(EmbeddableByJpaAnnotation.class).verify(); } @Test - public void fail_whenFieldsAreMutable_givenSuperclassHasJpaEmbeddableAnnotationButThisClassDoesnt() { + void fail_whenFieldsAreMutable_givenSuperclassHasJpaEmbeddableAnnotationButThisClassDoesnt() { ExpectedException .when(() -> EqualsVerifier.forClass(SubclassEmbeddableByJpaAnnotation.class).verify()) .assertFailure() @@ -45,7 +45,7 @@ public void fail_whenFieldsAreMutable_givenSuperclassHasJpaEmbeddableAnnotationB } @Test - public void fail_whenClassIsJpaEmbeddable_givenEmbeddableAnnotationResidesInWrongPackage() { + void fail_whenClassIsJpaEmbeddable_givenEmbeddableAnnotationResidesInWrongPackage() { ExpectedException .when(() -> EqualsVerifier.forClass(EmbeddableByNonJpaAnnotation.class).verify()) .assertFailure() @@ -53,12 +53,12 @@ public void fail_whenClassIsJpaEmbeddable_givenEmbeddableAnnotationResidesInWron } @Test - public void succeed_whenFieldsAreMutable_givenClassHasJpaMappedSuperclassAnnotation() { + void succeed_whenFieldsAreMutable_givenClassHasJpaMappedSuperclassAnnotation() { EqualsVerifier.forClass(MappedSuperclassByJpaAnnotation.class).verify(); } @Test - public void fail_whenFieldsAreMutable_givenSuperclassHasJpaMappedSuperclassAnnotationButThisClassDoesnt() { + void fail_whenFieldsAreMutable_givenSuperclassHasJpaMappedSuperclassAnnotationButThisClassDoesnt() { ExpectedException .when(() -> EqualsVerifier.forClass(SubclassMappedSuperclassByJpaAnnotation.class).verify()) .assertFailure() @@ -66,7 +66,7 @@ public void fail_whenFieldsAreMutable_givenSuperclassHasJpaMappedSuperclassAnnot } @Test - public void fail_whenClassIsJpaMappedSuperclass_givenMappedSuperclassAnnotationResidesInWrongPackage() { + void fail_whenClassIsJpaMappedSuperclass_givenMappedSuperclassAnnotationResidesInWrongPackage() { ExpectedException .when(() -> EqualsVerifier.forClass(MappedSuperclassByNonJpaAnnotation.class).verify()) .assertFailure() diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JpaIdTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JpaIdTest.java index 29112710d..3682de0d8 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JpaIdTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JpaIdTest.java @@ -14,22 +14,22 @@ import org.junit.jupiter.api.Test; @SuppressWarnings("unused") -public class JpaIdTest { +class JpaIdTest { @Test - public void succeed_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithId() { + void succeed_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithId() { EqualsVerifier.forClass(JpaIdBusinessKeyPerson.class).verify(); EqualsVerifier.forClass(JpaIdBusinessKeyPersonReorderedFields.class).verify(); } @Test - public void succeed_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWarningIsSuppressed() { + void succeed_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWarningIsSuppressed() { EqualsVerifier.forClass(JpaIdSurrogateKeyPerson.class).suppress(Warning.SURROGATE_KEY).verify(); EqualsVerifier.forClass(JpaIdSurrogateKeyPersonReorderedFields.class).suppress(Warning.SURROGATE_KEY).verify(); } @Test - public void succeed_whenAllFieldsAreUsed_givenIdIsAnnotatedWithIdAndJpaKeyWarningIsSuppressed() { + void succeed_whenAllFieldsAreUsed_givenIdIsAnnotatedWithIdAndJpaKeyWarningIsSuppressed() { EqualsVerifier.forClass(JpaIdValueKeyPerson.class).suppress(Warning.SURROGATE_OR_BUSINESS_KEY).verify(); EqualsVerifier .forClass(JpaIdValueKeyPersonReorderedFields.class) @@ -38,7 +38,7 @@ public void succeed_whenAllFieldsAreUsed_givenIdIsAnnotatedWithIdAndJpaKeyWarnin } @Test - public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdButIdAnnotationIsIgnored() { + void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdButIdAnnotationIsIgnored() { ExpectedException .when( () -> EqualsVerifier @@ -50,7 +50,7 @@ public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdButIdAnnotationIsI } @Test - public void fail_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithId() { + void fail_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithId() { ExpectedException .when(() -> EqualsVerifier.forClass(JpaIdSurrogateKeyPerson.class).verify()) .assertFailure() @@ -62,7 +62,7 @@ public void fail_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithId() { } @Test - public void fail_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithId2() { + void fail_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithId2() { ExpectedException .when(() -> EqualsVerifier.forClass(JpaIdSurrogateKeyPersonReorderedFields.class).verify()) .assertFailure() @@ -73,7 +73,7 @@ public void fail_whenOnlyIdFieldIsUsed_givenIdIsAnnotatedWithId2() { } @Test - public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWarningIsSuppressed() { + void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWarningIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -89,7 +89,7 @@ public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWar } @Test - public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWarningIsSuppressed2() { + void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWarningIsSuppressed2() { ExpectedException .when( () -> EqualsVerifier @@ -105,13 +105,13 @@ public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithIdAndSurrogateKeyWar } @Test - public void succeed_whenEmbeddedIdIsUsedCorrectly() { + void succeed_whenEmbeddedIdIsUsedCorrectly() { EqualsVerifier.forClass(JpaEmbeddedIdBusinessKeyPerson.class).verify(); EqualsVerifier.forClass(JpaEmbeddedIdSurrogateKeyPerson.class).suppress(Warning.SURROGATE_KEY).verify(); } @Test - public void fail_whenOnlyEmbeddedIdFieldIsUsed_givenIdIsAnnotatedWithEmbeddedId() { + void fail_whenOnlyEmbeddedIdFieldIsUsed_givenIdIsAnnotatedWithEmbeddedId() { ExpectedException .when(() -> EqualsVerifier.forClass(JpaEmbeddedIdSurrogateKeyPerson.class).verify()) .assertFailure() @@ -123,7 +123,7 @@ public void fail_whenOnlyEmbeddedIdFieldIsUsed_givenIdIsAnnotatedWithEmbeddedId( } @Test - public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithEmbeddedIdAndSurrogateKeyWarningIsSuppressed() { + void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithEmbeddedIdAndSurrogateKeyWarningIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -139,7 +139,7 @@ public void fail_whenIdFieldIsNotUsed_givenIdIsAnnotatedWithEmbeddedIdAndSurroga } @Test - public void fail_whenEmbeddedIdFieldIsTheOnlyFieldUsed() { + void fail_whenEmbeddedIdFieldIsTheOnlyFieldUsed() { ExpectedException .when( () -> EqualsVerifier @@ -153,17 +153,17 @@ public void fail_whenEmbeddedIdFieldIsTheOnlyFieldUsed() { } @Test - public void succeed_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWithNaturalId() { + void succeed_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWithNaturalId() { EqualsVerifier.forClass(NaturalIdBusinessKeyPerson.class).verify(); } @Test - public void succeed_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWithNaturalIdAndNothingIsAnnotatedWithJpaId() { + void succeed_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWithNaturalIdAndNothingIsAnnotatedWithJpaId() { EqualsVerifier.forClass(NaturalIdWithoutJpaIdBusinessKeyPerson.class).verify(); } @Test - public void fail_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWithNaturalIdButIdAnnotationIsIgnored() { + void fail_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWithNaturalIdButIdAnnotationIsIgnored() { ExpectedException .when( () -> EqualsVerifier @@ -175,12 +175,12 @@ public void fail_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWith } @Test - public void succeed_whenIdAndNameFieldsAreNotUsed_givenNameIsIgnored() { + void succeed_whenIdAndNameFieldsAreNotUsed_givenNameIsIgnored() { EqualsVerifier.forClass(JpaIdBusinessKeyPersonDoesntUseName.class).withIgnoredFields("name").verify(); } @Test - public void succeed_whenIdAndNameFieldsAreNotUsed_givenSocialSecurityAndBirthdateAreOnlyUsed() { + void succeed_whenIdAndNameFieldsAreNotUsed_givenSocialSecurityAndBirthdateAreOnlyUsed() { EqualsVerifier .forClass(JpaIdBusinessKeyPersonDoesntUseName.class) .withOnlyTheseFields("socialSecurity", "birthdate") @@ -188,17 +188,17 @@ public void succeed_whenIdAndNameFieldsAreNotUsed_givenSocialSecurityAndBirthdat } @Test - public void succeed_whenIdIsPartOfAProperJpaEntity() { + void succeed_whenIdIsPartOfAProperJpaEntity() { EqualsVerifier.forClass(JpaIdBusinessKeyPersonEntity.class).verify(); } @Test - public void succeed_whenNaturalIdIsPartOfAProperJpaEntity() { + void succeed_whenNaturalIdIsPartOfAProperJpaEntity() { EqualsVerifier.forClass(NaturalIdBusinessKeyPersonEntity.class).verify(); } @Test - public void succeed_whenEqualsBehavesLikeVersionedEntity_givenIdIsMarkedWithIdAndWarningVersionedEntityIsSuppressed() { + void succeed_whenEqualsBehavesLikeVersionedEntity_givenIdIsMarkedWithIdAndWarningVersionedEntityIsSuppressed() { EqualsVerifier .forClass(JpaIdVersionedEntity.class) .suppress(Warning.IDENTICAL_COPY_FOR_VERSIONED_ENTITY, Warning.SURROGATE_KEY) @@ -206,12 +206,12 @@ public void succeed_whenEqualsBehavesLikeVersionedEntity_givenIdIsMarkedWithIdAn } @Test - public void succeed_whenMethodsAreAnnotatedInsteadOfFields() { + void succeed_whenMethodsAreAnnotatedInsteadOfFields() { EqualsVerifier.forClass(MethodAnnotatedBusinessKeyPerson.class).verify(); } @Test - public void fail_whenIdFieldIsTheOnlyFieldUsed() { + void fail_whenIdFieldIsTheOnlyFieldUsed() { ExpectedException .when(() -> EqualsVerifier.forClass(JpaIdBusinessKeyPerson.class).withOnlyTheseFields("id").verify()) .assertFailure() @@ -221,7 +221,7 @@ public void fail_whenIdFieldIsTheOnlyFieldUsed() { } @Test - public void fail_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWithNaturalIdButSurrogateKeyWarningIsSuppressed() { + void fail_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWithNaturalIdButSurrogateKeyWarningIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -234,7 +234,7 @@ public void fail_whenOnlySocialSecurityIsUsed_givenSocialSecurityIsAnnotatedWith } @Test - public void fail_whenWithOnlyTheseFieldsIsUsed_givenWarningSurrogateKeyIsSuppressed() { + void fail_whenWithOnlyTheseFieldsIsUsed_givenWarningSurrogateKeyIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -248,7 +248,7 @@ public void fail_whenWithOnlyTheseFieldsIsUsed_givenWarningSurrogateKeyIsSuppres } @Test - public void fail_whenWithOnlyTheseFieldsIsUsed_givenWarningSurrogateKeyIsSuppressedInReverse() { + void fail_whenWithOnlyTheseFieldsIsUsed_givenWarningSurrogateKeyIsSuppressedInReverse() { ExpectedException .when( () -> EqualsVerifier @@ -262,7 +262,7 @@ public void fail_whenWithOnlyTheseFieldsIsUsed_givenWarningSurrogateKeyIsSuppres } @Test - public void fail_whenFieldsAreIgnored_givenWarningSurrogateKeyIsSuppressed() { + void fail_whenFieldsAreIgnored_givenWarningSurrogateKeyIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -275,7 +275,7 @@ public void fail_whenFieldsAreIgnored_givenWarningSurrogateKeyIsSuppressed() { } @Test - public void fail_whenFieldsAreIgnored_givenWarningSurrogateKeyIsSuppressedInReverse() { + void fail_whenFieldsAreIgnored_givenWarningSurrogateKeyIsSuppressedInReverse() { ExpectedException .when( () -> EqualsVerifier @@ -288,7 +288,7 @@ public void fail_whenFieldsAreIgnored_givenWarningSurrogateKeyIsSuppressedInReve } @Test - public void fail_whenWithOnlyTheseFieldsIsUsed_givenFieldsAreMarkedWithNaturalId() { + void fail_whenWithOnlyTheseFieldsIsUsed_givenFieldsAreMarkedWithNaturalId() { ExpectedException .when( () -> EqualsVerifier @@ -301,7 +301,7 @@ public void fail_whenWithOnlyTheseFieldsIsUsed_givenFieldsAreMarkedWithNaturalId } @Test - public void fail_whenFieldsAreIgnored_givenFieldsAreMarkedWithNaturalId() { + void fail_whenFieldsAreIgnored_givenFieldsAreMarkedWithNaturalId() { ExpectedException .when( () -> EqualsVerifier @@ -314,7 +314,7 @@ public void fail_whenFieldsAreIgnored_givenFieldsAreMarkedWithNaturalId() { } @Test - public void fail_whenWarningVersionedEntityIsSuppressed_givenAFieldIsAnnotatedWithNaturalId() { + void fail_whenWarningVersionedEntityIsSuppressed_givenAFieldIsAnnotatedWithNaturalId() { ExpectedException .when( () -> EqualsVerifier @@ -327,7 +327,7 @@ public void fail_whenWarningVersionedEntityIsSuppressed_givenAFieldIsAnnotatedWi } @Test - public void fail_whenWarningSurrogateKeyIsSuppressed_givenWarningSurrogateOrBusinessKeyIsAlsoSuppressed() { + void fail_whenWarningSurrogateKeyIsSuppressed_givenWarningSurrogateOrBusinessKeyIsAlsoSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -340,7 +340,7 @@ public void fail_whenWarningSurrogateKeyIsSuppressed_givenWarningSurrogateOrBusi } @Test - public void fail_whenAnIdAnnotationFromAnotherPackageIsUsed() { + void fail_whenAnIdAnnotationFromAnotherPackageIsUsed() { ExpectedException .when(() -> EqualsVerifier.forClass(NonJpaIdBusinessKeyPerson.class).verify()) .assertFailure() @@ -348,7 +348,7 @@ public void fail_whenAnIdAnnotationFromAnotherPackageIsUsed() { } @Test - public void fail_whenANaturalIdAnnotationFromAnotherPackageIsUsed() { + void fail_whenANaturalIdAnnotationFromAnotherPackageIsUsed() { ExpectedException .when(() -> EqualsVerifier.forClass(NonHibernateNaturalIdBusinessKeyPerson.class).verify()) .assertFailure() @@ -356,12 +356,12 @@ public void fail_whenANaturalIdAnnotationFromAnotherPackageIsUsed() { } @Test - public void succeed_whenEqualsIsImplementedInSuperclass_givenWarningSurrogateKeyIsSuppressed() { + void succeed_whenEqualsIsImplementedInSuperclass_givenWarningSurrogateKeyIsSuppressed() { EqualsVerifier.forClass(SubclassEntity.class).suppress(Warning.SURROGATE_KEY).verify(); } @Test - public void succeed_whenEqualsUsesIdsAndNonIds_givenWarningSurrogateOrBusinessKeyIsSuppressed() { + void succeed_whenEqualsUsesIdsAndNonIds_givenWarningSurrogateOrBusinessKeyIsSuppressed() { EqualsVerifier .forClass(JpaIdDirtyTrackingPerson.class) .suppress(Warning.SURROGATE_OR_BUSINESS_KEY) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JpaLazyEntityTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JpaLazyEntityTest.java index 6b7fccf6f..e2572bb7f 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JpaLazyEntityTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/JpaLazyEntityTest.java @@ -11,15 +11,15 @@ // CHECKSTYLE OFF: HiddenField -public class JpaLazyEntityTest { +class JpaLazyEntityTest { @Test - public void gettersAreUsed() { + void gettersAreUsed() { EqualsVerifier.forClass(CorrectJpaLazyFieldContainer.class).verify(); } @Test - public void basicGetterAbsent() { + void basicGetterAbsent() { ExpectedException .when(() -> EqualsVerifier.forClass(LazyFieldWithoutGetterContainer.class).verify()) .assertFailure() @@ -27,17 +27,17 @@ public void basicGetterAbsent() { } @Test - public void basicGetterNotUsed_givenEagerLoading() { + void basicGetterNotUsed_givenEagerLoading() { EqualsVerifier.forClass(CorrectBasicJpaEagerFieldContainer.class).verify(); } @Test - public void basicGetterNotUsed_givenCorrespondingFieldIgnored() { + void basicGetterNotUsed_givenCorrespondingFieldIgnored() { EqualsVerifier.forClass(CorrectBasicJpaIgnoredLazyFieldContainer.class).withIgnoredFields("basic").verify(); } @Test - public void basicGetterNotUsed_givenWarningSuppressed() { + void basicGetterNotUsed_givenWarningSuppressed() { EqualsVerifier .forClass(CorrectBasicJpaIgnoredLazyFieldContainer.class) .suppress(Warning.ALL_FIELDS_SHOULD_BE_USED) @@ -45,66 +45,66 @@ public void basicGetterNotUsed_givenWarningSuppressed() { } @Test - public void basicGetterNotUsed_givenAnnotationIsOnGetter() { + void basicGetterNotUsed_givenAnnotationIsOnGetter() { getterNotUsed(IncorrectBasicJpaLazyGetterContainer.class, "equals"); getterNotUsed_warningSuppressed(IncorrectBasicJpaLazyGetterContainer.class); } @Test - public void basicGetterNotUsedInHashCode() { + void basicGetterNotUsedInHashCode() { getterNotUsed(IncorrectBasicJpaLazyFieldContainerHashCode.class, "hashCode"); getterNotUsed_warningSuppressed(IncorrectBasicJpaLazyFieldContainerHashCode.class); } @Test - public void basicGetterNotUsed() { + void basicGetterNotUsed() { getterNotUsed(IncorrectBasicJpaLazyFieldContainer.class, "equals"); getterNotUsed_warningSuppressed(IncorrectBasicJpaLazyFieldContainer.class); } @Test - public void oneToOneGetterNotUsed() { + void oneToOneGetterNotUsed() { getterNotUsed(IncorrectOneToOneJpaLazyFieldContainer.class, "equals"); getterNotUsed_warningSuppressed(IncorrectOneToOneJpaLazyFieldContainer.class); } @Test - public void oneToManyGetterNotUsed() { + void oneToManyGetterNotUsed() { getterNotUsed(IncorrectOneToManyJpaLazyFieldContainer.class, "equals"); getterNotUsed_warningSuppressed(IncorrectOneToManyJpaLazyFieldContainer.class); } @Test - public void manyToOneGetterNotUsed() { + void manyToOneGetterNotUsed() { getterNotUsed(IncorrectManyToOneJpaLazyFieldContainer.class, "equals"); getterNotUsed_warningSuppressed(IncorrectManyToOneJpaLazyFieldContainer.class); } @Test - public void manyToManyGetterNotUsed() { + void manyToManyGetterNotUsed() { getterNotUsed(IncorrectManyToManyJpaLazyFieldContainer.class, "equals"); getterNotUsed_warningSuppressed(IncorrectManyToManyJpaLazyFieldContainer.class); } @Test - public void elementCollectionGetterNotUsed() { + void elementCollectionGetterNotUsed() { getterNotUsed(IncorrectElementCollectionJpaLazyFieldContainer.class, "equals"); getterNotUsed_warningSuppressed(IncorrectElementCollectionJpaLazyFieldContainer.class); } @Test - public void lazyGettersPickedUpInSuper() { + void lazyGettersPickedUpInSuper() { EqualsVerifier.forClass(LazyGetterContainer.class).usingGetClass().verify(); EqualsVerifier.forClass(ChildOfLazyGetterContainer.class).usingGetClass().verify(); } @Test - public void constantHashCode_givenStrictHashCodeSuppressed() { + void constantHashCode_givenStrictHashCodeSuppressed() { EqualsVerifier.forClass(ConstantHashCodeContainer.class).suppress(Warning.STRICT_HASHCODE).verify(); } @Test - public void differentCodingStyle_single() { + void differentCodingStyle_single() { EqualsVerifier .forClass(DifferentCodingStyleContainer.class) .withFieldnameToGetterConverter(fn -> "get" + Character.toUpperCase(fn.charAt(2)) + fn.substring(3)) @@ -112,7 +112,7 @@ public void differentCodingStyle_single() { } @Test - public void differentCodingStyle_configured() { + void differentCodingStyle_configured() { EqualsVerifier .configure() .withFieldnameToGetterConverter(fn -> "get" + Character.toUpperCase(fn.charAt(2)) + fn.substring(3)) @@ -121,7 +121,7 @@ public void differentCodingStyle_configured() { } @Test - public void differentCodingStyle_multiple() { + void differentCodingStyle_multiple() { EqualsVerifier .forClasses(Arrays.asList(DifferentCodingStyleContainer.class)) .withFieldnameToGetterConverter(fn -> "get" + Character.toUpperCase(fn.charAt(2)) + fn.substring(3)) @@ -129,7 +129,7 @@ public void differentCodingStyle_multiple() { } @Test - public void getterUsedForGeneratedId() { + void getterUsedForGeneratedId() { EqualsVerifier.forClass(CorrectGeneratedJpaIdContainer.class).suppress(Warning.SURROGATE_KEY).verify(); EqualsVerifier .forClass(CorrectGeneratedJpaIdContainer.class) @@ -138,7 +138,7 @@ public void getterUsedForGeneratedId() { } @Test - public void getterNotUsedForGeneratedId() { + void getterNotUsedForGeneratedId() { getterNotUsed(IncorrectGeneratedJpaIdContainer.class, "equals", Warning.SURROGATE_KEY); getterNotUsed_warningSuppressed(IncorrectGeneratedJpaIdContainer.class, Warning.SURROGATE_KEY); getterNotUsed(IncorrectGeneratedJpaIdContainer.class, "equals", Warning.SURROGATE_OR_BUSINESS_KEY); @@ -146,12 +146,12 @@ public void getterNotUsedForGeneratedId() { } @Test - public void gettersAreUsedAndProtected() { + void gettersAreUsedAndProtected() { EqualsVerifier.forClass(ProtectedJpaLazyFieldContainer.class).verify(); } @Test - public void finalEntitiesArentLazy() { + void finalEntitiesArentLazy() { EqualsVerifier.forClass(FinalEntity.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/LombokLazyEqualsAndHashcodeTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/LombokLazyEqualsAndHashcodeTest.java index 981ecbb44..e99eeb868 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/LombokLazyEqualsAndHashcodeTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/LombokLazyEqualsAndHashcodeTest.java @@ -12,10 +12,10 @@ // CHECKSTYLE OFF: MemberName // CHECKSTYLE OFF: NeedBraces -public class LombokLazyEqualsAndHashcodeTest { +class LombokLazyEqualsAndHashcodeTest { @Test - void testWithLombokCachedHashCode() { + void withLombokCachedHashCode() { EqualsVerifier .forClass(LazyPojo.class) .withLombokCachedHashCode(new LazyPojo("a", new Object())) @@ -24,7 +24,7 @@ void testWithLombokCachedHashCode() { } @Test - void testDefaultEqualsVerifierFailsForCachedLombokEqualsAndHashcode() { + void defaultEqualsVerifierFailsForCachedLombokEqualsAndHashcode() { final AssertionError error = assertThrows( AssertionError.class, () -> EqualsVerifier.forClass(LazyPojo.class).suppress(Warning.STRICT_INHERITANCE).verify()); @@ -32,7 +32,7 @@ void testDefaultEqualsVerifierFailsForCachedLombokEqualsAndHashcode() { } @Test - void testDefaultEqualsVerifierFailsForCachedLombokEqualsAndHashcodeWhenUsingWithCachedHashCode() { + void defaultEqualsVerifierFailsForCachedLombokEqualsAndHashcodeWhenUsingWithCachedHashCode() { final IllegalArgumentException error = assertThrows( IllegalArgumentException.class, () -> EqualsVerifier diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/RelaxedEqualsPreconditionTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/RelaxedEqualsPreconditionTest.java index 4afc6d2ea..36a0d2fc8 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/RelaxedEqualsPreconditionTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/RelaxedEqualsPreconditionTest.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class RelaxedEqualsPreconditionTest { +class RelaxedEqualsPreconditionTest { private static final String PRECONDITION = "Precondition"; private static final String DIFFERENT_CLASSES = "are of different classes"; @@ -21,14 +21,14 @@ public class RelaxedEqualsPreconditionTest { private Multiple green; @BeforeEach - public void setup() { + void setup() { red = new Multiple(1, 2); blue = new Multiple(2, 1); green = new Multiple(2, 2); } @Test - public void throw_whenTheFirstExampleIsNull() { + void throw_whenTheFirstExampleIsNull() { ExpectedException .when(() -> EqualsVerifier.forRelaxedEqualExamples(null, blue)) .assertThrows(IllegalArgumentException.class) @@ -36,7 +36,7 @@ public void throw_whenTheFirstExampleIsNull() { } @Test - public void throw_whenTheSecondExampleIsNull() { + void throw_whenTheSecondExampleIsNull() { ExpectedException .when(() -> EqualsVerifier.forRelaxedEqualExamples(red, null)) .assertThrows(IllegalArgumentException.class) @@ -44,12 +44,12 @@ public void throw_whenTheSecondExampleIsNull() { } @Test - public void succeed_whenTheVarargArrayIsNull() { + void succeed_whenTheVarargArrayIsNull() { EqualsVerifier.forRelaxedEqualExamples(red, blue, (Multiple[]) null).andUnequalExample(green).verify(); } @Test - public void fail_whenAVarargParameterIsNull() { + void fail_whenAVarargParameterIsNull() { Multiple another = new Multiple(-1, -2); ExpectedException .when(() -> EqualsVerifier.forRelaxedEqualExamples(red, blue, another, null)) @@ -58,7 +58,7 @@ public void fail_whenAVarargParameterIsNull() { } @Test - public void fail_whenTheUnequalExampleIsNull() { + void fail_whenTheUnequalExampleIsNull() { ExpectedException .when(() -> EqualsVerifier.forRelaxedEqualExamples(red, blue).andUnequalExample(null)) .assertThrows(IllegalArgumentException.class) @@ -66,12 +66,12 @@ public void fail_whenTheUnequalExampleIsNull() { } @Test - public void succeed_whenTheUnequalVarargArrayIsNull() { + void succeed_whenTheUnequalVarargArrayIsNull() { EqualsVerifier.forRelaxedEqualExamples(red, blue).andUnequalExamples(green, (Multiple[]) null).verify(); } @Test - public void fail_whenAnUnequalVarargParameterIsNull() { + void fail_whenAnUnequalVarargParameterIsNull() { Multiple another = new Multiple(3, 3); ExpectedException .when(() -> EqualsVerifier.forRelaxedEqualExamples(red, blue).andUnequalExamples(green, another, null)) @@ -79,7 +79,7 @@ public void fail_whenAnUnequalVarargParameterIsNull() { } @Test - public void fail_whenEqualExamplesAreOfDifferentRuntimeTypes() { + void fail_whenEqualExamplesAreOfDifferentRuntimeTypes() { SubMultiple sm = new SubMultiple(1, 2); ExpectedException .when(() -> EqualsVerifier.forRelaxedEqualExamples(sm, red).andUnequalExample(green).verify()) @@ -92,7 +92,7 @@ public void fail_whenEqualExamplesAreOfDifferentRuntimeTypes() { } @Test - public void fail_whenTheSameExampleIsGivenTwice() { + void fail_whenTheSameExampleIsGivenTwice() { ExpectedException .when(() -> EqualsVerifier.forRelaxedEqualExamples(red, red).andUnequalExample(green).verify()) .assertFailure() @@ -100,7 +100,7 @@ public void fail_whenTheSameExampleIsGivenTwice() { } @Test - public void fail_whenTwoExamplesAreIdentical() { + void fail_whenTwoExamplesAreIdentical() { Multiple aa = new Multiple(1, 2); ExpectedException .when(() -> EqualsVerifier.forRelaxedEqualExamples(red, aa).andUnequalExample(green).verify()) @@ -109,7 +109,7 @@ public void fail_whenTwoExamplesAreIdentical() { } @Test - public void fail_whenTwoExamplesAreNotEqualAtAll() { + void fail_whenTwoExamplesAreNotEqualAtAll() { Multiple aa = new Multiple(42, 42); ExpectedException .when(() -> EqualsVerifier.forRelaxedEqualExamples(red, aa).andUnequalExample(green).verify()) @@ -118,7 +118,7 @@ public void fail_whenTwoExamplesAreNotEqualAtAll() { } @Test - public void fail_whenAnEqualExampleIsAlsoGivenAsAnUnequalExample() { + void fail_whenAnEqualExampleIsAlsoGivenAsAnUnequalExample() { ExpectedException .when(() -> EqualsVerifier.forRelaxedEqualExamples(red, green).andUnequalExample(green)) .assertThrows(IllegalStateException.class) @@ -126,7 +126,7 @@ public void fail_whenAnEqualExampleIsAlsoGivenAsAnUnequalExample() { } @Test - public void fail_whenTheSameUnequalExampleIsGivenTwice() { + void fail_whenTheSameUnequalExampleIsGivenTwice() { ExpectedException .when(() -> EqualsVerifier.forRelaxedEqualExamples(red, blue).andUnequalExamples(green, green)) .assertThrows(IllegalStateException.class) @@ -134,7 +134,7 @@ public void fail_whenTheSameUnequalExampleIsGivenTwice() { } @Test - public void fail_whenTwoUnequalExamplesAreEqualToEachOther() { + void fail_whenTwoUnequalExamplesAreEqualToEachOther() { Multiple xx = new Multiple(2, 2); ExpectedException .when(() -> EqualsVerifier.forRelaxedEqualExamples(red, blue).andUnequalExamples(green, xx)) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/RelaxedEqualsTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/RelaxedEqualsTest.java index c2a23e19a..e3132458e 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/RelaxedEqualsTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/RelaxedEqualsTest.java @@ -6,21 +6,21 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class RelaxedEqualsTest { +class RelaxedEqualsTest { private Multiple a; private Multiple b; private Multiple x; @BeforeEach - public void setup() { + void setup() { a = new Multiple(1, 2); b = new Multiple(2, 1); x = new Multiple(2, 2); } @Test - public void fail_whenObjectsWithDifferentFieldsAreEqual() { + void fail_whenObjectsWithDifferentFieldsAreEqual() { ExpectedException .when(() -> EqualsVerifier.forClass(Multiple.class).verify()) .assertFailure() @@ -28,12 +28,12 @@ public void fail_whenObjectsWithDifferentFieldsAreEqual() { } @Test - public void succeed_whenObjectsWithDifferentFieldsAreEqual_givenTheyAreGivenAsRelaxedEqualExamples() { + void succeed_whenObjectsWithDifferentFieldsAreEqual_givenTheyAreGivenAsRelaxedEqualExamples() { EqualsVerifier.forRelaxedEqualExamples(a, b).andUnequalExample(x).verify(); } @Test - public void fail_whenTheSameObjectIsGivenAsAnUnequalExample() { + void fail_whenTheSameObjectIsGivenAsAnUnequalExample() { ExpectedException .when(() -> EqualsVerifier.forRelaxedEqualExamples(a, b).andUnequalExamples(a)) .assertThrows(IllegalStateException.class) @@ -41,7 +41,7 @@ public void fail_whenTheSameObjectIsGivenAsAnUnequalExample() { } @Test - public void succeed_whenAnUnusedFieldIsNull_givenItIsGivenAsARelaxedEqualExample() { + void succeed_whenAnUnusedFieldIsNull_givenItIsGivenAsARelaxedEqualExample() { EqualsVerifier .forRelaxedEqualExamples(new NullContainingSubMultiple(1, 2), new NullContainingSubMultiple(2, 1)) .andUnequalExample(new NullContainingSubMultiple(2, 2)) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/SimpleEqualsVerifierTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/SimpleEqualsVerifierTest.java index abe6d9f11..b2afb748f 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/SimpleEqualsVerifierTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/SimpleEqualsVerifierTest.java @@ -8,15 +8,15 @@ import nl.jqno.equalsverifier.testhelpers.types.Color; import org.junit.jupiter.api.Test; -public class SimpleEqualsVerifierTest { +class SimpleEqualsVerifierTest { @Test - public void succeed_whenTestingClass_givenASimpleEqualsVerifier() { + void succeed_whenTestingClass_givenASimpleEqualsVerifier() { EqualsVerifier.simple().forClass(SimplePoint.class).verify(); } @Test - public void succeed_whenTestingClassesRecursively_givenASimpleEqualsVerifier() { + void succeed_whenTestingClassesRecursively_givenASimpleEqualsVerifier() { EqualsVerifier .simple() .forPackage("nl.jqno.equalsverifier.integration.extra_features.simple_package", true) @@ -24,7 +24,7 @@ public void succeed_whenTestingClassesRecursively_givenASimpleEqualsVerifier() { } @Test - public void succeed_whenTestingClassesThatMustExtendSomething_givenASimpleEqualsVerifier() { + void succeed_whenTestingClassesThatMustExtendSomething_givenASimpleEqualsVerifier() { EqualsVerifier .simple() .forPackage("nl.jqno.equalsverifier.integration.extra_features.simple_package", Object.class) @@ -32,7 +32,7 @@ public void succeed_whenTestingClassesThatMustExtendSomething_givenASimpleEquals } @Test - public void mentionSimple_whenTestingClass_givenNothingSpecial() { + void mentionSimple_whenTestingClass_givenNothingSpecial() { ExpectedException .when(() -> EqualsVerifier.forClass(SimplePoint.class).verify()) .assertFailure() @@ -40,7 +40,7 @@ public void mentionSimple_whenTestingClass_givenNothingSpecial() { } @Test - public void mentionSimple_whenTestingClassesRecursively_givenNothingSpecial() { + void mentionSimple_whenTestingClassesRecursively_givenNothingSpecial() { ExpectedException .when( () -> EqualsVerifier @@ -51,7 +51,7 @@ public void mentionSimple_whenTestingClassesRecursively_givenNothingSpecial() { } @Test - public void mentionSimple_whenTestingClassesThatMustExtendSomething_givenNothingSpecial() { + void mentionSimple_whenTestingClassesThatMustExtendSomething_givenNothingSpecial() { ExpectedException .when( () -> EqualsVerifier @@ -64,7 +64,7 @@ public void mentionSimple_whenTestingClassesThatMustExtendSomething_givenNothing } @Test - public void mentionSimple_whenTestingClass_givenSuppressWarningStrictInheritance() { + void mentionSimple_whenTestingClass_givenSuppressWarningStrictInheritance() { ExpectedException .when(() -> EqualsVerifier.forClass(SimplePoint.class).suppress(Warning.STRICT_INHERITANCE).verify()) .assertFailure() @@ -72,7 +72,7 @@ public void mentionSimple_whenTestingClass_givenSuppressWarningStrictInheritance } @Test - public void fail_whenTestingClassesRecursively_whenPackageHasNoClasses() { + void fail_whenTestingClassesRecursively_whenPackageHasNoClasses() { ExpectedException .when(() -> EqualsVerifier.simple().forPackage("nl.jqno.equalsverifier.doesnotexist", true).verify()) .assertThrows(IllegalStateException.class) @@ -80,7 +80,7 @@ public void fail_whenTestingClassesRecursively_whenPackageHasNoClasses() { } @Test - public void fail_whenTestingClassesThatMustExtendSomething_whenPackageHasNoClasses() { + void fail_whenTestingClassesThatMustExtendSomething_whenPackageHasNoClasses() { ExpectedException .when( () -> EqualsVerifier diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/VersionedEntityTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/VersionedEntityTest.java index 5befe5363..d4e652ce5 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/VersionedEntityTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/VersionedEntityTest.java @@ -14,10 +14,10 @@ // CHECKSTYLE OFF: LineLength -public class VersionedEntityTest { +class VersionedEntityTest { @Test - public void fail_whenInstanceWithAZeroIdDoesNotEqualItself() { + void fail_whenInstanceWithAZeroIdDoesNotEqualItself() { ExpectedException .when(() -> EqualsVerifier.forClass(OtherwiseStatelessVersionedEntity.class).verify()) .assertFailure() @@ -27,7 +27,7 @@ public void fail_whenInstanceWithAZeroIdDoesNotEqualItself() { } @Test - public void fail_whenInstanceWithANonzeroIdEqualsItself_givenIdenticalCopyWarningIsSuppressed() { + void fail_whenInstanceWithANonzeroIdEqualsItself_givenIdenticalCopyWarningIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -39,7 +39,7 @@ public void fail_whenInstanceWithANonzeroIdEqualsItself_givenIdenticalCopyWarnin } @Test - public void succeed_whenInstanceWithAZeroIdDoesNotEqualItselfAndInstanceWithANonzeroIdDoes_givenVersionedEntityWarningIsSuppressed() { + void succeed_whenInstanceWithAZeroIdDoesNotEqualItselfAndInstanceWithANonzeroIdDoes_givenVersionedEntityWarningIsSuppressed() { EqualsVerifier .forClass(OtherwiseStatelessVersionedEntity.class) .suppress(Warning.IDENTICAL_COPY_FOR_VERSIONED_ENTITY, Warning.SURROGATE_KEY) @@ -47,7 +47,7 @@ public void succeed_whenInstanceWithAZeroIdDoesNotEqualItselfAndInstanceWithANon } @Test - public void fail_whenInstanceWithAZeroIdDoesNotEqualItself_givenAVersionedEntityWithState() { + void fail_whenInstanceWithAZeroIdDoesNotEqualItself_givenAVersionedEntityWithState() { ExpectedException .when(() -> EqualsVerifier.forClass(LongIdStringFieldVersionedEntity.class).verify()) .assertFailure() @@ -57,7 +57,7 @@ public void fail_whenInstanceWithAZeroIdDoesNotEqualItself_givenAVersionedEntity } @Test - public void fail_whenInstanceWithANonzeroIdEqualsItself_givenAVersionedEntityWithStateAndIdenticalCopyWarningIsSuppressed() { + void fail_whenInstanceWithANonzeroIdEqualsItself_givenAVersionedEntityWithStateAndIdenticalCopyWarningIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -69,7 +69,7 @@ public void fail_whenInstanceWithANonzeroIdEqualsItself_givenAVersionedEntityWit } @Test - public void succeed_whenInstanceWithAZeroIdDoesNotEqualItselfAndInstanceWithANonzeroIdDoes_givenAVersionedEntityWithStateAndVersionedEntityWarningIsSuppressed() { + void succeed_whenInstanceWithAZeroIdDoesNotEqualItselfAndInstanceWithANonzeroIdDoes_givenAVersionedEntityWithStateAndVersionedEntityWarningIsSuppressed() { EqualsVerifier .forClass(LongIdStringFieldVersionedEntity.class) .suppress(Warning.IDENTICAL_COPY_FOR_VERSIONED_ENTITY, Warning.SURROGATE_KEY) @@ -77,7 +77,7 @@ public void succeed_whenInstanceWithAZeroIdDoesNotEqualItselfAndInstanceWithANon } @Test - public void fail_whenInstanceWithANullIdDoesNotEqualItself_givenAVersionedEntityWithState() { + void fail_whenInstanceWithANullIdDoesNotEqualItself_givenAVersionedEntityWithState() { ExpectedException .when(() -> EqualsVerifier.forClass(UuidIdStringFieldVersionedEntity.class).verify()) .assertFailure() @@ -87,7 +87,7 @@ public void fail_whenInstanceWithANullIdDoesNotEqualItself_givenAVersionedEntity } @Test - public void fail_whenInstanceWithANonnullIdEqualsItself_givenAVersionedEntityWithStateAndIdenticalCopyWarningIsSuppressed() { + void fail_whenInstanceWithANonnullIdEqualsItself_givenAVersionedEntityWithStateAndIdenticalCopyWarningIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -99,7 +99,7 @@ public void fail_whenInstanceWithANonnullIdEqualsItself_givenAVersionedEntityWit } @Test - public void succeed_whenInstanceWithANullIdDoesNotEqualItselfAndInstanceWithANonnullIdDoes_givenAVersionedEntityWithStateAndVersionedEntityWarningIsSuppressed() { + void succeed_whenInstanceWithANullIdDoesNotEqualItselfAndInstanceWithANonnullIdDoes_givenAVersionedEntityWithStateAndVersionedEntityWarningIsSuppressed() { EqualsVerifier .forClass(UuidIdStringFieldVersionedEntity.class) .suppress(Warning.IDENTICAL_COPY_FOR_VERSIONED_ENTITY, Warning.SURROGATE_KEY) @@ -107,7 +107,7 @@ public void succeed_whenInstanceWithANullIdDoesNotEqualItselfAndInstanceWithANon } @Test - public void fail_whenInstanceWithAZeroIdCanEqualItselfAndInstanceWithANonzeroIdAlso_givenAVersionedEntityWithState() { + void fail_whenInstanceWithAZeroIdCanEqualItselfAndInstanceWithANonzeroIdAlso_givenAVersionedEntityWithState() { ExpectedException .when(() -> EqualsVerifier.forClass(WeakStringVersionedEntity.class).verify()) .assertFailure() @@ -115,7 +115,7 @@ public void fail_whenInstanceWithAZeroIdCanEqualItselfAndInstanceWithANonzeroIdA } @Test - public void succeed_whenInstanceWithAZeroIdCanEqualItselfAndInstanceWithANonzeroIdAlso_givenAVersionedEntityWithStateAndVersionedEntityWarningIsSuppressed() { + void succeed_whenInstanceWithAZeroIdCanEqualItselfAndInstanceWithANonzeroIdAlso_givenAVersionedEntityWithStateAndVersionedEntityWarningIsSuppressed() { EqualsVerifier .forClass(WeakStringVersionedEntity.class) .suppress(Warning.IDENTICAL_COPY_FOR_VERSIONED_ENTITY, Warning.SURROGATE_KEY) @@ -123,12 +123,12 @@ public void succeed_whenInstanceWithAZeroIdCanEqualItselfAndInstanceWithANonzero } @Test - public void succeed_whenInstanceWithAZeroIdCanEqualItselfAndInstanceWithANonzeroIdAlso_givenAVersionedEntityWithStateAndAllFieldsWarningIsSuppressed() { + void succeed_whenInstanceWithAZeroIdCanEqualItselfAndInstanceWithANonzeroIdAlso_givenAVersionedEntityWithStateAndAllFieldsWarningIsSuppressed() { EqualsVerifier.forClass(WeakStringVersionedEntity.class).suppress(Warning.ALL_FIELDS_SHOULD_BE_USED).verify(); } @Test - public void succeed_whenInstanceWithANullableIdDoesNullCheck_givenAVersionedEntityWithStateAndVersionedEntityWarningIsSuppressed() { + void succeed_whenInstanceWithANullableIdDoesNullCheck_givenAVersionedEntityWithStateAndVersionedEntityWarningIsSuppressed() { EqualsVerifier .forClass(NullCheckStringVersionedEntity.class) .suppress(Warning.IDENTICAL_COPY_FOR_VERSIONED_ENTITY, Warning.SURROGATE_KEY) @@ -136,7 +136,7 @@ public void succeed_whenInstanceWithANullableIdDoesNullCheck_givenAVersionedEnti } @Test - public void succeed_whenEntityWithABusinessKey_givenAVersionedEntityWithStateAndVersionedEntityWarningIsSuppressed() { + void succeed_whenEntityWithABusinessKey_givenAVersionedEntityWithStateAndVersionedEntityWarningIsSuppressed() { EqualsVerifier .forClass(BusinessKeyStringVersionedEntity.class) .suppress(Warning.IDENTICAL_COPY_FOR_VERSIONED_ENTITY) @@ -144,12 +144,12 @@ public void succeed_whenEntityWithABusinessKey_givenAVersionedEntityWithStateAnd } @Test - public void succeed_whenTheParentOfTheVersionedEntityIsCheckedForSanity() { + void succeed_whenTheParentOfTheVersionedEntityIsCheckedForSanity() { EqualsVerifier.forClass(CanEqualVersionedEntity.class).verify(); } @Test - public void fail_whenAnExceptionIsThrownInADifficultToReachPartOfTheSubclassOfAVersionedEntity() { + void fail_whenAnExceptionIsThrownInADifficultToReachPartOfTheSubclassOfAVersionedEntity() { ExpectedException .when(() -> EqualsVerifier.forClass(NonReflexiveCanEqualVersionedEntity.class).verify()) .assertFailure() @@ -157,7 +157,7 @@ public void fail_whenAnExceptionIsThrownInADifficultToReachPartOfTheSubclassOfAV } @Test - public void fail_whenTheExceptionIsThrownInADifficultToReachPartOfTheSubclassOfAVersionedEntity_givenVersionedEntityWarningIsSuppressed() { + void fail_whenTheExceptionIsThrownInADifficultToReachPartOfTheSubclassOfAVersionedEntity_givenVersionedEntityWarningIsSuppressed() { ExpectedException .when( () -> EqualsVerifier diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/WarningsMixTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/WarningsMixTest.java index 36d8414f8..26a4c2533 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/WarningsMixTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extra_features/WarningsMixTest.java @@ -7,10 +7,10 @@ import nl.jqno.equalsverifier.testhelpers.types.MutablePoint; import org.junit.jupiter.api.Test; -public class WarningsMixTest { +class WarningsMixTest { @Test - public void fail_whenFieldsAreNonfinalAndClassIsNonfinal_givenOnlyStrictInheritanceWarningIsSuppressed() { + void fail_whenFieldsAreNonfinalAndClassIsNonfinal_givenOnlyStrictInheritanceWarningIsSuppressed() { ExpectedException .when(() -> EqualsVerifier.forClass(MutablePoint.class).suppress(Warning.STRICT_INHERITANCE).verify()) .assertFailure() @@ -18,7 +18,7 @@ public void fail_whenFieldsAreNonfinalAndClassIsNonfinal_givenOnlyStrictInherita } @Test - public void fail_whenFieldsAreNonFinalAndClassIsNonFinal_givenOnlyNonfinalFieldsWarningIsSuppressed() { + void fail_whenFieldsAreNonFinalAndClassIsNonFinal_givenOnlyNonfinalFieldsWarningIsSuppressed() { ExpectedException .when(() -> EqualsVerifier.forClass(MutablePoint.class).suppress(Warning.NONFINAL_FIELDS).verify()) .assertFailure() @@ -26,7 +26,7 @@ public void fail_whenFieldsAreNonFinalAndClassIsNonFinal_givenOnlyNonfinalFields } @Test - public void succeed_whenFieldsAreNonfinalAndClassIsNonfinal_givenBothStrictInheritanceAndNonfinalFieldsWarningsAreSuppressed() { + void succeed_whenFieldsAreNonfinalAndClassIsNonfinal_givenBothStrictInheritanceAndNonfinalFieldsWarningsAreSuppressed() { EqualsVerifier .forClass(MutablePoint.class) .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS) @@ -34,7 +34,7 @@ public void succeed_whenFieldsAreNonfinalAndClassIsNonfinal_givenBothStrictInher } @Test - public void fail_whenClassIsNonfinalAndEqualsDoesNotCheckNull_givenOnlyStrictInheritanceWarningIsSuppressed() { + void fail_whenClassIsNonfinalAndEqualsDoesNotCheckNull_givenOnlyStrictInheritanceWarningIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -47,7 +47,7 @@ public void fail_whenClassIsNonfinalAndEqualsDoesNotCheckNull_givenOnlyStrictInh } @Test - public void fail_whenClassIsNonfinalAndEqualsDoesNotCheckNull_givenOnlyNullFieldsWarningIsSuppressed() { + void fail_whenClassIsNonfinalAndEqualsDoesNotCheckNull_givenOnlyNullFieldsWarningIsSuppressed() { ExpectedException .when( () -> EqualsVerifier.forClass(NeverNullColorContainer.class).suppress(Warning.NULL_FIELDS).verify()) @@ -56,7 +56,7 @@ public void fail_whenClassIsNonfinalAndEqualsDoesNotCheckNull_givenOnlyNullField } @Test - public void succeed_whenClassIsNonfinalAndEqualsDoesNotCheckNull_givenBothStrictInheritanceAndNullFieldsWarningsAreSuppressed() { + void succeed_whenClassIsNonfinalAndEqualsDoesNotCheckNull_givenBothStrictInheritanceAndNullFieldsWarningsAreSuppressed() { EqualsVerifier .forClass(NeverNullColorContainer.class) .suppress(Warning.STRICT_INHERITANCE, Warning.NULL_FIELDS) @@ -64,7 +64,7 @@ public void succeed_whenClassIsNonfinalAndEqualsDoesNotCheckNull_givenBothStrict } @Test - public void succeed_whenWarningsAreSuppressedSeparately_givenBothWarningsNeedToBeSuppressed() { + void succeed_whenWarningsAreSuppressedSeparately_givenBothWarningsNeedToBeSuppressed() { EqualsVerifier .forClass(NeverNullColorContainer.class) .suppress(Warning.STRICT_INHERITANCE) @@ -73,7 +73,7 @@ public void succeed_whenWarningsAreSuppressedSeparately_givenBothWarningsNeedToB } @Test - public void fail_whenClassIsNonfinalAndFieldsAreNonfinalAndEqualsDoesNotCheckNull_givenOnlyStrictInheritanceAndNullFieldsWarningsAreSuppressed() { + void fail_whenClassIsNonfinalAndFieldsAreNonfinalAndEqualsDoesNotCheckNull_givenOnlyStrictInheritanceAndNullFieldsWarningsAreSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -85,7 +85,7 @@ public void fail_whenClassIsNonfinalAndFieldsAreNonfinalAndEqualsDoesNotCheckNul } @Test - public void fail_whenClassAndFieldsAreNonfinalAndEqualsDoesNotCheckNull_givenOnlyStrictInheritanceAndNonfinalFieldsWarningsAreSuppressed() { + void fail_whenClassAndFieldsAreNonfinalAndEqualsDoesNotCheckNull_givenOnlyStrictInheritanceAndNonfinalFieldsWarningsAreSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -98,7 +98,7 @@ public void fail_whenClassAndFieldsAreNonfinalAndEqualsDoesNotCheckNull_givenOnl } @Test - public void fail_whenClassIsNonfinalAndFieldsAreNonfinalAndEqualsDoesNotCheckNull_givenOnlyNonfinalFieldsAndNullFieldsWarningsAreSuppressed() { + void fail_whenClassIsNonfinalAndFieldsAreNonfinalAndEqualsDoesNotCheckNull_givenOnlyNonfinalFieldsAndNullFieldsWarningsAreSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -110,7 +110,7 @@ public void fail_whenClassIsNonfinalAndFieldsAreNonfinalAndEqualsDoesNotCheckNul } @Test - public void succeed_whenClassIsNonfinalAndFieldsAreNonfinalAndEqualsDoesNotCheckNull_givenAllNecessaryWarningsAreSuppressed() { + void succeed_whenClassIsNonfinalAndFieldsAreNonfinalAndEqualsDoesNotCheckNull_givenAllNecessaryWarningsAreSuppressed() { EqualsVerifier .forClass(NeverNullAndMutableColorContainer.class) .suppress(Warning.STRICT_INHERITANCE, Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/AbstractHierarchyTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/AbstractHierarchyTest.java index 8db2941b1..98cf65d5f 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/AbstractHierarchyTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/AbstractHierarchyTest.java @@ -8,15 +8,15 @@ import nl.jqno.equalsverifier.testhelpers.types.Color; import org.junit.jupiter.api.Test; -public class AbstractHierarchyTest { +class AbstractHierarchyTest { @Test - public void succeed_whenEqualsAndHashCodeAreFinal_givenClassIsAbstract() { + void succeed_whenEqualsAndHashCodeAreFinal_givenClassIsAbstract() { EqualsVerifier.forClass(AbstractFinalMethodsPoint.class).verify(); } @Test - public void succeed_whenAnImplementingClassWithCorrectlyImplementedEquals_givenClassIsAbstract() { + void succeed_whenAnImplementingClassWithCorrectlyImplementedEquals_givenClassIsAbstract() { EqualsVerifier .forClass(AbstractRedefinablePoint.class) .withRedefinedSubclass(FinalRedefinedPoint.class) @@ -24,7 +24,7 @@ public void succeed_whenAnImplementingClassWithCorrectlyImplementedEquals_givenC } @Test - public void fail_whenEqualsThrowsNull_givenClassIsAbstract() { + void fail_whenEqualsThrowsNull_givenClassIsAbstract() { ExpectedException .when(() -> EqualsVerifier.forClass(NullThrowingColorContainer.class).verify()) .assertFailure() @@ -33,12 +33,12 @@ public void fail_whenEqualsThrowsNull_givenClassIsAbstract() { } @Test - public void succeed_whenEqualsThrowsNull_givenClassIsAbstractAndWarningIsSuppressed() { + void succeed_whenEqualsThrowsNull_givenClassIsAbstractAndWarningIsSuppressed() { EqualsVerifier.forClass(NullThrowingColorContainer.class).suppress(Warning.NULL_FIELDS).verify(); } @Test - public void fail_whenAbstractImplementationThrowsNpe() { + void fail_whenAbstractImplementationThrowsNpe() { ExpectedException .when( () -> EqualsVerifier @@ -52,7 +52,7 @@ public void fail_whenAbstractImplementationThrowsNpe() { } @Test - public void succeed_whenAbstractImplementationThrowsNpe_givenWarningIsSuppressed() { + void succeed_whenAbstractImplementationThrowsNpe_givenWarningIsSuppressed() { EqualsVerifier .forClass(NullThrowingLazyObjectContainer.class) .suppress(Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/FinalityTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/FinalityTest.java index 86bbb71df..3c3a34817 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/FinalityTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/FinalityTest.java @@ -8,7 +8,7 @@ import nl.jqno.equalsverifier.testhelpers.types.Point; import org.junit.jupiter.api.Test; -public class FinalityTest { +class FinalityTest { private static final String BOTH_FINAL_OR_NONFINAL = "Finality: equals and hashCode must both be final or both be non-final"; @@ -17,12 +17,12 @@ public class FinalityTest { "Make your class or your %s method final, or supply an instance of a redefined subclass using withRedefinedSubclass"; @Test - public void fail_whenEqualsIsFinalButHashCodeIsNonFinal() { + void fail_whenEqualsIsFinalButHashCodeIsNonFinal() { check(FinalEqualsNonFinalHashCode.class); } @Test - public void fail_whenEqualsIsNotFinal_givenAClassThatIsNotFinal() { + void fail_whenEqualsIsNotFinal_givenAClassThatIsNotFinal() { ExpectedException .when(() -> EqualsVerifier.forClass(Point.class).verify()) .assertFailure() @@ -34,7 +34,7 @@ public void fail_whenEqualsIsNotFinal_givenAClassThatIsNotFinal() { } @Test - public void succeed_whenEqualsIsFinalButHashCodeIsNonFinal_givenWarningIsSuppressed() { + void succeed_whenEqualsIsFinalButHashCodeIsNonFinal_givenWarningIsSuppressed() { EqualsVerifier .forClass(FinalEqualsNonFinalHashCode.class) .usingGetClass() @@ -43,17 +43,17 @@ public void succeed_whenEqualsIsFinalButHashCodeIsNonFinal_givenWarningIsSuppres } @Test - public void succeed_whenEqualsIsNotFinal_givenAClassThatIsNotFinalAndWarningIsSuppressed() { + void succeed_whenEqualsIsNotFinal_givenAClassThatIsNotFinalAndWarningIsSuppressed() { EqualsVerifier.forClass(Point.class).suppress(Warning.STRICT_INHERITANCE).verify(); } @Test - public void fail_whenEqualsIsNonFinalButHashCodeIsFinal() { + void fail_whenEqualsIsNonFinalButHashCodeIsFinal() { check(NonFinalEqualsFinalHashCode.class); } @Test - public void fail_whenHashCodeIsNotFinal_givenAClassThatIsNotFinalAndAnEqualsMethodThatIsFinal() { + void fail_whenHashCodeIsNotFinal_givenAClassThatIsNotFinalAndAnEqualsMethodThatIsFinal() { ExpectedException .when(() -> EqualsVerifier.forClass(FinalEqualsPoint.class).verify()) .assertFailure() @@ -65,7 +65,7 @@ public void fail_whenHashCodeIsNotFinal_givenAClassThatIsNotFinalAndAnEqualsMeth } @Test - public void succeed_whenEqualsIsNonFinalButHashCodeIsFinal_givenWarningsAreSuppressed() { + void succeed_whenEqualsIsNonFinalButHashCodeIsFinal_givenWarningsAreSuppressed() { EqualsVerifier .forClass(NonFinalEqualsFinalHashCode.class) .usingGetClass() @@ -74,7 +74,7 @@ public void succeed_whenEqualsIsNonFinalButHashCodeIsFinal_givenWarningsAreSuppr } @Test - public void succeed_whenHashCodeIsNotFinal_givenAClassThatIsNotFinalAndAnEqualsMethodThatIsFinalAndWarningIsSuppressed() { + void succeed_whenHashCodeIsNotFinal_givenAClassThatIsNotFinalAndAnEqualsMethodThatIsFinalAndWarningIsSuppressed() { EqualsVerifier.forClass(FinalEqualsPoint.class).suppress(Warning.STRICT_INHERITANCE).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/SubclassTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/SubclassTest.java index c12ef91a5..3ed071a13 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/SubclassTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/SubclassTest.java @@ -18,15 +18,15 @@ *

* 2. "can equal", as described by Odersky, Spoon and Venners in Programming in Scala. */ -public class SubclassTest { +class SubclassTest { @Test - public void succeed_whenClassIsFinal() { + void succeed_whenClassIsFinal() { EqualsVerifier.forClass(FinalPoint.class).verify(); } @Test - public void fail_whenClassIsNotEqualToATrivialSubclassWithEqualFields() { + void fail_whenClassIsNotEqualToATrivialSubclassWithEqualFields() { ExpectedException .when(() -> EqualsVerifier.forClass(LiskovSubstitutionPrincipleBroken.class).verify()) .assertFailure() @@ -38,7 +38,7 @@ public void fail_whenClassIsNotEqualToATrivialSubclassWithEqualFields() { } @Test - public void fail_whenEqualsIsOverridableAndBlindlyEqualsIsPresent() { + void fail_whenEqualsIsOverridableAndBlindlyEqualsIsPresent() { ExpectedException .when( () -> EqualsVerifier @@ -54,17 +54,17 @@ public void fail_whenEqualsIsOverridableAndBlindlyEqualsIsPresent() { } @Test - public void succeed_whenEqualsIsOverridableAndBlindlyEqualsIsPresent_givenACorrectSubclass() { + void succeed_whenEqualsIsOverridableAndBlindlyEqualsIsPresent_givenACorrectSubclass() { EqualsVerifier.forClass(BlindlyEqualsPoint.class).withRedefinedSubclass(BlindlyEqualsColorPoint.class).verify(); } @Test - public void succeed_whenEqualsIsOverriddenTwiceThroughBlindlyEquals_givenWithRedefinedSuperclass() { + void succeed_whenEqualsIsOverriddenTwiceThroughBlindlyEquals_givenWithRedefinedSuperclass() { EqualsVerifier.forClass(BlindlyEqualsColorPoint.class).withRedefinedSuperclass().verify(); } @Test - public void fail_whenEqualsIsOverridableAndCanEqualIsPresent() { + void fail_whenEqualsIsOverridableAndCanEqualIsPresent() { ExpectedException .when( () -> EqualsVerifier @@ -80,17 +80,17 @@ public void fail_whenEqualsIsOverridableAndCanEqualIsPresent() { } @Test - public void succeed_whenEqualsIsOverridableAndCanEqualIsPresent_givenACorrectSubclass() { + void succeed_whenEqualsIsOverridableAndCanEqualIsPresent_givenACorrectSubclass() { EqualsVerifier.forClass(CanEqualPoint.class).withRedefinedSubclass(CanEqualColorPoint.class).verify(); } @Test - public void succeed_whenEqualsIsOverridenTwiceThroughCanEqual_givenWithRedefinedSuperclass() { + void succeed_whenEqualsIsOverridenTwiceThroughCanEqual_givenWithRedefinedSuperclass() { EqualsVerifier.forClass(CanEqualColorPoint.class).withRedefinedSuperclass().verify(); } @Test - public void fail_whenWithRedefinedEqualsIsUsed_givenEqualsAndHashCodeAreFinal() { + void fail_whenWithRedefinedEqualsIsUsed_givenEqualsAndHashCodeAreFinal() { ExpectedException .when( () -> EqualsVerifier @@ -106,7 +106,7 @@ public void fail_whenWithRedefinedEqualsIsUsed_givenEqualsAndHashCodeAreFinal() } @Test - public void succeed_whenClassIsAbstract_givenACorrectImplementationOfEqualsUnderInheritanceAndARedefinedSubclass() { + void succeed_whenClassIsAbstract_givenACorrectImplementationOfEqualsUnderInheritanceAndARedefinedSubclass() { EqualsVerifier .forClass(AbstractRedefinablePoint.class) .withRedefinedSubclass(SubclassForAbstractRedefinablePoint.class) @@ -114,7 +114,7 @@ public void succeed_whenClassIsAbstract_givenACorrectImplementationOfEqualsUnder } @Test - public void fail_whenWithRedefinedSubclassIsUsed_givenStrictInheritanceWarningIsSuppressed() { + void fail_whenWithRedefinedSubclassIsUsed_givenStrictInheritanceWarningIsSuppressed() { ExpectedException .when( () -> EqualsVerifier @@ -127,7 +127,7 @@ public void fail_whenWithRedefinedSubclassIsUsed_givenStrictInheritanceWarningIs } @Test - public void fail_whenStrictInhertianceWarningIsSuppressed_givenWithRedefinedSubclassIsUsed() { + void fail_whenStrictInhertianceWarningIsSuppressed_givenWithRedefinedSubclassIsUsed() { ExpectedException .when( () -> EqualsVerifier diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/SuperclassTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/SuperclassTest.java index e6c610c28..e81155b28 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/SuperclassTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/inheritance/SuperclassTest.java @@ -17,15 +17,15 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.junit.jupiter.api.Test; -public class SuperclassTest { +class SuperclassTest { @Test - public void succeed_whenSubclassRedefinesEqualsButOnlyCallsSuper_givenSuperHasRedefinedAlsoAndAllFieldsWarningIsSuppressed() { + void succeed_whenSubclassRedefinesEqualsButOnlyCallsSuper_givenSuperHasRedefinedAlsoAndAllFieldsWarningIsSuppressed() { EqualsVerifier.forClass(ColorBlindColorPoint.class).suppress(Warning.ALL_FIELDS_SHOULD_BE_USED).verify(); } @Test - public void fail_whenEqualsIsRedefinedSoItBreaksSymmetry_givenSuperHasRedefinedAlso() { + void fail_whenEqualsIsRedefinedSoItBreaksSymmetry_givenSuperHasRedefinedAlso() { ExpectedException .when(() -> EqualsVerifier.forClass(SymmetryBrokenColorPoint.class).verify()) .assertFailure() @@ -37,7 +37,7 @@ public void fail_whenEqualsIsRedefinedSoItBreaksSymmetry_givenSuperHasRedefinedA } @Test - public void fail_whenEqualsIsRedefinedSoItBreaksTransitivity_givenSuperHasRedefinedAlso() { + void fail_whenEqualsIsRedefinedSoItBreaksTransitivity_givenSuperHasRedefinedAlso() { ExpectedException .when(() -> EqualsVerifier.forClass(TransitivityBrokenColorPoint.class).verify()) .assertFailure() @@ -50,7 +50,7 @@ public void fail_whenEqualsIsRedefinedSoItBreaksTransitivity_givenSuperHasRedefi } @Test - public void fail_whenClassHasDifferentHashCodeThanSuper_givenEqualsIsTheSame() { + void fail_whenClassHasDifferentHashCodeThanSuper_givenEqualsIsTheSame() { ExpectedException .when(() -> EqualsVerifier.forClass(HashCodeBrokenPoint.class).verify()) .assertFailure() @@ -63,14 +63,14 @@ public void fail_whenClassHasDifferentHashCodeThanSuper_givenEqualsIsTheSame() { } @Test - public void succeed_whenSuperDoesNotRedefineEquals() { + void succeed_whenSuperDoesNotRedefineEquals() { EqualsVerifier.forClass(SubclassOfEmpty.class).verify(); EqualsVerifier.forClass(SubOfEmptySubOfEmpty.class).verify(); EqualsVerifier.forClass(SubOfEmptySubOfAbstract.class).verify(); } @Test - public void fail_whenSuperDoesNotRedefineEquals_givenSuperOfSuperDoesRedefineEquals() { + void fail_whenSuperDoesNotRedefineEquals_givenSuperOfSuperDoesRedefineEquals() { ExpectedException .when(() -> EqualsVerifier.forClass(BrokenCanEqualColorPointWithEmptySuper.class).verify()) .assertFailure() @@ -78,7 +78,7 @@ public void fail_whenSuperDoesNotRedefineEquals_givenSuperOfSuperDoesRedefineEqu } @Test - public void fail_whenWithRedefinedSuperclassIsUsed_givenItIsNotNeeded() { + void fail_whenWithRedefinedSuperclassIsUsed_givenItIsNotNeeded() { ExpectedException .when(() -> EqualsVerifier.forClass(ColorBlindColorPoint.class).withRedefinedSuperclass().verify()) .assertFailure() @@ -91,17 +91,17 @@ public void fail_whenWithRedefinedSuperclassIsUsed_givenItIsNotNeeded() { } @Test - public void succeed_whenClassInheritsEqualsAndHashCode_givenSuperclassUsesCommonsLangEqualsBuilder() { + void succeed_whenClassInheritsEqualsAndHashCode_givenSuperclassUsesCommonsLangEqualsBuilder() { EqualsVerifier.forClass(ConcreteEqualsInheriter.class).withRedefinedSuperclass().verify(); } @Test - public void succeed_whenVersionedEntityIncorrectlyImplementsCanEqual_givenIncorrectnessIsOnlyObservedFromSubclass() { + void succeed_whenVersionedEntityIncorrectlyImplementsCanEqual_givenIncorrectnessIsOnlyObservedFromSubclass() { EqualsVerifier.forClass(SymmetryBrokenForNullIdWithIncorrectCanEqualSuper.class).verify(); } @Test - public void fail_whenSuperclassIsVersionedEntityAndIncorrectlyImplementsCanEqual_givenASubclassThatExploitsTheIncorrectness() { + void fail_whenSuperclassIsVersionedEntityAndIncorrectlyImplementsCanEqual_givenASubclassThatExploitsTheIncorrectness() { ExpectedException .when(() -> EqualsVerifier.forClass(SymmetryBrokenForNullIdWithIncorrectCanEqualSub.class).verify()) .assertFailure() 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 9d14e7148..7c92d6525 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 @@ -1,7 +1,6 @@ package nl.jqno.equalsverifier.integration.operational; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import java.util.Arrays; import java.util.List; @@ -24,39 +23,39 @@ import nl.jqno.equalsverifier.testhelpers.types.TypeHelper.SingleGenericContainerContainer; import org.junit.jupiter.api.Test; -public class ConfiguredEqualsVerifierMultipleTest { +class ConfiguredEqualsVerifierMultipleTest { @Test - public void succeed_whenCallingForPackage_givenAllClassesInPackageAreCorrect() { + void succeed_whenCallingForPackage_givenAllClassesInPackageAreCorrect() { EqualsVerifier.configure().forPackage("nl.jqno.equalsverifier.testhelpers.packages.correct").verify(); } @Test - public void succeed_whenEqualsVerifierUsesGetClassInsteadOfInstanceOf_givenUsingGetClassIsPreConfigured_forIterableOverload() { + void succeed_whenEqualsVerifierUsesGetClassInsteadOfInstanceOf_givenUsingGetClassIsPreConfigured_forIterableOverload() { List reports = EqualsVerifier .configure() .usingGetClass() .forClasses(Arrays.asList(GetClassPoint.class, FinalMethodsPoint.class)) .report(); - assertTrue(reports.get(0).isSuccessful()); - assertFalse(reports.get(1).isSuccessful()); + assertThat(reports.get(0).isSuccessful()).isTrue(); + assertThat(reports.get(1).isSuccessful()).isFalse(); } @Test - public void succeed_whenEqualsUsesGetClassInsteadOfInstanceOf_givenUsingGetClassIsPreConfigured_forVarargOverload() { + void succeed_whenEqualsUsesGetClassInsteadOfInstanceOf_givenUsingGetClassIsPreConfigured_forVarargOverload() { List reports = EqualsVerifier .configure() .usingGetClass() .forClasses(GetClassPoint.class, FinalMethodsPoint.class) .report(); - assertTrue(reports.get(0).isSuccessful()); - assertFalse(reports.get(1).isSuccessful()); + assertThat(reports.get(0).isSuccessful()).isTrue(); + assertThat(reports.get(1).isSuccessful()).isFalse(); } @Test - public void suppressedWarningsArePassedOn() { + void suppressedWarningsArePassedOn() { EqualsVerifier .configure() .suppress(Warning.STRICT_INHERITANCE) @@ -65,7 +64,7 @@ public void suppressedWarningsArePassedOn() { } @Test - public void sanity_fail_whenTypeIsRecursive() { + void sanity_fail_whenTypeIsRecursive() { ExpectedException .when(() -> EqualsVerifier.forClasses(RecursiveType.class, A.class).verify()) .assertFailure() @@ -73,7 +72,7 @@ public void sanity_fail_whenTypeIsRecursive() { } @Test - public void succeed_whenTypeIsRecursive_givenPrefabValuesArePreconfigured() { + void succeed_whenTypeIsRecursive_givenPrefabValuesArePreconfigured() { EqualsVerifier .configure() .withPrefabValues( @@ -85,7 +84,7 @@ public void succeed_whenTypeIsRecursive_givenPrefabValuesArePreconfigured() { } @Test - public void sanity_fail_whenSingleGenericTypeIsRecursive() { + void sanity_fail_whenSingleGenericTypeIsRecursive() { ExpectedException .when(() -> EqualsVerifier.forClasses(SingleGenericContainerContainer.class, A.class).verify()) .assertFailure() @@ -93,7 +92,7 @@ public void sanity_fail_whenSingleGenericTypeIsRecursive() { } @Test - public void succeed_whenSingleGenericTypeIsRecursive_givenGenericPrefabValuesArePreconfigured() { + void succeed_whenSingleGenericTypeIsRecursive_givenGenericPrefabValuesArePreconfigured() { EqualsVerifier .configure() .withGenericPrefabValues(SingleGenericContainer.class, SingleGenericContainer::new) @@ -102,7 +101,7 @@ public void succeed_whenSingleGenericTypeIsRecursive_givenGenericPrefabValuesAre } @Test - public void sanity_fail_whenDoubleGenericTypeIsRecursive() { + void sanity_fail_whenDoubleGenericTypeIsRecursive() { ExpectedException .when(() -> EqualsVerifier.forClasses(DoubleGenericContainerContainer.class, A.class).verify()) .assertFailure() @@ -110,7 +109,7 @@ public void sanity_fail_whenDoubleGenericTypeIsRecursive() { } @Test - public void succeed_whenDoubleGenericTypeIsRecursive_givenGenericPrefabValuesArePreconfigured() { + void succeed_whenDoubleGenericTypeIsRecursive_givenGenericPrefabValuesArePreconfigured() { EqualsVerifier .configure() .withGenericPrefabValues(DoubleGenericContainer.class, DoubleGenericContainer::new) @@ -119,7 +118,7 @@ public void succeed_whenDoubleGenericTypeIsRecursive_givenGenericPrefabValuesAre } @Test - public void succeed_whenConfigurationIsShared() { + void succeed_whenConfigurationIsShared() { ConfiguredEqualsVerifier ev = EqualsVerifier .configure() .withGenericPrefabValues(SingleGenericContainer.class, SingleGenericContainer::new) @@ -130,7 +129,7 @@ public void succeed_whenConfigurationIsShared() { } @Test - public void individuallySuppressedWarningsAreNotAddedGlobally() { + void individuallySuppressedWarningsAreNotAddedGlobally() { ConfiguredEqualsVerifier ev = EqualsVerifier.configure().suppress(Warning.STRICT_INHERITANCE); // should succeed @@ -144,7 +143,7 @@ public void individuallySuppressedWarningsAreNotAddedGlobally() { } @Test - public void individuallyAddedPrefabValuesAreNotAddedGlobally() { + void individuallyAddedPrefabValuesAreNotAddedGlobally() { ConfiguredEqualsVerifier ev = EqualsVerifier.configure(); // should succeed @@ -164,7 +163,7 @@ public void individuallyAddedPrefabValuesAreNotAddedGlobally() { } @Test - public void individuallyAddedGenericPrefabValuesAreNotAddedGlobally() { + void individuallyAddedGenericPrefabValuesAreNotAddedGlobally() { ConfiguredEqualsVerifier ev = EqualsVerifier.configure(); // should succeed @@ -181,7 +180,7 @@ public void individuallyAddedGenericPrefabValuesAreNotAddedGlobally() { } @Test - public void succeed_whenFieldsAreNonfinalAndClassIsNonfinal_givenTwoWarningsAreSuppressedButInDifferentPlaces() { + void succeed_whenFieldsAreNonfinalAndClassIsNonfinal_givenTwoWarningsAreSuppressedButInDifferentPlaces() { EqualsVerifier .configure() .suppress(Warning.STRICT_INHERITANCE) 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 8c289d64f..01179283f 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 @@ -15,20 +15,20 @@ import nl.jqno.equalsverifier.testhelpers.types.TypeHelper.SingleGenericContainerContainer; import org.junit.jupiter.api.Test; -public class ConfiguredEqualsVerifierSingleTest { +class ConfiguredEqualsVerifierSingleTest { @Test - public void succeed_whenEqualsUsesGetClassInsteadOfInstanceOf_givenUsingGetClassIsPreConfigured() { + void succeed_whenEqualsUsesGetClassInsteadOfInstanceOf_givenUsingGetClassIsPreConfigured() { EqualsVerifier.configure().usingGetClass().forClass(GetClassPoint.class).verify(); } @Test - public void suppressedWarningsArePassedOn() { + void suppressedWarningsArePassedOn() { EqualsVerifier.configure().suppress(Warning.STRICT_INHERITANCE).forClass(PointContainer.class).verify(); } @Test - public void sanity_fail_whenTypeIsRecursive() { + void sanity_fail_whenTypeIsRecursive() { ExpectedException .when(() -> EqualsVerifier.forClass(RecursiveType.class).verify()) .assertFailure() @@ -36,7 +36,7 @@ public void sanity_fail_whenTypeIsRecursive() { } @Test - public void succeed_whenTypeIsRecursive_givenPrefabValuesArePreconfigured() { + void succeed_whenTypeIsRecursive_givenPrefabValuesArePreconfigured() { EqualsVerifier .configure() .withPrefabValues( @@ -48,7 +48,7 @@ public void succeed_whenTypeIsRecursive_givenPrefabValuesArePreconfigured() { } @Test - public void sanity_fail_whenSingleGenericTypeIsRecursive() { + void sanity_fail_whenSingleGenericTypeIsRecursive() { ExpectedException .when(() -> EqualsVerifier.forClass(SingleGenericContainerContainer.class).verify()) .assertFailure() @@ -56,7 +56,7 @@ public void sanity_fail_whenSingleGenericTypeIsRecursive() { } @Test - public void succeed_whenSingleGenericTypeIsRecursive_givenGenericPrefabValuesArePreconfigured() { + void succeed_whenSingleGenericTypeIsRecursive_givenGenericPrefabValuesArePreconfigured() { EqualsVerifier .configure() .withGenericPrefabValues(SingleGenericContainer.class, SingleGenericContainer::new) @@ -65,7 +65,7 @@ public void succeed_whenSingleGenericTypeIsRecursive_givenGenericPrefabValuesAre } @Test - public void sanity_fail_whenDoubleGenericTypeIsRecursive() { + void sanity_fail_whenDoubleGenericTypeIsRecursive() { ExpectedException .when(() -> EqualsVerifier.forClass(DoubleGenericContainerContainer.class).verify()) .assertFailure() @@ -73,7 +73,7 @@ public void sanity_fail_whenDoubleGenericTypeIsRecursive() { } @Test - public void succeed_whenDoubleGenericTypeIsRecursive_givenGenericPrefabValuesArePreconfigured() { + void succeed_whenDoubleGenericTypeIsRecursive_givenGenericPrefabValuesArePreconfigured() { EqualsVerifier .configure() .withGenericPrefabValues(DoubleGenericContainer.class, DoubleGenericContainer::new) @@ -82,7 +82,7 @@ public void succeed_whenDoubleGenericTypeIsRecursive_givenGenericPrefabValuesAre } @Test - public void succeed_whenConfigurationIsShared() { + void succeed_whenConfigurationIsShared() { ConfiguredEqualsVerifier ev = EqualsVerifier .configure() .withGenericPrefabValues(SingleGenericContainer.class, SingleGenericContainer::new) @@ -93,7 +93,7 @@ public void succeed_whenConfigurationIsShared() { } @Test - public void individuallySuppressedWarningsAreNotAddedGlobally() { + void individuallySuppressedWarningsAreNotAddedGlobally() { ConfiguredEqualsVerifier ev = EqualsVerifier.configure().suppress(Warning.STRICT_INHERITANCE); // should succeed @@ -107,7 +107,7 @@ public void individuallySuppressedWarningsAreNotAddedGlobally() { } @Test - public void individuallyAddedPrefabValuesAreNotAddedGlobally() { + void individuallyAddedPrefabValuesAreNotAddedGlobally() { ConfiguredEqualsVerifier ev = EqualsVerifier.configure(); // should succeed @@ -127,7 +127,7 @@ public void individuallyAddedPrefabValuesAreNotAddedGlobally() { } @Test - public void individuallyAddedGenericPrefabValuesAreNotAddedGlobally() { + void individuallyAddedGenericPrefabValuesAreNotAddedGlobally() { ConfiguredEqualsVerifier ev = EqualsVerifier.configure(); // should succeed @@ -144,7 +144,7 @@ public void individuallyAddedGenericPrefabValuesAreNotAddedGlobally() { } @Test - public void succeed_whenFieldsAreNonfinalAndClassIsNonfinal_givenTwoWarningsAreSuppressedButInDifferentPlaces() { + void succeed_whenFieldsAreNonfinalAndClassIsNonfinal_givenTwoWarningsAreSuppressedButInDifferentPlaces() { EqualsVerifier .configure() .suppress(Warning.STRICT_INHERITANCE) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/MultipleTypeEqualsVerifierTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/MultipleTypeEqualsVerifierTest.java index c36a9f685..dc56d348a 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/MultipleTypeEqualsVerifierTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/MultipleTypeEqualsVerifierTest.java @@ -1,10 +1,8 @@ package nl.jqno.equalsverifier.integration.operational; +import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.List; @@ -23,7 +21,7 @@ import nl.jqno.equalsverifier.testhelpers.packages.twoincorrect.subpackage.IncorrectP; import org.junit.jupiter.api.Test; -public class MultipleTypeEqualsVerifierTest { +class MultipleTypeEqualsVerifierTest { private static final String CORRECT_PACKAGE = "nl.jqno.equalsverifier.testhelpers.packages.correct"; private static final String INCORRECT_PACKAGE = "nl.jqno.equalsverifier.testhelpers.packages.twoincorrect"; @@ -35,38 +33,38 @@ public class MultipleTypeEqualsVerifierTest { private static final String INCORRECT_P = INCORRECT_PACKAGE + ".subpackage.IncorrectP"; @Test - public void succeed_whenVerifyingSeveralCorrectClasses_givenIterableOverload() { + void succeed_whenVerifyingSeveralCorrectClasses_givenIterableOverload() { List> classes = Arrays.asList(A.class, B.class, C.class); EqualsVerifier.forClasses(classes).verify(); } @Test - public void succeed_whenVerifyingSeveralCorrectClasses_givenVarargsOverload() { + void succeed_whenVerifyingSeveralCorrectClasses_givenVarargsOverload() { EqualsVerifier.forClasses(A.class, B.class, C.class).verify(); } @Test - public void succeed_whenVerifyingACorrectPackage() { + void succeed_whenVerifyingACorrectPackage() { EqualsVerifier.forPackage(CORRECT_PACKAGE).verify(); } @Test - public void succeed_whenVerifyingACorrectPackageRecursively() { + void succeed_whenVerifyingACorrectPackageRecursively() { EqualsVerifier.forPackage(CORRECT_PACKAGE, true).verify(); } @Test - public void succeed_whenVerifyingAPackageWithASuperclass() { + void succeed_whenVerifyingAPackageWithASuperclass() { EqualsVerifier.forPackage(SUBCLASSES_PACKAGE, SuperA.class).verify(); } @Test - public void succeed_whenVerifyingAPackageWithASuperInterface_givenOneOfTheImplementationsIsAlsoAnInterface() { + void succeed_whenVerifyingAPackageWithASuperInterface_givenOneOfTheImplementationsIsAlsoAnInterface() { EqualsVerifier.forPackage(SUBCLASSES_PACKAGE, SuperI.class).verify(); } @Test - public void doesNotReportNonrecursive_whenPackageContainsRecursiveAndNonrecursiveClasses() { + void doesNotReportNonrecursive_whenPackageContainsRecursiveAndNonrecursiveClasses() { ExpectedException .when(() -> EqualsVerifier.forPackage(SOME_RECURSIVE_PACKAGE).verify()) .assertFailure() @@ -75,7 +73,7 @@ public void doesNotReportNonrecursive_whenPackageContainsRecursiveAndNonrecursiv } @Test - public void fail_whenVerifyingOneIncorrectClass() { + void fail_whenVerifyingOneIncorrectClass() { ExpectedException .when(() -> EqualsVerifier.forClasses(A.class, IncorrectM.class, C.class).verify()) .assertFailure() @@ -86,7 +84,7 @@ public void fail_whenVerifyingOneIncorrectClass() { } @Test - public void fail_whenVerifyingTwoIncorrectClasses() { + void fail_whenVerifyingTwoIncorrectClasses() { ExpectedException .when(() -> EqualsVerifier.forClasses(A.class, IncorrectM.class, C.class, IncorrectN.class).verify()) .assertFailure() @@ -99,7 +97,7 @@ public void fail_whenVerifyingTwoIncorrectClasses() { } @Test - public void fail_whenVerifyingAPackageWithTwoIncorrectClasses() { + void fail_whenVerifyingAPackageWithTwoIncorrectClasses() { ExpectedException .when(() -> EqualsVerifier.forPackage(INCORRECT_PACKAGE).verify()) .assertFailure() @@ -112,7 +110,7 @@ public void fail_whenVerifyingAPackageWithTwoIncorrectClasses() { } @Test - public void fail_whenVerifyingAPackageRecursivelyWithFourIncorrectClasses() { + void fail_whenVerifyingAPackageRecursivelyWithFourIncorrectClasses() { ExpectedException .when(() -> EqualsVerifier.forPackage(INCORRECT_PACKAGE, true).verify()) .assertFailure() @@ -127,7 +125,7 @@ public void fail_whenVerifyingAPackageRecursivelyWithFourIncorrectClasses() { } @Test - public void fail_whenVerifyingAPackageWithASuperclassWithFourIncorrectClasses() { + void fail_whenVerifyingAPackageWithASuperclassWithFourIncorrectClasses() { ExpectedException .when(() -> EqualsVerifier.forPackage(INCORRECT_PACKAGE, Object.class).verify()) .assertFailure() @@ -142,7 +140,7 @@ public void fail_whenVerifyingAPackageWithASuperclassWithFourIncorrectClasses() } @Test - public void fail_whenCallingForPackage_whenPackageHasNoClasses() { + void fail_whenCallingForPackage_whenPackageHasNoClasses() { ExpectedException .when(() -> EqualsVerifier.forPackage("nl.jqno.equalsverifier.doesnotexist")) .assertThrows(IllegalStateException.class) @@ -150,7 +148,7 @@ public void fail_whenCallingForPackage_whenPackageHasNoClasses() { } @Test - public void fail_whenCallingForPackageRecursively_whenPackageHasNoClasses() { + void fail_whenCallingForPackageRecursively_whenPackageHasNoClasses() { ExpectedException .when(() -> EqualsVerifier.forPackage("nl.jqno.equalsverifier.doesnotexist", true)) .assertThrows(IllegalStateException.class) @@ -158,7 +156,7 @@ public void fail_whenCallingForPackageRecursively_whenPackageHasNoClasses() { } @Test - public void fail_whenCallingForPackageWithASuperclass_whenPackageHasNoClasses() { + void fail_whenCallingForPackageWithASuperclass_whenPackageHasNoClasses() { ExpectedException .when(() -> EqualsVerifier.forPackage("nl.jqno.equalsverifier.doesnotexist", Object.class)) .assertThrows(IllegalStateException.class) @@ -166,12 +164,12 @@ public void fail_whenCallingForPackageWithASuperclass_whenPackageHasNoClasses() } @Test - public void succeed_whenCallingForPackageOnAPackageContainingFailingClasses_givenFailingClassesAreExcepted() { + void succeed_whenCallingForPackageOnAPackageContainingFailingClasses_givenFailingClassesAreExcepted() { EqualsVerifier.forPackage(INCORRECT_PACKAGE).except(IncorrectM.class, IncorrectN.class).verify(); } @Test - public void succeed_whenCallingForPackageRecursivelyOnAPackageContainingFailingClasses_givenFailingClassesAreExcepted() { + void succeed_whenCallingForPackageRecursivelyOnAPackageContainingFailingClasses_givenFailingClassesAreExcepted() { EqualsVerifier .forPackage(INCORRECT_PACKAGE, true) .except(IncorrectM.class, IncorrectN.class, IncorrectO.class, IncorrectP.class) @@ -179,7 +177,7 @@ public void succeed_whenCallingForPackageRecursivelyOnAPackageContainingFailingC } @Test - public void succeed_whenCallingForPackageWithASuperclassOnAPackageContainingFailingClasses_givenFailingClassesAreExcepted() { + void succeed_whenCallingForPackageWithASuperclassOnAPackageContainingFailingClasses_givenFailingClassesAreExcepted() { EqualsVerifier .forPackage(INCORRECT_PACKAGE, Object.class) .except(IncorrectM.class, IncorrectN.class, IncorrectO.class, IncorrectP.class) @@ -187,7 +185,7 @@ public void succeed_whenCallingForPackageWithASuperclassOnAPackageContainingFail } @Test - public void fail_whenExceptingAClassThatDoesntExistInThePackage() { + void fail_whenExceptingAClassThatDoesntExistInThePackage() { ExpectedException .when(() -> EqualsVerifier.forPackage(CORRECT_PACKAGE).except(IncorrectM.class)) .assertThrows(IllegalStateException.class) @@ -195,7 +193,7 @@ public void fail_whenExceptingAClassThatDoesntExistInThePackage() { } @Test - public void fail_whenExceptingAClassThatDoesntExistInThePackageAndSubPackages() { + void fail_whenExceptingAClassThatDoesntExistInThePackageAndSubPackages() { ExpectedException .when(() -> EqualsVerifier.forPackage(CORRECT_PACKAGE, true).except(IncorrectM.class)) .assertThrows(IllegalStateException.class) @@ -203,12 +201,12 @@ public void fail_whenExceptingAClassThatDoesntExistInThePackageAndSubPackages() } @Test - public void succeed_whenCallingForPackageOnAPackageContainingFailingClasses_givenFailingClassesAreExceptedByPredicate() { + void succeed_whenCallingForPackageOnAPackageContainingFailingClasses_givenFailingClassesAreExceptedByPredicate() { EqualsVerifier.forPackage(INCORRECT_PACKAGE).except(c -> c.getSimpleName().contains("Incorrect")).verify(); } @Test - public void succeed_whenCallingForPackageRecursivelyOnAPackageContainingFailingClasses_givenFailingClassesAreExceptedByPredicate() { + void succeed_whenCallingForPackageRecursivelyOnAPackageContainingFailingClasses_givenFailingClassesAreExceptedByPredicate() { EqualsVerifier .forPackage(INCORRECT_PACKAGE, true) .except(c -> c.getSimpleName().contains("Incorrect")) @@ -216,7 +214,7 @@ public void succeed_whenCallingForPackageRecursivelyOnAPackageContainingFailingC } @Test - public void fail_whenCallingForPackageOnAPackageContainingFailingClasses_givenFailingClassesAreNotExceptedByPredicate() { + void fail_whenCallingForPackageOnAPackageContainingFailingClasses_givenFailingClassesAreNotExceptedByPredicate() { ExpectedException .when(() -> EqualsVerifier.forPackage(INCORRECT_PACKAGE).except(c -> false).verify()) .assertFailure() @@ -224,7 +222,7 @@ public void fail_whenCallingForPackageOnAPackageContainingFailingClasses_givenFa } @Test - public void fail_whenCallingForPackageRecursivelyOnAPackageContainingFailingClasses_givenFailingClassesAreNotExceptedByPredicate() { + void fail_whenCallingForPackageRecursivelyOnAPackageContainingFailingClasses_givenFailingClassesAreNotExceptedByPredicate() { ExpectedException .when(() -> EqualsVerifier.forPackage(INCORRECT_PACKAGE, true).except(c -> false).verify()) .assertFailure() @@ -232,41 +230,41 @@ public void fail_whenCallingForPackageRecursivelyOnAPackageContainingFailingClas } @Test - public void succeed_whenCallingForPackageOnAPackageContainingFailingClasses_givenAllClassesAreExceptedByPredicate() { + void succeed_whenCallingForPackageOnAPackageContainingFailingClasses_givenAllClassesAreExceptedByPredicate() { EqualsVerifier.forPackage(INCORRECT_PACKAGE).except(c -> true).verify(); } @Test - public void succeed_whenCallingForPackageRecursivelyOnAPackageContainingFailingClasses_givenAllClassesAreExceptedByPredicate() { + void succeed_whenCallingForPackageRecursivelyOnAPackageContainingFailingClasses_givenAllClassesAreExceptedByPredicate() { EqualsVerifier.forPackage(INCORRECT_PACKAGE, true).except(c -> true).verify(); } @Test - public void succeed_whenReportingOnSeveralCorrectClasses() { + void succeed_whenReportingOnSeveralCorrectClasses() { List reports = EqualsVerifier.forClasses(A.class, B.class, C.class).report(); - assertEquals(3, reports.size()); + assertThat(reports.size()).isEqualTo(3); assertSuccessful(reports.get(0), A.class); assertSuccessful(reports.get(1), B.class); assertSuccessful(reports.get(2), C.class); } @Test - public void fail_whenReportingOnOneIncorrectClass() { + void fail_whenReportingOnOneIncorrectClass() { List reports = EqualsVerifier.forClasses(A.class, IncorrectM.class, C.class).report(); - assertEquals(3, reports.size()); + assertThat(reports.size()).isEqualTo(3); assertSuccessful(reports.get(0), A.class); assertSuccessful(reports.get(2), C.class); assertUnsuccessful(reports.get(1), IncorrectM.class, "Subclass: equals is not final."); } @Test - public void fail_whenReportingOnTwoIncorrectClasses() { + void fail_whenReportingOnTwoIncorrectClasses() { List reports = EqualsVerifier.forClasses(A.class, IncorrectM.class, C.class, IncorrectN.class).report(); - assertEquals(4, reports.size()); + assertThat(reports.size()).isEqualTo(4); assertSuccessful(reports.get(0), A.class); assertSuccessful(reports.get(2), C.class); assertUnsuccessful(reports.get(1), IncorrectM.class, "Subclass: equals is not final."); @@ -274,13 +272,13 @@ public void fail_whenReportingOnTwoIncorrectClasses() { } private void assertSuccessful(EqualsVerifierReport report, Class type) { - assertTrue(report.isSuccessful()); - assertEquals(type, report.getType()); + assertThat(report.isSuccessful()).isTrue(); + assertThat(report.getType()).isEqualTo(type); } private void assertUnsuccessful(EqualsVerifierReport report, Class type, String message) { - assertFalse(report.isSuccessful()); - assertEquals(type, report.getType()); + assertThat(report.isSuccessful()).isFalse(); + assertThat(report.getType()).isEqualTo(type); assertThat(report.getMessage(), containsString(message)); } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/OriginalStateTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/OriginalStateTest.java index 12a2b54d8..0e885ff54 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/OriginalStateTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/OriginalStateTest.java @@ -2,17 +2,17 @@ import static nl.jqno.equalsverifier.internal.testhelpers.Util.defaultEquals; import static nl.jqno.equalsverifier.internal.testhelpers.Util.defaultHashCode; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; import java.util.Objects; import nl.jqno.equalsverifier.EqualsVerifier; import org.junit.jupiter.api.Test; -@SuppressWarnings("unused") // because of the use of defaultEquals and defaultHashCode -public class OriginalStateTest { +// because of the use of defaultEquals and defaultHashCode +@SuppressWarnings("unused") +class OriginalStateTest { private static final String INSTANCE_1 = "instance 1"; private static final String INSTANCE_2 = "instance 2"; @@ -20,47 +20,47 @@ public class OriginalStateTest { private static final String STATIC_FINAL = "static final"; @Test - public void staticValueReturnsToOriginalState_whenEqualsVerifierIsFinished() { + void staticValueReturnsToOriginalState_whenEqualsVerifierIsFinished() { EqualsVerifier.forClass(CorrectEquals.class).verify(); - assertEquals(STATIC_FINAL, CorrectEquals.STATIC_FINAL_VALUE); - assertEquals(STATIC, CorrectEquals.staticValue); + assertThat(CorrectEquals.STATIC_FINAL_VALUE).isEqualTo(STATIC_FINAL); + assertThat(CorrectEquals.staticValue).isEqualTo(STATIC); } @Test - public void staticValueReturnsToOriginalStateRecursively_whenEqualsVerifierIsFinished() { + void staticValueReturnsToOriginalStateRecursively_whenEqualsVerifierIsFinished() { EqualsVerifier.forClass(CorrectEqualsContainer.class).verify(); - assertEquals(STATIC, CorrectEquals.staticValue); + assertThat(CorrectEquals.staticValue).isEqualTo(STATIC); } @Test - public void staticValueReturnsToOriginalStateDeeplyRecursively_whenEqualsVerifierIsFinished() { + void staticValueReturnsToOriginalStateDeeplyRecursively_whenEqualsVerifierIsFinished() { EqualsVerifier.forClass(CorrectEqualsContainerContainer.class).verify(); - assertEquals(STATIC, CorrectEquals.staticValue); + assertThat(CorrectEquals.staticValue).isEqualTo(STATIC); } @Test - public void staticValueInSuperReturnsToOriginalState_whenEqualsVerifierIsFinished() { + void staticValueInSuperReturnsToOriginalState_whenEqualsVerifierIsFinished() { EqualsVerifier.forClass(SubContainer.class).verify(); - assertEquals(STATIC, SuperContainer.staticValue); - assertEquals(STATIC_FINAL, SuperContainer.STATIC_FINAL_VALUE); + assertThat(SuperContainer.staticValue).isEqualTo(STATIC); + assertThat(SuperContainer.STATIC_FINAL_VALUE).isEqualTo(STATIC_FINAL); } @Test - public void allValuesReturnToOriginalState_whenEqualsVerifierIsFinishedWithException() { + void allValuesReturnToOriginalState_whenEqualsVerifierIsFinishedWithException() { try { EqualsVerifier.forClass(FailingEqualsContainerContainer.class).verify(); fail("EqualsVerifier should have failed on FailingEqualsContainerContainer."); } catch (AssertionError e) { // Make sure EV fails on a check that actually mutates fields. - assertTrue(e.getMessage().contains("Mutability")); + assertThat(e.getMessage().contains("Mutability")).isTrue(); } catch (Throwable ignored) { fail("EqualsVerifier should have failed on FailingEqualsContainerContainer with a different exception."); } - assertEquals(STATIC_FINAL, CorrectEquals.STATIC_FINAL_VALUE); - assertEquals(STATIC, CorrectEquals.staticValue); + assertThat(CorrectEquals.STATIC_FINAL_VALUE).isEqualTo(STATIC_FINAL); + assertThat(CorrectEquals.staticValue).isEqualTo(STATIC); } static final class CorrectEquals { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/OutputTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/OutputTest.java index c00583d4b..573510e1a 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/OutputTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/OutputTest.java @@ -9,7 +9,7 @@ import nl.jqno.equalsverifier.testhelpers.types.RecursiveTypeHelper.Node; import org.junit.jupiter.api.Test; -public class OutputTest { +class OutputTest { private static final String SEE_ALSO = "For more information, go to"; private static final String WEBSITE_URL = "https://www.jqno.nl/equalsverifier/errormessages"; @@ -17,7 +17,7 @@ public class OutputTest { private static final String MESSAGE = "a message for an exception"; @Test - public void messageIsValidForSingleType_whenEqualsVerifierFails_givenExceptionIsGeneratedByEqualsVerifierItself() { + void messageIsValidForSingleType_whenEqualsVerifierFails_givenExceptionIsGeneratedByEqualsVerifierItself() { ExpectedException .when(() -> EqualsVerifier.forClass(Point.class).verify()) .assertCause(AssertionException.class) @@ -25,7 +25,7 @@ public void messageIsValidForSingleType_whenEqualsVerifierFails_givenExceptionIs } @Test - public void messageIsValidForMultipleTypes_whenEqualsVerifierFails_givenExceptionIsGeneratedByEqualsVerifierItself() { + void messageIsValidForMultipleTypes_whenEqualsVerifierFails_givenExceptionIsGeneratedByEqualsVerifierItself() { ExpectedException .when(() -> EqualsVerifier.forClasses(Point.class, MutablePoint.class).verify()) .assertMessageContains(Point.class.getSimpleName()) @@ -36,7 +36,7 @@ public void messageIsValidForMultipleTypes_whenEqualsVerifierFails_givenExceptio } @Test - public void errorDescriptionAppearsOnlyAtTopOfStacktrace_notInOneOfItsCauses() { + void errorDescriptionAppearsOnlyAtTopOfStacktrace_notInOneOfItsCauses() { ExpectedException .when(() -> EqualsVerifier.forClass(Point.class).verify()) .assertMessageContains("Subclass") @@ -44,7 +44,7 @@ public void errorDescriptionAppearsOnlyAtTopOfStacktrace_notInOneOfItsCauses() { } @Test - public void messageIsValidAndCauseHasCause_whenEqualsVerifierFails_givenOriginalExceptionHasACause() { + void messageIsValidAndCauseHasCause_whenEqualsVerifierFails_givenOriginalExceptionHasACause() { ExpectedException .when(() -> EqualsVerifier.forClass(AssertionExceptionWithCauseThrower.class).verify()) .assertMessageContains(AssertionExceptionWithCauseThrower.class.getSimpleName()) @@ -55,7 +55,7 @@ public void messageIsValidAndCauseHasCause_whenEqualsVerifierFails_givenOriginal } @Test - public void originalMessageIsPresentInOutput_whenEqualsVerifierFails_givenOriginalExceptionHasAMessage() { + void originalMessageIsPresentInOutput_whenEqualsVerifierFails_givenOriginalExceptionHasAMessage() { ExpectedException .when(() -> EqualsVerifier.forClass(UnsupportedOperationExceptionWithMessageThrower.class).verify()) .assertMessageContains(UnsupportedOperationExceptionWithMessageThrower.class.getSimpleName()) @@ -67,7 +67,7 @@ public void originalMessageIsPresentInOutput_whenEqualsVerifierFails_givenOrigin } @Test - public void messageIsValidAndDoesNotContainStringNull_whenEqualsVerifierFails_givenOriginalExceptionIsBare() { + void messageIsValidAndDoesNotContainStringNull_whenEqualsVerifierFails_givenOriginalExceptionIsBare() { ExpectedException .when(() -> EqualsVerifier.forClass(IllegalStateExceptionThrower.class).verify()) .assertMessageContains(IllegalStateExceptionThrower.class.getSimpleName()) @@ -77,7 +77,7 @@ public void messageIsValidAndDoesNotContainStringNull_whenEqualsVerifierFails_gi } @Test - public void noStackOverflowErrorIsThrown_whenClassIsARecursiveDatastructure() { + void noStackOverflowErrorIsThrown_whenClassIsARecursiveDatastructure() { ExpectedException .when(() -> EqualsVerifier.forClass(Node.class).verify()) .assertMessageContains(Node.class.getSimpleName(), SEE_ALSO, WEBSITE_URL, SUFFIX) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/RecursionTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/RecursionTest.java index 4d001f9ae..f88b31dc5 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/RecursionTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/RecursionTest.java @@ -14,7 +14,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class RecursionTest { +class RecursionTest { private static final String RECURSIVE_DATASTRUCTURE = "Recursive datastructure"; private static final String PREFAB = "Add prefab values for one of the following types"; @@ -25,7 +25,7 @@ public class RecursionTest { private Tree blueTree; @BeforeEach - public void createSomeNodes() { + void createSomeNodes() { red = new Node(null); blue = new Node(new Node(null)); redTree = new Tree(Collections.emptyList()); @@ -33,7 +33,7 @@ public void createSomeNodes() { } @Test - public void fail_whenDatastructureIsRecursive_givenItIsPassedInAsAClass() { + void fail_whenDatastructureIsRecursive_givenItIsPassedInAsAClass() { ExpectedException .when(() -> EqualsVerifier.forClass(Node.class).verify()) .assertFailure() @@ -41,27 +41,27 @@ public void fail_whenDatastructureIsRecursive_givenItIsPassedInAsAClass() { } @Test - public void succeed_whenDatastructureIsRecursive_givenPrefabValues() { + void succeed_whenDatastructureIsRecursive_givenPrefabValues() { EqualsVerifier.forClass(Node.class).withPrefabValues(Node.class, red, blue).verify(); } @Test - public void succeed_whenDatastructureIsRecursive_givenPrefabValuesForField() { + void succeed_whenDatastructureIsRecursive_givenPrefabValuesForField() { EqualsVerifier.forClass(Node.class).withPrefabValuesForField("node", red, blue).verify(); } @Test - public void succeed_whenDatastructureIsRecursive_givenPrefabValuesOfSuperclass() { + void succeed_whenDatastructureIsRecursive_givenPrefabValuesOfSuperclass() { EqualsVerifier.forClass(SubNode.class).withPrefabValues(Node.class, red, blue).verify(); } @Test - public void succeed_whenDatastructureIsRecursive_givenPrefabValuesForFieldOfSuperclass() { + void succeed_whenDatastructureIsRecursive_givenPrefabValuesForFieldOfSuperclass() { EqualsVerifier.forClass(SubNode.class).withPrefabValuesForField("node", red, blue).verify(); } @Test - public void fail_whenFieldIsARecursiveType() { + void fail_whenFieldIsARecursiveType() { ExpectedException .when(() -> EqualsVerifier.forClass(NodeContainer.class).verify()) .assertFailure() @@ -69,27 +69,27 @@ public void fail_whenFieldIsARecursiveType() { } @Test - public void succeed_whenFieldIsARecursiveType_givenPrefabValues() { + void succeed_whenFieldIsARecursiveType_givenPrefabValues() { EqualsVerifier.forClass(NodeContainer.class).withPrefabValues(Node.class, red, blue).verify(); } @Test - public void succeed_whenFieldIsARecursiveType_givenPrefabValuesForField() { + void succeed_whenFieldIsARecursiveType_givenPrefabValuesForField() { EqualsVerifier.forClass(NodeContainer.class).withPrefabValuesForField("node", red, blue).verify(); } @Test - public void succeed_whenFieldIsARecursiveType_givenPrefabValuesOfSuperclass() { + void succeed_whenFieldIsARecursiveType_givenPrefabValuesOfSuperclass() { EqualsVerifier.forClass(SubNodeContainer.class).withPrefabValues(Node.class, red, blue).verify(); } @Test - public void succeed_whenFieldIsARecursiveType_givenPrefabValuesForFieldOfSuperclass() { + void succeed_whenFieldIsARecursiveType_givenPrefabValuesForFieldOfSuperclass() { EqualsVerifier.forClass(SubNodeContainer.class).withPrefabValuesForField("node", red, blue).verify(); } @Test - public void fail_whenDatastructureIsRecursiveInGenerics() { + void fail_whenDatastructureIsRecursiveInGenerics() { ExpectedException .when(() -> EqualsVerifier.forClass(Tree.class).verify()) .assertFailure() @@ -97,12 +97,12 @@ public void fail_whenDatastructureIsRecursiveInGenerics() { } @Test - public void succeed_whenDatastructureIsRecursiveInGenerics_givenPrefabValues() { + void succeed_whenDatastructureIsRecursiveInGenerics_givenPrefabValues() { EqualsVerifier.forClass(Tree.class).withPrefabValues(Tree.class, redTree, blueTree).verify(); } @Test - public void fail_whenFieldIsARecursiveTypeInGenerics() { + void fail_whenFieldIsARecursiveTypeInGenerics() { ExpectedException .when(() -> EqualsVerifier.forClass(TreeContainer.class).verify()) .assertFailure() @@ -110,12 +110,12 @@ public void fail_whenFieldIsARecursiveTypeInGenerics() { } @Test - public void succeed_whenFieldIsARecursiveTypeInGenerics_givenPrefabValues() { + void succeed_whenFieldIsARecursiveTypeInGenerics_givenPrefabValues() { EqualsVerifier.forClass(TreeContainer.class).withPrefabValues(Tree.class, redTree, blueTree).verify(); } @Test - public void giveCorrectErrorMessage_whenFieldIsInstantiatedUsingReflectiveFactory() { + void giveCorrectErrorMessage_whenFieldIsInstantiatedUsingReflectiveFactory() { ExpectedException .when(() -> EqualsVerifier.forClass(ImmutableListTree.class).verify()) .assertFailure() @@ -126,7 +126,7 @@ public void giveCorrectErrorMessage_whenFieldIsInstantiatedUsingReflectiveFactor } @Test - public void succeed_whenStaticFinalFieldIsRecursive_givenNoPrefabValues() { + void succeed_whenStaticFinalFieldIsRecursive_givenNoPrefabValues() { EqualsVerifier.forClass(StaticFinalNodeContainer.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ReportTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ReportTest.java index 8dcbc0140..337810094 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ReportTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/ReportTest.java @@ -1,8 +1,9 @@ package nl.jqno.equalsverifier.integration.operational; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; import static org.hamcrest.CoreMatchers.startsWith; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.*; import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.EqualsVerifierReport; @@ -11,47 +12,47 @@ import nl.jqno.equalsverifier.testhelpers.types.Point; import org.junit.jupiter.api.Test; -public class ReportTest { +class ReportTest { @Test - public void isEmptyWhenClassIsCorrect() { + void isEmptyWhenClassIsCorrect() { EqualsVerifierReport report = EqualsVerifier.forClass(FinalPoint.class).report(); - assertEquals(FinalPoint.class, report.getType()); - assertTrue(report.isSuccessful()); - assertEquals("", report.getMessage()); - assertNull(report.getCause()); + assertThat(report.getType()).isEqualTo(FinalPoint.class); + assertThat(report.isSuccessful()).isTrue(); + assertThat(report.getMessage()).isEqualTo(""); + assertThat(report.getCause()).isNull(); } @Test - public void containsAppropriateErrorMessageAndExceptionWhenClassIsIncorrect() { + void containsAppropriateErrorMessageAndExceptionWhenClassIsIncorrect() { EqualsVerifierReport report = EqualsVerifier.forClass(Point.class).report(); - assertEquals(Point.class, report.getType()); - assertFalse(report.isSuccessful()); + assertThat(report.getType()).isEqualTo(Point.class); + assertThat(report.isSuccessful()).isFalse(); assertThat( report.getMessage(), startsWith("EqualsVerifier found a problem in class nl.jqno.equalsverifier.testhelpers.types.Point")); - assertEquals(AssertionException.class, report.getCause().getClass()); - assertNull(report.getCause().getMessage()); + assertThat(report.getCause().getClass()).isEqualTo(AssertionException.class); + assertThat(report.getCause().getMessage()).isNull(); } @Test - public void reportReturnsTheSameInformationAsVerify() { + void reportReturnsTheSameInformationAsVerify() { EqualsVerifierReport report = EqualsVerifier.forClass(Point.class).report(); try { EqualsVerifier.forClass(Point.class).verify(); fail("Should have failed"); } catch (AssertionError e) { - assertEquals(e.getMessage(), report.getMessage()); - assertEquals(e.getCause().getClass(), report.getCause().getClass()); + assertThat(report.getMessage()).isEqualTo(e.getMessage()); + assertThat(report.getCause().getClass()).isEqualTo(e.getCause().getClass()); StackTraceElement[] verified = e.getCause().getStackTrace(); StackTraceElement[] reported = report.getCause().getStackTrace(); // Implementation detail: // `report` has 1 extra stack frame because it delegates to an overload. - assertEquals(verified.length + 1, reported.length); + assertThat(reported.length).isEqualTo(verified.length + 1); for (int i = 0; i < verified.length; i++) { if (!verified[i].getMethodName().equals("verify")) { @@ -59,7 +60,7 @@ public void reportReturnsTheSameInformationAsVerify() { break; } - assertEquals(verified[i], reported[i]); + assertThat(reported[i]).isEqualTo(verified[i]); } } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/SignedJarTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/SignedJarTest.java index 51bd28e0f..1423c72f8 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/SignedJarTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/SignedJarTest.java @@ -4,15 +4,15 @@ import nl.jqno.equalsverifier.signedjar.SignedJarPoint; import org.junit.jupiter.api.Test; -public class SignedJarTest { +class SignedJarTest { @Test - public void succeed_whenTestingAClassFromASignedJar() { + void succeed_whenTestingAClassFromASignedJar() { EqualsVerifier.forClass(SignedJarPoint.class).verify(); } @Test - public void succeed_whenTestingAClassThatExtendsFromAClassFromASignedJar() { + void succeed_whenTestingAClassThatExtendsFromAClassFromASignedJar() { EqualsVerifier.forClass(SubclassOfSignedJarPoint.class).verify(); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/WithGenericPrefabValuesTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/WithGenericPrefabValuesTest.java index 23be3c417..c13052e71 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/WithGenericPrefabValuesTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/WithGenericPrefabValuesTest.java @@ -11,10 +11,10 @@ import org.junit.jupiter.api.Test; @SuppressWarnings("unchecked") -public class WithGenericPrefabValuesTest { +class WithGenericPrefabValuesTest { @Test - public void sanityCheck() { + void sanityCheck() { EqualsVerifier .forClass(SingleGenericContainer.class) .withPrefabValues( @@ -33,7 +33,7 @@ public void sanityCheck() { } @Test - public void fail_whenRegularPrefabValuesOfWrongTypeAreUsed_given1GenericParameter() { + void fail_whenRegularPrefabValuesOfWrongTypeAreUsed_given1GenericParameter() { ExpectedException .when( () -> EqualsVerifier @@ -49,7 +49,7 @@ public void fail_whenRegularPrefabValuesOfWrongTypeAreUsed_given1GenericParamete } @Test - public void fail_whenRegularPrefabValuesOfWrongTypeAreUsedAndMarkedAsNonnull_given1GenericParameter() { + void fail_whenRegularPrefabValuesOfWrongTypeAreUsedAndMarkedAsNonnull_given1GenericParameter() { ExpectedException .when( () -> EqualsVerifier @@ -66,7 +66,7 @@ public void fail_whenRegularPrefabValuesOfWrongTypeAreUsedAndMarkedAsNonnull_giv } @Test - public void succeed_whenPrefabValuesMatchGenericParameterInClassUnderTest_given1GenericParameter() { + void succeed_whenPrefabValuesMatchGenericParameterInClassUnderTest_given1GenericParameter() { EqualsVerifier .forClass(SingleGenericContainerContainer.class) .withGenericPrefabValues(SingleGenericContainer.class, SingleGenericContainer::new) @@ -74,7 +74,7 @@ public void succeed_whenPrefabValuesMatchGenericParameterInClassUnderTest_given1 } @Test - public void throw_whenTypeIsNull_given1GenericParameter() { + void throw_whenTypeIsNull_given1GenericParameter() { ExpectedException .when( () -> EqualsVerifier @@ -84,7 +84,7 @@ public void throw_whenTypeIsNull_given1GenericParameter() { } @Test - public void throw_whenFactoryIsNull_given1GenericParameter() { + void throw_whenFactoryIsNull_given1GenericParameter() { ExpectedException .when( () -> EqualsVerifier @@ -94,7 +94,7 @@ public void throw_whenFactoryIsNull_given1GenericParameter() { } @Test - public void throw_whenFactoryHas2Parameters_given1GenericParameter() { + void throw_whenFactoryHas2Parameters_given1GenericParameter() { ExpectedException .when( () -> EqualsVerifier @@ -107,7 +107,7 @@ public void throw_whenFactoryHas2Parameters_given1GenericParameter() { } @Test - public void fail_whenRegularPrefabValuesOfWrongTypeAreUsed_given2GenericParameters() { + void fail_whenRegularPrefabValuesOfWrongTypeAreUsed_given2GenericParameters() { ExpectedException .when( () -> EqualsVerifier @@ -123,7 +123,7 @@ public void fail_whenRegularPrefabValuesOfWrongTypeAreUsed_given2GenericParamete } @Test - public void fail_whenRegularPrefabValuesOfWrongTypeAreUsedAndMarkedAsNonnull_given2GenericParameters() { + void fail_whenRegularPrefabValuesOfWrongTypeAreUsedAndMarkedAsNonnull_given2GenericParameters() { ExpectedException .when( () -> EqualsVerifier @@ -140,7 +140,7 @@ public void fail_whenRegularPrefabValuesOfWrongTypeAreUsedAndMarkedAsNonnull_giv } @Test - public void succeed_whenPrefabValuesMatchGenericParametersInClassUnderTest_given2GenericParameters() { + void succeed_whenPrefabValuesMatchGenericParametersInClassUnderTest_given2GenericParameters() { EqualsVerifier .forClass(DoubleGenericContainerContainer.class) .withGenericPrefabValues(DoubleGenericContainer.class, DoubleGenericContainer::new) @@ -148,7 +148,7 @@ public void succeed_whenPrefabValuesMatchGenericParametersInClassUnderTest_given } @Test - public void throw_whenTypeIsNull_given2GenericParameters() { + void throw_whenTypeIsNull_given2GenericParameters() { ExpectedException .when( () -> EqualsVerifier @@ -158,7 +158,7 @@ public void throw_whenTypeIsNull_given2GenericParameters() { } @Test - public void throw_whenFactoryIsNull_given2GenericParameters() { + void throw_whenFactoryIsNull_given2GenericParameters() { ExpectedException .when( () -> EqualsVerifier @@ -168,7 +168,7 @@ public void throw_whenFactoryIsNull_given2GenericParameters() { } @Test - public void throw_whenFactoryHas1Parameter_given2GenericParameters() { + void throw_whenFactoryHas1Parameter_given2GenericParameters() { ExpectedException .when( () -> EqualsVerifier diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/WithPrefabValuesForFieldTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/WithPrefabValuesForFieldTest.java index d4ab8013e..3cf6835d5 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/WithPrefabValuesForFieldTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/WithPrefabValuesForFieldTest.java @@ -10,7 +10,7 @@ import nl.jqno.equalsverifier.testhelpers.types.FinalPoint; import org.junit.jupiter.api.Test; -public class WithPrefabValuesForFieldTest { +class WithPrefabValuesForFieldTest { private final FinalPoint pRed = new FinalPoint(3, 42); private final FinalPoint pBlue = new FinalPoint(3, 1337); @@ -18,7 +18,7 @@ public class WithPrefabValuesForFieldTest { private final int iBlue = 142; @Test - public void fail_whenClassHasSinglePrecondition() { + void fail_whenClassHasSinglePrecondition() { ExpectedException .when(() -> EqualsVerifier.forClass(SinglePrecondition.class).suppress(Warning.NULL_FIELDS).verify()) .assertFailure() @@ -26,12 +26,12 @@ public void fail_whenClassHasSinglePrecondition() { } @Test - public void succeed_whenClassHasSinglePrecondition_givenPrefabValuesForField() { + void succeed_whenClassHasSinglePrecondition_givenPrefabValuesForField() { EqualsVerifier.forClass(SinglePrecondition.class).withPrefabValuesForField("point", pRed, pBlue).verify(); } @Test - public void fail_whenClassHasDualPrecondition() { + void fail_whenClassHasDualPrecondition() { ExpectedException .when(() -> EqualsVerifier.forClass(DualPrecondition.class).verify()) .assertFailure() @@ -39,7 +39,7 @@ public void fail_whenClassHasDualPrecondition() { } @Test - public void fail_whenClassHasDualPrecondition_givenPrefabValuesForOnlyOneField() { + void fail_whenClassHasDualPrecondition_givenPrefabValuesForOnlyOneField() { ExpectedException .when( () -> EqualsVerifier @@ -51,7 +51,7 @@ public void fail_whenClassHasDualPrecondition_givenPrefabValuesForOnlyOneField() } @Test - public void succeed_whenClassHasDualPrecondition_givenPrefabValueForBothFields() { + void succeed_whenClassHasDualPrecondition_givenPrefabValueForBothFields() { EqualsVerifier .forClass(DualPrecondition.class) .withPrefabValuesForField("x", iRed, iBlue) @@ -60,7 +60,7 @@ public void succeed_whenClassHasDualPrecondition_givenPrefabValueForBothFields() } @Test - public void throw_whenFieldDoesNotExistInClass() { + void throw_whenFieldDoesNotExistInClass() { ExpectedException .when( () -> EqualsVerifier @@ -71,7 +71,7 @@ public void throw_whenFieldDoesNotExistInClass() { } @Test - public void throw_whenFirstPrefabValueIsNull() { + void throw_whenFirstPrefabValueIsNull() { ExpectedException .when( () -> EqualsVerifier @@ -81,7 +81,7 @@ public void throw_whenFirstPrefabValueIsNull() { } @Test - public void throw_whenSecondPrefabValueIsNull() { + void throw_whenSecondPrefabValueIsNull() { ExpectedException .when( () -> EqualsVerifier @@ -91,7 +91,7 @@ public void throw_whenSecondPrefabValueIsNull() { } @Test - public void throw_whenThePrefabValuesAreTheSame() { + void throw_whenThePrefabValuesAreTheSame() { ExpectedException .when( () -> EqualsVerifier @@ -102,7 +102,7 @@ public void throw_whenThePrefabValuesAreTheSame() { } @Test - public void throw_whenThePrefabValuesAreEqual() { + void throw_whenThePrefabValuesAreEqual() { FinalPoint red1 = new FinalPoint(3, 4); FinalPoint red2 = new FinalPoint(3, 4); @@ -116,7 +116,7 @@ public void throw_whenThePrefabValuesAreEqual() { } @Test - public void throw_whenFieldsDontMatch() { + void throw_whenFieldsDontMatch() { ExpectedException .when(() -> EqualsVerifier.forClass(SinglePrecondition.class).withPrefabValuesForField("point", 1, 2)) .assertThrows(IllegalStateException.class) @@ -124,7 +124,7 @@ public void throw_whenFieldsDontMatch() { } @Test - public void dontThrow_whenAddingPrefabValuesFromAnotherModuleAndThereforeARedCopyCantBeMade() { + void dontThrow_whenAddingPrefabValuesFromAnotherModuleAndThereforeARedCopyCantBeMade() { EqualsVerifier .forClass(OtherModuleContainer.class) .withPrefabValuesForField("date", LocalDate.of(2024, 9, 18), LocalDate.of(2024, 9, 19)) @@ -132,7 +132,7 @@ public void dontThrow_whenAddingPrefabValuesFromAnotherModuleAndThereforeARedCop } @Test - public void succeed_whenPrefabForArrayIsOverridden() { + void succeed_whenPrefabForArrayIsOverridden() { EqualsVerifier .forClass(ThrowingArrayContainer.class) .withPrefabValuesForField("field", new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 }) @@ -140,7 +140,7 @@ public void succeed_whenPrefabForArrayIsOverridden() { } @Test - public void succeed_whenClassContainsSomethingThatAllowsSubclassesAndASubclassIsGiven() { + void succeed_whenClassContainsSomethingThatAllowsSubclassesAndASubclassIsGiven() { EqualsVerifier .forClass(ListContainer.class) .withPrefabValuesForField("list", Collections.singletonList("x"), Collections.singletonList("y")) @@ -148,7 +148,7 @@ public void succeed_whenClassContainsSomethingThatAllowsSubclassesAndASubclassIs } @Test - public void succeed_whenClassContainsAGenericInterfaceThatRefersToItself() { + void succeed_whenClassContainsAGenericInterfaceThatRefersToItself() { DifficultGeneric one = new DifficultGeneric(new ArrayList<>()); DifficultGeneric two = new DifficultGeneric(null); EqualsVerifier diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/WithPrefabValuesTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/WithPrefabValuesTest.java index 324f91d4a..0e249f798 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/WithPrefabValuesTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/operational/WithPrefabValuesTest.java @@ -7,25 +7,25 @@ import nl.jqno.equalsverifier.testhelpers.types.FinalPoint; import org.junit.jupiter.api.Test; -public class WithPrefabValuesTest { +class WithPrefabValuesTest { private final FinalPoint red = new FinalPoint(1, 2); private final FinalPoint blue = new FinalPoint(2, 3); @Test - public void succeed_whenPrefabValuesAreOfSameTypeAsClassUnderTest() { + void succeed_whenPrefabValuesAreOfSameTypeAsClassUnderTest() { EqualsVerifier.forClass(FinalPoint.class).withPrefabValues(FinalPoint.class, red, blue).verify(); } @Test - public void throw_whenTypeIsNull() { + void throw_whenTypeIsNull() { ExpectedException .when(() -> EqualsVerifier.forClass(WithPrefabValuesTest.class).withPrefabValues(null, red, blue)) .assertThrows(NullPointerException.class); } @Test - public void throw_whenFirstPrefabValueIsNull() { + void throw_whenFirstPrefabValueIsNull() { ExpectedException .when( () -> EqualsVerifier @@ -35,7 +35,7 @@ public void throw_whenFirstPrefabValueIsNull() { } @Test - public void throw_whenSecondPrefabValueIsNull() { + void throw_whenSecondPrefabValueIsNull() { ExpectedException .when( () -> EqualsVerifier @@ -45,7 +45,7 @@ public void throw_whenSecondPrefabValueIsNull() { } @Test - public void throw_whenThePrefabValuesAreTheSame() { + void throw_whenThePrefabValuesAreTheSame() { ExpectedException .when( () -> EqualsVerifier @@ -56,7 +56,7 @@ public void throw_whenThePrefabValuesAreTheSame() { } @Test - public void throw_whenThePrefabValuesAreEqual() { + void throw_whenThePrefabValuesAreEqual() { FinalPoint red1 = new FinalPoint(4, 4); FinalPoint red2 = new FinalPoint(4, 4); @@ -70,7 +70,7 @@ public void throw_whenThePrefabValuesAreEqual() { } @Test - public void dontThrow_whenAddingPrefabValuesFromAnotherModuleAndThereforeARedCopyCantBeMade() { + void dontThrow_whenAddingPrefabValuesFromAnotherModuleAndThereforeARedCopyCantBeMade() { EqualsVerifier .forClass(FinalPoint.class) .withPrefabValues(LocalDate.class, LocalDate.of(2018, 12, 24), LocalDate.of(2018, 12, 25)) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/EqualsVerifierTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/EqualsVerifierTest.java index 909ac4d0b..73edeaf8a 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/EqualsVerifierTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/EqualsVerifierTest.java @@ -5,10 +5,10 @@ import nl.jqno.equalsverifier.EqualsVerifier; import org.junit.jupiter.api.Test; -public class EqualsVerifierTest { +class EqualsVerifierTest { @Test - public void coverTheConstructor() { + void coverTheConstructor() { coverThePrivateConstructor(EqualsVerifier.class); } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/EqualsVerifierInternalBugExceptionTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/EqualsVerifierInternalBugExceptionTest.java index ac852f483..d0c6caa7a 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/EqualsVerifierInternalBugExceptionTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/EqualsVerifierInternalBugExceptionTest.java @@ -5,12 +5,12 @@ import org.junit.jupiter.api.Test; -public class EqualsVerifierInternalBugExceptionTest { +class EqualsVerifierInternalBugExceptionTest { private EqualsVerifierInternalBugException actual; @Test - public void exceptionHasNoSpecificMessage() { + void exceptionHasNoSpecificMessage() { actual = new EqualsVerifierInternalBugException(); assertNoMessage(); @@ -18,7 +18,7 @@ public void exceptionHasNoSpecificMessage() { } @Test - public void exceptionHasSpecificMessage() { + void exceptionHasSpecificMessage() { String message = "my message"; actual = new EqualsVerifierInternalBugException(message); @@ -27,7 +27,7 @@ public void exceptionHasSpecificMessage() { } @Test - public void exceptionHasACause() { + void exceptionHasACause() { Throwable cause = new IllegalStateException("cause of the bug"); actual = new EqualsVerifierInternalBugException(cause); @@ -36,7 +36,7 @@ public void exceptionHasACause() { } @Test - public void exceptionHasMessageAndCause() { + void exceptionHasMessageAndCause() { String message = "some message"; Throwable cause = new IllegalArgumentException("some cause"); actual = new EqualsVerifierInternalBugException(message, cause); diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/NoValueExceptionTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/NoValueExceptionTest.java index 58259cc49..376330b01 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/NoValueExceptionTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/NoValueExceptionTest.java @@ -1,16 +1,16 @@ package nl.jqno.equalsverifier.internal.exceptions; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import nl.jqno.equalsverifier.internal.reflection.TypeTag; import org.junit.jupiter.api.Test; -public class NoValueExceptionTest { +class NoValueExceptionTest { @Test - public void description() { + void description() { TypeTag tag = new TypeTag(String.class); NoValueException e = new NoValueException(tag); - assertTrue(e.getDescription().contains("String")); + assertThat(e.getDescription().contains("String")).isTrue(); } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/RecursionExceptionTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/RecursionExceptionTest.java index 4504db033..32aae0c83 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/RecursionExceptionTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/exceptions/RecursionExceptionTest.java @@ -1,6 +1,6 @@ package nl.jqno.equalsverifier.internal.exceptions; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import java.util.LinkedHashSet; @@ -8,10 +8,10 @@ import nl.jqno.equalsverifier.testhelpers.types.Point; import org.junit.jupiter.api.Test; -public class RecursionExceptionTest { +class RecursionExceptionTest { @Test - public void descriptionContainsAllTypes() { + void descriptionContainsAllTypes() { LinkedHashSet stack = new LinkedHashSet<>(); stack.add(new TypeTag(String.class)); stack.add(new TypeTag(Point.class)); @@ -20,7 +20,7 @@ public void descriptionContainsAllTypes() { String message = new RecursionException(stack).getDescription(); for (TypeTag tag : stack) { - assertTrue(message.contains(tag.toString())); + assertThat(message.contains(tag.toString())).isTrue(); } } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/InstanceCreatorTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/InstanceCreatorTest.java index daffe71aa..1463d2e48 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/InstanceCreatorTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/InstanceCreatorTest.java @@ -1,6 +1,6 @@ package nl.jqno.equalsverifier.internal.instantiation; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import java.lang.reflect.Field; import java.util.HashMap; @@ -11,10 +11,10 @@ import org.objenesis.Objenesis; import org.objenesis.ObjenesisStd; -public class InstanceCreatorTest { +class InstanceCreatorTest { @Test - public void instantiate() throws NoSuchFieldException { + void instantiate() throws NoSuchFieldException { ClassProbe probe = ClassProbe.of(SomeClass.class); Objenesis objenesis = new ObjenesisStd(); InstanceCreator sut = new InstanceCreator<>(probe, objenesis); @@ -27,13 +27,13 @@ public void instantiate() throws NoSuchFieldException { SomeClass actual = sut.instantiate(values); - assertEquals(42, actual.x); - assertEquals(0, actual.y); - assertEquals("42", actual.z); + assertThat(actual.x).isEqualTo(42); + assertThat(actual.y).isEqualTo(0); + assertThat(actual.z).isEqualTo("42"); } @Test - public void copy() throws NoSuchFieldException { + void copy() throws NoSuchFieldException { ClassProbe probe = ClassProbe.of(SomeSubClass.class); Objenesis objenesis = new ObjenesisStd(); InstanceCreator sut = new InstanceCreator<>(probe, objenesis); @@ -41,10 +41,10 @@ public void copy() throws NoSuchFieldException { SomeClass original = new SomeClass(42, 1337, "yeah"); SomeSubClass copy = sut.copy(original); - assertEquals(original.x, copy.x); - assertEquals(original.y, copy.y); - assertEquals(original.z, copy.z); - assertEquals(0, copy.a); + assertThat(copy.x).isEqualTo(original.x); + assertThat(copy.y).isEqualTo(original.y); + assertThat(copy.z).isEqualTo(original.z); + assertThat(copy.a).isEqualTo(0); } static class SomeClass { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/SubjectCreatorTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/SubjectCreatorTest.java index c64600743..ad6cf259b 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/SubjectCreatorTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/SubjectCreatorTest.java @@ -1,6 +1,6 @@ package nl.jqno.equalsverifier.internal.instantiation; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertNotSame; import java.lang.reflect.Field; @@ -19,7 +19,7 @@ import org.objenesis.Objenesis; import org.objenesis.ObjenesisStd; -public class SubjectCreatorTest { +class SubjectCreatorTest { private static final int I_RED = 42; private static final int I_BLUE = 1337; @@ -40,161 +40,161 @@ public class SubjectCreatorTest { private SomeClass actual; @BeforeEach - public void setup() throws NoSuchFieldException { + void setup() throws NoSuchFieldException { fieldX = SomeSuper.class.getDeclaredField("x"); fieldI = SomeClass.class.getDeclaredField("i"); fieldS = SomeClass.class.getDeclaredField("s"); } @Test - public void plain() { + void plain() { expected = new SomeClass(I_RED, I_RED, S_RED); actual = sut.plain(); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void withFieldDefaulted_super() { + void withFieldDefaulted_super() { expected = new SomeClass(0, I_RED, S_RED); actual = sut.withFieldDefaulted(fieldX); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void withFieldDefaulted_primitive() { + void withFieldDefaulted_primitive() { expected = new SomeClass(I_RED, 0, S_RED); actual = sut.withFieldDefaulted(fieldI); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void withFieldDefaulted_object() { + void withFieldDefaulted_object() { expected = new SomeClass(I_RED, I_RED, null); actual = sut.withFieldDefaulted(fieldS); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void withAllFieldsDefaulted() { + void withAllFieldsDefaulted() { expected = new SomeClass(0, 0, null); actual = sut.withAllFieldsDefaulted(); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void withAllFieldsDefaultedExcept() { + void withAllFieldsDefaultedExcept() { expected = new SomeClass(0, I_RED, null); actual = sut.withAllFieldsDefaultedExcept(fieldI); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void withFieldSetTo_super() { + void withFieldSetTo_super() { expected = new SomeClass(99, I_RED, S_RED); actual = sut.withFieldSetTo(fieldX, 99); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void withFieldSetTo_primitive() { + void withFieldSetTo_primitive() { expected = new SomeClass(I_RED, 99, S_RED); actual = sut.withFieldSetTo(fieldI, 99); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void withFieldSetTo_object() { + void withFieldSetTo_object() { expected = new SomeClass(I_RED, I_RED, "value"); actual = sut.withFieldSetTo(fieldS, "value"); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void withFieldChanged_super() { + void withFieldChanged_super() { expected = new SomeClass(I_BLUE, I_RED, S_RED); actual = sut.withFieldChanged(fieldX); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void withFieldChanged_primitive() { + void withFieldChanged_primitive() { expected = new SomeClass(I_RED, I_BLUE, S_RED); actual = sut.withFieldChanged(fieldI); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void withFieldChanged_object() { + void withFieldChanged_object() { expected = new SomeClass(I_RED, I_RED, S_BLUE); actual = sut.withFieldChanged(fieldS); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void withAllFieldsChanged() { + void withAllFieldsChanged() { expected = new SomeClass(I_BLUE, I_BLUE, S_BLUE); actual = sut.withAllFieldsChanged(); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void withAllFieldsShallowlyChanged() { + void withAllFieldsShallowlyChanged() { expected = new SomeClass(I_RED, I_BLUE, S_BLUE); actual = sut.withAllFieldsShallowlyChanged(); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void copy() { + void copy() { expected = new SomeClass(I_RED, I_RED, S_RED); SomeClass original = new SomeClass(I_RED, I_RED, S_RED); actual = sut.copy(original); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); assertNotSame(expected, actual); } @Test - public void copyIntoSuperclass() { + void copyIntoSuperclass() { SomeSuper superExpected = new SomeSuper(I_RED); SomeClass original = new SomeClass(I_RED, I_RED, S_RED); Object superActual = sut.copyIntoSuperclass(original); - assertEquals(superExpected, superActual); - assertEquals(SomeSuper.class, superActual.getClass()); + assertThat(superActual).isEqualTo(superExpected); + assertThat(superActual.getClass()).isEqualTo(SomeSuper.class); } @Test - public void copyIntoSubclass() { + void copyIntoSubclass() { expected = new SomeSub(I_RED, I_RED, S_RED, null); SomeClass original = new SomeClass(I_RED, I_RED, S_RED); actual = sut.copyIntoSubclass(original, SomeSub.class); - assertEquals(expected, actual); - assertEquals(SomeSub.class, actual.getClass()); + assertThat(actual).isEqualTo(expected); + assertThat(actual.getClass()).isEqualTo(SomeSub.class); } @Test - public void noValueFound() { + void noValueFound() { sut = new SubjectCreator<>(config, new NoValueProvider(), fieldCache, objenesis); ExpectedException.when(() -> sut.plain()).assertThrows(NoValueException.class).assertDescriptionContains("int"); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } static class SubjectCreatorTestValueProvider implements ValueProvider { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/FactoryCacheTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/FactoryCacheTest.java index 6e34ba5cf..3a5952328 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/FactoryCacheTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/FactoryCacheTest.java @@ -1,12 +1,12 @@ package nl.jqno.equalsverifier.internal.instantiation.vintage; -import static org.junit.jupiter.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; import nl.jqno.equalsverifier.internal.instantiation.vintage.prefabvalues.factories.PrefabValueFactory; import nl.jqno.equalsverifier.internal.instantiation.vintage.prefabvalues.factories.SimpleFactory; import org.junit.jupiter.api.Test; -public class FactoryCacheTest { +class FactoryCacheTest { private static final Class STRING_CLASS = String.class; private static final PrefabValueFactory STRING_FACTORY = @@ -17,49 +17,49 @@ public class FactoryCacheTest { private final FactoryCache cache = new FactoryCache(); @Test - public void putAndGetTuple() { + void putAndGetTuple() { cache.put(STRING_CLASS, STRING_FACTORY); - assertEquals(STRING_FACTORY, cache.get(STRING_CLASS)); + assertThat(cache.get(STRING_CLASS)).isEqualTo(STRING_FACTORY); } @Test - public void putTwiceAndGetBoth() { + void putTwiceAndGetBoth() { cache.put(STRING_CLASS, STRING_FACTORY); cache.put(INT_CLASS, INT_FACTORY); - assertEquals(INT_FACTORY, cache.get(INT_CLASS)); - assertEquals(STRING_FACTORY, cache.get(STRING_CLASS)); + assertThat(cache.get(INT_CLASS)).isEqualTo(INT_FACTORY); + assertThat(cache.get(STRING_CLASS)).isEqualTo(STRING_FACTORY); } @Test - public void putNullAndGetNothingBack() { + void putNullAndGetNothingBack() { cache.put((Class) null, STRING_FACTORY); - assertNull(cache.get(null)); + assertThat(cache.get(null)).isNull(); } @Test - public void contains() { + void contains() { cache.put(STRING_CLASS, STRING_FACTORY); - assertTrue(cache.contains(STRING_CLASS)); + assertThat(cache.contains(STRING_CLASS)).isTrue(); } @Test - public void doesntContain() { - assertFalse(cache.contains(STRING_CLASS)); + void doesntContain() { + assertThat(cache.contains(STRING_CLASS)).isFalse(); } @Test - public void copy() { + void copy() { cache.put(STRING_CLASS, STRING_FACTORY); FactoryCache copy = cache.copy(); copy.put(INT_CLASS, INT_FACTORY); - assertTrue(copy.contains(STRING_CLASS)); - assertFalse(copy == cache); - assertFalse(cache.contains(INT_CLASS)); + assertThat(copy.contains(STRING_CLASS)).isTrue(); + assertThat(copy == cache).isFalse(); + assertThat(cache.contains(INT_CLASS)).isFalse(); } @Test - public void merge() { + void merge() { FactoryCache a = new FactoryCache(); a.put(STRING_CLASS, STRING_FACTORY); @@ -68,11 +68,11 @@ public void merge() { FactoryCache combined = a.merge(b); - assertTrue(combined.contains(STRING_CLASS)); - assertTrue(combined.contains(INT_CLASS)); + assertThat(combined.contains(STRING_CLASS)).isTrue(); + assertThat(combined.contains(INT_CLASS)).isTrue(); - assertFalse(a == combined); - assertFalse(a.contains(INT_CLASS)); - assertFalse(b.contains(STRING_CLASS)); + assertThat(a == combined).isFalse(); + assertThat(a.contains(INT_CLASS)).isFalse(); + assertThat(b.contains(STRING_CLASS)).isFalse(); } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/PrefabValuesApiTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/PrefabValuesApiTest.java index 33d789da6..b25f566e1 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/PrefabValuesApiTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/PrefabValuesApiTest.java @@ -4,10 +4,10 @@ import org.junit.jupiter.api.Test; -public class PrefabValuesApiTest { +class PrefabValuesApiTest { @Test - public void coverTheConstructor() { + void coverTheConstructor() { coverThePrivateConstructor(PrefabValuesApi.class); } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/VintageValueProviderCreatorTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/VintageValueProviderCreatorTest.java index c33ed35ba..00912be8d 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/VintageValueProviderCreatorTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/VintageValueProviderCreatorTest.java @@ -1,7 +1,7 @@ package nl.jqno.equalsverifier.internal.instantiation.vintage; import static nl.jqno.equalsverifier.internal.instantiation.vintage.prefabvalues.factories.Factories.values; -import static org.junit.jupiter.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; import nl.jqno.equalsverifier.internal.exceptions.RecursionException; import nl.jqno.equalsverifier.internal.reflection.TypeTag; @@ -17,7 +17,7 @@ import org.objenesis.Objenesis; import org.objenesis.ObjenesisStd; -public class VintageValueProviderCreatorTest { +class VintageValueProviderCreatorTest { private static final TypeTag POINT_TAG = new TypeTag(Point.class); private static final TypeTag ENUM_TAG = new TypeTag(Enum.class); @@ -33,84 +33,84 @@ public class VintageValueProviderCreatorTest { private VintageValueProvider valueProvider; @BeforeEach - public void setup() { + void setup() { objenesis = new ObjenesisStd(); factoryCache = FactoryCacheFactory.withPrimitiveFactories(); valueProvider = new VintageValueProvider(factoryCache, objenesis); } @Test - public void simple() { + void simple() { Point red = valueProvider.giveRed(POINT_TAG); Point blue = valueProvider.giveBlue(POINT_TAG); - assertFalse(red.equals(blue)); + assertThat(blue).isNotEqualTo(red); } @Test - public void createSecondTimeIsNoOp() { + void createSecondTimeIsNoOp() { Point red = valueProvider.giveRed(POINT_TAG); Point blue = valueProvider.giveBlue(POINT_TAG); - assertSame(red, valueProvider.giveRed(POINT_TAG)); - assertSame(blue, valueProvider.giveBlue(POINT_TAG)); + assertThat(valueProvider.giveRed(POINT_TAG)).isSameAs(red); + assertThat(valueProvider.giveBlue(POINT_TAG)).isSameAs(blue); } @Test - public void createEnum() { - assertNotNull(valueProvider.giveRed(ENUM_TAG)); - assertNotNull(valueProvider.giveBlue(ENUM_TAG)); + void createEnum() { + assertThat(valueProvider.giveRed(ENUM_TAG)).isNotNull(); + assertThat(valueProvider.giveBlue(ENUM_TAG)).isNotNull(); } @Test - public void createOneElementEnum() { - assertNotNull(valueProvider.giveRed(ONE_ELT_ENUM_TAG)); - assertNotNull(valueProvider.giveBlue(ONE_ELT_ENUM_TAG)); + void createOneElementEnum() { + assertThat(valueProvider.giveRed(ONE_ELT_ENUM_TAG)).isNotNull(); + assertThat(valueProvider.giveBlue(ONE_ELT_ENUM_TAG)).isNotNull(); } @Test - public void createEmptyEnum() { - assertNull(valueProvider.giveRed(EMPTY_ENUM_TAG)); - assertNull(valueProvider.giveBlue(EMPTY_ENUM_TAG)); + void createEmptyEnum() { + assertThat(valueProvider.giveRed(EMPTY_ENUM_TAG)).isNull(); + assertThat(valueProvider.giveBlue(EMPTY_ENUM_TAG)).isNull(); } @Test - public void oneStepRecursiveType() { + void oneStepRecursiveType() { factoryCache.put(Node.class, values(new Node(), new Node(), new Node())); valueProvider = new VintageValueProvider(factoryCache, objenesis); valueProvider.giveRed(NODE_TAG); } @Test - public void dontAddOneStepRecursiveType() { + void dontAddOneStepRecursiveType() { ExpectedException.when(() -> valueProvider.giveRed(NODE_TAG)).assertThrows(RecursionException.class); } @Test - public void oneStepRecursiveArrayType() { + void oneStepRecursiveArrayType() { factoryCache.put(NodeArray.class, values(new NodeArray(), new NodeArray(), new NodeArray())); valueProvider = new VintageValueProvider(factoryCache, objenesis); valueProvider.giveRed(NODE_ARRAY_TAG); } @Test - public void dontAddOneStepRecursiveArrayType() { + void dontAddOneStepRecursiveArrayType() { ExpectedException.when(() -> valueProvider.giveRed(NODE_ARRAY_TAG)).assertThrows(RecursionException.class); } @Test - public void addTwoStepRecursiveType() { + void addTwoStepRecursiveType() { factoryCache.put(TwoStepNodeB.class, values(new TwoStepNodeB(), new TwoStepNodeB(), new TwoStepNodeB())); valueProvider = new VintageValueProvider(factoryCache, objenesis); valueProvider.giveRed(TWOSTEP_NODE_A_TAG); } @Test - public void dontAddTwoStepRecursiveType() { + void dontAddTwoStepRecursiveType() { ExpectedException.when(() -> valueProvider.giveRed(TWOSTEP_NODE_A_TAG)).assertThrows(RecursionException.class); } @Test - public void twoStepRecursiveArrayType() { + void twoStepRecursiveArrayType() { factoryCache .put( TwoStepNodeArrayB.class, @@ -120,19 +120,19 @@ public void twoStepRecursiveArrayType() { } @Test - public void dontAddTwoStepRecursiveArrayType() { + void dontAddTwoStepRecursiveArrayType() { ExpectedException .when(() -> valueProvider.giveRed(TWOSTEP_NODE_ARRAY_A_TAG)) .assertThrows(RecursionException.class); } @Test - public void sameClassTwiceButNoRecursion() { + void sameClassTwiceButNoRecursion() { valueProvider.giveRed(new TypeTag(NotRecursiveA.class)); } @Test - public void recursiveWithAnotherFieldFirst() { + void recursiveWithAnotherFieldFirst() { ExpectedException .when(() -> valueProvider.giveRed(new TypeTag(RecursiveWithAnotherFieldFirst.class))) .assertThrows(RecursionException.class) @@ -141,7 +141,7 @@ public void recursiveWithAnotherFieldFirst() { } @Test - public void exceptionMessage() { + void exceptionMessage() { ExpectedException .when(() -> valueProvider.giveRed(TWOSTEP_NODE_A_TAG)) .assertThrows(RecursionException.class) @@ -149,7 +149,7 @@ public void exceptionMessage() { } @Test - public void skipStaticFinal() { + void skipStaticFinal() { valueProvider.giveRed(new TypeTag(StaticFinalContainer.class)); } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/VintageValueProviderTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/VintageValueProviderTest.java index 550890887..0d793db43 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/VintageValueProviderTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/VintageValueProviderTest.java @@ -3,9 +3,9 @@ import static nl.jqno.equalsverifier.internal.instantiation.vintage.prefabvalues.factories.Factories.values; import static nl.jqno.equalsverifier.internal.testhelpers.Util.defaultEquals; import static nl.jqno.equalsverifier.internal.testhelpers.Util.defaultHashCode; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.assertNotSame; -import static org.junit.jupiter.api.Assertions.fail; import java.util.*; @@ -19,7 +19,7 @@ import org.objenesis.Objenesis; import org.objenesis.ObjenesisStd; -public class VintageValueProviderTest { +class VintageValueProviderTest { private static final TypeTag STRING_TAG = new TypeTag(String.class); private static final TypeTag POINT_TAG = new TypeTag(Point.class); @@ -30,124 +30,124 @@ public class VintageValueProviderTest { private VintageValueProvider vp; @BeforeEach - public void setUp() { + void setUp() { factoryCache.put(String.class, new AppendingStringTestFactory()); factoryCache.put(int.class, values(42, 1337, 42)); vp = new VintageValueProvider(factoryCache, objenesis); } @Test - public void sanityTestFactoryIncreasesStringLength() { + void sanityTestFactoryIncreasesStringLength() { AppendingStringTestFactory f = new AppendingStringTestFactory(); - assertEquals("r", f.createValues(null, null, null).getRed()); - assertEquals("rr", f.createValues(null, null, null).getRed()); - assertEquals("rrr", f.createValues(null, null, null).getRed()); + assertThat(f.createValues(null, null, null).getRed()).isEqualTo("r"); + assertThat(f.createValues(null, null, null).getRed()).isEqualTo("rr"); + assertThat(f.createValues(null, null, null).getRed()).isEqualTo("rrr"); } @Test - public void provide() { + void provide() { Optional> actual = vp.provide(POINT_TAG); - assertEquals(Tuple.of(new Point(42, 42), new Point(1337, 1337), new Point(42, 42)), actual.get()); + assertThat(actual.get()).isEqualTo(Tuple.of(new Point(42, 42), new Point(1337, 1337), new Point(42, 42))); } @Test - public void giveRedFromFactory() { - assertEquals("r", vp.giveRed(STRING_TAG)); + void giveRedFromFactory() { + assertThat(vp.giveRed(STRING_TAG)).isEqualTo("r"); } @Test - public void giveRedFromCache() { + void giveRedFromCache() { vp.giveRed(STRING_TAG); - assertEquals("r", vp.giveRed(STRING_TAG)); + assertThat(vp.giveRed(STRING_TAG)).isEqualTo("r"); } @Test - public void giveBlueFromFactory() { - assertEquals("b", vp.giveBlue(STRING_TAG)); + void giveBlueFromFactory() { + assertThat(vp.giveBlue(STRING_TAG)).isEqualTo("b"); } @Test - public void giveBlueFromCache() { + void giveBlueFromCache() { vp.giveBlue(STRING_TAG); - assertEquals("b", vp.giveBlue(STRING_TAG)); + assertThat(vp.giveBlue(STRING_TAG)).isEqualTo("b"); } @Test - public void giveRedCopyFromFactory() { - assertEquals("r", vp.giveRedCopy(STRING_TAG)); + void giveRedCopyFromFactory() { + assertThat(vp.giveRedCopy(STRING_TAG)).isEqualTo("r"); assertNotSame(vp.giveRed(STRING_TAG), vp.giveRedCopy(STRING_TAG)); } @Test - public void giveRedCopyFromCache() { + void giveRedCopyFromCache() { vp.giveRedCopy(STRING_TAG); - assertEquals("r", vp.giveRedCopy(STRING_TAG)); + assertThat(vp.giveRedCopy(STRING_TAG)).isEqualTo("r"); assertNotSame(vp.giveRed(STRING_TAG), vp.giveRedCopy(STRING_TAG)); } @Test - public void giveRedFromFallbackFactory() { + void giveRedFromFallbackFactory() { Point actual = vp.giveRed(POINT_TAG); - assertEquals(new Point(42, 42), actual); + assertThat(actual).isEqualTo(new Point(42, 42)); } @Test - public void giveBlueFromFallbackFactory() { + void giveBlueFromFallbackFactory() { Point actual = vp.giveBlue(POINT_TAG); - assertEquals(new Point(1337, 1337), actual); + assertThat(actual).isEqualTo(new Point(1337, 1337)); } @Test - public void giveRedCopyFromFallbackFactory() { + void giveRedCopyFromFallbackFactory() { Point actual = vp.giveRedCopy(POINT_TAG); - assertEquals(new Point(42, 42), actual); + assertThat(actual).isEqualTo(new Point(42, 42)); assertNotSame(vp.giveRed(POINT_TAG), actual); } @Test - public void fallbackDoesNotAffectStaticFields() { + void fallbackDoesNotAffectStaticFields() { int expected = StaticContainer.staticInt; vp.giveRed(new TypeTag(StaticContainer.class)); - assertEquals(expected, StaticContainer.staticInt); + assertThat(StaticContainer.staticInt).isEqualTo(expected); } @Test - public void stringListIsSeparateFromIntegerList() { + void stringListIsSeparateFromIntegerList() { factoryCache.put(List.class, new ListTestFactory()); vp = new VintageValueProvider(factoryCache, objenesis); List strings = vp.giveRed(new TypeTag(List.class, STRING_TAG)); List ints = vp.giveRed(new TypeTag(List.class, INT_TAG)); - assertEquals("r", strings.get(0)); - assertEquals(42, (int) ints.get(0)); + assertThat(strings.get(0)).isEqualTo("r"); + assertThat((int) ints.get(0)).isEqualTo(42); } @Test - public void addingNullDoesntBreakAnything() { + void addingNullDoesntBreakAnything() { factoryCache.put((Class) null, new ListTestFactory()); } @Test - public void addingATypeTwiceOverrulesTheExistingOne() { + void addingATypeTwiceOverrulesTheExistingOne() { factoryCache.put(int.class, values(-1, -2, -1)); vp = new VintageValueProvider(factoryCache, objenesis); - assertEquals(-1, (int) vp.giveRed(INT_TAG)); - assertEquals(-2, (int) vp.giveBlue(INT_TAG)); + assertThat((int) vp.giveRed(INT_TAG)).isEqualTo(-1); + assertThat((int) vp.giveBlue(INT_TAG)).isEqualTo(-2); } @Test - public void addLazyFactoryWorks() { + void addLazyFactoryWorks() { TypeTag lazyTag = new TypeTag(Lazy.class); factoryCache.put(Lazy.class.getName(), values(Lazy.X, Lazy.Y, Lazy.X)); vp = new VintageValueProvider(factoryCache, objenesis); - assertEquals(Lazy.X, vp.giveRed(lazyTag)); - assertEquals(Lazy.Y, vp.giveBlue(lazyTag)); - assertEquals(Lazy.X, vp.giveRedCopy(lazyTag)); + assertThat(vp.giveRed(lazyTag)).isEqualTo(Lazy.X); + assertThat(vp.giveBlue(lazyTag)).isEqualTo(Lazy.Y); + assertThat(vp.giveRedCopy(lazyTag)).isEqualTo(Lazy.X); } @Test - public void addLazyFactoryIsLazy() { + void addLazyFactoryIsLazy() { TypeTag throwingInitializerTag = new TypeTag(ThrowingInitializer.class); // Shouldn't throw, because constructing PrefabValues doesn't instantiate objects: diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/AbstractGenericFactoryTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/AbstractGenericFactoryTest.java index 87875b512..d406b4064 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/AbstractGenericFactoryTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/AbstractGenericFactoryTest.java @@ -2,7 +2,7 @@ import static nl.jqno.equalsverifier.internal.reflection.Util.classes; import static nl.jqno.equalsverifier.internal.reflection.Util.objects; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; import java.util.LinkedHashSet; @@ -13,13 +13,13 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class AbstractGenericFactoryTest { +class AbstractGenericFactoryTest { private String receiver; private AbstractGenericFactory factory; @BeforeEach - public void setUp() { + void setUp() { receiver = ""; factory = new AbstractGenericFactory() { @Override @@ -33,10 +33,10 @@ public Tuple createValues( } @Test - public void throwTheUnthrowableException() { - assertThrows( - ReflectionException.class, - () -> factory.invoke(String.class, receiver, "this method does not exist", classes(), objects())); + void throwTheUnthrowableException() { + assertThatExceptionOfType(ReflectionException.class) + .isThrownBy( + () -> factory.invoke(String.class, receiver, "this method does not exist", classes(), objects())); } // The rest of this class is tested indirectly through its subclasses. } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/FactoriesTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/FactoriesTest.java index 17a113e7d..784572c11 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/FactoriesTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/FactoriesTest.java @@ -4,10 +4,10 @@ import org.junit.jupiter.api.Test; -public class FactoriesTest { +class FactoriesTest { @Test - public void coverTheConstructor() { + void coverTheConstructor() { coverThePrivateConstructor(Factories.class); } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/FallbackFactoryTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/FallbackFactoryTest.java index 7868b77ca..cdcf084e9 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/FallbackFactoryTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/FallbackFactoryTest.java @@ -3,8 +3,7 @@ import static nl.jqno.equalsverifier.internal.instantiation.vintage.prefabvalues.factories.Factories.values; import static nl.jqno.equalsverifier.internal.testhelpers.Util.defaultEquals; import static nl.jqno.equalsverifier.internal.testhelpers.Util.defaultHashCode; -import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertNotSame; import java.util.LinkedHashSet; @@ -26,14 +25,14 @@ import org.objenesis.Objenesis; import org.objenesis.ObjenesisStd; -public class FallbackFactoryTest { +class FallbackFactoryTest { private FallbackFactory factory; private VintageValueProvider valueProvider; private LinkedHashSet typeStack; @BeforeEach - public void setUp() { + void setUp() { Objenesis objenesis = new ObjenesisStd(); factory = new FallbackFactory<>(objenesis); FactoryCache factoryCache = new FactoryCache(); @@ -43,52 +42,52 @@ public void setUp() { } @Test - public void giveNullInsteadOfEmptyEnum() { + void giveNullInsteadOfEmptyEnum() { assertCorrectTuple(EmptyEnum.class, null, null); } @Test - public void giveOneElementEnum() { + void giveOneElementEnum() { assertCorrectTuple(OneElementEnum.class, OneElementEnum.ONE, OneElementEnum.ONE); } @Test - public void giveMultiElementEnum() { + void giveMultiElementEnum() { assertCorrectTuple(TwoElementEnum.class, TwoElementEnum.ONE, TwoElementEnum.TWO); } @Test - public void giveArray() { + void giveArray() { Tuple tuple = factory.createValues(new TypeTag(int[].class), valueProvider, typeStack); - assertArrayEquals(new int[] { 42 }, (int[]) tuple.getRed()); - assertArrayEquals(new int[] { 1337 }, (int[]) tuple.getBlue()); + assertThat((int[]) tuple.getRed()).containsExactly(new int[] { 42 }); + assertThat((int[]) tuple.getBlue()).containsExactly(new int[] { 1337 }); } @Test - public void giveClassWithFields() { + void giveClassWithFields() { assertCorrectTuple(IntContainer.class, new IntContainer(42, 42), new IntContainer(1337, 1337)); // Assert that static fields are untouched - assertEquals(-100, IntContainer.staticI); - assertEquals(-10, IntContainer.STATIC_FINAL_I); + assertThat(IntContainer.staticI).isEqualTo(-100); + assertThat(IntContainer.STATIC_FINAL_I).isEqualTo(-10); } @Test - public void redCopyIsNotSameAsRed() { + void redCopyIsNotSameAsRed() { Tuple tuple = factory.createValues(new TypeTag(IntContainer.class), valueProvider, typeStack); - assertEquals(tuple.getRed(), tuple.getRedCopy()); + assertThat(tuple.getRedCopy()).isEqualTo(tuple.getRed()); assertNotSame(tuple.getRed(), tuple.getRedCopy()); } @Test - public void dontGiveRecursiveClass() { + void dontGiveRecursiveClass() { ExpectedException .when(() -> factory.createValues(new TypeTag(Node.class), valueProvider, typeStack)) .assertThrows(RecursionException.class); } @Test - public void dontGiveTwoStepRecursiveClass() { + void dontGiveTwoStepRecursiveClass() { ExpectedException .when(() -> factory.createValues(new TypeTag(TwoStepNodeA.class), valueProvider, typeStack)) .assertThrows(RecursionException.class) @@ -96,7 +95,7 @@ public void dontGiveTwoStepRecursiveClass() { } @Test - public void dontGiveRecursiveArray() { + void dontGiveRecursiveArray() { ExpectedException .when(() -> factory.createValues(new TypeTag(NodeArray.class), valueProvider, typeStack)) .assertThrows(RecursionException.class); @@ -104,9 +103,9 @@ public void dontGiveRecursiveArray() { private void assertCorrectTuple(Class type, T expectedRed, T expectedBlue) { Tuple tuple = factory.createValues(new TypeTag(type), valueProvider, typeStack); - assertEquals(expectedRed, tuple.getRed()); - assertEquals(expectedBlue, tuple.getBlue()); - assertEquals(expectedRed, tuple.getRedCopy()); + assertThat(tuple.getRed()).isEqualTo(expectedRed); + assertThat(tuple.getBlue()).isEqualTo(expectedBlue); + assertThat(tuple.getRedCopy()).isEqualTo(expectedRed); } private static final class IntContainer { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/MapFactoryTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/MapFactoryTest.java index cfb057e71..5a3faf30c 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/MapFactoryTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/MapFactoryTest.java @@ -1,6 +1,6 @@ package nl.jqno.equalsverifier.internal.instantiation.vintage.prefabvalues.factories; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import java.util.HashMap; import java.util.LinkedHashSet; @@ -15,8 +15,8 @@ import org.junit.jupiter.api.Test; import org.objenesis.ObjenesisStd; -@SuppressWarnings("rawtypes") -public class MapFactoryTest { +@SuppressWarnings({ "rawtypes", "unchecked" }) +class MapFactoryTest { private static final TypeTag STRING_TYPETAG = new TypeTag(String.class); private static final TypeTag STRINGSTRINGMAP_TYPETAG = new TypeTag(Map.class, STRING_TYPETAG, STRING_TYPETAG); @@ -38,7 +38,7 @@ public class MapFactoryTest { private OneElementEnum redEnum; @BeforeEach - public void setUp() { + void setUp() { valueProvider = new VintageValueProvider(JavaApiPrefabValues.build(), new ObjenesisStd()); red = valueProvider.giveRed(STRING_TYPETAG); blue = valueProvider.giveBlue(STRING_TYPETAG); @@ -48,31 +48,31 @@ public void setUp() { } @Test - public void createMapsOfStringToString() { + void createMapsOfStringToString() { Tuple tuple = MAP_FACTORY.createValues(STRINGSTRINGMAP_TYPETAG, valueProvider, typeStack); - assertEquals(mapOf(red, blue), tuple.getRed()); - assertEquals(mapOf(blue, blue), tuple.getBlue()); + assertThat(tuple.getRed()).isEqualTo(mapOf(red, blue)); + assertThat(tuple.getBlue()).isEqualTo(mapOf(blue, blue)); } @Test - public void createMapsOfWildcard() { + void createMapsOfWildcard() { Tuple tuple = MAP_FACTORY.createValues(WILDCARDMAP_TYPETAG, valueProvider, typeStack); - assertEquals(mapOf(redObject, blueObject), tuple.getRed()); - assertEquals(mapOf(blueObject, blueObject), tuple.getBlue()); + assertThat(tuple.getRed()).isEqualTo(mapOf(redObject, blueObject)); + assertThat(tuple.getBlue()).isEqualTo(mapOf(blueObject, blueObject)); } @Test - public void createRawMaps() { + void createRawMaps() { Tuple tuple = MAP_FACTORY.createValues(RAWMAP_TYPETAG, valueProvider, typeStack); - assertEquals(mapOf(redObject, blueObject), tuple.getRed()); - assertEquals(mapOf(blueObject, blueObject), tuple.getBlue()); + assertThat(tuple.getRed()).isEqualTo(mapOf(redObject, blueObject)); + assertThat(tuple.getBlue()).isEqualTo(mapOf(blueObject, blueObject)); } @Test - public void createMapOfOneElementEnumKey() { + void createMapOfOneElementEnumKey() { Tuple tuple = MAP_FACTORY.createValues(ONEELEMENTENUMKEYMAP_TYPETAG, valueProvider, typeStack); - assertEquals(mapOf(redEnum, blueObject), tuple.getRed()); - assertEquals(new HashMap<>(), tuple.getBlue()); + assertThat(tuple.getRed()).isEqualTo(mapOf(redEnum, blueObject)); + assertThat(tuple.getBlue()).isEqualTo(new HashMap<>()); } private Map mapOf(K key, V value) { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SimpleFactoryTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SimpleFactoryTest.java index 7eec1bf30..5de418613 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SimpleFactoryTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SimpleFactoryTest.java @@ -1,28 +1,28 @@ package nl.jqno.equalsverifier.internal.instantiation.vintage.prefabvalues.factories; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertNotSame; import org.junit.jupiter.api.Test; -public class SimpleFactoryTest { +class SimpleFactoryTest { private SimpleFactory factory = new SimpleFactory<>("red", "blue", new String("red")); @Test - public void createRed() { - assertEquals("red", factory.createValues(null, null, null).getRed()); + void createRed() { + assertThat(factory.createValues(null, null, null).getRed()).isEqualTo("red"); } @Test - public void createBlue() { - assertEquals("blue", factory.createValues(null, null, null).getBlue()); + void createBlue() { + assertThat(factory.createValues(null, null, null).getBlue()).isEqualTo("blue"); } @Test - public void redCopy() { + void redCopy() { String redCopy = factory.createValues(null, null, null).getRedCopy(); - assertEquals("red", redCopy); + assertThat(redCopy).isEqualTo("red"); assertNotSame("red", redCopy); } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SimpleGenericFactoryTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SimpleGenericFactoryTest.java index dbd5f3e5f..4e417c23d 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SimpleGenericFactoryTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factories/SimpleGenericFactoryTest.java @@ -1,6 +1,6 @@ package nl.jqno.equalsverifier.internal.instantiation.vintage.prefabvalues.factories; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import java.util.LinkedHashSet; import java.util.Optional; @@ -14,8 +14,8 @@ import org.junit.jupiter.api.Test; import org.objenesis.ObjenesisStd; -@SuppressWarnings("rawtypes") -public class SimpleGenericFactoryTest { +@SuppressWarnings({ "rawtypes", "unchecked" }) +class SimpleGenericFactoryTest { private static final TypeTag STRING_TYPETAG = new TypeTag(String.class); private static final TypeTag INTEGER_TYPETAG = new TypeTag(Integer.class); @@ -39,7 +39,7 @@ public class SimpleGenericFactoryTest { private Object blueObject; @BeforeEach - public void setUp() { + void setUp() { valueProvider = new VintageValueProvider(JavaApiPrefabValues.build(), new ObjenesisStd()); redString = valueProvider.giveRed(STRING_TYPETAG); blueString = valueProvider.giveBlue(STRING_TYPETAG); @@ -50,30 +50,30 @@ public void setUp() { } @Test - public void createOptionalsOfMapOfString() { + void createOptionalsOfMapOfString() { Tuple tuple = OPTIONAL_FACTORY.createValues(STRINGOPTIONAL_TYPETAG, valueProvider, typeStack); - assertEquals(Optional.of(redString), tuple.getRed()); - assertEquals(Optional.of(blueString), tuple.getBlue()); + assertThat(tuple.getRed()).isEqualTo(Optional.of(redString)); + assertThat(tuple.getBlue()).isEqualTo(Optional.of(blueString)); } @Test - public void createOptionalsOfWildcard() { + void createOptionalsOfWildcard() { Tuple tuple = OPTIONAL_FACTORY.createValues(WILDCARDOPTIONAL_TYPETAG, valueProvider, typeStack); - assertEquals(Optional.of(redObject), tuple.getRed()); - assertEquals(Optional.of(blueObject), tuple.getBlue()); + assertThat(tuple.getRed()).isEqualTo(Optional.of(redObject)); + assertThat(tuple.getBlue()).isEqualTo(Optional.of(blueObject)); } @Test - public void createRawOptionals() { + void createRawOptionals() { Tuple tuple = OPTIONAL_FACTORY.createValues(RAWOPTIONAL_TYPETAG, valueProvider, typeStack); - assertEquals(Optional.of(redObject), tuple.getRed()); - assertEquals(Optional.of(blueObject), tuple.getBlue()); + assertThat(tuple.getRed()).isEqualTo(Optional.of(redObject)); + assertThat(tuple.getBlue()).isEqualTo(Optional.of(blueObject)); } @Test - public void createSomethingWithMoreThanOneTypeParameter() { + void createSomethingWithMoreThanOneTypeParameter() { Tuple tuple = PAIR_FACTORY.createValues(PAIR_TYPETAG, valueProvider, typeStack); - assertEquals(new Pair<>(redString, redInt), tuple.getRed()); - assertEquals(new Pair<>(blueString, blueInt), tuple.getBlue()); + assertThat(tuple.getRed()).isEqualTo(new Pair<>(redString, redInt)); + assertThat(tuple.getBlue()).isEqualTo(new Pair<>(blueString, blueInt)); } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JavaFxFactoryProviderTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JavaFxFactoryProviderTest.java index 7218ea8e5..7d010f555 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JavaFxFactoryProviderTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/prefabvalues/factoryproviders/JavaFxFactoryProviderTest.java @@ -1,7 +1,6 @@ package nl.jqno.equalsverifier.internal.instantiation.vintage.prefabvalues.factoryproviders; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import java.util.Map; @@ -17,23 +16,23 @@ import org.junit.jupiter.api.Test; import org.objenesis.ObjenesisStd; -@SuppressWarnings("rawtypes") -public class JavaFxFactoryProviderTest { +@SuppressWarnings({ "rawtypes", "unchecked" }) +class JavaFxFactoryProviderTest { private VintageValueProvider valueProvider; @BeforeEach - public void setUp() { + void setUp() { valueProvider = new VintageValueProvider(JavaApiPrefabValues.build(), new ObjenesisStd()); } @Test - public void maintainCoverageOnJdksThatDontHaveJavafx() { - assertNotNull(new JavaFxFactoryProvider().getFactoryCache()); + void maintainCoverageOnJdksThatDontHaveJavafx() { + assertThat(new JavaFxFactoryProvider().getFactoryCache()).isNotNull(); } @Test - public void createInstancesWithCorrectSingleGenericParameter() { + void createInstancesWithCorrectSingleGenericParameter() { TypeTag tag = new TypeTag(GenericContainer.class, new TypeTag(String.class)); TypeTag listTag = new TypeTag(List.class, new TypeTag(String.class)); @@ -41,13 +40,13 @@ public void createInstancesWithCorrectSingleGenericParameter() { new PropertyFactory<>(GenericContainer.class.getName(), List.class); Tuple tuple = factory.createValues(tag, valueProvider, null); - assertEquals(valueProvider.giveRed(listTag), tuple.getRed().t); - assertEquals(valueProvider.giveBlue(listTag), tuple.getBlue().t); - assertEquals(String.class, tuple.getRed().t.get(0).getClass()); + assertThat(tuple.getRed().t).isEqualTo(valueProvider.giveRed(listTag)); + assertThat(tuple.getBlue().t).isEqualTo(valueProvider.giveBlue(listTag)); + assertThat(tuple.getRed().t.get(0).getClass()).isEqualTo(String.class); } @Test - public void createInstancesWithCorrectMultipleGenericParameter() { + void createInstancesWithCorrectMultipleGenericParameter() { TypeTag tag = new TypeTag(GenericMultiContainer.class, new TypeTag(String.class), new TypeTag(Point.class)); TypeTag mapTag = new TypeTag(Map.class, new TypeTag(String.class), new TypeTag(Point.class)); @@ -55,12 +54,12 @@ public void createInstancesWithCorrectMultipleGenericParameter() { new PropertyFactory<>(GenericMultiContainer.class.getName(), Map.class); Tuple tuple = factory.createValues(tag, valueProvider, null); - assertEquals(valueProvider.giveRed(mapTag), tuple.getRed().t); - assertEquals(valueProvider.giveBlue(mapTag), tuple.getBlue().t); + assertThat(tuple.getRed().t).isEqualTo(valueProvider.giveRed(mapTag)); + assertThat(tuple.getBlue().t).isEqualTo(valueProvider.giveBlue(mapTag)); Map.Entry next = (Map.Entry) tuple.getRed().t.entrySet().iterator().next(); - assertEquals(String.class, next.getKey().getClass()); - assertEquals(Point.class, next.getValue().getClass()); + assertThat(next.getKey().getClass()).isEqualTo(String.class); + assertThat(next.getValue().getClass()).isEqualTo(Point.class); } private static final class GenericContainer { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/ClassAccessorTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/ClassAccessorTest.java index 74ea73491..e5d369809 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/ClassAccessorTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/ClassAccessorTest.java @@ -1,9 +1,7 @@ package nl.jqno.equalsverifier.internal.instantiation.vintage.reflection; import static nl.jqno.equalsverifier.internal.instantiation.vintage.prefabvalues.factories.Factories.values; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.assertj.core.api.Assertions.assertThat; import java.util.LinkedHashSet; @@ -20,7 +18,7 @@ import org.objenesis.Objenesis; import org.objenesis.ObjenesisStd; -public class ClassAccessorTest { +class ClassAccessorTest { private LinkedHashSet empty; private Objenesis objenesis; @@ -29,7 +27,7 @@ public class ClassAccessorTest { private ClassAccessor pointContainerAccessor; @BeforeEach - public void setup() { + void setup() { empty = new LinkedHashSet<>(); objenesis = new ObjenesisStd(); factoryCache = JavaApiPrefabValues.build(); @@ -38,91 +36,91 @@ public void setup() { } @Test - public void getRedObject() { + void getRedObject() { assertObjectHasNoNullFields(pointContainerAccessor.getRedObject(TypeTag.NULL, empty)); } @Test @SuppressWarnings("rawtypes") - public void getRedObjectGeneric() { + void getRedObjectGeneric() { ClassAccessor accessor = ClassAccessor.of(GenericTypeVariableListContainer.class, valueProvider, objenesis); GenericTypeVariableListContainer foo = accessor .getRedObject(new TypeTag(GenericTypeVariableListContainer.class, new TypeTag(String.class)), empty); - assertEquals(String.class, foo.tList.get(0).getClass()); + assertThat(foo.tList.get(0).getClass()).isEqualTo(String.class); } @Test - public void getRedAccessor() { + void getRedAccessor() { PointContainer foo = pointContainerAccessor.getRedObject(TypeTag.NULL, empty); ObjectAccessor objectAccessor = pointContainerAccessor.getRedAccessor(TypeTag.NULL, empty); - assertEquals(foo, objectAccessor.get()); + assertThat(objectAccessor.get()).isEqualTo(foo); } @Test - public void getBlueObject() { + void getBlueObject() { assertObjectHasNoNullFields(pointContainerAccessor.getBlueObject(TypeTag.NULL, empty)); } @Test @SuppressWarnings("rawtypes") - public void getBlueObjectGeneric() { + void getBlueObjectGeneric() { ClassAccessor accessor = ClassAccessor.of(GenericTypeVariableListContainer.class, valueProvider, objenesis); GenericTypeVariableListContainer foo = accessor .getBlueObject(new TypeTag(GenericTypeVariableListContainer.class, new TypeTag(String.class)), empty); - assertEquals(String.class, foo.tList.get(0).getClass()); + assertThat(foo.tList.get(0).getClass()).isEqualTo(String.class); } @Test - public void getBlueAccessor() { + void getBlueAccessor() { PointContainer foo = pointContainerAccessor.getBlueObject(TypeTag.NULL, empty); ObjectAccessor objectAccessor = pointContainerAccessor.getBlueAccessor(TypeTag.NULL, empty); - assertEquals(foo, objectAccessor.get()); + assertThat(objectAccessor.get()).isEqualTo(foo); } @Test - public void redAndBlueNotEqual() { + void redAndBlueNotEqual() { PointContainer red = pointContainerAccessor.getRedObject(TypeTag.NULL, empty); PointContainer blue = pointContainerAccessor.getBlueObject(TypeTag.NULL, empty); - assertFalse(red.equals(blue)); + assertThat(blue).isNotEqualTo(red); } @Test - public void instantiateAllTypes() { + void instantiateAllTypes() { ClassAccessor.of(AllTypesContainer.class, valueProvider, objenesis).getRedObject(TypeTag.NULL, empty); } @Test - public void instantiateArrayTypes() { + void instantiateArrayTypes() { ClassAccessor.of(AllArrayTypesContainer.class, valueProvider, objenesis).getRedObject(TypeTag.NULL, empty); } @Test - public void instantiateRecursiveTypeUsingPrefabValue() { + void instantiateRecursiveTypeUsingPrefabValue() { factoryCache.put(TwoStepNodeB.class, values(new TwoStepNodeB(), new TwoStepNodeB(), new TwoStepNodeB())); valueProvider = new VintageValueProvider(factoryCache, objenesis); ClassAccessor.of(TwoStepNodeA.class, valueProvider, objenesis).getRedObject(TypeTag.NULL, empty); } @Test - public void instantiateInterfaceField() { + void instantiateInterfaceField() { ClassAccessor.of(InterfaceContainer.class, valueProvider, objenesis).getRedObject(TypeTag.NULL, empty); } @Test - public void instantiateAbstractClassField() { + void instantiateAbstractClassField() { ClassAccessor.of(AbstractClassContainer.class, valueProvider, objenesis).getRedObject(TypeTag.NULL, empty); } @Test - public void anInvalidTypeShouldNotThrowAnExceptionUponCreation() { + void anInvalidTypeShouldNotThrowAnExceptionUponCreation() { ClassAccessor.of(null, valueProvider, objenesis); } private void assertObjectHasNoNullFields(PointContainer foo) { - assertNotNull(foo); - assertNotNull(foo.getPoint()); + assertThat(foo).isNotNull(); + assertThat(foo.getPoint()).isNotNull(); } static class MethodContainer { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/FieldModifierTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/FieldModifierTest.java index 5c7fa3fa4..51c2f581a 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/FieldModifierTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/FieldModifierTest.java @@ -1,7 +1,6 @@ package nl.jqno.equalsverifier.internal.instantiation.vintage.reflection; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertSame; +import static org.assertj.core.api.Assertions.assertThat; import java.lang.reflect.Field; @@ -10,12 +9,12 @@ import nl.jqno.equalsverifier.testhelpers.types.TypeHelper.PrimitiveContainer; import org.junit.jupiter.api.Test; -public class FieldModifierTest { +class FieldModifierTest { private static final String FIELD_NAME = "field"; @Test - public void copyToPrimitiveField() { + void copyToPrimitiveField() { int value = 10; PrimitiveContainer from = new PrimitiveContainer(); @@ -24,11 +23,11 @@ public void copyToPrimitiveField() { PrimitiveContainer to = new PrimitiveContainer(); doCopyField(to, from, FIELD_NAME); - assertEquals(value, to.field); + assertThat(to.field).isEqualTo(value); } @Test - public void copyToObjectField() { + void copyToObjectField() { Object value = new Object(); ObjectContainer from = new ObjectContainer(); @@ -37,7 +36,7 @@ public void copyToObjectField() { ObjectContainer to = new ObjectContainer(); doCopyField(to, from, FIELD_NAME); - assertSame(value, to.field); + assertThat(to.field).isSameAs(value); } private void doCopyField(Object to, Object from, String fieldName) { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/InPlaceObjectAccessorCopyingTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/InPlaceObjectAccessorCopyingTest.java index 54d9585cb..ae93e6d00 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/InPlaceObjectAccessorCopyingTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/InPlaceObjectAccessorCopyingTest.java @@ -1,8 +1,7 @@ package nl.jqno.equalsverifier.internal.instantiation.vintage.reflection; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertNotSame; -import static org.junit.jupiter.api.Assertions.assertTrue; import nl.jqno.equalsverifier.internal.exceptions.ReflectionException; import nl.jqno.equalsverifier.internal.reflection.FieldIterable; @@ -15,12 +14,12 @@ import org.objenesis.Objenesis; import org.objenesis.ObjenesisStd; -public class InPlaceObjectAccessorCopyingTest { +class InPlaceObjectAccessorCopyingTest { private Objenesis objenesis = new ObjenesisStd(); @Test - public void copyHappyPath() { + void copyHappyPath() { Point original = new Point(2, 3); Point copy = copyOf(original); @@ -28,22 +27,22 @@ public void copyHappyPath() { } @Test - public void shallowCopy() { + void shallowCopy() { PointContainer original = new PointContainer(new Point(1, 2)); PointContainer copy = copyOf(original); assertNotSame(original, copy); - assertTrue(original.getPoint() == copy.getPoint()); + assertThat(original.getPoint() == copy.getPoint()).isTrue(); } @Test - public void copyStaticFinal() { + void copyStaticFinal() { StaticFinalContainer foo = new StaticFinalContainer(); copyOf(foo); } @Test - public void inheritanceCopy() { + void inheritanceCopy() { Point3D original = new Point3D(2, 3, 4); Point3D copy = copyOf(original); @@ -52,11 +51,11 @@ public void inheritanceCopy() { } @Test - public void copyFromSub() { + void copyFromSub() { Point3D original = new Point3D(2, 3, 4); Point copy = copyOf(original, Point.class); - assertEquals(Point.class, copy.getClass()); + assertThat(copy.getClass()).isEqualTo(Point.class); assertAllFieldsEqual(original, copy, Point.class); } @@ -77,7 +76,7 @@ private static void assertAllFieldsEqual(T original, T copy, Class EMPTY_TYPE_STACK = new LinkedHashSet<>(); private Objenesis objenesis; private VintageValueProvider valueProviderTest; @BeforeEach - public void setup() { + void setup() { FactoryCache factoryCache = JavaApiPrefabValues.build(); factoryCache.put(Point.class, values(new Point(1, 2), new Point(2, 3), new Point(1, 2))); objenesis = new ObjenesisStd(); @@ -39,95 +39,95 @@ public void setup() { } @Test - public void scrambleReturnsThis() { + void scrambleReturnsThis() { Point original = new Point(2, 3); Point copy = copy(original); ObjectAccessor actual = doScramble(copy); - assertSame(copy, actual.get()); + assertThat(actual.get()).isSameAs(copy); } @Test - public void scramble() { + void scramble() { Point original = new Point(2, 3); Point copy = copy(original); - assertTrue(original.equals(copy)); + assertThat(copy).isEqualTo(original); doScramble(copy); - assertFalse(original.equals(copy)); + assertThat(copy).isNotEqualTo(original); } @Test - public void deepScramble() { + void deepScramble() { Point3D modified = new Point3D(2, 3, 4); Point3D reference = copy(modified); doScramble(modified); - assertFalse(modified.equals(reference)); + assertThat(reference).isNotEqualTo(modified); modified.z = 4; - assertFalse(modified.equals(reference)); + assertThat(reference).isNotEqualTo(modified); } @SuppressWarnings("static-access") @Test - public void scrambleStaticFinal() { + void scrambleStaticFinal() { StaticFinalContainer foo = new StaticFinalContainer(); int originalInt = StaticFinalContainer.CONST; Object originalObject = StaticFinalContainer.OBJECT; doScramble(foo); - assertEquals(originalInt, foo.CONST); - assertEquals(originalObject, foo.OBJECT); + assertThat(originalInt).isEqualTo(foo.CONST); + assertThat(originalObject).isEqualTo(foo.OBJECT); } @Test - public void scrambleString() { + void scrambleString() { StringContainer foo = new StringContainer(); String before = foo.s; doScramble(foo); - assertFalse(before.equals(foo.s)); + assertThat(foo.s).isNotEqualTo(before); } @Test - public void privateFinalStringCannotBeScrambled() { + void privateFinalStringCannotBeScrambled() { FinalAssignedStringContainer foo = new FinalAssignedStringContainer(); String before = foo.s; doScramble(foo); - assertEquals(before, foo.s); + assertThat(foo.s).isEqualTo(before); } @Test - public void scramblePrivateFinalPoint() { + void scramblePrivateFinalPoint() { FinalAssignedPointContainer foo = new FinalAssignedPointContainer(); Point before = foo.p; - assertTrue(before.equals(foo.p)); + assertThat(foo.p).isEqualTo(before); doScramble(foo); - assertFalse(before.equals(foo.p)); + assertThat(foo.p).isNotEqualTo(before); } @Test - public void scrambleNestedGenerics() { + void scrambleNestedGenerics() { GenericContainerContainer foo = new GenericContainerContainer(); - assertTrue(foo.strings.ts.isEmpty()); - assertTrue(foo.points.ts.isEmpty()); + assertThat(foo.strings.ts.isEmpty()).isTrue(); + assertThat(foo.points.ts.isEmpty()).isTrue(); doScramble(foo); - assertFalse(foo.strings.ts.isEmpty()); - assertEquals(String.class, foo.strings.ts.get(0).getClass()); - assertFalse(foo.points.ts.isEmpty()); - assertEquals(Point.class, foo.points.ts.get(0).getClass()); + assertThat(foo.strings.ts.isEmpty()).isFalse(); + assertThat(foo.strings.ts.get(0).getClass()).isEqualTo(String.class); + assertThat(foo.points.ts.isEmpty()).isFalse(); + assertThat(foo.points.ts.get(0).getClass()).isEqualTo(Point.class); } @Test @DisabledForJreRange(max = JRE.JAVA_11) - public void scrambleSutInaccessible() { + void scrambleSutInaccessible() { AttributedString as = new AttributedString("x"); ExpectedException @@ -139,7 +139,7 @@ public void scrambleSutInaccessible() { @Test @DisabledForJreRange(max = JRE.JAVA_11) - public void scrambleFieldInaccessible() { + void scrambleFieldInaccessible() { InaccessibleContainer ic = new InaccessibleContainer(new AttributedString("x")); ExpectedException.when(() -> doScramble(ic)).assertThrows(ModuleException.class); diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/InPlaceObjectAccessorTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/InPlaceObjectAccessorTest.java index 77a4a7c52..901505c53 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/InPlaceObjectAccessorTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/instantiation/vintage/reflection/InPlaceObjectAccessorTest.java @@ -1,25 +1,24 @@ package nl.jqno.equalsverifier.internal.instantiation.vintage.reflection; -import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import nl.jqno.equalsverifier.testhelpers.types.Point; import org.junit.jupiter.api.Test; -public class InPlaceObjectAccessorTest { +class InPlaceObjectAccessorTest { @Test - public void of() { + void of() { Point p = new Point(1, 2); ObjectAccessor actual = ObjectAccessor.of(p); - assertTrue(actual instanceof InPlaceObjectAccessor); + assertThat(actual instanceof InPlaceObjectAccessor).isTrue(); } @Test - public void get() { + void get() { Object foo = new Object(); InPlaceObjectAccessor accessor = create(foo); - assertSame(foo, accessor.get()); + assertThat(accessor.get()).isSameAs(foo); } @SuppressWarnings("unchecked") diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/ClassProbeTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/ClassProbeTest.java index f638f7d53..1cbc8749d 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/ClassProbeTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/ClassProbeTest.java @@ -1,6 +1,6 @@ package nl.jqno.equalsverifier.internal.reflection; -import static org.junit.jupiter.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; import nl.jqno.equalsverifier.testhelpers.types.ColorPoint3D; import nl.jqno.equalsverifier.testhelpers.types.Point3D; @@ -11,130 +11,130 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class ClassProbeTest { +class ClassProbeTest { private ClassProbe pointProbe; private ClassProbe abstractProbe; @BeforeEach - public void setup() { + void setup() { pointProbe = ClassProbe.of(PointContainer.class); abstractProbe = ClassProbe.of(AbstractEqualsAndHashCode.class); } @Test - public void getType() { - assertSame(PointContainer.class, pointProbe.getType()); + void getType() { + assertThat(pointProbe.getType()).isSameAs(PointContainer.class); } /* Tests the false case. The true case is tested in {@link ClassProbeCompilerTest}. */ @Test - public void isRecord() { - assertFalse(pointProbe.isRecord()); + void isRecord() { + assertThat(pointProbe.isRecord()).isFalse(); } /* Tests the false case. The true case is tested in {@link ClassProbeSealedTest}. */ @Test - public void isSealed() { - assertFalse(pointProbe.isSealed()); + void isSealed() { + assertThat(pointProbe.isSealed()).isFalse(); } @Test - public void declaresEquals() { - assertTrue(pointProbe.declaresEquals()); - assertTrue(abstractProbe.declaresEquals()); + void declaresEquals() { + assertThat(pointProbe.declaresEquals()).isTrue(); + assertThat(abstractProbe.declaresEquals()).isTrue(); } @Test - public void doesNotDeclareEquals() { + void doesNotDeclareEquals() { ClassProbe accessor = ClassProbe.of(Empty.class); - assertFalse(accessor.declaresEquals()); + assertThat(accessor.declaresEquals()).isFalse(); } @Test - public void declaresHashCode() { - assertTrue(pointProbe.declaresHashCode()); - assertTrue(abstractProbe.declaresHashCode()); + void declaresHashCode() { + assertThat(pointProbe.declaresHashCode()).isTrue(); + assertThat(abstractProbe.declaresHashCode()).isTrue(); } @Test - public void doesNotDeclareHashCode() { + void doesNotDeclareHashCode() { ClassProbe accessor = ClassProbe.of(Empty.class); - assertFalse(accessor.declaresHashCode()); + assertThat(accessor.declaresHashCode()).isFalse(); } @Test - public void hasMethod() { + void hasMethod() { ClassProbe accessor = ClassProbe.of(MethodContainer.class); - assertTrue(accessor.hasMethod("m")); + assertThat(accessor.hasMethod("m")).isTrue(); } @Test - public void hasProtectedMethod() { + void hasProtectedMethod() { ClassProbe accessor = ClassProbe.of(MethodContainer.class); - assertTrue(accessor.hasMethod("m_protected")); + assertThat(accessor.hasMethod("m_protected")).isTrue(); } @Test - public void hasMethodInSuper() { + void hasMethodInSuper() { ClassProbe accessor = ClassProbe.of(ChildOfMethodContainer.class); - assertTrue(accessor.hasMethod("m")); + assertThat(accessor.hasMethod("m")).isTrue(); } @Test - public void hasProtectedMethodInSuper() { + void hasProtectedMethodInSuper() { ClassProbe accessor = ClassProbe.of(ChildOfMethodContainer.class); - assertTrue(accessor.hasMethod("m_protected")); + assertThat(accessor.hasMethod("m_protected")).isTrue(); } @Test - public void doesNotHaveMethod() { + void doesNotHaveMethod() { ClassProbe accessor = ClassProbe.of(MethodContainer.class); - assertFalse(accessor.hasMethod("doesNotExist")); + assertThat(accessor.hasMethod("doesNotExist")).isFalse(); } @Test - public void equalsIsNotAbstract() { - assertFalse(pointProbe.isEqualsAbstract()); + void equalsIsNotAbstract() { + assertThat(pointProbe.isEqualsAbstract()).isFalse(); } @Test - public void equalsIsAbstract() { - assertTrue(abstractProbe.isEqualsAbstract()); + void equalsIsAbstract() { + assertThat(abstractProbe.isEqualsAbstract()).isTrue(); } @Test - public void hashCodeIsNotAbstract() { - assertFalse(pointProbe.isHashCodeAbstract()); + void hashCodeIsNotAbstract() { + assertThat(pointProbe.isHashCodeAbstract()).isFalse(); } @Test - public void hashCodeIsAbstract() { - assertTrue(abstractProbe.isHashCodeAbstract()); + void hashCodeIsAbstract() { + assertThat(abstractProbe.isHashCodeAbstract()).isTrue(); } @Test - public void equalsIsInheritedFromObject() { + void equalsIsInheritedFromObject() { ClassProbe accessor = ClassProbe.of(NoFieldsSubWithFields.class); - assertTrue(accessor.isEqualsInheritedFromObject()); + assertThat(accessor.isEqualsInheritedFromObject()).isTrue(); } @Test - public void equalsIsNotInheritedFromObject() { - assertFalse(pointProbe.isEqualsInheritedFromObject()); + void equalsIsNotInheritedFromObject() { + assertThat(pointProbe.isEqualsInheritedFromObject()).isFalse(); } @Test - public void getSuperAccessorForPojo() { + void getSuperAccessorForPojo() { ClassProbe superAccessor = pointProbe.getSuperProbe(); - assertEquals(Object.class, superAccessor.getType()); + assertThat(superAccessor.getType()).isEqualTo(Object.class); } @Test - public void getSuperAccessorInHierarchy() { + void getSuperAccessorInHierarchy() { ClassProbe accessor = ClassProbe.of(ColorPoint3D.class); ClassProbe superAccessor = accessor.getSuperProbe(); - assertEquals(Point3D.class, superAccessor.getType()); + assertThat(superAccessor.getType()).isEqualTo(Point3D.class); } static class MethodContainer { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/ConditionalInstantiatorTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/ConditionalInstantiatorTest.java index 3100a9388..588e53582 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/ConditionalInstantiatorTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/ConditionalInstantiatorTest.java @@ -2,11 +2,11 @@ import static nl.jqno.equalsverifier.internal.reflection.Util.classes; import static nl.jqno.equalsverifier.internal.reflection.Util.objects; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; import java.math.BigDecimal; import java.util.Calendar; @@ -17,22 +17,22 @@ import nl.jqno.equalsverifier.internal.exceptions.ReflectionException; import org.junit.jupiter.api.Test; -public class ConditionalInstantiatorTest { +class ConditionalInstantiatorTest { private static final String THIS_TYPE_DOES_NOT_EXIST = "this.type.does.not.Exist"; private ConditionalInstantiator ci; @Test - public void resolveReturnsClass_whenTypeExists() { + void resolveReturnsClass_whenTypeExists() { ci = new ConditionalInstantiator("java.util.GregorianCalendar"); Class actual = ci.resolve(); - assertEquals(actual, GregorianCalendar.class); + assertThat(actual).isEqualTo(GregorianCalendar.class); } @Test - public void resolveReturnsNull_whenTypeDoesntExist() { + void resolveReturnsNull_whenTypeDoesntExist() { ci = new ConditionalInstantiator(THIS_TYPE_DOES_NOT_EXIST); Class actual = ci.resolve(); @@ -40,7 +40,7 @@ public void resolveReturnsNull_whenTypeDoesntExist() { } @Test - public void objectIsInstantiatedCorrectly_whenValidConstructorParametersAreProvided() { + void objectIsInstantiatedCorrectly_whenValidConstructorParametersAreProvided() { ci = new ConditionalInstantiator("java.util.GregorianCalendar"); Calendar expected = new GregorianCalendar(1999, 11, 31); @@ -49,23 +49,22 @@ public void objectIsInstantiatedCorrectly_whenValidConstructorParametersAreProvi } @Test - public void nullIsReturned_whenInstantiateIsCalled_givenTypeDoesNotExist() { + void nullIsReturned_whenInstantiateIsCalled_givenTypeDoesNotExist() { ci = new ConditionalInstantiator(THIS_TYPE_DOES_NOT_EXIST); Object actual = ci.instantiate(classes(String.class), objects("nope")); assertThat(actual, is(nullValue())); } @Test - public void throwsIse_whenInvalidConstructorParametersAreProvided() { + void throwsIse_whenInvalidConstructorParametersAreProvided() { ci = new ConditionalInstantiator("java.util.GregorianCalendar"); - assertThrows( - ReflectionException.class, - () -> ci.instantiate(classes(int.class, int.class, int.class), objects(1999, 31, "hello"))); + assertThatExceptionOfType(ReflectionException.class) + .isThrownBy(() -> ci.instantiate(classes(int.class, int.class, int.class), objects(1999, 31, "hello"))); } @Test - public void nullIsReturned_whenInvalidConstructorParametersAreProvided_givenFalse() { + void nullIsReturned_whenInvalidConstructorParametersAreProvided_givenFalse() { ci = new ConditionalInstantiator("java.util.GregorianCalendar", false); Object actual = ci.instantiate(classes(int.class, int.class, int.class), objects(1999, 31, "hello")); @@ -73,7 +72,7 @@ public void nullIsReturned_whenInvalidConstructorParametersAreProvided_givenFals } @Test - public void objectIsInstantiatedCorrectly_whenValidFactoryMethodAndParametersAreProvided() { + void objectIsInstantiatedCorrectly_whenValidFactoryMethodAndParametersAreProvided() { ci = new ConditionalInstantiator("java.lang.Integer"); int expected = Integer.valueOf(42); @@ -82,23 +81,22 @@ public void objectIsInstantiatedCorrectly_whenValidFactoryMethodAndParametersAre } @Test - public void nullIsReturned_whenFactoryIsCalled_givenTypeDoesNotExist() { + void nullIsReturned_whenFactoryIsCalled_givenTypeDoesNotExist() { ci = new ConditionalInstantiator(THIS_TYPE_DOES_NOT_EXIST); Object actual = ci.callFactory("factory", classes(String.class), objects("nope")); assertThat(actual, is(nullValue())); } @Test - public void throwsIse_whenInvalidMethodNameIsProvided() { + void throwsIse_whenInvalidMethodNameIsProvided() { ci = new ConditionalInstantiator("java.lang.Integer"); - assertThrows( - ReflectionException.class, - () -> ci.callFactory("thisMethodDoesntExist", classes(int.class), objects(42))); + assertThatExceptionOfType(ReflectionException.class) + .isThrownBy(() -> ci.callFactory("thisMethodDoesntExist", classes(int.class), objects(42))); } @Test - public void nullIsReturned_whenInvalidMethodNameIsProvided_givenFalse() { + void nullIsReturned_whenInvalidMethodNameIsProvided_givenFalse() { ci = new ConditionalInstantiator("java.lang.Integer", false); Object actual = ci.callFactory("thisMethodDoesntExist", classes(int.class), objects(42)); @@ -106,16 +104,15 @@ public void nullIsReturned_whenInvalidMethodNameIsProvided_givenFalse() { } @Test - public void throwsIse_whenInvalidFactoryMethodParametersAreProvided() { + void throwsIse_whenInvalidFactoryMethodParametersAreProvided() { ci = new ConditionalInstantiator("java.lang.Integer"); - assertThrows( - ReflectionException.class, - () -> ci.callFactory("valueOf", classes(int.class, int.class), objects(42))); + assertThatExceptionOfType(ReflectionException.class) + .isThrownBy(() -> ci.callFactory("valueOf", classes(int.class, int.class), objects(42))); } @Test - public void nullIsReturned_whenInvalidFactoryMethodParametersAreProvided_givenFalse() { + void nullIsReturned_whenInvalidFactoryMethodParametersAreProvided_givenFalse() { ci = new ConditionalInstantiator("java.lang.Integer", false); Object actual = ci.callFactory("valueOf", classes(int.class, int.class), objects(42)); @@ -123,7 +120,7 @@ public void nullIsReturned_whenInvalidFactoryMethodParametersAreProvided_givenFa } @Test - public void objectIsInstantiatedCorrectly_whenValidExternalFactoryMethodAndParametersAreProvided() { + void objectIsInstantiatedCorrectly_whenValidExternalFactoryMethodAndParametersAreProvided() { ci = new ConditionalInstantiator("java.util.List"); List expected = Collections.emptyList(); @@ -132,23 +129,22 @@ public void objectIsInstantiatedCorrectly_whenValidExternalFactoryMethodAndParam } @Test - public void nullIsReturned_whenExternalFactoryIsCalled_givenTypeDoesNotExist() { + void nullIsReturned_whenExternalFactoryIsCalled_givenTypeDoesNotExist() { ci = new ConditionalInstantiator(THIS_TYPE_DOES_NOT_EXIST); Object actual = ci.callFactory("java.util.Collections", "emptyList", classes(), objects()); assertThat(actual, is(nullValue())); } @Test - public void throwsIse_whenExternalFactoryIsCalled_givenFactoryTypeDoesNotExist() { + void throwsIse_whenExternalFactoryIsCalled_givenFactoryTypeDoesNotExist() { ci = new ConditionalInstantiator("java.util.List"); - assertThrows( - ReflectionException.class, - () -> ci.callFactory("java.util.ThisTypeDoesNotExist", "emptyList", classes(), objects())); + assertThatExceptionOfType(ReflectionException.class) + .isThrownBy(() -> ci.callFactory("java.util.ThisTypeDoesNotExist", "emptyList", classes(), objects())); } @Test - public void nullIsReturned_whenExternalFactoryIsCalled_givenFactoryTypeDoesNotExist_givenFalse() { + void nullIsReturned_whenExternalFactoryIsCalled_givenFactoryTypeDoesNotExist_givenFalse() { ci = new ConditionalInstantiator("java.util.List", false); Object actual = ci.callFactory("java.util.ThisTypeDoesNotExist", "emptyList", classes(), objects()); @@ -156,16 +152,16 @@ public void nullIsReturned_whenExternalFactoryIsCalled_givenFactoryTypeDoesNotEx } @Test - public void throwsIse_whenInvalidExternalFactoryMethodNameIsProvided() { + void throwsIse_whenInvalidExternalFactoryMethodNameIsProvided() { ci = new ConditionalInstantiator("java.util.List"); - assertThrows( - ReflectionException.class, - () -> ci.callFactory("java.util.Collections", "thisMethodDoesntExist", classes(), objects())); + assertThatExceptionOfType(ReflectionException.class) + .isThrownBy( + () -> ci.callFactory("java.util.Collections", "thisMethodDoesntExist", classes(), objects())); } @Test - public void nullIsReturned_whenInvalidExternalFactoryMethodNameIsProvided_givenFalse() { + void nullIsReturned_whenInvalidExternalFactoryMethodNameIsProvided_givenFalse() { ci = new ConditionalInstantiator("java.util.List", false); Object actual = ci.callFactory("java.util.Collections", "thisMethodDoesntExist", classes(), objects()); @@ -173,16 +169,16 @@ public void nullIsReturned_whenInvalidExternalFactoryMethodNameIsProvided_givenF } @Test - public void throwsIse_whenInvalidExternalFactoryMethodParametersAreProvided() { + void throwsIse_whenInvalidExternalFactoryMethodParametersAreProvided() { ci = new ConditionalInstantiator("java.util.List"); - assertThrows( - ReflectionException.class, - () -> ci.callFactory("java.util.Collections", "emptyList", classes(int.class), objects(42))); + assertThatExceptionOfType(ReflectionException.class) + .isThrownBy( + () -> ci.callFactory("java.util.Collections", "emptyList", classes(int.class), objects(42))); } @Test - public void nullIsReturned_whenInvalidExternalFactoryMethodParametersAreProvided_givenFalse() { + void nullIsReturned_whenInvalidExternalFactoryMethodParametersAreProvided_givenFalse() { ci = new ConditionalInstantiator("java.util.List", false); Object actual = ci.callFactory("java.util.Collections", "emptyList", classes(int.class), objects(42)); @@ -190,14 +186,14 @@ public void nullIsReturned_whenInvalidExternalFactoryMethodParametersAreProvided } @Test - public void nullIsReturned_whenReturnConstantIsCalled_givenTypeDoesNotExist() { + void nullIsReturned_whenReturnConstantIsCalled_givenTypeDoesNotExist() { ci = new ConditionalInstantiator(THIS_TYPE_DOES_NOT_EXIST); Object actual = ci.returnConstant("NOPE"); assertThat(actual, is(nullValue())); } @Test - public void objectIsReturned_whenValidConstantIsProvided() { + void objectIsReturned_whenValidConstantIsProvided() { ci = new ConditionalInstantiator("java.math.BigDecimal"); BigDecimal expected = BigDecimal.TEN; @@ -206,14 +202,14 @@ public void objectIsReturned_whenValidConstantIsProvided() { } @Test - public void throwsIse_whenConstantDoesNotExist() { + void throwsIse_whenConstantDoesNotExist() { ci = new ConditionalInstantiator("java.math.BigDecimal"); - assertThrows(ReflectionException.class, () -> ci.returnConstant("FORTY-TWO")); + assertThatExceptionOfType(ReflectionException.class).isThrownBy(() -> ci.returnConstant("FORTY-TWO")); } @Test - public void nullIsReturned_whenConstantDoesNotExist_givenFalse() { + void nullIsReturned_whenConstantDoesNotExist_givenFalse() { ci = new ConditionalInstantiator("java.math.BigDecimal", false); Object actual = ci.returnConstant("FORTY-TWO"); diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldCacheTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldCacheTest.java index d4dd872a9..f967a8d17 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldCacheTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldCacheTest.java @@ -1,6 +1,6 @@ package nl.jqno.equalsverifier.internal.reflection; -import static org.junit.jupiter.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; import java.util.Collections; import java.util.HashSet; @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test; -public class FieldCacheTest { +class FieldCacheTest { private String stringField = "string"; private final Tuple stringValues = Tuple.of("red", "blue", "red"); @@ -19,44 +19,44 @@ public class FieldCacheTest { private FieldCache cache = new FieldCache(); @Test - public void putAndGetTuple() { + void putAndGetTuple() { cache.put(stringField, stringValues); - assertEquals(stringValues, cache.get(stringField)); + assertThat(cache.get(stringField)).isEqualTo(stringValues); } @Test - public void putTwiceAndGetBoth() { + void putTwiceAndGetBoth() { cache.put(stringField, stringValues); cache.put(intField, intValues); - assertEquals(intValues, cache.get(intField)); - assertEquals(stringValues, cache.get(stringField)); + assertThat(cache.get(intField)).isEqualTo(intValues); + assertThat(cache.get(stringField)).isEqualTo(stringValues); } @Test - public void putNullAndGetNothingBack() { + void putNullAndGetNothingBack() { cache.put(null, stringValues); - assertNull(cache.get(null)); + assertThat(cache.get(null)).isNull(); } @Test - public void contains() { + void contains() { cache.put(stringField, stringValues); - assertTrue(cache.contains(stringField)); + assertThat(cache.contains(stringField)).isTrue(); } @Test - public void doesntContain() { - assertFalse(cache.contains(stringField)); + void doesntContain() { + assertThat(cache.contains(stringField)).isFalse(); } @Test - public void getFieldNames() { - assertEquals(Collections.emptySet(), cache.getFieldNames()); + void getFieldNames() { + assertThat(cache.getFieldNames()).isEqualTo(Collections.emptySet()); cache.put(stringField, stringValues); Set expected = new HashSet<>(); expected.add(stringField); - assertEquals(expected, cache.getFieldNames()); + assertThat(cache.getFieldNames()).isEqualTo(expected); } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldIterableTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldIterableTest.java index 5e8366ac8..95ca4338d 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldIterableTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldIterableTest.java @@ -1,8 +1,7 @@ package nl.jqno.equalsverifier.internal.reflection; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; import java.lang.reflect.Field; import java.util.*; @@ -10,7 +9,7 @@ import nl.jqno.equalsverifier.testhelpers.types.TypeHelper.*; import org.junit.jupiter.api.Test; -public class FieldIterableTest { +class FieldIterableTest { private static final Set FIELD_CONTAINER_FIELDS = createFieldContainerFields(); private static final Set NONSTATIC_FIELD_CONTAINER_FIELDS = createNonStaticFieldContainerFields(); @@ -18,53 +17,53 @@ public class FieldIterableTest { private static final Set FIELD_AND_SUB_FIELD_CONTAINER_FIELDS = createFieldAndSubFieldContainerFields(); @Test - public void simpleFields() { + void simpleFields() { Set actual = new HashSet<>(); for (FieldProbe probe : FieldIterable.of(DifferentAccessModifiersFieldContainer.class)) { actual.add(probe.getField()); } - assertEquals(FIELD_CONTAINER_FIELDS, actual); + assertThat(actual).isEqualTo(FIELD_CONTAINER_FIELDS); } @Test - public void simpleFieldsWithoutStatics() { + void simpleFieldsWithoutStatics() { Set actual = new HashSet<>(); for (FieldProbe probe : FieldIterable.ofIgnoringStatic(DifferentAccessModifiersFieldContainer.class)) { actual.add(probe.getField()); } - assertEquals(NONSTATIC_FIELD_CONTAINER_FIELDS, actual); + assertThat(actual).isEqualTo(NONSTATIC_FIELD_CONTAINER_FIELDS); } @Test - public void subAndSuperClassFields() { + void subAndSuperClassFields() { Set actual = new HashSet<>(); for (FieldProbe probe : FieldIterable.of(DifferentAccessModifiersSubFieldContainer.class)) { actual.add(probe.getField()); } - assertEquals(FIELD_AND_SUB_FIELD_CONTAINER_FIELDS, actual); + assertThat(actual).isEqualTo(FIELD_AND_SUB_FIELD_CONTAINER_FIELDS); } @Test - public void onlySubClassFields() { + void onlySubClassFields() { Set actual = new HashSet<>(); for (FieldProbe probe : FieldIterable.ofIgnoringSuper(DifferentAccessModifiersSubFieldContainer.class)) { actual.add(probe.getField()); } - assertEquals(SUB_FIELD_CONTAINER_FIELDS, actual); + assertThat(actual).isEqualTo(SUB_FIELD_CONTAINER_FIELDS); } @Test - public void noFields() { + void noFields() { FieldIterable iterable = FieldIterable.of(NoFields.class); - assertFalse(iterable.iterator().hasNext()); + assertThat(iterable.iterator().hasNext()).isFalse(); } @Test - public void superHasNoFields() throws NoSuchFieldException { + void superHasNoFields() throws NoSuchFieldException { Set expected = new HashSet<>(); expected.add(NoFieldsSubWithFields.class.getField("field")); @@ -73,21 +72,21 @@ public void superHasNoFields() throws NoSuchFieldException { actual.add(probe.getField()); } - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void subHasNoFields() { + void subHasNoFields() { Set actual = new HashSet<>(); for (FieldProbe probe : FieldIterable.of(EmptySubFieldContainer.class)) { actual.add(probe.getField()); } - assertEquals(FIELD_CONTAINER_FIELDS, actual); + assertThat(actual).isEqualTo(FIELD_CONTAINER_FIELDS); } @Test - public void classInTheMiddleHasNoFields() throws NoSuchFieldException { + void classInTheMiddleHasNoFields() throws NoSuchFieldException { Set expected = new HashSet<>(); expected.addAll(FIELD_CONTAINER_FIELDS); expected.add(SubEmptySubFieldContainer.class.getDeclaredField("field")); @@ -97,57 +96,57 @@ public void classInTheMiddleHasNoFields() throws NoSuchFieldException { actual.add(probe.getField()); } - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void orderingTest() { + void orderingTest() { FieldIterable iterable = FieldIterable.of(UnorderedFieldContainer.class); List actual = new ArrayList<>(); for (FieldProbe probe : iterable) { actual.add(probe.getName()); } - assertEquals(Arrays.asList("one", "two", "THREE", "FOUR"), actual); + assertThat(actual).isEqualTo(Arrays.asList("one", "two", "THREE", "FOUR")); } @Test - public void interfaceTest() { + void interfaceTest() { FieldIterable iterable = FieldIterable.of(Interface.class); - assertFalse(iterable.iterator().hasNext()); + assertThat(iterable.iterator().hasNext()).isFalse(); } @Test - public void nextAfterLastElement() { + void nextAfterLastElement() { Iterator iterator = FieldIterable.of(DifferentAccessModifiersFieldContainer.class).iterator(); while (iterator.hasNext()) { iterator.next(); } - assertThrows(NoSuchElementException.class, () -> iterator.next()); + assertThatExceptionOfType(NoSuchElementException.class).isThrownBy(() -> iterator.next()); } @Test - public void objectHasNoElements() { + void objectHasNoElements() { FieldIterable iterable = FieldIterable.of(Object.class); - assertFalse(iterable.iterator().hasNext()); + assertThat(iterable.iterator().hasNext()).isFalse(); } @Test - public void ignoreSyntheticFields() { + void ignoreSyntheticFields() { FieldIterable iterable = FieldIterable.of(Outer.Inner.class); - assertFalse(iterable.iterator().hasNext()); + assertThat(iterable.iterator().hasNext()).isFalse(); } @Test - public void ignoreNonSyntheticCoberturaFields() { + void ignoreNonSyntheticCoberturaFields() { FieldIterable iterable = FieldIterable.of(CoberturaContainer.class); List fields = new ArrayList<>(); for (FieldProbe probe : iterable) { fields.add(probe.getField()); } - assertEquals(1, fields.size()); - assertEquals("i", fields.get(0).getName()); + assertThat(fields.size()).isEqualTo(1); + assertThat(fields.get(0).getName()).isEqualTo("i"); } private static Set createFieldContainerFields() { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldMutatorTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldMutatorTest.java index d6ec87c5d..7d8e485ac 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldMutatorTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldMutatorTest.java @@ -1,53 +1,53 @@ package nl.jqno.equalsverifier.internal.reflection; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; -public class FieldMutatorTest { +class FieldMutatorTest { private FieldProbe p; private FieldMutator sut; private Container o = new Container(); @Test - public void setPrimitive() throws NoSuchFieldException { + void setPrimitive() throws NoSuchFieldException { p = FieldProbe.of(Container.class.getDeclaredField("i")); sut = new FieldMutator(p); - assertEquals(10, o.i); + assertThat(o.i).isEqualTo(10); sut.setNewValue(o, 1337); - assertEquals(1337, o.i); + assertThat(o.i).isEqualTo(1337); } @Test - public void setObject() throws NoSuchFieldException { + void setObject() throws NoSuchFieldException { p = FieldProbe.of(Container.class.getDeclaredField("s")); sut = new FieldMutator(p); - assertEquals("NON-FINAL", o.s); + assertThat(o.s).isEqualTo("NON-FINAL"); sut.setNewValue(o, "changed"); - assertEquals("changed", o.s); + assertThat(o.s).isEqualTo("changed"); } @Test - public void dontSetConstantPrimitive() throws NoSuchFieldException { + void dontSetConstantPrimitive() throws NoSuchFieldException { p = FieldProbe.of(Container.class.getDeclaredField("FINAL_INT")); sut = new FieldMutator(p); - assertEquals(42, Container.FINAL_INT); + assertThat(Container.FINAL_INT).isEqualTo(42); sut.setNewValue(o, 1337); - assertEquals(42, Container.FINAL_INT); + assertThat(Container.FINAL_INT).isEqualTo(42); } @Test - public void dontSetConstantObject() throws NoSuchFieldException { + void dontSetConstantObject() throws NoSuchFieldException { p = FieldProbe.of(Container.class.getDeclaredField("FINAL_STRING")); sut = new FieldMutator(p); - assertEquals("FINAL", Container.FINAL_STRING); + assertThat(Container.FINAL_STRING).isEqualTo("FINAL"); sut.setNewValue(o, "changed"); - assertEquals("FINAL", Container.FINAL_STRING); + assertThat(Container.FINAL_STRING).isEqualTo("FINAL"); } static class Container { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldProbeTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldProbeTest.java index 22b0656a1..1fabe15cc 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldProbeTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/FieldProbeTest.java @@ -1,6 +1,6 @@ package nl.jqno.equalsverifier.internal.reflection; -import static org.junit.jupiter.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; import java.lang.reflect.Field; @@ -12,176 +12,176 @@ /* * FieldProbe.isAnnotatedNonnull() is tested in AnnotationNonnullTest */ -public class FieldProbeTest { +class FieldProbeTest { private static final String FIELD_NAME = "field"; private Configuration config = ConfigurationHelper.emptyConfiguration(ObjectContainer.class); @Test - public void getField() throws NoSuchFieldException { + void getField() throws NoSuchFieldException { ObjectContainer foo = new ObjectContainer(); Field field = foo.getClass().getDeclaredField(FIELD_NAME); FieldProbe probe = FieldProbe.of(field); - assertSame(field, probe.getField()); + assertThat(probe.getField()).isSameAs(field); } @Test - public void getType() { + void getType() { FieldProbe probe = getProbeFor(ObjectContainer.class, FIELD_NAME); - assertEquals(Object.class, probe.getType()); + assertThat(probe.getType()).isEqualTo(Object.class); } @Test - public void getName() { + void getName() { FieldProbe probe = getProbeFor(ObjectContainer.class, FIELD_NAME); - assertEquals(FIELD_NAME, probe.getName()); + assertThat(probe.getName()).isEqualTo(FIELD_NAME); } @Test - public void isNotPublic() { + void isNotPublic() { FieldProbe probe = getProbeFor(DifferentAccessModifiersFieldContainer.class, "K"); - assertFalse(probe.isPublic()); + assertThat(probe.isPublic()).isFalse(); } @Test - public void isPublic() { + void isPublic() { FieldProbe probe = getProbeFor(DifferentAccessModifiersFieldContainer.class, "L"); - assertTrue(probe.isPublic()); + assertThat(probe.isPublic()).isTrue(); } @Test - public void isNotPrimitive() { + void isNotPrimitive() { FieldProbe probe = getProbeFor(ObjectContainer.class, FIELD_NAME); - assertFalse(probe.isPrimitive()); + assertThat(probe.isPrimitive()).isFalse(); } @Test - public void isPrimitive() { + void isPrimitive() { FieldProbe probe = getProbeFor(PrimitiveContainer.class, FIELD_NAME); - assertTrue(probe.isPrimitive()); + assertThat(probe.isPrimitive()).isTrue(); } @Test - public void isNotFinal() { + void isNotFinal() { FieldProbe probe = getProbeFor(ObjectContainer.class, FIELD_NAME); - assertFalse(probe.isFinal()); + assertThat(probe.isFinal()).isFalse(); } @Test - public void isFinal() { + void isFinal() { FieldProbe probe = getProbeFor(FinalContainer.class, FIELD_NAME); - assertTrue(probe.isFinal()); + assertThat(probe.isFinal()).isTrue(); } @Test - public void isNotStatic() { + void isNotStatic() { FieldProbe probe = getProbeFor(ObjectContainer.class, FIELD_NAME); - assertFalse(probe.isStatic()); + assertThat(probe.isStatic()).isFalse(); } @Test - public void isStatic() { + void isStatic() { FieldProbe probe = getProbeFor(StaticContainer.class, FIELD_NAME); - assertTrue(probe.isStatic()); + assertThat(probe.isStatic()).isTrue(); } @Test - public void isNotTransient() { + void isNotTransient() { FieldProbe probe = getProbeFor(ObjectContainer.class, FIELD_NAME); - assertFalse(probe.isTransient()); + assertThat(probe.isTransient()).isFalse(); } @Test - public void isTransient() { + void isTransient() { FieldProbe probe = getProbeFor(TransientContainer.class, FIELD_NAME); - assertTrue(probe.isTransient()); + assertThat(probe.isTransient()).isTrue(); } @Test - public void isNotEnum() { + void isNotEnum() { FieldProbe probe = getProbeFor(PrimitiveContainer.class, FIELD_NAME); - assertFalse(probe.isEmptyOrSingleValueEnum()); + assertThat(probe.isEmptyOrSingleValueEnum()).isFalse(); } @Test - public void isEnumButNotSingleValue() { + void isEnumButNotSingleValue() { FieldProbe probe = getProbeFor(EnumContainer.class, "twoElementEnum"); - assertFalse(probe.isEmptyOrSingleValueEnum()); + assertThat(probe.isEmptyOrSingleValueEnum()).isFalse(); } @Test - public void isSingleValueEnum() { + void isSingleValueEnum() { FieldProbe probe = getProbeFor(EnumContainer.class, "oneElementEnum"); - assertTrue(probe.isEmptyOrSingleValueEnum()); + assertThat(probe.isEmptyOrSingleValueEnum()).isTrue(); } @Test - public void isEmptyEnum() { + void isEmptyEnum() { FieldProbe probe = getProbeFor(EnumContainer.class, "emptyEnum"); - assertTrue(probe.isEmptyOrSingleValueEnum()); + assertThat(probe.isEmptyOrSingleValueEnum()).isTrue(); } @Test - public void canBeDefault_forObject() { + void canBeDefault_forObject() { FieldProbe probe = getProbeFor(ObjectContainer.class, FIELD_NAME); - assertTrue(probe.canBeDefault(config)); + assertThat(probe.canBeDefault(config)).isTrue(); } @Test - public void canBeDefault_primitive() { + void canBeDefault_primitive() { FieldProbe probe = getProbeFor(PrimitiveContainer.class, FIELD_NAME); - assertTrue(probe.canBeDefault(config)); + assertThat(probe.canBeDefault(config)).isTrue(); } @Test - public void canBeDefault_primitiveWithPrefabbedField() { + void canBeDefault_primitiveWithPrefabbedField() { config = ConfigurationHelper.emptyConfigurationWithPrefabbedFields(PrimitiveContainer.class, FIELD_NAME); FieldProbe probe = getProbeFor(PrimitiveContainer.class, FIELD_NAME); - assertFalse(probe.canBeDefault(config)); + assertThat(probe.canBeDefault(config)).isFalse(); } @Test - public void canBeDefault_isMentionedExplicitly() { + void canBeDefault_isMentionedExplicitly() { config = ConfigurationHelper.emptyConfigurationWithNonnullFields(ObjectContainer.class, FIELD_NAME); FieldProbe probe = getProbeFor(ObjectContainer.class, FIELD_NAME); - assertFalse(probe.canBeDefault(config)); + assertThat(probe.canBeDefault(config)).isFalse(); } @Test - public void canBeDefault_annotated() { + void canBeDefault_annotated() { config = ConfigurationHelper.emptyConfigurationWithNonnullFields(NonNullContainer.class, FIELD_NAME); FieldProbe probe = getProbeFor(NonNullContainer.class, FIELD_NAME); - assertFalse(probe.canBeDefault(config)); + assertThat(probe.canBeDefault(config)).isFalse(); } @Test - public void canBeModifiedReflectively_synthetic() { + void canBeModifiedReflectively_synthetic() { FieldProbe probe = getProbeFor(NonStaticInner.class, "this$0"); - assertFalse(probe.canBeModifiedReflectively()); + assertThat(probe.canBeModifiedReflectively()).isFalse(); } @Test - public void canBeModifiedReflectively_staticFinal() { + void canBeModifiedReflectively_staticFinal() { FieldProbe publicStaticFinal = getProbeFor(ModifierMix.class, "PUBLIC_STATIC_FINAL"); - assertFalse(publicStaticFinal.canBeModifiedReflectively()); + assertThat(publicStaticFinal.canBeModifiedReflectively()).isFalse(); } @Test - public void canBeModifiedReflectively_static() { + void canBeModifiedReflectively_static() { FieldProbe publicStatic = getProbeFor(ModifierMix.class, "publicStatic"); - assertTrue(publicStatic.canBeModifiedReflectively()); + assertThat(publicStatic.canBeModifiedReflectively()).isTrue(); } @Test - public void canBeModifiedReflectively_final() { + void canBeModifiedReflectively_final() { FieldProbe publicFinal = getProbeFor(ModifierMix.class, "publicFinal"); - assertTrue(publicFinal.canBeModifiedReflectively()); + assertThat(publicFinal.canBeModifiedReflectively()).isTrue(); } @Test - public void canBeModifiedReflectively_noModifiers() { + void canBeModifiedReflectively_noModifiers() { FieldProbe publicNothingElse = getProbeFor(ModifierMix.class, "publicNothingElse"); - assertTrue(publicNothingElse.canBeModifiedReflectively()); + assertThat(publicNothingElse.canBeModifiedReflectively()).isTrue(); } private FieldProbe getProbeFor(Class type, String fieldName) { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/InstantiatorTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/InstantiatorTest.java index 18b0d5042..c787e3b4b 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/InstantiatorTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/InstantiatorTest.java @@ -1,9 +1,6 @@ package nl.jqno.equalsverifier.internal.reflection; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import java.lang.reflect.Field; import java.util.List; @@ -22,58 +19,58 @@ import org.objenesis.ObjenesisStd; import org.w3c.dom.Element; -public class InstantiatorTest { +class InstantiatorTest { private Objenesis objenesis = new ObjenesisStd(); @Test - public void instantiateClass() { + void instantiateClass() { Instantiator instantiator = Instantiator.of(Point.class, objenesis); Point p = instantiator.instantiate(); - assertEquals(Point.class, p.getClass()); + assertThat(p.getClass()).isEqualTo(Point.class); } @Test - public void fieldsOfInstantiatedObjectHaveDefaultValues() { + void fieldsOfInstantiatedObjectHaveDefaultValues() { ColorBlindColorPoint p = Instantiator.of(ColorBlindColorPoint.class, objenesis).instantiate(); - assertEquals(0, p.x); - assertEquals(null, p.color); + assertThat(p.x).isEqualTo(0); + assertThat(p.color).isNull(); } @Test - public void instantiateInterface() { + void instantiateInterface() { Instantiator instantiator = Instantiator.of(Interface.class, objenesis); Interface i = instantiator.instantiate(); - assertTrue(Interface.class.isAssignableFrom(i.getClass())); + assertThat(Interface.class.isAssignableFrom(i.getClass())).isTrue(); } @Test - public void instantiateFinalClass() { + void instantiateFinalClass() { Instantiator.of(FinalPoint.class, objenesis); } @Test - public void instantiateArrayContainer() { + void instantiateArrayContainer() { Instantiator.of(ArrayContainer.class, objenesis); } @Test - public void instantiateAbstractClass() { + void instantiateAbstractClass() { Instantiator instantiator = Instantiator.of(AbstractClass.class, objenesis); AbstractClass ac = instantiator.instantiate(); - assertTrue(AbstractClass.class.isAssignableFrom(ac.getClass())); + assertThat(AbstractClass.class.isAssignableFrom(ac.getClass())).isTrue(); } @Test - public void instantiateSubclass() { + void instantiateSubclass() { Instantiator instantiator = Instantiator.of(Point.class, objenesis); Point p = instantiator.instantiateAnonymousSubclass(); - assertFalse(p.getClass() == Point.class); - assertTrue(Point.class.isAssignableFrom(p.getClass())); + assertThat(p.getClass() == Point.class).isFalse(); + assertThat(Point.class.isAssignableFrom(p.getClass())).isTrue(); } @Test - public void instantiateAnNonToplevelClass() { + void instantiateAnNonToplevelClass() { class Something {} Instantiator instantiator = Instantiator.of(Something.class, objenesis); instantiator.instantiateAnonymousSubclass(); @@ -81,27 +78,27 @@ class Something {} @Test @SuppressWarnings("rawtypes") - public void instantiateJavaApiClassWhichHasBootstrapClassLoader() { + void instantiateJavaApiClassWhichHasBootstrapClassLoader() { Instantiator instantiator = Instantiator.of(List.class, objenesis); instantiator.instantiateAnonymousSubclass(); } @Test - public void instantiateOrgW3cDomClassWhichHasBootstrapClassLoader() { + void instantiateOrgW3cDomClassWhichHasBootstrapClassLoader() { Instantiator instantiator = Instantiator.of(Element.class, objenesis); instantiator.instantiateAnonymousSubclass(); } @Test - public void instantiateTheSameSubclass() { + void instantiateTheSameSubclass() { Instantiator instantiator = Instantiator.of(Point.class, objenesis); Class expected = instantiator.instantiateAnonymousSubclass().getClass(); Class actual = instantiator.instantiateAnonymousSubclass().getClass(); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void giveDynamicSubclass() throws Exception { + void giveDynamicSubclass() throws Exception { class Super {} Class sub = Instantiator .giveDynamicSubclass( @@ -109,11 +106,11 @@ class Super {} "dynamicField", b -> b.defineField("dynamicField", int.class, Visibility.PRIVATE)); Field f = sub.getDeclaredField("dynamicField"); - assertNotNull(f); + assertThat(f).isNotNull(); } @Test - public void giveDynamicSubclassForClassWithNoPackage() { + void giveDynamicSubclassForClassWithNoPackage() { Class type = new ByteBuddy() .with(TypeValidation.DISABLED) .subclass(Object.class) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/PackageScannerTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/PackageScannerTest.java index 87a3ae6d6..519a2d916 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/PackageScannerTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/PackageScannerTest.java @@ -1,8 +1,7 @@ package nl.jqno.equalsverifier.internal.reflection; import static nl.jqno.equalsverifier.internal.testhelpers.Util.coverThePrivateConstructor; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import java.util.Arrays; import java.util.Collections; @@ -22,100 +21,101 @@ import nl.jqno.equalsverifier.testhelpers.packages.subclasses.subpackage.SubA3; import org.junit.jupiter.api.Test; -public class PackageScannerTest { +class PackageScannerTest { @Test - public void coverTheConstructor() { + void coverTheConstructor() { coverThePrivateConstructor(PackageScanner.class); } @Test - public void happyPath() { + void happyPath() { List> classes = PackageScanner.getClassesIn("nl.jqno.equalsverifier.testhelpers.packages.correct", null, false); sort(classes); - assertEquals(Arrays.asList(A.class, B.class, C.class), classes); + assertThat(classes).isEqualTo(Arrays.asList(A.class, B.class, C.class)); } @Test - public void happyPathMustExtendClass() { + void happyPathMustExtendClass() { List> classes = PackageScanner .getClassesIn("nl.jqno.equalsverifier.testhelpers.packages.subclasses", SuperA.class, false); sort(classes); - assertEquals(Arrays.asList(SubA1.class, SubA2.class), classes); + assertThat(classes).isEqualTo(Arrays.asList(SubA1.class, SubA2.class)); } @Test - public void happyPathMustExtendInterface() { + void happyPathMustExtendInterface() { List> classes = PackageScanner .getClassesIn("nl.jqno.equalsverifier.testhelpers.packages.subclasses", SuperI.class, false); sort(classes); - assertEquals(Arrays.asList(SubI1.class, SubI2.class), classes); + assertThat(classes).isEqualTo(Arrays.asList(SubI1.class, SubI2.class)); } @Test - public void happyPathRecursive() { + void happyPathRecursive() { List> classes = PackageScanner.getClassesIn("nl.jqno.equalsverifier.testhelpers.packages.correct", null, true); sort(classes); - assertEquals( - Arrays - .asList( - A.class, - B.class, - C.class, - nl.jqno.equalsverifier.testhelpers.packages.correct.subpackage.A.class, - nl.jqno.equalsverifier.testhelpers.packages.correct.subpackage.B.class, - nl.jqno.equalsverifier.testhelpers.packages.correct.subpackage.subpackage.A.class, - nl.jqno.equalsverifier.testhelpers.packages.correct.subpackage.subpackage.B.class, - nl.jqno.equalsverifier.testhelpers.packages.correct.subpackage.subpackage.D.class), - classes); + assertThat(classes) + .isEqualTo( + Arrays + .asList( + A.class, + B.class, + C.class, + nl.jqno.equalsverifier.testhelpers.packages.correct.subpackage.A.class, + nl.jqno.equalsverifier.testhelpers.packages.correct.subpackage.B.class, + nl.jqno.equalsverifier.testhelpers.packages.correct.subpackage.subpackage.A.class, + nl.jqno.equalsverifier.testhelpers.packages.correct.subpackage.subpackage.B.class, + nl.jqno.equalsverifier.testhelpers.packages.correct.subpackage.subpackage.D.class)); } @Test - public void happyPathMustExtendClassRecursive() { + void happyPathMustExtendClassRecursive() { List> classes = PackageScanner .getClassesIn("nl.jqno.equalsverifier.testhelpers.packages.subclasses", SuperA.class, true); sort(classes); - assertEquals(Arrays.asList(SubA1.class, SubA2.class, SubA3.class), classes); + assertThat(classes).isEqualTo(Arrays.asList(SubA1.class, SubA2.class, SubA3.class)); } @Test - public void filterOutTestClasses() { + void filterOutTestClasses() { List> classes = PackageScanner.getClassesIn("nl.jqno.equalsverifier.internal.reflection", null, false); List> testClasses = classes.stream().filter(c -> c.getName().endsWith("Test")).collect(Collectors.toList()); - assertEquals(Collections.emptyList(), testClasses); - assertTrue(classes.size() - testClasses.size() > 0); + assertThat(testClasses).isEqualTo(Collections.emptyList()); + assertThat(classes.size() - testClasses.size() > 0).isTrue(); } @Test - public void filterOutTestClassesRecursively() { + void filterOutTestClassesRecursively() { List> classes = PackageScanner.getClassesIn("nl.jqno.equalsverifier.internal.reflection", null, true); List> testClasses = classes.stream().filter(c -> c.getName().endsWith("Test")).collect(Collectors.toList()); - assertEquals(Collections.emptyList(), testClasses); - assertTrue(classes.size() - testClasses.size() > 0); + assertThat(testClasses).isEqualTo(Collections.emptyList()); + assertThat(classes.size() - testClasses.size() > 0).isTrue(); } @Test - public void nonexistentPackage() { + void nonexistentPackage() { List> classes = PackageScanner.getClassesIn("nl.jqno.equalsverifier.nonexistentpackage", null, false); - assertEquals(Collections.emptyList(), classes); + assertThat(classes).isEqualTo(Collections.emptyList()); } @Test - public void nonexistentPackageAndSubPackage() { + void nonexistentPackageAndSubPackage() { List> classes = PackageScanner.getClassesIn("nl.jqno.equalsverifier.nonexistentpackage", null, true); - assertEquals(Collections.emptyList(), classes); + assertThat(classes).isEqualTo(Collections.emptyList()); } @Test - public void anonymousAndLocalClassesAreSkipped() { + void anonymousAndLocalClassesAreSkipped() { List> classes = PackageScanner.getClassesIn("nl.jqno.equalsverifier.testhelpers.packages.anonymous", null, false); - assertEquals(Collections.singletonList(nl.jqno.equalsverifier.testhelpers.packages.anonymous.A.class), classes); + assertThat(classes) + .isEqualTo(Collections.singletonList(nl.jqno.equalsverifier.testhelpers.packages.anonymous.A.class)); } private void sort(List> classes) { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/SuperclassIterableTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/SuperclassIterableTest.java index 2fa1a6199..63f5cb470 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/SuperclassIterableTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/SuperclassIterableTest.java @@ -3,7 +3,7 @@ import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import java.util.ArrayList; import java.util.List; @@ -11,77 +11,77 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class SuperclassIterableTest { +class SuperclassIterableTest { private List> actual; @BeforeEach - public void setUp() { + void setUp() { actual = new ArrayList<>(); } @Test - public void simpleClassExcludeSelf() { + void simpleClassExcludeSelf() { for (Class type : SuperclassIterable.of(SimpleClass.class)) { actual.add(type); } - assertEquals(emptyList(), actual); + assertThat(actual).isEqualTo(emptyList()); } @Test - public void simpleClassIncludeSelf() { + void simpleClassIncludeSelf() { for (Class type : SuperclassIterable.ofIncludeSelf(SimpleClass.class)) { actual.add(type); } - assertEquals(singletonList(SimpleClass.class), actual); + assertThat(actual).isEqualTo(singletonList(SimpleClass.class)); } @Test - public void hierarchyExcludeSelf() { + void hierarchyExcludeSelf() { for (Class type : SuperclassIterable.of(SimpleSubSubclass.class)) { actual.add(type); } - assertEquals(asList(SimpleSubclass.class, SimpleClass.class), actual); + assertThat(actual).isEqualTo(asList(SimpleSubclass.class, SimpleClass.class)); } @Test - public void hierarchyIncludeSelf() { + void hierarchyIncludeSelf() { for (Class type : SuperclassIterable.ofIncludeSelf(SimpleSubSubclass.class)) { actual.add(type); } - assertEquals(asList(SimpleSubSubclass.class, SimpleSubclass.class, SimpleClass.class), actual); + assertThat(actual).isEqualTo(asList(SimpleSubSubclass.class, SimpleSubclass.class, SimpleClass.class)); } @Test - public void interfaceExcludeSelf() { + void interfaceExcludeSelf() { for (Class type : SuperclassIterable.of(SimpleInterface.class)) { actual.add(type); } - assertEquals(emptyList(), actual); + assertThat(actual).isEqualTo(emptyList()); } @Test - public void interfaceIncludeSelf() { + void interfaceIncludeSelf() { for (Class type : SuperclassIterable.ofIncludeSelf(SimpleInterface.class)) { actual.add(type); } - assertEquals(singletonList(SimpleInterface.class), actual); + assertThat(actual).isEqualTo(singletonList(SimpleInterface.class)); } @Test - public void subInterfaceExcludeSelf() { + void subInterfaceExcludeSelf() { for (Class type : SuperclassIterable.of(SimpleSubInterface.class)) { actual.add(type); } - assertEquals(emptyList(), actual); + assertThat(actual).isEqualTo(emptyList()); } @Test - public void subInterfaceIncludeSelf() { + void subInterfaceIncludeSelf() { for (Class type : SuperclassIterable.ofIncludeSelf(SimpleSubInterface.class)) { actual.add(type); } - assertEquals(singletonList(SimpleSubInterface.class), actual); + assertThat(actual).isEqualTo(singletonList(SimpleSubInterface.class)); } static class SimpleClass {} diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TupleTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TupleTest.java index 1dd1ab32a..07961c783 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TupleTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TupleTest.java @@ -1,39 +1,39 @@ package nl.jqno.equalsverifier.internal.reflection; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertNotSame; import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.Warning; import org.junit.jupiter.api.Test; -public class TupleTest { +class TupleTest { private Tuple tuple = Tuple.of("red", "blue", new String("red")); @Test - public void equalsAndHashCode() { + void equalsAndHashCode() { EqualsVerifier.forClass(Tuple.class).suppress(Warning.NULL_FIELDS).verify(); } @Test - public void getRed() { - assertEquals("red", tuple.getRed()); + void getRed() { + assertThat(tuple.getRed()).isEqualTo("red"); } @Test - public void getBlue() { - assertEquals("blue", tuple.getBlue()); + void getBlue() { + assertThat(tuple.getBlue()).isEqualTo("blue"); } @Test - public void getRedCopy() { - assertEquals("red", tuple.getRedCopy()); + void getRedCopy() { + assertThat(tuple.getRedCopy()).isEqualTo("red"); } @Test - public void redAndRedCopyInvariant() { - assertEquals(tuple.getRed(), tuple.getRedCopy()); + void redAndRedCopyInvariant() { + assertThat(tuple.getRedCopy()).isEqualTo(tuple.getRed()); assertNotSame(tuple.getRed(), tuple.getRedCopy()); } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TypeTagParameterizedTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TypeTagParameterizedTest.java index 7b73b25fc..1d94e8d40 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TypeTagParameterizedTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TypeTagParameterizedTest.java @@ -1,7 +1,7 @@ package nl.jqno.equalsverifier.internal.reflection; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; import java.lang.reflect.Field; import java.util.List; @@ -13,7 +13,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -public class TypeTagParameterizedTest { +class TypeTagParameterizedTest { @SuppressWarnings("unused") private final String simpleField = null; @@ -105,9 +105,9 @@ private static Stream data() { @ParameterizedTest @MethodSource("data") - public void correctness(String fieldName, TypeTag expected) { + void correctness(String fieldName, TypeTag expected) { TypeTag actual = TypeTag.of(getField(fieldName), TypeTag.NULL); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } private Field getField(String name) { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TypeTagTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TypeTagTest.java index dbd85cd10..abf1c81d5 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TypeTagTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/TypeTagTest.java @@ -1,7 +1,7 @@ package nl.jqno.equalsverifier.internal.reflection; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; import java.lang.reflect.Field; import java.util.Arrays; @@ -13,13 +13,13 @@ import nl.jqno.equalsverifier.testhelpers.types.Point; import org.junit.jupiter.api.Test; -public class TypeTagTest { +class TypeTagTest { private static final TypeTag SOME_LONG_TYPETAG = new TypeTag(Map.class, new TypeTag(Integer.class), new TypeTag(List.class, new TypeTag(String.class))); @Test - public void equalsAndHashCode() { + void equalsAndHashCode() { EqualsVerifier .forClass(TypeTag.class) .withPrefabValues(TypeTag.class, new TypeTag(Integer.class), SOME_LONG_TYPETAG) @@ -28,103 +28,103 @@ public void equalsAndHashCode() { } @Test - public void typeCannotBeNull() { - assertThrows(NullPointerException.class, () -> new TypeTag(null)); + void typeCannotBeNull() { + assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> new TypeTag(null)); } @Test - public void getType() { - assertEquals(Map.class, SOME_LONG_TYPETAG.getType()); + void getType() { + assertThat(SOME_LONG_TYPETAG.getType()).isEqualTo(Map.class); } @Test - public void getGenericTypes() { + void getGenericTypes() { List expected = Arrays.asList(new TypeTag(Integer.class), new TypeTag(List.class, new TypeTag(String.class))); - assertEquals(expected, SOME_LONG_TYPETAG.getGenericTypes()); + assertThat(SOME_LONG_TYPETAG.getGenericTypes()).isEqualTo(expected); } @Test - public void testToString() { - assertEquals("String", new TypeTag(String.class).toString()); - assertEquals("List", new TypeTag(List.class, new TypeTag(String.class)).toString()); - assertEquals("Map>", SOME_LONG_TYPETAG.toString()); + void testToString() { + assertThat(new TypeTag(String.class).toString()).isEqualTo("String"); + assertThat(new TypeTag(List.class, new TypeTag(String.class)).toString()).isEqualTo("List"); + assertThat(SOME_LONG_TYPETAG.toString()).isEqualTo("Map>"); } @Test - public void matchParameterizedField() throws Exception { + void matchParameterizedField() throws Exception { Field enclosingField = ContainerContainer.class.getDeclaredField("stringContainer"); TypeTag enclosingType = TypeTag.of(enclosingField, TypeTag.NULL); Field f = Container.class.getDeclaredField("t"); TypeTag actual = TypeTag.of(f, enclosingType); - assertEquals(new TypeTag(String.class), actual); + assertThat(actual).isEqualTo(new TypeTag(String.class)); } @Test - public void matchParameterizedGenericField() throws Exception { + void matchParameterizedGenericField() throws Exception { Field enclosingField = ContainerContainer.class.getDeclaredField("stringContainer"); TypeTag enclosingType = TypeTag.of(enclosingField, TypeTag.NULL); Field f = Container.class.getDeclaredField("ts"); TypeTag actual = TypeTag.of(f, enclosingType); - assertEquals(new TypeTag(List.class, new TypeTag(String.class)), actual); + assertThat(actual).isEqualTo(new TypeTag(List.class, new TypeTag(String.class))); } @Test - public void matchParameterizedArrayField() throws Exception { + void matchParameterizedArrayField() throws Exception { Field enclosingField = ContainerContainer.class.getDeclaredField("stringContainer"); TypeTag enclosingType = TypeTag.of(enclosingField, TypeTag.NULL); Field f = Container.class.getDeclaredField("tarr"); TypeTag actual = TypeTag.of(f, enclosingType); - assertEquals(new TypeTag(String[].class), actual); + assertThat(actual).isEqualTo(new TypeTag(String[].class)); } @Test - public void matchNestedParameterizedGenericField() throws Exception { + void matchNestedParameterizedGenericField() throws Exception { Field enclosingField = ContainerContainer.class.getDeclaredField("stringContainer"); TypeTag enclosingType = TypeTag.of(enclosingField, TypeTag.NULL); Field f = Container.class.getDeclaredField("tss"); TypeTag actual = TypeTag.of(f, enclosingType); - assertEquals(new TypeTag(List.class, new TypeTag(List.class, new TypeTag(String.class))), actual); + assertThat(actual).isEqualTo(new TypeTag(List.class, new TypeTag(List.class, new TypeTag(String.class)))); } @Test - public void correctnessOfBoundedTypeVariable() throws NoSuchFieldException { + void correctnessOfBoundedTypeVariable() throws NoSuchFieldException { Field field = BoundedTypeVariable.class.getDeclaredField("fieldWithBoundedTypeVariable"); TypeTag expected = new TypeTag(Point.class); TypeTag actual = TypeTag.of(field, TypeTag.NULL); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void correctnessOfRecursiveBoundedTypeVariable() throws NoSuchFieldException { + void correctnessOfRecursiveBoundedTypeVariable() throws NoSuchFieldException { Field field = RecursiveBoundedTypeVariable.class.getDeclaredField("fieldWithBoundedTypeVariable"); TypeTag expected = new TypeTag(Comparable.class, new TypeTag(Object.class)); TypeTag actual = TypeTag.of(field, TypeTag.NULL); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void correctnessOfRecursiveBoundedWildcardTypeVariable() throws NoSuchFieldException { + void correctnessOfRecursiveBoundedWildcardTypeVariable() throws NoSuchFieldException { Field field = RecursiveBoundedWildcardTypeVariable.class.getDeclaredField("fieldWithBoundedTypeVariable"); TypeTag expected = new TypeTag(Comparable.class, new TypeTag(Object.class)); TypeTag actual = TypeTag.of(field, TypeTag.NULL); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @Test - public void correctnessOfWildcardFieldWithBoundedType() throws NoSuchFieldException { + void correctnessOfWildcardFieldWithBoundedType() throws NoSuchFieldException { Field field = WildcardBoundedTypeVariableContainer.class.getDeclaredField("wildcard"); TypeTag expected = new TypeTag(BoundedTypeVariable.class, new TypeTag(Point.class)); TypeTag actual = TypeTag.of(field, TypeTag.NULL); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } @SuppressWarnings("unused") diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/UtilTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/UtilTest.java index 1859f14a7..7d8ba0760 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/UtilTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/UtilTest.java @@ -2,7 +2,7 @@ import static nl.jqno.equalsverifier.internal.reflection.Util.setOf; import static nl.jqno.equalsverifier.internal.testhelpers.Util.coverThePrivateConstructor; -import static org.junit.jupiter.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; import java.util.GregorianCalendar; import java.util.HashSet; @@ -11,60 +11,60 @@ import nl.jqno.equalsverifier.testhelpers.types.Point; import org.junit.jupiter.api.Test; -public class UtilTest { +class UtilTest { @Test - public void coverTheConstructor() { + void coverTheConstructor() { coverThePrivateConstructor(Util.class); } @Test - public void forNameReturnsClass_whenTypeExists() { + void forNameReturnsClass_whenTypeExists() { Class actual = Util.classForName("java.util.GregorianCalendar"); - assertEquals(actual, GregorianCalendar.class); + assertThat(actual).isEqualTo(GregorianCalendar.class); } @Test - public void forNameReturnsNull_whenTypeDoesntExist() { + void forNameReturnsNull_whenTypeDoesntExist() { Class actual = Util.classForName("this.type.does.not.exist"); - assertNull(actual); + assertThat(actual).isNull(); } @Test - public void forNameWithClassLoaderReturnsClass_whenTypeExists() { + void forNameWithClassLoaderReturnsClass_whenTypeExists() { ClassLoader cl = getClass().getClassLoader(); Class actual = Util.classForName(cl, "java.util.GregorianCalendar"); - assertEquals(actual, GregorianCalendar.class); + assertThat(actual).isEqualTo(GregorianCalendar.class); } @Test - public void forNameWithClassLoaderReturnsNull_whenTypeDoesntExist() { + void forNameWithClassLoaderReturnsNull_whenTypeDoesntExist() { ClassLoader cl = getClass().getClassLoader(); Class actual = Util.classForName(cl, "this.type.does.not.exist"); - assertNull(actual); + assertThat(actual).isNull(); } @Test - public void classesReturnsItsArguments() { + void classesReturnsItsArguments() { Class[] expected = new Class[] { String.class, Object.class }; Class[] actual = Util.classes(String.class, Object.class); - assertArrayEquals(expected, actual); + assertThat(actual).containsExactly(expected); } @Test - public void objectsReturnsItsArguments() { + void objectsReturnsItsArguments() { Object[] expected = new Object[] { "x", new Point(1, 2) }; Object[] actual = Util.objects("x", new Point(1, 2)); - assertArrayEquals(expected, actual); + assertThat(actual).containsExactly(expected); } @Test - public void setOfReturnsItsArguments() { + void setOfReturnsItsArguments() { Set expected = new HashSet<>(); expected.add("one"); expected.add("two"); Set actual = setOf("one", "two"); - assertEquals(expected, actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/annotations/AnnotationCacheBuilderTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/annotations/AnnotationCacheBuilderTest.java index f892fe396..673815098 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/annotations/AnnotationCacheBuilderTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/annotations/AnnotationCacheBuilderTest.java @@ -1,9 +1,7 @@ package nl.jqno.equalsverifier.internal.reflection.annotations; import static nl.jqno.equalsverifier.testhelpers.annotations.TestSupportedAnnotations.*; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import java.lang.annotation.ElementType; import java.util.HashSet; @@ -23,7 +21,7 @@ import org.junit.jupiter.api.Test; import org.objenesis.ObjenesisStd; -public class AnnotationCacheBuilderTest { +class AnnotationCacheBuilderTest { private static final String RUNTIME_RETENTION = "runtimeRetention"; private static final String CLASS_RETENTION = "classRetention"; @@ -36,13 +34,13 @@ public class AnnotationCacheBuilderTest { private AnnotationCache cache; @BeforeEach - public void setUp() { + void setUp() { cache = new AnnotationCache(); cacheBuilder = new AnnotationCacheBuilder(TestSupportedAnnotations.values(), NO_INGORED_ANNOTATIONS); } @Test - public void findRuntimeAnnotationInType() { + void findRuntimeAnnotationInType() { build(AnnotatedWithRuntime.class, AnnotatedWithClass.class, AnnotatedWithBoth.class, AnnotatedFields.class); assertTypeHasAnnotation(AnnotatedWithRuntime.class, TYPE_RUNTIME_RETENTION); @@ -52,7 +50,7 @@ public void findRuntimeAnnotationInType() { } @Test - public void findClassAnnotationInType() { + void findClassAnnotationInType() { build(AnnotatedWithRuntime.class, AnnotatedWithClass.class, AnnotatedWithBoth.class, AnnotatedFields.class); assertTypeHasAnnotation(AnnotatedWithClass.class, TYPE_CLASS_RETENTION); @@ -62,7 +60,7 @@ public void findClassAnnotationInType() { } @Test - public void findRuntimeAnnotationInField() { + void findRuntimeAnnotationInField() { build(AnnotatedFields.class); assertFieldHasAnnotation(AnnotatedFields.class, RUNTIME_RETENTION, FIELD_RUNTIME_RETENTION); @@ -72,7 +70,7 @@ public void findRuntimeAnnotationInField() { } @Test - public void findClassAnnotationInField() { + void findClassAnnotationInField() { build(AnnotatedFields.class); assertFieldHasAnnotation(AnnotatedFields.class, CLASS_RETENTION, FIELD_CLASS_RETENTION); @@ -82,7 +80,7 @@ public void findClassAnnotationInField() { } @Test - public void findTypeUseRuntimeAnnotationInField() { + void findTypeUseRuntimeAnnotationInField() { build(AnnotatedTypes.class); assertFieldHasAnnotation(AnnotatedTypes.class, RUNTIME_RETENTION, TYPEUSE_RUNTIME_RETENTION); @@ -92,7 +90,7 @@ public void findTypeUseRuntimeAnnotationInField() { } @Test - public void findTypeUseClassAnnotationInField() { + void findTypeUseClassAnnotationInField() { build(AnnotatedTypes.class); assertFieldHasAnnotation(AnnotatedTypes.class, CLASS_RETENTION, TYPEUSE_CLASS_RETENTION); @@ -102,7 +100,7 @@ public void findTypeUseClassAnnotationInField() { } @Test - public void findRuntimeAnnotationInMethod() { + void findRuntimeAnnotationInMethod() { build(AnnotatedMethods.class); assertFieldHasAnnotation(AnnotatedMethods.class, RUNTIME_RETENTION, METHOD_RUNTIME_RETENTION); @@ -112,7 +110,7 @@ public void findRuntimeAnnotationInMethod() { } @Test - public void findClassAnnotationInMethod() { + void findClassAnnotationInMethod() { build(AnnotatedMethods.class); assertFieldHasAnnotation(AnnotatedMethods.class, CLASS_RETENTION, METHOD_CLASS_RETENTION); @@ -122,7 +120,7 @@ public void findClassAnnotationInMethod() { } @Test - public void findPartialAnnotationName() { + void findPartialAnnotationName() { build(AnnotatedWithRuntime.class, AnnotatedFields.class, AnnotatedTypes.class, AnnotatedMethods.class); assertTypeHasAnnotation(AnnotatedWithRuntime.class, TYPE_RUNTIME_RETENTION_PARTIAL_CLASSNAME); @@ -132,7 +130,7 @@ public void findPartialAnnotationName() { } @Test - public void findFullyQualifiedAnnotationName() { + void findFullyQualifiedAnnotationName() { build(AnnotatedWithRuntime.class, AnnotatedFields.class, AnnotatedTypes.class, AnnotatedMethods.class); assertTypeHasAnnotation(AnnotatedWithRuntime.class, TYPE_RUNTIME_RETENTION_CANONICAL_CLASSNAME); @@ -148,7 +146,7 @@ public void findFullyQualifiedAnnotationName() { } @Test - public void typeAnnotationInheritance() { + void typeAnnotationInheritance() { build(SubclassWithAnnotations.class); assertTypeHasAnnotation(SubclassWithAnnotations.class, TYPE_INHERITS); @@ -157,7 +155,7 @@ public void typeAnnotationInheritance() { } @Test - public void fieldAnnotationInheritance() { + void fieldAnnotationInheritance() { build(SubclassWithAnnotations.class); assertFieldHasAnnotation(SubclassWithAnnotations.class, "inherits", FIELD_INHERITS); @@ -166,7 +164,7 @@ public void fieldAnnotationInheritance() { } @Test - public void typeUseAnnotationInheritance() { + void typeUseAnnotationInheritance() { build(SubclassWithAnnotations.class); assertFieldHasAnnotation(SubclassWithAnnotations.class, "inherits", TYPEUSE_INHERITS); @@ -175,7 +173,7 @@ public void typeUseAnnotationInheritance() { } @Test - public void typeAnnotationInOuterClass() { + void typeAnnotationInOuterClass() { build(AnnotatedOuter.AnnotatedMiddle.class); assertTypeHasAnnotation(AnnotatedOuter.AnnotatedMiddle.class, TYPE_CLASS_RETENTION); @@ -183,7 +181,7 @@ public void typeAnnotationInOuterClass() { } @Test - public void typeAnnotationNestedInOuterClass() { + void typeAnnotationNestedInOuterClass() { build(AnnotatedOuter.AnnotatedMiddle.AnnotatedInner.class); assertTypeHasAnnotation(AnnotatedOuter.AnnotatedMiddle.AnnotatedInner.class, TYPE_CLASS_RETENTION); @@ -191,7 +189,7 @@ public void typeAnnotationNestedInOuterClass() { } @Test - public void typeAnnotationInPackage() { + void typeAnnotationInPackage() { build(AnnotatedPackage.class); assertTypeHasAnnotation(AnnotatedPackage.class, PACKAGE_ANNOTATION); @@ -199,7 +197,7 @@ public void typeAnnotationInPackage() { } @Test - public void searchIgnoredField() { + void searchIgnoredField() { cacheBuilder = new AnnotationCacheBuilder(TestSupportedAnnotations.values(), Util.setOf(FieldAnnotationRuntimeRetention.class.getCanonicalName())); build(AnnotatedFields.class); @@ -208,14 +206,14 @@ public void searchIgnoredField() { } @Test - public void searchNonExistingField() { + void searchNonExistingField() { build(AnnotatedFields.class); assertFieldDoesNotHaveAnnotation(AnnotatedFields.class, "x", FIELD_RUNTIME_RETENTION); } @Test - public void annotationsAreValidated() { + void annotationsAreValidated() { build(InapplicableAnnotations.class); assertTypeDoesNotHaveAnnotation(InapplicableAnnotations.class, INAPPLICABLE); @@ -223,7 +221,7 @@ public void annotationsAreValidated() { } @Test - public void annotationsArePostProcessed() { + void annotationsArePostProcessed() { build(PostProcessedFieldAnnotation.class); assertTypeHasAnnotation(PostProcessedFieldAnnotation.class, POST_PROCESS); @@ -231,7 +229,7 @@ public void annotationsArePostProcessed() { } @Test - public void annotationsEnumParametersAreFoundOnClass() { + void annotationsEnumParametersAreFoundOnClass() { AnnotationWithClassValuesAnnotation annotation = new AnnotationWithClassValuesAnnotation(); Annotation[] supportedAnnotations = { annotation }; AnnotationCacheBuilder acb = new AnnotationCacheBuilder(supportedAnnotations, NO_INGORED_ANNOTATIONS); @@ -240,11 +238,11 @@ public void annotationsEnumParametersAreFoundOnClass() { assertTypeHasAnnotation(AnnotationWithValuesContainer.class, annotation); String value = annotation.properties.getEnumValue("elementType"); - assertEquals("FIELD", value); + assertThat(value).isEqualTo("FIELD"); } @Test - public void annotationsArrayParametersAreFoundOnClass() { + void annotationsArrayParametersAreFoundOnClass() { AnnotationWithClassValuesAnnotation annotation = new AnnotationWithClassValuesAnnotation(); Annotation[] supportedAnnotations = { annotation }; AnnotationCacheBuilder acb = new AnnotationCacheBuilder(supportedAnnotations, NO_INGORED_ANNOTATIONS); @@ -253,27 +251,27 @@ public void annotationsArrayParametersAreFoundOnClass() { assertTypeHasAnnotation(AnnotationWithValuesContainer.class, annotation); Set annotations = new HashSet<>(annotation.properties.getArrayValues("annotations")); - assertTrue(annotations.contains("javax.annotation.Nonnull")); - assertTrue(annotations.contains("nl.jqno.equalsverifier.testhelpers.annotations.NotNull")); + assertThat(annotations.contains("javax.annotation.Nonnull")).isTrue(); + assertThat(annotations.contains("nl.jqno.equalsverifier.testhelpers.annotations.NotNull")).isTrue(); } @Test - public void classWithMethodNamedGetDoesNotThrow() { + void classWithMethodNamedGetDoesNotThrow() { build(ClassContainsMethodNamedGet.class); } @Test - public void classWithDifficultAnnotationDoesNotThrow() { + void classWithDifficultAnnotationDoesNotThrow() { build(DifficultAnnotationHolder.class); } @Test - public void loadedBySystemClassLoaderDoesNotThrowNullPointerException() { + void loadedBySystemClassLoaderDoesNotThrowNullPointerException() { build(LoadedBySystemClassLoader.class); } @Test - public void dynamicClassDoesntGetProcessed_butDoesntThrowEither() { + void dynamicClassDoesntGetProcessed_butDoesntThrowEither() { Class type = Instantiator .of(AnnotatedWithRuntime.class, new ObjenesisStd()) .instantiateAnonymousSubclass() @@ -284,7 +282,7 @@ public void dynamicClassDoesntGetProcessed_butDoesntThrowEither() { } @Test - public void generatedClassWithGeneratedFieldDoesNotThrow() { + void generatedClassWithGeneratedFieldDoesNotThrow() { class Super {} Class sub = Instantiator .giveDynamicSubclass( @@ -301,19 +299,19 @@ private void build(Class... types) { } private void assertTypeHasAnnotation(Class type, Annotation annotation) { - assertTrue(cache.hasClassAnnotation(type, annotation)); + assertThat(cache.hasClassAnnotation(type, annotation)).isTrue(); } private void assertTypeDoesNotHaveAnnotation(Class type, Annotation annotation) { - assertFalse(cache.hasClassAnnotation(type, annotation)); + assertThat(cache.hasClassAnnotation(type, annotation)).isFalse(); } private void assertFieldHasAnnotation(Class type, String fieldName, Annotation annotation) { - assertTrue(cache.hasFieldAnnotation(type, fieldName, annotation)); + assertThat(cache.hasFieldAnnotation(type, fieldName, annotation)).isTrue(); } private void assertFieldDoesNotHaveAnnotation(Class type, String fieldName, Annotation annotation) { - assertFalse(cache.hasFieldAnnotation(type, fieldName, annotation)); + assertThat(cache.hasFieldAnnotation(type, fieldName, annotation)).isFalse(); } private static final class AnnotationWithClassValuesAnnotation implements Annotation { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/annotations/SupportedAnnotationsTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/annotations/SupportedAnnotationsTest.java index 277b10732..a02dfbca4 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/annotations/SupportedAnnotationsTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/reflection/annotations/SupportedAnnotationsTest.java @@ -1,53 +1,52 @@ package nl.jqno.equalsverifier.internal.reflection.annotations; import static nl.jqno.equalsverifier.internal.reflection.Util.setOf; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import java.util.HashSet; import java.util.Set; import org.junit.jupiter.api.Test; -public class SupportedAnnotationsTest { +class SupportedAnnotationsTest { private static final Set NO_IGNORED_ANNOTATIONS = new HashSet<>(); private static final AnnotationCache ANNOTATION_CACHE = new AnnotationCache(); @Test - public void jsr305DefaultReturnsTrue_whenAnnotationHasNonnullAnnotation() { + void jsr305DefaultReturnsTrue_whenAnnotationHasNonnullAnnotation() { AnnotationProperties props = new AnnotationProperties("nl.jqno.equalsverifier.testhelpers.annotations.DefaultNonnullJavax"); boolean actual = SupportedAnnotations.JSR305_DEFAULT_ANNOTATION_NONNULL .validate(props, ANNOTATION_CACHE, NO_IGNORED_ANNOTATIONS); - assertTrue(actual); + assertThat(actual).isTrue(); } @Test - public void jsr305DefaultReturnsFalse_whenAnnotationDoesntHaveNonnullAnnotation() { + void jsr305DefaultReturnsFalse_whenAnnotationDoesntHaveNonnullAnnotation() { AnnotationProperties props = new AnnotationProperties("javax.annotation.Nonnull"); boolean actual = SupportedAnnotations.JSR305_DEFAULT_ANNOTATION_NONNULL .validate(props, ANNOTATION_CACHE, NO_IGNORED_ANNOTATIONS); - assertFalse(actual); + assertThat(actual).isFalse(); } @Test - public void jsr305DefaultReturnsFalse_whenTypeDoesNotExist() { + void jsr305DefaultReturnsFalse_whenTypeDoesNotExist() { AnnotationProperties props = new AnnotationProperties("nl.jqno.equalsverifier.TypeDoesNotExist"); boolean actual = SupportedAnnotations.JSR305_DEFAULT_ANNOTATION_NONNULL .validate(props, ANNOTATION_CACHE, NO_IGNORED_ANNOTATIONS); - assertFalse(actual); + assertThat(actual).isFalse(); } @Test - public void jpaIdAnnotationIsAlsoAddedAsAClassAnnotation() { + void jpaIdAnnotationIsAlsoAddedAsAClassAnnotation() { SupportedAnnotations.ID.postProcess(setOf(String.class), ANNOTATION_CACHE); - assertTrue(ANNOTATION_CACHE.hasClassAnnotation(String.class, SupportedAnnotations.ID)); + assertThat(ANNOTATION_CACHE.hasClassAnnotation(String.class, SupportedAnnotations.ID)).isTrue(); } @Test - public void hibernateNaturalIdAnnotationIsAlsoAddedAsAClassAnnotation() { + void hibernateNaturalIdAnnotationIsAlsoAddedAsAClassAnnotation() { SupportedAnnotations.NATURALID.postProcess(setOf(String.class), ANNOTATION_CACHE); - assertTrue(ANNOTATION_CACHE.hasClassAnnotation(String.class, SupportedAnnotations.NATURALID)); + assertThat(ANNOTATION_CACHE.hasClassAnnotation(String.class, SupportedAnnotations.NATURALID)).isTrue(); } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/AssertTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/AssertTest.java index 65a055ccd..a7538285c 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/AssertTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/AssertTest.java @@ -6,24 +6,24 @@ import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; import org.junit.jupiter.api.Test; -public class AssertTest { +class AssertTest { private static final Formatter FAIL = Formatter.of("fail"); @Test - public void coverTheConstructor() { + void coverTheConstructor() { coverThePrivateConstructor(Assert.class); } @Test - public void assertEqualsObjectSuccess() { + void assertEqualsObjectSuccess() { String red = new String("text"); String blue = new String("text"); Assert.assertEquals(FAIL, red, blue); } @Test - public void assertEqualsObjectFailure() { + void assertEqualsObjectFailure() { ExpectedException .when(() -> Assert.assertEquals(FAIL, "one", "two")) .assertThrows(AssertionException.class) @@ -31,12 +31,12 @@ public void assertEqualsObjectFailure() { } @Test - public void assertFalseSuccess() { + void assertFalseSuccess() { Assert.assertFalse(FAIL, false); } @Test - public void assertFalseFailure() { + void assertFalseFailure() { ExpectedException .when(() -> Assert.assertFalse(FAIL, true)) .assertThrows(AssertionException.class) @@ -44,12 +44,12 @@ public void assertFalseFailure() { } @Test - public void assertTrueSuccess() { + void assertTrueSuccess() { Assert.assertTrue(FAIL, true); } @Test - public void assertTrueFailure() { + void assertTrueFailure() { ExpectedException .when(() -> Assert.assertTrue(FAIL, false)) .assertThrows(AssertionException.class) @@ -57,7 +57,7 @@ public void assertTrueFailure() { } @Test - public void failFailure() { + void failFailure() { ExpectedException .when(() -> Assert.fail(FAIL)) .assertThrows(AssertionException.class) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/FieldNameExtractorTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/FieldNameExtractorTest.java index 52cadd799..6e3b1af9a 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/FieldNameExtractorTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/FieldNameExtractorTest.java @@ -1,15 +1,15 @@ package nl.jqno.equalsverifier.internal.util; import static nl.jqno.equalsverifier.internal.testhelpers.Util.coverThePrivateConstructor; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; import java.util.List; import java.util.Set; import org.junit.jupiter.api.Test; -public class FieldNameExtractorTest { +class FieldNameExtractorTest { private static final String FIELD_NOT_FOUND = "field not found: "; @@ -19,34 +19,35 @@ public class FieldNameExtractorTest { private static final String FIELD_PRIMITIVE_INT = "fieldPrimitiveInt"; @Test - public void coverTheConstructor() { + void coverTheConstructor() { coverThePrivateConstructor(FieldNameExtractor.class); } @Test - public void should_extractFields_succesfully() { + void should_extractFields_succesfully() { Set fields = FieldNameExtractor.extractFieldNames(FieldNameExtractorTestHelper.class); - assertTrue(fields.contains(FIELD_STRING), FIELD_NOT_FOUND + FIELD_STRING); - assertTrue(fields.contains(FIELD_OBJECT), FIELD_NOT_FOUND + FIELD_OBJECT); - assertTrue(fields.contains(FIELD_LIST), FIELD_NOT_FOUND + FIELD_LIST); - assertTrue(fields.contains(FIELD_PRIMITIVE_INT), FIELD_NOT_FOUND + FIELD_PRIMITIVE_INT); + assertThat(fields.contains(FIELD_STRING)).as(FIELD_NOT_FOUND + FIELD_STRING).isTrue(); + assertThat(fields.contains(FIELD_OBJECT)).as(FIELD_NOT_FOUND + FIELD_OBJECT).isTrue(); + assertThat(fields.contains(FIELD_LIST)).as(FIELD_NOT_FOUND + FIELD_LIST).isTrue(); + assertThat(fields.contains(FIELD_PRIMITIVE_INT)).as(FIELD_NOT_FOUND + FIELD_PRIMITIVE_INT).isTrue(); - assertTrue(4 == fields.size(), "Total number of fields was not equal to expected value"); + assertThat(fields.size()).as("Total number of fields was not equal to expected value").isEqualTo(4); } @Test - public void should_disallow_adding_extra_fields() { + void should_disallow_adding_extra_fields() { Set fields = FieldNameExtractor.extractFieldNames(FieldNameExtractorTestHelper.class); - assertThrows(UnsupportedOperationException.class, () -> fields.add("illegally added field")); + assertThatExceptionOfType(UnsupportedOperationException.class) + .isThrownBy(() -> fields.add("illegally added field")); } @Test - public void should_disallow_removing_fields() { + void should_disallow_removing_fields() { Set fields = FieldNameExtractor.extractFieldNames(FieldNameExtractorTestHelper.class); - assertThrows(UnsupportedOperationException.class, () -> fields.remove(FIELD_STRING)); + assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> fields.remove(FIELD_STRING)); } class FieldNameExtractorTestHelper { diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/FormatterTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/FormatterTest.java index c05c493cb..ffe15f8a9 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/FormatterTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/FormatterTest.java @@ -1,9 +1,9 @@ package nl.jqno.equalsverifier.internal.util; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; import nl.jqno.equalsverifier.internal.reflection.Instantiator; import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; @@ -11,81 +11,81 @@ import org.objenesis.Objenesis; import org.objenesis.ObjenesisStd; -public class FormatterTest { +class FormatterTest { private final Objenesis objenesis = new ObjenesisStd(); @Test - public void noParameters() { + void noParameters() { Formatter f = Formatter.of("No parameters"); - assertEquals("No parameters", f.format()); + assertThat(f.format()).isEqualTo("No parameters"); } @Test - public void oneSimpleParameter() { + void oneSimpleParameter() { Formatter f = Formatter.of("One simple parameter: %%", new Simple(42)); - assertEquals("One simple parameter: Simple: 42", f.format()); + assertThat(f.format()).isEqualTo("One simple parameter: Simple: 42"); } @Test - public void multipleSimpleParameters() { + void multipleSimpleParameters() { Formatter f = Formatter .of("Multiple simple parameters: %% and %% and also %%", new Simple(0), new Simple(1), new Simple(2)); - assertEquals("Multiple simple parameters: Simple: 0 and Simple: 1 and also Simple: 2", f.format()); + assertThat(f.format()).isEqualTo("Multiple simple parameters: Simple: 0 and Simple: 1 and also Simple: 2"); } @Test - public void oneThrowingParameter() { + void oneThrowingParameter() { Formatter f = Formatter.of("One throwing parameter: %%", new Throwing(1337, "string")); - assertEquals( - "One throwing parameter: [Throwing i=1337 s=string]-throws IllegalStateException(msg)", - f.format()); + assertThat(f.format()) + .isEqualTo("One throwing parameter: [Throwing i=1337 s=string]-throws IllegalStateException(msg)"); } @Test - public void oneThrowingParameterWithNullSubparameter() { + void oneThrowingParameterWithNullSubparameter() { Formatter f = Formatter.of("One throwing parameter: %%", new Throwing(1337, null)); - assertEquals("One throwing parameter: [Throwing i=1337 s=null]-throws IllegalStateException(msg)", f.format()); + assertThat(f.format()) + .isEqualTo("One throwing parameter: [Throwing i=1337 s=null]-throws IllegalStateException(msg)"); } @Test - public void oneParameterWithNoFieldsAndThrowsWithNullMessage() { + void oneParameterWithNoFieldsAndThrowsWithNullMessage() { Formatter f = Formatter.of("No fields, null message: %%", new NoFieldsAndThrowsNullMessage()); - assertEquals( - "No fields, null message: [NoFieldsAndThrowsNullMessage (no fields)]-throws NullPointerException(null)", - f.format()); + assertThat(f.format()) + .isEqualTo( + "No fields, null message: [NoFieldsAndThrowsNullMessage (no fields)]-throws NullPointerException(null)"); } @Test - public void oneAbstractParameter() { + void oneAbstractParameter() { Instantiator i = Instantiator.of(Abstract.class, objenesis); Formatter f = Formatter.of("Abstract: %%", i.instantiate()); assertThat(f.format(), containsString("Abstract: [Abstract x=0]")); } @Test - public void oneConcreteSubclassParameter() { + void oneConcreteSubclassParameter() { Instantiator i = Instantiator.of(AbstractImpl.class, objenesis); Formatter f = Formatter.of("Concrete: %%", i.instantiate()); assertThat(f.format(), containsString("Concrete: something concrete")); } @Test - public void oneDelegatedAbstractParameter() { + void oneDelegatedAbstractParameter() { Instantiator i = Instantiator.of(AbstractDelegation.class, objenesis); Formatter f = Formatter.of("Abstract: %%", i.instantiate()); assertThat(f.format(), containsString("Abstract: [AbstractDelegation y=0]")); } @Test - public void oneDelegatedConcreteSubclassParameter() { + void oneDelegatedConcreteSubclassParameter() { Instantiator i = Instantiator.of(AbstractDelegationImpl.class, objenesis); Formatter f = Formatter.of("Concrete: %%", i.instantiate()); assertThat(f.format(), containsString("Concrete: something concrete")); } @Test - public void oneThrowingContainerParameter() { + void oneThrowingContainerParameter() { Instantiator i = Instantiator.of(Throwing.class, objenesis); ThrowingContainer tc = new ThrowingContainer(i.instantiate()); Formatter f = Formatter.of("TC: %%", tc); @@ -95,7 +95,7 @@ public void oneThrowingContainerParameter() { } @Test - public void oneAbstractContainerParameter() { + void oneAbstractContainerParameter() { Instantiator i = Instantiator.of(AbstractDelegation.class, objenesis); AbstractContainer ac = new AbstractContainer(i.instantiate()); @@ -104,7 +104,7 @@ public void oneAbstractContainerParameter() { } @Test - public void parameterWithMixOfVariousFields() { + void parameterWithMixOfVariousFields() { Mix mix = new Mix(); mix.throwing = new Throwing(42, "empty"); @@ -116,24 +116,24 @@ public void parameterWithMixOfVariousFields() { } @Test - public void connectedParameters() { + void connectedParameters() { Formatter f = Formatter.of("%%%%", 1, 2); assertThat(f.format(), containsString("12")); } @Test - public void nullParameter() { + void nullParameter() { Formatter f = Formatter.of("This parameter is null: %%", (Object) null); - assertEquals("This parameter is null: null", f.format()); + assertThat(f.format()).isEqualTo("This parameter is null: null"); } @Test - public void nullMessage() { - assertThrows(NullPointerException.class, () -> Formatter.of(null)); + void nullMessage() { + assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> Formatter.of(null)); } @Test - public void notEnoughParameters() { + void notEnoughParameters() { Formatter f = Formatter.of("Not enough: %% and %%"); ExpectedException @@ -143,7 +143,7 @@ public void notEnoughParameters() { } @Test - public void tooManyParameters() { + void tooManyParameters() { Formatter f = Formatter.of("Too many!", new Simple(0)); ExpectedException diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/ListBuildersTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/ListBuildersTest.java index 7f3fa4180..e15a0ca86 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/ListBuildersTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/ListBuildersTest.java @@ -4,10 +4,10 @@ import org.junit.jupiter.api.Test; -public class ListBuildersTest { +class ListBuildersTest { @Test - public void coverTheConstructor() { + void coverTheConstructor() { coverThePrivateConstructor(ListBuilders.class); } } diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/RethrowTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/RethrowTest.java index a41ded7a9..2e24d28f5 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/RethrowTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/RethrowTest.java @@ -12,18 +12,18 @@ import nl.jqno.equalsverifier.internal.util.Rethrow.ThrowingSupplier; import org.junit.jupiter.api.Test; -public class RethrowTest { +class RethrowTest { private static final String PROVIDED_MSG = "this message is provided"; private static final String CAUSE_MSG = "this message came from the exception"; @Test - public void coverTheConstructor() { + void coverTheConstructor() { coverThePrivateConstructor(Rethrow.class); } @Test - public void supplierWithIgnoredMessageThrowsRuntimeException() { + void supplierWithIgnoredMessageThrowsRuntimeException() { ExpectedException .when(() -> rethrow(supply(new RuntimeException(CAUSE_MSG)), e -> PROVIDED_MSG)) .assertThrows(RuntimeException.class) @@ -31,7 +31,7 @@ public void supplierWithIgnoredMessageThrowsRuntimeException() { } @Test - public void supplierWithMessageThrowsReflectiveOperationException() { + void supplierWithMessageThrowsReflectiveOperationException() { ExpectedException .when(() -> rethrow(supply(new IllegalAccessException(CAUSE_MSG)), e -> PROVIDED_MSG)) .assertThrows(ReflectionException.class) @@ -39,7 +39,7 @@ public void supplierWithMessageThrowsReflectiveOperationException() { } @Test - public void supplierWithMessageThrowsException() { + void supplierWithMessageThrowsException() { ExpectedException .when(() -> rethrow(supply(new IOException(CAUSE_MSG)), e -> PROVIDED_MSG)) .assertThrows(EqualsVerifierInternalBugException.class) @@ -47,7 +47,7 @@ public void supplierWithMessageThrowsException() { } @Test - public void supplierWithNoMessageThrowsRuntimeException() { + void supplierWithNoMessageThrowsRuntimeException() { ExpectedException .when(() -> rethrow(supply(new RuntimeException(CAUSE_MSG)))) .assertThrows(RuntimeException.class) @@ -55,7 +55,7 @@ public void supplierWithNoMessageThrowsRuntimeException() { } @Test - public void supplierWithNoMessageThrowsReflectiveOperationException() { + void supplierWithNoMessageThrowsReflectiveOperationException() { ExpectedException .when(() -> rethrow(supply(new IllegalAccessException(CAUSE_MSG)))) .assertThrows(ReflectionException.class) @@ -63,7 +63,7 @@ public void supplierWithNoMessageThrowsReflectiveOperationException() { } @Test - public void supplierWithNoMessageThrowsException() { + void supplierWithNoMessageThrowsException() { ExpectedException .when(() -> rethrow(supply(new IOException(CAUSE_MSG)))) .assertThrows(EqualsVerifierInternalBugException.class) @@ -71,7 +71,7 @@ public void supplierWithNoMessageThrowsException() { } @Test - public void runnableWithIgnoredMessageThrowsRuntimeException() { + void runnableWithIgnoredMessageThrowsRuntimeException() { ExpectedException .when(() -> rethrow(run(new RuntimeException(CAUSE_MSG)), e -> PROVIDED_MSG)) .assertThrows(RuntimeException.class) @@ -79,7 +79,7 @@ public void runnableWithIgnoredMessageThrowsRuntimeException() { } @Test - public void runnableWithMessageThrowsReflectiveOperationException() { + void runnableWithMessageThrowsReflectiveOperationException() { ExpectedException .when(() -> rethrow(run(new IllegalAccessException(CAUSE_MSG)), e -> PROVIDED_MSG)) .assertThrows(ReflectionException.class) @@ -87,7 +87,7 @@ public void runnableWithMessageThrowsReflectiveOperationException() { } @Test - public void runnableWithMessageThrowsException() { + void runnableWithMessageThrowsException() { ExpectedException .when(() -> rethrow(run(new IOException(CAUSE_MSG)), e -> PROVIDED_MSG)) .assertThrows(EqualsVerifierInternalBugException.class) @@ -95,7 +95,7 @@ public void runnableWithMessageThrowsException() { } @Test - public void runnableWithNoMessageThrowsRuntimeException() { + void runnableWithNoMessageThrowsRuntimeException() { ExpectedException .when(() -> rethrow(run(new RuntimeException(CAUSE_MSG)))) .assertThrows(RuntimeException.class) @@ -103,7 +103,7 @@ public void runnableWithNoMessageThrowsRuntimeException() { } @Test - public void runnableWithNoMessageThrowsReflectiveOperationException() { + void runnableWithNoMessageThrowsReflectiveOperationException() { ExpectedException .when(() -> rethrow(run(new IllegalAccessException(CAUSE_MSG)))) .assertThrows(ReflectionException.class) @@ -111,7 +111,7 @@ public void runnableWithNoMessageThrowsReflectiveOperationException() { } @Test - public void runnableWithNoMessageThrowsException() { + void runnableWithNoMessageThrowsException() { ExpectedException .when(() -> rethrow(run(new IOException(CAUSE_MSG)))) .assertThrows(EqualsVerifierInternalBugException.class) diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/ValidationsTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/ValidationsTest.java index 00984a308..3f8771fec 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/ValidationsTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/internal/util/ValidationsTest.java @@ -15,12 +15,12 @@ class ValidationsTest { @Test - public void coverTheConstructor() { + void coverTheConstructor() { coverThePrivateConstructor(Validations.class); } @Test - public void validateFieldTypeMatches_shouldFailOnWrongType() { + void validateFieldTypeMatches_shouldFailOnWrongType() { assertAll(() -> { ExpectedException .when(() -> Validations.validateFieldTypeMatches(TestContainer.class, "listField", HashSet.class)) @@ -41,7 +41,7 @@ public void validateFieldTypeMatches_shouldFailOnWrongType() { } @Test - public void validateFieldTypeMatches_shouldAllowSubTypes() { + void validateFieldTypeMatches_shouldAllowSubTypes() { assertAll( () -> assertDoesNotThrow( () -> Validations.validateFieldTypeMatches(TestContainer.class, "listField", ArrayList.class), @@ -55,7 +55,7 @@ public void validateFieldTypeMatches_shouldAllowSubTypes() { } @Test - public void validateFieldTypeMatches_shouldFailOnSuperTypes() { + void validateFieldTypeMatches_shouldFailOnSuperTypes() { assertAll(() -> { ExpectedException .when( diff --git a/equalsverifier-release-verify/pom.xml b/equalsverifier-release-verify/pom.xml index 362ca9038..a0a181a77 100644 --- a/equalsverifier-release-verify/pom.xml +++ b/equalsverifier-release-verify/pom.xml @@ -102,6 +102,12 @@ ${version.junit-jupiter} test + + org.assertj + assertj-core + ${version.assertj} + test + diff --git a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/MainClassesJarTest.java b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/MainClassesJarTest.java index f4c5b64f2..3b0697dc8 100644 --- a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/MainClassesJarTest.java +++ b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/MainClassesJarTest.java @@ -6,45 +6,45 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public class MainClassesJarTest { +class MainClassesJarTest { private static final String FILENAME = "equalsverifier-main.jar"; private static JarReader reader; private static JarAsserter jar; @BeforeAll - public static void setup() { + static void setup() { reader = new JarReader(FILENAME); jar = new JarAsserter(reader); } @AfterAll - public static void clean() throws Exception { + static void clean() throws Exception { reader.close(); } @Test - public void presenceOfCoreClasses() { + void presenceOfCoreClasses() { jar.assertPresenceOfCoreClasses(); } @Test - public void presenceOfMultiReleaseClasses() { + void presenceOfMultiReleaseClasses() { jar.assertPresenceOfMultiReleaseClasses(); } @Test - public void assertAbsenceOfEmbeddedDependencies() { + void assertAbsenceOfEmbeddedDependencies() { jar.assertAbsenceOfEmbeddedDepedencies(); } @Test - public void contentOfManifest() { + void contentOfManifest() { jar.assertContentOfManifest("EqualsVerifier"); } @Test - public void versionsOfClassFiles() { + void versionsOfClassFiles() { jar.assertVersionsOfClassFiles(); } } diff --git a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/MainJavadocJarTest.java b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/MainJavadocJarTest.java index 242e886e8..32b09528a 100644 --- a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/MainJavadocJarTest.java +++ b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/MainJavadocJarTest.java @@ -8,25 +8,25 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public class MainJavadocJarTest { +class MainJavadocJarTest { private static final String FILENAME = "equalsverifier-main-javadoc.jar"; private static JarReader reader; private static JarAsserter jar; @BeforeAll - public static void setup() { + static void setup() { reader = new JarReader(FILENAME); jar = new JarAsserter(reader); } @AfterAll - public static void clean() throws Exception { + static void clean() throws Exception { reader.close(); } @Test - public void presenceOfCoreSources() { + void presenceOfCoreSources() { jar.assertPresenceOf("/index.html", EV + "/EqualsVerifier.html"); } } diff --git a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/MainSourcesJarTest.java b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/MainSourcesJarTest.java index aee5d2369..74df4e601 100644 --- a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/MainSourcesJarTest.java +++ b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/MainSourcesJarTest.java @@ -8,25 +8,25 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public class MainSourcesJarTest { +class MainSourcesJarTest { private static final String FILENAME = "equalsverifier-main-sources.jar"; private static JarReader reader; private static JarAsserter jar; @BeforeAll - public static void setup() { + static void setup() { reader = new JarReader(FILENAME); jar = new JarAsserter(reader); } @AfterAll - public static void clean() throws Exception { + static void clean() throws Exception { reader.close(); } @Test - public void presenceOfCoreSources() { + void presenceOfCoreSources() { jar.assertPresenceOf(EV + "/EqualsVerifier.java"); } } diff --git a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/NodepClassesJarTest.java b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/NodepClassesJarTest.java index 28f70da56..de8d47de2 100644 --- a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/NodepClassesJarTest.java +++ b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/NodepClassesJarTest.java @@ -6,50 +6,50 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public class NodepClassesJarTest { +class NodepClassesJarTest { private static final String FILENAME = "equalsverifier-nodep.jar"; private static JarReader reader; private static JarAsserter jar; @BeforeAll - public static void setup() { + static void setup() { reader = new JarReader(FILENAME); jar = new JarAsserter(reader); } @AfterAll - public static void clean() throws Exception { + static void clean() throws Exception { reader.close(); } @Test - public void presenceOfCoreClasses() { + void presenceOfCoreClasses() { jar.assertPresenceOfCoreClasses(); } @Test - public void presenceOfMultiReleaseClasses() { + void presenceOfMultiReleaseClasses() { jar.assertPresenceOfMultiReleaseClasses(); } @Test - public void assertPresenceOfEmbeddedDependencies() { + void assertPresenceOfEmbeddedDependencies() { jar.assertPresenceOfEmbeddedDepedencies(); } @Test - public void contentOfManifest() { + void contentOfManifest() { jar.assertContentOfManifest("EqualsVerifier (no dependencies)"); } @Test - public void versionsOfClassFiles() { + void versionsOfClassFiles() { jar.assertVersionsOfClassFiles(); } @Test - public void versionsOfEmbeddedDependencies() { + void versionsOfEmbeddedDependencies() { jar.assertVersionsOfEmbeddedClassFiles(); } } diff --git a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/NodepJavadocJarTest.java b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/NodepJavadocJarTest.java index 5d4706185..f24c27709 100644 --- a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/NodepJavadocJarTest.java +++ b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/NodepJavadocJarTest.java @@ -8,25 +8,25 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public class NodepJavadocJarTest { +class NodepJavadocJarTest { private static final String FILENAME = "equalsverifier-nodep-javadoc.jar"; private static JarReader reader; private static JarAsserter jar; @BeforeAll - public static void setup() { + static void setup() { reader = new JarReader(FILENAME); jar = new JarAsserter(reader); } @AfterAll - public static void clean() throws Exception { + static void clean() throws Exception { reader.close(); } @Test - public void presenceOfCoreSources() { + void presenceOfCoreSources() { jar.assertPresenceOf("/index.html", EV + "/EqualsVerifier.html"); } } diff --git a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/NodepSourcesJarTest.java b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/NodepSourcesJarTest.java index 12acacd59..98a3144ea 100644 --- a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/NodepSourcesJarTest.java +++ b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/NodepSourcesJarTest.java @@ -8,25 +8,25 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public class NodepSourcesJarTest { +class NodepSourcesJarTest { private static final String FILENAME = "equalsverifier-nodep-sources.jar"; private static JarReader reader; private static JarAsserter jar; @BeforeAll - public static void setup() { + static void setup() { reader = new JarReader(FILENAME); jar = new JarAsserter(reader); } @AfterAll - public static void clean() throws Exception { + static void clean() throws Exception { reader.close(); } @Test - public void presenceOfCoreSources() { + void presenceOfCoreSources() { jar.assertPresenceOf(EV + "/EqualsVerifier.java"); } } diff --git a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/helper/JarAsserter.java b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/helper/JarAsserter.java index b57ecca54..e383b343b 100644 --- a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/helper/JarAsserter.java +++ b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/jar/helper/JarAsserter.java @@ -1,8 +1,7 @@ package nl.jqno.equalsverifier.verify_release.jar.helper; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.function.Function; @@ -64,7 +63,7 @@ public void assertAbsenceOf(String... fileNames) { private void assertForAll(Predicate assertion, Function message, String... filenames) { Stream assertions = - Arrays.stream(filenames).map(fn -> () -> assertTrue(assertion.test(fn), message.apply(fn))); + Arrays.stream(filenames).map(fn -> () -> assertThat(assertion.test(fn)).as(message.apply(fn)).isTrue()); assertAll(assertions); } @@ -80,7 +79,7 @@ public void assertContentOfManifest(String implementationTitle) { } private void assertContains(String needle, String haystack, String innerFilename) { - assertTrue(haystack.contains(needle), "Expected to find '" + needle + "' in " + innerFilename); + assertThat(haystack.contains(needle)).as("Expected to find '" + needle + "' in " + innerFilename).isTrue(); } public void assertVersionsOfClassFiles() { @@ -110,10 +109,10 @@ public void assertVersionsOfEmbeddedClassFiles() { private void assertVersionOfClassFile(int expectedVersion, String innerFilename) { var classFile = reader.getContentOf(innerFilename); var actualVersion = classFile[7]; - assertEquals( - (byte) expectedVersion, - actualVersion, - "Expected " + innerFilename + " to have version " + expectedVersion + ", but it has version " - + actualVersion); + assertThat(actualVersion) + .as( + "Expected " + innerFilename + " to have version " + expectedVersion + ", but it has version " + + actualVersion) + .isEqualTo((byte) expectedVersion); } } diff --git a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/MainPomTest.java b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/MainPomTest.java index 579159802..8747c1ef1 100644 --- a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/MainPomTest.java +++ b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/MainPomTest.java @@ -7,29 +7,29 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public class MainPomTest { +class MainPomTest { private static final String FILENAME = "equalsverifier-main.pom"; private static PomAsserter pom; @BeforeAll - public static void setup() throws Exception { + static void setup() throws Exception { var reader = new PomReader(FILENAME); pom = new PomAsserter(reader); } @Test - public void commonProperties() { + void commonProperties() { pom.assertCommonProperties(); } @Test - public void artifactId() { + void artifactId() { pom.assertArtifactId("equalsverifier"); } @Test - public void dependencies() { + void dependencies() { assertAll( () -> pom.assertNumberOfDependencies(6), () -> pom.assertDependencyIsOptional(1), diff --git a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/NodepPomTest.java b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/NodepPomTest.java index e215d5ea0..a3b5f1254 100644 --- a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/NodepPomTest.java +++ b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/NodepPomTest.java @@ -5,29 +5,29 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public class NodepPomTest { +class NodepPomTest { private static final String FILENAME = "equalsverifier-nodep.pom"; private static PomAsserter pom; @BeforeAll - public static void setup() throws Exception { + static void setup() throws Exception { var reader = new PomReader(FILENAME); pom = new PomAsserter(reader); } @Test - public void commonProperties() { + void commonProperties() { pom.assertCommonProperties(); } @Test - public void artifactId() { + void artifactId() { pom.assertArtifactId("equalsverifier-nodep"); } @Test - public void noDependencies() { + void noDependencies() { pom.assertNumberOfDependencies(0); } } diff --git a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/helper/PomReader.java b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/helper/PomReader.java index 357aa4f4c..3db70e48a 100644 --- a/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/helper/PomReader.java +++ b/equalsverifier-release-verify/src/test/java/nl/jqno/equalsverifier/verify_release/pom/helper/PomReader.java @@ -1,6 +1,6 @@ package nl.jqno.equalsverifier.verify_release.pom.helper; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilderFactory; @@ -31,20 +31,20 @@ public PomReader(String filename) throws Exception { public void assertNode(String expression, String value) { var actual = (String) getValue(expression, XPathConstants.STRING); - assertEquals( - value, - actual, - "Expected: " + value + ", but was: " + actual + "\nFilename: " + filename + "; expression: [" + expression - + "]"); + assertThat(actual) + .as( + "Expected: " + value + ", but was: " + actual + "\nFilename: " + filename + "; expression: [" + + expression + "]") + .isEqualTo(value); } public void assertNodeSize(int expectedLength, String expression) { var nodes = (NodeList) getValue(expression, XPathConstants.NODESET); - assertEquals( - expectedLength, - nodes.getLength(), - "Expected node to have " + expectedLength + " nodes, but it has " + nodes.getLength() + "!\nFilename: " - + filename + "; expression: [" + expression + "]"); + assertThat(nodes.getLength()) + .as( + "Expected node to have " + expectedLength + " nodes, but it has " + nodes.getLength() + + "!\nFilename: " + filename + "; expression: [" + expression + "]") + .isEqualTo(expectedLength); } private Object getValue(String expression, QName qname) { diff --git a/pom.xml b/pom.xml index 1ec8812d3..ccb747538 100644 --- a/pom.xml +++ b/pom.xml @@ -79,6 +79,7 @@ 3.4 1.3.0 + 3.26.3 3.17.0 2.3.100 0.2