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

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


        verify(dao).update(es);
    }
   
    @Test
    public void testGet() {
        ExtraService es = newService("Window cleaning", "Thorough window and mirror cleaning", BigDecimal.valueOf(22.2));
        es.setId(2L);
        ExtraServiceTO esto = mapper.map(es, ExtraServiceTO.class);
        //
        when(dao.get(2L)).thenReturn(es);
        ExtraServiceTO estoNew = service.get(2L);
        //
View Full Code Here


        assertEquals(estoNew, esto);
    }

    @Test
    public void testRemove() {
        ExtraService es = newService("Window cleaning", "Thorough window and mirror cleaning", BigDecimal.valueOf(22.2));
        es.setId(2L);
        ExtraServiceTO esto = mapper.map(es, ExtraServiceTO.class);
        //
        service.remove(esto);
        verify(dao).remove(es);
    }
View Full Code Here

        verify(dao).remove(es);
    }

    @Test
    public void testFindAll() {
        ExtraService es1 = newService("1", "2", BigDecimal.ZERO);
        es1.setId(2L);
        ExtraService es2 = newService("3", "5", BigDecimal.ONE);
        es2.setId(3L);
        List<ExtraService> extraServices = Arrays.asList(new ExtraService[]{es1, es2});
        List<ExtraServiceTO> esTOs = Arrays.asList(new ExtraServiceTO[]{
            mapper.map(es1, ExtraServiceTO.class),
            mapper.map(es2, ExtraServiceTO.class)
        });
View Full Code Here

        assertTrue(ess.containsAll(esTOs) && esTOs.containsAll(ess));
    }

    @Test
    public void testFindByName() {
        ExtraService es1 = newService("as1", "2", BigDecimal.ZERO);
        es1.setId(2L);
        ExtraService es2 = newService("as1", "5", BigDecimal.ONE);
        es2.setId(3L);
        List<ExtraService> extraServices = Arrays.asList(new ExtraService[]{es1, es2});
        List<ExtraServiceTO> esTOs = Arrays.asList(new ExtraServiceTO[]{
            mapper.map(es1, ExtraServiceTO.class),
            mapper.map(es2, ExtraServiceTO.class)
        });
View Full Code Here

        //
        assertTrue(ess.containsAll(esTOs) && esTOs.containsAll(ess));
    }
   
    private static ExtraService newService(String name, String description, BigDecimal price) {
        ExtraService es = new ExtraService();
        es.setName(name);
        es.setDescription(description);
        es.setPrice(price);
       
        return es;
    }
View Full Code Here

        ReflectionTestUtils.setField(orderService, "mapper", mapper);
       
        customer = newCustomer("Jozin", "Zbazin", "Baziny 22", "005544");
        customer.setId(1L);
        //
        ExtraService es1 = newExtraService("Umytie", "Umytie okien a zrkadiel", BigDecimal.valueOf(22.2));
        es1.setId(1L);
        ExtraService es2 = newExtraService("Vysavanie", "Vysavanie auta", BigDecimal.valueOf(122.5));
        es2.setId(2L);
        extraServices = new HashSet<ExtraService>(Arrays.asList(new ExtraService[]{es1, es2}));
        //
        Tyre t1 = newTyre(17D, "MM22", "EZ256", "Michellin", BigDecimal.valueOf(222));
        t1.setId(1L);
        Tyre t2 = newTyre(17D, "MM23", "EZ257", "Michellin", BigDecimal.valueOf(222));
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

    /**
     * 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

        /**
     * 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

    /**
     * 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

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.