예제 #1
0
  /** Test method for {@link com.loiane.dao.ContactDAO#delete(int)}. */
  @Test
  public void testDelete() {

    contactDAO.delete(21);

    Contact expected = contactDAO.selectById(21);

    assertNull(expected);
  }
예제 #2
0
  /** Test method for {@link com.loiane.dao.ContactDAO#insert(com.loiane.model.Contact)}. */
  @Test
  public void testInsert() {

    Contact actual = new Contact();
    actual.setName("Loiane");
    actual.setPhone("(000) 111-1111");
    actual.setEmail("*****@*****.**");
    contactDAO.insert(actual);

    assertEquals(21, actual.getId());

    Contact expected = contactDAO.selectById(actual.getId()); // id = 21

    assertEquals(actual, expected);
    assertNotSame(actual, expected);
  }
예제 #3
0
  /** Test method for {@link com.loiane.dao.ContactDAO#update(com.loiane.model.Contact)}. */
  @Test
  public void testUpdate() {

    Contact actual =
        new Contact(3, "Contact2Updated", "(000) 111-1111", "*****@*****.**");

    Contact expected = contactDAO.selectById(3);
    expected.setEmail("*****@*****.**");
    expected.setName("Contact2Updated");
    expected.setPhone("(000) 111-1111");
    contactDAO.update(expected);
    expected = contactDAO.selectById(3);

    assertNotNull(expected);
    assertEquals(actual, expected);
    assertNotSame(actual, expected);
  }
예제 #4
0
  /** Test method for {@link com.loiane.dao.ContactDAO#selectById(int)}. */
  @Test
  public void testSelectById() {

    Contact actual = new Contact(2, "Contact1", "(000) 000-0000", "*****@*****.**");

    Contact expected = contactDAO.selectById(2);

    assertNotNull(expected);
    assertEquals(actual, expected);
    assertNotSame(actual, expected);
  }
예제 #5
0
 /** Test method for {@link com.loiane.dao.ContactDAO#selectAll()}. */
 @Test
 public void testSelectAll() {
   List<Contact> list = contactDAO.selectAll();
   assertNotNull(list);
   assertEquals(20, list.size());
 }