Fix a knock-on effect of removing JobLogs
Original commit: elastic/x-pack-elasticsearch@501fcda045
This commit is contained in:
parent
c1d8b31b0e
commit
c6d52cd949
|
@ -17,6 +17,7 @@ import org.elasticsearch.search.SearchHit;
|
|||
import org.elasticsearch.search.SearchHitField;
|
||||
import org.elasticsearch.search.SearchHits;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.prelert.action.DeleteJobAction;
|
||||
import org.elasticsearch.xpack.prelert.job.AnalysisLimits;
|
||||
import org.elasticsearch.xpack.prelert.job.CategorizerState;
|
||||
import org.elasticsearch.xpack.prelert.job.Job;
|
||||
|
@ -163,7 +164,7 @@ public class ElasticsearchJobProviderTests extends ESTestCase {
|
|||
|
||||
public void testDeleteJob() throws InterruptedException, ExecutionException, IOException {
|
||||
@SuppressWarnings("unchecked")
|
||||
ActionListener<Boolean> actionListener = mock(ActionListener.class);
|
||||
ActionListener<DeleteJobAction.Response> actionListener = mock(ActionListener.class);
|
||||
String jobId = "ThisIsMyJob";
|
||||
MockClientBuilder clientBuilder = new MockClientBuilder(CLUSTER_NAME).addClusterStatusYellowResponse()
|
||||
.addIndicesExistsResponse(ElasticsearchJobProvider.PRELERT_USAGE_INDEX, true);
|
||||
|
@ -176,12 +177,14 @@ public class ElasticsearchJobProviderTests extends ESTestCase {
|
|||
|
||||
provider.deleteJobRelatedIndices(jobId, actionListener);
|
||||
|
||||
verify(actionListener).onResponse(true);
|
||||
ArgumentCaptor<DeleteJobAction.Response> responseCaptor = ArgumentCaptor.forClass(DeleteJobAction.Response.class);
|
||||
verify(actionListener).onResponse(responseCaptor.capture());
|
||||
assertTrue(responseCaptor.getValue().isAcknowledged());
|
||||
}
|
||||
|
||||
public void testDeleteJob_InvalidIndex() throws InterruptedException, ExecutionException, IOException {
|
||||
@SuppressWarnings("unchecked")
|
||||
ActionListener<Boolean> actionListener = mock(ActionListener.class);
|
||||
ActionListener<DeleteJobAction.Response> actionListener = mock(ActionListener.class);
|
||||
String jobId = "ThisIsMyJob";
|
||||
MockClientBuilder clientBuilder = new MockClientBuilder(CLUSTER_NAME).addClusterStatusYellowResponse()
|
||||
.addIndicesExistsResponse(ElasticsearchJobProvider.PRELERT_USAGE_INDEX, true);
|
||||
|
|
|
@ -58,6 +58,7 @@ import org.elasticsearch.index.query.QueryBuilder;
|
|||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.search.sort.SortBuilder;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
import org.elasticsearch.xpack.prelert.action.DeleteJobAction;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.mockito.Mock;
|
||||
|
@ -161,7 +162,7 @@ public class MockClientBuilder {
|
|||
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public MockClientBuilder addIndicesDeleteResponse(String index, boolean exists, boolean exception,
|
||||
ActionListener<Boolean> actionListener) throws InterruptedException, ExecutionException, IOException {
|
||||
ActionListener<DeleteJobAction.Response> actionListener) throws InterruptedException, ExecutionException, IOException {
|
||||
DeleteIndexResponse response = DeleteIndexAction.INSTANCE.newResponse();
|
||||
StreamInput si = mock(StreamInput.class);
|
||||
when(si.readByte()).thenReturn((byte) 0x41);
|
||||
|
@ -174,7 +175,7 @@ public class MockClientBuilder {
|
|||
if (exception) {
|
||||
actionListener.onFailure(new InterruptedException());
|
||||
} else {
|
||||
actionListener.onResponse(true);
|
||||
actionListener.onResponse(new DeleteJobAction.Response(true));
|
||||
}
|
||||
return null;
|
||||
}).when(indicesAdminClient).delete(any(DeleteIndexRequest.class), any(ActionListener.class));
|
||||
|
|
Loading…
Reference in New Issue