// return all not done defects public static GroupResult GetAllDefectWithGroupBy(string releaseId) { List <String> fields = new List <string>(); fields.Add(WorkItem.NAME_FIELD); fields.Add(WorkItem.SUBTYPE_FIELD); List <QueryPhrase> queries = new List <QueryPhrase>(); LogicalQueryPhrase subtypeQuery = new LogicalQueryPhrase(WorkItem.SUBTYPE_FIELD, WorkItem.SUBTYPE_DEFECT); queries.Add(subtypeQuery); QueryPhrase releaseIdPhrase = new LogicalQueryPhrase("id", releaseId); QueryPhrase byReleasePhrase = new CrossQueryPhrase(WorkItem.RELEASE_FIELD, releaseIdPhrase); queries.Add(byReleasePhrase); LogicalQueryPhrase doneMetaphasePhrase = new LogicalQueryPhrase("logical_name", "metaphase.work_item.done"); NegativeQueryPhrase notDoneMetaphasePhrase = new NegativeQueryPhrase(doneMetaphasePhrase); CrossQueryPhrase phaseIdPhrase = new CrossQueryPhrase("metaphase", notDoneMetaphasePhrase); CrossQueryPhrase byPhasePhrase = new CrossQueryPhrase(WorkItem.PHASE_FIELD, phaseIdPhrase); queries.Add(byPhasePhrase); GroupResult result = SettingsForm.EntityService.GetWithGroupBy <WorkItem>(workspaceContext, queries, "severity"); return(result); }
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(sharedSpaceContext, userForUpdate); //READ USER List <String> fields = new List <string> { SharedspaceUser.NAME_FIELD, SharedspaceUser.WORKSPACE_ROLES_FIELD }; SharedspaceUser updatedUser = entityService.GetById <SharedspaceUser>(sharedSpaceContext, createdUser.Id, fields); List <EntityId> assignedWorkspaceRoles = updatedUser.WorkspaceRoles.data.Select(p => p.Id).ToList(); Assert.IsTrue(assignedWorkspaceRoles.Contains(sharedSpaceAdminRole.Id)); }
private void LoadWorkspaces(long sharedSpaceId) { WorkspaceContext defaultWorkspaceContext = new WorkspaceContext(sharedSpaceId, 1002); LogicalQueryPhrase byName = new LogicalQueryPhrase(WorkspaceUser.NAME_FIELD, txtName.Text); List <QueryPhrase> queries = new List <QueryPhrase>(); queries.Add(byName); EntityListResult <WorkspaceUser> users = EntityService.GetInstance().Get <WorkspaceUser>(defaultWorkspaceContext, queries, null); long userId = users.data[0].Id; SharedSpaceContext context = new SharedSpaceContext(sharedSpaceId); LogicalQueryPhrase byUserId = new LogicalQueryPhrase(WorkspaceUser.ID_FIELD, userId); CrossQueryPhrase byUser = new CrossQueryPhrase(Workspace.USERS_FIELD, byUserId); queries = new List <QueryPhrase>(); queries.Add(byUser); EntityListResult <Workspace> workspaces = EntityService.GetInstance().Get <Workspace>(context, queries, null); //User user = GetSharedSpaceUser(sharedSpaceId, txtName.Text); FillCombo <Workspace>(cmbWorkspace, workspaces.data); }
public static GroupResult GetAllDefectWithGroupBy(long releaseId) { List <String> fields = new List <string>(); fields.Add(WorkItem.NAME_FIELD); fields.Add(WorkItem.SUBTYPE_FIELD); List <QueryPhrase> queries = new List <QueryPhrase>(); LogicalQueryPhrase subtypeQuery = new LogicalQueryPhrase(WorkItem.SUBTYPE_FIELD, WorkItem.SUBTYPE_DEFECT); queries.Add(subtypeQuery); QueryPhrase releaseIdPhrase = new LogicalQueryPhrase("id", releaseId); QueryPhrase byReleasePhrase = new CrossQueryPhrase(WorkItem.RELEASE_FIELD, releaseIdPhrase); queries.Add(byReleasePhrase); LogicalQueryPhrase phaseNamePhrase = new LogicalQueryPhrase("name", "Done"); phaseNamePhrase.NegativeCondition = true; CrossQueryPhrase phaseIdPhrase = new CrossQueryPhrase("metaphase", phaseNamePhrase); CrossQueryPhrase byPhasePhrase = new CrossQueryPhrase(WorkItem.PHASE_FIELD, phaseIdPhrase); queries.Add(byPhasePhrase); GroupResult result = entityService.GetWithGroupBy <WorkItem>(workspaceContext, queries, "severity"); return(result); }
public static EntityListResult <WorkItem> GetStoriesByRelease(long releaseId) { List <String> fields = new List <string>(); fields.Add(WorkItem.NAME_FIELD); fields.Add(WorkItem.SUBTYPE_FIELD); List <QueryPhrase> queryPhrases = new List <QueryPhrase>(); List <QueryPhrase> queries = new List <QueryPhrase>(); LogicalQueryPhrase subtypeQuery = new LogicalQueryPhrase(WorkItem.SUBTYPE_FIELD, WorkItem.SUBTYPE_STORY); queryPhrases.Add(subtypeQuery); QueryPhrase releaseIdPhrase = new LogicalQueryPhrase("id", releaseId); QueryPhrase byReleasePhrase = new CrossQueryPhrase(WorkItem.RELEASE_FIELD, releaseIdPhrase); queryPhrases.Add(byReleasePhrase); LogicalQueryPhrase phaseNamePhrase = new LogicalQueryPhrase("name", "Done"); phaseNamePhrase.NegativeCondition = true; CrossQueryPhrase phaseIdPhrase = new CrossQueryPhrase("metaphase", phaseNamePhrase); CrossQueryPhrase byPhasePhrase = new CrossQueryPhrase(WorkItem.PHASE_FIELD, phaseIdPhrase); queryPhrases.Add(byPhasePhrase); EntityListResult <WorkItem> result = entityService.Get <WorkItem>(workspaceContext, queryPhrases, fields, 1); return(result); }
public void BuildCrossFieldNullPhrase() { var phrase = new CrossQueryPhrase("parent_suite", NullQueryPhrase.Null); var phrases = new List <QueryPhrase>(new[] { phrase }); string raw = QueryBuilder.BuildQueryString(phrases); Assert.AreEqual("query=\"parent_suite={null}\"", raw); }
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); }
public void DefectCoverageTest() { Test createdTest1 = TestManualTests.CreateManualTest(); Test createdTest2 = TestManualTests.CreateManualTest(); Test createdTest3 = TestManualTests.CreateManualTest(); Defect createdDefect = DefectTests.CreateDefect(); //create coverage Defect defectForUpdate = new Defect(createdDefect.Id); //add tests EntityList <Test> testList = new EntityList <Test>(); Test testForLink1 = new Test(createdTest1.Id); testForLink1.TypeName = "test"; testList.data.Add(testForLink1); Test testForLink2 = new Test(createdTest3.Id); testForLink2.TypeName = "test"; testList.data.Add(testForLink2); defectForUpdate.SetValue("test", testList); //define service arg, its required to add new relation instead of replace existing ones Dictionary <string, string> serviceArgs = new Dictionary <string, string>(); serviceArgs.Add("reference_update_mode", "append"); //actial update Defect updated = entityService.Update(workspaceContext, defectForUpdate, serviceArgs, null); //get test coverage List <QueryPhrase> queryPhrases = new List <QueryPhrase>(); QueryPhrase defectIdPhrase = new LogicalQueryPhrase(Release.ID_FIELD, createdDefect.Id); QueryPhrase coveredContentPhrase = new CrossQueryPhrase("covered_content", defectIdPhrase); queryPhrases.Add(coveredContentPhrase); EntityListResult <Test> coveredTests = entityService.Get <Test>(workspaceContext, queryPhrases, null); Assert.AreEqual(2, coveredTests.data.Count); //validation List <EntityId> coveredTestIds = coveredTests.data.ConvertAll <EntityId>(a => a.Id); Assert.IsTrue(coveredTestIds.Contains(testForLink1.Id)); Assert.IsTrue(coveredTestIds.Contains(testForLink2.Id)); }
public void GetMilestonesByReleaseTest() { Release release = CreateRelease(); Milestone created1 = CreateMilestone(release); Milestone created2 = CreateMilestone(release); List <QueryPhrase> queryPhrases = new List <QueryPhrase>(); QueryPhrase releaseIdPhrase = new LogicalQueryPhrase(Release.ID_FIELD, release.Id); QueryPhrase byReleasePhrase = new CrossQueryPhrase(Milestone.RELEASE_FIELD, releaseIdPhrase); queryPhrases.Add(byReleasePhrase); EntityListResult <Milestone> result = entityService.Get <Milestone>(workspaceContext, queryPhrases, null); Assert.AreEqual <int>(2, result.data.Count); }
public static EntityListResult <Milestone> GetMilestonesByRelease(string releaseId) { List <String> fields = new List <string>(); fields.Add(Milestone.NAME_FIELD); fields.Add(Milestone.DATE_FIELD); fields.Add(Milestone.RELEASE_FIELD); fields.Add(Milestone.DESCRIPTION_FIELD); List <QueryPhrase> queryPhrases = new List <QueryPhrase>(); QueryPhrase releaseIdPhrase = new LogicalQueryPhrase("id", releaseId); QueryPhrase byReleasePhrase = new CrossQueryPhrase(Milestone.RELEASE_FIELD, releaseIdPhrase); queryPhrases.Add(byReleasePhrase); EntityListResult <Milestone> result = SettingsForm.EntityService.Get <Milestone>(workspaceContext, queryPhrases, fields); return(result); }
public static WorkspaceRole GetWorkspaceAdminRole() { if (workspaceAdminRole == null) { LogicalQueryPhrase logicalNamePhrase = new LogicalQueryPhrase(Role.LOGICAL_NAME_FIELD, WorkspaceRole.WORKSPACE_ADMIN_ROLE_LOGICAL_NAME); CrossQueryPhrase byRole = new CrossQueryPhrase(WorkspaceRole.ROLE_FIELD, logicalNamePhrase); LogicalQueryPhrase workspaceIdPhrase = new LogicalQueryPhrase(Workspace.ID_FIELD, workspaceContext.WorkspaceId); CrossQueryPhrase byWorkpace = new CrossQueryPhrase(WorkspaceRole.WORKSPACE_FIELD, workspaceIdPhrase); List <QueryPhrase> queries = new List <QueryPhrase>(); queries.Add(byWorkpace); queries.Add(byRole); EntityListResult <WorkspaceRole> roles = entityService.Get <WorkspaceRole>(sharedSpaceContext, queries, null); workspaceAdminRole = roles.data[0]; Assert.AreEqual(WorkspaceRole.WORKSPACE_ADMIN_ROLE_LOGICAL_NAME, workspaceAdminRole.Role.LogicalName); Assert.AreEqual(workspaceContext.WorkspaceId.ToString(), workspaceAdminRole.Workspace.Id.ToString()); } return(workspaceAdminRole); }
public static EntityListResult <Sprint> GetSprintsByRelease(string releaseId) { List <String> fields = new List <string>(); fields.Add(Sprint.NAME_FIELD); fields.Add(Sprint.START_DATE_FIELD); fields.Add(Sprint.END_DATE_FIELD); fields.Add(Sprint.RELEASE_FIELD); List <QueryPhrase> queryPhrases = new List <QueryPhrase>(); QueryPhrase releaseIdPhrase = new LogicalQueryPhrase("id", releaseId); QueryPhrase byReleasePhrase = new CrossQueryPhrase(Sprint.RELEASE_FIELD, releaseIdPhrase); queryPhrases.Add(byReleasePhrase); EntityListResult <Sprint> result = SettingsForm.EntityService.Get <Sprint>(workspaceContext, queryPhrases, fields); //Release release = result.data[0].Release; return(result); }
public void GetNotCompletedDefectsAssinedToReleaseTest() { Defect defect = CreateDefect(); Release release = CreateRelease(); //assign defect to release Defect defectForUpdate = new Defect(defect.Id); defectForUpdate.Release = release; entityService.Update <Defect>(workspaceContext, defectForUpdate); Defect defectAfterUpdate = entityService.GetById <Defect>(workspaceContext, defect.Id, null); Assert.AreEqual <long>(release.Id, defectAfterUpdate.Release.Id); //Fetch all defects that assigned to release and still not done //Fetch defects as work-items List <QueryPhrase> queries = new List <QueryPhrase>(); LogicalQueryPhrase subtypeQuery = new LogicalQueryPhrase(WorkItem.SUBTYPE_FIELD, WorkItem.SUBTYPE_DEFECT); queries.Add(subtypeQuery); //condition of release QueryPhrase releaseIdPhrase = new LogicalQueryPhrase(WorkItem.ID_FIELD, release.Id); QueryPhrase byReleasePhrase = new CrossQueryPhrase(WorkItem.RELEASE_FIELD, releaseIdPhrase); queries.Add(byReleasePhrase); //condition by metaphase (parent of phase) LogicalQueryPhrase phaseNamePhrase = new LogicalQueryPhrase(WorkItem.NAME_FIELD, "Done"); phaseNamePhrase.NegativeCondition = true;//not Done CrossQueryPhrase phaseIdPhrase = new CrossQueryPhrase("metaphase", phaseNamePhrase); CrossQueryPhrase byPhasePhrase = new CrossQueryPhrase(WorkItem.PHASE_FIELD, phaseIdPhrase); queries.Add(byPhasePhrase); EntityListResult <WorkItem> entitiesResult = entityService.Get <WorkItem>(workspaceContext, queries, null); Assert.AreEqual <int>(1, entitiesResult.total_count.Value); Assert.AreEqual <long>(defect.Id, entitiesResult.data[0].Id); }
public void GetSprintsByReleaseTest() { Release release = CreateRelease(); List <String> fields = new List <string>(); fields.Add(Sprint.NAME_FIELD); fields.Add(Sprint.START_DATE_FIELD); fields.Add(Sprint.END_DATE_FIELD); fields.Add(Sprint.RELEASE_FIELD); List <QueryPhrase> queryPhrases = new List <QueryPhrase>(); QueryPhrase releaseIdPhrase = new LogicalQueryPhrase(Release.ID_FIELD, release.Id); QueryPhrase byReleasePhrase = new CrossQueryPhrase(Sprint.RELEASE_FIELD, releaseIdPhrase); queryPhrases.Add(byReleasePhrase); EntityListResult <Sprint> result = entityService.Get <Sprint>(workspaceContext, queryPhrases, fields); Assert.IsTrue(result.data.Count >= 1); Release releaseFromSprint = result.data[0].Release; Assert.AreEqual(release.Id, releaseFromSprint.Id); }
public void GetNotDoneDefectsAssinedToReleaseTest() { Phase PHASE_CLOSED = TestHelper.GetPhaseForEntityByLogicalName(entityService, workspaceContext, WorkItem.SUBTYPE_DEFECT, "phase.defect.closed"); Defect defect1 = CreateDefect(); Defect defect2 = CreateDefect(PHASE_CLOSED); Defect defect3 = CreateDefect(); Defect defect4 = CreateDefect(); Release release = ReleaseTests.CreateRelease(); //assign defect to release Defect defectForUpdate1 = new Defect(defect1.Id); defectForUpdate1.Release = release; Defect defectForUpdate2 = new Defect(defect2.Id); defectForUpdate2.Release = release; Defect defectForUpdate3 = new Defect(defect3.Id); defectForUpdate3.Release = release; defectForUpdate3.Severity = getSeverityCritical(); Defect defectForUpdate4 = new Defect(defect4.Id); defectForUpdate4.Release = release; EntityList <Defect> listForUpdate = new EntityList <Defect>(); listForUpdate.data.AddRange(new Defect[] { defectForUpdate1, defectForUpdate2, defectForUpdate3, defectForUpdate4 }); EntityListResult <Defect> updated = entityService.UpdateEntities <Defect>(workspaceContext, listForUpdate); Assert.AreEqual <int?>(4, updated.total_count); //Fetch all defects that assigned to release and still not done //Fetch defects as work-items List <QueryPhrase> queries = new List <QueryPhrase>(); LogicalQueryPhrase subtypeQuery = new LogicalQueryPhrase(WorkItem.SUBTYPE_FIELD, WorkItem.SUBTYPE_DEFECT); queries.Add(subtypeQuery); //condition of release QueryPhrase releaseIdPhrase = new LogicalQueryPhrase(WorkItem.ID_FIELD, release.Id); QueryPhrase byReleasePhrase = new CrossQueryPhrase(WorkItem.RELEASE_FIELD, releaseIdPhrase); queries.Add(byReleasePhrase); //There are several phased in "Done" metaphase - there are we are doing condition on metaphase and not on phase //condition by metaphase (parent of phase) LogicalQueryPhrase donePhaseNamePhrase = new LogicalQueryPhrase(Metaphase.LOGICAL_NAME_FIELD, "metaphase.work_item.done"); NegativeQueryPhrase notDonePhrase = new NegativeQueryPhrase(donePhaseNamePhrase); CrossQueryPhrase phaseIdPhrase = new CrossQueryPhrase("metaphase", notDonePhrase); CrossQueryPhrase byPhasePhrase = new CrossQueryPhrase(WorkItem.PHASE_FIELD, phaseIdPhrase); queries.Add(byPhasePhrase); EntityListResult <WorkItem> entitiesResult = entityService.Get <WorkItem>(workspaceContext, queries, null); Assert.AreEqual <int>(3, entitiesResult.total_count.Value); Assert.IsTrue(entitiesResult.data[0].Id == defect1.Id || entitiesResult.data[0].Id == defect3.Id || entitiesResult.data[0].Id == defect4.Id); Assert.IsTrue(entitiesResult.data[1].Id == defect1.Id || entitiesResult.data[1].Id == defect3.Id || entitiesResult.data[1].Id == defect4.Id); Assert.IsTrue(entitiesResult.data[2].Id == defect1.Id || entitiesResult.data[2].Id == defect3.Id || entitiesResult.data[2].Id == defect4.Id); //check group by GroupResult groupResult = entityService.GetWithGroupBy <WorkItem>(workspaceContext, queries, "severity"); Assert.AreEqual(2, groupResult.groupsTotalCount); Group group1 = groupResult.groups[0]; Group group2 = groupResult.groups[1]; if (group1.count == 1) { Group temp = group1; group1 = group2; group2 = temp; } Assert.AreEqual <int>(2, group1.count); Assert.AreEqual <String>("list_node.severity.high", group1.value.logical_name); Assert.AreEqual <int>(1, group2.count); Assert.AreEqual <String>("list_node.severity.urgent", group2.value.logical_name); }