From eda3da2aeab4de943f58df3960c88b49d47f4d23 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Mon, 13 Aug 2012 14:40:36 +0200 Subject: [PATCH] fix geo shape tests --- .../common/geo/GeoJSONShapeParserTests.java | 51 ++++++++++--------- .../query/SimpleIndexQueryParserTests.java | 2 + 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/test/java/org/elasticsearch/test/unit/common/geo/GeoJSONShapeParserTests.java b/src/test/java/org/elasticsearch/test/unit/common/geo/GeoJSONShapeParserTests.java index dfdcfa670e4..83957d1c0b0 100644 --- a/src/test/java/org/elasticsearch/test/unit/common/geo/GeoJSONShapeParserTests.java +++ b/src/test/java/org/elasticsearch/test/unit/common/geo/GeoJSONShapeParserTests.java @@ -37,8 +37,8 @@ public class GeoJSONShapeParserTests { public void testParse_lineString() throws IOException { String lineGeoJson = XContentFactory.jsonBuilder().startObject().field("type", "LineString") .startArray("coordinates") - .startArray().value(100.0).value(0.0).endArray() - .startArray().value(101.0).value(1.0).endArray() + .startArray().value(100.0).value(0.0).endArray() + .startArray().value(101.0).value(1.0).endArray() .endArray() .endObject().string(); @@ -55,13 +55,13 @@ public class GeoJSONShapeParserTests { public void testParse_polygonNoHoles() throws IOException { String polygonGeoJson = XContentFactory.jsonBuilder().startObject().field("type", "Polygon") .startArray("coordinates") - .startArray() - .startArray().value(100.0).value(0.0).endArray() - .startArray().value(101.0).value(0.0).endArray() - .startArray().value(101.0).value(1.0).endArray() - .startArray().value(100.0).value(1.0).endArray() - .startArray().value(100.0).value(0.0).endArray() - .endArray() + .startArray() + .startArray().value(100.0).value(0.0).endArray() + .startArray().value(101.0).value(0.0).endArray() + .startArray().value(101.0).value(1.0).endArray() + .startArray().value(100.0).value(1.0).endArray() + .startArray().value(100.0).value(0.0).endArray() + .endArray() .endArray() .endObject().string(); @@ -82,20 +82,20 @@ public class GeoJSONShapeParserTests { public void testParse_polygonWithHole() throws IOException { String polygonGeoJson = XContentFactory.jsonBuilder().startObject().field("type", "Polygon") .startArray("coordinates") - .startArray() - .startArray().value(100.0).value(0.0).endArray() - .startArray().value(101.0).value(0.0).endArray() - .startArray().value(101.0).value(1.0).endArray() - .startArray().value(100.0).value(1.0).endArray() - .startArray().value(100.0).value(0.0).endArray() - .endArray() - .startArray() - .startArray().value(100.2).value(0.2).endArray() - .startArray().value(100.8).value(0.2).endArray() - .startArray().value(100.8).value(0.8).endArray() - .startArray().value(100.2).value(0.8).endArray() - .startArray().value(100.2).value(0.2).endArray() - .endArray() + .startArray() + .startArray().value(100.0).value(0.0).endArray() + .startArray().value(101.0).value(0.0).endArray() + .startArray().value(101.0).value(1.0).endArray() + .startArray().value(100.0).value(1.0).endArray() + .startArray().value(100.0).value(0.0).endArray() + .endArray() + .startArray() + .startArray().value(100.2).value(0.2).endArray() + .startArray().value(100.8).value(0.2).endArray() + .startArray().value(100.8).value(0.8).endArray() + .startArray().value(100.2).value(0.8).endArray() + .startArray().value(100.2).value(0.2).endArray() + .endArray() .endArray() .endObject().string(); @@ -126,8 +126,8 @@ public class GeoJSONShapeParserTests { public void testParse_multiPoint() throws IOException { String multiPointGeoJson = XContentFactory.jsonBuilder().startObject().field("type", "MultiPoint") .startArray("coordinates") - .startArray().value(100.0).value(0.0).endArray() - .startArray().value(101.0).value(1.0).endArray() + .startArray().value(100.0).value(0.0).endArray() + .startArray().value(101.0).value(1.0).endArray() .endArray() .endObject().string(); @@ -142,6 +142,7 @@ public class GeoJSONShapeParserTests { private void assertGeometryEquals(Shape expected, String geoJson) throws IOException { XContentParser parser = JsonXContent.jsonXContent.createParser(geoJson); + parser.nextToken(); assertEquals(GeoJSONShapeParser.parse(parser), expected); } } diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/SimpleIndexQueryParserTests.java b/src/test/java/org/elasticsearch/test/unit/index/query/SimpleIndexQueryParserTests.java index 313821f7dfe..22b082f7a4c 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/query/SimpleIndexQueryParserTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/query/SimpleIndexQueryParserTests.java @@ -1840,6 +1840,8 @@ public class SimpleIndexQueryParserTests { IndexQueryParserService queryParser = queryParser(); String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/geoShape-query.json"); Query parsedQuery = queryParser.parse(query).query(); + assertThat(parsedQuery, instanceOf(ConstantScoreQuery.class)); + parsedQuery = ((ConstantScoreQuery) parsedQuery).getQuery(); assertThat(parsedQuery, instanceOf(BooleanQuery.class)); BooleanQuery booleanQuery = (BooleanQuery) parsedQuery; TermQuery termQuery = (TermQuery) booleanQuery.getClauses()[0].getQuery();