@Test
  public void getAllTest() {
    PostControllerTestServiceApi service0 =
        getPostServiceApi(testUser0.getUsername(), testUser0.getPassword());
    PostControllerTestServiceApi service1 =
        getPostServiceApi(testUser1.getUsername(), testUser1.getPassword());
    service1.addBulk(new ArrayList<>(Arrays.asList(posts)));

    // check you can see own posts
    ArrayList<Post> addedPosts = service1.getAll();
    assertPostsNoId(posts, addedPosts);

    // check you can't see other's posts without confirmation
    addedPosts = service0.getAll();
    assertEquals(0, addedPosts.size());

    // confirm relation and check you can see posts and only the part, which is allowed by patient
    FollowerControllerTestServiceApi followerService1 =
        getFollowerServiceApi(testUser1.getUsername(), testUser1.getPassword());
    followerService1.confirm(
        testUser0.getUsername(), new FollowSettings(true, false, true, false, true));
    addedPosts = service0.getAll();
    assertEquals(3, addedPosts.size());

    for (int i = 0; i < addedPosts.size(); i++) {
      assertEquals(null, addedPosts.get(i).getFeeling());
      assertEquals(false, addedPosts.get(i).getAdministeredInsulin());
      assertEquals(posts[i].getBloodSugar(), addedPosts.get(i).getBloodSugar(), 0.01);
      assertEquals(posts[i].getQuestionnaire(), addedPosts.get(i).getQuestionnaire());
    }
  }
  @Test
  public void addPostTest() {
    PostControllerTestServiceApi service0 =
        getPostServiceApi(testUser0.getUsername(), testUser0.getPassword());
    PostControllerTestServiceApi service1 =
        getPostServiceApi(testUser1.getUsername(), testUser1.getPassword());

    // publish post as user1 and check it is okay
    Post post = service1.add(posts[1]);
    assertPostNoId(posts[1], post);

    // get post as user1 and check it is okay
    ArrayList<Post> postsList;
    postsList = service1.getByUser(testUser1.getUsername());
    assertPostNoId(posts[1], postsList.get(0));

    // try to get post as user0. Check you do not get it. There is no confirmed connection
    // postsList = service0.getByUser(testUser1.getUsername());
    // assertEquals(0, postsList.size());

    // confirm relation, get post, check you got it
    FollowerControllerTestServiceApi followerService1 =
        getFollowerServiceApi(testUser1.getUsername(), testUser1.getPassword());
    followerService1.confirm(
        testUser0.getUsername(), new FollowSettings(true, true, true, true, true));
    postsList = service0.getByUser(testUser1.getUsername());
    assertPostNoId(posts[1], postsList.get(0));
    long id = postsList.get(0).getId();
    service1.delete(id);
  }
 @Before
 public void initiate() {
   PostControllerTestServiceApi postService =
       getPostServiceApi(admin.getUsername(), admin.getPassword());
   postService.deleteAll();
   if (userServiceApi.getUser(testUser0.getUsername()) == null) userServiceApi.signup(testUser0);
   if (userServiceApi.getUser(testUser1.getUsername()) == null) userServiceApi.signup(testUser1);
   FollowerControllerTestServiceApi followerService =
       getFollowerServiceApi(testUser0.getUsername(), testUser0.getPassword());
   followerService.add(testFollower1);
 }
  @After
  public void finish() {
    FollowerControllerTestServiceApi followerService =
        getFollowerServiceApi(testUser0.getUsername(), testUser0.getPassword());
    followerService.delete(testUser1.getUsername());
    userServiceApi.delete(testUser0.getUsername());
    userServiceApi.delete(testUser1.getUsername());

    PostControllerTestServiceApi postService =
        getPostServiceApi(admin.getUsername(), admin.getPassword());
    postService.deleteAll();
  }