### Question:
RouteUtils { @Nullable public BannerInstructions findCurrentBannerInstructions(LegStep currentStep, double stepDistanceRemaining) { if (isValidBannerInstructions(currentStep)) { List<BannerInstructions> instructions = sortBannerInstructions(currentStep.bannerInstructions()); for (BannerInstructions instruction : instructions) { double distanceAlongGeometry = instruction.distanceAlongGeometry(); if (distanceAlongGeometry >= stepDistanceRemaining) { return instruction; } } return instructions.get(FIRST_INSTRUCTION); } return null; }  boolean isNewRoute(@Nullable RouteProgress previousRouteProgress,
                            @NonNull RouteProgress routeProgress); boolean isNewRoute(@Nullable RouteProgress previousRouteProgress,
                            @NonNull DirectionsRoute directionsRoute); boolean isArrivalEvent(@NonNull RouteProgress routeProgress, @NonNull Milestone milestone); boolean isLastLeg(RouteProgress routeProgress); @Nullable List<Point> calculateRemainingWaypoints(RouteProgress routeProgress); @Nullable String[] calculateRemainingWaypointNames(RouteProgress routeProgress); Location createFirstLocationFromRoute(DirectionsRoute route); boolean isValidRouteProfile(String routeProfile); @Nullable BannerInstructions findCurrentBannerInstructions(LegStep currentStep, double stepDistanceRemaining); @Nullable BannerText findCurrentBannerText(LegStep currentStep, double stepDistanceRemaining,
                                          boolean findPrimary); @Nullable VoiceInstructions findCurrentVoiceInstructions(LegStep currentStep, double stepDistanceRemaining);  }### Answer:
@Test public void findCurrentBannerInstructions_returnsNullWithNullCurrentStep() throws Exception { LegStep currentStep = null; double stepDistanceRemaining = 0; RouteUtils routeUtils = new RouteUtils(); BannerInstructions currentBannerInstructions = routeUtils.findCurrentBannerInstructions( currentStep, stepDistanceRemaining ); assertNull(currentBannerInstructions); }
@Test public void findCurrentBannerInstructions_returnsNullWithCurrentStepEmptyInstructions() throws Exception { RouteProgress routeProgress = buildDefaultTestRouteProgress(); LegStep currentStep = routeProgress.currentLegProgress().currentStep(); double stepDistanceRemaining = routeProgress.currentLegProgress().currentStepProgress().distanceRemaining(); List<BannerInstructions> currentInstructions = currentStep.bannerInstructions(); currentInstructions.clear(); RouteUtils routeUtils = new RouteUtils(); BannerInstructions currentBannerInstructions = routeUtils.findCurrentBannerInstructions( currentStep, stepDistanceRemaining ); assertNull(currentBannerInstructions); }
@Test public void findCurrentBannerInstructions_returnsCorrectCurrentInstruction() throws Exception { RouteProgress routeProgress = buildDefaultTestRouteProgress(); LegStep currentStep = routeProgress.currentLegProgress().currentStep(); double stepDistanceRemaining = routeProgress.currentLegProgress().currentStepProgress().distanceRemaining(); RouteUtils routeUtils = new RouteUtils(); BannerInstructions currentBannerInstructions = routeUtils.findCurrentBannerInstructions( currentStep, stepDistanceRemaining ); assertEquals(currentStep.bannerInstructions().get(0), currentBannerInstructions); }
@Test public void findCurrentBannerInstructions_adjustedDistanceRemainingReturnsCorrectInstruction() throws Exception { RouteProgress routeProgress = buildDefaultTestRouteProgress(); routeProgress = routeProgress.toBuilder() .stepIndex(1) .stepDistanceRemaining(50) .build(); LegStep currentStep = routeProgress.currentLegProgress().currentStep(); double stepDistanceRemaining = routeProgress.currentLegProgress().currentStepProgress().distanceRemaining(); RouteUtils routeUtils = new RouteUtils(); BannerInstructions currentBannerInstructions = routeUtils.findCurrentBannerInstructions( currentStep, stepDistanceRemaining ); assertEquals(currentStep.bannerInstructions().get(1), currentBannerInstructions); }
@Test public void findCurrentBannerInstructions_adjustedDistanceRemainingRemovesCorrectInstructions() throws Exception { RouteProgress routeProgress = buildDefaultTestRouteProgress(); routeProgress = routeProgress.toBuilder() .stepIndex(1) .stepDistanceRemaining(500) .build(); LegStep currentStep = routeProgress.currentLegProgress().currentStep(); double stepDistanceRemaining = routeProgress.currentLegProgress().currentStepProgress().distanceRemaining(); RouteUtils routeUtils = new RouteUtils(); BannerInstructions currentBannerInstructions = routeUtils.findCurrentBannerInstructions( currentStep, stepDistanceRemaining ); assertEquals(currentStep.bannerInstructions().get(0), currentBannerInstructions); }