Skip to content

Commit

Permalink
Tests: Fix SearchFieldsIT.testDocValueFields (elastic#31995)
Browse files Browse the repository at this point in the history
This test produced different implementations of joda time classes,
depending on if the data was serialized or not (DateTime vs
MutableDateTime). This now uses a common base class to extract the
milliseconds from the data.

Closes elastic#31992
  • Loading branch information
spinscale authored Jul 12, 2018
1 parent 4ae4ac0 commit 0b7e7be
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.InternalSettingsPlugin;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.base.BaseDateTime;

import java.time.ZoneOffset;
import java.time.ZonedDateTime;
Expand Down Expand Up @@ -702,7 +701,6 @@ public void testSingleValueFieldDatatField() throws ExecutionException, Interrup
assertThat(fields.get("test_field").getValue(), equalTo("foobar"));
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/31992")
public void testDocValueFields() throws Exception {
createIndex("test");

Expand Down Expand Up @@ -804,8 +802,8 @@ public void testDocValueFields() throws Exception {
assertThat(searchResponse.getHits().getAt(0).getFields().get("long_field").getValue(), equalTo((Object) 4L));
assertThat(searchResponse.getHits().getAt(0).getFields().get("float_field").getValue(), equalTo((Object) 5.0));
assertThat(searchResponse.getHits().getAt(0).getFields().get("double_field").getValue(), equalTo((Object) 6.0d));
assertThat(searchResponse.getHits().getAt(0).getFields().get("date_field").getValue(),
equalTo(new DateTime(date.toInstant().toEpochMilli(), DateTimeZone.UTC)));
BaseDateTime dateField = searchResponse.getHits().getAt(0).getFields().get("date_field").getValue();
assertThat(dateField.getMillis(), equalTo(date.toInstant().toEpochMilli()));
assertThat(searchResponse.getHits().getAt(0).getFields().get("boolean_field").getValue(), equalTo((Object) true));
assertThat(searchResponse.getHits().getAt(0).getFields().get("text_field").getValue(), equalTo("foo"));
assertThat(searchResponse.getHits().getAt(0).getFields().get("keyword_field").getValue(), equalTo("foo"));
Expand Down

0 comments on commit 0b7e7be

Please sign in to comment.