Package org.apache.torque.test.dbobject

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


    {
        Criteria criteria = new Criteria().where(
                AuthorPeer.AUTHOR_ID,
                authorList.get(0).getAuthorId());

        Author author = AuthorPeer.doSelectSingleRecord(criteria);
        assertEquals("Expected author with Id "
                + authorList.get(0).getAuthorId()
                + " but got "
                + author.getAuthorId(),
                authorList.get(0).getAuthorId(),
                author.getAuthorId());
    }
View Full Code Here


        Criteria criteria = new Criteria().where(
                AuthorPeer.AUTHOR_ID,
                authorList.get(0).getAuthorId());

        Connection connection = Torque.getConnection();
        Author author = AuthorPeer.doSelectSingleRecord(criteria, connection);
        Torque.closeConnection(connection);
        assertEquals("Expected author with Id "
                + authorList.get(0).getAuthorId()
                + " but got "
                + author.getAuthorId(),
                authorList.get(0).getAuthorId(),
                author.getAuthorId());
    }
View Full Code Here

     *
     * @throws Exception if the test fails
     */
    public void testSelectSingleRecordWithObject() throws Exception
    {
       Author author = AuthorPeer.doSelectSingleRecord(authorList.get(0));
        assertEquals("Expected author with Id "
                + authorList.get(0).getAuthorId()
                + " but got "
                + author.getAuthorId(),
                authorList.get(0).getAuthorId(),
                author.getAuthorId());
    }
View Full Code Here

    {
        cleanBookstore();
        AuthorManager.getManager().setRegion("om_Author");
        BookManager.getManager().setRegion("om_Book");

        Author author1 = new Author();
        author1.setName("author1");
        author1.save();
        Author author2 = new Author();
        author2.setName("author2");
        author2.save();

        Author myauthor = AuthorManager.getCachedInstance(author1.getPrimaryKey());
        assertNotNull("Primary key of Author1 should not be null", author1.getPrimaryKey());
        assertNotNull("MyAuthor should not be null", myauthor);
        assertTrue("Author1 and MyAuthor should point to the same cache instance", author1 == myauthor);

        Book book = new Book();
View Full Code Here

        // insert some data into the database
        // taken from tutorial step 4 with some changes
        try
        {
            Author bloch = new Author();
            bloch.setName(AUTHOR_1_NAME);
            bloch.save();

            Author stevens = new Author();
            stevens.setName(AUTHOR_2_NAME);
            AuthorPeer.doInsert(stevens);

            Author withoutBook = new Author();
            withoutBook.setName(AUTHOR_3_NAME);
            AuthorPeer.doInsert(withoutBook);

            Book effective = new Book();
            effective.setTitle(BOOK_1_TITLE);
            effective.setIsbn(BOOK_1_ISBN);
View Full Code Here

                    Criteria.INNER_JOIN);

            bookAuthors = AuthorPeer.doSelect(criteria);

            // from Details section
            Author author = bookAuthors.get(0);
            List<Book> books = author.getBooks();
        }
        catch (Exception e)
        {
            e.printStackTrace();
            fail("inner join : Exception caught : "
View Full Code Here

        assertTrue(
            "size of bookAuthors is not 2, but"
            + bookAuthors.size(),
            bookAuthors.size() == 2);

        Author author = bookAuthors.get(0);
        assertTrue(
            "Author of first book is not "
            + AUTHOR_1_NAME
            + " but "
            + author.getName(),
            AUTHOR_1_NAME.equals(author.getName()));

        author = bookAuthors.get(1);
        assertTrue(
            "Author of second book is not "
            + AUTHOR_2_NAME
            + " but "
            + author.getName(),
            AUTHOR_2_NAME.equals(author.getName()));
    }
View Full Code Here

    public void testInsert() throws Exception
    {
        // prepare
        cleanBookstore();
        List<Author> bookstoreContent = insertBookstoreData();
        Author author = new Author();
        author.setName("Author");

        // execute
        author.save();

        // verify
        assertNotNull(author.getAuthorId());
        assertEquals("Author", author.getName());

        bookstoreContent.add(author);
        verifyBookstore(bookstoreContent);
    }
View Full Code Here

    public void testUpdate() throws Exception
    {
        // prepare
        cleanBookstore();
        List<Author> bookstoreContent = insertBookstoreData();
        Author author = new Author();
        author.setName("Author");
        author.save();
        author.setName("nameModified"); // modify after saving

        // execute
        author.save();

        // verify
        assertNotNull(author.getAuthorId());
        assertEquals("nameModified", author.getName());
        bookstoreContent.add(author);
        verifyBookstore(bookstoreContent);
    }
View Full Code Here

    public void testInsertPropagationDown() throws Exception
    {
        // prepare
        cleanBookstore();
        List<Author> bookstoreContent = insertBookstoreData();
        Author author = new Author();
        author.setName("Author");
        Book book = new Book();
        author.addBook(book);
        book.setTitle("Book title");
        book.setIsbn("ISBN");

        // execute
        author.save();

        // verify
        assertNotNull(author.getAuthorId());
        assertEquals("Author", author.getName());
        assertNotNull(book.getBookId());
        assertEquals("Book title", book.getTitle());
        assertEquals("ISBN", book.getIsbn());

        bookstoreContent.add(author);
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.