Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Change the default value of lastUpdateTime #77

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public static AnomalyDetector parse(
List<Feature> features = new ArrayList<>();
int schemaVersion = 0;
Map<String, Object> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down