### Question:
RouteUtils { @Nullable public BannerText findCurrentBannerText(LegStep currentStep, double stepDistanceRemaining, boolean findPrimary) { BannerInstructions instructions = findCurrentBannerInstructions(currentStep, stepDistanceRemaining); if (instructions != null) { return retrievePrimaryOrSecondaryBannerText(findPrimary, instructions); } 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 findCurrentBannerText_returnsCorrectPrimaryBannerText() 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(); BannerText currentBannerText = routeUtils.findCurrentBannerText( currentStep, stepDistanceRemaining, true ); assertEquals(currentStep.bannerInstructions().get(1).primary(), currentBannerText); }
@Test public void findCurrentBannerText_returnsCorrectSecondaryBannerText() 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(); BannerText currentBannerText = routeUtils.findCurrentBannerText( currentStep, stepDistanceRemaining, false ); assertEquals(currentStep.bannerInstructions().get(1).secondary(), currentBannerText); }
@Test public void findCurrentBannerText_returnsNullWithNullCurrentStep() throws Exception { LegStep currentStep = null; double stepDistanceRemaining = 0; RouteUtils routeUtils = new RouteUtils(); BannerText currentBannerText = routeUtils.findCurrentBannerText( currentStep, stepDistanceRemaining, false ); assertNull(currentBannerText); }