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

Commit

Permalink
Updating Delete Detector test to expect exception
Browse files Browse the repository at this point in the history
  • Loading branch information
saratvemulapalli committed Dec 17, 2020
1 parent bd4ae09 commit 3d645bf
Showing 1 changed file with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1083,20 +1083,13 @@ public void testSearchAnomalyDetectorMatch() throws Exception {
}

public void testDeleteAnomalyDetectorWhileRunning() throws Exception {
try {
AnomalyDetector detector = createRandomAnomalyDetector(true, true, client());
Assert.assertNotNull(detector.getDetectorId());
Response response = startAnomalyDetector(detector.getDetectorId(), client());
Assert.assertEquals(response.getStatusLine().toString(), "HTTP/1.1 200 OK");

// Deleting detector should fail while its running
response = deleteAnomalyDetector(detector.getDetectorId(), client());
Assert.assertEquals(response.getStatusLine().toString(), "HTTP/1.1 400 Bad Request");
Assert.assertTrue(false); // Should always raise exception and never end up here
} catch (IOException e) {
if (!e.getMessage().contains("Detector job is running")) {
Assert.assertTrue(false);
}
}
AnomalyDetector detector = createRandomAnomalyDetector(true, true, client());
Assert.assertNotNull(detector.getDetectorId());
Response response = startAnomalyDetector(detector.getDetectorId(), client());
Assert.assertEquals(response.getStatusLine().toString(), "HTTP/1.1 200 OK");

// Deleting detector should fail while its running
Exception exception = expectThrows(IOException.class, () -> { deleteAnomalyDetector(detector.getDetectorId(), client()); });
Assert.assertTrue(exception.getMessage().contains("Detector job is running"));
}
}

0 comments on commit 3d645bf

Please sign in to comment.