Esempio n. 1
0
        public static async Task ToDTO_FieldIsYesNo_ReturnsCorrectValue(this IObjectManager manager, IHelper helper, int workspaceId, int docId)
        {
            //ARRANGE
            var fieldGuid = Guid.Parse(DocumentFieldDefinitions.YesNo);
            var client    = helper.GetRSAPIClient(workspaceId);

            client.Repositories.Document.UpdateSingle(new Document(docId)
            {
                Fields = new List <FieldValue>
                {
                    new FieldValue(fieldGuid, true)
                }
            });

            //ACT
            var obj = SharedTestCases.CreateTestObject(
                docId,
                new FieldRef(fieldGuid),
                true);
            var result = await manager.ReadAsync(workspaceId, obj, null);

            var dto        = result.ToDTODocument();
            var fieldValue = dto[fieldGuid].ValueAsYesNo;

            //ASSERT
            Assert.True(fieldValue);
            Assert.Equal(kCura.Relativity.Client.FieldType.YesNo, dto[fieldGuid].FieldType);
        }
Esempio n. 2
0
        public async Task UpdateAsync_CallingContextArtifactIdSet_ReturnsCorrectStatus()
        {
            //ARRANGE
            var fieldGuid = Guid.Parse(DocumentFieldDefinitions.FixedLength);

            _creation.Create(_fixture.WorkspaceId, 1);
            _installFixture.Init(_fixture.WorkspaceId, ApplicationInstallContext.FieldTestPath);
            var client = _fixture.Helper.GetServicesManager().CreateProxy <IRSAPIClient>(Relativity.API.ExecutionIdentity.System);

            client.APIOptions.WorkspaceID = _fixture.WorkspaceId;

            var query = new Query <Layout>();

            query.Condition = new TextCondition(LayoutFieldNames.TextIdentifier, TextConditionEnum.EqualTo, "Default Test Layout");
            query.Fields    = FieldValue.AllFields;
            var layout = client.Repositories.Layout.Query(query).Results.First().Artifact;

            //ACT
            var obj = SharedTestCases.CreateTestObject(
                _creation.DocIds.First(),
                new FieldRef(fieldGuid),
                "hello world");

            var result = await _manager.UpdateAsync(_fixture.WorkspaceId, obj, new Interfaces.CallingContext
            {
                Layout = new Interfaces.LayoutRef(layout.Name, layout.ArtifactID)
            });

            //ASSERT
            Assert.True(result.EventHandlerStatuses.All(x => x.Success));
        }
Esempio n. 3
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 <RelativityObject> ReadAsync_CallingContextSetLayoutHasPreload_ReturnsCorrectLoadedFields(this IObjectManager manager, IHelper helper, int workspaceId, int docId)
        {
            var fieldGuid = Guid.Parse(DocumentFieldDefinitions.LongText);

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

            client.APIOptions.WorkspaceID = workspaceId;

            var query = new Query <Layout>();

            query.Condition = new WholeNumberCondition(LayoutFieldNames.ObjectType, NumericConditionEnum.EqualTo, 10);
            query.Fields    = FieldValue.AllFields;
            var layout = client.Repositories.Layout.Query(query)
                         .Results
                         .First(x => x.Artifact.Guids.Contains(Guid.Parse(LayoutDefinitions.PreloadPopulatesLongText))).Artifact;

            var obj = SharedTestCases.CreateTestObject(
                docId,
                new FieldRef(fieldGuid),
                true);

            var result = await manager.ReadAsync(workspaceId, obj, new Interfaces.CallingContext
            {
                Layout = new Interfaces.LayoutRef(layout.Name, layout.ArtifactID)
            });

            return(result);
        }
        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);
        }
Esempio n. 7
0
        public static async Task ToDTO_FieldIsUser_ReturnsCorrectValue(this IObjectManager manager, IHelper helper, int workspaceId, int docId)
        {
            //ARRANGE
            var fieldGuid = Guid.Parse(DocumentFieldDefinitions.User);

            var client = helper.GetRSAPIClient(workspaceId);

            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 kCura.Relativity.Client.ObjectsCondition(UserFieldNames.Groups, kCura.Relativity.Client.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 value = userRes.Results.First().Artifact;

            client.APIOptions.WorkspaceID = workspaceId;
            client.Repositories.Document.UpdateSingle(new Document(docId)
            {
                Fields = new List <FieldValue>
                {
                    new FieldValue(fieldGuid, value)
                }
            });

            //ACT
            var obj = SharedTestCases.CreateTestObject(
                docId,
                new FieldRef(fieldGuid),
                true);
            var result = await manager.ReadAsync(workspaceId, obj, null);

            var dto        = result.ToDTODocument();
            var fieldValue = dto[fieldGuid].ValueAsUser;

            //ASSERT
            Assert.Equal(value.ArtifactID, fieldValue.ArtifactID);
            Assert.Equal(kCura.Relativity.Client.FieldType.User, dto[fieldGuid].FieldType);
        }
        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);
        }
Esempio n. 9
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);
        }
        public static async Task CreateAsync_SanityCheckRDO_ReturnsSuccess(this IObjectManager manager, IHelper helper, int workspaceId, Guid objectTypeGuid)
        {
            //ARRANGE
            var fieldGuid    = Guid.Parse(SingleObjectFieldDefinitions.LongText);
            var fieldValue   = "Asdf";
            var dbContext    = helper.GetDBContext(workspaceId);
            var sql          = "select o.[DescriptorArtifactTypeID] from [eddsdbo].[ObjectType] o join [eddsdbo].[ArtifactGuid] ag on o.artifactId = ag.ArtifactID where ag.ArtifactGuid = @guid";
            var objectTypeId = dbContext.ExecuteSqlStatementAsScalar <int?>(sql, new[] { new SqlParameter("@guid", objectTypeGuid) });

            var artifact = SharedTestCases.CreateTestObject(null, new FieldRef(fieldGuid), fieldValue, objectTypeId);

            //ACT
            var result = await manager.CreateAsync(workspaceId, artifact, null);

            artifact.ArtifactId = result.Object.ArtifactId;
            var readResult = await manager.ReadAsync(workspaceId, artifact, null);

            //ASSERT
            Assert.Equal(fieldValue, result.Object[fieldGuid].ValueAsString());
        }
Esempio n. 11
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
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
        public static async Task ToDTO_FieldIsMultiObject_ReturnsCorrectValue(this IObjectManager manager, IHelper helper, int workspaceId, int docId)
        {
            //ARRANGE
            var fieldGuid = Guid.Parse(DocumentFieldDefinitions.MultiObject);

            var client = helper.GetRSAPIClient(workspaceId);
            var rdo    = client.Repositories.RDO.CreateSingle(new RDO
            {
                ArtifactTypeGuids = new List <Guid> {
                    Guid.Parse(ObjectTypeGuids.MultiObject)
                },
                TextIdentifier = Guid.NewGuid().ToString()
            });
            var value = new RDO(rdo);

            client.Repositories.Document.UpdateSingle(new Document(docId)
            {
                Fields = new List <FieldValue>
                {
                    new FieldValue(fieldGuid, new FieldValueList <Artifact>(value))
                }
            });

            //ACT
            var obj = SharedTestCases.CreateTestObject(
                docId,
                new FieldRef(fieldGuid),
                true);
            var result = await manager.ReadAsync(workspaceId, obj, null);

            var dto        = result.ToDTODocument();
            var fieldValue = dto[fieldGuid].GetValueAsMultipleObject <Artifact>().First();

            //ASSERT
            Assert.Equal(value.ArtifactID, fieldValue.ArtifactID);
            Assert.Equal(kCura.Relativity.Client.FieldType.MultipleObject, dto[fieldGuid].FieldType);
        }
Esempio n. 14
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);
        }