### Question:
StraightLaneNavigator extends TinkerPopDatabase implements Navigator { @Override public JsonObject getNavigationInstruction(LaneDetectionResult ldr) { JsonObject message = null; if (this.emergencyStopActivated) return message; setTime(ldr); Vertex ldrVertex=addToGraph(ldr); boolean showDebug = true; analyzeAngleRanges(timeWindow, showDebug); if (currentTime - startTime > MAX_DURATION_NO_LINES_DETECTED && stopRangeLeft.count + stopRangeRight.count == 0 || emergencyStopActivated) { this.emergencyStopActivated = true; return ActionVerticle.emergencyStopCommand(); } int MIN_FOUND_PER_TIMEWINDOW = 3; AngleRange navigateRange = null; if (middleRange.count >= MIN_FOUND_PER_TIMEWINDOW) { navigateRange = courseRange; } else { navigateRange = leftRange.count > rightRange.count ? leftRange : rightRange; } if (this.cmdOk(navigateRange, MIN_FOUND_PER_TIMEWINDOW)) { double angle = navigateRange.steer(); String msg = ldr.debugInfo() + String.format("\nsteer by %s: %s", navigateRange.name, Line.angleString(angle)); LOG.debug(msg); ldrVertex.property("steer",angle); ldrVertex.property("steerBy",navigateRange.name); ldrVertex.property("debugInfo",msg); tsLatestCommand = currentTime; message = steerCommand(angle); } return message; } StraightLaneNavigator();  StraightLaneNavigator(int timeWindow); DukesVerticle getSender(); void setSender(DukesVerticle sender); Vertex addToGraph(LaneDetectionResult ldr); @Override LaneDetectionResult fromJsonObject(JsonObject jo); boolean cmdOk(AngleRange angleRange, int minFound); void setTime(LaneDetectionResult ldr); void analyzeAngleRanges(int timeWindow, boolean showDebug); @Override JsonObject getNavigationInstruction(LaneDetectionResult ldr); JsonObject steerCommand(Double angle); @Override void navigateWithInstruction(JsonObject navigationInstruction); @Override void navigateWithMessage(Message<JsonObject> ldrMessage); @Override void navigateWithLaneDetectionResult(LaneDetectionResult ldr); @Override void videoStopped(VideoInfo videoInfo); static int COMMAND_LOOP_INTERVAL; static final int MAX_DURATION_NO_LINES_DETECTED; static final int DEFAULT_TIME_WINDOW; }### Answer:
@Test public void testFromVideo() throws Exception { NativeLibrary.load(); Navigator nav = new StraightLaneNavigator(); String testUrl = "http: ImageFetcher imageFetcher = new ImageFetcher(testUrl); imageFetcher.open(); int frameIndex = 0; int maxFrameIndex = 300; while (frameIndex < maxFrameIndex && imageFetcher.hasNext() && !imageFetcher.isClosed()) { Image image = imageFetcher.fetch(); frameIndex = image.getFrameIndex(); System.out.println(frameIndex); if (imageFetcher.hasNext()) { LaneDetector laneDetector = LaneDetector.getDefault(); LaneDetectionResult ldr = laneDetector.detect(image); if (debug) System.out.println(ldr.debugInfo()); JsonObject navJo = nav.getNavigationInstruction(ldr); if (navJo != null) System.out.println(navJo.encodePrettily()); } } imageFetcher.close(); long nodeCount = nav.g().V().count().next().longValue(); assertEquals(maxFrameIndex, nodeCount); }