Search in sources :

Example 1 with ResourceImageFactory

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();
}
Also used : Shape(java.awt.Shape) Point2D(java.awt.geom.Point2D) ResourceImageFactory(games.strategy.triplea.image.ResourceImageFactory) Graphics2D(java.awt.Graphics2D) ResourceCollection(games.strategy.engine.data.ResourceCollection) Test(org.junit.jupiter.api.Test)

Aggregations

ResourceCollection (games.strategy.engine.data.ResourceCollection)1 ResourceImageFactory (games.strategy.triplea.image.ResourceImageFactory)1 Graphics2D (java.awt.Graphics2D)1 Shape (java.awt.Shape)1 Point2D (java.awt.geom.Point2D)1 Test (org.junit.jupiter.api.Test)1