Esempio n. 1
0
 @Test
 public void testCostruttoreTot() {
   initTot();
   assertTrue("Username non è quello atteso", user.getUsername() == "Liquid90");
   assertTrue("Nome non è quello atteso", user.getName() == "Giacomo");
   assertTrue("Cognome non è quello atteso", user.getSurname() == "Bain");
   assertTrue("IP non è quello atteso", user.getIP() == "0.0.10.10");
 }
Esempio n. 2
0
  @Test
  public void testLoginUser() throws Exception {
    User user = createUser();
    api.createUser(user);

    String token = api.loginUser(user.getUsername(), user.getPassword());
    assertTrue(token.startsWith("logged in user session:"));
  }
Esempio n. 3
0
  @Test
  public void testCreateUser() throws Exception {
    User user = createUser();

    api.createUser(user);

    User fetched = api.getUserByName(user.getUsername());
    assertEquals(user.getId(), fetched.getId());
  }
 @Test
 public void getUserInfo() throws Exception {
   User userInfo = module.getUserInfo();
   assertNotNull(userInfo);
   assertFalse(userInfo.getUserId().isEmpty());
   assertFalse(userInfo.getUserEmail().isEmpty());
   assertEquals(System.getenv("zuoraUsername"), userInfo.getUsername());
   assertFalse(userInfo.getTenantId().isEmpty());
   assertFalse(userInfo.getTenantName().isEmpty());
 }
Esempio n. 5
0
  @Test
  public void testCreateUsersWithList() throws Exception {
    User user1 = createUser();
    user1.setUsername("abc123");
    User user2 = createUser();
    user2.setUsername("123abc");

    api.createUsersWithListInput(Arrays.asList(new User[] {user1, user2}));

    User fetched = api.getUserByName(user1.getUsername());
    assertEquals(user1.getId(), fetched.getId());
  }
  @Test
  public void getUsersBids_should_return_a_list_of_bids_corresponding_to_that_users_bids() {
    User bidsUser =
        new User(
            1,
            "Irrelevant",
            null,
            null,
            null,
            null); // only ID relevant and username has to be set due to JSONHandler.
    String json = jsonHandler.userToJSON(bidsUser);
    ArrayList<Bid> expectedBids = new ArrayList<Bid>();
    expectedBids.add(new Bid(1, 1, 1, 1337, bidsUser.getUsername()));
    expectedBids.add(new Bid(2, 2, 1, 42, bidsUser.getUsername()));
    dbHandler.populateUsersBidsResult(expectedBids);
    initProvider();

    ArrayList<ViewBid> viewBids = provider.getUsersBids(json);

    assertEquals(2, viewBids.size());
    assertEquals(2, viewBids.get(1).getItemno());
  }
  @Test
  public void
      verifyLogIn_should_return_a_user_with_matching_password_and_username_but_password_should_be_null() {
    User loginUser = new User(42, "User1", null, null, null, "123");
    ArrayList<User> expected = new ArrayList<User>();
    expected.add(loginUser);
    dbHandler.populateUserResult(expected);
    initProvider();
    String json = jsonHandler.userToJSON(loginUser);
    User user = provider.verifyLogIn(json);

    assertEquals("User1", user.getUsername());
    assertNull(user.getPassword());
  }