139140141142143144145146147148149
book.setAuthorId(1); // does not exist // execute & verify try { book.save(); fail("Exception expected"); } catch (ConstraintViolationException e) { assertTrue(e.getCause() instanceof SQLException);
495496497498499500501502503504505
author.save(); Book book = new Book(); book.setAuthor(author); book.setTitle("Book 1"); book.setIsbn("unknown"); book.save(); author = new Author(); author.setName("Author without book"); author.save();
510511512513514515516517518519520
{ book = new Book(); book.setAuthor(author); book.setTitle("Book " + bookNr); book.setIsbn("unknown"); book.save(); } } /**
5859606162636465666768
Book book = new Book(); book.setAuthor(author1); book.setTitle("Book 1"); book.setIsbn("unknown"); book.save(); Book mybook = BookManager.getInstance(book.getPrimaryKey()); assertTrue("Author1 and the author of MyBook should point to the same cache instance", author1 == mybook.getAuthor()); }