### Question:
EqualsImpl implements Equals<T> { @Override public boolean equals(T object, Object otherObject) { if (object == otherObject) { return true; } if (object == null || otherObject == null) { return false; } if (!classMatcher.classesMatch(object, otherObject)) { return false; } return isEqual(object, targetClass.cast(otherObject)); } private  EqualsImpl(Class<T> targetClass, List<? extends ComparisonStep<T>> comparisonSteps, ClassMatcher<T> classMatcher); @Override boolean equals(T object, Object otherObject);  }### Answer:
@Test void givenValuesAreTheSameAndNoComparisonsItShouldReturnTrue() { TestObject testObject = getTestObject(); Equals<TestObject> equals = new EqualsImpl.Builder<>(TestObject.class).build(); boolean result = equals.equals(testObject, testObject); assertThat(result) .isTrue(); }
@Test void givenValuesAreNotTheSameAndNoComparisonsItShouldReturnFalse() { TestObject testObject1 = getTestObject(); TestObject testObject2 = getTestObject(); Equals<TestObject> equals = new EqualsImpl.Builder<>(TestObject.class).build(); boolean result = equals.equals(testObject1, testObject2); assertThat(result) .isFalse(); }
@Test void givenClassesDoNotMatchItShouldReturnFalse() { TestObject testObject1 = getTestObject(); TestObject testObject2 = getTestObject(); Equals<TestObject> equals = new EqualsImpl.Builder<>(TestObject.class) .compare(TestObject::getStringValue) .classMatcher((v1, v2) -> false) .build(); boolean result = equals.equals(testObject1, testObject2); assertThat(result) .isFalse(); }
@Test void givenDelegatingComparisonFailsItShouldReturnFalse() { TestObject testObject1 = getTestObject(); TestObject testObject2 = getTestObject(); Equals<TestObject> equals = new EqualsImpl.Builder<>(TestObject.class) .compare(TestObject::getStringValue) .equalIf((value1, value2) -> false) .build(); boolean result = equals.equals(testObject1, testObject2); assertThat(result) .isFalse(); }