Package org.uned.agonzalo16.bitacora.domain

Examples of org.uned.agonzalo16.bitacora.domain.Article


    return blogDao.merge(blog);
  }

  private Article createArticle(Blog blog) {
    Article article = new Article();
    article.setTitle("title 1");
    article.setCreationDate(new Date());
    article.setText("text 1");
    article.setOpenComments(true);
    article.setBlog(blog);
    article.setUser(createUser());

    return articleDao.merge(article);
  }
View Full Code Here


    return userDao.merge(user);
  }

  @Test
  public void testList() {
    Article article = createArticle(createBlog());
    for (int i = 0; i < 100; i++) {
      Comment comment = new Comment();
      comment.setContent("comment " + i);
      comment.setCreationDate(new Date());
      comment.setArticle(article);
View Full Code Here

    assertEquals("100 comments in datastore", allComments.size(), 100);
  }

  @Test
  public void testSave() {
    Article article = createArticle(createBlog());
    Comment comment = new Comment();
    comment.setContent("comment 1");
    comment.setCreationDate(new Date());
    comment.setArticle(article);
    comment.setUser(createUser());
View Full Code Here

    assertEquals("Id must be the same", comment.getId(), newComment.getId());
  }

  @Test
  public void testDelete() {
    Article article = createArticle(createBlog());
    Comment comment = new Comment();
    comment.setContent("comment 1");
    comment.setCreationDate(new Date());
    comment.setArticle(article);
    comment.setUser(createUser());
View Full Code Here

  }

  @Test
  public void testFindByArticle() {
    Blog blog = createBlog();
    Article article1 = createArticle(blog);
    Article article2 = createArticle(blog);
    for (int i = 0; i < 10; i++) {
      Comment comment = new Comment();
      comment.setContent("comment " + i);
      comment.setCreationDate(new Date());
      comment.setArticle(article1);
View Full Code Here

  }

  @Test
  public void testCountByArticle() {
    Blog blog = createBlog();
    Article article1 = createArticle(blog);
    Article article2 = createArticle(blog);
    for (int i = 0; i < 10; i++) {
      Comment comment = new Comment();
      comment.setContent("comment " + i);
      comment.setCreationDate(new Date());
      comment.setArticle(article1);
View Full Code Here

  }

  @Test
  public void testDeleteAricleWithComments() {
    Blog blog = createBlog();
    Article article1 = createArticle(blog);
    Article article2 = createArticle(blog);
    for (int i = 0; i < 10; i++) {
      Comment comment = new Comment();
      comment.setContent("comment " + i);
      comment.setCreationDate(new Date());
      comment.setArticle(article1);
      comment.setUser(createUser());

      commentDao.merge(comment);
    }

    for (int i = 10; i < 30; i++) {
      Comment comment = new Comment();
      comment.setContent("comment " + i);
      comment.setCreationDate(new Date());
      comment.setArticle(article2);
      comment.setUser(createUser());

      commentDao.merge(comment);
    }

    assertEquals("30 comments", commentDao.findAll().size(), 30);

    articleDao.delete(article1.getId());
    assertEquals("20 comments", commentDao.findAll().size(), 20);

    articleDao.delete(article2.getId());
    assertEquals("0 comments", commentDao.findAll().size(), 0);
  }
View Full Code Here

    assertEquals("0 comments", commentDao.findAll().size(), 0);
  }

  @Test
  public void testFidByUser() {
    Article article = createArticle(createBlog());
    User user1 = createUser();
    User user2 = createUser();
    for (int i = 0; i < 10; i++) {
      Comment comment = new Comment();
      comment.setContent("comment " + i);
View Full Code Here

    if (result.hasErrors()) {
      return "contributor/article/create";
    }

    Article article = new Article();
    article.setCreationDate(new Date());
    article.setOpenComments(true);
    article.setTitle(form.getTitle());
    article.setText(form.getText());
    article.setBlog(blogDao.get(form.getBlogId()));
    article.setUser(userDao.get(user.getId()));

    articleDao.merge(article);

    searchService.addArticle(article);

    return "redirect:/article/" + article.getId();
  }
View Full Code Here

    if (result.hasErrors()) {
      return "contributor/article/update";
    }

    Article article = articleDao.get(form.getId());
    article.setTitle(form.getTitle());
    article.setText(form.getText());

    articleDao.merge(article);

    searchService.addArticle(article);

    return "redirect:/article/" + article.getId();
  }
View Full Code Here

TOP

Related Classes of org.uned.agonzalo16.bitacora.domain.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.