diff --git a/src/main/java/pl/pojo/tester/internal/field/AbstractFieldValueChanger.java b/src/main/java/pl/pojo/tester/internal/field/AbstractFieldValueChanger.java index 5b9e79f1..80738199 100644 --- a/src/main/java/pl/pojo/tester/internal/field/AbstractFieldValueChanger.java +++ b/src/main/java/pl/pojo/tester/internal/field/AbstractFieldValueChanger.java @@ -53,7 +53,7 @@ public T increaseValue(final T value) { return (T) next.increaseValue(value); } LOGGER.debug("Could not change value '{}' ot type {} by any field value changer", value, value.getClass()); - return value; + return null; } } diff --git a/src/test/java/pl/pojo/tester/internal/field/AbstractFieldValueChangerTest.java b/src/test/java/pl/pojo/tester/internal/field/AbstractFieldValueChangerTest.java index 6d10524e..7b1707c4 100644 --- a/src/test/java/pl/pojo/tester/internal/field/AbstractFieldValueChangerTest.java +++ b/src/test/java/pl/pojo/tester/internal/field/AbstractFieldValueChangerTest.java @@ -30,7 +30,7 @@ void Should_Register_First_Value_Changer() { } @Test - void Should_Not_Change_If_No_Matching_Changer() { + void Should_Be_Null_If_No_Matching_Changer() { // given final AbstractFieldValueChanger abstractFieldValueChanger = new ImplementationForTest(); final String expectedValue = "string"; @@ -39,7 +39,7 @@ void Should_Not_Change_If_No_Matching_Changer() { final Object result = abstractFieldValueChanger.increaseValue(expectedValue); // then - assertThat(result).isEqualTo(expectedValue); + assertThat(result).isNull(); } @Test diff --git a/src/test/java/pl/pojo/tester/internal/tester/EqualsTesterTest.java b/src/test/java/pl/pojo/tester/internal/tester/EqualsTesterTest.java index b1f29bfd..675c5a8d 100644 --- a/src/test/java/pl/pojo/tester/internal/tester/EqualsTesterTest.java +++ b/src/test/java/pl/pojo/tester/internal/tester/EqualsTesterTest.java @@ -33,6 +33,19 @@ void Should_Pass_All_Equals_Tests() { assertThat(result).isNull(); } + @Test + void Should_Pass_All_Equals_Tests_On_Embedded_Classes() { + // given + final Class[] classesToTest = {GoodPojo_Equals_HashCode_Inner_Class.class}; + final EqualsTester equalsTester = new EqualsTester(DefaultFieldValueChanger.INSTANCE); + + // when + final Throwable result = catchThrowable(() -> equalsTester.testAll(classesToTest)); + + // then + assertThat(result).isNull(); + } + @Test void Should_Pass_All_Equals_Tests_Excluding_Fields() { // given diff --git a/src/test/java/pl/pojo/tester/internal/tester/GoodPojo_Equals_HashCode_Inner_Class.java b/src/test/java/pl/pojo/tester/internal/tester/GoodPojo_Equals_HashCode_Inner_Class.java new file mode 100644 index 00000000..39d0a21f --- /dev/null +++ b/src/test/java/pl/pojo/tester/internal/tester/GoodPojo_Equals_HashCode_Inner_Class.java @@ -0,0 +1,15 @@ +package pl.pojo.tester.internal.tester; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class GoodPojo_Equals_HashCode_Inner_Class { + private InternalClass internalClass; + + @Data + public static class InternalClass { + String id; + } +} \ No newline at end of file