Package org.jboss.seam.wiki.core.model

Examples of org.jboss.seam.wiki.core.model.WikiDocument


            protected void beforeRequest() {
                setParameter("nodeId", "6");
            }

            protected void renderResponse() throws Exception {
                WikiDocument doc = (WikiDocument)getValue("#{currentDocument}");
                assert doc != null;
                assert doc.getId().equals(6l);

                CommentQuery commentQuery = (CommentQuery)getInstance(CommentQuery.class);
                assert commentQuery.getComments().size() == 6;

                assert commentQuery.getComments().get(0).getId().equals(10l);
View Full Code Here


        }.run();
    }
   
    @Test
    public void macrosFromDefaultStrings() throws Exception {
        WikiDocument doc = new WikiDocument();

        WikiDocumentDefaults defaults = new WikiDocumentDefaults() {
            @Override
            public String[] getContentMacrosAsString() {
                return new String[] {"contentMacro1", "contentMacro2"};
            }
            @Override
            public String getContentText() {
                return "foo";
            }
            @Override
            public String[] getHeaderMacrosAsString() {
                return new String[] {"headerMacro1", "headerMacro2"};
            }
            @Override
            public String getHeaderText() {
                return "bar";
            }
            @Override
            public String[] getFooterMacrosAsString() {
                return new String[] {"footerMacro1", "footerMacro2"};
            }
            @Override
            public String getFooterText() {
                return "baz";
            }
        };
        doc.setDefaults(defaults);

        assert doc.getContentMacros().size() == 2;
        assert doc.getContentMacrosString().contains("contentMacro1");
        assert doc.getContentMacrosString().contains("contentMacro1");
        assert doc.getContent().contains("[<=contentMacro1]");
        assert doc.getContent().contains("[<=contentMacro2]");
        assert doc.getContent().indexOf("foo") == doc.getContent().length()-3;

        assert doc.getHeaderMacros().size() == 2;
        assert doc.getHeaderMacrosString().contains("headerMacro1");
        assert doc.getHeaderMacrosString().contains("headerMacro2");
        assert doc.getHeader().contains("[<=headerMacro1]");
        assert doc.getHeader().contains("[<=headerMacro2]");
        assert doc.getHeader().indexOf("bar") == doc.getHeader().length()-3;

        assert doc.getFooterMacros().size() == 2;
        assert doc.getFooterMacrosString().contains("footerMacro1");
        assert doc.getFooterMacrosString().contains("footerMacro2");
        assert doc.getFooter().contains("[<=footerMacro1]");
        assert doc.getFooter().contains("[<=footerMacro2]");
        assert doc.getFooter().indexOf("baz") == 0;
    }
View Full Code Here

        assert doc.getFooter().indexOf("baz") == 0;
    }

    @Test
    public void macrosFromDefaultTypesafe() throws Exception {
        WikiDocument doc = new WikiDocument();

        WikiDocumentDefaults defaults = new WikiDocumentDefaults() {
            @Override
            public List<WikiTextMacro> getContentMacros() {
                return new ArrayList<WikiTextMacro>() {{
                   add(new WikiTextMacro("contentMacro1", 0));
                   add(new WikiTextMacro("contentMacro2", 1));
                }};
            }
            @Override
            public String getContentText() {
                return "foo";
            }
            @Override
            public List<WikiTextMacro> getHeaderMacros() {
                return new ArrayList<WikiTextMacro>() {{
                   add(new WikiTextMacro("headerMacro1", 0));
                   add(new WikiTextMacro("headerMacro2", 1));
                }};
            }
            @Override
            public String getHeaderText() {
                return "bar";
            }
            @Override
            public List<WikiTextMacro> getFooterMacros() {
                return new ArrayList<WikiTextMacro>() {{
                   add(new WikiTextMacro("footerMacro1", 0));
                   add(new WikiTextMacro("footerMacro2", 1));
                }};
            }
            @Override
            public String getFooterText() {
                return "baz";
            }
        };
        doc.setDefaults(defaults);

        assert doc.getContentMacros().size() == 2;
        assert doc.getContentMacrosString().contains("contentMacro1");
        assert doc.getContentMacrosString().contains("contentMacro1");
        assert doc.getContent().contains("[<=contentMacro1]");
        assert doc.getContent().contains("[<=contentMacro2]");
        assert doc.getContent().indexOf("foo") == doc.getContent().length()-3;

        assert doc.getHeaderMacros().size() == 2;
        assert doc.getHeaderMacrosString().contains("headerMacro1");
        assert doc.getHeaderMacrosString().contains("headerMacro2");
        assert doc.getHeader().contains("[<=headerMacro1]");
        assert doc.getHeader().contains("[<=headerMacro2]");
        assert doc.getHeader().indexOf("bar") == doc.getHeader().length()-3;

        assert doc.getFooterMacros().size() == 2;
        assert doc.getFooterMacrosString().contains("footerMacro1");
        assert doc.getFooterMacrosString().contains("footerMacro2");
        assert doc.getFooter().contains("[<=footerMacro1]");
        assert doc.getFooter().contains("[<=footerMacro2]");
        assert doc.getFooter().indexOf("baz") == 0;
    }
View Full Code Here

        // Rollback to historical revision?
        if (documentHistory != null && documentHistory.getSelectedHistoricalFile() != null) {
            getLog().debug("rolling back to revision: " + documentHistory.getSelectedHistoricalFile().getRevision());
            // TODO: Avoid cast, make history polymorphic
            WikiDocument oldRevision = (WikiDocument)documentHistory.getSelectedHistoricalFile();
            doc.rollback(oldRevision);
            doc.setWikiname(WikiUtil.convertToWikiName(doc.getName()));
        }

        isOnSiteFeed = feedDAO.isOnSiteFeed(doc);
View Full Code Here

        textEditor.setValueAndConvertLinks(areaNumber, doc.getContent());
        textEditor.setRows(docEditorPreferences.getRegularEditAreaRows().intValue());
    }

    protected void copyHistoricalRevision(WikiDocument doc) {
        historicalCopy = new WikiDocument();
        historicalCopy.flatCopy(doc, true);
    }
View Full Code Here

            protected void renderResponse() throws Exception {
                DocumentHome docHome = (DocumentHome)getInstance(DocumentHome.class);
                assert docHome.getInstance().getId().equals(6l); // Init!

                WikiDocument doc = (WikiDocument)getValue("#{currentDocument}");
                assert doc != null;
                assert doc.getId().equals(6l);

                assert doc.getRevision() == 3;

                assert docHome.isHistoricalFilesPresent();
                assert docHome.getHistoricalFiles().size() == 3;

                // Sorted by revision descending
                assert docHome.getHistoricalFiles().get(0).getRevision() == 2;
                assert docHome.getHistoricalFiles().get(0).getId().equals(6l);
                assert docHome.getHistoricalFiles().get(0).getLastModifiedByUsername().equals("admin");
                assert docHome.getHistoricalFiles().get(0).getLastModifiedOn() != null;
                assert !docHome.getHistoricalFiles().get(0).getLastModifiedOn().equals(doc.getLastModifiedOn());

                assert docHome.getHistoricalFiles().get(1).getRevision() == 1;
                assert docHome.getHistoricalFiles().get(0).getId().equals(6l);
                assert docHome.getHistoricalFiles().get(1).getLastModifiedByUsername().equals("guest");
                assert docHome.getHistoricalFiles().get(1).getLastModifiedOn() != null;
                assert !docHome.getHistoricalFiles().get(1).getLastModifiedOn().equals(doc.getLastModifiedOn());

                assert docHome.getHistoricalFiles().get(2).getRevision() == 0;
                assert docHome.getHistoricalFiles().get(0).getId().equals(6l);
                assert docHome.getHistoricalFiles().get(2).getLastModifiedByUsername().equals("admin");
                assert docHome.getHistoricalFiles().get(2).getLastModifiedOn() == null;
View Full Code Here

            // Try to find the area/directory
            WikiDirectory area = wikiNodeDAO.findArea(areaName);
            if (area != null) {

                // Try to find the document
                WikiDocument doc = wikiNodeDAO.findWikiDocumentInArea(area.getAreaNumber(), nodeName);
                if (doc != null) {
                    // Found it, let's use that
                    currentDocument = doc;
                    // TODO: Avoid cast
                    currentDirectory = (WikiDirectory)currentDocument.getParent();
View Full Code Here

                assert invokeMethod("#{documentHome.persist}").equals("persisted");

            }

            protected void renderResponse() throws Exception {
                WikiDocument newNode = (WikiDocument)getValue("#{documentHome.instance}");

                assert newNode.getAreaNumber().equals(3l);
                assert newNode.getCreatedBy().getId().equals(2l);
                assert newNode.getParent().getId().equals(3l);
                assert newNode.getWikiname().equals("TestName");
                assert newNode.getReadAccessLevel() == 0;
                assert newNode.getWriteAccessLevel() == 0;
                assert newNode.getLastModifiedBy() == null;
                assert newNode.getLastModifiedOn() == null;
                assert newNode.getTags().size() == 0;
                assert checkDocumentInDatabase(newNode.getId());
            }

        }.run();
    }
View Full Code Here

                DirectoryHome dirHome = (DirectoryHome)getInstance(DirectoryHome.class);
                assert dirHome.getInstance().getId().equals(4l); // Init!

                // Just take the first one, these should be ordered by name, but there is only one there
                WikiDocument defaultDocument = dirHome.getChildDocuments().get(0);
                dirHome.getInstance().setDefaultFile(defaultDocument);
                newDefaultDocumentId = defaultDocument.getId();

                assert invokeMethod("#{directoryHome.update}").equals("updated");
            }

            protected void renderResponse() throws Exception {
View Full Code Here

                DirectoryHome dirHome = (DirectoryHome)getInstance(DirectoryHome.class);
                assert dirHome.getInstance().getId().equals(3l); // Init!

                // Switch from first to second, these are ordered by name, "One", "Two"
                WikiDocument defaultDocument = dirHome.getChildDocuments().get(1);
                dirHome.getInstance().setDefaultFile(defaultDocument);
                newDefaultDocumentId = defaultDocument.getId();

                assert invokeMethod("#{directoryHome.update}").equals("updated");
            }

            protected void renderResponse() throws Exception {
View Full Code Here

TOP

Related Classes of org.jboss.seam.wiki.core.model.WikiDocument

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.