Skip to content

Commit

Permalink
Fix watcher tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jkakavas committed Feb 7, 2019
1 parent 56af70b commit df711bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void setConfiguration(Configuration configuration) {
@Override
public Engine.Index preIndex(ShardId shardId, Engine.Index operation) {
if (isWatchDocument(shardId.getIndexName(), operation.type())) {
ZonedDateTime now = Instant.ofEpochMilli(clock.millis()).atZone(ZoneOffset.UTC);
ZonedDateTime now = clock.instant().atZone(ZoneOffset.UTC);
try {
Watch watch = parser.parseWithSecrets(operation.id(), true, operation.source(), now, XContentType.JSON,
operation.getIfSeqNo(), operation.getIfPrimaryTerm());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -324,8 +325,9 @@ public void testIndexActionExecuteSingleDoc() throws Exception {
assertThat(indexRequest.getRefreshPolicy(), is(expectedRefreshPolicy));

if (timestampField != null) {
final DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
assertThat(indexRequest.sourceAsMap().keySet(), is(hasSize(2)));
assertThat(indexRequest.sourceAsMap(), hasEntry(timestampField, executionTime.toString()));
assertThat(indexRequest.sourceAsMap(), hasEntry(timestampField, formatter.format(executionTime)));
} else {
assertThat(indexRequest.sourceAsMap().keySet(), is(hasSize(1)));
}
Expand Down

0 comments on commit df711bd

Please sign in to comment.