@Test
  public void testCloseSessionByNormalUser() throws Exception {
    String sessionIdString = "555";
    String actionString = Action.CloseSession.toString();
    long sessionIdLong = Long.parseLong(sessionIdString);
    when(mockHttpServletRequest.getParameter(ServletUtil.ACTION)).thenReturn(actionString);
    when(mockHttpServletRequest.getParameter(ServletUtil.SESSION_ID)).thenReturn(sessionIdString);

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

    UsersCache userCacheHelper = mock(UsersCache.class);
    mockStatic(UsersCacheFactory.class);
    when(UsersCacheFactory.getInstance()).thenReturn(userCacheHelper);
    doNothing().when(userCacheHelper);
    userCacheHelper.remove(sessionIdLong);

    // 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(sessionIdLong)));
  }
  @Test(expected = NotFoundException.class)
  public void unbindByInvalidSerialShouldFail() {
    Consumer consumer = createConsumer();
    ConsumerCurator consumerCurator = mock(ConsumerCurator.class);
    when(consumerCurator.verifyAndLookupConsumer(eq("fake uuid"))).thenReturn(consumer);

    EntitlementCurator entitlementCurator = mock(EntitlementCurator.class);
    when(entitlementCurator.find(any(Serializable.class))).thenReturn(null);

    ConsumerResource consumerResource =
        new ConsumerResource(
            consumerCurator,
            null,
            null,
            null,
            entitlementCurator,
            null,
            null,
            i18n,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            new CandlepinCommonTestConfig(),
            null,
            null,
            null,
            consumerBindUtil,
            productCurator,
            null);

    consumerResource.unbindBySerial("fake uuid", Long.valueOf(1234L));
  }
  @Test
  public void testCertificationGetters() {
    Certification credential = CredentialFactory.getInstance().createCertification();
    credential.getCertificationType().setId(1L);

    action.setCredential(new Degree());
    assertNull(action.getCertification());

    action.setCertification(new Certification());

    when(mockDataService.getPersistentObject(CertificationType.class, null)).thenReturn(null);
    when(mockDataService.getPersistentObject(CertificationType.class, 1L))
        .thenReturn(credential.getCertificationType());

    action.setCertificationTypeId(null);
    assertNull(action.getCertificationTypeId());
    action.setCertificationTypeId(1L);
    assertEquals(Long.valueOf(1L), action.getCertificationTypeId());
  }