src/test/java/com/webcheckers/ui/PostLoginRouteTest.java
/**
     * Test for checking if the password is wrong.
     */
Test for checking if the password is wrong.
Test for checking if the password is wrong .
@Test
    public void login_game(){
        when(request.queryParams(eq(USERNAME))).thenReturn(USERW);
        when(request.queryParams(eq(PASSWORD))).thenReturn(PASSW);
        when(playerLobby.sign_in(USERW, PASSW)).thenReturn(LoginStatus.NEW_USER_LOGIN);
        Hashtable<String, Player> Players = new Hashtable<>();
        Players.put(USERW, player);
        when(playerLobby.getPlayers()).thenReturn(Players);
        final TemplateEngineTester testHelper = new TemplateEngineTester();
        when(engine.render(any(ModelAndView.class))).thenAnswer(testHelper.makeAnswer());
        CuT.handle(request, response);
        testHelper.assertViewModelExists();
        testHelper.assertViewModelIsaMap();
        testHelper.assertViewModelAttribute(VMAttributes.TITLE, PostLoginRoute.TITLE);
        testHelper.assertViewModelAttribute(VMAttributes.MESSAGE, PostLoginRoute.WELCOME_MSG);
        testHelper.assertViewName("home.ftl");
    }
@ Test public void login_game ( ) { when ( request . queryParams ( eq ( USERNAME ) ) ) . thenReturn ( USERW ) ; when ( request . queryParams ( eq ( PASSWORD ) ) ) . thenReturn ( PASSW ) ; when ( playerLobby . sign_in ( USERW , PASSW ) ) . thenReturn ( LoginStatus . NEW_USER_LOGIN ) ; Hashtable < String , Player > Players = new Hashtable < > ( ) ; Players . put ( USERW , player ) ; when ( playerLobby . getPlayers ( ) ) . thenReturn ( Players ) ; final TemplateEngineTester testHelper = new TemplateEngineTester ( ) ; when ( engine . render ( any ( ModelAndView . class ) ) ) . thenAnswer ( testHelper . makeAnswer ( ) ) ; CuT . handle ( request , response ) ; testHelper . assertViewModelExists ( ) ; testHelper . assertViewModelIsaMap ( ) ; testHelper . assertViewModelAttribute ( VMAttributes . TITLE , PostLoginRoute . TITLE ) ; testHelper . assertViewModelAttribute ( VMAttributes . MESSAGE , PostLoginRoute . WELCOME_MSG ) ; testHelper . assertViewName ( "home.ftl" ) ; }
Test for checking if the password is wrong.
Test for checking if the password is wrong .
// Template engine tester //call handle on the CuT //Test viewmodel // assert view model data //assert view