Package com.saasovation.identityaccess.domain.model.identity

Examples of com.saasovation.identityaccess.domain.model.identity.Group


        return user;
    }

    @Transactional
    public void removeGroupFromGroup(RemoveGroupFromGroupCommand aCommand) {
        Group parentGroup =
                this.existingGroup(
                        aCommand.getTenantId(),
                        aCommand.getParentGroupName());

        Group childGroup =
                this.existingGroup(
                        aCommand.getTenantId(),
                        aCommand.getChildGroupName());

        parentGroup.removeGroup(childGroup);
View Full Code Here


        parentGroup.removeGroup(childGroup);
    }

    @Transactional
    public void removeUserFromGroup(RemoveUserFromGroupCommand aCommand) {
        Group group =
                this.existingGroup(
                        aCommand.getTenantId(),
                        aCommand.getGroupName());

        User user =
                this.existingUser(
                        aCommand.getTenantId(),
                        aCommand.getUsername());

        group.removeUser(user);
    }
View Full Code Here

    private AuthenticationService authenticationService() {
        return this.authenticationService;
    }

    private Group existingGroup(String aTenantId, String aGroupName) {
        Group group = this.group(aTenantId, aGroupName);

        if (group == null) {
            throw new IllegalArgumentException(
                    "Group does not exist for: "
                    + aTenantId + " and: " + aGroupName);
View Full Code Here

        assertEquals(tenant.name(), changedTenant.name());
        assertTrue(changedTenant.isActive());
    }

    public void testAddGroupToGroup() throws Exception {
        Group parentGroup = this.group1Aggregate();
        DomainRegistry.groupRepository().add(parentGroup);

        Group childGroup = this.group2Aggregate();
        DomainRegistry.groupRepository().add(childGroup);

        assertEquals(0, parentGroup.groupMembers().size());

        ApplicationServiceRegistry
            .identityApplicationService()
            .addGroupToGroup(new AddGroupToGroupCommand(
                    parentGroup.tenantId().id(),
                    parentGroup.name(),
                    childGroup.name()));

        assertEquals(1, parentGroup.groupMembers().size());
    }
View Full Code Here

        assertEquals(1, parentGroup.groupMembers().size());
    }

    public void testAddUserToGroup() 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);

        assertEquals(0, parentGroup.groupMembers().size());
        assertEquals(0, childGroup.groupMembers().size());

        parentGroup.addGroup(childGroup, DomainRegistry.groupMemberService());

        ApplicationServiceRegistry
            .identityApplicationService()
            .addUserToGroup(new AddUserToGroupCommand(
                childGroup.tenantId().id(),
                childGroup.name(),
                user.username()));

        assertEquals(1, parentGroup.groupMembers().size());
        assertEquals(1, childGroup.groupMembers().size());
        assertTrue(parentGroup.isMember(user, DomainRegistry.groupMemberService()));
        assertTrue(childGroup.isMember(user, DomainRegistry.groupMemberService()));
    }
View Full Code Here

        assertNotNull(changedUser);
        assertTrue(changedUser.isEnabled());
    }

    public void testIsGroupMember() 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);

        assertEquals(0, parentGroup.groupMembers().size());
        assertEquals(0, childGroup.groupMembers().size());

        parentGroup.addGroup(childGroup, DomainRegistry.groupMemberService());
        childGroup.addUser(user);

        assertTrue(
                ApplicationServiceRegistry
                    .identityApplicationService()
                    .isGroupMember(
                            parentGroup.tenantId().id(),
                            parentGroup.name(),
                            user.username()));

        assertTrue(
                ApplicationServiceRegistry
                    .identityApplicationService()
                    .isGroupMember(
                            childGroup.tenantId().id(),
                            childGroup.name(),
                            user.username()));
    }
View Full Code Here

                            childGroup.name(),
                            user.username()));
    }

    public void testRemoveGroupFromGroup() throws Exception {
        Group parentGroup = this.group1Aggregate();
        DomainRegistry.groupRepository().add(parentGroup);

        Group childGroup = this.group2Aggregate();
        DomainRegistry.groupRepository().add(childGroup);

        parentGroup.addGroup(childGroup, DomainRegistry.groupMemberService());

        assertEquals(1, parentGroup.groupMembers().size());

        ApplicationServiceRegistry
            .identityApplicationService()
            .removeGroupFromGroup(new RemoveGroupFromGroupCommand(
                    parentGroup.tenantId().id(),
                    parentGroup.name(),
                    childGroup.name()));

        assertEquals(0, parentGroup.groupMembers().size());
    }
View Full Code Here

        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()));
    }
View Full Code Here

    public GroupResourceTest() {
        super();
    }

    public void testGetGroup() throws Exception {
        Group group = this.group1Aggregate();
        DomainRegistry.groupRepository().add(group);

        String url = "http://localhost:" + PORT + "/tenants/{tenantId}/groups/{groupName}";

        System.out.println(">>> GET: " + url);
        ClientRequest request = new ClientRequest(url);
        request.pathParameter("tenantId", group.tenantId().id());
        request.pathParameter("groupName", group.name());
        String output = request.getTarget(String.class);
        System.out.println(output);

        RepresentationReader reader = new RepresentationReader(output);

        assertEquals(group.tenantId().id(), reader.stringValue("tenantId.id"));
        assertEquals(group.name(), reader.stringValue("name"));
    }
View Full Code Here

    protected void createInternalGroup() {
        String groupName =
                Group.ROLE_GROUP_PREFIX
                + UUID.randomUUID().toString().toUpperCase();

        this.setGroup(new Group(
                this.tenantId(),
                groupName,
                "Role backing group for: " + this.name()));
    }
View Full Code Here

TOP

Related Classes of com.saasovation.identityaccess.domain.model.identity.Group

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.