Beispiel #1
0
 @Test
 public void testFind() throws Exception {
   User foundUser = h2User.find(user.getId());
   assertEquals(email, foundUser.getEmail());
   assertEquals(password, foundUser.getPassword());
   assertEquals(type, foundUser.getType());
 }
Beispiel #2
0
 @Test
 public void testUpdate() throws Exception {
   user.setEmail("*****@*****.**");
   user.setPassword("changedPassword");
   user.setType(UserType.STUDENT);
   assertTrue(h2User.update(user));
 }
Beispiel #3
0
  @Test
  public void testGetAll() throws Exception {
    int userCount = 10;
    User[] users = new User[userCount];
    for (int i = 0; i < users.length; i++) {
      users[i] = h2User.create(email, password, type);
    }

    List<User> all = h2User.getAll();
    assertNotNull(all);
    assertEquals(userCount + 1, all.size());

    for (int i = 0; i < userCount; i++) {
      assertEquals(email, users[i].getEmail());
      assertEquals(password, users[i].getPassword());
      assertEquals(type, users[i].getType());
    }

    for (User user : users) {
      h2User.delete(user.getId());
    }
  }
Beispiel #4
0
 @Test
 public void testDelete() throws Exception {
   assertTrue(h2User.delete(user.getId()));
 }
Beispiel #5
0
 @Before
 public void setUp() throws Exception {
   user = h2User.create(email, password, type);
 }
Beispiel #6
0
 @After
 public void tearDown() throws Exception {
   h2User.delete(user.getId());
 }