RouteSearch { public RouteSearch(final List<? extends Line> loc) throws OpenLREncoderProcessingException { location = loc; if (location == null || location.isEmpty()) { throw new OpenLREncoderProcessingException( EncoderProcessingError.ROUTE_CONSTRUCTION_ERROR); } startLine = location.get(0); destLine = location.get(location.size() - 1); for (int routeIndex = 0; routeIndex < location.size(); ++routeIndex) { lengthBetweenStartAndEndLineAlongLocation += location.get(routeIndex).getLineLength(); } startLoopIndex = checkLoopAtStart(); endLoopIndex = checkLoopAtEnd(); } RouteSearch(final List<? extends Line> loc); final RouteSearchResult calculateRoute(); @Override final String toString();  }
@Test public final void testRouteSearch() { TestData td = TestData.getInstance(); Location loc = td.getRoute(); List<? extends Line> theRoute = loc.getLocationLines(); RouteSearchResult result = null; try { RouteSearch rs = new RouteSearch(theRoute); result = rs.calculateRoute(); } catch (OpenLREncoderProcessingException e1) { fail("Unexpected exception", e1); } assertTrue("Route search failed for first calculation!", result .getResult() == RouteSearchResult.RouteSearchReturnCode.INTERMEDIATE_FOUND); assertEquals("Wrong intermediate found!", result.getIntermediate() .getID(), td.getIntermediate().getID()); assertEquals("Wrong route length 1!", result.getRouteLength(), td .getRoutLength1()); List<? extends Line> rest = theRoute.subList(td.getIntermediatePos(), theRoute.size()); try { RouteSearch rs = new RouteSearch(rest); result = rs.calculateRoute(); CommonObjectTestUtils.testToString(rs); } catch (OpenLREncoderProcessingException e) { fail("Unexpected exception", e); } assertTrue("Route search failed for first calculation!", result .getResult() == RouteSearchResult.RouteSearchReturnCode.ROUTE_FOUND); assertEquals("Wrong route length 2!", result.getRouteLength(), td .getRoutLength2()); }