コード例 #1
0
 @Test
 public void getUser() {
   User user1 = registrationMgr.registerUser("xxx5@yyy5");
   User userGet = registrationMgr.getUser("xxx5@yyy5");
   assertSame(userGet, user1);
   assertNull(registrationMgr.getUser("aaa4@bb5"));
   registrationMgr.registerUser("abc");
   assertNull(registrationMgr.getUser("abc"));
 }
コード例 #2
0
 @Test
 public void registerUser() {
   User user1 = registrationMgr.registerUser("xxx1@yyy");
   assertTrue(user1.getEmail().equals("xxx1@yyy"));
   User user2 = registrationMgr.registerUser("xxx2@yyy2");
   assertTrue(user2.getEmail().equals("xxx2@yyy2"));
   User user2bis = registrationMgr.registerUser("xxx2@yyy2");
   assertSame(user2bis, user2);
   // geen @ in het adres
   assertNull(registrationMgr.registerUser("abc"));
 }
コード例 #3
0
  @Test
  public void getUsers() {
    List<User> users = registrationMgr.getUsers();
    assertEquals(0, users.size());

    em.getTransaction().begin();
    User user1 = registrationMgr.registerUser("xxx8@yyy");
    em.getTransaction().commit();
    users = registrationMgr.getUsers();
    assertEquals(1, users.size());
    assertSame(users.get(0), user1);

    em.getTransaction().begin();
    User user2 = registrationMgr.registerUser("xxx9@yyy");
    em.getTransaction().commit();
    users = registrationMgr.getUsers();
    assertEquals(2, users.size());

    em.getTransaction().begin();
    registrationMgr.registerUser("abc");
    em.getTransaction().commit();
    // geen nieuwe user toegevoegd, dus gedrag hetzelfde als hiervoor
    users = registrationMgr.getUsers();
    assertEquals(2, users.size());
  }