assertEquals("Correct telephoneNumber is not return", readers[i].getTelephoneNumber(), result.getTelephoneNumber());
}
}
public void testUpdateReader() {
Reader reader = addReader();
persist(reader);
reader.setFirstName(null);
try {
readerDAO.updateReader(reader);
fail("FirstName is null, NullPointerException has not been thrown");
} catch (IllegalArgumentException ex) {
//OK
}
reader.setFirstName("");
try {
readerDAO.updateReader(reader);
fail("FirstName is empty, IllegalArgumentException has not been thrown");
} catch (IllegalArgumentException ex) {
//OK
}
reader.setSurname(null);
try {
readerDAO.updateReader(reader);
fail("Surname is null, NullPointerException has not been thrown");
} catch (IllegalArgumentException ex) {
//OK
}
reader.setSurname("");
try {
readerDAO.updateReader(reader);
fail("Surname is empty, IllegalArgumentException has not been thrown");
} catch (IllegalArgumentException ex) {
//OK
}
reader.setBirthNumber(null);
try {
readerDAO.updateReader(reader);
fail("Birth number is null, NullPointerException has not been thrown");
} catch (IllegalArgumentException ex) {
//OK
}
reader.setBirthNumber("");
try {
readerDAO.updateReader(reader);
fail("Birth number is empty, IllegalArgumentException has not been thrown");
} catch (IllegalArgumentException ex) {
//OK
}
reader.setAddress(null);
try {
readerDAO.updateReader(reader);
fail("Address is null, NullPointerException has not been thrown");
} catch (IllegalArgumentException ex) {
//OK
}
reader.setAddress("");
try {
readerDAO.updateReader(reader);
fail("Address is empty, IllegalArgumentException has not been thrown");
} catch (IllegalArgumentException ex) {
//OK
}
reader.setEmail(null);
try {
readerDAO.updateReader(reader);
fail("Email is null, NullPointerException has not been thrown");
} catch (IllegalArgumentException ex) {
//OK
}
reader.setEmail("");
try {
readerDAO.updateReader(reader);
fail("Email is empty, IllegalArgumentException has not been thrown");
} catch (IllegalArgumentException ex) {
//OK
}
reader.setFirstName("Marie");
reader.setSurname("Nová");
reader.setAddress("8859182456");
reader.setBirthNumber("Praha 5");
reader.setEmail("adresa@gmail.com");
reader.setTelephoneNumber("+234455743");
readerDAO.updateReader(reader);
Reader reader2 = readerDAO.findReaderById(reader.getId());
assertEquals("Readers are not equals", reader2, reader);
assertEquals("Correct ID is not return", reader2.getId(), reader.getId());
assertEquals("Correct first name is not return",reader2.getFirstName(), reader.getFirstName());
assertEquals("Correct surname is not return", reader2.getSurname(), reader.getSurname());
assertEquals("Correct birthNumber is not return", reader2.getBirthNumber(), reader.getBirthNumber());
assertEquals("Correct address is not return", reader2.getAddress(), reader.getAddress());
assertEquals("Correct email is not return", reader2.getEmail(), reader.getEmail());
assertEquals("Correct telephoneNumber is not return", reader2.getTelephoneNumber(), reader.getTelephoneNumber());
}