Skip to content

Commit

Permalink
Update unitTest
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 23, 2025
1 parent e78b358 commit fe42887
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,20 @@ public class GeoIPFunctionTest {
@Mock private Environment<Expression, ExprValue> env;

@Test
public void geoIpDefaultImplementation() {
UnsupportedOperationException exception =
assertThrows(
UnsupportedOperationException.class,
() ->
DSL.geoip(DSL.literal("HARDCODED_DATASOURCE_NAME"), DSL.ref("ip_address", STRING))
.valueOf(env));
assertTrue(exception.getMessage().matches(".*no default implementation available"));
}

@Test
public void testGeoipFnctionSignature() {
public void testGeoipFunctionSignature() {
var geoip = DSL.geoip(DSL.literal("HARDCODED_DATASOURCE_NAME"), DSL.ref("ip_address", STRING));
assertEquals(BOOLEAN, geoip.type());
}

/** To make sure no logic being evaluated when no environment being passed. */
@Test
public void testDefaultValueOf() {
var geoip = DSL.geoip(DSL.literal("HARDCODED_DATASOURCE_NAME"), DSL.ref("ip_address", STRING));
assertNull(geoip.valueOf());
UnsupportedOperationException exception =
assertThrows(
UnsupportedOperationException.class,
() ->
DSL.geoip(DSL.literal("HARDCODED_DATASOURCE_NAME"), DSL.ref("ip_address", STRING))
.valueOf(env));
assertTrue(exception.getMessage().contains("OpenSearch defined function [geoip] is only supported in WHERE clause, HAVING clause and Eval operation."));
}
}
1 change: 0 additions & 1 deletion docs/category.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"user/ppl/functions/condition.rst",
"user/ppl/functions/datetime.rst",
"user/ppl/functions/expressions.rst",
"user/ppl/functions/ip.rst",
"user/ppl/functions/json.rst",
"user/ppl/functions/math.rst",
"user/ppl/functions/relevance.rst",
Expand Down

0 comments on commit fe42887

Please sign in to comment.