Skip to content

Commit 59c0286

Browse files
committed
Mock updateProjectPersistentTaskState
1 parent ba8e9a1 commit 59c0286

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderTests.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,11 @@ public void testUpdateTaskState() {
508508
projectId
509509
) {
510510
@Override
511-
public void updatePersistentTaskState(PersistentTaskState state, ActionListener<PersistentTask<?>> listener) {
511+
public void updateProjectPersistentTaskState(
512+
ProjectId projectId,
513+
PersistentTaskState state,
514+
ActionListener<PersistentTask<?>> listener
515+
) {
512516
assertSame(GeoIpTaskState.EMPTY, state);
513517
PersistentTask<?> task = mock(PersistentTask.class);
514518
when(task.getState()).thenReturn(GeoIpTaskState.EMPTY);
@@ -539,7 +543,11 @@ public void testUpdateTaskStateError() {
539543
projectId
540544
) {
541545
@Override
542-
public void updatePersistentTaskState(PersistentTaskState state, ActionListener<PersistentTask<?>> listener) {
546+
public void updateProjectPersistentTaskState(
547+
ProjectId projectId,
548+
PersistentTaskState state,
549+
ActionListener<PersistentTask<?>> listener
550+
) {
543551
assertSame(GeoIpTaskState.EMPTY, state);
544552
PersistentTask<?> task = mock(PersistentTask.class);
545553
when(task.getState()).thenReturn(GeoIpTaskState.EMPTY);
@@ -627,7 +635,7 @@ public void testThatRunDownloaderDeletesExpiredDatabases() {
627635
* This test puts some expired databases and some non-expired ones into the GeoIpTaskState, and then calls runDownloader(), making
628636
* sure that the expired databases have been deleted.
629637
*/
630-
AtomicInteger updatePersistentTaskStateCount = new AtomicInteger(0);
638+
AtomicInteger updateProjectPersistentTaskStateCount = new AtomicInteger(0);
631639
AtomicInteger deleteCount = new AtomicInteger(0);
632640
int expiredDatabasesCount = randomIntBetween(1, 100);
633641
int unexpiredDatabasesCount = randomIntBetween(0, 100);
@@ -651,7 +659,7 @@ public void testThatRunDownloaderDeletesExpiredDatabases() {
651659
request.getAllocationId(),
652660
assignment
653661
);
654-
updatePersistentTaskStateCount.incrementAndGet();
662+
updateProjectPersistentTaskStateCount.incrementAndGet();
655663
taskResponseListener.onResponse(new PersistentTaskResponse(new PersistentTask<>(persistentTask, request.getState())));
656664
}
657665
);
@@ -674,14 +682,14 @@ public void testThatRunDownloaderDeletesExpiredDatabases() {
674682
);
675683
}
676684
assertThat(deleteCount.get(), equalTo(expiredDatabasesCount));
677-
assertThat(updatePersistentTaskStateCount.get(), equalTo(expiredDatabasesCount));
685+
assertThat(updateProjectPersistentTaskStateCount.get(), equalTo(expiredDatabasesCount));
678686
geoIpDownloader.runDownloader();
679687
/*
680688
* The following two lines assert current behavior that might not be desirable -- we continue to delete expired databases every
681689
* time that runDownloader runs. This seems unnecessary.
682690
*/
683691
assertThat(deleteCount.get(), equalTo(expiredDatabasesCount * 2));
684-
assertThat(updatePersistentTaskStateCount.get(), equalTo(expiredDatabasesCount * 2));
692+
assertThat(updateProjectPersistentTaskStateCount.get(), equalTo(expiredDatabasesCount * 2));
685693
}
686694

687695
private GeoIpTaskState.Metadata newGeoIpTaskStateMetadata(boolean expired) {

0 commit comments

Comments
 (0)