@Before
  public void setUp() {
    when(tokenGenerator.generate()).thenReturn("123456789");
    when(tokenGenerator.hash(anyString())).thenReturn("987654321");
    userSession.login().setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
    userDb.insertUser(newUserDto().setLogin(GRACE_HOPPER));
    userDb.insertUser(newUserDto().setLogin(ADA_LOVELACE));

    ws =
        new WsActionTester(
            new GenerateAction(db.getDbClient(), userSession, System2.INSTANCE, tokenGenerator));
  }
  @Test
  public void fail_if_token_hash_already_exists_in_db() {
    when(tokenGenerator.hash(anyString())).thenReturn("987654321");
    db.getDbClient()
        .userTokenDao()
        .insert(db.getSession(), newUserToken().setTokenHash("987654321"));
    db.commit();
    expectedException.expect(ServerException.class);
    expectedException.expectMessage("Error while generating token. Please try again.");

    newRequest(GRACE_HOPPER, TOKEN_NAME);
  }