diff --git a/build.gradle b/build.gradle index cd3673394..2e6218add 100644 --- a/build.gradle +++ b/build.gradle @@ -83,6 +83,7 @@ dependencies { testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' testCompile group: 'io.grpc', name: 'grpc-testing', version: '1.54.2' testImplementation 'io.opentracing:opentracing-mock:0.33.0' + testImplementation group: 'org.mockito', name: 'mockito-core', version: '4.5.1' } license { diff --git a/src/test/java/com/uber/cadence/activity/LocalActivityContextPropagationTest.java b/src/test/java/com/uber/cadence/activity/LocalActivityContextPropagationTest.java index 2e1b4581f..4acb622d2 100644 --- a/src/test/java/com/uber/cadence/activity/LocalActivityContextPropagationTest.java +++ b/src/test/java/com/uber/cadence/activity/LocalActivityContextPropagationTest.java @@ -39,10 +39,7 @@ import java.util.Map; import java.util.Optional; import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -@RunWith(MockitoJUnitRunner.class) public class LocalActivityContextPropagationTest { private static final String LOCAL_ACTIVITY_CP_TASK_LIST = "LOCAL_ACTIVITY_CP_TASK_LIST"; diff --git a/src/test/java/com/uber/cadence/internal/compatibility/ProtoObjects.java b/src/test/java/com/uber/cadence/internal/compatibility/ProtoObjects.java index 30c9100cb..3c029b8e7 100644 --- a/src/test/java/com/uber/cadence/internal/compatibility/ProtoObjects.java +++ b/src/test/java/com/uber/cadence/internal/compatibility/ProtoObjects.java @@ -1,3 +1,17 @@ +/** + * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + *
Modifications copyright (C) 2017 Uber Technologies, Inc. + * + *
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file + * except in compliance with the License. A copy of the License is located at + * + *
http://aws.amazon.com/apache2.0 + * + *
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
package com.uber.cadence.internal.compatibility;
import com.google.common.collect.ImmutableList;
diff --git a/src/test/java/com/uber/cadence/internal/compatibility/Thrift2ProtoAdapterTest.java b/src/test/java/com/uber/cadence/internal/compatibility/Thrift2ProtoAdapterTest.java
index 62197570f..2b35eb21a 100644
--- a/src/test/java/com/uber/cadence/internal/compatibility/Thrift2ProtoAdapterTest.java
+++ b/src/test/java/com/uber/cadence/internal/compatibility/Thrift2ProtoAdapterTest.java
@@ -19,7 +19,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import com.uber.cadence.SignalWithStartWorkflowExecutionAsyncRequest;
@@ -157,9 +157,10 @@ private void assertTracingHeaders(Header header) {
.toString());
}
+ @SuppressWarnings("CheckReturnValue")
private Modifications copyright (C) 2017 Uber Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
+ * except in compliance with the License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
package com.uber.cadence.internal.compatibility;
import com.google.common.collect.ImmutableList;
diff --git a/src/test/java/com/uber/cadence/internal/compatibility/proto/DecisionMapperTest.java b/src/test/java/com/uber/cadence/internal/compatibility/proto/DecisionMapperTest.java
index 163d64858..f12ad2d53 100644
--- a/src/test/java/com/uber/cadence/internal/compatibility/proto/DecisionMapperTest.java
+++ b/src/test/java/com/uber/cadence/internal/compatibility/proto/DecisionMapperTest.java
@@ -1,3 +1,17 @@
+/**
+ * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Modifications copyright (C) 2017 Uber Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
+ * except in compliance with the License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
package com.uber.cadence.internal.compatibility.proto;
import static com.uber.cadence.internal.compatibility.MapperTestUtil.assertMissingFields;
diff --git a/src/test/java/com/uber/cadence/internal/replay/ReplayDeciderCacheTests.java b/src/test/java/com/uber/cadence/internal/replay/ReplayDeciderCacheTests.java
index e790bec59..564ad78ea 100644
--- a/src/test/java/com/uber/cadence/internal/replay/ReplayDeciderCacheTests.java
+++ b/src/test/java/com/uber/cadence/internal/replay/ReplayDeciderCacheTests.java
@@ -19,8 +19,6 @@
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.*;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
import com.uber.cadence.HistoryEvent;
@@ -211,7 +209,7 @@ public void evictAnyWillInvalidateAnEntryRandomlyFromTheCache() throws Exception
// Wait for reporter
Thread.sleep(600);
verify(reporter, atLeastOnce())
- .reportCounter(eq(MetricsType.STICKY_CACHE_TOTAL_FORCED_EVICTION), eq(tags), anyInt());
+ .reportCounter(eq(MetricsType.STICKY_CACHE_TOTAL_FORCED_EVICTION), eq(tags), anyLong());
}
@Test
diff --git a/src/test/java/com/uber/cadence/internal/replay/ReplayDeciderTaskHandlerTests.java b/src/test/java/com/uber/cadence/internal/replay/ReplayDeciderTaskHandlerTests.java
index fb9f6bbb1..186141c0a 100644
--- a/src/test/java/com/uber/cadence/internal/replay/ReplayDeciderTaskHandlerTests.java
+++ b/src/test/java/com/uber/cadence/internal/replay/ReplayDeciderTaskHandlerTests.java
@@ -21,7 +21,7 @@
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/src/test/java/com/uber/cadence/internal/shadowing/ReplayWorkflowActivityTest.java b/src/test/java/com/uber/cadence/internal/shadowing/ReplayWorkflowActivityTest.java
index 77ed1786a..4e1df82c3 100644
--- a/src/test/java/com/uber/cadence/internal/shadowing/ReplayWorkflowActivityTest.java
+++ b/src/test/java/com/uber/cadence/internal/shadowing/ReplayWorkflowActivityTest.java
@@ -23,7 +23,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/src/test/java/com/uber/cadence/internal/shadowing/ScanWorkflowActivityTest.java b/src/test/java/com/uber/cadence/internal/shadowing/ScanWorkflowActivityTest.java
index 187c695e4..a16bee129 100644
--- a/src/test/java/com/uber/cadence/internal/shadowing/ScanWorkflowActivityTest.java
+++ b/src/test/java/com/uber/cadence/internal/shadowing/ScanWorkflowActivityTest.java
@@ -17,8 +17,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/src/test/java/com/uber/cadence/internal/sync/DeterministicRunnerTest.java b/src/test/java/com/uber/cadence/internal/sync/DeterministicRunnerTest.java
index 36747dad0..e53c3e662 100644
--- a/src/test/java/com/uber/cadence/internal/sync/DeterministicRunnerTest.java
+++ b/src/test/java/com/uber/cadence/internal/sync/DeterministicRunnerTest.java
@@ -779,7 +779,7 @@ public void workflowThreadsWillEvictCacheWhenMaxThreadCountIsHit() throws Throwa
// Wait for reporter
Thread.sleep(600);
verify(reporter, atLeastOnce())
- .reportCounter(eq(MetricsType.STICKY_CACHE_THREAD_FORCED_EVICTION), eq(tags), anyInt());
+ .reportCounter(eq(MetricsType.STICKY_CACHE_THREAD_FORCED_EVICTION), eq(tags), anyLong());
}
@Test
diff --git a/src/test/java/com/uber/cadence/internal/sync/WorkflowStubImplTest.java b/src/test/java/com/uber/cadence/internal/sync/WorkflowStubImplTest.java
index 7516634ef..4cafd2236 100644
--- a/src/test/java/com/uber/cadence/internal/sync/WorkflowStubImplTest.java
+++ b/src/test/java/com/uber/cadence/internal/sync/WorkflowStubImplTest.java
@@ -19,8 +19,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
diff --git a/src/test/java/com/uber/cadence/internal/testing/ActivityTestingTest.java b/src/test/java/com/uber/cadence/internal/testing/ActivityTestingTest.java
index 9603f9e4c..9275c6891 100644
--- a/src/test/java/com/uber/cadence/internal/testing/ActivityTestingTest.java
+++ b/src/test/java/com/uber/cadence/internal/testing/ActivityTestingTest.java
@@ -20,7 +20,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/src/test/java/com/uber/cadence/internal/testing/WorkflowTestingTest.java b/src/test/java/com/uber/cadence/internal/testing/WorkflowTestingTest.java
index 4cd94778a..08051a726 100644
--- a/src/test/java/com/uber/cadence/internal/testing/WorkflowTestingTest.java
+++ b/src/test/java/com/uber/cadence/internal/testing/WorkflowTestingTest.java
@@ -18,7 +18,7 @@
package com.uber.cadence.internal.testing;
import static org.junit.Assert.*;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/src/test/java/com/uber/cadence/internal/worker/PollDecisionTaskDispatcherTests.java b/src/test/java/com/uber/cadence/internal/worker/PollDecisionTaskDispatcherTests.java
index d399b40a9..cff5c3a1a 100644
--- a/src/test/java/com/uber/cadence/internal/worker/PollDecisionTaskDispatcherTests.java
+++ b/src/test/java/com/uber/cadence/internal/worker/PollDecisionTaskDispatcherTests.java
@@ -18,7 +18,6 @@
package com.uber.cadence.internal.worker;
import static junit.framework.TestCase.*;
-import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
import ch.qos.logback.classic.Level;
diff --git a/src/test/java/com/uber/cadence/internal/worker/WorkerShutDownHandlerTest.java b/src/test/java/com/uber/cadence/internal/worker/WorkerShutDownHandlerTest.java
index a99f27c17..7098c6f68 100644
--- a/src/test/java/com/uber/cadence/internal/worker/WorkerShutDownHandlerTest.java
+++ b/src/test/java/com/uber/cadence/internal/worker/WorkerShutDownHandlerTest.java
@@ -18,6 +18,7 @@
package com.uber.cadence.internal.worker;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.uber.cadence.client.WorkflowClient;
@@ -28,11 +29,8 @@
import com.uber.m3.tally.NoopScope;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-@RunWith(MockitoJUnitRunner.class)
public class WorkerShutDownHandlerTest {
@Mock private WorkflowClient mockClient;
@@ -41,6 +39,8 @@ public class WorkerShutDownHandlerTest {
@Before
public void setup() {
+ mockClient = mock(WorkflowClient.class);
+ mockService = mock(IWorkflowService.class);
WorkflowClientOptions clientOptions =
WorkflowClientOptions.newBuilder().setMetricsScope(new NoopScope()).build();
when(mockClient.getOptions()).thenReturn(clientOptions);
diff --git a/src/test/java/com/uber/cadence/internal/worker/autoscaler/PollerAutoScalerTest.java b/src/test/java/com/uber/cadence/internal/worker/autoscaler/PollerAutoScalerTest.java
index dc9479e2c..f660e5c72 100644
--- a/src/test/java/com/uber/cadence/internal/worker/autoscaler/PollerAutoScalerTest.java
+++ b/src/test/java/com/uber/cadence/internal/worker/autoscaler/PollerAutoScalerTest.java
@@ -19,10 +19,7 @@
import java.time.Duration;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-@RunWith(MockitoJUnitRunner.class)
public class PollerAutoScalerTest {
@Test
diff --git a/src/test/java/com/uber/cadence/internal/worker/autoscaler/PollerUsageEstimatorTest.java b/src/test/java/com/uber/cadence/internal/worker/autoscaler/PollerUsageEstimatorTest.java
index d31bcd394..2d1390c33 100644
--- a/src/test/java/com/uber/cadence/internal/worker/autoscaler/PollerUsageEstimatorTest.java
+++ b/src/test/java/com/uber/cadence/internal/worker/autoscaler/PollerUsageEstimatorTest.java
@@ -20,10 +20,7 @@
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-@RunWith(MockitoJUnitRunner.class)
public class PollerUsageEstimatorTest {
@Test
diff --git a/src/test/java/com/uber/cadence/internal/worker/autoscaler/RecommenderTest.java b/src/test/java/com/uber/cadence/internal/worker/autoscaler/RecommenderTest.java
index b37a3ebdf..56384639a 100644
--- a/src/test/java/com/uber/cadence/internal/worker/autoscaler/RecommenderTest.java
+++ b/src/test/java/com/uber/cadence/internal/worker/autoscaler/RecommenderTest.java
@@ -18,10 +18,7 @@
import static org.junit.Assert.*;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-@RunWith(MockitoJUnitRunner.class)
public class RecommenderTest {
@Test
diff --git a/src/test/java/com/uber/cadence/internal/worker/autoscaler/ResizableSemaphoreTest.java b/src/test/java/com/uber/cadence/internal/worker/autoscaler/ResizableSemaphoreTest.java
index 13c9288d9..d5b09f780 100644
--- a/src/test/java/com/uber/cadence/internal/worker/autoscaler/ResizableSemaphoreTest.java
+++ b/src/test/java/com/uber/cadence/internal/worker/autoscaler/ResizableSemaphoreTest.java
@@ -18,10 +18,7 @@
import static org.junit.Assert.*;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-@RunWith(MockitoJUnitRunner.class)
public class ResizableSemaphoreTest {
@Test
diff --git a/src/test/java/com/uber/cadence/migration/MigrationIWorkflowServiceTest.java b/src/test/java/com/uber/cadence/migration/MigrationIWorkflowServiceTest.java
index 92537aac2..163411976 100644
--- a/src/test/java/com/uber/cadence/migration/MigrationIWorkflowServiceTest.java
+++ b/src/test/java/com/uber/cadence/migration/MigrationIWorkflowServiceTest.java
@@ -27,7 +27,6 @@
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
public class MigrationIWorkflowServiceTest {
@@ -38,7 +37,8 @@ public class MigrationIWorkflowServiceTest {
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
+ serviceOld = mock(IWorkflowService.class);
+ serviceNew = mock(IWorkflowService.class);
migrationService =
new MigrationIWorkflowService(serviceOld, "domainOld", serviceNew, "domainNew");
}
diff --git a/src/test/java/com/uber/cadence/testing/WorkflowShadowerTest.java b/src/test/java/com/uber/cadence/testing/WorkflowShadowerTest.java
index 82d4cf7ac..06a532ea9 100644
--- a/src/test/java/com/uber/cadence/testing/WorkflowShadowerTest.java
+++ b/src/test/java/com/uber/cadence/testing/WorkflowShadowerTest.java
@@ -15,8 +15,8 @@
*/
package com.uber.cadence.testing;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.argThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -87,7 +87,7 @@ public void testRun_CallReplay_ThrowsException() throws Throwable {
}
private class ScanWorkflowActivityParamsMatcher
- extends ArgumentMatcher