/**
* Test of findByName method of class ExtraServiceDAO.
*/
@Test
public void testFindByName() {
ExtraService e1 = newExtraService("Tyre cleaning", "Proffesional tyre cleaning", BigDecimal.valueOf(325));
extraServiceDAO.create(e1);
ExtraService e2 = newExtraService("Tyre fixing", "Proffesional tyre fixing", BigDecimal.valueOf(490));
extraServiceDAO.create(e2);
String name;
try {
extraServiceDAO.findByName(null);
fail("String name is null");
} catch (DataAccessException e) {
// ok
} catch (Exception e) {
fail("String name is null - should have been thrown another exception");
}
name = "TyreCleaning";
List<ExtraService> extraServices = extraServiceDAO.findByName(name);
assertTrue("ExtraService is not in DB", extraServices.isEmpty());
name = "Tyre cleaning";
extraServices = extraServiceDAO.findByName(name);
assertEquals(e1.getId(), extraServices.get(0).getId());
assertDeepEquals(e1, extraServices.get(0));
ExtraService e3 = newExtraService("Tyre cleaning", "Proffesional tyre cleaning", BigDecimal.valueOf(260));
ExtraService e4 = newExtraService("Tyre cleaning", "Proffesional tyre cleaning", BigDecimal.valueOf(355));
extraServiceDAO.create(e3);
extraServiceDAO.create(e4);
List<ExtraService> extraServiceList = Arrays.asList(new ExtraService[]{e1, e2, e3, e4});