LocationCheck { private LocationCheck() { throw new UnsupportedOperationException(); } private  LocationCheck(); static int calculateMaxDistanceFromPath(final List<? extends Line> lines); static int calculateMaxDistanceFromCoordinates(final List<? extends GeoCoordinates> coords);  }
@Test public final void testLocationCheck() { Mockery context = new Mockery(); final Line l1 = context.mock(Line.class, "l1"); final Node sl1 = context.mock(Node.class, "sl1)"); final Node el1 = context.mock(Node.class, "el1)"); final Line l2 = context.mock(Line.class, "l2"); final Node sl2 = context.mock(Node.class, "sl2)"); final Node el2 = context.mock(Node.class, "el2)"); final Line l3 = context.mock(Line.class, "l3"); final Node sl3 = context.mock(Node.class, "sl3)"); final Node el3 = context.mock(Node.class, "el3)"); context.checking(new Expectations() { { allowing(l1).getStartNode(); will(returnValue(sl1)); } { allowing(l1).getEndNode(); will(returnValue(el1)); } { allowing(sl1).getLatitudeDeg(); will(returnValue(65.69)); } { allowing(el1).getLatitudeDeg(); will(returnValue(64.69)); } }); context.checking(new Expectations() { { allowing(l2).getStartNode(); will(returnValue(sl2)); } { allowing(l2).getEndNode(); will(returnValue(el2)); } { allowing(sl2).getLatitudeDeg(); will(returnValue(66.00)); } { allowing(el2).getLatitudeDeg(); will(returnValue(64.69)); } }); context.checking(new Expectations() { { allowing(l3).getStartNode(); will(returnValue(sl3)); } { allowing(l3).getEndNode(); will(returnValue(el3)); } { allowing(sl3).getLatitudeDeg(); will(returnValue(66.00)); } { allowing(el3).getLatitudeDeg(); will(returnValue(70.0)); } }); List<Line> lines1 = new ArrayList<Line>(); lines1.add(l1); int value1 = LocationCheck.calculateMaxDistanceFromPath(lines1); assertEquals(value1, 15000); List<Line> lines2 = new ArrayList<Line>(); lines2.add(l2); int value2 = LocationCheck.calculateMaxDistanceFromPath(lines2); assertEquals(value2, 14820); List<Line> lines3 = new ArrayList<Line>(); lines3.add(l3); int value3 = LocationCheck.calculateMaxDistanceFromPath(lines3); assertEquals(value3, 12462); List<Line> lines4 = new ArrayList<Line>(); lines4.add(l2); lines4.add(l3); int value4 = LocationCheck.calculateMaxDistanceFromPath(lines4); assertEquals(value4, 12462); }