forked from komoot/photon
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add osm_value to dedupe key (komoot#367)
Signed-off-by: Holger Bruch <[email protected]>
- Loading branch information
Showing
2 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/java/de/komoot/photon/searcher/StreetDupesRemoverTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package de.komoot.photon.searcher; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.json.JSONObject; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import de.komoot.photon.Constants; | ||
|
||
public class StreetDupesRemoverTest { | ||
|
||
@Test | ||
public void testDeduplicatesStreets() { | ||
StreetDupesRemover streetDupesRemover = new StreetDupesRemover("en"); | ||
List<JSONObject> allResults = new ArrayList<>(); | ||
allResults.add(createDummyResult("99999", "Main Street", "highway", "Unclassified")); | ||
allResults.add(createDummyResult("99999", "Main Street", "highway", "Unclassified")); | ||
|
||
List<JSONObject> dedupedResults = streetDupesRemover.execute(allResults); | ||
Assert.assertEquals(1, dedupedResults.size()); | ||
} | ||
|
||
@Test | ||
public void testStreetAndBusStopNotDeduplicated() { | ||
StreetDupesRemover streetDupesRemover = new StreetDupesRemover("en"); | ||
List<JSONObject> allResults = new ArrayList<>(); | ||
allResults.add(createDummyResult("99999", "Main Street", "highway", "bus_stop")); | ||
allResults.add(createDummyResult("99999", "Main Street", "highway", "Unclassified")); | ||
|
||
List<JSONObject> dedupedResults = streetDupesRemover.execute(allResults); | ||
Assert.assertEquals(2, dedupedResults.size()); | ||
} | ||
|
||
private JSONObject createDummyResult(String postCode, String name, String osmKey, | ||
String osmValue) { | ||
return new JSONObject().put(Constants.PROPERTIES, new JSONObject() | ||
.put(Constants.POSTCODE, postCode).put(Constants.NAME, name) | ||
.put(Constants.OSM_KEY, osmKey).put(Constants.OSM_VALUE, osmValue)); | ||
} | ||
|
||
} |