Expose ComparisonStrategy::areEqual in AbstractAssert (#2633) · assertj/assertj@c592c18 (original) (raw)
``
1
`+
/*
`
``
2
`+
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
`
``
3
`+
- the License. You may obtain a copy of the License at
`
``
4
`+
`
``
5
`+
`
``
6
`+
`
``
7
`+
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
`
``
8
`+
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
`
``
9
`+
- specific language governing permissions and limitations under the License.
`
``
10
`+
`
``
11
`+
- Copyright 2012-2022 the original author or authors.
`
``
12
`+
*/
`
``
13
`+
package org.assertj.core.api;
`
``
14
+
``
15
`+
import static org.assertj.core.api.BDDAssertions.then;
`
``
16
`+
import static org.mockito.Answers.CALLS_REAL_METHODS;
`
``
17
`+
import static org.mockito.Mockito.verify;
`
``
18
+
``
19
`+
import java.lang.reflect.Method;
`
``
20
`+
import java.lang.reflect.Modifier;
`
``
21
+
``
22
`+
import org.assertj.core.internal.ComparisonStrategy;
`
``
23
`+
import org.assertj.core.internal.Objects;
`
``
24
`+
import org.junit.jupiter.api.Test;
`
``
25
`+
import org.junit.jupiter.api.extension.ExtendWith;
`
``
26
`+
import org.mockito.Mock;
`
``
27
`+
import org.mockito.junit.jupiter.MockitoExtension;
`
``
28
+
``
29
`+
@ExtendWith(MockitoExtension.class)
`
``
30
`+
class AbstractAssert_areEqual_Test {
`
``
31
+
``
32
`+
@Mock(answer = CALLS_REAL_METHODS)
`
``
33
`+
private AbstractAssert<?, Object> underTest;
`
``
34
+
``
35
`+
@Mock
`
``
36
`+
private ComparisonStrategy comparisonStrategy;
`
``
37
+
``
38
`+
@Test
`
``
39
`+
@SuppressWarnings("deprecation")
`
``
40
`+
void should_delegate_to_ComparableAssert() {
`
``
41
`+
// GIVEN
`
``
42
`+
underTest.objects = new Objects(comparisonStrategy);
`
``
43
`+
// WHEN
`
``
44
`+
underTest.areEqual(42, 43);
`
``
45
`+
// THEN
`
``
46
`+
verify(comparisonStrategy).areEqual(42, 43);
`
``
47
`+
}
`
``
48
+
``
49
`+
@Test
`
``
50
`+
void should_be_protected() throws NoSuchMethodException {
`
``
51
`+
// GIVEN
`
``
52
`+
Method areEqual = underTest.getClass().getDeclaredMethod("areEqual", Object.class, Object.class);
`
``
53
`+
// WHEN
`
``
54
`+
boolean isProtected = Modifier.isProtected(areEqual.getModifiers());
`
``
55
`+
// THEN
`
``
56
`+
then(isProtected).isTrue();
`
``
57
`+
}
`
``
58
+
``
59
`+
}
`