* Test add follower.
*/
@Test
public void testAddFollower()
{
Person ford = jpaPersonMapper.findByAccountId("fordp");
Person sagan = jpaPersonMapper.findByAccountId("csagan");
assertEquals("followers/followings should be 0 initially", 0, ford.getFollowersCount());
assertEquals("followers/followings should be 0 initially", 0, ford.getFollowingCount());
assertEquals("followers/followings should be 0 initially", 0, sagan.getFollowersCount());
assertEquals("followers/followings should be 0 initially", 0, sagan.getFollowingCount());
jpaPersonMapper.addFollower(ford.getId(), sagan.getId());
getEntityManager().clear();
ford = jpaPersonMapper.findByAccountId("fordp");
sagan = jpaPersonMapper.findByAccountId("csagan");
assertEquals("sagan should have 1 follower", 1, sagan.getFollowersCount());
assertEquals("sagan follows no one", 0, sagan.getFollowingCount());
assertEquals("ford should have no followers", 0, ford.getFollowersCount());
assertEquals("ford should be following sagan", 1, ford.getFollowingCount());
// test case for add when relationship already present.
jpaPersonMapper.addFollower(ford.getId(), sagan.getId());
getEntityManager().clear();
ford = jpaPersonMapper.findByAccountId("fordp");
sagan = jpaPersonMapper.findByAccountId("csagan");
// verify nothing has changed counts should be same.
assertEquals("Followers count changed after duplicate add.", 1, sagan.getFollowersCount());
assertEquals("Following count changed after duplicate add", 0, sagan.getFollowingCount());
assertEquals("follower's Followers count changed after duplicate add.", 0, ford.getFollowersCount());
assertEquals("follower's Following count changed after duplicate add", 1, ford.getFollowingCount());
}