Ejemplo n.º 1
0
        public async Task ChemicalProcessing_InvalidMol_GenerateExpectedInvalidRecordEntity()
        {
            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}',
				'ownedBy': '{JohnId}',
				'createdBy': '{JohnId}',
				'createdDateTime': '{DateTime.UtcNow}',
				'updatedBy': '{JohnId}',
				'updatedDateTime': '{DateTime.UtcNow}',
				'index': 0,
				'status': '{FileStatus.Failed}',
				'message': 'molfile loader: ring bond count is allowed only for queries',
				'version': *EXIST*
			}}"            );
        }
        public async Task FileSharing_WithUnauthorizeUser_ReturnsExpectedRecordEntity()
        {
            var recordResponse = await UnauthorizedApi.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'
						}}
					],
					'chemicalProperties': *EXIST*
				}}	
			}}"            );
            recordEntity["images"].Should().NotBeNull();
            recordEntity["images"].Should().HaveCount(1);
        }
Ejemplo n.º 3
0
        public async Task CrystalProcessing_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': 'Crystal',
				'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': 'Field1', 
							'value': 'Value1'
						}},
						{{
							'name': 'Field2',
							'value': 'Value2'
						}}
					]
				}}	
			}}"            );
            recordEntity["images"].Should().NotBeNull();
            recordEntity["images"].Should().HaveCount(3);
        }
Ejemplo n.º 4
0
        private async Task ValidRecordEntity(Guid recordId, int recordIndex)
        {
            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': *EXIST*,
					'updatedBy': '{JohnId}',
					'updatedDateTime': *EXIST*,
					'index': {recordIndex},
					'status': '{FileStatus.Processed}',
					'version': *EXIST*,
					'properties': {{
						'fields': [
							{{ 
								'name': 'StdInChI', 
								'value': 'StdInChI-{recordIndex}'
							}},
							{{
								'name': 'StdInChIKey',
								'value': 'StdInChIKey-{recordIndex}'
							}},
							{{
								'name': 'SMILES',
								'value': 'SMILES-{recordIndex}'
							}}
						],
						'chemicalProperties': *EXIST*
					}}	
				}}"                );
            recordEntity["images"].Should().NotBeNull();
            recordEntity["images"].Should().HaveCount(1);
        }
Ejemplo n.º 5
0
        public async Task BlobImageRecordSharing_WithUnauthorizeUser_ReturnsExpectedNotFound()
        {
            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 response = await UnauthorizedApi.GetImagesRecordEntityById(recordId, imageId);

            response.IsSuccessStatusCode.Should().Be(false);
//            response.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.NotFound);
//            response.ReasonPhrase.ShouldAllBeEquivalentTo("Not Found");
        }
Ejemplo n.º 6
0
        public async Task FileSharin_WithAuthorizeUser_ReturnsExpectedBlobRecord()
        {
            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 blobResponse = await JohnApi.GetBlobRecordEntityById(recordId, recordBlobId);

            blobResponse.EnsureSuccessStatusCode();
            blobResponse.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.OK);
            blobResponse.Content.Headers.ContentType.MediaType.ShouldBeEquivalentTo("chemical/x-mdl-molfile");
            blobResponse.Content.Headers.ContentLength.ShouldBeEquivalentTo(1689);
            //blobResponse.Content.Headers.ContentDisposition.FileName.Should().NotBeNullOrEmpty();
        }
        public async Task FileSharing_WithAuthorizeUser_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 JohnApi.GetImagesRecordEntityById(recordId, imageId);

            blobResponse.EnsureSuccessStatusCode();
            blobResponse.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.OK);
            blobResponse.Content.Headers.ContentType.MediaType.ShouldBeEquivalentTo("application/octet-stream");
            blobResponse.Content.Headers.ContentLength.Should().BeGreaterThan(10000);
            blobResponse.Content.Headers.ContentDisposition.FileName.ShouldBeEquivalentTo("Aspirin.mol.svg");
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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++;
            }
        }