From cb50fe39b39b5c4264ab9193145560a55eae5588 Mon Sep 17 00:00:00 2001 From: Shijie Sheng Date: Mon, 28 Oct 2024 10:58:15 -0700 Subject: [PATCH 1/2] upgrade mockito to 4.5.1 --- build.gradle | 1 + .../LocalActivityContextPropagationTest.java | 3 --- .../internal/compatibility/ProtoObjects.java | 14 ++++++++++++++ .../compatibility/Thrift2ProtoAdapterTest.java | 5 +++-- .../internal/compatibility/ThriftObjects.java | 14 ++++++++++++++ .../compatibility/proto/DecisionMapperTest.java | 14 ++++++++++++++ .../internal/replay/ReplayDeciderCacheTests.java | 2 -- .../replay/ReplayDeciderTaskHandlerTests.java | 2 +- .../shadowing/ReplayWorkflowActivityTest.java | 2 +- .../shadowing/ScanWorkflowActivityTest.java | 4 ++-- .../internal/sync/WorkflowStubImplTest.java | 4 ++-- .../internal/testing/ActivityTestingTest.java | 2 +- .../internal/testing/WorkflowTestingTest.java | 2 +- .../worker/PollDecisionTaskDispatcherTests.java | 1 - .../internal/worker/WorkerShutDownHandlerTest.java | 9 ++++++--- .../worker/autoscaler/PollerAutoScalerTest.java | 3 --- .../autoscaler/PollerUsageEstimatorTest.java | 3 --- .../worker/autoscaler/RecommenderTest.java | 3 --- .../worker/autoscaler/ResizableSemaphoreTest.java | 3 --- .../migration/MigrationIWorkflowServiceTest.java | 4 ++-- .../uber/cadence/testing/WorkflowShadowerTest.java | 8 ++++---- .../uber/cadence/worker/ShadowingWorkerTest.java | 8 ++++---- .../com/uber/cadence/worker/StickyWorkerTest.java | 4 ++-- .../com/uber/cadence/workflow/MetricsTest.java | 2 -- 24 files changed, 72 insertions(+), 45 deletions(-) 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 ArgumentCaptor mockRpc( BiConsumer> method, RES value) { - ArgumentCaptor captor = new ArgumentCaptor<>(); + ArgumentCaptor captor = ArgumentCaptor.forClass(null); doAnswer( invocation -> { @SuppressWarnings("unchecked") diff --git a/src/test/java/com/uber/cadence/internal/compatibility/ThriftObjects.java b/src/test/java/com/uber/cadence/internal/compatibility/ThriftObjects.java index d3269daa1..5c7e7308a 100644 --- a/src/test/java/com/uber/cadence/internal/compatibility/ThriftObjects.java +++ b/src/test/java/com/uber/cadence/internal/compatibility/ThriftObjects.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/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..437a98257 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; 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/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..72aec6062 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,12 +29,14 @@ 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 { + @Before + public void setUp() { + mockClient = mock(WorkflowClient.class); + mockService = mock(IWorkflowService.class); + } @Mock private WorkflowClient mockClient; 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 { + implements ArgumentMatcher { ScanWorkflowActivityParams params; public ScanWorkflowActivityParamsMatcher(ScanWorkflowActivityParams params) { @@ -95,7 +95,7 @@ public ScanWorkflowActivityParamsMatcher(ScanWorkflowActivityParams params) { } @Override - public boolean matches(Object argument) { + public boolean matches(ScanWorkflowActivityParams argument) { ScanWorkflowActivityParams newParams = (ScanWorkflowActivityParams) argument; return params.getDomain().equals(newParams.getDomain()) && params.getWorkflowQuery().equals(newParams.getWorkflowQuery()) diff --git a/src/test/java/com/uber/cadence/worker/ShadowingWorkerTest.java b/src/test/java/com/uber/cadence/worker/ShadowingWorkerTest.java index 8be2a91e6..7c338731a 100644 --- a/src/test/java/com/uber/cadence/worker/ShadowingWorkerTest.java +++ b/src/test/java/com/uber/cadence/worker/ShadowingWorkerTest.java @@ -16,8 +16,8 @@ */ package com.uber.cadence.worker; -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.verify; import static org.mockito.Mockito.when; @@ -103,7 +103,7 @@ public void testStartShadowingWorkflow_ReceiveExpectedRequest() throws Exception } private class StartWorkflowExecutionRequestMatcher - extends ArgumentMatcher { + implements ArgumentMatcher { StartWorkflowExecutionRequest request; public StartWorkflowExecutionRequestMatcher(StartWorkflowExecutionRequest request) { @@ -111,7 +111,7 @@ public StartWorkflowExecutionRequestMatcher(StartWorkflowExecutionRequest reques } @Override - public boolean matches(Object argument) { + public boolean matches(StartWorkflowExecutionRequest argument) { StartWorkflowExecutionRequest newRequest = (StartWorkflowExecutionRequest) argument; return request.getDomain().equals(newRequest.getDomain()) && request.getTaskList().equals(newRequest.getTaskList()) diff --git a/src/test/java/com/uber/cadence/worker/StickyWorkerTest.java b/src/test/java/com/uber/cadence/worker/StickyWorkerTest.java index eaa79218f..01ff2811c 100644 --- a/src/test/java/com/uber/cadence/worker/StickyWorkerTest.java +++ b/src/test/java/com/uber/cadence/worker/StickyWorkerTest.java @@ -21,8 +21,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; diff --git a/src/test/java/com/uber/cadence/workflow/MetricsTest.java b/src/test/java/com/uber/cadence/workflow/MetricsTest.java index 4b84a0919..a583e040e 100644 --- a/src/test/java/com/uber/cadence/workflow/MetricsTest.java +++ b/src/test/java/com/uber/cadence/workflow/MetricsTest.java @@ -19,8 +19,6 @@ import static com.uber.cadence.testUtils.TestEnvironment.DOMAIN; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; import static org.mockito.Mockito.*; import com.uber.cadence.activity.ActivityOptions; From 95663cfb57f7ad6e8e31ae5bcf3707f67f1d3aec Mon Sep 17 00:00:00 2001 From: Shijie Sheng Date: Mon, 28 Oct 2024 13:51:18 -0700 Subject: [PATCH 2/2] fix unit test --- .../replay/ReplayDeciderCacheTests.java | 2 +- .../sync/DeterministicRunnerTest.java | 2 +- .../worker/WorkerShutDownHandlerTest.java | 7 ++----- .../uber/cadence/worker/StickyWorkerTest.java | 19 +++++++++---------- .../uber/cadence/workflow/WorkflowTest.java | 6 ------ 5 files changed, 13 insertions(+), 23 deletions(-) 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 437a98257..564ad78ea 100644 --- a/src/test/java/com/uber/cadence/internal/replay/ReplayDeciderCacheTests.java +++ b/src/test/java/com/uber/cadence/internal/replay/ReplayDeciderCacheTests.java @@ -209,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/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/worker/WorkerShutDownHandlerTest.java b/src/test/java/com/uber/cadence/internal/worker/WorkerShutDownHandlerTest.java index 72aec6062..7098c6f68 100644 --- a/src/test/java/com/uber/cadence/internal/worker/WorkerShutDownHandlerTest.java +++ b/src/test/java/com/uber/cadence/internal/worker/WorkerShutDownHandlerTest.java @@ -32,11 +32,6 @@ import org.mockito.Mock; public class WorkerShutDownHandlerTest { - @Before - public void setUp() { - mockClient = mock(WorkflowClient.class); - mockService = mock(IWorkflowService.class); - } @Mock private WorkflowClient mockClient; @@ -44,6 +39,8 @@ public void setUp() { @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/worker/StickyWorkerTest.java b/src/test/java/com/uber/cadence/worker/StickyWorkerTest.java index 01ff2811c..2b7375580 100644 --- a/src/test/java/com/uber/cadence/worker/StickyWorkerTest.java +++ b/src/test/java/com/uber/cadence/worker/StickyWorkerTest.java @@ -21,8 +21,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -156,8 +155,8 @@ public void whenStickyIsEnabledThenTheWorkflowIsCachedSignals() throws Exception .build(); Thread.sleep(600); verify(reporter, atLeastOnce()) - .reportCounter(eq(MetricsType.STICKY_CACHE_HIT), eq(tags), anyInt()); - verify(reporter, never()).reportCounter(eq(MetricsType.STICKY_CACHE_MISS), eq(tags), anyInt()); + .reportCounter(eq(MetricsType.STICKY_CACHE_HIT), eq(tags), anyLong()); + verify(reporter, never()).reportCounter(eq(MetricsType.STICKY_CACHE_MISS), eq(tags), anyLong()); // Finish Workflow wrapper.close(); @@ -269,8 +268,8 @@ public void whenStickyIsEnabledThenTheWorkflowIsCachedActivities() throws Except .put(MetricsTag.TASK_LIST, STICKY_TASK_LIST_METRIC_TAG) .build(); verify(reporter, atLeastOnce()) - .reportCounter(eq(MetricsType.STICKY_CACHE_HIT), eq(tags), anyInt()); - verify(reporter, never()).reportCounter(eq(MetricsType.STICKY_CACHE_MISS), eq(tags), anyInt()); + .reportCounter(eq(MetricsType.STICKY_CACHE_HIT), eq(tags), anyLong()); + verify(reporter, never()).reportCounter(eq(MetricsType.STICKY_CACHE_MISS), eq(tags), anyLong()); // Finish Workflow wrapper.close(); @@ -318,8 +317,8 @@ public void whenStickyIsEnabledThenTheWorkflowIsCachedChildWorkflows() throws Ex .put(MetricsTag.TASK_LIST, STICKY_TASK_LIST_METRIC_TAG) .build(); verify(reporter, atLeastOnce()) - .reportCounter(eq(MetricsType.STICKY_CACHE_HIT), eq(tags), anyInt()); - verify(reporter, never()).reportCounter(eq(MetricsType.STICKY_CACHE_MISS), eq(tags), anyInt()); + .reportCounter(eq(MetricsType.STICKY_CACHE_HIT), eq(tags), anyLong()); + verify(reporter, never()).reportCounter(eq(MetricsType.STICKY_CACHE_MISS), eq(tags), anyLong()); // Finish Workflow wrapper.close(); } @@ -374,8 +373,8 @@ public void whenStickyIsEnabledThenTheWorkflowIsCachedMutableSideEffect() throws .put(MetricsTag.TASK_LIST, STICKY_TASK_LIST_METRIC_TAG) .build(); verify(reporter, atLeastOnce()) - .reportCounter(eq(MetricsType.STICKY_CACHE_HIT), eq(tags), anyInt()); - verify(reporter, never()).reportCounter(eq(MetricsType.STICKY_CACHE_MISS), eq(tags), anyInt()); + .reportCounter(eq(MetricsType.STICKY_CACHE_HIT), eq(tags), anyLong()); + verify(reporter, never()).reportCounter(eq(MetricsType.STICKY_CACHE_MISS), eq(tags), anyLong()); // Finish Workflow wrapper.close(); } diff --git a/src/test/java/com/uber/cadence/workflow/WorkflowTest.java b/src/test/java/com/uber/cadence/workflow/WorkflowTest.java index 36576bb89..4535afd16 100644 --- a/src/test/java/com/uber/cadence/workflow/WorkflowTest.java +++ b/src/test/java/com/uber/cadence/workflow/WorkflowTest.java @@ -27,8 +27,6 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.junit.Assume.assumeTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import com.google.common.base.Strings; import com.google.common.util.concurrent.UncheckedExecutionException; @@ -5730,10 +5728,6 @@ public String getState() { @Test public void testGetVersionRetry() throws ExecutionException, InterruptedException { - TestActivities activity = mock(TestActivities.class); - when(activity.activity1(1)).thenReturn(1); - cadenceTestRule.getWorker().registerActivitiesImplementations(activity); - startWorkerFor(TestGetVersionWorkflowRetryImpl.class); TestWorkflow3 workflowStub = workflowClient.newWorkflowStub(