コード例 #1
0
        private async Task ValidRecordNode(Guid recordId, int recordIndex)
        {
            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',
					'name': {recordIndex},
					'blob': {{
						'bucket': '{JohnId}'
					}},
					'ownedBy': '{JohnId}',
					'createdBy': '{JohnId}',
					'createdDateTime': *EXIST*,
					'updatedBy': '{JohnId}',
					'updatedDateTime': *EXIST*,
					'parentId': '{FileId}',
					'version': *EXIST*,
					'status': '{FileStatus.Processed}',
				}}"                );
            recordNode["images"].Should().NotBeNull();
            recordNode["images"].Should().HaveCount(1);
        }
コード例 #2
0
        public async Task SpectraProcessing_InvalidJdx_GenerateExpectedFileNode()
        {
            var blobInfo = await BlobStorage.GetFileInfo(BlobId, JohnId.ToString());

            blobInfo.Should().NotBeNull();

            var fileNodeResponse = await JohnApi.GetNodeById(FileId);

            var fileNode = JsonConvert.DeserializeObject <JObject>(await fileNodeResponse.Content.ReadAsStringAsync());

            fileNode.Should().ContainsJson($@"
			{{
				'id': '{FileId}',
				'type': 'File',
				'subType': 'Records',
				'blob': {{
					'id': '{blobInfo.Id}',
					'bucket': '{JohnId}',
					'length': {blobInfo.Length},
					'md5': '{blobInfo.MD5}'
				}},
				'status': '{FileStatus.Failed}',
				'ownedBy':'{JohnId}',
				'createdBy': '{JohnId}',
				'createdDateTime': '{DateTime.UtcNow}',
				'updatedBy': '{JohnId}',
				'updatedDateTime': '{DateTime.UtcNow}',
				'name': '{blobInfo.FileName}',
				'parentId': '{JohnId}',
				'version': *EXIST*
			}}"            );
        }
コード例 #3
0
        public async Task ReactionProcessing_ValidRnx_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();
            recordId.Should().Should().BeOfType <GuidAssertions>();

            var recordNodeResponse = await JohnApi.GetNodeById(recordId);

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

            recordNode.Should().ContainsJson($@"
			{{
                'id': '{recordId}',
				'type': 'Record',
				'subType': 'Reaction',
				'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(1);
        }
コード例 #4
0
        public async Task MlProcessing_ModelTraining_ModelPersisted()
        {
            var models = Harness.GetDependentFilesExcept(FolderId, FileType.Image, FileType.Tabular, FileType.Pdf);

            var modelResponse = await JohnApi.GetModelEntityById(models.First());

            modelResponse.EnsureSuccessStatusCode();
            var modelJson = JToken.Parse(await modelResponse.Content.ReadAsStringAsync());

            modelJson.Should().ContainsJson($@"
            {{
                'id': '{modelJson["id"].ToObject<Guid>()}',
                'blob': *EXIST*,
                'ownedBy': '{JohnId}',
                'createdBy': '{JohnId}',
                'createdDateTime': *EXIST*,
                'updatedBy': '{JohnId}',
                'updatedDateTime': *EXIST*,
                'parentId': '{FolderId}',
                'name': 'Naive Bayes',
                'status': 'Processed',
                'version': 11,
                'method': 'NaiveBayes',
                'className': 'ClassName',
                'subSampleSize': '0.2',
                'kFold': 4,
                'fingerprints': [
                {{
                    'type': '1',
                    'size': 1024,
                    'radius': 3
                }}],
                'images': *EXIST*
                
            }}", new List <string> {
                "testDatasetSize"
            });

            var modelNodeResponse = await JohnApi.GetNodeById(models.First());

            modelNodeResponse.EnsureSuccessStatusCode();
            var nodeJson = JToken.Parse(await modelNodeResponse.Content.ReadAsStringAsync());

            nodeJson.Should().ContainsJson($@"
            {{
                'id': '{modelJson["id"].ToObject<Guid>()}',
                'blob': *EXIST*,
                'type': 'Model',
                'ownedBy': '{JohnId}',
                'createdBy': '{JohnId}',
                'createdDateTime': *EXIST*,
                'updatedBy': '{JohnId}',
                'updatedDateTime': *EXIST*,
                'parentId': '{FolderId}',
                'name': 'Naive Bayes',
                'status': 'Processed',
                'version': 11,
                'images': *EXIST*
            }}");
        }
コード例 #5
0
        public async Task ChemicalProcessing_InvalidMol_GenerateExpectedInvalidRecordNode()
        {
            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': 'Structure',
				'ownedBy':'{JohnId}',
				'createdBy':'{JohnId}',
				'createdDateTime': '{DateTime.UtcNow}',
				'updatedBy':'{JohnId}',
				'updatedDateTime': '{DateTime.UtcNow}',
				'parentId': '{FileId}',
				'version': *EXIST*,
				'status': '{FileStatus.Failed}'
			}}"            );
        }
コード例 #6
0
        public async Task MlPrediction_PredictionCsvFilePersisted()
        {
            var tabulars = Harness.GetDependentFiles(FolderId, FileType.Tabular);
            var list     = tabulars.ToList();

            tabulars.Should().NotBeNullOrEmpty();
            tabulars.Should().HaveCount(1);

            foreach (var tabularId in tabulars)
            {
                var tabularResponse = await JohnApi.GetNodeById(tabularId);

                var tabularJson = JToken.Parse(await tabularResponse.Content.ReadAsStringAsync());

                tabularJson.Should().ContainsJson($@"
                {{
                    'id': '{tabularId}',
                    'blob': *EXIST*,
                    'subType': 'Tabular',
                    'ownedBy': '{JohnId}',
                    'createdBy': '{JohnId}',
                    'createdDateTime': *EXIST*,
                    'updatedBy': '{JohnId}',
                    'updatedDateTime': *EXIST*,
                    'parentId': '{FolderId}',
                    'name': 'FocusSynthesis_InStock.csv',
                    'status': 'Processed',
                    'version': 7
                }}");
            }

            await Task.CompletedTask;
        }
        public async Task MlProcessing_ModelTraining_GeneratesPdfReport()
        {
            var pdfFiles = Harness.GetDependentFiles(FolderId, FileType.Pdf);

            pdfFiles.Should().NotBeNullOrEmpty();
            pdfFiles.Should().HaveCount(1);

            foreach (var pdfId in pdfFiles)
            {
                var pdfResponse = await JohnApi.GetFileEntityById(pdfId);

                var pdfJson = JToken.Parse(await pdfResponse.Content.ReadAsStringAsync());
                pdfJson.Should().ContainsJson($@"
                {{
                    'id': '{pdfId}',
                    'blob': *EXIST*,
                    'subType': 'Pdf',
                    'ownedBy': '{JohnId}',
                    'createdBy': '{JohnId}',
                    'createdDateTime': *EXIST*,
                    'updatedBy': '{JohnId}',
                    'updatedDateTime': *EXIST*,
                    'parentId': '{FolderId}',
                    'name': 'ML_report.pdf',
                    'status': 'Processed',
                    'version': 7
                }}");
                pdfJson["images"].Should().HaveCount(3);

                var nodePdfResponse = await JohnApi.GetNodeById(pdfId);

                var nodeJson = JToken.Parse(await nodePdfResponse.Content.ReadAsStringAsync());
                nodeJson.Should().ContainsJson($@"
                {{
                    'id': '{pdfId}',
                    'blob': *EXIST*,
                    'subType': 'Pdf',
                    'ownedBy': '{JohnId}',
                    'createdBy': '{JohnId}',
                    'createdDateTime': *EXIST*,
                    'updatedBy': '{JohnId}',
                    'updatedDateTime': *EXIST*,
                    'parentId': '{FolderId}',
                    'name': 'ML_report.pdf',
                    'status': 'Processed',
                    'version': 7
                }}");
            }

            await Task.CompletedTask;
        }
コード例 #8
0
        public async Task DeleteOneCategoryToEntity()
        {
            var fileNodeResponse = await JohnApi.GetNodeById(FileId);

            var fileNode = await fileNodeResponse.Content.ReadAsJObjectAsync();

            var fileNodeId = Guid.Parse(fileNode.Value <string>("id"));

            var treeResponse = await JohnApi.GetData($"api/categorytrees/tree/{RootCategoryId}");

            var treeContent = await treeResponse.Content.ReadAsJObjectAsync();

            var categoryId1 = treeContent["nodes"][0]["children"][0]["id"].ToString();
            var categoryId2 = treeContent["nodes"][0]["children"][1]["id"].ToString();

            // add categories to entity
            await JohnApi.PostData($"/api/categoryentities/entities/{fileNodeId}/categories", new List <string> {
                categoryId1, categoryId2
            });

            WebFixture.WaitWhileCategoryIndexed(categoryId1.ToString());
            WebFixture.WaitWhileCategoryIndexed(categoryId2.ToString());
            // check if node exists by categoryId1
            var firstCategoryAddedNodeRequest = await JohnApi.GetData($"/api/categoryentities/categories/{categoryId1}");

            var firstCategoryAddedNode = await firstCategoryAddedNodeRequest.Content.ReadAsJArrayAsync();

            firstCategoryAddedNode.First().Value <string>("id").Should().Be(fileNodeId.ToString());

            // delete first category from node
            await JohnApi.DeleteData($"/api/categoryentities/entities/{fileNodeId}/categories/{categoryId1}");

            WebFixture.WaitWhileCategoryDeleted(categoryId1.ToString());
            // check if node contains categoryId1
            var firstCategoryDeletedNodeRequest = await JohnApi.GetData($"/api/categoryentities/categories/{categoryId1}");

            var firstCategoryDeletedNode = await firstCategoryDeletedNodeRequest.Content.ReadAsJArrayAsync();

            firstCategoryDeletedNode.Should().BeEmpty();

            var secondCategoryAddedNodeRequest = await JohnApi.GetData($"/api/categoryentities/categories/{categoryId2}");

            var secondCategoryAddedNode = await secondCategoryAddedNodeRequest.Content.ReadAsJArrayAsync();

            secondCategoryAddedNode.First().Value <string>("id").Should().Be(fileNodeId.ToString());
        }
コード例 #9
0
        public async Task DeleteCategory_DeleteOneCategoryFromEntity_CategoryIdShouldBeRemovedFromEntity()
        {
            var fileNodeResponse = await JohnApi.GetNodeById(FileId);

            var fileNode = await fileNodeResponse.Content.ReadAsJObjectAsync();

            var fileNodeId = Guid.Parse(fileNode.Value <string>("id"));

            var treeRequest = await JohnApi.GetData($"api/categorytrees/tree/{RootCategoryId}");

            var treeContent = await treeRequest.Content.ReadAsJObjectAsync();

            var categoryId1 = treeContent["nodes"][0]["children"][0]["id"].ToString();
            var categoryId2 = treeContent["nodes"][0]["children"][1]["id"].ToString();

            // add categories to entity
            await JohnApi.PostData($"/api/categoryentities/entities/{fileNodeId}/categories", new List <string> {
                categoryId1, categoryId2
            });

            WebFixture.WaitWhileCategoryIndexed(fileNodeId.ToString());

            var firstCategoryAddedNode = await GetNodeByCategoryId(categoryId1);

            firstCategoryAddedNode.Value <string>("id").Should().Be(fileNodeId.ToString());

            // delete first category from node
            await JohnApi.DeleteData($"/api/categoryentities/entities/{fileNodeId}/categories/{categoryId1}");

            // check if node contains categoryId
            WebFixture.WaitWhileCategoryDeleted(categoryId1);
            var firstCategoryDeletedNode = await GetNodeByCategoryId(categoryId1);

            firstCategoryDeletedNode.Should().BeNull();

            var entityCategoryIdsRequest = await JohnApi.GetData($"/api/categoryentities/entities/{fileNodeId}/categories");

            var entityCategoryIds = await entityCategoryIdsRequest.Content.ReadAsJArrayAsync();

            entityCategoryIds.Should().HaveCount(1);
            entityCategoryIds.Single().Value <string>("id").Should().Be(categoryId2);
        }
コード例 #10
0
        public async Task GetCategoriesIdsByEntityIdTest()
        {
            var fileNodeResponse = await JohnApi.GetNodeById(FileId);

            var fileNode = await fileNodeResponse.Content.ReadAsJObjectAsync();

            var fileNodeId = Guid.Parse(fileNode.Value <string>("id"));

            await JohnApi.PostData($"/api/categoryentities/entities/{fileNodeId}/categories", new List <Guid> {
                CategoryId
            });

            WebFixture.WaitWhileCategoryIndexed(CategoryId.ToString());

            var response = await JohnApi.GetData($"/api/categoryentities/entities/{fileNodeId}/categories");

            var categoriesIds = await response.Content.ReadAsJArrayAsync();

            categoriesIds.Single().Value <string>().Should().Be(CategoryId.ToString());
        }
コード例 #11
0
        public async Task UserOperation_GetUserInfoUsingNodesEndpoint_ReturnsUserInfo()
        {
            var response = await JohnApi.GetNodeById(JohnId);

            response.EnsureSuccessStatusCode();

            var user = JObject.Parse(await response.Content.ReadAsStringAsync());

            user.Should().ContainsJson($@"
			{{
				'id': '{JohnDoe.Id}',
                'type': 'User',
                'displayName': '{JohnDoe.DisplayName}',
                'firstName': '{JohnDoe.FirstName}',
                'lastName': '{JohnDoe.LastName}',
                'loginName': '{JohnDoe.LoginName}',
                'email': '{JohnDoe.Email}',
                'avatar': '{JohnDoe.Avatar}',
                'version': '{JohnDoe.Version}'
			}}"            );
        }
コード例 #12
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;
        }
コード例 #13
0
        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++;
            }
        }