Package de.flexguse.demo.model

Examples of de.flexguse.demo.model.Book


    /*
     * create 2 books. the books must be persisted before they are assigned
     * to a user.
     */
    // create the first book
    Book book1 = new Book();
    book1.setAuthor(author);
    book1.setDescription("This is the first book");
    book1.setIsbnNumber("1");
    book1.setTitle("Book 1");
    bookRepository.save(book1);
   
    Book book2 = new Book();
    book2.setAuthor(author);
    book2.setDescription("This is the second book");
    book2.setIsbnNumber("2");
    book2.setTitle("Book 2");
    bookRepository.save(book2);
   
    /*
     * create and persist a user which has both books as borrowed books
     */
 
View Full Code Here


  @Rollback(true)
  @Transactional
  @Test
  public void testSaveBook() {

    Book book = new Book();

    book.setIsbnNumber("1234567890");
    book.setDescription("This is a wonderfil book.");
    book.setTitle("The Art of living");

    // the author must be existend in the persistence when it is assigned to
    // the book -> CascadingType
    Author author = createAuthor();
    authorRepository.save(author);
    book.setAuthor(author);
   
    bookRepository.save(book);
   
    // check a book was persisted
    List<Book> availableBooks = bookRepository.findAll();
    assertEquals(1, availableBooks.size());
   
    // check if the author is available
    Book check = availableBooks.get(0);
    assertEquals(author, check.getAuthor());
  }
View Full Code Here

TOP

Related Classes of de.flexguse.demo.model.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.