Package org.apache.type_substitution

Examples of org.apache.type_substitution.Porsche


         * It shows a doc wrapper style operation.
        */

        List<Car> cars = dealer.getSedans("porsche");
        assertEquals(2, cars.size());
        Porsche car = (Porsche) cars.get(0);
        assertNotNull(car);
        if (car != null && "Porsche".equals(car.getMake())
            && "Boxster".equals(car.getModel())
            && "1998".equals(car.getYear())
            && "white".equals(car.getColor())) {
            // get the right car
        } else {
            fail("Get the wrong car!");
        }
       
        /**
         * CarDealer.tradeIn(Car) takes an abstract class Car and returns the same.
         * We will send a sub-class instead and expect to get the same.
         *
         */
        Porsche oldCar = new Porsche();
        oldCar.setMake("Porsche");
        oldCar.setColor("white");
        oldCar.setModel("GT2000");
        oldCar.setYear("2000");
        Porsche newCar = (Porsche)dealer.tradeIn(oldCar);
        assertNotNull(newCar);

        if (newCar != null && "Porsche".equals(newCar.getMake())
            && "911GT3".equals(newCar.getModel())
            && "2007".equals(newCar.getYear())
            && "black".equals(newCar.getColor())) {
            // get the right car
        } else {
            fail("Get the wrong car!");
        }
    }
View Full Code Here


    public Car tradeIn(Car oldCar) {
        if (!(oldCar instanceof Porsche)) {
            throw new WebServiceException("Expected Porsche, received, " + oldCar.getClass().getName());
        }

        Porsche porsche = (Porsche)oldCar;
        if (porsche.getMake().equals("Porsche") && porsche.getModel().equals("GT2000")
            && porsche.getYear().equals("2000") && porsche.getColor().equals("white")) {
            return newPorsche("911GT3", "2007", "black");
        }
        throw new WebServiceException("Invalid Porsche Car");
    }
View Full Code Here

        }
        throw new WebServiceException("Invalid Porsche Car");
    }

    private Porsche newPorsche(String model, String year, String color) {
        Porsche porsche = new Porsche();
        porsche.setMake("Porsche");
        porsche.setModel(model);
        porsche.setYear(year);
        porsche.setColor(color);
        return porsche;
    }
View Full Code Here

         * It shows a doc wrapper style operation.
        */

        List<Car> cars = dealer.getSedans("porsche");
        assertEquals(2, cars.size());
        Porsche car = (Porsche) cars.get(0);
        assertNotNull(car);
        if (car != null && "Porsche".equals(car.getMake())
            && "Boxster".equals(car.getModel())
            && "1998".equals(car.getYear())
            && "white".equals(car.getColor())) {
            // get the right car
        } else {
            fail("Get the wrong car!");
        }
       
        /**
         * CarDealer.tradeIn(Car) takes an abstract class Car and returns the same.
         * We will send a sub-class instead and expect to get the same.
         *
         */
        Porsche oldCar = new Porsche();
        oldCar.setMake("Porsche");
        oldCar.setColor("white");
        oldCar.setModel("GT2000");
        oldCar.setYear("2000");
        Porsche newCar = (Porsche)dealer.tradeIn(oldCar);
        assertNotNull(newCar);

        if (newCar != null && "Porsche".equals(newCar.getMake())
            && "911GT3".equals(newCar.getModel())
            && "2007".equals(newCar.getYear())
            && "black".equals(newCar.getColor())) {
            // get the right car
        } else {
            fail("Get the wrong car!");
        }
    }
View Full Code Here

         * It shows a doc wrapper style operation.
        */

        List<Car> cars = dealer.getSedans("porsche");
        assertEquals(2, cars.size());
        Porsche car = (Porsche) cars.get(0);
        assertNotNull(car);
        if (car != null && "Porsche".equals(car.getMake())
            && "Boxster".equals(car.getModel())
            && "1998".equals(car.getYear())
            && "white".equals(car.getColor())) {
            // get the right car
        } else {
            fail("Get the wrong car!");
        }
       
        /**
         * CarDealer.tradeIn(Car) takes an abstract class Car and returns the same.
         * We will send a sub-class instead and expect to get the same.
         *
         */
        Porsche oldCar = new Porsche();
        oldCar.setMake("Porsche");
        oldCar.setColor("white");
        oldCar.setModel("GT2000");
        oldCar.setYear("2000");
        Porsche newCar = (Porsche)dealer.tradeIn(oldCar);
        assertNotNull(newCar);

        if (newCar != null && "Porsche".equals(newCar.getMake())
            && "911GT3".equals(newCar.getModel())
            && "2007".equals(newCar.getYear())
            && "black".equals(newCar.getColor())) {
            // get the right car
        } else {
            fail("Get the wrong car!");
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.type_substitution.Porsche

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.