Expose ComparisonStrategy::areEqual in AbstractAssert (#2633) · assertj/assertj@c592c18 (original) (raw)

``

1

`+

/*

`

``

2

`+

`

``

3

`+

`

``

4

`+

`

``

5

`+

`

``

6

`+

`

``

7

`+

`

``

8

`+

`

``

9

`+

`

``

10

`+

`

``

11

`+

`

``

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

`+

}

`