Package org.apache.torque.test.dbobject

Examples of org.apache.torque.test.dbobject.Book


     * Checks the valueEquals method outcome if all colums are not-null
     * and equal in the two objects.
     */
    public void testAllSetAndEqual()
    {
        Book book1 = new Book();
        book1.setAuthorId(1);
        book1.setBookId(5);
        book1.setIsbn("abc");
        book1.setTitle("title");
        Book book2 = new Book();
        book2.setAuthorId(1);
        book2.setBookId(5);
        book2.setIsbn("abc");
        book2.setTitle("title");
        assertTrue(book1.valueEquals(book2));
    }
View Full Code Here


     * Checks the valueEquals method outcome if all colums are not-null
     * and equal in the two objects except the primary key column.
     */
    public void testAllSetDifferentPk()
    {
        Book book1 = new Book();
        book1.setAuthorId(1);
        book1.setBookId(5);
        book1.setIsbn("abc");
        book1.setTitle("title");
        Book book2 = new Book();
        book2.setAuthorId(1);
        book2.setBookId(7);
        book2.setIsbn("abc");
        book2.setTitle("title");
        assertFalse(book1.valueEquals(book2));
    }
View Full Code Here

     * Checks the valueEquals method outcome if all colums are not-null
     * and equal in the two objects except a non-primary key column.
     */
    public void testAllSetDifferentNonPk()
    {
        Book book1 = new Book();
        book1.setAuthorId(1);
        book1.setBookId(5);
        book1.setIsbn("abc");
        book1.setTitle("title");
        Book book2 = new Book();
        book2.setAuthorId(1);
        book2.setBookId(5);
        book2.setIsbn("abc");
        book2.setTitle("otherTitle");
        assertFalse(book1.valueEquals(book2));
    }
View Full Code Here

     * Checks the valueEquals method outcome if all colums are not-null
     * and equal in the two objects except a non-primary-key foreign-key column.
     */
    public void testAllSetDifferentNonPkFk()
    {
        Book book1 = new Book();
        book1.setAuthorId(3);
        book1.setBookId(5);
        book1.setIsbn("abc");
        book1.setTitle("title");
        Book book2 = new Book();
        book2.setAuthorId(1);
        book2.setBookId(5);
        book2.setIsbn("abc");
        book2.setTitle("title");
        assertFalse(book1.valueEquals(book2));
    }
View Full Code Here

    public void testSameObjectRelations() throws Exception
    {
        Author author = new Author();
        author.setAuthorId(AUTHOR_1_ID);

        Book book = new Book();
        book.setBookId(BOOK_1_ID);

        author.addBook(book);
        book.setAuthor(author);

        // check one roundtrip from author
        assertTrue("author from book should be the same object as author",
                author == book.getAuthor());

        AuthorBean authorBean = author.getBean();
        BookBean bookBean = authorBean.getBookBeans().get(0);
        assertTrue("authorBean from BookBean should be the same "
                + "object as authorBean",
                bookBean.getAuthorBean() == authorBean);

        author = Author.createAuthor(authorBean);
        book = author.getBooks().get(0);

        assertTrue("author from book should be the same object as author "
                + "after creating from bean",
                author == book.getAuthor());

        // check one roundtrip from book
        assertTrue("book from author should be the same object as book",
                book == author.getBooks().get(0));

        bookBean = book.getBean();
        authorBean = bookBean.getAuthorBean();
        assertTrue("bookBean from authorBean should be the same "
                + "object as bookBean",
                authorBean.getBookBeans().get(0) == bookBean);

        book = Book.createBook(bookBean);
        author = book.getAuthor();

        assertTrue("book from author should be the same object as book "
                + "after creating from bean",
                author.getBooks().get(0) == book);
    }
View Full Code Here

     * Checks the valueEquals method outcome if a column is null
     * in the two objects and all other fields are set and equal.
     */
    public void testFieldNotSetBothNull()
    {
        Book book1 = new Book();
        book1.setAuthorId(1);
        book1.setBookId(5);
        book1.setIsbn(null);
        book1.setTitle("title");
        Book book2 = new Book();
        book2.setAuthorId(1);
        book2.setBookId(5);
        book2.setIsbn(null);
        book2.setTitle("title");
        assertTrue(book1.valueEquals(book2));
    }
View Full Code Here

        //         |            |                    |
        // author ----> book -----> differentAuthor ---> differentBook
        Author author = new Author();
        author.setAuthorId(AUTHOR_1_ID);

        Book book = new Book();
        book.setBookId(BOOK_1_ID);

        Author differentAuthor = new Author();
        author.setAuthorId(AUTHOR_1_ID);

        author.addBook(book);
        book.setAuthor(differentAuthor);

        Book differentBook = new Book();
        book.setBookId(BOOK_1_ID);

        differentAuthor.addBook(differentBook);

        // check one roundtrip from author
View Full Code Here

     * Checks the valueEquals method outcome if a column is null
     * in only one the two objects and all other fields are set and equal.
     */
    public void testFieldNotSetOneNull()
    {
        Book book1 = new Book();
        book1.setAuthorId(1);
        book1.setBookId(5);
        book1.setIsbn(null);
        book1.setTitle("title");
        Book book2 = new Book();
        book2.setAuthorId(1);
        book2.setBookId(5);
        book2.setIsbn("abc");
        book2.setTitle("Title");
        assertFalse(book1.valueEquals(book2));
    }
View Full Code Here

        BookBean bookBean = new BookBean();
        bookBean.setTitle(BOOK_1_TITLE);
        bookBean.setIsbn(BOOK_1_ISBN);

        Book book = Book.createBook(bookBean);
        assertTrue("isModified() should return true after creation of object "
                + " from new bean",
                book.isModified());
        assertTrue("isNew() should return true after creation of object "
                + " from new bean",
                book.isNew());
        book.setAuthor(author);
        book.save();

        List<Book> bookList = BookPeer.doSelect(new Criteria());
        assertTrue("Ther should be one book in DB but there are "
                + bookList.size(),
                bookList.size() == 1);
View Full Code Here

            assertTrue("authorId should not be 0 after insert",
                    author.getAuthorId() != 0);

            for (int j = 1; j <= 10; j++)
            {
                Book book = new Book();
                author.addBook(book);
                book.setTitle("Book " + j + " - Author " + i);
                if (j < 10)
                {
                    book.setIsbn("ISBN " + j + " - " + i);
                }
                else
                {
                   book.setIsbn(null);
                }
                book.save();
            }
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of org.apache.torque.test.dbobject.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.