package pipe.views;

import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.awt.geom.Point2D;

import org.junit.Before;
import org.junit.Test;

import pipe.controllers.PetriNetController;
import pipe.gui.ZoomController;
import pipe.models.component.arc.Arc;
import pipe.models.component.place.Place;
import pipe.models.component.transition.Transition;
import pipe.views.viewComponents.ArcPath;

public class ArcViewTest {

    private ArcView<Place, Transition> arcView;
    private Arc<Place, Transition> mockArc;
    private Point2D.Double start = new Point2D.Double(50, 39);
    private Point2D.Double end = new Point2D.Double(100, 500);
    private static final double DOUBLE_DELTA = 0.0001;
    private Place source;
    private Transition transition;

    @Before
    public void setUp() throws Exception {
        PetriNetController mockController = mock(PetriNetController.class);
        mockArc = mock(Arc.class);
        source = new Place("","");
        transition =  new Transition("", "");
        when(mockArc.getSource()).thenReturn(source);
        when(mockArc.getTarget()).thenReturn(transition);
        when(mockArc.getStartPoint()).thenReturn(start);
        when(mockArc.getEndPoint()).thenReturn(end);
        arcView = new NormalArcView<Place, Transition>(mockArc, mockController);
    }

    @Test
    public void ArcViewSetsCorrectPathInConstructor() {
        ArcPath path = arcView.getArcPath();
        assertEquals(2, path.getNumPoints());
        assertEquals(start, path.getPoint(0));
        assertEquals(end, path.getPoint(1));
    }


    @Test
    public void zoomUpdatesPoints() {
        int zoom = 110;
        arcView.zoomUpdate(zoom);
        ArcPath path = arcView.getArcPath();
        assertEquals(2, path.getNumPoints());
        Point2D.Double zoomedStart =  ZoomController.getZoomedValue(start, zoom);
        Point2D actualStart = path.getPoint(0);
        assertEquals(zoomedStart.x, actualStart.getX(), DOUBLE_DELTA);
        assertEquals(zoomedStart.y, actualStart.getY(), DOUBLE_DELTA);


        Point2D.Double zoomedEnd =  ZoomController.getZoomedValue(end, zoom);
        Point2D actualEnd = path.getPoint(1);
        assertEquals(zoomedEnd.x, actualEnd.getX(), DOUBLE_DELTA);
        assertEquals(zoomedEnd.y, actualEnd.getY(), DOUBLE_DELTA);
    }
}

@@ -1690,743 +1690,6 @@
   %7D%0A
-%0A%0A    @Test%0A    public void zoomUpdatesPoints() %7B%0A        int zoom = 110;%0A        arcView.zoomUpdate(zoom);%0A        ArcPath path = arcView.getArcPath();%0A        assertEquals(2, path.getNumPoints());%0A        Point2D.Double zoomedStart =  ZoomController.getZoomedValue(start, zoom);%0A        Point2D actualStart = path.getPoint(0);%0A        assertEquals(zoomedStart.x, actualStart.getX(), DOUBLE_DELTA);%0A        assertEquals(zoomedStart.y, actualStart.getY(), DOUBLE_DELTA);%0A%0A%0A        Point2D.Double zoomedEnd =  ZoomController.getZoomedValue(end, zoom);%0A        Point2D actualEnd = path.getPoint(1);%0A        assertEquals(zoomedEnd.x, actualEnd.getX(), DOUBLE_DELTA);%0A        assertEquals(zoomedEnd.y, actualEnd.getY(), DOUBLE_DELTA);%0A    %7D%0A
 %7D%0A

Remove ZoomUpdatesPoints test from ArcView