public async Task ChemicalProcessing_ValidMol_GenerateExpectedSubstanceAggregate() { var recordId = Fixture.GetProcessedRecords(FileId).First(); var record = await Session.Get <Substance>(recordId); record.Should().NotBeNull(); record.ShouldBeEquivalentTo(new { Id = recordId, RecordType = RecordType.Structure, Bucket = JohnId.ToString(), OwnedBy = JohnId, CreatedBy = JohnId, CreatedDateTime = DateTimeOffset.UtcNow, UpdatedBy = JohnId, UpdatedDateTime = DateTimeOffset.UtcNow, ParentId = FileId, Status = RecordStatus.Processed, Index = 0, Issues = new List <Generic.Domain.ValueObjects.Issue>() { new Generic.Domain.ValueObjects.Issue { Code = "Code", AuxInfo = "AuxInfo", Message = "Message", Severity = Severity.Information, Title = "Title" } } }, options => options .ExcludingMissingMembers() ); record.Images.Should().NotBeNullOrEmpty(); record.Images.Should().ContainSingle(); record.Fields.Should().NotBeNullOrEmpty(); record.Fields.Should().HaveCount(3); record.Properties.Should().NotBeNullOrEmpty(); record.Properties.Should().HaveCount(9); record.BlobId.Should().NotBeEmpty(); }
public async Task ChemicalProcessing_ValidSdf_GenerateExpectedFileAggregate() { var blobInfo = await BlobStorage.GetFileInfo(BlobId, JohnId.ToString()); blobInfo.Should().NotBeNull(); var file = await Session.Get <RecordsFile.Domain.RecordsFile>(FileId); file.Should().NotBeNull(); file.ShouldBeEquivalentTo(new { Id = FileId, Type = FileType.Records, Bucket = JohnId.ToString(), BlobId = BlobId, OwnedBy = JohnId, CreatedBy = JohnId, CreatedDateTime = DateTimeOffset.UtcNow, UpdatedBy = JohnId, UpdatedDateTime = DateTimeOffset.UtcNow, ParentId = JohnId, FileName = blobInfo.FileName, Length = blobInfo.Length, Md5 = blobInfo.MD5, IsDeleted = false, Status = FileStatus.Processed, TotalRecords = 2, Fields = new List <string>() { "StdInChI", "StdInChIKey", "SMILES" } }, options => options .ExcludingMissingMembers() ); file.Images.Should().NotBeNullOrEmpty(); file.Images.Count.Should().Be(1); }
public async Task ChemicalProcessing_ValidCdx_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': '{DateTime.UtcNow}', 'updatedBy': '{JohnId}', 'updatedDateTime': '{DateTime.UtcNow}', 'parentId': '{JohnId}', 'name': '{blobInfo.FileName}', 'status': '{FileStatus.Processed}', 'version': *EXIST*, 'totalRecords': 3, 'properties': *EXIST* }}" ); fileEntity["images"].Should().NotBeNull(); fileEntity["images"].Should().HaveCount(1); }
public async Task FileSharing_WithUnauthorizeUser_ReturnsExpectedFileNode() { var blobInfo = await BlobStorage.GetFileInfo(BlobId, JohnId.ToString()); blobInfo.Should().NotBeNull(); var fileEntityResponse = await UnauthorizedApi.GetNodeById(FileId); fileEntityResponse.EnsureSuccessStatusCode(); fileEntityResponse.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.OK); 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, 'type': 'File' }}" ); fileEntity["images"].Should().HaveCount(1); }
protected async Task <Guid> TrainModel(string bucket, string fileName, IDictionary <string, object> metadata = null) { var blobId = await AddBlob(JohnId.ToString(), fileName, metadata); Guid correlationId = NewId.NextGuid(); var modelFolderId = NewId.NextGuid(); if (metadata["case"].Equals("valid one model with success optimization") || metadata["case"].Equals("train model with failed optimization")) { await Harness.Bus.Publish <StartTraining>(new { Id = modelFolderId, ParentId = modelFolderId, SourceBlobId = blobId, SourceBucket = bucket, CorrelationId = correlationId, UserId = JohnId, SourceFileName = fileName, Methods = new List <string>(new[] { "NaiveBayes" }), ClassName = "ClassName", Optimize = true }); } else if (!metadata["case"].Equals("two valid models")) { await Harness.Bus.Publish <StartTraining>(new { Id = modelFolderId, ParentId = modelFolderId, SourceBlobId = blobId, SourceBucket = bucket, CorrelationId = correlationId, UserId = JohnId, SourceFileName = fileName, Scaler = "Somebody knows what is Scaler???", Methods = new List <string>(new[] { "NaiveBayes" }), ClassName = "ClassName", SubSampleSize = (decimal)0.2, TestDataSize = (decimal)0.2, KFold = 4, Fingerprints = new List <IDictionary <string, object> >() { new Dictionary <string, object>() { { "radius", 3 }, { "size", 1024 }, { "type", FingerprintType.ecfp } } }, Optimize = false, HyperParameters = new HyperParametersOptimization() { NumberOfIterations = 100, OptimizationMethod = "OptimizationMethod" } }); } if (metadata["case"].Equals("two valid models")) { await Harness.Bus.Publish <StartTraining>(new { Id = modelFolderId, ParentId = modelFolderId, SourceBlobId = blobId, SourceBucket = bucket, CorrelationId = correlationId, UserId = JohnId, SourceFileName = fileName, Scaler = "Somebody knows what is Scaler???", Methods = new List <string>(new[] { "NaiveBayes", "LogisticRegression" }), ClassName = "ClassName", SubSampleSize = (decimal)0.2, TestDataSize = (decimal)0.2, KFold = 4, Fingerprints = new List <IDictionary <string, object> >() { new Dictionary <string, object>() { { "radius", 3 }, { "size", 1024 }, { "type", FingerprintType.ecfp } } }, Optimize = false }); } if (!Harness.Published.Select <TrainingFinished>(m => m.Context.Message.Id == modelFolderId).Any()) { throw new TimeoutException(); } return(modelFolderId); }
public async Task ChemicalProcessing_ValidCdxWithThreeRecords_GenerateExpectedRecordsEntityAndRecordsNode() { var records = Fixture.GetProcessedRecords(FileId); records.Should().HaveCount(3); foreach (var recordId in records) { var recordView = Records.Find(new BsonDocument("_id", recordId)).FirstOrDefault() as IDictionary <string, object>; recordView.Should().NotBeNull(); var recordBlob = recordView["Blob"]; recordBlob.Should().NotBeNull(); recordBlob.Should().BeAssignableTo <IDictionary <string, object> >(); var recordBlobId = (recordBlob as IDictionary <string, object>)["_id"]; recordBlobId.Should().NotBeNull(); recordBlobId.Should().BeOfType <Guid>(); var index = Convert.ToInt32(recordView["Index"]); index.Should().BeGreaterOrEqualTo(0); var record = await Session.Get <Substance>((Guid)recordId); record.Should().NotBeNull(); record.ShouldBeEquivalentTo(new { Id = recordId, RecordType = RecordType.Structure, Bucket = JohnId.ToString(), BlobId = recordBlobId, OwnedBy = JohnId, CreatedBy = JohnId, CreatedDateTime = DateTimeOffset.UtcNow, UpdatedBy = JohnId, UpdatedDateTime = DateTimeOffset.UtcNow, ParentId = FileId, Status = RecordStatus.Processed, Index = index, Issues = new List <Generic.Domain.ValueObjects.Issue>() { new Generic.Domain.ValueObjects.Issue { Code = "Code", AuxInfo = "AuxInfo", Message = "Message", Severity = Generic.Domain.ValueObjects.Severity.Information, Title = "Title" } } }, options => options .ExcludingMissingMembers() ); record.Images.Should().NotBeNullOrEmpty(); record.Images.Should().ContainSingle(); record.Fields.Should().BeEmpty(); record.Properties.Should().NotBeNullOrEmpty(); record.Properties.Should().HaveCount(9); recordView.Should().EntityShouldBeEquivalentTo(record); var recordNode = Nodes.Find(new BsonDocument("_id", (Guid)recordId)).FirstOrDefault() as IDictionary <string, object>; recordNode.Should().NotBeNull(); recordNode.Should().NodeShouldBeEquivalentTo(record); } }
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"); }
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); }