4444import com .marklogic .client .document .JSONDocumentManager ;
4545import com .marklogic .client .io .DOMHandle ;
4646import com .marklogic .client .io .FileHandle ;
47+ import com .marklogic .client .io .Format ;
4748import com .marklogic .client .io .JacksonHandle ;
49+ import com .marklogic .client .io .ReaderHandle ;
4850import com .marklogic .client .io .SearchHandle ;
4951import com .marklogic .client .query .MatchDocumentSummary ;
5052import com .marklogic .client .query .QueryManager ;
@@ -106,7 +108,7 @@ public void testLinestringContainsPoint() throws KeyManagementException, NoSuchA
106108 // create query def
107109 StructuredQueryBuilder qb = queryMgr .newStructuredQueryBuilder ();
108110 StructuredQueryDefinition t = qb .geospatial (qb .geoRegionPath (qb .pathIndex ("/root/item/linestring" ), CoordinateSystem .WGS84DOUBLE ),
109- GeospatialOperator .CONTAINS , qb .point (0 , -66.09375 ));
111+ GeospatialOperator .CONTAINS , qb .point (2.85526278436658 , -80.5078125 ));
110112
111113 // create handle
112114 JacksonHandle resultsJsonHandle = new JacksonHandle ();
@@ -135,34 +137,25 @@ public void testLinestringContainsPoint() throws KeyManagementException, NoSuchA
135137 TreeMap <String , String > readMap = new TreeMap <String , String >();
136138 String linedesc = null ;
137139
138- String snippetFromSummary = null ;
139- String snippetFromRead = null ;
140-
141140 // Making sure that we proper results. Snippets are not complete. Taking in
142141 // what appears in summary.
143- expectedMap .put ("/Equator-json.json" , "Json Point In Equator - South America" );
144- expectedMap .put ("/Equator.xml" , "Point In Equator - South America" );
142+ expectedMap .put ("/Equator-json.json" , "Json Linestring In Equator - South America" );
143+ expectedMap .put ("/Equator.xml" , "Linestring In Equator - South America" );
145144
146145 for (MatchDocumentSummary summary : matches ) {
147146 String docUri = summary .getUri ();
148147 System .out .println ("docURI is " + docUri );
149148 System .out .println ("Snippet from Summary is " + summary .getFirstSnippetText ());
150- // Get only the numbers. Strip away others. Refer to data files.
151- snippetFromSummary = summary .getFirstSnippetText ().split ("LINESTRING\\ (" )[0 ];
152- // Strip the ... characters from snippets.
153- if (snippetFromSummary .contains ("Json" ))
154- snippetFromSummary = "Json " + snippetFromSummary .split ("Json" )[1 ].trim ();
155- else
156- snippetFromSummary = "Point " + snippetFromSummary .split ("Point" )[1 ].trim ();
149+
157150 if (summary .getFormat ().name ().equalsIgnoreCase ("XML" )) {
158151 DOMHandle contentHandle = readDocumentUsingDOMHandle (client , docUri , "XML" );
159152 Document readDoc = contentHandle .get ();
160- linedesc = readDoc .getElementsByTagName ("point -desc" ).item (0 ).getFirstChild ().getNodeValue ().trim ();
153+ linedesc = readDoc .getElementsByTagName ("line -desc" ).item (0 ).getFirstChild ().getNodeValue ().trim ();
161154
162- System .out .println ("Point desc from XML file is " + linedesc );
155+ System .out .println ("Line desc from XML file is " + linedesc );
163156
164157 // Verify that snippets from qb and read contain the same.
165- assertTrue ("Snippets from summary and from XML file are incorrect " , linedesc .contains (snippetFromSummary ));
158+ assertTrue ("Snippets from summary and from XML file are incorrect " , linedesc .contains ("Linestring In Equator - South America" ));
166159
167160 readDoc = null ;
168161 contentHandle = null ;
@@ -171,12 +164,12 @@ else if (summary.getFormat().name().equalsIgnoreCase("JSON")) {
171164 JacksonHandle jacksonhandle = new JacksonHandle ();
172165 docMgr .read (docUri , jacksonhandle );
173166 JsonNode resultNode = jacksonhandle .get ();
174- linedesc = resultNode .path ("root" ).path ("item" ).path ("point -desc" ).asText ().trim ();
167+ linedesc = resultNode .path ("root" ).path ("item" ).path ("line -desc" ).asText ().trim ();
175168
176- System .out .println ("Snippet point -desc from JSON file is " + linedesc );
169+ System .out .println ("Snippet line -desc from JSON file is " + linedesc );
177170
178171 // Verify that snippets from qb and read contain the same.
179- assertTrue ("Snippets from summary and from JSON file are incorrect " , linedesc .contains (snippetFromSummary ));
172+ assertTrue ("Snippets from summary and from JSON file are incorrect " , linedesc .contains ("Json Linestring In Equator - South America" ));
180173 jacksonhandle = null ;
181174 resultNode = null ;
182175 }
0 commit comments