Search in sources :

Example 6 with Format

use of org.talend.esb.examples.ebook.model.Format 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());
}
Also used : Format(org.talend.esb.examples.ebook.model.Format) Book(org.talend.esb.examples.ebook.model.Book) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 7 with Format

use of org.talend.esb.examples.ebook.model.Format in project tesb-rt-se by Talend.

the class AbstractJPAItest method createBook.

protected Book createBook(String title) {
    Book book = new Book();
    book.setId("myid" + UUID.randomUUID());
    book.setTitle(title);
    book.setCreator("Me");
    try {
        Format format = new Format();
        format.setFile(new URI("file:/test"));
        book.getFormats().add(format);
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }
    return book;
}
Also used : Format(org.talend.esb.examples.ebook.model.Format) Book(org.talend.esb.examples.ebook.model.Book) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

Format (org.talend.esb.examples.ebook.model.Format)7 Book (org.talend.esb.examples.ebook.model.Book)5 URI (java.net.URI)3 URISyntaxException (java.net.URISyntaxException)2 Test (org.junit.Test)2 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Coordination (org.osgi.service.coordinator.Coordination)1 Document (org.w3c.dom.Document)1 NodeList (org.w3c.dom.NodeList)1