1515import ru .untitled_devs .bot .shared .models .Profile ;
1616import ru .untitled_devs .core .client .PollingClient ;
1717import ru .untitled_devs .core .context .UpdateContext ;
18+ import ru .untitled_devs .core .exceptions .StopRoutingException ;
1819import ru .untitled_devs .core .fsm .DataKey ;
1920import ru .untitled_devs .core .fsm .FSMContext ;
2021import ru .untitled_devs .core .routers .scenes .SceneManager ;
@@ -85,7 +86,8 @@ void getNameGotValidName() {
8586 DataKey <Profile > key = DataKey .of ("RegistrationData" , Profile .class );
8687 when (ctx .getData (key )).thenReturn (profile );
8788
88- assertDoesNotThrow (() -> router .routeUpdate (updateContext , ctx ));
89+ assertThrows (StopRoutingException .class ,
90+ () -> router .routeUpdate (updateContext , ctx ));
8991 assertEquals ("Саня" , profile .getName ());
9092 }
9193
@@ -105,7 +107,8 @@ void getNameGotInvalidName() {
105107 DataKey <Profile > key = DataKey .of ("RegistrationData" , Profile .class );
106108 when (ctx .getData (key )).thenReturn (profile );
107109
108- assertDoesNotThrow (() -> router .routeUpdate (updateContext , ctx ));
110+ assertThrows (StopRoutingException .class ,
111+ () -> router .routeUpdate (updateContext , ctx ));
109112 assertNull (profile .getName ());
110113 }
111114
@@ -125,7 +128,8 @@ void getAgeGotDigitString() {
125128 DataKey <Profile > key = DataKey .of ("RegistrationData" , Profile .class );
126129 when (ctx .getData (key )).thenReturn (profile );
127130
128- assertDoesNotThrow (() -> router .routeUpdate (updateContext , ctx ),
131+ assertThrows (StopRoutingException .class ,
132+ () -> router .routeUpdate (updateContext , ctx ),
129133 "Get age must do not throw any exceptions when got valid age type" );
130134
131135 assertEquals (15 , profile .getAge (), "Age must be changed" );
@@ -196,7 +200,8 @@ void getGenderGotValidGender() {
196200 DataKey <Profile > key = DataKey .of ("RegistrationData" , Profile .class );
197201 when (ctx .getData (key )).thenReturn (profile );
198202
199- assertDoesNotThrow (() -> router .routeUpdate (updateContext , ctx ));
203+ assertThrows (StopRoutingException .class ,
204+ () -> router .routeUpdate (updateContext , ctx ));
200205 assertEquals (Gender .FEMALE , profile .getGender ());
201206 }
202207
@@ -236,9 +241,8 @@ void getLocationGotValidLocation() {
236241
237242 when (ctx .getState ()).thenReturn (RegistrationStates .LOCATION );
238243
239- assertDoesNotThrow (
240- () -> router .routeUpdate (updateContext , ctx )
241- );
244+ assertThrows (StopRoutingException .class ,
245+ () -> router .routeUpdate (updateContext , ctx ));
242246
243247 assertEquals ("Екатеринбург" , profile .getLocation ());
244248 assertEquals (Arrays .asList (123.0 , 123.0 ), profile .getCoordinates ().getCoordinates ().getValues ());
@@ -285,9 +289,8 @@ void getLocationGotValidCoordinates() {
285289
286290 when (ctx .getState ()).thenReturn (RegistrationStates .LOCATION );
287291
288- assertDoesNotThrow (
289- () -> router .routeUpdate (updateContext , ctx )
290- );
292+ assertThrows (StopRoutingException .class ,
293+ () -> router .routeUpdate (updateContext , ctx ));
291294
292295 assertEquals ("Екатеринбург" , profile .getLocation ());
293296 assertEquals (Arrays .asList (123.0 , 123.0 ), profile .getCoordinates ().getCoordinates ().getValues ());
@@ -311,9 +314,8 @@ void getLocationGotInvalidCoordinates() {
311314
312315 when (ctx .getState ()).thenReturn (RegistrationStates .LOCATION );
313316
314- assertDoesNotThrow (
315- () -> router .routeUpdate (updateContext , ctx )
316- );
317+ assertThrows (StopRoutingException .class ,
318+ () -> router .routeUpdate (updateContext , ctx ));
317319
318320 assertNull (profile .getLocation ());
319321 assertNull (profile .getCoordinates ());
@@ -336,9 +338,8 @@ void getDescriptionGotValidText() {
336338 when (update .getMessage ()).thenReturn (message );
337339 when (ctx .getState ()).thenReturn (RegistrationStates .DESCRIPTION );
338340
339- assertDoesNotThrow (
340- () -> router .routeUpdate (updateContext , ctx )
341- );
341+ assertThrows (StopRoutingException .class ,
342+ () -> router .routeUpdate (updateContext , ctx ));
342343
343344 assertEquals ("Test description" , profile .getDescription ());
344345 }
@@ -384,9 +385,8 @@ void getDescriptionGotSkipText() {
384385
385386 when (ctx .getState ()).thenReturn (RegistrationStates .DESCRIPTION );
386387
387- assertDoesNotThrow (
388- () -> router .routeUpdate (updateContext , ctx )
389- );
388+ assertThrows (StopRoutingException .class ,
389+ () -> router .routeUpdate (updateContext , ctx ));
390390
391391 assertEquals ("No description." , profile .getDescription ());
392392 }
@@ -424,9 +424,8 @@ void getPhotoGotValidPhoto() throws TelegramApiException, IOException {
424424
425425 when (ctx .getState ()).thenReturn (RegistrationStates .PHOTO );
426426
427- assertDoesNotThrow (
428- () -> router .routeUpdate (updateContext , ctx )
429- );
427+ assertThrows (StopRoutingException .class ,
428+ () -> router .routeUpdate (updateContext , ctx ));
430429 }
431430
432431 @ Test
0 commit comments