コード例 #1
0
        public void AssignSharedSpaceAdminRoleToUserTest()
        {
            //FIND shared space admin role
            LogicalQueryPhrase roleLogicalName = new LogicalQueryPhrase(Role.LOGICAL_NAME_FIELD, "role.shared.space.admin");
            CrossQueryPhrase byRole = new CrossQueryPhrase(WorkspaceRole.ROLE_FIELD, roleLogicalName);
            List<QueryPhrase> queries = new List<QueryPhrase>();
            queries.Add(byRole);
            EntityListResult<WorkspaceRole> roles = entityService.Get<WorkspaceRole>(sharedSpaceContext, queries, null);
            Assert.AreEqual<int>(1, roles.total_count.Value);
            WorkspaceRole sharedSpaceAdminRole = roles.data[0];

            //CREATE USER
            SharedspaceUser createdUser = CreateUser();

            //UPDATE USER by adding shared space admin role
            SharedspaceUser userForUpdate = new SharedspaceUser(createdUser.Id);
            userForUpdate.WorkspaceRoles = createdUser.WorkspaceRoles;
            userForUpdate.WorkspaceRoles.data.Add(sharedSpaceAdminRole);
            entityService.Update<SharedspaceUser>(sharedSpaceContext, userForUpdate);

            //READ USER
            List<String> fields = new List<string> { SharedspaceUser.NAME_FIELD, SharedspaceUser.WORKSPACE_ROLES_FIELD };
            SharedspaceUser updatedUser = EntityService.GetInstance().GetById<SharedspaceUser>(sharedSpaceContext, createdUser.Id, fields);

            List<long> assignedWorkspaceRoles = updatedUser.WorkspaceRoles.data.Select(p => p.Id).ToList<long>();
            Assert.IsTrue(assignedWorkspaceRoles.Contains(sharedSpaceAdminRole.Id));
        }
コード例 #2
0
        public void GetWorkspaceUserByName()
        {
            LogicalQueryPhrase byName = new LogicalQueryPhrase(WorkspaceUser.NAME_FIELD, CurrentUserName);
            List<QueryPhrase> queries = new List<QueryPhrase>();
            queries.Add(byName);

            EntityListResult<WorkspaceUser> users = EntityService.GetInstance().Get<WorkspaceUser>(workspaceContext, queries, null);
            Assert.IsTrue(users.total_count == 1);
        }
コード例 #3
0
        public void GetStoryFieldMetadataTest()
        {
            List<QueryPhrase> queryPhrases = new List<QueryPhrase>();

            LogicalQueryPhrase byEntityNamePhrase = new LogicalQueryPhrase(FieldMetadata.ENTITY_NAME_FIELD, "story");
            queryPhrases.Add(byEntityNamePhrase);

            EntityListResult<FieldMetadata> result = entityService.Get<FieldMetadata>(workspaceContext, queryPhrases, null);
            Assert.IsTrue(result.total_count >= 1);
        }
コード例 #4
0
        public void GetCurrentUser()
        {
            LogicalQueryPhrase byName = new LogicalQueryPhrase(SharedspaceUser.NAME_FIELD, CurrentUserName);
            List<QueryPhrase> queries = new List<QueryPhrase>();
            queries.Add(byName);

            List<String> fields = new List<string> { SharedspaceUser.NAME_FIELD, SharedspaceUser.WORKSPACE_ROLES_FIELD };

            EntityListResult<SharedspaceUser> users = EntityService.GetInstance().Get<SharedspaceUser>(sharedSpaceContext, queries, fields);
            Assert.AreEqual<int>(1, users.total_count.Value);
        }
コード例 #5
0
        public void GetAllStories()
        {
            CreateStory();

            //get as stories
            EntityListResult<Story> stories = entityService.Get<Story>(workspaceContext, null, null);
            Assert.IsTrue(stories.total_count > 0);

            //get as work-items
            List<QueryPhrase> queries = new List<QueryPhrase>();
            LogicalQueryPhrase byStorySubType = new LogicalQueryPhrase(WorkItem.SUBTYPE_FIELD, WorkItem.SUBTYPE_STORY);
            queries.Add(byStorySubType);

            EntityListResult<WorkItem> storiesAsWorkItems = entityService.Get<WorkItem>(workspaceContext, queries, null);
            Assert.AreEqual<int?>(stories.total_count, storiesAsWorkItems.total_count);
        }
コード例 #6
0
        private static String BuildPhraseString(QueryPhrase phrase)
        {
            String output = null;

            if (phrase is LogicalQueryPhrase)
            {
                LogicalQueryPhrase logicalPhrase = (LogicalQueryPhrase)phrase;

                List <String> expStrings = new List <string>();
                foreach (QueryExpression exp in logicalPhrase.Expressions)
                {
                    String comparisonOperator = GetComparisonOperatorString(exp.Operator);
                    String valueStr           = GetExpressionValueString(exp.Value);
                    String expStr             = String.Format("{0}{1}{2}", logicalPhrase.FieldName, comparisonOperator, valueStr);
                    expStrings.Add(expStr);
                }

                output = String.Join("||", expStrings);
                if (expStrings.Count > 1)
                {
                    output = "(" + output + ")";
                }

                if (logicalPhrase.NegativeCondition)
                {
                    output = "!" + output;
                }
            }
            else if (phrase is CrossQueryPhrase)
            {
                //release={id=5002}
                CrossQueryPhrase crossPhrase = (CrossQueryPhrase)phrase;
                String           expStr      = String.Format("{0}={{{1}}}", crossPhrase.FieldName, BuildPhraseString(crossPhrase.QueryPhrase));
                output = expStr;
            }
            else
            {
                throw new NotImplementedException();
            }
            return(output);
        }
コード例 #7
0
 public void GetWorkspaceRoleForWorkspaceTest()
 {
     LogicalQueryPhrase workspaceId = new LogicalQueryPhrase(Workspace.ID_FIELD, workspaceContext.WorkspaceId);
     CrossQueryPhrase byWorkpace = new CrossQueryPhrase(WorkspaceRole.WORKSPACE_FIELD, workspaceId);
     List<QueryPhrase> queries = new List<QueryPhrase>();
     queries.Add(byWorkpace);
     EntityListResult<WorkspaceRole> roles = entityService.Get<WorkspaceRole>(sharedSpaceContext, queries, null);
 }