Package de.komoot.photon.importer.elasticsearch

Source Code of de.komoot.photon.importer.elasticsearch.RemoveStreetDuplicatesTest

package de.komoot.photon.importer.elasticsearch;

import com.google.common.collect.ImmutableMap;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.PrecisionModel;
import de.komoot.photon.ESBaseTester;
import de.komoot.photon.importer.model.PhotonDoc;
import org.json.JSONObject;
import org.junit.*;

import java.util.List;

import static org.junit.Assert.*;

/**
* @author Christoph
*/
public class RemoveStreetDuplicatesTest extends ESBaseTester {
  GeometryFactory FACTORY = new GeometryFactory(new PrecisionModel(), 4326);

  @Before
  public void setUp() {
    setUpES();
    deleteAll();
    PhotonDoc street1 = this.createStreetDoc(1, "Walserstraße", "6993");
    PhotonDoc street2 = this.createStreetDoc(2, "Walserstraße", "6993");
    PhotonDoc street3 = this.createStreetDoc(3, "Walserstraße", "6991");

    Importer instance = new Importer(getClient());
    instance.add(street1);
    instance.add(street2);
    instance.add(street3);
    instance.finish();
    refresh();
  }

  private PhotonDoc createStreetDoc(int id, String name, String postcode) {
    final PhotonDoc doc = new PhotonDoc(id, "way", id, "highway", "primary", ImmutableMap.of("name", name),
        null, null, null, 0, 0.5, null,
        FACTORY.createPoint(new Coordinate(10., 47.)),
        0, 0);
    doc.setPostcode(postcode);
    return doc;
  }

  @Test
  public void checkDuplicates() {
    final Searcher searcher = new Searcher(getClient());
    final List<JSONObject> results = searcher.search("Walserstraße", "en", null, null, 10, true);
    assertEquals(2, results.size());
  }
}
TOP

Related Classes of de.komoot.photon.importer.elasticsearch.RemoveStreetDuplicatesTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.