Skip to content

Commit

Permalink
Update spotless
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Kwok <[email protected]>
  • Loading branch information
andy-k-improving committed Jan 22, 2025
1 parent f25be31 commit ca20d0b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;

import lombok.SneakyThrows;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.json.JSONObject;
Expand All @@ -40,9 +39,9 @@ public class GeoIpFunctionsIT extends PPLIntegTestCase {
private static boolean initialized = false;

private static Map<String, Object> MANIFEST_LOCATION =
Map.of(
"endpoint",
"https://raw.githubusercontent.com/opensearch-project/geospatial/main/src/test/resources/ip2geo/server/city/manifest.json");
Map.of(
"endpoint",
"https://raw.githubusercontent.com/opensearch-project/geospatial/main/src/test/resources/ip2geo/server/city/manifest.json");

private static String DATASOURCE_NAME = "dummycityindex";

Expand Down Expand Up @@ -80,16 +79,16 @@ public void testGeoIpEnrichment() {
waitForDatasourceToBeAvailable(DATASOURCE_NAME, Duration.ofSeconds(10));

JSONObject resultGeoIp =
executeQuery(
String.format(
"search source=%s | eval enrichmentResult = geoip(\\\"%s\\\",%s)",
TEST_INDEX_GEOIP, "dummycityindex", "ip"));
executeQuery(
String.format(
"search source=%s | eval enrichmentResult = geoip(\\\"%s\\\",%s)",
TEST_INDEX_GEOIP, "dummycityindex", "ip"));

verifyColumn(resultGeoIp, columnName("name"), columnName("ip"), columnName("enrichmentResult"));
verifyDataRows(
resultGeoIp,
rows("Test user - USA", "10.1.1.1", Map.of("country", "USA", "city", "Seattle")),
rows("Test user - Canada", "127.1.1.1", Map.of("country", "Canada", "city", "Vancouver")));
resultGeoIp,
rows("Test user - USA", "10.1.1.1", Map.of("country", "USA", "city", "Seattle")),
rows("Test user - Canada", "127.1.1.1", Map.of("country", "Canada", "city", "Vancouver")));
}

/**
Expand All @@ -102,7 +101,7 @@ public void testGeoIpEnrichment() {
* @throws IOException In case of network failure
*/
private Response createDatasource(final String name, Map<String, Object> properties)
throws IOException {
throws IOException {
XContentBuilder builder = XContentFactory.jsonBuilder().startObject();
for (Map.Entry<String, Object> config : properties.entrySet()) {
builder.field(config.getKey(), config.getValue());
Expand All @@ -121,16 +120,16 @@ private Response createDatasource(final String name, Map<String, Object> propert
* @throws Exception Exception
*/
private void waitForDatasourceToBeAvailable(final String name, final Duration timeout)
throws Exception {
throws Exception {
Instant start = Instant.now();
while (!"AVAILABLE".equals(getDatasourceState(name))) {
if (Duration.between(start, Instant.now()).compareTo(timeout) > 0) {
throw new RuntimeException(
String.format(
Locale.ROOT,
"Datasource state didn't change to %s after %d seconds",
"AVAILABLE",
timeout.toSeconds()));
String.format(
Locale.ROOT,
"Datasource state didn't change to %s after %d seconds",
"AVAILABLE",
timeout.toSeconds()));
}
Thread.sleep(1000);
}
Expand All @@ -147,8 +146,8 @@ private String getDatasourceState(final String name) throws Exception {
Request request = new Request("GET", GEO_SPATIAL_DATASOURCE_PATH + name);
Response response = client().performRequest(request);
var responseInMap =
createParser(XContentType.JSON.xContent(), EntityUtils.toString(response.getEntity()))
.map();
createParser(XContentType.JSON.xContent(), EntityUtils.toString(response.getEntity()))
.map();
var datasources = (List<Map<String, Object>>) responseInMap.get("datasources");
return (String) datasources.get(0).get("state");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ public void test_visitTrendline() {
}

/**
* To ensure the original Eval functionality continue to work after the OpenSearchEvalOperator wrapper.
* To ensure the original Eval functionality continue to work after the OpenSearchEvalOperator
* wrapper.
*/
@Test
void test_visitOpenSearchEval() {
Expand Down

0 comments on commit ca20d0b

Please sign in to comment.