Fix rest of mocking issues, remove awaitsFix
Original commit: elastic/x-pack-elasticsearch@d5e876e867
This commit is contained in:
parent
6e929fb290
commit
1591003c7d
|
@ -5,7 +5,6 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.ml.job.persistence;
|
package org.elasticsearch.xpack.ml.job.persistence;
|
||||||
|
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
|
||||||
import org.elasticsearch.action.ActionListener;
|
import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.action.bulk.BulkResponse;
|
import org.elasticsearch.action.bulk.BulkResponse;
|
||||||
import org.elasticsearch.action.delete.DeleteRequestBuilder;
|
import org.elasticsearch.action.delete.DeleteRequestBuilder;
|
||||||
|
@ -24,7 +23,6 @@ import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.elasticsearch.mock.orig.Mockito.mock;
|
|
||||||
import static org.elasticsearch.mock.orig.Mockito.times;
|
import static org.elasticsearch.mock.orig.Mockito.times;
|
||||||
import static org.elasticsearch.mock.orig.Mockito.verify;
|
import static org.elasticsearch.mock.orig.Mockito.verify;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
|
@ -32,7 +30,6 @@ import static org.mockito.Matchers.anyString;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@LuceneTestCase.AwaitsFix(bugUrl = "[zach] fixing mocking")
|
|
||||||
public class JobDataDeleterTests extends ESTestCase {
|
public class JobDataDeleterTests extends ESTestCase {
|
||||||
|
|
||||||
public void testDeleteResultsFromTime() {
|
public void testDeleteResultsFromTime() {
|
||||||
|
@ -110,8 +107,6 @@ public class JobDataDeleterTests extends ESTestCase {
|
||||||
|
|
||||||
private SearchHits mockSearchHits(long totalHitCount, int hitsPerSearchResult) {
|
private SearchHits mockSearchHits(long totalHitCount, int hitsPerSearchResult) {
|
||||||
|
|
||||||
SearchHits hits = new SearchHits(new SearchHit[(int)totalHitCount], totalHitCount, 1);
|
|
||||||
|
|
||||||
List<SearchHit> hitList = new ArrayList<>();
|
List<SearchHit> hitList = new ArrayList<>();
|
||||||
for (int i=0; i<20; i++) {
|
for (int i=0; i<20; i++) {
|
||||||
SearchHit hit = new SearchHit(123, "mockSeachHit-" + i,
|
SearchHit hit = new SearchHit(123, "mockSeachHit-" + i,
|
||||||
|
@ -119,6 +114,6 @@ public class JobDataDeleterTests extends ESTestCase {
|
||||||
hitList.add(hit);
|
hitList.add(hit);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hits;
|
return new SearchHits(hitList.toArray(new SearchHit[0]), totalHitCount, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,6 @@ import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@LuceneTestCase.AwaitsFix(bugUrl = "[Zach] Fixing mocking")
|
|
||||||
public class JobProviderTests extends ESTestCase {
|
public class JobProviderTests extends ESTestCase {
|
||||||
private static final String CLUSTER_NAME = "myCluster";
|
private static final String CLUSTER_NAME = "myCluster";
|
||||||
private static final String JOB_ID = "foo";
|
private static final String JOB_ID = "foo";
|
||||||
|
@ -1180,11 +1179,6 @@ public class JobProviderTests extends ESTestCase {
|
||||||
SearchHits hits = new SearchHits(list.toArray(new SearchHit[0]), source.size(), 1);
|
SearchHits hits = new SearchHits(list.toArray(new SearchHit[0]), source.size(), 1);
|
||||||
when(response.getHits()).thenReturn(hits);
|
when(response.getHits()).thenReturn(hits);
|
||||||
|
|
||||||
doAnswer(invocation -> {
|
|
||||||
Integer idx = (Integer) invocation.getArguments()[0];
|
|
||||||
return list.get(idx);
|
|
||||||
}).when(hits).getAt(any(Integer.class));
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue