예제 #1
0
        public async Task UpdateAsync_UpdateMultiChoiceByGuidUsingChoiceGuid_ReturnsSuccess()
        {
            //ARRANGE
            var fieldGuid = Guid.Parse(DocumentFieldDefinitions.Multichoice);

            _creation.Create(_fixture.WorkspaceId, 1);

            //ACT
            var value = new List <ChoiceRef> {
                new ChoiceRef(Guid.Parse(MultiChoiceChoiceDefinitions.Multi1)),
                new ChoiceRef(Guid.Parse(MultiChoiceChoiceDefinitions.Multi2))
            };

            var(uResult, result) = await SharedTestCases.RunUpdateTestAsync(_manager,
                                                                            _fixture.WorkspaceId,
                                                                            _creation.DocIds.First(),
                                                                            new FieldRef(fieldGuid),
                                                                            value);

            //ASSERT
            Assert.True(uResult.EventHandlerStatuses.All(x => x.Success));
            Assert.Equal(_creation.DocIds.Single(), result.ArtifactId);
            Assert.Contains(result.FieldValues, (f) => f.Field.Guids.Contains(fieldGuid));
            Assert.Equal(value.First().Guids.First(), result[fieldGuid].ValueAsMultiChoice().First().Guids.First());
            Assert.Equal(value.Last().Guids.First(), result[fieldGuid].ValueAsMultiChoice().Last().Guids.First());
        }
        public static async Task UpdateAsync_UpdateMultiChoiceByGuidUsingChoiceArtifactId_ReturnsSuccess(this IObjectManager manager, IHelper helper, int workspaceId, int docId)
        {
            //ARRANGE
            var fieldGuid = Guid.Parse(DocumentFieldDefinitions.Multichoice);

            var client = helper.GetServicesManager().CreateProxy <IRSAPIClient>(Relativity.API.ExecutionIdentity.System);

            client.APIOptions.WorkspaceID = workspaceId;
            var choice1 = client.Repositories.Choice.ReadSingle(Guid.Parse(MultiChoiceChoiceDefinitions.Multi1));
            var choice2 = client.Repositories.Choice.ReadSingle(Guid.Parse(MultiChoiceChoiceDefinitions.Multi2));

            //ACT
            var value = new List <ChoiceRef> {
                new ChoiceRef(choice1.ArtifactID),
                new ChoiceRef(choice2.ArtifactID)
            };

            var(uResult, result) = await SharedTestCases.RunUpdateTestAsync(manager,
                                                                            workspaceId,
                                                                            docId,
                                                                            new FieldRef(fieldGuid),
                                                                            value);

            //ASSERT
            Assert.True(uResult.EventHandlerStatuses.All(x => x.Success));
            Assert.Equal(docId, result.ArtifactId);
            Assert.Contains(result.FieldValues, (f) => f.Field.Guids.Contains(fieldGuid));
            Assert.Equal(choice1.ArtifactID, result[fieldGuid].ValueAsMultiChoice().First().ArtifactId);
            Assert.Equal(choice2.ArtifactID, result[fieldGuid].ValueAsMultiChoice().Last().ArtifactId);
        }
        public static async Task UpdateAsync_UpdateSingleObjectByArtifactId_ReturnsSuccess(this IObjectManager manager, IHelper helper, int workspaceId, int docId)
        {
            //ARRANGE
            var fieldGuid = Guid.Parse(DocumentFieldDefinitions.SingleObject);
            var client    = helper.GetServicesManager().CreateProxy <IRSAPIClient>(Relativity.API.ExecutionIdentity.System);

            client.APIOptions.WorkspaceID = workspaceId;
            var obj = client.Repositories.RDO.CreateSingle(new RDO
            {
                ArtifactTypeGuids = new List <Guid> {
                    Guid.Parse(ObjectTypeGuids.SingleObject)
                },
                TextIdentifier = Guid.NewGuid().ToString()
            });

            //ACT
            var value = new RelativityObject()
            {
                ArtifactId = obj
            };

            var(uResult, result) = await SharedTestCases.RunUpdateTestAsync(manager,
                                                                            workspaceId,
                                                                            docId,
                                                                            new FieldRef(fieldGuid),
                                                                            value);

            //ASSERT
            Assert.True(uResult.EventHandlerStatuses.All(x => x.Success));
            Assert.Equal(docId, result.ArtifactId);
            Assert.Contains(result.FieldValues, (f) => f.Field.Guids.Contains(fieldGuid));
            Assert.Equal(obj, result[fieldGuid].ValueAsSingleObject().ArtifactId);
        }
        public static async Task UpdateAsync_UpdateUserByArtifactId_ReturnsSuccess(this IObjectManager manager, IHelper helper, int workspaceId, int docId, string userName)
        {
            //ARRANGE
            var fieldGuid = Guid.Parse(DocumentFieldDefinitions.User);
            var client    = helper.GetServicesManager().CreateProxy <IRSAPIClient>(Relativity.API.ExecutionIdentity.System);

            client.APIOptions.WorkspaceID = -1;

            var q = new Query <Group>();

            q.ArtifactTypeID = (int)kCura.Relativity.Client.ArtifactType.Group;
            q.Condition      = new kCura.Relativity.Client.CompositeCondition(new kCura.Relativity.Client.WholeNumberCondition(GroupFieldNames.GroupType, kCura.Relativity.Client.NumericConditionEnum.EqualTo, 2),
                                                                              kCura.Relativity.Client.CompositeConditionEnum.And,
                                                                              new kCura.Relativity.Client.ObjectsCondition(GroupFieldNames.Workspaces, kCura.Relativity.Client.ObjectsConditionEnum.AnyOfThese, new int[] { workspaceId }));
            var res = client.Repositories.Group.Query(q);

            var userQ = new Query <kCura.Relativity.Client.DTOs.User>();

            userQ.Condition = new ObjectsCondition(UserFieldNames.Groups, ObjectsConditionEnum.AnyOfThese, res.Results.Select(x => x.Artifact.ArtifactID).ToList());
            var userRes = client.Repositories.User.Query(userQ);

            if (userRes.TotalCount < 1)
            {
                //ideally you'd create a user in this but that's too much for the scope of this work
                throw new NotSupportedException("No user to run this test, please create a non system admin and ensure the group is assigned to the workspace.");
            }
            var userId = userRes.Results.First().Artifact.ArtifactID;
            //ACT
            var value = new RelativityObject()
            {
                ArtifactId = userId
            };

            var(uResult, result) = await SharedTestCases.RunUpdateTestAsync(manager,
                                                                            workspaceId,
                                                                            docId,
                                                                            new FieldRef(fieldGuid),
                                                                            value);

            //ASSERT
            Assert.True(uResult.EventHandlerStatuses.All(x => x.Success));
            Assert.Equal(docId, result.ArtifactId);
            Assert.Contains(result.FieldValues, (f) => f.Field.Guids.Contains(fieldGuid));
            Assert.Equal(userId, result[fieldGuid].ValueAsSingleObject().ArtifactId);
        }
예제 #5
0
        public async Task UpdateAsync_UpdateFieldByName_ReturnsSuccess(string fieldGuidString, object value, object expected)
        {
            //ARRANGE
            var client = _fixture.Helper.GetServicesManager().CreateProxy <IRSAPIClient>(Relativity.API.ExecutionIdentity.System);

            client.APIOptions.WorkspaceID = _fixture.WorkspaceId;
            _creation.Create(_fixture.WorkspaceId, 1);

            var fieldGuid = Guid.Parse(fieldGuidString);
            var field     = client.Repositories.Field.ReadSingle(fieldGuid);

            //ACT
            var(uResult, result) = await SharedTestCases.RunUpdateTestAsync(_manager, _fixture.WorkspaceId, _creation.DocIds.First(), new FieldRef(field.ArtifactID), value);

            //ASSERT
            Assert.True(uResult.EventHandlerStatuses.All(x => x.Success));
            Assert.Equal(_creation.DocIds.Single(), result.ArtifactId);
            Assert.Contains(result.FieldValues, (f) => f.Field.Name == field.Name);
            Assert.Equal(expected, result[field.Name].Value);
        }
예제 #6
0
        public async Task UpdateAsync_UpdateSingleChoiceByGuidUsingChoiceGuid_ReturnsSuccess()
        {
            //ARRANGE
            var fieldGuid = Guid.Parse(DocumentFieldDefinitions.SingleChoice);

            //ACT
            var value = new ChoiceRef(Guid.Parse(SingleChoiceChoiceDefinitions.Single1));

            var(uResult, result) = await SharedTestCases.RunUpdateTestAsync(_manager,
                                                                            _fixture.WorkspaceId,
                                                                            _creation.DocIds.First(),
                                                                            new FieldRef(fieldGuid),
                                                                            value);

            //ASSERT
            Assert.True(uResult.EventHandlerStatuses.All(x => x.Success));
            Assert.Equal(_creation.DocIds.Single(), result.ArtifactId);
            Assert.Contains(result.FieldValues, (f) => f.Field.Guids.Contains(fieldGuid));
            Assert.Empty(result[fieldGuid].ValueAsSingleChoice().Guids); //this is by design it's how Relativity works
        }
예제 #7
0
        public async Task UpdateAsync_UpdateFieldByGuid_ReturnsSuccess(string fieldGuidString, object value, object expected)
        {
            //ARRANGE
            var fieldGuid = Guid.Parse(fieldGuidString);

            _creation.Create(_fixture.WorkspaceId, 1);
            _installFixture.Init(_fixture.WorkspaceId, ApplicationInstallContext.FieldTestPath);

            //ACT
            var(uResult, result) = await SharedTestCases.RunUpdateTestAsync(
                _manager,
                _fixture.WorkspaceId,
                _creation.DocIds.First(),
                new FieldRef(fieldGuid), value);

            //ASSERT
            Assert.True(uResult.EventHandlerStatuses.All(x => x.Success));
            Assert.Equal(_creation.DocIds.Single(), result.ArtifactId);
            Assert.Contains(result.FieldValues, (f) => f.Field.Guids.Contains(fieldGuid));
            Assert.Equal(expected, result[fieldGuid].Value);
        }
예제 #8
0
        public async Task UpdateAsync_UpdateSingleChoiceByGuidUsingChoiceArtifactId_ReturnsSuccess()
        {
            //ARRANGE
            var fieldGuid = Guid.Parse(DocumentFieldDefinitions.SingleChoice);
            var client    = _fixture.Helper.GetServicesManager().CreateProxy <IRSAPIClient>(Relativity.API.ExecutionIdentity.System);

            client.APIOptions.WorkspaceID = _fixture.WorkspaceId;
            var choice = client.Repositories.Choice.ReadSingle(Guid.Parse(SingleChoiceChoiceDefinitions.Single1));

            //ACT
            var value = new ChoiceRef(choice.ArtifactID);

            var(uResult, result) = await SharedTestCases.RunUpdateTestAsync(_manager,
                                                                            _fixture.WorkspaceId,
                                                                            _creation.DocIds.First(),
                                                                            new FieldRef(fieldGuid),
                                                                            value);

            //ASSERT
            Assert.True(uResult.EventHandlerStatuses.All(x => x.Success));
            Assert.Equal(_creation.DocIds.Single(), result.ArtifactId);
            Assert.Contains(result.FieldValues, (f) => f.Field.Guids.Contains(fieldGuid));
            Assert.Equal(choice.ArtifactID, result[fieldGuid].ValueAsSingleChoice().ArtifactId);
        }