Package com.example.bookstore.domain

Examples of com.example.bookstore.domain.Book


  public List<Book> initializeSelectableBooks(OrderForm orderForm) {
    return bookstoreService.findBooksByCategory(orderForm.getCategory());
  }

  public void addBook(OrderForm orderForm) {
    Book book = orderForm.getBook();
    if (orderForm.getBooks().containsKey(book)) {
      orderForm.getBooks().put(book, orderForm.getBooks().get(book) + orderForm.getQuantity());
    } else {
      orderForm.getBooks().put(book, orderForm.getQuantity());
    }
View Full Code Here


  }

  @Test
  public void testFindById() {
    entityManager.flush();
    Book book = bookRepository.findById(this.book.getId());
    assertEquals(this.book.getAuthor(), book.getAuthor());
    assertEquals(this.book.getDescription(), book.getDescription());
    assertEquals(this.book.getIsbn(), book.getIsbn());
  }
View Full Code Here

  }

  @Test
  @Rollback(true)
  public void testStoreBook() {
    Book book = new BookBuilder() {
      {
        description("Something");
        author("JohnDoe");
        title("John Doe's life");
        isbn("1234567890123");
        category(category);
      }
    }.build();

    bookRepository.storeBook(book);

    // Explicitly flush so any CUD query that is left behind is send to the database before rolling back
    entityManager.flush();
   
    Book book1 = bookRepository.findById(book.getId());
   
    assertEquals(book1.getAuthor(), book.getAuthor());
    assertEquals(book1.getDescription(), book.getDescription());
    assertEquals(book1.getIsbn(), book.getIsbn());
  }
View Full Code Here

     * @param model the implicit model
     * @return view name to render (book/detail)
     */
    @RequestMapping(value = "/public/book/detail/{bookId}")
    public String details(@PathVariable("bookId") long bookId, Model model) {
        Book book = this.bookstoreService.findBook(bookId);
        model.addAttribute(book);
        return "book/detail";
    }
View Full Code Here

    BookBuilder bookBuilder = new BookBuilder();
    bookBuilder.title(manageBookForm.getTitle()).description(manageBookForm.getDescription())
        .price(manageBookForm.getPrice().toString()).author(manageBookForm.getAuthor())
        .year(manageBookForm.getYear()).category(manageBookForm.getCategory());

    Book book = bookBuilder.build(true);

    bookstoreService.addBook(book);
    manageBookForm.clear();
    mov.addObject("actionSuccess", "book");
View Full Code Here

    @Autowired
    private BookstoreService bookstoreService;

    @RequestMapping("/add/{bookId}")
    public String addToCart(@PathVariable("bookId") long bookId, @RequestHeader("referer") String referer) {
        Book book = this.bookstoreService.findBook(bookId);
        this.cart.addBook(book);
        this.logger.info("Cart: {}", this.cart);
        return "redirect:" + referer;
    }
View Full Code Here

     * @param model the implicit model
     * @return view name to render (book/detail)
     */
    @RequestMapping(value = "/book/detail/{bookId}")
    public String details(@PathVariable("bookId") long bookId, Model model) {
        Book book = this.bookstoreService.findBook(bookId);
        model.addAttribute(book);
        return "book/detail";
    }
View Full Code Here

  private Book product;

  @Override
  void initProduct() {
    product = new Book();
  }
View Full Code Here

                }

                // Create different books
                List<Order> orders = new ArrayList<Order>();
                {
                    final Book effectiveJava = new BookBuilder() {
                        {
                            title("Effective Java");
                            isbn("9780321356680");
                            description("Brings together seventy-eight indispensable programmer's rules of thumb.");
                            author("Joshua Bloch");
                            year(2008);
                            price("31.20");
                            category(InitialDataSetup.this.category);
                        }
                    }.build();

                    final Book refactoring = new BookBuilder() {
                        {
                            title("Refactoring: Improving the Design of Existing Code");
                            isbn("9780201485677");
                            description("Refactoring is about improving the design of existing code. It is the process of "
                                    + "changing a software system in such a way that it does not alter the external beha"
                                    + "vior of the code, yet improves its internal structure.");
                            author("Martin Fowler");
                            year(1999);
                            price("41.39");
                            category(InitialDataSetup.this.category);
                        }
                    }.build();

                    final Book cleanCode = new BookBuilder() {
                        {
                            title("Clean Code: A Handbook of Agile Software Craftsmanship");
                            isbn("9780132350884");
                            description("Even bad code can function. But if code isn't clean, it can bring a development organization "
                                    + "to its knees. Every year, countless hours and significant resources are lost because of poorly "
                                    + "written code. But it doesn't have to be that way.");
                            author("Robert C. Martin");
                            year(2008);
                            price("33.32");
                            category(InitialDataSetup.this.category);
                        }
                    }.build();

                    final Book agileSoftware = new BookBuilder() {
                        {
                            title("Agile Software Development, Principles, Patterns, and Practices");
                            isbn("9780135974445");
                            description("A unique collection of the latest software development methods. Includes OOD, UML, Design Patterns, Agile and XP methods with a "
                                    + "detailed description of a complete software design for reusable programs in C++ and Java.");
                            author("Robert C. Martin");
                            year(2002);
                            price("54.61");
                            category(InitialDataSetup.this.category);
                        }
                    }.build();

                    final Book practicalApiDesign = new BookBuilder() {
                        {
                            title("Practical API Design: Confessions of a Java Framework Architect");
                            isbn("9781430209737");
                            description("The definitive guide to API design, this book will be required reading for all "
                                    + "designers and engineers involved with the development, testing, and maintenance of APIs.");
View Full Code Here

TOP

Related Classes of com.example.bookstore.domain.Book

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.