Package de.flexguse.demo.model

Examples of de.flexguse.demo.model.Author


  @Transactional
  @Test
  public void testSaveUserWithBooks() {

    // create the author of the books in the persistence
    Author author = createAuthor();
    authorRepository.save(author);

    /*
     * create 2 books. the books must be persisted before they are assigned
     * to a user.
View Full Code Here


   * This helper method creates a filled Author object.
   *
   * @return
   */
  protected Author createAuthor() {
    Author author = new Author();
    author.setFirstName("Simon");
    author.setLastName("Becket");
    author.seteMail("simon.becket@book.de");
    return author;
  }
View Full Code Here

    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);
   
View Full Code Here

  @Test
  public void testSaveAuthor() {

    prepareAuditingUser();

    Author author = createAuthor();

    // check no authors are persisted
    List<Author> existentAuthors = authorRepository.findAll();
    assertTrue(existentAuthors.isEmpty());

    authorRepository.save(author);
    existentAuthors = authorRepository.findAll();

    assertEquals("Simon Becket expected to be persisted", 1,
        existentAuthors.size());

    // check if auditing was done
    Author check = existentAuthors.get(0);
    assertNotNull("createdBy expected", check.getCreatedBy());
    assertNotNull("created date expected", check.getCreatedDate());
    assertEquals(author.geteMail(), check.geteMail());
  }
View Full Code Here

TOP

Related Classes of de.flexguse.demo.model.Author

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.