use of games.strategy.triplea.image.ResourceImageFactory in project triplea by triplea-game.
the class RouteTest method testCorrectParameterHandling.
@Test
public void testCorrectParameterHandling() {
final MapPanel mockedMapPanel = mock(MapPanel.class);
final MapRouteDrawer routeDrawer = spy(new MapRouteDrawer(mockedMapPanel, dummyMapData));
when(mockedMapPanel.getXOffset()).thenReturn(0);
when(mockedMapPanel.getYOffset()).thenReturn(0);
when(mockedMapPanel.getScale()).thenReturn(0.0);
when(mockedMapPanel.getImageWidth()).thenReturn(1);
when(mockedMapPanel.getImageHeight()).thenReturn(1);
final Shape mockShape = mock(Shape.class);
final Graphics2D mockGraphics = mock(Graphics2D.class);
when(mockShape.contains(any(Point2D.class))).thenReturn(true);
final ResourceCollection mockResourceCollection = mock(ResourceCollection.class);
when(mockResourceCollection.getResourcesCopy()).thenReturn(new IntegerMap<>());
final ResourceImageFactory mockResourceImageFactory = mock(ResourceImageFactory.class);
routeDrawer.drawRoute(mockGraphics, dummyRouteDescription, "2", mockResourceCollection, mockResourceImageFactory);
verify(mockGraphics, atLeastOnce()).fill(any(Shape.class));
verify(mockGraphics, atLeastOnce()).draw(any(Shape.class));
// Those methods are needed
verify(mockedMapPanel, atLeastOnce()).getXOffset();
verify(mockedMapPanel, atLeastOnce()).getYOffset();
verify(mockedMapPanel, atLeastOnce()).getScale();
verify(dummyRouteDescription, times(2)).getRoute();
verify(dummyRouteDescription.getRoute(), atLeastOnce()).getAllTerritories();
}
Aggregations