Package com.taskadapter.redmineapi.bean

Examples of com.taskadapter.redmineapi.bean.Membership


    return role;
  }

  public static Membership parseMembership(JSONObject content)
      throws JSONException {
    final Membership result = MembershipFactory.create(JsonInput.getIntOrNull(content, "id"));
    result.setProject(JsonInput.getObjectOrNull(content, "project",
        MINIMAL_PROJECT_PARSER));
    result.setUser(JsonInput.getObjectOrNull(content, "user", USER_PARSER));
    result.addRoles(JsonInput.getListOrEmpty(content, "roles", ROLE_PARSER));
    return result;
  }
View Full Code Here


     *
     * This method is here only to show what the future API will look like
     */
    @Deprecated
    public void createMembershipForGroup(int projectId, int groupId, Collection<Role> roles) throws RedmineException {
        final Membership membership = MembershipFactory.create();
        final Project project = ProjectFactory.create(projectId);
        membership.setProject(project);
        membership.setGroup(GroupFactory.create(groupId));
        membership.addRoles(roles);

        addMembership(membership);
    }
View Full Code Here

        addMembership(membership);
    }

    public void createMembershipForUser(int projectId, int userId, Collection<Role> roles) throws RedmineException {
        final Membership membership = MembershipFactory.create();
        final Project project = ProjectFactory.create(projectId);
        membership.setProject(project);
        membership.setUser(UserFactory.create(userId));
        membership.addRoles(roles);
        addMembership(membership);
    }
View Full Code Here

        final User currentUser = mgr.getUserManager().getCurrentUser();

        membershipManager.createMembershipForUser(project.getId(), currentUser.getId(), roles);
        final List<Membership> memberships1 = membershipManager.getMemberships(project.getIdentifier());
        assertEquals(1, memberships1.size());
        final Membership createdMembership = memberships1.get(0);
        assertEquals(currentUser.getId(), createdMembership.getUser()
                .getId());
        assertEquals(roles.size(), createdMembership.getRoles().size());

        final Membership membershipById = membershipManager.getMembership(createdMembership
                .getId());
        assertEquals(createdMembership, membershipById);

        final Membership emptyMembership = MembershipFactory.create(createdMembership.getId());
        emptyMembership.setProject(createdMembership.getProject());
        emptyMembership.setUser(createdMembership.getUser());
        emptyMembership.addRoles(Collections.singletonList(roles.get(0)));

        membershipManager.update(emptyMembership);
        final Membership updatedEmptyMembership = membershipManager.getMembership(createdMembership.getId());

        assertEquals(1, updatedEmptyMembership.getRoles().size());
        membershipManager.delete(updatedEmptyMembership);
    }
View Full Code Here

TOP

Related Classes of com.taskadapter.redmineapi.bean.Membership

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.