use of org.opensearch.ad.TestHelpers.randomAnomalyDetector in project anomaly-detection by opensearch-project.
the class ADTaskManagerTests method testStartHistoricalAnalysisWithNoOwningNode.
@SuppressWarnings("unchecked")
public void testStartHistoricalAnalysisWithNoOwningNode() throws IOException {
AnomalyDetector detector = TestHelpers.randomAnomalyDetector(ImmutableList.of());
DetectionDateRange detectionDateRange = TestHelpers.randomDetectionDateRange();
User user = null;
int availableTaskSlots = randomIntBetween(1, 10);
ActionListener<AnomalyDetectorJobResponse> listener = mock(ActionListener.class);
doAnswer(invocation -> {
Consumer<Optional<DiscoveryNode>> function = invocation.getArgument(1);
function.accept(Optional.empty());
return null;
}).when(hashRing).buildAndGetOwningNodeWithSameLocalAdVersion(anyString(), any(), any());
adTaskManager.startHistoricalAnalysis(detector, detectionDateRange, user, availableTaskSlots, transportService, listener);
verify(listener, times(1)).onFailure(any());
}
Aggregations