Search in sources :

Example 6 with DocumentModel

use of org.apache.maven.doxia.document.DocumentModel in project maven-plugins by apache.

the class DocumentModelBuilderTest method testGetDocumentModel.

/**
     * Test of getDocumentModel method, of class DocumentModelBuilder.
     */
public void testGetDocumentModel() {
    DocumentModel model = new DocumentModelBuilder(new ModelBuilderMavenProjectStub()).getDocumentModel();
    assertEquals("ISO-8859-1", model.getModelEncoding());
    assertEquals("Test ArtifactId", model.getOutputName());
    DocumentCover cover = model.getCover();
    assertEquals("Test Version", cover.getCoverVersion());
    assertEquals("Test Name", cover.getProjectName());
    assertEquals("Test Name", cover.getCoverTitle());
    assertEquals("v. Test Version", cover.getCoverSubTitle());
    assertEquals("Test Organization", cover.getCompanyName());
    assertEquals(2, cover.getAuthors().size());
    assertFirstDocumentAuthor(cover.getAuthors().get(0));
    DocumentMeta meta = model.getMeta();
    assertEquals("Test Description", meta.getDescription());
    assertEquals(2, meta.getAuthors().size());
    assertFirstDocumentAuthor(meta.getAuthors().get(0));
    assertEquals("Test Name", meta.getSubject());
    assertEquals("Test Name", meta.getTitle());
    DocumentTOC toc = model.getToc();
    assertEquals(0, toc.getItems().size());
}
Also used : DocumentTOC(org.apache.maven.doxia.document.DocumentTOC) DocumentCover(org.apache.maven.doxia.document.DocumentCover) DocumentMeta(org.apache.maven.doxia.document.DocumentMeta) ModelBuilderMavenProjectStub(org.apache.maven.plugins.pdf.stubs.ModelBuilderMavenProjectStub) DocumentModel(org.apache.maven.doxia.document.DocumentModel)

Example 7 with DocumentModel

use of org.apache.maven.doxia.document.DocumentModel in project maven-plugins by apache.

the class DocumentModelBuilderTest method testEmptyDocumentModel.

/**
     * Test of getDocumentModel method, of class DocumentModelBuilder.
     */
public void testEmptyDocumentModel() {
    DocumentModel model = new DocumentModelBuilder(null).getDocumentModel();
    assertNotNull(model);
    assertNull(model.getModelEncoding());
    assertEquals("unnamed", model.getOutputName());
    assertNotNull(model.getCover());
    assertNotNull(model.getMeta());
    assertNotNull(model.getToc());
}
Also used : DocumentModel(org.apache.maven.doxia.document.DocumentModel)

Example 8 with DocumentModel

use of org.apache.maven.doxia.document.DocumentModel in project maven-plugins by apache.

the class DocumentModelBuilder method getDocumentModel.

// ----------------------------------------------------------------------
// Private methods
// ----------------------------------------------------------------------
/**
     * Extract a DocumentModel from a MavenProject.
     *
     * @param project a MavenProject. May be null.
     * @param decorationModel a DecorationModel. May be null.
     * @param date the date of the TOC. May be null in which case the build date will be used.
     *
     * @return a DocumentModel. Always non-null.
     */
private static DocumentModel getDocumentModel(MavenProject project, DecorationModel decorationModel, Date date) {
    final Date now = (date == null ? new Date() : date);
    final DocumentModel docModel = new DocumentModel();
    docModel.setModelEncoding(getProjectModelEncoding(project));
    docModel.setOutputName(project == null || project.getArtifactId() == null ? "unnamed" : project.getArtifactId());
    docModel.setMeta(getDocumentMeta(project, now));
    docModel.setCover(getDocumentCover(project, now));
    docModel.setToc(getDocumentTOC(decorationModel));
    return docModel;
}
Also used : Date(java.util.Date) DocumentModel(org.apache.maven.doxia.document.DocumentModel)

Aggregations

DocumentModel (org.apache.maven.doxia.document.DocumentModel)8 File (java.io.File)4 DocumentTOC (org.apache.maven.doxia.document.DocumentTOC)2 ModelBuilderMavenProjectStub (org.apache.maven.plugins.pdf.stubs.ModelBuilderMavenProjectStub)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 Map (java.util.Map)1 AbstractDocumentRenderer (org.apache.maven.doxia.docrenderer.AbstractDocumentRenderer)1 DocumentRendererContext (org.apache.maven.doxia.docrenderer.DocumentRendererContext)1 DocumentRendererException (org.apache.maven.doxia.docrenderer.DocumentRendererException)1 DocumentCover (org.apache.maven.doxia.document.DocumentCover)1 DocumentMeta (org.apache.maven.doxia.document.DocumentMeta)1 DecorationModel (org.apache.maven.doxia.site.decoration.DecorationModel)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 FilteringMavenProjectStub (org.apache.maven.plugins.pdf.stubs.FilteringMavenProjectStub)1 FileUtils (org.codehaus.plexus.util.FileUtils)1 PathTool (org.codehaus.plexus.util.PathTool)1 StringUtils (org.codehaus.plexus.util.StringUtils)1