Package org.agoncal.application.petstore.domain

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


        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();

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

        // Finds the object by primary key
        item = catalogService.findItem(id);
        assertEquals("Large", item.getName());

        // Updates the object
        item.setName("Large fish");
        catalogService.updateItem(item);

        // Finds the object by primary key
        item = catalogService.findItem(id);
        assertEquals("Large fish", item.getName());

        // Deletes the object
        catalogService.removeItem(item);

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


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

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

TOP

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

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.