Package br.com.caelum.tubaina

Examples of br.com.caelum.tubaina.Book


      Scanner scanner = new Scanner(reader);
      scanner.useDelimiter("$$");
      if (scanner.hasNext())
        chapters.addAll(parse(scanner.next()));
    }
    return new Book(name, chapters, showNotes);
  }
View Full Code Here


        + "texto da prim seção\n" + "[section Segunda seção]\n" + "texto da segunda seção\n\n";

    builder.addReaderFromString(content);
    builder.addReaderFromString("[chapter Introdução]\n" + "Algum texto de introdução\n");

    Book book = builder.build();
    module.inject(book);
    Assert.assertEquals("livro", book.getName());

    List<Chapter> chapters = book.getChapters();

    Assert.assertEquals(2, chapters.size());
    List<Section> sections1 = chapters.get(0).getSections();

    Assert.assertEquals("O que é java?", chapters.get(0).getTitle());
View Full Code Here

  }

  private List<Chapter> getChapters(final String content) {
    builder.addReaderFromString(content);
    Book b = builder.build();
    module.inject(b);
    List<Chapter> chapters = b.getChapters();
    return chapters;
  }
View Full Code Here

  @Test
  public void testBookWithMultipleParts() throws Exception {
    String content = "[part \"parte um\"]\n" + "[chapter capitulo um]\n" + "introducao do capitulo um\n"
        + "[section secao um]\n" + "conteudo da secao um";
    builder.addReaderFromString(content);
    Book b = builder.build();
    module.inject(b);
    BookPart bookPart = b.getParts().get(0);
    Chapter chapter = bookPart.getChapters().get(0);
    assertEquals("capitulo um", chapter.getTitle());
    assertEquals("secao um", chapter.getSections().get(0).getTitle());

    assertEquals("parte um", bookPart.getTitle());
View Full Code Here

  public void testBookWithChapterOutsideParts() throws Exception {
    String chapter0 = "[chapter capitulo zero]";
    String chapter1 = "[part \"parte um\"]\n" + "[chapter capitulo um]\n" + "introducao do capitulo um\n"
        + "[section secao um]\n" + "conteudo da secao um";
    builder.addReaderFromStrings(Arrays.asList(chapter0, chapter1));
    Book b = builder.build();
    module.inject(b);
    BookPart bookPart = b.getParts().get(1);
    Chapter chapter = bookPart.getChapters().get(0);
    assertEquals("capitulo um", chapter.getTitle());
    assertEquals("secao um", chapter.getSections().get(0).getTitle());

    assertEquals("parte um", bookPart.getTitle());
    assertEquals(true, bookPart.isPrintable());

    assertEquals(false, b.getParts().get(0).isPrintable());
  }
View Full Code Here

    List<String> chapters = Arrays.asList(chapter);
    List<String> introductionChapters = Arrays.asList(preface, about);
    builder.addReaderFromStrings(chapters);
    builder.addAllReadersOfNonNumberedFromStrings(introductionChapters);

    Book book = builder.build();
    module.inject(book);
    assertEquals(2, book.getIntroductionChapters().size());
    assertEquals("preface", book.getIntroductionChapters().get(0).getTitle());
    assertEquals("about", book.getIntroductionChapters().get(1).getTitle());
  }
View Full Code Here

  @Test
  public void testBookWithPartsWithIllustrations() throws Exception {
    String content = "[part \"parte um\" illustration=resources/image.png]\n" + "[chapter capitulo um]\n"
        + "introducao do capitulo um\n" + "[section secao um]\n" + "conteudo da secao um";
    builder.addReaderFromString(content);
    Book b = builder.build();
    module.inject(b);
    BookPart bookPart = b.getParts().get(0);
    Chapter chapter = bookPart.getChapters().get(0);
    assertEquals("capitulo um", chapter.getTitle());
    assertEquals("secao um", chapter.getSections().get(0).getTitle());

    assertEquals("parte um", bookPart.getTitle());
View Full Code Here

  @Test
  public void testBookWithChapterWithLabel() throws Exception {
    String content = "[chapter capitulo um label=\"label of this chapter\"]\n" + "introducao do capitulo um\n"
        + "[section secao um]\n" + "conteudo da secao um";
    builder.addReaderFromString(content);
    Book b = builder.build();
    module.inject(b);
    BookPart bookPart = b.getParts().get(0);
    Chapter chapter = bookPart.getChapters().get(0);
    assertEquals("capitulo um", chapter.getTitle());
    assertEquals("label of this chapter", chapter.getLabel());
  }
View Full Code Here

  @Test
  public void testGeneratorWithCorrectImages() throws IOException {
    BookBuilder builder = builder("Com imagens");
    builder.addReaderFromString("[chapter qualquer um]\n" + "[img baseJpgImage.jpg]");
    Book b = builder.build();
    new LatexModule().inject(b);

    generator.generate(b, temp);

    File[] images = temp.listFiles(new FilenameFilter() {
View Full Code Here

  @Test
  public void testGeneratorWithDoubledImage() throws TubainaException, IOException {
    BookBuilder builder = builder("Com imagens");
    builder.addReaderFromString("[chapter qualquer um]\n" + "[img baseJpgImage.jpg]\n[img baseJpgImage.jpg]");

    Book b = builder.build();
    new LatexModule().inject(b);
    try {
      generator.generate(b, temp);
    } catch (TubainaException t) {
      Assert.fail("Should not raise an exception");
View Full Code Here

TOP

Related Classes of br.com.caelum.tubaina.Book

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.