assertEquals(0, parentGroup.groupMembers().size());
}
public void testRemoveUserFromGroup() throws Exception {
Group parentGroup = this.group1Aggregate();
DomainRegistry.groupRepository().add(parentGroup);
Group childGroup = this.group2Aggregate();
DomainRegistry.groupRepository().add(childGroup);
User user = this.userAggregate();
DomainRegistry.userRepository().add(user);
parentGroup.addGroup(childGroup, DomainRegistry.groupMemberService());
childGroup.addUser(user);
assertEquals(1, parentGroup.groupMembers().size());
assertEquals(1, childGroup.groupMembers().size());
assertTrue(parentGroup.isMember(user, DomainRegistry.groupMemberService()));
assertTrue(childGroup.isMember(user, DomainRegistry.groupMemberService()));
ApplicationServiceRegistry
.identityApplicationService()
.removeUserFromGroup(new RemoveUserFromGroupCommand(
childGroup.tenantId().id(),
childGroup.name(),
user.username()));
assertEquals(1, parentGroup.groupMembers().size());
assertEquals(0, childGroup.groupMembers().size());
assertFalse(parentGroup.isMember(user, DomainRegistry.groupMemberService()));
assertFalse(childGroup.isMember(user, DomainRegistry.groupMemberService()));
}