Package models

Examples of models.Article


                        testServerUrl().path(
                                GET_ARTICLE_URL
                                        .replace("{username}", "bob@gmail.com")
                                        .replace("{id}", "1"))));

        Article article = getGsonWithLongToDateParsing().fromJson(response.payload, Article.class);
        // one new result:
        sayAndAssertThat("And we got back the first article"
                , article.id
                , CoreMatchers.is(1L));
    }
View Full Code Here


            // Create a new user and save it
            User bob = new User("bob@gmail.com", "secret", "Bob");
            entityManager.persist(bob);
           
            // Create a new post
            Article bobPost3 = new Article(bob, "My third post", lipsum);
            entityManager.persist(bobPost3);

            // Create a new post
            Article bobPost2 = new Article(bob, "My second post", lipsum);
            entityManager.persist(bobPost2);
           
            // Create a new post
            Article bobPost1 = new Article(bob, post1Title, post1Content);
            entityManager.persist(bobPost1);
           
            entityManager.setFlushMode(FlushModeType.COMMIT);
            entityManager.flush();
        }
View Full Code Here

    }

    public Result index() {

        Article frontPost = articleDao.getFirstArticleForFrontPage();

        List<Article> olderPosts = articleDao.getOlderArticlesForFrontPage();

        Map<String, Object> map = Maps.newHashMap();
        map.put("frontArticle", frontPost);
View Full Code Here

    ///////////////////////////////////////////////////////////////////////////
    // Show article
    ///////////////////////////////////////////////////////////////////////////
    public Result articleShow(@PathParam("id") Long id) {

        Article article = null;

        if (id != null) {

            article = articleDao.getArticle(id);
View Full Code Here

    private List<Article> toArticles(SearchResponse searchResponse) {
        List<Article> articles = Lists.newArrayList();

        for (SearchHit searchHit : searchResponse.hits().hits()) {
            try {
                Article article = json.readValue(searchHit.source(), Article.class);
                articles.add(article);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
View Full Code Here

                }

                log.info("Checking for article file '{}'", articleFile.getName());
                try {
                    String slug = articleFile.getName().replaceAll(".yaml", "");
                    Article article = articleDao.findBySlug(slug);
                    if (article == null) {
                        log.info("Adding new article [{}]", slug);
                        article = json.readYamlValue(articleFile, Article.class);
                        article.setSlug(slug);
                        articleDao.store(article);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
View Full Code Here

        throw new WebApplicationException(Status.NO_CONTENT);
    }

    @GET
    public ArticleView getArticle(@PathParam("slug") String slug) {
        Article article = dao.findBySlug(slug);
        notFoundIfNull(article);

        return new ArticleView(article);
    }
View Full Code Here

*/
public class CommentArticleActivityTest extends AbstractActivityTest {

    @Test
    public void addCommentValid() {
        Article article = createArticle("test");
        article.valid = true;
        article.save();
       
        // Non activity for the article
        assertEquals(0, Activity.count("article = ?", article));
       
        ArticleComment c = new ArticleComment(member, article, "Un commentaire");
        article.addComment(c);
        article.save();
       
        // One activity for the article
        assertEquals(1, Activity.count("article = ?", article));
        Activity a = Activity.find("article = ?", article).first();
        assertActivity(a);
View Full Code Here

        assertEquals(c, ca.comment);
    }

    @Test
    public void addCommentNonValid() {
        Article article = createArticle("test");
        article.valid = false;
        article.save();
       
        // No activity for the article
        assertEquals(0, Activity.count("article = ?", article));
       
        ArticleComment c = new ArticleComment(member, article, "Un commentaire");
        article.addComment(c);
        article.save();
       
        // Still no activity for the article
        assertEquals(0, Activity.count("article = ?", article));
       
        article.validate();
        // 1 comment activity amongst others
        assertEquals(1, CommentArticleActivity.count("article = ?", article));
        Activity a = CommentArticleActivity.find("article = ?", article).first();
        assertActivity(a);
        assertTrue(a instanceof CommentArticleActivity);
View Full Code Here

        assertNotNull(Activity.recentsBySession(s, 1, 10));
    }

    @Test
    public void recentsByArticle() {
        final Article a = Article.all().first();
        assertNotNull(Activity.recentsByArticle(a, 1, 10));
    }
View Full Code Here

TOP

Related Classes of models.Article

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.