Skip to content

Commit

Permalink
upgrade mockito to 4.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
shijiesheng committed Oct 28, 2024
1 parent 760f880 commit 81a6a01
Show file tree
Hide file tree
Showing 24 changed files with 72 additions and 45 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/**
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* <p>Modifications copyright (C) 2017 Uber Technologies, Inc.
*
* <p>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
*
* <p>http://aws.amazon.com/apache2.0
*
* <p>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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -157,9 +157,10 @@ private void assertTracingHeaders(Header header) {
.toString());
}

@SuppressWarnings("CheckReturnValue")
private <REQ, RES> ArgumentCaptor<REQ> mockRpc(
BiConsumer<REQ, StreamObserver<RES>> method, RES value) {
ArgumentCaptor<REQ> captor = new ArgumentCaptor<>();
ArgumentCaptor<REQ> captor = ArgumentCaptor.forClass(null);
doAnswer(
invocation -> {
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/**
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* <p>Modifications copyright (C) 2017 Uber Technologies, Inc.
*
* <p>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
*
* <p>http://aws.amazon.com/apache2.0
*
* <p>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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/**
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* <p>Modifications copyright (C) 2017 Uber Technologies, Inc.
*
* <p>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
*
* <p>http://aws.amazon.com/apache2.0
*
* <p>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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

public class MigrationIWorkflowServiceTest {

Expand All @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -87,15 +87,15 @@ public void testRun_CallReplay_ThrowsException() throws Throwable {
}

private class ScanWorkflowActivityParamsMatcher
extends ArgumentMatcher<ScanWorkflowActivityParams> {
implements ArgumentMatcher<ScanWorkflowActivityParams> {
ScanWorkflowActivityParams params;

public ScanWorkflowActivityParamsMatcher(ScanWorkflowActivityParams params) {
this.params = 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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -103,15 +103,15 @@ public void testStartShadowingWorkflow_ReceiveExpectedRequest() throws Exception
}

private class StartWorkflowExecutionRequestMatcher
extends ArgumentMatcher<StartWorkflowExecutionRequest> {
implements ArgumentMatcher<StartWorkflowExecutionRequest> {
StartWorkflowExecutionRequest request;

public StartWorkflowExecutionRequestMatcher(StartWorkflowExecutionRequest request) {
this.request = request;
}

@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())
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/uber/cadence/worker/StickyWorkerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/com/uber/cadence/workflow/MetricsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
package com.uber.cadence.workflow;

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;
Expand Down

0 comments on commit 81a6a01

Please sign in to comment.