Package org.agoncal.application.petstore.domain

Examples of org.agoncal.application.petstore.domain.Product


        // Finds all the objects
        int initialNumber = catalogService.findAllProducts().size();

        // Creates an object
        Category category = new Category("Fish", "Any of numerous cold-blooded aquatic vertebrates characteristically having fins, gills, and a streamlined body");
        Product product = new Product("Angelfish", "Saltwater fish from Australia", category);

        // Persists the object
        product = catalogService.createProduct(product);
        Long id = product.getId();

        // Finds all the objects and checks there's an extra one
        assertEquals("Should have an extra object", initialNumber + 1, catalogService.findAllProducts().size());

        // Finds the object by primary key
        product = catalogService.findProduct(id);
        assertEquals("Angelfish", product.getName());

        // Updates the object
        product.setName("Big Angelfish");
        catalogService.updateProduct(product);

        // Finds the object by primary key
        product = catalogService.findProduct(id);
        assertEquals("Big Angelfish", product.getName());

        // Deletes the object
        catalogService.removeProduct(product);

        // Checks the object has been deleted
View Full Code Here


        // Finds all the objects
        int initialNumber = catalogService.findAllItems().size();

        // Creates an object
        Category category = new Category("Fish", "Any of numerous cold-blooded aquatic vertebrates characteristically having fins, gills, and a streamlined body");
        Product product = new Product("Angelfish", "Saltwater fish from Australia", category);
        Item item = new Item("Large", 10.00f, "fish1.jpg", product, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum velit ante, malesuada porta condimentum eget, tristique id magna. Donec ac justo velit. Suspendisse potenti. Donec vulputate vulputate molestie. Quisque vitae arcu massa, dictum sodales leo. Sed feugiat elit vitae ante auctor ultrices. Duis auctor consectetur arcu id faucibus. Curabitur gravida.");

        // Persists the object
        item = catalogService.createItem(item);
        Long id = item.getId();
View Full Code Here

    public Product findProduct(Long productId) {
        if (productId == null)
            throw new ValidationException("Invalid product id");

        Product product = em.find(Product.class, productId);
        if (product != null) {
            product.getItems(); // TODO check lazy loading
        }
        return product;
    }
View Full Code Here

    @POST
    @Path("/product")
    @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    public Response createProduct(JAXBElement<Product> xmlProduct) {
        Product product = catalogService.createProduct(xmlProduct.getValue());
        URI uri = uriInfo.getAbsolutePathBuilder().path(product.getId().toString()).build();
        return Response.created(uri).build();
    }
View Full Code Here

    @PUT
    @Path("/product")
    @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    public Response updateProduct(JAXBElement<Product> xmlProduct) {
        Product product = catalogService.updateProduct(xmlProduct.getValue());
        URI uri = uriInfo.getAbsolutePathBuilder().path(product.getId().toString()).build();
        return Response.ok(uri).build();
    }
View Full Code Here

TOP

Related Classes of org.agoncal.application.petstore.domain.Product

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.