public async Task WhenTheIMSUserPartiallyUpdatesThePostedEntitiesWhereIsAndIsWithoutThePropertyUsingVInTheERCollection(string asyncHeader, string asyncValue, string allowPartialUpdateHeader, string allowPartialUpdateValue, string propertyMissing, string version) { restClientUser = "******"; var getNewEntities = scenarioContext.CreatedEntities().ToList(); var erCollectionIdList = scenarioContext.CreatedERCollections().ToList(); for (int i = 0; i < erCollectionIdList.Count; i++) { var headers = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>(PlatformHeaders.ErCollectionId, erCollectionIdList[i]), new KeyValuePair <string, string>(asyncHeader, asyncValue), new KeyValuePair <string, string>(allowPartialUpdateHeader, allowPartialUpdateValue) }; List <Entity> partialUpdateEntitiesList = new List <Entity>(); for (int j = 0; j < getNewEntities.Count; j++) { Log.Information($"Attempting to Partially update entities from ER Collection {erCollectionIdList[i]}"); Entity newEntity = null; if (propertyMissing.Equals("entityId")) { newEntity = new Entity(id: null, entityType: getNewEntities[j].EntityType, entityName: getNewEntities[j].EntityName); } //if (propertyMissing.Equals("entityType")) // newEntity = new Entity(id: getNewEntities[j].Id, entityType: null, entityName: getNewEntities[j].EntityName); partialUpdateEntitiesList.Add(newEntity); } // RestClientResponse<PlatformItemResponse> postEntityResponseMsg = null; var partialUpdateEntityResponseMsg = await ERService.PostEntities(version, partialUpdateEntitiesList, headers); scenarioContext.AddPartialUpdateResponses(partialUpdateEntityResponseMsg); if (asyncValue == "true") { partialUpdateEntityResponseMsg.Response.StatusCode.Should().Be(HttpStatusCode.Accepted, $"{restClientUser} user with {_testCfg.ImsScopes} scopes should not be able to partial update entity in er collection {erCollectionIdList[i]}"); } else { partialUpdateEntityResponseMsg.Response.StatusCode.ToString().Should().Be("207", $"{restClientUser} user with {_testCfg.ImsScopes} scopes should not be able to partial update entity in er collection {erCollectionIdList[i]}"); } //try //{ // postEntityResponseMsg = await ERService.PostEntities(version, partialUpdateEntitiesList, headers); //} //catch (RestClientException ex) //{ // scenarioContext.AddRestClientExceptionErrors(ex); //} } }
public async Task WhenTheIMSUserPostsNewRelationshipSBetweenTheEntitiesWhereIsWithoutPropertyUsingVInTheERCollectionTimeS(int numOfRelationship, string asyncHeader, string asyncValue, string missingField, string version) { restClientUser = "******"; for (int i = 0; i < numOfRelationship; i++) { int index = i; var newEntities = scenarioContext.CreatedEntities().ToList(); while (newEntities.Count <= index + 1) { index = index + 1 - newEntities.Count; } var sourceEntityId = newEntities[index].Id; var destinationEntityId = newEntities[index + 1].Id; Relationship newRelationship = null; { if (missingField.Equals("relationshipType")) { newRelationship = new Relationship(id: $"test-{Guid.NewGuid()}", relationshipType: null, relationshipName: "test relationship", sourceEntityId: sourceEntityId, destinationEntityId: destinationEntityId); } if (missingField.Equals("sourceEntityId")) { newRelationship = new Relationship(id: $"test-{Guid.NewGuid()}", relationshipType: BrickRelationshipTypes.BrickEquipmentIsLocatedInLocation, relationshipName: "test relationship", sourceEntityId: null, destinationEntityId: destinationEntityId); } if (missingField.Equals("destinationEntityId")) { newRelationship = new Relationship(id: $"test-{Guid.NewGuid()}", relationshipType: BrickRelationshipTypes.BrickEquipmentIsLocatedInLocation, relationshipName: "test relationship", sourceEntityId: sourceEntityId, destinationEntityId: null); } if (missingField.Equals("relationshipName")) { newRelationship = new Relationship(id: $"test-{Guid.NewGuid()}", relationshipType: BrickRelationshipTypes.BrickEquipmentIsLocatedInLocation, relationshipName: null, sourceEntityId: sourceEntityId, destinationEntityId: destinationEntityId); } if (missingField.Equals("relationshipId")) { newRelationship = new Relationship(id: null, relationshipType: BrickRelationshipTypes.BrickEquipmentIsLocatedInLocation, relationshipName: "test relationship", sourceEntityId: sourceEntityId, destinationEntityId: destinationEntityId); } } scenarioContext.AddRelationship(newRelationship); } //var erCollectionIdList = scenarioContext.CreatedERCollections().ToList(); string erCollectionId = this.scenarioContext.Get <dynamic>("CollectionsResponse"); scenarioContext.AddERCollections(erCollectionId); var headers = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>(PlatformHeaders.ErCollectionId, erCollectionId), new KeyValuePair <string, string>(asyncHeader, asyncValue) }; var getRelationships = scenarioContext.CreatedRelationships().ToList(); Log.Information($"Attempting to post new Relationship/Relationships between Entities synchronously in ER collection {erCollectionId}"); { RestClientResponse <PlatformItemResponse> postRelationshipResponseMsg = null; //try //{ postRelationshipResponseMsg = await ERService.PostRelationship(version, getRelationships, headers); if (asyncValue == "true") { postRelationshipResponseMsg.Response.StatusCode.Should().Be(HttpStatusCode.Accepted, $"{restClientUser} user with {_testCfg.ImsScopes} scopes should be able to partial update relationship in er collection {erCollectionId}"); } else { scenarioContext.AddPartialUpdateResponses(postRelationshipResponseMsg); } } //} //catch (RestClientException ex) //{ // scenarioContext.AddRestClientExceptionErrors(ex); //} }