public async Task FileSharing_WithUnauthorizeUser_ReturnsExpectedImageRecord()
        {
            var nodeRecordResponse = await JohnApi.GetNodesById(FileId);

            var nodeRecord = JArray.Parse(await nodeRecordResponse.Content.ReadAsStringAsync()).First();

            var nodeRecordId   = nodeRecord["id"].ToObject <Guid>();
            var recordResponse = await JohnApi.GetRecordEntityById(nodeRecordId);

            var record   = JObject.Parse(await recordResponse.Content.ReadAsStringAsync());
            var recordId = record["id"].ToObject <Guid>();
            var imageId  = record["images"].First()["id"].ToObject <Guid>();

            var blobResponse = await UnauthorizedApi.GetImagesRecordEntityById(recordId, imageId);

            blobResponse.EnsureSuccessStatusCode();
            blobResponse.StatusCode.Should().Be(HttpStatusCode.OK);
            blobResponse.Content.Headers.ContentType.MediaType.Should().Be("application/octet-stream");
            blobResponse.Content.Headers.ContentLength.Should().BeGreaterThan(10000);
            blobResponse.Content.Headers.ContentDisposition.FileName.Should().Be("Aspirin.mol.svg");
        }
示例#2
0
        public async Task MlProcessing_ModelTraining_AllGenericFilesPersisted()
        {
            var files = Harness.GetDependentFiles(FolderId, FileType.Image, FileType.Tabular, FileType.Pdf);

            foreach (var id in files)
            {
                var fileResponse     = JohnApi.GetFileEntityById(id).Result;
                var fileJson         = JToken.Parse(fileResponse.Content.ReadAsStringAsync().Result);
                var fileNodeResponse = JohnApi.GetNodeById(id).Result;
                fileNodeResponse.EnsureSuccessStatusCode();
                fileJson["status"].ToObject <string>().Should().BeEquivalentTo("Processed");

                var jsonNode = JToken.Parse(fileNodeResponse.Content.ReadAsStringAsync().Result);
                jsonNode.Should().NotBeEmpty();
                jsonNode.Should().ContainsJson($@"
                {{
                    'id': '{fileJson["id"].ToObject<Guid>()}',
                    'type': 'File',
                    'subType': *EXIST*,
                    'blob': *EXIST*,
                    'status': '{fileJson["status"].ToObject<string>()}',
                    'ownedBy': '{JohnId}',
                    'createdBy': '{JohnId}',
                    'createdDateTime': *EXIST*,
                    'updatedBy': '{JohnId}',
                    'updatedDateTime': *EXIST*,
                    'name': '{fileJson["name"].ToObject<string>()}',
                    'parentId': '{fileJson["parentId"].ToObject<Guid>()}',
                    'version': {fileJson["version"].ToObject<int>()}
                }}");

                if (fileJson.Contains("images") && jsonNode.Contains("images"))
                {
                    jsonNode["images"].Should().BeEquivalentTo(fileJson["images"]);
                }
            }
            ;

            await Task.CompletedTask;
        }
        public async Task ReactionProcessing_ValidRnx_GenerateExpectedFileEntity()
        {
            var blobInfo = await BlobStorage.GetFileInfo(BlobId, JohnId.ToString());

            blobInfo.Should().NotBeNull();

            var fileEntityResponse = await JohnApi.GetFileEntityById(FileId);

            var fileEntity = JsonConvert.DeserializeObject <JObject>(await fileEntityResponse.Content.ReadAsStringAsync());

            fileEntity.Should().ContainsJson($@"
			{{
				'id': '{FileId}',
				'blob': {{
					'id': '{blobInfo.Id}',
					'bucket': '{JohnId}',
					'length': {blobInfo.Length},
					'md5': '{blobInfo.MD5}'
				}},
				'subType': '{FileType.Records}',
				'ownedBy': '{JohnId}',
				'createdBy': '{JohnId}',
				'createdDateTime': '{DateTime.UtcNow}',
				'updatedBy': '{JohnId}',
				'updatedDateTime': '{DateTime.UtcNow}',
				'parentId': '{JohnId}',
				'name': '{blobInfo.FileName}',
				'status': '{FileStatus.Processed}',
				'version': *EXIST*,
				'totalRecords': 1,
				'properties': {{
					'fields': [
						'Field1',
						'Field2'
					]
				}}
			}}"            );
            fileEntity["images"].Should().NotBeNull();
            fileEntity["images"].Should().HaveCount(1);
        }
示例#4
0
        public async Task FileSharing_WithAuthorizeUser_ReturnsExpectedBlobFileAndRecord()
        {
            var nodeRecordResponse = await JohnApi.GetNodesById(FileId);

            var nodeRecord = JArray.Parse(await nodeRecordResponse.Content.ReadAsStringAsync()).First();

            var nodeRecordId   = nodeRecord["id"].ToObject <Guid>();
            var recordResponse = await JohnApi.GetRecordEntityById(nodeRecordId);

            var record             = JObject.Parse(await recordResponse.Content.ReadAsStringAsync());
            var recordId           = record["id"].ToObject <Guid>();
            var recordBlobId       = record["blob"]["id"].ToObject <Guid>();
            var blobRecordResponse = await JohnApi.GetBlobRecordEntityById(recordId, recordBlobId);

            var recordString = await blobRecordResponse.Content.ReadAsStringAsync();

            var blobFileResponse = await UnauthorizedApi.GetBlobFileEntityById(FileId, BlobId);

            var fileString = await blobFileResponse.Content.ReadAsStringAsync();

            recordString.Should().BeEquivalentTo(fileString);
        }
示例#5
0
        public GetAllCategoryTrees(OsdrWebTestHarness fixture, ITestOutputHelper output) : base(fixture, output)
        {
            var categories = new List <TreeNode>()
            {
                new TreeNode("Projects", new List <TreeNode>()
                {
                    new TreeNode("Projects One"),
                    new TreeNode("Projects Two")
                })
            };

            for (int i = 0; i < 10; i++)
            {
                var response = JohnApi.PostData("/api/categorytrees/tree", categories).Result;

                var content = response.Content.ReadAsStringAsync().Result;

                var categoryId = Guid.Parse(content);

                Harness.WaitWhileCategoryTreePersisted(categoryId);
            }
        }
示例#6
0
        public async Task MlProcessing_InvalidModelTraining_WaitsWhileAllAssociatedGenericFilesProcessed()
        {
            var modelId = await Fixture.GetDependentFilesExcept(FolderId, FileType.Image, FileType.Pdf, FileType.Tabular);

            modelId.Should().HaveCount(1);
            modelId.SingleOrDefault().Should().NotBeEmpty();

            var dependentFiles = Fixture.GetDependentFiles(modelId.Single()).ToList();

            dependentFiles.Should().HaveCount(2);

            dependentFiles.ToList().ForEach(async id =>
            {
                var fileResponse = await JohnApi.GetFileEntityById(id);
                fileResponse.EnsureSuccessStatusCode();

                var jsonFile = JToken.Parse(await fileResponse.Content.ReadAsStringAsync());
                jsonFile["status"].Should().BeEquivalentTo("Processed");
            });

            await Task.CompletedTask;
        }
示例#7
0
        public async Task FileSharing_WithAuthorizeUser_ReturnsExpectedAllNodes()
        {
            var fileResponse = await JohnApi.GetNodes();

            var nodes = JToken.Parse(await fileResponse.Content.ReadAsStringAsync());

            nodes.Should().HaveCount(4);

            var fileNames = new[]
            {
                "ringcount_0.mol",
                "Aspirin.mol"
            };

            foreach (var node in nodes)
            {
                if (node["type"].ToObject <string>() == "File")
                {
                    fileNames.Contains(node["name"].ToObject <string>()).Should().BeTrue();
                }
            }
        }
示例#8
0
        public async Task CategoryTree_CreateNewCategoryTree_BuiltExpectedDocument()
        {
            var contentRequest = await JohnApi.GetData($"/api/categorytrees/tree/{CategoryId}");

            var jsonCategory = await contentRequest.Content.ReadAsJObjectAsync();

            jsonCategory.Should().HaveElement("id");
            jsonCategory["id"].Value <string>().Should().Be(CategoryId.ToString());

            jsonCategory.Should().HaveElement("createdBy");
            jsonCategory["createdBy"].Value <string>().Should().Be(JohnId.ToString());

            jsonCategory.Should().HaveElement("createdDateTime")
            .And.HaveElement("createdDateTime")
            .And.HaveElement("updatedDateTime");

            jsonCategory.Should().HaveElement("version");
            jsonCategory["version"].Value <int>().Should().Be(1);

            jsonCategory.Should().HaveElement("nodes");
            var treeNodes = jsonCategory["nodes"].Value <JArray>();

            treeNodes.Should().HaveCount(1);
            var mainNode = treeNodes.Single();

            mainNode.Should().HaveElement("title");
            mainNode["title"].Value <string>().Should().Be("Projects");
            var insideNodes = mainNode["children"].Value <JArray>();

            insideNodes.Should().HaveCount(2);
            var titles = insideNodes.Select(i => i["title"].Value <string>());

            titles.Should().Contain(new List <string> {
                "Projects One", "Projects Two"
            });
            insideNodes[0].Should().HaveElement("id");
            insideNodes[1].Should().HaveElement("id");
        }
        public async Task CategoryTree_UpdateCategoryTreeNode_UpdatedCategoryMayBeExpectedDocument()
        {
            var response = await JohnApi.PutData($"/api/categorytrees/tree/{CategoryId}/{NodeId}", Categories);

            Harness.WaitWhileCategoryTreeUpdatedPersisted(CategoryId);

            response = await JohnApi.GetData($"/api/categorytrees/tree/{CategoryId}");

            response.EnsureSuccessStatusCode();

            var jsonCategory = JToken.Parse(await response.Content.ReadAsStringAsync());

            jsonCategory.Should().ContainsJson($@"
            {{
                'id': '{CategoryId}',
                'createdBy': '{JohnId}',
                'createdDateTime': *EXIST*,
                'updatedBy': '{JohnId}',
                'updatedDateTime': *EXIST*,
                'version': 2,
                'nodes': *EXIST*
            }}");
        }
示例#10
0
        public async Task CrystalProcessing_ValidMol_GenerateExpectedRecordNode()
        {
            var recordResponse = await JohnApi.GetNodesById(FileId);

            var recordNodes = JsonConvert.DeserializeObject <JArray>(await recordResponse.Content.ReadAsStringAsync());
            var recordId    = recordNodes.First()["id"].ToObject <Guid>();

            recordId.Should().NotBeEmpty();

            var recordNodeResponse = await JohnApi.GetNodeById(recordId);

            var recordNode = JsonConvert.DeserializeObject <JObject>(await recordNodeResponse.Content.ReadAsStringAsync());

            recordNode.Should().NotBeEmpty();

            recordNode.Should().ContainsJson($@"
			{{
                'id': '{recordId}',
				'type': 'Record',
				'subType': 'Crystal',
				'name': 0,
				'blob': {{
					'bucket': '{JohnId}'
				}},
				'ownedBy':'{JohnId}',
				'createdBy':'{JohnId}',
				'createdDateTime': '{DateTime.UtcNow}',
				'updatedBy':'{JohnId}',
				'updatedDateTime': '{DateTime.UtcNow}',
				'parentId': '{FileId}',
				'version': *EXIST*,
				'status': '{FileStatus.Processed}',
			}}"            );

            recordNode["images"].Should().NotBeNull();
            recordNode["images"].Should().HaveCount(3);
        }
示例#11
0
        public async Task MlProcessing_ModelTraining_AllGenericFilesProcessed()
        {
            var models = Harness.GetDependentFilesExcept(FolderId, FileType.Image, FileType.Tabular, FileType.Pdf);

            foreach (var modelId in models)
            {
                var model = await Session.Get <Model>(modelId);

                model.Should().NotBeNull();
                model.Status.Should().Be(ModelStatus.Processed);

                await JohnApi.SetPublicModelsEntity(modelId, true);

                Harness.WaitWhileModelShared(modelId);

                var responseSSP = await JohnApi.CreateSingleStructurePridiction(new RunSingleStructurePrediction
                {
                    Format   = "SMILES",
                    ModelIds = new List <Guid> {
                        modelId
                    },
                    PropertyName = "name",
                    Structure    = "C1C=CC=C1C1C=CC=C1"
                });

                var predictionId = JToken.Parse(await responseSSP.Content.ReadAsStringAsync())["predictionId"].ToObject <Guid>();
                responseSSP.EnsureSuccessStatusCode();

                var responseStatus = await JohnApi.GetPredictionStatus(predictionId);

                var status = JToken.Parse(await responseStatus.Content.ReadAsStringAsync());
                status["id"].ToObject <Guid>().ShouldBeEquivalentTo(predictionId);
//                status["status"].ToObject<string>().ShouldAllBeEquivalentTo("CALCULATING");
            }

            await Task.CompletedTask;
        }
示例#12
0
        public async Task UpdateMetadata_UpdateGenericMetadata_ExpectedRenamedFolder()
        {
            var processedFile = await Harness.Session.Get <File>(FileId);

            var url = $"/api/entities/files/{FileId}?version={processedFile.Version}";

            var data = $"[{{'op':'replace','path':'Metadata','value':[{{'name':'test1', 'value': 'value1'}}]}}]";

            JohnApi.PatchData(url, data).Wait();

            Harness.WaitMetadataUpdated(FileId);

            var response = await JohnApi.GetFileEntityById(FileId);

            response.EnsureSuccessStatusCode();
            var json = JToken.Parse(await response.Content.ReadAsStringAsync());

            json.Should().ContainsJson($@"
            {{
                'id': '{FileId}',
                'createdBy': '{JohnId}',
                'createdDateTime': *EXIST*,
                'updatedBy': '{JohnId}',
                'updatedDateTime': *EXIST*,
                'ownedBy': '{JohnId}',
                'version': 8,
                'properties': {{
                    'metadata':
                    [
                        {{ 
                            'name': 'test1',
                            'value': 'value1'
                        }}
                    ]
                }}
            }}");
        }
示例#13
0
        public async Task CategoryTreeOperations_GetAllCategoryTrees_ExpectedListOfCategories()
        {
            var response = await JohnApi.GetData($"/api/categorytrees/tree");

            response.EnsureSuccessStatusCode();

            var content = await response.Content.ReadAsStringAsync();

            var jsonCategories = JArray.Parse(await response.Content.ReadAsStringAsync());

            jsonCategories.Should().NotBeEmpty();
            foreach (var category in jsonCategories.Children())
            {
                category.Should().ContainsJson($@"
                {{
                    'id': *EXIST*,
                    'createdBy': '{JohnId}',
                    'createdDateTime': *EXIST*,
                    'updatedBy': '{JohnId}',
                    'updatedDateTime': *EXIST*,
                    'version': *EXIST*
                }}");
            }
        }
示例#14
0
        public async Task FolderOperation_RenameFolder_ExpectedRenamedFolder()
        {
            await JohnApi.RenameFolder(_folderId, "renamed folder");

            Harness.WaitWhileFolderRenamed(_folderId);

            var response = await JohnApi.GetFolder(_folderId);

            response.EnsureSuccessStatusCode();
            var jsonFolder = JToken.Parse(await response.Content.ReadAsStringAsync());

            jsonFolder.Should().ContainsJson($@"
			{{
				'id': '{_folderId}',
				'createdBy': '{JohnId}',
				'createdDateTime': *EXIST*,
				'updatedBy': '{JohnId}',
				'updatedDateTime': *EXIST*,
				'ownedBy': '{JohnId}',
				'name': 'renamed folder',
				'status': 'Created',
				'version': 2
			}}"            );
        }
示例#15
0
        public async Task CategoryTree_UpdateCategoryTreeNode_UpdatedCategoryMayBeExpectedDocument()
        {
            var json = $@"[
              {{
                'title': 'Level 0: Main Node 1',
                'children': [
                  {{ 'title': 'Level 1: Node 1' }},
                  {{ 'title': 'Level 1: Node 2' }}
                ]
              }}
            ]";

            var url  = $"/api/categorytrees/tree/{CategoryId}";
            var data = $"[{{'op':'replace','path':'nodes','value': {json} }}]";

            var response = await JohnApi.PatchData(url, data);

            Harness.WaitWhileCategoryTreeUpdatedPersisted(CategoryId);

            response = await JohnApi.GetData($"/api/categorytrees/tree/{CategoryId}");

            response.EnsureSuccessStatusCode();

            var jsonCategory = JToken.Parse(await response.Content.ReadAsStringAsync());

            jsonCategory.Should().ContainsJson($@"
            {{
                'id': '{CategoryId}',
                'createdBy': '{JohnId}',
                'createdDateTime': *EXIST*,
                'updatedBy': '{JohnId}',
                'updatedDateTime': *EXIST*,
                'version': 2,
                'nodes': *EXIST*
            }}");
        }
        public async Task MlProcessing_ModelTraining_WaitsWhileAllAssociatedGenericFilesProcessed()
        {
            var models = await Fixture.GetDependentFilesExcept(FolderId, FileType.Image, FileType.Tabular, FileType.Pdf);

            models.Should().HaveCount(1);

            foreach (var modelId in models)
            {
                var modelGenericFiles =
                    await Fixture.GetDependentFiles(modelId, FileType.Image, FileType.Tabular, FileType.Pdf);

                modelGenericFiles.Should().HaveCount(5);

                modelGenericFiles.ToList().ForEach(async fileId =>
                {
                    var file = await Session.Get <File>(modelId);
                    file.Should().NotBeNull();
                    file.Status.Should().Be(FileStatus.Processed);
                });
            }

            var reportFiles = await Fixture.GetDependentFiles(FolderId, FileType.Image, FileType.Tabular, FileType.Pdf);

            reportFiles.Should().HaveCount(3);

            reportFiles.ToList().ForEach(async id =>
            {
                var fileResponse = await JohnApi.GetFileEntityById(id);
                fileResponse.EnsureSuccessStatusCode();

                var jsonFile = JToken.Parse(await fileResponse.Content.ReadAsStringAsync());
                jsonFile["status"].Should().BeEquivalentTo("Processed");
            });

            await Task.CompletedTask;
        }
示例#17
0
        public async Task WebApi_AuthorizedAccessToProtectedResource_ReturnsSuccessResponse()
        {
            var response = await JohnApi.GetNodesMe();

            response.EnsureSuccessStatusCode();
        }
        public async Task CategoryTree_UpdateNodeInNonExistantCategoryTree_ReturnsNotFound()
        {
            var response = await JohnApi.PutData($"/api/categorytrees/tree/{Guid.NewGuid()}/{NodeId}", Categories);

            response.StatusCode.Should().Be(HttpStatusCode.NotFound);
        }
示例#19
0
        public async Task ChemicalProcessing_ValidSdf_GenerateExpectedFileEntity()
        {
            var blobInfo = await BlobStorage.GetFileInfo(BlobId, JohnId.ToString());

            blobInfo.Should().NotBeNull();

            var fileEntityResponse = await JohnApi.GetFileEntityById(FileId);

            var fileEntity = JsonConvert.DeserializeObject <JObject>(await fileEntityResponse.Content.ReadAsStringAsync());

            fileEntity.Should().NotBeNull();

            fileEntity.Should().ContainsJson($@"
			{{
				'id': '{FileId}',
				'blob': {{
					'id': '{blobInfo.Id}',
					'bucket': '{JohnId}',
					'length': {blobInfo.Length},
					'md5': '{blobInfo.MD5}'
				}},
				'subType': '{FileType.Records}',
				'ownedBy': '{JohnId}',
				'createdBy': '{JohnId}',
				'createdDateTime': *EXIST*,
				'updatedBy': '{JohnId}',
				'updatedDateTime': *EXIST*,
				'parentId': '{JohnId}',
				'name': '{blobInfo.FileName}',
				'status': '{FileStatus.Processed}',
				'version': 8,
				'totalRecords': 10,
				'properties': {{
					'fields': [
						'DATABASE_ID',
                        'DATABASE_NAME',
                        'SMILES',
                        'INCHI_IDENTIFIER',
                        'INCHI_KEY',
                        'FORMULA',
                        'MOLECULAR_WEIGHT',
                        'EXACT_MASS',
                        'JCHEM_ACCEPTOR_COUNT',
                        'JCHEM_AVERAGE_POLARIZABILITY',
                        'JCHEM_BIOAVAILABILITY',
                        'JCHEM_DONOR_COUNT',
                        'JCHEM_FORMAL_CHARGE',
                        'JCHEM_GHOSE_FILTER',
                        'JCHEM_IUPAC',
                        'ALOGPS_LOGP',
                        'JCHEM_LOGP',
                        'ALOGPS_LOGS',
                        'JCHEM_MDDR_LIKE_RULE',
                        'JCHEM_NUMBER_OF_RINGS',
                        'JCHEM_PHYSIOLOGICAL_CHARGE',
                        'JCHEM_PKA',
                        'JCHEM_PKA_STRONGEST_ACIDIC',
                        'JCHEM_PKA_STRONGEST_BASIC',
                        'JCHEM_POLAR_SURFACE_AREA',
                        'JCHEM_REFRACTIVITY',
                        'JCHEM_ROTATABLE_BOND_COUNT',
                        'JCHEM_RULE_OF_FIVE',
                        'ALOGPS_SOLUBILITY',
                        'JCHEM_TRADITIONAL_IUPAC',
                        'JCHEM_VEBER_RULE',
                        'DRUGBANK_ID',
                        'SECONDARY_ACCESSION_NUMBERS',
                        'DRUG_GROUPS',
                        'GENERIC_NAME',
                        'PRODUCTS',
                        'SALTS',
                        'SYNONYMS',
                        'INTERNATIONAL_BRANDS',
                        'JCHEM_ATOM_COUNT'
					],
					'chemicalProperties': [
						'MOST_ABUNDANT_MASS',
						'MONOISOTOPIC_MASS',
						'MOLECULAR_WEIGHT',
						'MOLECULAR_FORMULA',
						'SMILES',
						'InChIKey',
						'InChI'
					]
				}}
			}}"            );
            fileEntity["images"].Should().NotBeNull();
            fileEntity["images"].Should().HaveCount(1);
        }
        public async Task CategoryTree_GetNonExistantCategoryTree_ReturnsNotFoundCode()
        {
            var response = await JohnApi.GetData($"/api/categorytrees/tree/{Guid.NewGuid()}");

            response.StatusCode.Should().Be(HttpStatusCode.NotFound);
        }
示例#21
0
        public async Task CategoryTree_UpdateExistantCategoryTree_BuiltExpectedDocument()
        {
            var contentRequest = await JohnApi.GetData($"/api/categorytrees/tree/{CategoryId}");

            var jsonCategory = await contentRequest.Content.ReadAsJObjectAsync();

            jsonCategory.Should().HaveElement("id");
            jsonCategory["id"].Value <string>().Should().Be(CategoryId.ToString());

            jsonCategory.Should().HaveElement("createdBy");
            jsonCategory["createdBy"].Value <string>().Should().Be(JohnId.ToString());

            jsonCategory.Should().HaveElement("createdDateTime")
            .And.HaveElement("createdDateTime")
            .And.HaveElement("updatedDateTime");

            jsonCategory.Should().HaveElement("version");
            jsonCategory["version"].Value <int>().Should().Be(2);

            jsonCategory.Should().HaveElement("nodes");
            var treeNodes = jsonCategory["nodes"].Value <JArray>();

            treeNodes.Should().HaveCount(6);
            treeNodes.Select(i => i.Should().HaveElement("id"));
            var titles = treeNodes.Select(i => i["title"].Value <string>());

            titles.Should().Contain(new List <string> {
                "Level 0: Main Node 1", "NoNameNode", "1", "2", "3", "4"
            });
            var firstNode = treeNodes.Where(i => i.Value <string>("title") == "Level 0: Main Node 1").SingleOrDefault();

            firstNode.Should().NotBeNull();
            firstNode.Should().HaveElement("title");
            var insideNodes = firstNode["children"].Value <JArray>();

            insideNodes.Should().HaveCount(2);
            var insideTitles = insideNodes.Select(i => i["title"].Value <string>());

            insideTitles.Should().Contain(new List <string> {
                "Level 1: Node 1", "Level 1: Node 2"
            });
            insideNodes.Select(i => i.Should().HaveElement("id"));

            var lastNode = treeNodes.Where(i => i.Value <string>("title") == "4").SingleOrDefault();

            lastNode.Should().NotBeNull();
            var lastNodeInsideNodes = lastNode["children"].Value <JArray>();

            lastNodeInsideNodes.Should().HaveCount(2);
            var lastNodeInsideTitles = lastNodeInsideNodes.Select(i => i["title"].Value <string>());

            lastNodeInsideTitles.Should().Contain(new List <string> {
                "4-1", "4-2"
            });
            lastNodeInsideNodes.Select(i => i.Should().HaveElement("id"));

            var lastNodeSubnode = lastNodeInsideNodes.Where(i => i.Value <string>("title") == "4-2").SingleOrDefault();

            lastNodeSubnode.Should().NotBeNull();
            var lastSubnodeChildren = lastNodeSubnode["children"].Value <JArray>();

            lastSubnodeChildren.Should().HaveCount(1);
            lastSubnodeChildren.Single().Should().HaveElement("id");
        }
示例#22
0
        public async Task CategoryTreeOperations_DeleteNodeFromNonExistantCategoryTree_ReturnsNotFoundCode()
        {
            var response = await JohnApi.DeleteData($"/api/categorytrees/tree/{Guid.NewGuid()}/{ChildCategoryId}");

            response.StatusCode.Should().Be(HttpStatusCode.NotFound);
        }
        public async Task ChemicalProcessing_InvalidSdf_GenerateExpectedRecordNodeAndRecordEntity()
        {
            var recordResponse = await JohnApi.GetNodesById(FileId);

            var recordNodes = JsonConvert.DeserializeObject <JArray>(await recordResponse.Content.ReadAsStringAsync());

            recordNodes.Should().HaveCount(5);
            var recordNodesIndex = 0;
            var listStatus       = new List <FileStatus> {
                FileStatus.Failed, FileStatus.Processed
            };

            //var listType = new List<string> { "InvalidRecord", "Record" };

            foreach (var recordNodesItem in recordNodes)
            {
                var recordId = recordNodesItem["id"].ToObject <Guid>();
                recordId.Should().NotBeEmpty();

                var recordEntityResponse = await JohnApi.GetRecordEntityById(recordId);

                var recordEntity = JsonConvert.DeserializeObject <JObject>(await recordEntityResponse.Content.ReadAsStringAsync());
                recordEntity.Should().NotBeEmpty();

                recordEntity.Should().ContainsJson($@"
				{{
					'id': '{recordId}',
					'type': 'Structure',
					'fileId': '{FileId}',
					'ownedBy': '{JohnId}',
					'createdBy': '{JohnId}',
					'createdDateTime': *EXIST*,
					'updatedBy': '{JohnId}',
					'updatedDateTime': *EXIST*,
					'index': {recordNodesIndex},
					'status': '{listStatus[recordNodesIndex]}',
					'version': *EXIST*
				}}"                );

                var recordNodeResponse = await JohnApi.GetNodeById(recordId);

                var recordNode = JsonConvert.DeserializeObject <JObject>(await recordNodeResponse.Content.ReadAsStringAsync());
                recordNode.Should().NotBeEmpty();
                recordNode.Should().ContainsJson($@"
				{{
                    'id': '{recordId}',
					'type': 'Record',
					'subType': 'Structure',
					'ownedBy': '{JohnId}',
					'createdBy': '{JohnId}',
					'createdDateTime': *EXIST*,
					'updatedBy': '{JohnId}',
					'updatedDateTime': *EXIST*,
					'parentId': '{FileId}',
					'version': *EXIST*,
					'status': '{listStatus[recordNodesIndex]}'
				}}"                );

                recordNodesIndex++;
            }
        }
示例#24
0
        public async Task ChemicalProcessing_ValidMol_GenerateExpectedRecordEntity()
        {
            var recordResponse = await JohnApi.GetNodesById(FileId);

            var recordNodes = JsonConvert.DeserializeObject <JArray>(await recordResponse.Content.ReadAsStringAsync());

            var recordId = recordNodes.First()["id"].ToObject <Guid>();

            recordId.Should().NotBeEmpty();

            var recordEntityResponse = await JohnApi.GetRecordEntityById(recordId);

            var recordEntity = JsonConvert.DeserializeObject <JObject>(await recordEntityResponse.Content.ReadAsStringAsync());

            recordEntity.Should().NotBeEmpty();

            recordEntity.Should().ContainsJson($@"
			{{
				'id': '{recordId}',
				'type': 'Structure',
				'fileId': '{FileId}',
				'blob': {{
					'bucket': '{JohnId}',
				}},
				'ownedBy': '{JohnId}',
				'createdBy': '{JohnId}',
				'createdDateTime': '{DateTime.UtcNow}',
				'updatedBy': '{JohnId}',
				'updatedDateTime': '{DateTime.UtcNow}',
				'index': 0,
				'status': '{FileStatus.Processed}',
				'version': *EXIST*,
				'properties': {{
					'fields': [
						{{ 
							'name': 'StdInChI', 
							'value': 'InChI=1S/C9H8O4/c1-6(10)13-8-5-3-2-4-7(8)9(11)12/h2-5H,1H3,(H,11,12)'
						}},
						{{
							'name': 'StdInChIKey',
							'value': 'BSYNRYMUTXBXSQ-UHFFFAOYSA-N'
						}},
						{{
							'name': 'SMILES',
							'value': 'CC(OC1=C(C(=O)O)C=CC=C1)=O'
						}},
                        {{
                            'name': 'AuxInfo',
                            'value': '1/1/N:1,8,7,9,6,2,10,5,11,3,12,13,4/E:(11,12)/rA:13nCCOOCCCCCCCOO/rB:s1;d2;s2;s4;s5;d6;s7;d8;d5s9;s10;s11;d11;/rC:5.982,-4.6062,0;5.318,-3.4576,0;5.982,-2.3031,0;3.99,-3.4576,0;3.326,-2.3031,0;3.99,-1.1545,0;3.326,0,0;1.992,0,0;1.328,-1.1545,0;1.992,-2.3031,0;1.328,-3.4576,0;0,-3.4576,0;1.992,-4.6062,0;'
                        }},
                        {{
                            'name': 'Formula',
                            'value': 'C9 H8 O4'    
                        }},
                        {{
                            'name': 'Mw',
                            'value': '180.1574'
                        }},
                        {{
                            'name': 'CSID',
                            'value': '2157'
                        }}
					],
					'chemicalProperties': *EXIST*
				}}	
			}}"            );
            recordEntity["images"].Should().NotBeNull();
            recordEntity["images"].Should().HaveCount(1);
        }