diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetector.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetector.java index 84f6bf1b..6155241c 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetector.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetector.java @@ -233,7 +233,7 @@ public static AnomalyDetector parse( List features = new ArrayList<>(); int schemaVersion = 0; Map uiMetadata = null; - Instant lastUpdateTime = Instant.now(); + Instant lastUpdateTime = null; ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser::getTokenLocation); while (parser.nextToken() != XContentParser.Token.END_OBJECT) { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorTests.java index 1504601d..1b8c667a 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorTests.java @@ -94,16 +94,6 @@ public void testParseAnomalyDetectorWithEmptyUiMetadata() throws IOException { assertEquals("Parsing anomaly detector doesn't work", detector, parsedDetector); } - public void testParseAnomalyDetectorWithNullLastUpdateTime() throws IOException { - AnomalyDetector detector = TestHelpers.randomAnomalyDetector(ImmutableMap.of(), null); - String detectorString = TestHelpers.xContentBuilderToString(detector.toXContent(TestHelpers.builder(), ToXContent.EMPTY_PARAMS)); - AnomalyDetector parsedDetector = AnomalyDetector.parse(TestHelpers.parser(detectorString), detector.getDetectorId()); - assertEquals("Parsing anomaly detector doesn't work", detector, parsedDetector); - assertEquals("Parsing anomaly detector doesn't work", detector.getDetectorId(), parsedDetector.getDetectorId()); - assertNull(detector.getLastUpdateTime()); - assertNotNull(parsedDetector.getLastUpdateTime()); - } - public void testNullDetectorName() throws Exception { TestHelpers .assertFailWith( diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStateManagerTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStateManagerTests.java index 417f7428..5804216d 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStateManagerTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStateManagerTests.java @@ -92,6 +92,7 @@ public void setUp() throws Exception { .build(); clock = mock(Clock.class); duration = Duration.ofHours(1); + context = TestHelpers.createThreadPool(); throttler = new Throttler(clock); stateManager = new ADStateManager( diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/IndexUtilsTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/IndexUtilsTests.java index 9fdc9123..f26e66e3 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/IndexUtilsTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/IndexUtilsTests.java @@ -23,6 +23,7 @@ import org.junit.Before; import org.junit.Test; +import com.amazon.opendistroforelasticsearch.ad.TestHelpers; import java.time.Clock; import static org.mockito.Mockito.mock; @@ -36,8 +37,8 @@ public void setup() { Client client = client(); Clock clock = mock(Clock.class); Throttler throttler = new Throttler(clock); - ThreadPool threadPool = mock(ThreadPool.class); - clientUtil = new ClientUtil(Settings.EMPTY, client, throttler, threadPool); + ThreadPool context = TestHelpers.createThreadPool(); + clientUtil = new ClientUtil(Settings.EMPTY, client, throttler, context); } @Test