Package org.apache.torque.test.dbobject

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


    public void testGetRelatedObjectsWithCriteriaAfterInit() throws Exception
    {
        Criteria criteria = new Criteria().where(
                AuthorPeer.AUTHOR_ID,
                authorList.get(0).getAuthorId());
        Author author = AuthorPeer.doSelect(criteria).get(0);
        author.initBooks();
        Book book = authorList.get(0).getBooks().get(2);

        // execute : load books
        criteria = new Criteria().where(BookPeer.BOOK_ID, book.getBookId());
        List<Book> books = author.getBooks(criteria);

        // verify
        assertEquals(1, books.size());
        assertEquals(book.getBookId(), books.get(0).getBookId());
    }
View Full Code Here


    @Override
    public void setUp() throws Exception
    {
        super.setUp();
        cleanBookstore();
        author1 = new Author();
        author1.setName("author1");
        author1.save();
        author2 = new Author();
        author2.setName("author2");
        author2.save();
        author2b = new Author();
        author2b.setName("author2");
        author2b.save();
        author3 = new Author();
        author3.setName("author3");
        author3.save();
        book1 = new Book();
        book1.setTitle("Book from author 1");
        book1.setAuthor(author1);
View Full Code Here

        List<?> result = AuthorPeer.doSelect(criteria);
        assertEquals("Expected result of size 2 but got " + result.size(),
                result.size(),
                3);
        Author author = (Author) result.get(0);
        assertEquals("Expected author with Id "
                + author2b.getAuthorId()
                + " at first position but got "
                + author.getAuthorId(),
                author2b.getAuthorId(),
                author.getAuthorId());
        author = (Author) result.get(1);
        assertEquals("Expected author with Id "
                + author2.getAuthorId()
                + " at second position but got "
                + author.getAuthorId(),
                author2.getAuthorId(),
                author.getAuthorId());
        author = (Author) result.get(2);
        assertEquals("Expected author with Id "
                + author1.getAuthorId()
                + " at second position but got "
                + author.getAuthorId(),
                author1.getAuthorId(),
                author.getAuthorId());
    }
View Full Code Here

        List<?> result = AuthorPeer.doSelect(criteria);
        assertEquals("Expected result of size 1 but got " + result.size(),
                1,
                result.size());
        Author author = (Author) result.get(0);
        assertEquals("Expected author with Id "
                + author1.getAuthorId()
                + " at first position but got "
                + author.getAuthorId(),
                author1.getAuthorId(),
                author.getAuthorId());
    }
View Full Code Here

        List<Author> result = AuthorPeer.doSelect(criteria);
        assertEquals("Expected result of size 1 but got " + result.size(),
                result.size(),
                1);
        Author author = result.get(0);
        assertEquals("Expected author with Id "
                + author1.getAuthorId()
                + " but got "
                + author.getAuthorId(),
                author1.getAuthorId(),
                author.getAuthorId());
    }
View Full Code Here

        List<Author> result = AuthorPeer.doSelect(criteria);
        assertEquals("Expected result of size 2 but got " + result.size(),
                result.size(),
                3);
        Author author = result.get(0);
        assertEquals("Expected author with Id "
                + author1.getAuthorId()
                + " but got "
                + author.getAuthorId(),
                author1.getAuthorId(),
                author.getAuthorId());
        author = result.get(1);
        assertEquals("Expected author with Id "
                + author2.getAuthorId()
                + " but got "
                + author.getAuthorId(),
                author2.getAuthorId(),
                author.getAuthorId());
        author = result.get(2);
        assertEquals("Expected author with Id "
                + author2b.getAuthorId()
                + " but got "
                + author.getAuthorId(),
                author2b.getAuthorId(),
                author.getAuthorId());
    }
View Full Code Here

        List<?> result = AuthorPeer.doSelect(criteria);
        assertEquals("Expected result of size 1 but got " + result.size(),
                1,
                result.size());
        Author author = (Author) result.get(0);
        assertEquals("Expected author with Id "
                + author3.getAuthorId()
                + " but got "
                + author.getAuthorId(),
                author3.getAuthorId(),
                author.getAuthorId());
    }
View Full Code Here

    {
        Criteria criteria = new Criteria().where(
                AuthorPeer.AUTHOR_ID,
                -1);

        Author author = AuthorPeer.doSelectSingleRecord(criteria);
        assertEquals(null, author);
    }
View Full Code Here

        List<Author> result = AuthorPeer.doSelect(criteria);
        assertEquals("Expected result of size 2 but got " + result.size(),
                2,
                result.size());
        Author author = result.get(0);
        assertEquals("Expected author with Id "
                + authorList.get(1).getAuthorId()
                + " at first position but got "
                + author.getAuthorId(),
                authorList.get(1).getAuthorId(),
                author.getAuthorId());
        author = result.get(1);
        assertEquals("Expected author with Id "
                + authorList.get(0).getAuthorId()
                + " at second position but got "
                + author.getAuthorId(),
                authorList.get(0).getAuthorId(),
                author.getAuthorId());
    }
View Full Code Here

        List<Author> result = AuthorPeer.doSelect(criteria);
        assertEquals("Expected result of size 2 but got " + result.size(),
                2,
                result.size());
        Author author = result.get(0);
        assertEquals("Expected author with Id "
                + authorList.get(1).getAuthorId()
                + " at first position but got "
                + author.getAuthorId(),
                authorList.get(1).getAuthorId(),
                author.getAuthorId());
        author = result.get(1);
        assertEquals("Expected author with Id "
                + authorList.get(0).getAuthorId()
                + " at second position but got "
                + author.getAuthorId(),
                authorList.get(0).getAuthorId(),
                author.getAuthorId());
    }
View Full Code Here

TOP

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