Search in sources :

Example 31 with ListOfBooks

use of org.talend.types.test.library.common._1.ListOfBooks in project tesb-rt-se by Talend.

the class TransformationAssertionTest method commonTest.

private void commonTest(String testName, String searchFor, String expectedResult) {
    final String dir = testName;
    serviceContext = startParticipants(dir);
    Library client = (Library) serviceContext.getBean("libraryHttp");
    ListOfBooks response = null;
    try {
        response = searchFor(searchFor, client);
    } catch (SeekBookError e) {
        fail("Exception during service call");
    }
    assertEquals("Books amount in response differs from 1", 1, booksInResponse(response));
    assertEquals("Received unexpected author name", expectedResult, authorLastName(response));
}
Also used : SeekBookError(org.talend.services.test.library._1_0.SeekBookError) Library(org.talend.services.test.library._1_0.Library) ListOfBooks(org.talend.types.test.library.common._1.ListOfBooks)

Example 32 with ListOfBooks

use of org.talend.types.test.library.common._1.ListOfBooks in project tesb-rt-se by Talend.

the class TransformationFeatureTest method commonTest.

private void commonTest(String testName, String searchFor, String expectedResult) {
    final String dir = testName;
    serviceContext = startProvider(dir);
    Library client = (Library) serviceContext.getBean("libraryHttp");
    ListOfBooks response = null;
    try {
        response = searchFor(searchFor, client);
    } catch (SeekBookError e) {
        fail("Exception during service call");
    }
    assertEquals("Books amount in response differs from 1", 1, booksInResponse(response));
    assertEquals("Received unexpected author name", expectedResult, authorLastName(response));
}
Also used : SeekBookError(org.talend.services.test.library._1_0.SeekBookError) Library(org.talend.services.test.library._1_0.Library) ListOfBooks(org.talend.types.test.library.common._1.ListOfBooks)

Example 33 with ListOfBooks

use of org.talend.types.test.library.common._1.ListOfBooks in project tesb-rt-se by Talend.

the class LibraryTester method testRequestResponsePositive.

public void testRequestResponsePositive() throws SeekBookError {
    // Test the positive case where author(s) are found and we retrieve
    // a list of books
    System.out.println("***************************************************************");
    System.out.println("*** Request-Response operation ********************************");
    System.out.println("***************************************************************");
    System.out.println("\nSending request for authors named Icebear");
    SearchFor request = new SearchFor();
    request.getAuthorLastName().add("Icebear");
    ListOfBooks response = libraryHttp.seekBook(request);
    System.out.println("\nResponse received:");
    if (response.getBook().size() != 1) {
        System.out.println("An error occured: number of books found is not equal to 1");
    }
    if (!"Icebear".equals(response.getBook().get(0).getAuthor().get(0).getLastName())) {
        System.out.println("An error occured: the author of the found book is not Icebear");
    }
}
Also used : SearchFor(org.talend.types.test.library.common._1.SearchFor) ListOfBooks(org.talend.types.test.library.common._1.ListOfBooks)

Example 34 with ListOfBooks

use of org.talend.types.test.library.common._1.ListOfBooks in project tesb-rt-se by Talend.

the class LibraryNotificationReceiverImpl method showNewBooks.

private void showNewBooks(final Date listDate, final List<BookType> response) {
    System.out.println("New books from " + DateFormat.getDateInstance().format(listDate));
    final ListOfBooks books = new ListOfBooks();
    books.getBook().addAll(response);
    Utils.showBooks(books);
}
Also used : ListOfBooks(org.talend.types.demos.library.common._1.ListOfBooks)

Example 35 with ListOfBooks

use of org.talend.types.test.library.common._1.ListOfBooks in project tesb-rt-se by Talend.

the class Utils method showBooks.

/**
 * Show books.
 *
 * @param booksList the books list
 */
public static void showBooks(final ListOfBooks booksList) {
    if (booksList != null && booksList.getBook() != null && !booksList.getBook().isEmpty()) {
        List<BookType> books = booksList.getBook();
        System.out.println("\nNumber of books: " + books.size());
        int cnt = 0;
        for (BookType book : books) {
            System.out.println("\nBookNum: " + (cnt++ + 1));
            List<PersonType> authors = book.getAuthor();
            if (authors != null && !authors.isEmpty()) {
                for (PersonType author : authors) {
                    System.out.println("Author:  " + author.getFirstName() + " " + author.getLastName());
                }
            }
            System.out.println("Title:   " + book.getTitle());
            System.out.println("Year:    " + book.getYearPublished());
            if (book.getISBN() != null) {
                System.out.println("ISBN:    " + book.getISBN());
            }
        }
    } else {
        System.out.println("List of books is empty");
    }
    System.out.println("");
}
Also used : BookType(org.talend.types.demos.library.common._1.BookType) PersonType(org.talend.types.demos.library.common._1.PersonType)

Aggregations

ListOfBooks (org.talend.types.test.library.common._1.ListOfBooks)21 SearchFor (org.talend.types.test.library.common._1.SearchFor)18 SeekBookError (org.talend.services.test.library._1_0.SeekBookError)16 Calendar (java.util.Calendar)7 GregorianCalendar (java.util.GregorianCalendar)7 Library (org.talend.services.test.library._1_0.Library)6 ListOfBooks (org.talend.types.demos.library.common._1.ListOfBooks)6 BookType (org.talend.types.test.library.common._1.BookType)5 PersonType (org.talend.types.test.library.common._1.PersonType)5 SeekBookError (org.talend.services.demos.library._1_0.SeekBookError)3 BookType (org.talend.types.demos.library.common._1.BookType)3 PersonType (org.talend.types.demos.library.common._1.PersonType)3 SearchFor (org.talend.types.demos.library.common._1.SearchFor)3 HashMap (java.util.HashMap)1 BindingProvider (javax.xml.ws.BindingProvider)1 CallContext (org.talend.esb.mep.requestcallback.feature.CallContext)1 CallContextStore (org.talend.esb.mep.requestcallback.impl.callcontext.CallContextStore)1 LibraryConsumer (org.talend.services.demos.library._1_0.LibraryConsumer)1