Skip to content

Commit

Permalink
[NOID] fix time assertion GeocodeTest (#3565)
Browse files Browse the repository at this point in the history
  • Loading branch information
vga91 authored May 24, 2023
1 parent ef7332a commit 7279d01
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions core/src/test/java/apoc/spatial/GeocodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public void initDb() throws Exception {
@Test
public void testWrongUrlButViaOtherProvider() throws Exception {
// wrong url but doesn't fail because provider is osm, not opencage
testGeocodeWithThrottling("osm", false,
testGeocodeWithThrottling("osm", false,
map("url", "https://api.opencagedata.com/geocode/v1/json?q=PLACE&key=KEY111"));
}

@Test(expected = QueryExecutionException.class)
public void testWrongUrlWithOpenCage() throws Exception {
// overwrite ApocConfig provider
Expand Down Expand Up @@ -108,7 +108,7 @@ public void testGeocodeWithBlockedAddressWithApocConf() {
assertGeocodeAllowedUrl(true);
});
}

@Test
public void testGeocodeWithBlockedAddressWithConfigMap() {
Stream.of("https", "http", "ftp").forEach(protocol -> {
Expand Down Expand Up @@ -267,9 +267,15 @@ private void testGeocodeAddress(Map map, String provider, AtomicLong time, Map<S
for (String field : new String[]{"address", "noresults"}) {
checkJsonFields(map, field);
}
// with the `{"address": "", "noresults": true}` entry
// the time passed with throttle 100 and 2000 are about equal, unlike the other cases,
// so it is better not to add the time passed in this case
AtomicLong time1 = "".equals( map.get("address") )
? null
: time;
waitForServerResponseOK(geocodeQuery,
map("url", map.get("address").toString()),
time,
time1,
(res) -> assertFalse(res.hasNext())
);
} else if (map.containsKey("count")) {
Expand Down Expand Up @@ -339,7 +345,9 @@ private void waitForServerResponseOK(String query, Map<String, Object> params, A
return null;
});

time.addAndGet( System.currentTimeMillis() - start );
if (time != null) {
time.addAndGet(System.currentTimeMillis() - start);
}
return true;
} catch (Exception e) {
String msg = e.getMessage();
Expand Down

0 comments on commit 7279d01

Please sign in to comment.