@Before public void beforeTest() { testObj = new IndexPageImpl(); testObj.setApplication(new UserApplicationStub()); testObj.setSessionData(new UserSessionData()); testObj.setMainMenuPage(new MainMenuStub()); jsfUtil = new JsfUtilStub(); testObj.setJsfUtill(jsfUtil); }
@Test public void testLoginNgNoUser() { testObj.setUserId("NODATA"); testObj.setPassword(UserApplicationStub.TEST_USER_PASSWORD); final String forwardKey = testObj.login(); assertThat(forwardKey, is(ForwardKey.INDEX_PAGE.getValue())); assertThat(jsfUtil.getErrorCount(), is(1)); assertThat(jsfUtil.getByIndex(0).getMessageInfo(), is(MessageInfo.ERROR_LOGIN)); }
@Test public void testLoginOk() { testObj.setUserId(UserApplicationStub.TEST_USER_ID); testObj.setPassword(UserApplicationStub.TEST_USER_PASSWORD); final String forwardKey = testObj.login(); assertThat(forwardKey, is(ForwardKey.MAIN_MENU.getValue())); final UserSessionData sessionData = testObj.getSessionData(); assertThat(sessionData.getUserId(), is(UserApplicationStub.TEST_USER_ID)); assertThat(sessionData.getName(), is(UserApplicationStub.TEST_USER_NAME)); assertThat(sessionData.getAuthorityList().contains(AuthorityType.ADMINISTRATOR), is(true)); }