Examples of ExtraService


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

    /**
     * Test of get method of class ExtraServiceDAO.
     */
    @Test
    public void testGet() {
        ExtraService e = newExtraService(null, null, BigDecimal.ZERO);
        extraServiceDAO.create(e);
        Long id = null;
        try {
            extraServiceDAO.get(id);
            fail("Id null and didn't throw exception");
        } catch (DataAccessException ex) {
            //ok
        } catch (Exception ex) {
            fail("Id null and didn't throw appropriate exception");
        }
        ExtraService e2 = extraServiceDAO.get(e.getId());
        assertNotNull("ExtraService is null", e2);
        assertEquals("ExtraServices are not the same", e2, e);
        assertDeepEquals(e2, e);
        ExtraService e3 = extraServiceDAO.get(e.getId() + 1); // shouldn't exist
        assertNull("ExtraService is not null", e3);
        removeAll();
    }
View Full Code Here

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

        /**
     * Test of update method of class ExtraServiceDAO.
     */
    @Test
    public void testUpdate() {
        ExtraService e = newExtraService(null, null, BigDecimal.ZERO);
        extraServiceDAO.create(e);
        Long eId = e.getId();
        e.setId(null);
        //
        try {
            extraServiceDAO.update(null);
            fail("ExtraService is null and didn't throw exception");
        } catch (DataAccessException ex) {
            //ok
        } catch (Exception ex) {
            fail("ExtraService is null and didn't throw appropriate exception");
        }
        try {
            extraServiceDAO.update(e);
            fail("ExtraService is ID null and didn't throw exception");
        } catch (DataAccessException ex) {
            //ok
        } catch (Exception ex) {
            fail("ExtraService is ID null and didn't throw appropriate exception");
        }
        //
        e.setId(eId);
        extraServiceDAO.update(e);
        //
        ExtraService e2 = extraServiceDAO.get(e.getId());
        assertEquals("ExtraServices are not the same", e2, e);
        assertDeepEquals(e2, e);
    }
View Full Code Here

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

    /**
     * Test of remove method of class ExtraServiceDAO.
     */
    @Test
    public void testRemove() {
        ExtraService e = newExtraService(null, null, BigDecimal.TEN);
        extraServiceDAO.create(e);
        //
        try {
            extraServiceDAO.remove(null);
            fail("ExtraService is null and didn't throw exception");
        } catch (DataAccessException ex) {
            //ok
        } catch (Exception ex) {
            fail("ExtraService is null and didn't throw appropriate exception");
        }
        try {
            extraServiceDAO.remove(new ExtraService());
            fail("ExtraService ID is null and didn't throw exception");
        } catch (DataAccessException ex) {
            // ok
        } catch (Exception ex) {
            fail("ExtraService ID is null and didn't throw appropriate exception");
        }
        try {
            ExtraService es = new ExtraService();
            es.setId(-1L);
            extraServiceDAO.remove(es);
            fail("Shouldn't remove non-existent entity");
        } catch (DataAccessException ex) {
            //ok
        } catch (Exception ex) {
            fail("Non existent es (extra service) - should throw appropriate exception");
        }
        //
        extraServiceDAO.remove(e);
        ExtraService e2 = extraServiceDAO.get(e.getId());
        assertNull("Found extraService that shouldn't be there", e2);
        removeAll();
    }
View Full Code Here

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

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

        }
    }


    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

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

    @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

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

        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

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

       
        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

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

            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

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

        }
        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
TOP
Copyright © 2018 www.massapi.com. 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.