Exemplo n.º 1
0
  @Test
  public void shouldGetProperTags() {
    Article article = new Article();
    article.setTitle("correct");
    article.setTags(Arrays.asList("gwt", "maven"));
    dao.save(article);
    article = new Article();
    article.setTitle("wrong");
    article.setTags(Arrays.asList("eclipse", "maven"));
    dao.save(article);

    List<ArticleLink> links = dao.getArticleLinksByTag("gwt");
    assertNotNull(links);
    assertEquals(1, links.size());
    assertEquals("correct", links.get(0).getTitle());
  }
Exemplo n.º 2
0
  @Test
  public void shouldIncreaseTheViewCounterOnEveryGet() {
    Article article = new Article();
    article.setTitle("correct");
    article.setTags(Arrays.asList("gwt", "maven"));
    dao.save(article);

    List<ArticleLink> links = dao.getArticleLinksByTag("gwt");
    assertNotNull(links);
    assertEquals(1, links.size());

    Article a1 = dao.get(links.get(0).getUrl());
    assertEquals(Long.valueOf(1), a1.getCounter());

    Article a2 = dao.get(links.get(0).getUrl());
    assertEquals(Long.valueOf(2), a2.getCounter());
  }