Upgrade mockito lib version to avoid test case failure due to mock mechanism legacy issues.
diff --git a/helix-core/pom.xml b/helix-core/pom.xml
index 19d3eed..da1a72d 100644
--- a/helix-core/pom.xml
+++ b/helix-core/pom.xml
@@ -114,7 +114,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/helix-core/src/test/java/org/apache/helix/common/caches/TestPropertyCache.java b/helix-core/src/test/java/org/apache/helix/common/caches/TestPropertyCache.java
index 1e0b882..10eca77 100644
--- a/helix-core/src/test/java/org/apache/helix/common/caches/TestPropertyCache.java
+++ b/helix-core/src/test/java/org/apache/helix/common/caches/TestPropertyCache.java
@@ -28,10 +28,13 @@
import org.apache.helix.HelixProperty;
import org.apache.helix.PropertyKey;
import org.apache.helix.common.controllers.ControlContextProvider;
+import org.apache.helix.model.IdealState;
import org.apache.helix.model.InstanceConfig;
import org.testng.Assert;
import org.testng.annotations.Test;
+import static org.apache.helix.PropertyType.IDEALSTATES;
+import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -65,12 +68,18 @@
@Test(description = "Unit test for simple cache refresh")
public void testSimpleCacheRefresh() {
- @SuppressWarnings("unchecked")
- PropertyCache<HelixProperty> propertyCache = new PropertyCache<>(MOCK_CONTROL_CONTEXT_PROVIDER,
- "mock property cache", mock(PropertyCache.PropertyCacheKeyFuncs.class), false);
+ PropertyCache.PropertyCacheKeyFuncs propertyCacheKeyFuncs =
+ mock(PropertyCache.PropertyCacheKeyFuncs.class);
+ // Return a random property key, it does not impact test result.
+ when(propertyCacheKeyFuncs.getRootKey(any(HelixDataAccessor.class)))
+ .thenReturn(new PropertyKey(IDEALSTATES, IdealState.class, "Foobar"));
+
+ PropertyCache<HelixProperty> propertyCache =
+ new PropertyCache<>(MOCK_CONTROL_CONTEXT_PROVIDER, "mock property cache",
+ propertyCacheKeyFuncs, false);
HelixDataAccessor accessor = mock(HelixDataAccessor.class);
Map<String, HelixProperty> propertyConfigMap = ImmutableMap.of("id", new HelixProperty("test"));
- when(accessor.getChildValuesMap(any(PropertyKey.class), any(Boolean.class)))
+ when(accessor.getChildValuesMap(any(PropertyKey.class), anyBoolean()))
.thenReturn(propertyConfigMap);
propertyCache.refresh(accessor);
diff --git a/helix-core/src/test/java/org/apache/helix/util/TestInstanceValidationUtil.java b/helix-core/src/test/java/org/apache/helix/util/TestInstanceValidationUtil.java
index 832cedd..04c110d 100644
--- a/helix-core/src/test/java/org/apache/helix/util/TestInstanceValidationUtil.java
+++ b/helix-core/src/test/java/org/apache/helix/util/TestInstanceValidationUtil.java
@@ -486,7 +486,7 @@
}
}
- public static class PropertyKeyArgument extends ArgumentMatcher<PropertyKey> {
+ public static class PropertyKeyArgument implements ArgumentMatcher<PropertyKey> {
private PropertyType propertyType;
public PropertyKeyArgument(PropertyType propertyType) {
@@ -494,9 +494,7 @@
}
@Override
- public boolean matches(Object o) {
- PropertyKey propertyKey = (PropertyKey) o;
-
+ public boolean matches(PropertyKey propertyKey) {
return this.propertyType == propertyKey.getType();
}
}
diff --git a/helix-rest/pom.xml b/helix-rest/pom.xml
index f856ea6..11614f2 100644
--- a/helix-rest/pom.xml
+++ b/helix-rest/pom.xml
@@ -155,7 +155,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/helix-rest/src/test/java/org/apache/helix/rest/server/service/TestInstanceService.java b/helix-rest/src/test/java/org/apache/helix/rest/server/service/TestInstanceService.java
index a03a92f..54db45c 100644
--- a/helix-rest/src/test/java/org/apache/helix/rest/server/service/TestInstanceService.java
+++ b/helix-rest/src/test/java/org/apache/helix/rest/server/service/TestInstanceService.java
@@ -49,6 +49,7 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyList;
import static org.mockito.Matchers.anyMap;
@@ -265,7 +266,7 @@
verify(_configAccessor, times(1)).getRESTConfig(anyString());
verify(_customRestClient, times(1)).getInstanceStoppableCheck(anyString(), anyMap());
verify(_customRestClient, times(2))
- .getPartitionStoppableCheck(anyString(), anyList(), anyMap());
+ .getPartitionStoppableCheck(anyString(), nullable(List.class), anyMap());
}
// TODO re-enable the test when partition health checks get decoupled
diff --git a/pom.xml b/pom.xml
index 8aa2ce4..cf83cff 100644
--- a/pom.xml
+++ b/pom.xml
@@ -512,8 +512,8 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.9.5</version>
+ <artifactId>mockito-core</artifactId>
+ <version>3.12.4</version>
</dependency>
</dependencies>
</dependencyManagement>
diff --git a/zookeeper-api/pom.xml b/zookeeper-api/pom.xml
index 8ee50c1..85fbf96 100644
--- a/zookeeper-api/pom.xml
+++ b/zookeeper-api/pom.xml
@@ -106,7 +106,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>