public void GetPointsOfInterestById_EmptyWikiTag_ShouldReturnIt() { var poiId = "poiId"; var feature = GetValidFeature(poiId, _adapter.Source); feature.Attributes.Add(FeatureAttributes.WIKIPEDIA, string.Empty); feature.Attributes.Add(FeatureAttributes.WEBSITE, "website"); _elasticSearchGateway.GetPointOfInterestById(poiId, _adapter.Source).Returns(feature); _dataContainerConverterService.ToDataContainer(Arg.Any <byte[]>(), Arg.Any <string>()).Returns( new DataContainer { Routes = new List <RouteData>() }); _wikipediaGateway.GetByPageTitle(Arg.Any <string>(), Arg.Any <string>()).Returns( new Feature(new Point(0, 0), new AttributesTable())); var result = _adapter.GetPointOfInterestById(Sources.OSM, poiId, null).Result; Assert.IsNotNull(result); Assert.AreEqual("website", result.References.First().Url); }
private async Task <Feature> UpdateElasticSearch(ICompleteOsmGeo osm, string name) { var feature = ConvertOsmToFeature(osm, name); if (feature == null) { return(null); } var featureFromDb = await _elasticSearchGateway.GetPointOfInterestById(feature.Attributes[FeatureAttributes.ID].ToString(), Sources.OSM); if (featureFromDb != null) { foreach (var attributeKey in featureFromDb.Attributes.GetNames().Where(n => n.StartsWith(FeatureAttributes.POI_PREFIX))) { if (!feature.Attributes.GetNames().Any(n => n == attributeKey)) { feature.Attributes.AddOrUpdate(attributeKey, featureFromDb.Attributes[attributeKey]); } } if (feature.Geometry.OgcGeometryType == OgcGeometryType.Point && featureFromDb.Geometry.OgcGeometryType != OgcGeometryType.Point) { feature.Geometry = featureFromDb.Geometry; } } await _elasticSearchGateway.UpdatePointsOfInterestData(new List <Feature> { feature }); foreach (var language in Languages.Array) { var title = feature.Attributes.GetWikipediaTitle(language); if (string.IsNullOrWhiteSpace(title)) { continue; } var pageFetaure = await _wikipediaGateway.GetByPageTitle(title, language); if (pageFetaure == null) { continue; } await _elasticSearchGateway.DeletePointOfInterestById(pageFetaure.Attributes[FeatureAttributes.ID].ToString(), Sources.WIKIPEDIA); } return(feature); }