use of org.talend.types.test.library.common._1.SearchFor 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));
}
use of org.talend.types.test.library.common._1.SearchFor 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));
}
use of org.talend.types.test.library.common._1.SearchFor 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");
}
}
use of org.talend.types.test.library.common._1.SearchFor in project tesb-rt-se by Talend.
the class LibraryServerImpl method seekBook.
@Override
public ListOfBooks seekBook(SearchFor body) throws SeekBookError {
System.out.println("***************************************************************");
System.out.println("*** seekBook request (Request-Response operation) is received *");
System.out.println("***************************************************************");
showSeekBookRequest(body);
List<String> authorsLastNames = body.getAuthorLastName();
if (authorsLastNames != null && authorsLastNames.size() > 0) {
String authorsLastName = authorsLastNames.get(0);
if (authorsLastName != null && authorsLastName.length() > 0 && (!"Icebear".equalsIgnoreCase(authorsLastName)) && (!"Morillo".equalsIgnoreCase(authorsLastName))) {
SeekBookError e = prepareException("No book available from author " + authorsLastName);
System.out.println("No book available from author " + authorsLastName);
System.out.println("\nSending business fault (SeekBook error) with parameters:");
Utils.showSeekBookError(e);
throw e;
}
}
ListOfBooks result = new ListOfBooks();
if (authorsLastNames.contains("Icebear")) {
BookType book = new BookType();
result.getBook().add(book);
PersonType author = new PersonType();
book.getAuthor().add(author);
author.setFirstName("Jack");
author.setLastName("Icebear");
Calendar dateOfBirth = new GregorianCalendar(101, Calendar.JANUARY, 2);
author.setDateOfBirth(dateOfBirth.getTime());
book.getTitle().add("Survival in the Arctic");
book.getPublisher().add("Frosty Edition");
book.setYearPublished("2010");
}
if (authorsLastNames.contains("Morillo")) {
BookType book = new BookType();
result.getBook().add(book);
PersonType author = new PersonType();
book.getAuthor().add(author);
author.setFirstName("David A.");
author.setLastName("Morillo");
Calendar dateOfBirth = new GregorianCalendar(1970, Calendar.JANUARY, 1);
author.setDateOfBirth(dateOfBirth.getTime());
book.getTitle().add("The book about software");
book.getPublisher().add("Frosty Edition");
book.setYearPublished("2006");
}
System.out.println("Book(s) is found:");
showSeekBookResponse(result);
return result;
}
Aggregations