Beispiel #1
0
  @Test
  public void testListPost() {
    Page<Post> postPage = postService.listPost(10, 0);

    Assert.assertTrue(postPage.getSize() != 0);

    for (Post post : postPage.getContent()) {
      System.out.println(post.getId() + "\t" + post.getTitle() + "\t" + post.getContent());
      //            post.setPostTerms(null);
      post.getPostTerms().clear();
      Long expectedId = post.getId();

      Post acutal = postService.save(post);
      Assert.assertNotNull(acutal);
      Assert.assertEquals(expectedId, acutal.getId());
    }
  }
Beispiel #2
0
  @Test
  public void testSave() {
    Random random = new Random();
    int flag = random.nextInt();

    Post post = new Post();
    post.setTitle("title_" + flag);
    post.setContent("content_" + flag);

    PostTerm postTerm = new PostTerm();
    postTerm.setTermId(301L);
    post.addPostTerm(postTerm);

    Post acutal = postService.save(post);

    Assert.assertNotNull(acutal.getId());

    System.out.println(acutal.getId() + "\t" + acutal.getTitle() + "\t" + post.getContent());
  }