use of org.talend.esb.examples.ebook.model.Book in project tesb-rt-se by Talend.
the class ImportRouteTest method testImport.
@Test
public void testImport() throws Exception {
final Book book = createBook("My title");
sendMessage("books.in", book);
Book book2 = tryTo("get book", new Callable<Book>() {
public Book call() throws Exception {
return bookRepo.getBook(book.getId());
}
});
Assert.assertEquals(book.getId(), book2.getId());
Assert.assertEquals(book.getTitle(), book2.getTitle());
bookRepo.delete(book.getId());
}
use of org.talend.esb.examples.ebook.model.Book in project tesb-rt-se by Talend.
the class ImportRouteTest method testImportError.
@Test(expected = TimeoutException.class)
public void testImportError() throws Exception {
final Book book = createBook("error1");
sendMessage("books.in", book);
tryTo("get book", new Callable<Book>() {
public Book call() throws Exception {
return bookRepo.getBook(book.getId());
}
}, 10000);
}
use of org.talend.esb.examples.ebook.model.Book in project tesb-rt-se by Talend.
the class BookService method getBook.
@GET
@Path("{id}")
public Response getBook(@PathParam("id") String id) {
System.out.println(id);
Book book = bookRepo.getBook(id);
return book == null ? Response.status(Status.NOT_FOUND).build() : Response.ok(book).build();
}
use of org.talend.esb.examples.ebook.model.Book in project tesb-rt-se by Talend.
the class BookService method getBooks.
@GET
public Collection<Book> getBooks() {
List<Book> outBooks = new ArrayList<>();
for (Book book : bookRepo.getBooks()) {
Book outBook = new Book();
outBook.setId(book.getId());
outBook.setTitle(book.getTitle());
outBook.setCreator(book.getCreator());
outBooks.add(outBook);
}
return outBooks;
}
use of org.talend.esb.examples.ebook.model.Book in project tesb-rt-se by Talend.
the class ParseTest method testParse.
@Test
public void testParse() throws Exception {
Document doc = readDocument("pg50180.rdf");
BookParser parser = new BookParser();
Book book = parser.parse(doc);
Assert.assertEquals("Maugham, W. Somerset (William Somerset) - Penelope\nA Comedy in Three Acts", book.toString());
Assert.assertEquals("ebooks/50180", book.getId());
Assert.assertEquals("Penelope\nA Comedy in Three Acts", book.getTitle());
Assert.assertEquals("Maugham, W. Somerset (William Somerset)", book.getCreator());
// Assert.assertEquals(4, book.getSubjects().size());
// Assert.assertEquals("Justice -- Early works to 1800", book.getSubjects().get(0).getSubject());
Assert.assertEquals("http://www.gutenberg.org/cache/epub/50180/pg50180.cover.medium.jpg", book.getCover().toString());
Assert.assertEquals(11, book.getFormats().size());
Format format = book.getFormats().get(0);
Assert.assertEquals("http://www.gutenberg.org/ebooks/50180.kindle.images", format.getFile().toString());
Assert.assertEquals("application/x-mobipocket-ebook", format.getMediaType().toString());
}
Aggregations