Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
l-trotta committed Aug 22, 2024
1 parent b35cd3f commit c7ff6d3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,74 +223,6 @@ public void testEnumShortcutProperty() {
assertEquals(SortOrder.Asc, so.field().order());
}

@Test
public void testObjectShortcutProperty() {

// Check that we look ahead to handle the shortcut
ObjectDeserializer<?> deser = (ObjectDeserializer<?>) LazyDeserializer.unwrap(RankEvalQuery._DESERIALIZER);
assertEquals("query", deser.shortcutProperty());
assertTrue(deser.shortcutIsObject());

// Standard form
RankEvalQuery req = fromJson("{\"query\":{\"term\":{\"foo\":{\"value\":\"bar\"}}}}", RankEvalQuery.class);

assertEquals("foo", req.query().term().field());
assertEquals("bar", req.query().term().value().stringValue());

// Shortcut form
req = fromJson("{\"term\":{\"foo\":{\"value\":\"bar\"}}}", RankEvalQuery.class);

assertEquals("foo", req.query().term().field());
assertEquals("bar", req.query().term().value().stringValue());

// Nested shortcuts
req = fromJson("{\"term\":{\"foo\":\"bar\"}}", RankEvalQuery.class);

assertEquals("foo", req.query().term().field());
assertEquals("bar", req.query().term().value().stringValue());
}

@Test
public void testFunctionScoreQuery() {
String shortcut =
"{" +
" \"gauss\": {" +
" \"date\": {" +
" \"origin\": \"2013-09-17\", " +
" \"scale\": \"10d\"," +
" \"offset\": \"5d\", " +
" \"decay\": 0.5" +
" }," +
" \"multi_value_mode\": \"avg\"" +
" }" +
"}";

String full =
"{" +
" \"functions\": [" +
" {" +
" \"gauss\": {" +
" \"date\": {" +
" \"origin\": \"2013-09-17\"," +
" \"scale\": \"10d\"," +
" \"offset\": \"5d\"," +
" \"decay\": 0.5" +
" }," +
" \"multi_value_mode\": \"avg\"" +
" }" +
" }" +
" ]" +
"}";

FunctionScoreQuery fsq;

fsq = fromJson(full, FunctionScoreQuery.class);
assertEquals(MultiValueMode.Avg, fsq.functions().get(0).gauss().untyped().multiValueMode());

fsq = fromJson(shortcut, FunctionScoreQuery.class);
assertEquals(MultiValueMode.Avg, fsq.functions().get(0).gauss().untyped().multiValueMode());
}

@Test
public void testWithNull() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void testUntaggedUnion() {
.relation(RangeRelation.Contains))));

String expectedDateRangeQuery = "{\"range\":{\"day\":{\"boost\":1.0,\"relation\":\"contains\"," +
"\"gte\":\"20-06-24\",\"lte\":\"20-07-24\"},\"format\":\"some-format\"}}";
"\"gte\":\"20-06-24\",\"lte\":\"20-07-24\",\"format\":\"some-format\"}}}";

assertEquals(expectedDateRangeQuery, toJson(dateRangeQuery));

Expand Down

0 comments on commit c7ff6d3

Please sign in to comment.