Package cz.muni.fi.pa165.stis.entity

Examples of cz.muni.fi.pa165.stis.entity.ExtraService


    /**
     * 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});

View Full Code Here


        }
    }


    private static ExtraService newExtraService(String name, String desc, BigDecimal price) {
        ExtraService es = new ExtraService();
        es.setName(name);
        es.setDescription(desc);
        es.setPrice(price);

        return es;
    }
View Full Code Here

    @Before
    public void setUp() {
        customer = newCustomer("Jozin", "Zbazin", "Baziny 22", "005544");
        customerDAO.create(customer);
        //
        ExtraService es1 = newExtraService("Umytie", "Umytie okien a zrkadiel", BigDecimal.valueOf(22.2));
        extraServiceDAO.create(es1);
        ExtraService es2 = newExtraService("Vysavanie", "Vysavanie auta", BigDecimal.valueOf(122.5));
        extraServiceDAO.create(es2);
        extraServices = new HashSet<ExtraService>(Arrays.asList(new ExtraService[]{es1, es2}));
        //
        Tyre t1 = newTyre(17D, "MM22", "EZ256", "Michellin", BigDecimal.valueOf(222));
        tyreDAO.create(t1);
View Full Code Here

        assertEquals("Orders are not the same", o3, o);
        assertDeepEquals(o3, o);
        //
        // test extra services remove and add
        o.getExtraServices().remove(o.getExtraServices().iterator().next());
        ExtraService es = newExtraService("Baking pastery", "You wouldn't drive hungry!", BigDecimal.ZERO);
        extraServiceDAO.create(es);
        o.getExtraServices().add(es);
        dao.update(o);
        //
        Order o4 = dao.get(o.getId());
View Full Code Here

       
        return t;
    }
   
    private static ExtraService newExtraService(String name, String desc, BigDecimal price) {
        ExtraService es = new ExtraService();
        es.setName(name);
        es.setDescription(desc);
        es.setPrice(price);
       
        return es;
    }
View Full Code Here

            throw new IllegalArgumentException("extraService is null");
        }
        if (extraService.getId() == null) {
            throw new IllegalArgumentException("extraService.id is null");
        }
        ExtraService toRemove = entityManager.find(ExtraService.class, extraService.getId());
        if (toRemove == null) {
            throw new IllegalArgumentException("given extraService doesn't exist");
        }
        entityManager.remove(toRemove);
    }
View Full Code Here

        }
        if (extraService.getId() != null) {
            throw new IllegalArgumentException("extraService.id is not null");
        }
       
        ExtraService es = mapper.map(extraService, ExtraService.class);
        extraServiceDAO.create(es);
        extraService.setId(es.getId());
    }
View Full Code Here

    public ExtraServiceTO get(Long id) {
        if (id == null) {
            throw new IllegalArgumentException("id is null");
        }
       
        ExtraService es = extraServiceDAO.get(id);
        if (es == null) {
            return null;
        }
       
        return mapper.map(es, ExtraServiceTO.class);
View Full Code Here

        }
        if (extraService.getId() == null) {
            throw new IllegalArgumentException("extraService.id is null");
        }
       
        ExtraService es = mapper.map(extraService, ExtraService.class);
        extraServiceDAO.update(es);
    }
View Full Code Here

        }
        if (extraService.getId() == null) {
            throw new IllegalArgumentException("extraService.id is null");
        }
       
        ExtraService es = mapper.map(extraService, ExtraService.class);
        extraServiceDAO.remove(es);
    }
View Full Code Here

TOP

Related Classes of cz.muni.fi.pa165.stis.entity.ExtraService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.