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

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


        verify(dao).remove(tyre);       
    }
   
    @Test
    public void testFindAll() {
        Tyre tyre1 = createTyre(19D, "P Zero", "235/40ZR19", "Pirelli", BigDecimal.valueOf(420));
        tyre1.setId(2L);
       
        Tyre tyre2 = createTyre(19D, "Potenza RE050A", " 235/40R19", "Bridgestone", BigDecimal.valueOf(324));
        tyre2.setId(3L);
       
        List<Tyre> tyres = Arrays.asList(new Tyre[]{tyre1, tyre2});
        List<TyreTO> tyreTOList = Arrays.asList(new TyreTO[]{
            mapper.map(tyre1, TyreTO.class),
            mapper.map(tyre2, TyreTO.class)
View Full Code Here


        assertTrue(tyreTOServiceList.containsAll(tyreTOList) && tyreTOList.containsAll(tyreTOServiceList));
    }
   
    @Test
    public void testFindByName() {
        Tyre tyre1 = createTyre(19D, "P Zero", "235/40ZR19", "Pirelli", BigDecimal.valueOf(450));
        Tyre tyre2 = createTyre(20D, "P Zero", "240/50R20", "Goodyear", BigDecimal.valueOf(480));
        tyre1.setId(2L);
        tyre2.setId(3L);
       
        List<Tyre> tyres = Arrays.asList(new Tyre[]{tyre1, tyre2});
        List<TyreTO> tyreTOList = Arrays.asList(new TyreTO[]{
            mapper.map(tyre1, TyreTO.class),
            mapper.map(tyre2, TyreTO.class)
View Full Code Here

       
        assertTrue(tyreTOServiceList.containsAll(tyreTOList) && tyreTOList.containsAll(tyreTOServiceList));
    }
   
    private static Tyre createTyre(Double diameter, String name, String type, String vendor, BigDecimal price) {
        Tyre t = new Tyre();
        t.setDiameter(diameter);
        t.setName(name);
        t.setType(type);
        t.setVendor(vendor);
        t.setPrice(price);
        return t;
    }
View Full Code Here

        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));
        t2.setId(2L);
        Tyre t3 = newTyre(18D, "PR89", "NT99", "Pirelli", BigDecimal.valueOf(253.4));
        t3.setId(3L);
        tyres = new EnumMap<TyrePosition, Tyre>(TyrePosition.class);
        tyres.put(TyrePosition.FRONT_LEFT, t1);
        tyres.put(TyrePosition.FRONT_RIGHT, t2);
        tyres.put(TyrePosition.REAR_LEFT, t3);
        order = newOrder(customer, newDate("22.9.2012 12:13:15"), null, null, extraServices, tyres, BigDecimal.ZERO);
View Full Code Here

                }
                if (no.getTyres().size() != o.getTyres().size()) {
                    return false;
                }
                for (Map.Entry<TyrePosition, Tyre> me : no.getTyres().entrySet()) {
                    Tyre t = o.getTyres().get(me.getKey());
                    if (!Objects.equals(t, me.getValue())) {
                        return false;
                    }
                }
               
View Full Code Here

       
        assertTrue(res.containsAll(otos) && otos.containsAll(res));
    }
   
    private static Tyre newTyre(Double diameter, String name, String type, String vendor, BigDecimal price) {
        Tyre t = new Tyre();
        t.setDiameter(diameter);
        t.setName(name);
        t.setType(type);
        t.setVendor(vendor);
        t.setPrice(price);
       
        return t;
    }
View Full Code Here

    /**
     * Test of get method, of class TyreDAO.
     */
    @Test
    public void testGet() {
        Tyre t1 = createTyre(17D, "MM22", "EZ256", "Michellin", BigDecimal.valueOf(222));
        tyreDAO.create(t1);
        Long id = null;

        try {
            tyreDAO.get(id);
            fail("Getting tyre with null id");
        } catch (DataAccessException e) {
            // ok
        } catch (Exception e) {
            fail("Incorrect exception has been thrown while getting tyre by null id.");
        }

        Tyre t2 = tyreDAO.get(t1.getId());
        assertNotNull("Tyre is null", t2);
        assertEquals("Tyres are not equal", t1, t2);
        assertDeepEquals(t1, t2);

        Tyre t3 = tyreDAO.get(t2.getId() + 1);
        assertNull("Tyre should not exists", t3);
    }
View Full Code Here

        }

        tyre.setId(tyreOldId);
        tyre.setPrice(BigDecimal.valueOf(440));
        tyreDAO.update(tyre);
        Tyre tyre2 = tyreDAO.get(tyre.getId());
        assertEquals("Tyres should be same.", tyre, tyre2);
        assertDeepEquals(tyre, tyre2);
    }
View Full Code Here

        }

        tyre.setId(tOldId);
        tyreDAO.create(tyre);
        tyreDAO.remove(tyre);
        Tyre tyre2 = tyreDAO.get(tyre.getId());
        assertNull(tyre2);
    }
View Full Code Here

     * Test of findByName method, of class TyreDAO.
     */
    @Test
    public void testFindByName() {
        System.out.println("findByName");
        Tyre t1 = createTyre(19D, "P Zero", "235/40ZR19", "Pirelli", BigDecimal.valueOf(410));
        tyreDAO.create(t1);
        Tyre t2 = createTyre(17D, "MM22", "EZ256", "Michellin", BigDecimal.valueOf(222));
        tyreDAO.create(t2);
        String name;

        try {
            tyreDAO.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 = "PZero";
        List<Tyre> tyres = tyreDAO.findByName(name);
        assertTrue("Tyre is not in DB", tyres.isEmpty());

        name = "P Zero";
        tyres = tyreDAO.findByName(name);
        assertEquals(t1.getId(), tyres.get(0).getId());
        assertDeepEquals(t1, tyres.get(0));

        Tyre t3 = createTyre(19D, "P Zero", "235/40ZR19", "Pirelli", BigDecimal.valueOf(450));
        Tyre t4 = createTyre(20D, "P Zero", "240/50R20", "Goodyear", BigDecimal.valueOf(480));
        tyreDAO.create(t3);
        tyreDAO.create(t4);

        List<Tyre> tyreList = Arrays.asList(new Tyre[]{t1, t2, t3, t4});

View Full Code Here

TOP

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

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.