/
LocatorParameterizedTest.java
64 lines (48 loc) · 1.72 KB
/
LocatorParameterizedTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.automationrhapsody.junit;
import com.automationrhapsody.junit.utils.PointUtils;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(Parameterized.class)
public class LocatorParameterizedTest {
private static final Point MOCKED_POINT = new Point(11, 11);
private LocatorService locatorServiceMock = mock(LocatorService.class);
private Locator locatorUnderTest;
@Parameterized.Parameters(name = "{index}: Test with X={0}, Y={1}, result is: {2}")
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][] {
{-1, -1, new Point(1, 1)},
{-1, 0, new Point(1, 0)},
{-1, 1, new Point(1, 1)},
{0, -1, new Point(0, 1)},
{0, 0, MOCKED_POINT},
{0, 1, MOCKED_POINT},
{1, -1, new Point(1, 1)},
{1, 0, MOCKED_POINT},
{1, 1, MOCKED_POINT}
});
}
private final int x;
private final int y;
private final Point expected;
public LocatorParameterizedTest(int x, int y, Point expected) {
this.x = x;
this.y = y;
this.expected = expected;
}
@Before
public void setUp() {
when(locatorServiceMock.geoLocate(any(Point.class))).thenReturn(MOCKED_POINT);
locatorUnderTest = new Locator(locatorServiceMock);
}
@Test
public void testLocateResults() {
assertTrue(PointUtils.arePointsEqual(expected, locatorUnderTest.locate(x, y)));
}
}