@Test
  public void testLoginActionByAuthenticateOneTimeUser() throws Exception {
    String actionString = Action.Login.toString();
    when(mockHttpServletRequest.getParameter(ServletUtil.ACTION)).thenReturn(actionString);
    when(mockHttpServletRequest.getParameter(ServletUtil.PROJECT)).thenReturn(projectString);

    // set AuthenticateOneTimeUser true
    prepareEnterAuthenticateOneTimeUser(true);

    String xmi = constructProjectsObjectsXmi();
    doThrow(
            new org.talend.gwtadministrator.server.remoteconnection.ConnectionUtil
                .ResponseException(xmi))
        .when(ConnectionUtil.class);
    ConnectionUtil.returnProjectAndUsers(anyString(), (User) any(), anyBoolean());

    // RUN...
    defaultConnectionStrategy.execute(mockHttpServletRequest, mockHttpServletResponse);

    verifyNecessaryChecks(actionString);

    // verify called listAllProjects once
    verifyStatic(org.mockito.Mockito.times(1));
    ConnectionUtil.returnProjectAndUsers(anyString(), (User) any(), anyBoolean());

    PrintWriter writer = mockHttpServletResponse.getWriter();
    writer.flush();
    System.out.println(outStringWriter.toString());
    // ASSERT...
    assertThat(outStringWriter.toString(), is("RESPONSE:" + xmi));
  }
  @Test
  public void testLoginActionByNormalUser() throws Exception {
    String actionString = Action.Login.toString();
    when(mockHttpServletRequest.getParameter(ServletUtil.ACTION)).thenReturn(actionString);
    when(mockHttpServletRequest.getParameter(ServletUtil.PROJECT)).thenReturn(projectString);

    // set AuthenticateOneTimeUser false
    prepareEnterAuthenticateOneTimeUser(false);
    User user = stubbingCheckUser();

    UserHelper tempUserHelper = SingletonUtil.spySingleton(UserHelper.class);
    doNothing().when(tempUserHelper).merge(user);

    doNothing().when(ConnectionUtil.class);
    ConnectionUtil.updateUserConnectionTracking(user);
    doNothing().when(ConnectionUtil.class);
    ConnectionUtil.checkUserAuthorization(projectString, user);

    String xmi = constructProjectsObjectsXmi();
    doThrow(
            new org.talend.gwtadministrator.server.remoteconnection.ConnectionUtil
                .ResponseException(xmi))
        .when(ConnectionUtil.class);
    ConnectionUtil.returnProjectAndUsers(projectString, user, false);

    // RUN...
    defaultConnectionStrategy.execute(mockHttpServletRequest, mockHttpServletResponse);

    verifyNecessaryChecks(actionString);

    verifyStatic(org.mockito.Mockito.times(1));
    ConnectionUtil.checkUser(loginString, password, false);

    verifyStatic(org.mockito.Mockito.times(1));
    ConnectionUtil.updateUserConnectionTracking(user);

    verifyStatic(org.mockito.Mockito.times(1));
    ConnectionUtil.checkUserAuthorization(projectString, user);

    verifyStatic(org.mockito.Mockito.times(1));
    ConnectionUtil.returnProjectAndUsers(projectString, user, false);

    PrintWriter writer = mockHttpServletResponse.getWriter();
    writer.flush();
    System.out.println(outStringWriter.toString());
    // ASSERT...
    assertThat(outStringWriter.toString(), is("RESPONSE:" + xmi));
  }