Buggy code:
@ Concurrent public class GroupResourceIT extends AbstractRestIT { public GroupResourceIT ( ) throws Exception { } private Entity createGroup ( String groupName , String groupPath ) throws IOException { } private Entity createRole ( String roleName , String roleTitle ) throws IOException { } private Entity createUser ( String username , String email , String password ) throws IOException { } @ Test public void createGroupValidation ( ) throws IOException { } @ Test public void createGroupSlashInNameAndPathValidation ( ) throws IOException { } @ Test public void createGroupSpaceInNameValidation ( ) throws IOException { } @ Test public void createGroupSpaceInPathValidation ( ) throws IOException { } @ Test public void groupCRUDOperations ( ) throws IOException { } @ Test public void addRemoveUserGroup ( ) throws IOException { } @ Test public void addRemoveRoleGroup ( ) throws IOException { } @ Test public void addRolePermissionToGroupVerifyPermission ( ) throws IOException { } @ Test public void postGroupActivity ( ) throws IOException { String groupName = "testgroup" ; String groupPath = "testgroup" ; Entity group = this . createGroup ( groupName , groupPath ) ; String user1Username = "fred" ; String user1Email = "fred@usergrid.com" ; String password = "password" ; Entity user1 = this . createUser ( user1Username , user1Email , password ) ; String user2Username = "barney" ; String user2Email = "barney@usergrid.com" ; password = "password" ; Entity user2 = this . createUser ( user2Username , user2Email , password ) ; String user3Username = "wilma" ; String user3Email = "wilma@usergrid.com" ; password = "password" ; Entity user3 = this . createUser ( user3Username , user3Email , password ) ; Entity addUser1Response = this . app ( ) . collection ( "users" ) . entity ( user1 ) . connection ( ) . collection ( "groups" ) . entity ( group ) . post ( ) ; assertEquals ( addUser1Response . get ( "name" ) , groupName ) ; Entity addUser2Response = this . app ( ) . collection ( "users" ) . entity ( user2 ) . connection ( ) . collection ( "groups" ) . entity ( group ) . post ( ) ; assertEquals ( addUser2Response . get ( "name" ) , groupName ) ; this . refreshIndex ( ) ; Collection usersInGroup = this . app ( ) . collection ( "groups" ) . uniqueID ( groupName ) . connection ( "users" ) . get ( ) ; <START_BUG> assertEquals ( usersInGroup . response . getEntityCount ( ) , 2 ) ; <END_BUG> Entity payload = new Entity ( ) ; payload . put ( "displayName" , "fred" ) ; payload . put ( "uuid" , user1 . get ( "uuid" ) ) ; payload . put ( "username" , "fred" ) ; Entity activity = new Entity ( ) ; activity . put ( "actor" , payload ) ; activity . put ( "verb" , "post" ) ; String content = "content" ; activity . put ( "content" , content ) ; Entity activityResponse = this . app ( ) . collection ( "groups" ) . uniqueID ( groupName ) . connection ( "activities" ) . post ( activity ) ; assertEquals ( activityResponse . get ( "content" ) , content ) ; this . refreshIndex ( ) ; this . app ( ) . collection ( "role" ) . uniqueID ( "Default" ) . delete ( ) ; this . getAppUserToken ( user1Username , password ) ; Collection user1ActivityResponse = this . app ( ) . collection ( "groups" ) . entity ( group ) . connection ( "activities" ) . get ( ) ; boolean found = false ; while ( user1ActivityResponse . hasNext ( ) ) { Entity tempActivity = user1ActivityResponse . next ( ) ; if ( ( tempActivity . get ( "type" ) . equals ( "activity" ) ) && ( tempActivity . get ( "content" ) . equals ( content ) ) ) { found = true ; } } assertTrue ( found ) ; this . getAppUserToken ( user2Username , password ) ; Collection user2ActivityResponse = this . app ( ) . collection ( "groups" ) . entity ( group ) . connection ( "activities" ) . get ( ) ; found = false ; while ( user2ActivityResponse . hasNext ( ) ) { Entity tempActivity = user2ActivityResponse . next ( ) ; if ( ( tempActivity . get ( "type" ) . equals ( "activity" ) ) && ( tempActivity . get ( "content" ) . equals ( content ) ) ) { found = true ; } } assertTrue ( found ) ; this . getAppUserToken ( user3Username , password ) ; Collection user3ActivityResponse = this . app ( ) . collection ( "groups" ) . entity ( group ) . connection ( "activities" ) . get ( ) ; found = false ; while ( user3ActivityResponse . hasNext ( ) ) { Entity tempActivity = user3ActivityResponse . next ( ) ; if ( ( tempActivity . get ( "type" ) . equals ( "activity" ) ) && ( tempActivity . get ( "content" ) . equals ( "content" ) ) ) { found = true ; } } assertFalse ( found ) ; } No newline ; at end ; of file ; }

Fix:
assertEquals ( usersInGroup . getResponse ( ) . getEntityCount ( ) , 2 ) ;