public void CreateBoundary_HappyPath() { const string boundaryName = "Boundary Web test 3"; this.Msg.Title(boundaryName, "Create boundary"); var boundaryRequest = BoundaryRequest.Create(string.Empty, boundaryName, boundaryWKT); var boundary = JsonConvert.SerializeObject(boundaryRequest, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); var responseCreate = ts.CallFilterWebApi($"api/v1/boundary/{ProjectUid}", "PUT", boundary); Assert.AreNotEqual(string.Empty, responseCreate, "Boundary WKT not found from PUT request"); var boundaryResponse = JsonConvert.DeserializeObject <GeofenceDataSingleResult>(responseCreate, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); Assert.AreEqual(boundaryWKT, boundaryResponse.GeofenceData.GeometryWKT, "Boundary WKT doesn't match for PUT request"); Assert.AreEqual(boundaryName, boundaryResponse.GeofenceData.GeofenceName, "Boundary name doesn't match for PUT request"); var boundaryUid = boundaryResponse.GeofenceData.GeofenceUID; var responseGet = ts.CallFilterWebApi($"api/v1/boundary/{ProjectUid}?boundaryUid={boundaryUid}", "GET"); var boundaryResponseGet = JsonConvert.DeserializeObject <GeofenceDataSingleResult>(responseGet, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); Assert.AreEqual(boundaryWKT, boundaryResponseGet.GeofenceData.GeometryWKT, "Boundary WKT doesn't match for GET request"); Assert.AreEqual(boundaryName, boundaryResponseGet.GeofenceData.GeofenceName, "Boundary name doesn't match for GET request"); }
public void DeleteBoundary_HappyPath() { const string boundaryName = "Boundary Web test 4"; this.Msg.Title(boundaryName, "Create then delete boundary"); var boundaryRequest = BoundaryRequest.Create(string.Empty, boundaryName, boundaryWKT); var boundary = JsonConvert.SerializeObject(boundaryRequest, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); var response = ts.CallFilterWebApi($"api/v1/boundary/{ProjectUid}", "PUT", boundary); var boundaryResponse = JsonConvert.DeserializeObject <GeofenceDataSingleResult>(response, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); var boundaryUid = boundaryResponse.GeofenceData.GeofenceUID; var responseDelete = ts.CallFilterWebApi($"api/v1/boundary/{ProjectUid}?boundaryUid={boundaryUid}", "DELETE"); var responseDel = JsonConvert.DeserializeObject <ContractExecutionResult>(responseDelete, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); Assert.AreEqual("success", responseDel.Message, "delete call to wep api expects success"); var responseGet = ts.CallFilterWebApi($"api/v1/boundary/{ProjectUid}?boundaryUid={boundaryUid}", "GET"); var respGet = JsonConvert.DeserializeObject <GeofenceDataSingleResult>(responseGet, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); Assert.AreEqual("GetBoundary By BoundaryUid. The requested Boundary does not exist, or does not belong to the requesting project or filter.", respGet.Message, "Expecting an error message to say the boundary does not exist."); }
public void CreateFilterWithBoundaryThenDeleteBoundary(FilterType filterType) { ts.DeleteAllBoundariesAndAssociations(); const string filterName = "Filter Web test 5"; Msg.Title(filterName, $"Create {filterType} filter with boundary and delete boundary"); var boundaryWkt = GenerateWKTPolygon(); var boundaryName = filterName + " - boundary"; var boundaryRequest = BoundaryRequest.Create(string.Empty, boundaryName, boundaryWkt); var boundary = JsonConvert.SerializeObject(boundaryRequest, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); var responseCreate = ts.CallFilterWebApi($"api/v1/boundary/{ProjectUid}", "PUT", boundary); var boundaryResponse = JsonConvert.DeserializeObject <GeofenceDataSingleResult>(responseCreate, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); var boundaryUid = boundaryResponse.GeofenceData.GeofenceUID; var filterJson = CreateTestFilter(polygonUid: boundaryUid.ToString()); var filterRequest = FilterRequest.Create(string.Empty, filterName, filterJson, filterType); var filter = JsonConvert.SerializeObject(filterRequest, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); responseCreate = ts.CallFilterWebApi($"api/v1/filter/{ProjectUid}", "PUT", filter); var filterResponse = JsonConvert.DeserializeObject <FilterDescriptorSingleResult>(responseCreate, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); var filterUid = filterResponse.FilterDescriptor.FilterUid; var hydratedFilterJson = CreateTestFilter(polygonUid: boundaryUid.ToString(), polygonName: boundaryName, polygonPoints: GetPointsFromWkt(boundaryWkt), polygonType: GeofenceType.Filter); var responseDelete = ts.CallFilterWebApi($"api/v1/boundary/{ProjectUid}?boundaryUid={boundaryUid}", "DELETE"); var filterResponse1 = JsonConvert.DeserializeObject <FilterDescriptorSingleResult>(responseDelete, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); Assert.AreEqual(0, filterResponse1.Code, " Expecting a sucessful result but got " + filterResponse1.Message); var responseGet = ts.CallFilterWebApi($"api/v1/filter/{ProjectUid}?filterUid={filterUid}", "GET"); var filterResponseGet = JsonConvert.DeserializeObject <FilterDescriptorSingleResult>(responseGet, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); Assert.AreEqual(filterRequest.Name, filterResponseGet.FilterDescriptor.Name, "Filter name doesn't match for GET request"); Assert.AreEqual(hydratedFilterJson, filterResponseGet.FilterDescriptor.FilterJson, "JSON Filter doesn't match for GET request"); Assert.AreEqual(filterRequest.FilterType, filterResponseGet.FilterDescriptor.FilterType, "Filter type doesn't match for GET request"); }
public void CreateBoundary_SameNameDifferentProject() { const string boundaryName = "Boundary Web test 2"; this.Msg.Title(boundaryName, "Create boundary with same name in different project"); var boundaryRequest = BoundaryRequest.Create(string.Empty, boundaryName, boundaryWKT); var boundary = JsonConvert.SerializeObject(boundaryRequest, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); var responseCreate = ts.CallFilterWebApi($"api/v1/boundary/{ProjectUid}", "PUT", boundary); var boundaryResponse = JsonConvert.DeserializeObject <GeofenceDataSingleResult>(responseCreate, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); Assert.AreEqual("success", boundaryResponse.Message, "Expecting success (1)"); //Now create in another project responseCreate = ts.CallFilterWebApi($"api/v1/boundary/{ProjectUid2}", "PUT", boundary); boundaryResponse = JsonConvert.DeserializeObject <GeofenceDataSingleResult>(responseCreate, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); Assert.AreEqual("success", boundaryResponse.Message, "Expecting success (2)"); }
public void CreateBoundary_DuplicateNameNotValid() { const string boundaryName = "Boundary Web test 1"; this.Msg.Title(boundaryName, "Create boundary with duplicate name"); var boundaryRequest = BoundaryRequest.Create(string.Empty, boundaryName, boundaryWKT); var boundary = JsonConvert.SerializeObject(boundaryRequest, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); var responseCreate = ts.CallFilterWebApi($"api/v1/boundary/{ProjectUid}", "PUT", boundary); var boundaryResponse = JsonConvert.DeserializeObject <GeofenceDataSingleResult>(responseCreate, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); Assert.AreEqual("success", boundaryResponse.Message, "Expecting success"); //Now duplicate responseCreate = ts.CallFilterWebApi($"api/v1/boundary/{ProjectUid}", "PUT", boundary); boundaryResponse = JsonConvert.DeserializeObject <GeofenceDataSingleResult>(responseCreate, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); Assert.AreEqual("Duplicate boundary name", boundaryResponse.Message, "Expecting duplicate boundary name"); Assert.AreEqual(2062, boundaryResponse.Code, "Wrong error code"); }