### Question:
VoiceInstructionMilestone extends Milestone { @Override public boolean isOccurring(RouteProgress previousRouteProgress, RouteProgress routeProgress) { if (isNewRoute(routeProgress)) { cacheInstructions(routeProgress, true); } LegStep currentStep = routeProgress.currentLegProgress().currentStep(); double stepDistanceRemaining = routeProgress.currentLegProgress().currentStepProgress().distanceRemaining(); VoiceInstructions instructions = routeUtils.findCurrentVoiceInstructions(currentStep, stepDistanceRemaining); if (shouldBeVoiced(instructions, stepDistanceRemaining)) { return updateInstructions(routeProgress, instructions); } return false; } VoiceInstructionMilestone(Builder builder); @Override boolean isOccurring(RouteProgress previousRouteProgress, RouteProgress routeProgress); @Override Instruction getInstruction(); String getSsmlAnnouncement(); String getAnnouncement();  }### Answer:
@Test public void onBeginningOfStep_voiceInstructionsShouldTrigger() throws Exception { RouteProgress routeProgress = buildDefaultTestRouteProgress(); routeProgress = createBeginningOfStepRouteProgress(routeProgress); VoiceInstructionMilestone milestone = buildVoiceInstructionMilestone(); boolean isOccurring = milestone.isOccurring(routeProgress, routeProgress); assertTrue(isOccurring); }
@Test public void onSameInstructionOccurring_milestoneDoesNotTriggerTwice() throws Exception { RouteProgress routeProgress = buildDefaultTestRouteProgress(); RouteProgress firstProgress = createBeginningOfStepRouteProgress(routeProgress); RouteProgress secondProgress = routeProgress.toBuilder() .stepDistanceRemaining(routeProgress.currentLegProgress().currentStep().distance() - 40) .stepIndex(0) .build(); VoiceInstructionMilestone milestone = buildVoiceInstructionMilestone(); milestone.isOccurring(firstProgress, firstProgress); boolean shouldNotBeOccurring = milestone.isOccurring(firstProgress, secondProgress); assertFalse(shouldNotBeOccurring); }
@Test public void nullInstructions_doNotGetTriggered() throws Exception { RouteProgress routeProgress = buildDefaultTestRouteProgress(); LegStep currentStep = routeProgress.currentLegProgress().currentStep(); List<VoiceInstructions> instructions = currentStep.voiceInstructions(); instructions.clear(); routeProgress = createBeginningOfStepRouteProgress(routeProgress); VoiceInstructionMilestone milestone = buildVoiceInstructionMilestone(); boolean isOccurring = milestone.isOccurring(routeProgress, routeProgress); assertFalse(isOccurring); }