@Test public void testOpenSessionByNormalUser() throws Exception { long sessionLong = 555; String actionString = Action.OpenSession.toString(); when(mockHttpServletRequest.getParameter(ServletUtil.ACTION)).thenReturn(actionString); when(mockHttpServletRequest.getParameter(ServletUtil.PROJECT)).thenReturn(projectString); // set AuthenticateOneTimeUser false prepareEnterAuthenticateOneTimeUser(false); User user = stubbingCheckUser(); UsersCache userCacheHelper = mock(UsersCache.class); mockStatic(UsersCacheFactory.class); when(UsersCacheFactory.getInstance()).thenReturn(userCacheHelper); when(userCacheHelper.logWithProjectLabel(loginString, CLIENT_TYPE, projectString)) .thenReturn(sessionLong); // RUN... defaultConnectionStrategy.execute(mockHttpServletRequest, mockHttpServletResponse); verifyNecessaryChecks(actionString); verifyStatic(org.mockito.Mockito.times(1)); ConnectionUtil.checkUser(loginString, password, false); PrintWriter writer = mockHttpServletResponse.getWriter(); writer.flush(); System.out.println(outStringWriter.toString()); // ASSERT... assertThat(outStringWriter.toString(), is("RESPONSE:" + String.valueOf(sessionLong))); }
@Test public void testOpenSessionsActionsByAuthenticateOneTimeUser() throws Exception { testSessionActionsByAuthenticateOneTimeUser(Action.OpenSession.toString()); }