11package com .mapbox .services .android .navigation .v5 .milestone ;
22
33import com .mapbox .api .directions .v5 .models .DirectionsRoute ;
4+ import com .mapbox .navigator .VoiceInstruction ;
45import com .mapbox .services .android .navigation .v5 .routeprogress .RouteProgress ;
56
67import org .junit .Test ;
78
89import static junit .framework .Assert .assertEquals ;
910import static junit .framework .Assert .assertFalse ;
1011import static junit .framework .Assert .assertNotNull ;
12+ import static org .mockito .Mockito .RETURNS_DEEP_STUBS ;
1113import static org .mockito .Mockito .mock ;
1214import static org .mockito .Mockito .when ;
1315
@@ -23,26 +25,25 @@ public void sanity() {
2325 @ Test
2426 public void onSameInstructionOccurring_milestoneDoesNotTriggerTwice () {
2527 RouteProgress firstProgress = mock (RouteProgress .class );
26- when (firstProgress .currentAnnouncement ()).thenReturn ("instruction" );
28+ VoiceInstruction voiceInstruction = mock (VoiceInstruction .class );
29+ when (firstProgress .voiceInstruction ()).thenReturn (voiceInstruction , null );
30+ when (voiceInstruction .getAnnouncement ()).thenReturn ("instruction" );
2731 when (firstProgress .directionsRoute ()).thenReturn (mock (DirectionsRoute .class ));
28- RouteProgress secondProgress = mock (RouteProgress .class );
29- when (secondProgress .directionsRoute ()).thenReturn (mock (DirectionsRoute .class ));
30- when (secondProgress .currentAnnouncement ()).thenReturn ("instruction" );
3132 VoiceInstructionMilestone milestone = buildVoiceInstructionMilestone ();
3233
3334 milestone .isOccurring (firstProgress , firstProgress );
34- boolean shouldNotBeOccurring = milestone .isOccurring (firstProgress , secondProgress );
35+ boolean shouldNotBeOccurring = milestone .isOccurring (firstProgress , firstProgress );
3536
3637 assertFalse (shouldNotBeOccurring );
3738 }
3839
3940 @ Test
4041 public void onOccurringMilestone_voiceSsmlInstructionsAreReturned () {
41- RouteProgress routeProgress = mock (RouteProgress .class );
42+ RouteProgress routeProgress = mock (RouteProgress .class , RETURNS_DEEP_STUBS );
4243 when (routeProgress .directionsRoute ()).thenReturn (mock (DirectionsRoute .class ));
43- when (routeProgress .currentAnnouncement ()).thenReturn ("current announcement" );
44+ when (routeProgress .voiceInstruction (). getAnnouncement ()).thenReturn ("current announcement" );
4445 String currentSsmlAnnouncement = "current SSML announcement" ;
45- when (routeProgress .currentSsmlAnnouncement ()).thenReturn (currentSsmlAnnouncement );
46+ when (routeProgress .voiceInstruction (). getSsmlAnnouncement ()).thenReturn (currentSsmlAnnouncement );
4647 VoiceInstructionMilestone milestone = buildVoiceInstructionMilestone ();
4748
4849 milestone .isOccurring (routeProgress , routeProgress );
@@ -52,12 +53,12 @@ public void onOccurringMilestone_voiceSsmlInstructionsAreReturned() {
5253
5354 @ Test
5455 public void onOccurringMilestone_voiceInstructionsAreReturned () {
55- RouteProgress routeProgress = mock (RouteProgress .class );
56+ RouteProgress routeProgress = mock (RouteProgress .class , RETURNS_DEEP_STUBS );
5657 when (routeProgress .directionsRoute ()).thenReturn (mock (DirectionsRoute .class ));
5758 String currentAnnouncement = "current announcement" ;
58- when (routeProgress .currentAnnouncement ()).thenReturn (currentAnnouncement );
59+ when (routeProgress .voiceInstruction (). getAnnouncement ()).thenReturn (currentAnnouncement );
5960 String currentSsmlAnnouncement = "current SSML announcement" ;
60- when (routeProgress .currentSsmlAnnouncement ()).thenReturn (currentSsmlAnnouncement );
61+ when (routeProgress .voiceInstruction (). getSsmlAnnouncement ()).thenReturn (currentSsmlAnnouncement );
6162 VoiceInstructionMilestone milestone = buildVoiceInstructionMilestone ();
6263
6364 milestone .isOccurring (routeProgress , routeProgress );
@@ -67,12 +68,12 @@ public void onOccurringMilestone_voiceInstructionsAreReturned() {
6768
6869 @ Test
6970 public void onOccurringMilestone_instructionsAreReturned () {
70- RouteProgress routeProgress = mock (RouteProgress .class );
71+ RouteProgress routeProgress = mock (RouteProgress .class , RETURNS_DEEP_STUBS );
7172 when (routeProgress .directionsRoute ()).thenReturn (mock (DirectionsRoute .class ));
7273 String currentAnnouncement = "current announcement" ;
73- when (routeProgress .currentAnnouncement ()).thenReturn (currentAnnouncement );
74+ when (routeProgress .voiceInstruction (). getAnnouncement ()).thenReturn (currentAnnouncement );
7475 String currentSsmlAnnouncement = "current SSML announcement" ;
75- when (routeProgress .currentSsmlAnnouncement ()).thenReturn (currentSsmlAnnouncement );
76+ when (routeProgress .voiceInstruction (). getSsmlAnnouncement ()).thenReturn (currentSsmlAnnouncement );
7677 VoiceInstructionMilestone milestone = buildVoiceInstructionMilestone ();
7778
7879 milestone .isOccurring (routeProgress , routeProgress );
0 commit comments