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

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


                assert invokeMethod("#{topicHome.persist}") == null;

                Long newId = (Long)getValue("#{topicHome.instance.id}");

                WikiNodeDAO nodeDAO = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDocument newTopic = nodeDAO.findWikiDocument(newId);

                assert newTopic.getAreaNumber().equals(100l);

                FeedDAO feedDAO = (FeedDAO)getInstance(FeedDAO.class);
                FeedEntry fe = feedDAO.findFeedEntry(newTopic);
                assert fe.getTitle().equals("[Seam Users] New Topic");

                assert newTopic.getHeaderMacrosString().contains("forumPosting");
                assert newTopic.getFooterMacrosString().contains("forumReplies");
                assert newTopic.getContent().equals("This is a new topic.");
                assert !newTopic.isNameAsTitle();
                assert !newTopic.isEnableComments();
            }
        }.run();
    }
View Full Code Here


    public void loadDocumentById() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiDocument d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d where d.id = :id")
                                .setParameter("id", 6l)
                                .getSingleResult();
                assert d.getName().equals("One");
            }
        }.run();
    }
View Full Code Here

    public void updateDocumentById() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiDocument d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d where d.id = :id")
                                .setParameter("id", 6l)
                                .getSingleResult();
                d.setName("One2");
                em.flush();

                em.clear();
                d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d where d.id = :id")
                                .setParameter("id", 6l)
                                .getSingleResult();
                assert d.getName().equals("One2");
                assert d.getLastModifiedBy() != null;
                assert d.getLastModifiedOn() != null;
            }
        }.run();
    }
View Full Code Here

        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");

                WikiDocument d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d left join fetch d.incomingLinks where d.id = :id")
                                .setParameter("id", 8l)
                                .getSingleResult();
                assert d.getIncomingLinks().size() == 1;

                em.clear();

                d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d left join fetch d.incomingLinks where d.id = :id")
                                .setParameter("id", 9l)
                                .getSingleResult();
                assert d.getIncomingLinks().size() == 1;

                em.clear();

                d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d where d.id = :id")
                                .setParameter("id", 7l)
                                .getSingleResult();

                assert d.getOutgoingLinks().size() == 2;

                em.remove(d);
                em.flush();

                try {
                    d = null;
                    d = (WikiDocument)
                            em.createQuery("select d from WikiDocument d where d.id = :id")
                                    .setParameter("id", 7l)
                                    .getSingleResult();
                } catch (Exception ex) {} finally {
                    assert d == null;
                }

                em.clear();

                d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d left join fetch d.incomingLinks where d.id = :id")
                                .setParameter("id", 8l)
                                .getSingleResult();
                assert d.getIncomingLinks().size() == 0;

                em.clear();

                d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d left join fetch d.incomingLinks where d.id = :id")
                                .setParameter("id", 9l)
                                .getSingleResult();
                assert d.getIncomingLinks().size() == 0;

            }
        }.run();
    }
View Full Code Here

                WikiDirectory d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 3l)
                                .getSingleResult();

                WikiDocument newDoc = new WikiDocument();
                newDoc.setName("Four");
                newDoc.setWikiname("Four");
                newDoc.setAreaNumber(d.getAreaNumber());
                newDoc.setCreatedBy(em.find(User.class, 1l));
                newDoc.setContent("Testdocument Four");
                newDoc.setParent(d);

                em.persist(newDoc);
                em.flush();

                em.clear();
                WikiDocument doc = (WikiDocument)
                        em.createQuery("select d from WikiDocument d where d.id = :id")
                                .setParameter("id", newDoc.getId())
                                .getSingleResult();
                assert doc.getName().equals("Four");
                assert doc.getParent().getId().equals(d.getId());
                assert doc.getAreaNumber().equals(d.getAreaNumber());
                assert doc.getLastModifiedBy() == null;
                assert doc.getLastModifiedOn() == null;
            }
        }.run();
    }
View Full Code Here

        new FacesRequest() {

            protected void invokeApplication() throws Exception {

                WikiNodeDAO nodeDAO = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDocument document = nodeDAO.findWikiDocument(9l);

                FeedDAO feedDAO = (FeedDAO)getInstance(FeedDAO.class);

                List<WikiFeed> feeds = feedDAO.findFeeds(document);
                assert feeds.size() == 2;
View Full Code Here

        new FacesRequest() {

            protected void invokeApplication() throws Exception {

                WikiNodeDAO nodeDAO = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDocument document = nodeDAO.findWikiDocument(9l);

                FeedDAO feedDAO = (FeedDAO)getInstance(FeedDAO.class);

                assert feedDAO.isOnSiteFeed(document);
            }
View Full Code Here

        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");

                WikiDocument d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d left join fetch d.incomingLinks where d.id = :id")
                                .setParameter("id", 7l)
                                .getSingleResult();
                assert d.getIncomingLinks().size() == 1;
                em.clear();

                d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d left join fetch d.incomingLinks where d.id = :id")
                                .setParameter("id", 8l)
                                .getSingleResult();
                assert d.getIncomingLinks().size() == 2;
                em.clear();

                WikiUpload f = (WikiUpload)
                        em.createQuery("select f from WikiUpload f left join fetch f.incomingLinks where f.id = :id")
                                .setParameter("id", 30l)
View Full Code Here

    public void documentURL() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiDocument d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d where d.id = :id")
                                .setParameter("id", 6l)
                                .getSingleResult();

                assert d.getPermURL(".lace").equals("6.lace");
                assert d.getWikiURL().equals("CCC/One");
            }
        }.run();
    }
View Full Code Here

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

                WikiDocument doc = docHome.getInstance();

                // Header
                doc.setHeader("[<=testMacro1[param1=value1]]\n[<=testMacro2]\nfoo");
                docHome.syncMacros(doc);
                assert doc.getHeaderMacros().size() == 2;
                assert doc.getHeaderMacrosString().contains("testMacro1");
                assert doc.getHeaderMacrosString().contains("testMacro2");
                assert doc.getHeader().contains("[<=testMacro1[param1=value1]]\n");
                assert doc.getHeader().contains("[<=testMacro2]\n");
                assert doc.getHeader().indexOf("foo") == doc.getHeader().length()-3;

                doc.removeHeaderMacros("testMacro1");
                WikiTextMacro replacement = new WikiTextMacro("testMacro3");
                replacement.getParams().put("p1", "value1");
                replacement.getParams().put("p2", "value2");
                doc.addHeaderMacro(replacement);
                assert doc.getHeaderMacros().size() == 2;
                assert doc.getHeaderMacrosString().contains("testMacro3");
                assert doc.getHeaderMacrosString().contains("testMacro2");
                assert doc.getHeader().contains("[<=testMacro3[p1=value1][p2=value2]]\n");
                assert doc.getHeader().contains("[<=testMacro2]\n");
                assert doc.getHeader().indexOf("foo") == doc.getHeader().length()-3;


            }

        }.run();
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.