コード例 #1
0
  @Test
  public void testLastUpdateChanged() {
    Article article = new Article(admin, "art1", "cont1");
    articleService.persist(article);

    long created = article.getCreated().getTime();
    long updated = article.getUpdated().getTime();

    LOG.info("Created: " + created);
    LOG.info("Updated: " + updated);

    Assert.assertEquals(created, updated);

    try {
      Thread.sleep(5);
    } catch (InterruptedException e) {
    }

    article.setContent("Content upr");
    articleService.merge(article);

    article = articleService.get(article.getId());
    Assert.assertEquals("Content upr", article.getContent());

    LOG.info("Updated after update: " + article.getUpdated().getTime());
    Assert.assertTrue(updated < article.getUpdated().getTime());

    LOG.info("Created after update: " + article.getCreated().getTime());
    Assert.assertEquals(created, article.getCreated().getTime());
  }
コード例 #2
0
  @Test
  public void testIsPartOf() {
    Article art1 = new Article(admin, "art1", "cont1");
    articleService.persist(art1);

    Article art2 = new Article(admin, "art2", "cont2");
    articleService.persist(art2);

    Ticket t1 = new Ticket(admin, "t1", "t1info");
    ticketService.persist(t1);

    Ticket t2 = new Ticket(admin, "t2", "t2info");
    ticketService.persist(t2);

    t1 = ticketService.addContains(t1, t2);
    t1 = ticketService.addContains(t1, art1);
    t2 = ticketService.addContains(t2, art2);

    t1 = ticketService.loadLazyCollections(ticketService.get(t1.getId()));
    t2 = ticketService.loadLazyCollections(ticketService.get(t2.getId()));
    art1 = articleService.loadLazyCollections(articleService.get(art1.getId()));
    art2 = articleService.loadLazyCollections(articleService.get(art2.getId()));

    Assert.assertTrue(t2.getPartOf().contains(t1));
    Assert.assertTrue(art1.getPartOf().contains(t1));
    Assert.assertTrue(art2.getPartOf().contains(t2));

    Assert.assertFalse(art2.getPartOf().contains(t1));
  }