Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly rewrite verifyZeroInteractions #975

Merged
merged 2 commits into from
Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.palantir.baseline.refaster;

import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;

import com.google.errorprone.refaster.ImportPolicy;
Expand All @@ -25,7 +25,7 @@
import com.google.errorprone.refaster.annotation.Repeated;
import com.google.errorprone.refaster.annotation.UseImportPolicy;

public final class MockitoVerifyNoInteractions {
public final class MockitoVerifyZeroInteractions {

@BeforeTemplate
@SuppressWarnings("deprecation")
Expand All @@ -37,6 +37,6 @@ void before(@Repeated Object varargs) {
@AfterTemplate
@UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)
void after(@Repeated Object varargs) {
verifyNoInteractions(varargs);
verifyNoMoreInteractions(varargs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

import org.junit.Test;

public class MockitoVerifyNoInteractionsTest {
public class MockitoVerifyZeroInteractionsTest {

@Test
public void testSingleArg() {
RefasterTestHelper
.forRefactoring(MockitoVerifyNoInteractions.class)
.forRefactoring(MockitoVerifyZeroInteractions.class)
.withInputLines(
"Test",
"import static org.mockito.Mockito.verifyZeroInteractions;",
Expand All @@ -33,19 +33,19 @@ public void testSingleArg() {
" }",
"}")
.hasOutputLines(
"import static org.mockito.Mockito.verifyNoInteractions;",
"import static org.mockito.Mockito.verifyNoMoreInteractions;",
"import static org.mockito.Mockito.verifyZeroInteractions;",
"public class Test {",
" void test(Object mock) {",
" verifyNoInteractions(mock);",
" verifyNoMoreInteractions(mock);",
" }",
"}");
}

@Test
public void testMultipleArgs() {
RefasterTestHelper
.forRefactoring(MockitoVerifyNoInteractions.class)
.forRefactoring(MockitoVerifyZeroInteractions.class)
.withInputLines(
"Test",
"import static org.mockito.Mockito.verifyZeroInteractions;",
Expand All @@ -55,19 +55,19 @@ public void testMultipleArgs() {
" }",
"}")
.hasOutputLines(
"import static org.mockito.Mockito.verifyNoInteractions;",
"import static org.mockito.Mockito.verifyNoMoreInteractions;",
"import static org.mockito.Mockito.verifyZeroInteractions;",
"public class Test {",
" void test(Object mock1, Object mock2) {",
" verifyNoInteractions(mock1, mock2);",
" verifyNoMoreInteractions(mock1, mock2);",
" }",
"}");
}

@Test
public void testVarArgs() {
RefasterTestHelper
.forRefactoring(MockitoVerifyNoInteractions.class)
.forRefactoring(MockitoVerifyZeroInteractions.class)
.withInputLines(
"Test",
"import static org.mockito.Mockito.verifyZeroInteractions;",
Expand All @@ -77,11 +77,11 @@ public void testVarArgs() {
" }",
"}")
.hasOutputLines(
"import static org.mockito.Mockito.verifyNoInteractions;",
"import static org.mockito.Mockito.verifyNoMoreInteractions;",
"import static org.mockito.Mockito.verifyZeroInteractions;",
"public class Test {",
" void test(Object... mocks) {",
" verifyNoInteractions(mocks);",
" verifyNoMoreInteractions(mocks);",
" }",
"}");
}
Expand Down
6 changes: 6 additions & 0 deletions changelog/@unreleased/pr-975.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: fix
fix:
description: The deprecated `verifyZeroInteractions` now gets rewritten to `verifyNoMoreInteractions`,
which has the same behaviour.
links:
- https://github.com/palantir/gradle-baseline/pull/975