Package br.com.caelum.tubaina.builder

Examples of br.com.caelum.tubaina.builder.BookBuilder


        Assert.assertFalse(index.exists());
    }

    @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 HtmlModule().inject(b);

        generator.generate(b, temp);
        File images = new File(temp, "com-imagens/qualquer-um/");
        Assert.assertTrue(images.exists());
View Full Code Here


        Assert.assertTrue(copied.exists());
    }
   
    @Test
    public void testGeneratorWithImagesInIndex() throws IOException {
      BookBuilder builder = builder("com-imagens");
        builder.addAllReadersOfNonNumberedFromStrings(Arrays.asList("[chapter qualquer um]\n"
                + "[img baseJpgImage.jpg]"));
        Book b = builder.build();
        new HtmlModule().inject(b);

        generator.generate(b, temp);
        File images = new File(temp, "com-imagens/");
        Assert.assertTrue(images.exists());
View Full Code Here

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

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

    @Test
    public void testGeneratorWithUnexistantImage() throws TubainaException, IOException {
        String chapterContent = "[chapter qualquer um]\n"
                + "[img src/test/resources/someImage.gif]";
        BookBuilder builder = builder("com-erro");
        builder.addReaderFromString(chapterContent);
        try {
            Book b = builder.build();
            new HtmlModule().inject(b);
            generator.generate(b, temp);
            Assert.fail("Should raise an exception");
        } catch (TubainaException t) {
            // OK
View Full Code Here

    @Test
    public void testGeneratorWithDuppedChapterName() throws TubainaException, IOException {
        String fileContent = "[chapter qualquer um]\n"
                + "alguma coisa\n[chapter qualquer um]outra coisa";
        BookBuilder builder = builder("com-erro");
        builder.addReaderFromString(fileContent);
        try {
            Book b = builder.build();
            new HtmlModule().inject(b);
            generator.generate(b, temp);
            Assert.fail("Should raise an exception");
        } catch (TubainaException t) {
            System.out.println(t.getMessage());
View Full Code Here

        File introduction = new File(livro, "introduction");
        Assert.assertFalse(introduction.exists());
    }
   
    public BookBuilder builder(String title) {
      return new BookBuilder(title, new SectionsManager());
    }
View Full Code Here

    assertTrue("should contain directory with chosen book name", bookRoot.exists());
    assertTrue("should contain includes directory", includes.exists());
  }

  private Book createsSimpleBookWithTitle(String title) {
    BookBuilder builder = new BookBuilder(title, new SectionsManager());

    String fileContent = "[chapter     O que é java?   ]\n" + "texto da seção\n" + "[section Primeira seção]\n"
        + "texto da prim seção\n" + "[section Segunda seção]\n" + "texto da segunda seção\n\n";
    builder.addReaderFromString(fileContent);

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

    return builder.build();
  }
View Full Code Here

    assertTrue("should create the index.html containing the whole book", theBookItself.exists());
  }

  @Test
  public void shouldCreateADirectoryForEachChapterThatContainsImages() throws Exception {
    BookBuilder builder = builder("Com Imagens");
    builder.addReaderFromString("[chapter Um capítulo]\n" + "Uma introdução com imagem: \n\n"
        + "[img baseJpgImage.jpg]");
    builder.addReaderFromString("[chapter Outro capítulo]\n" + "Uma introdução com imagem: \n\n"
        + "[img basePngImage.png]");
    Book imageBook = builder.build();
    new HtmlModule().inject(imageBook);

    generator.generate(imageBook, directory);

    File bookRoot = new File(directory, "com-imagens/");
View Full Code Here

    assertTrue(secondChapter.exists());
    assertTrue(secondChaptersImage.exists());
  }

  private BookBuilder builder(String title) {
    return new BookBuilder(title, new SectionsManager());
  }
View Full Code Here

    return new BookBuilder(title, new SectionsManager());
  }

  @Test
  public void shouldNotCreateADirectoryChapterThatDoesntContainAnyImages() throws Exception {
    BookBuilder builder = builder("Com Imagens");
    builder.addReaderFromString("[chapter Um capítulo]\n" + "Uma introdução com imagem:\n");
    builder.addReaderFromString("[chapter Outro capítulo]\n" + "Uma introdução com imagem: \n\n"
        + "[img basePngImage.png]");
    Book imageBook = builder.build();
    new HtmlModule().inject(imageBook);

    generator.generate(imageBook, directory);

    File bookRoot = new File(directory, "com-imagens/");
View Full Code Here

TOP

Related Classes of br.com.caelum.tubaina.builder.BookBuilder

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.