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

Bump versions.errorprone from 2.10.0 to 2.11.0 #2553

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ allprojects { proj ->
mavenCentral()
google()
}
plugins.withId('java') {
proj.apply from: "$rootDir/gradle/errorprone.gradle"
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
plugins.withId('java') {
proj.apply from: "$rootDir/gradle/errorprone.gradle"
}
}
tasks.withType(JavaCompile) {
//I don't believe those warnings add value given modern IDEs
Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def versions = [:]

versions.bytebuddy = '1.12.7'
versions.junitJupiter = '5.8.2'
versions.errorprone = '2.10.0'
versions.errorprone = '2.11.0'

libraries.junit4 = 'junit:junit:4.13.2'
libraries.junitJupiterApi = "org.junit.jupiter:junit-jupiter-api:${versions.junitJupiter}"
Expand Down
7 changes: 6 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ include("inline",
"junitJupiterInlineMockMakerExtensionTest",
"module-test",
"memory-test",
"errorprone",
"junitJupiterParallelTest",
"osgi-test",
"bom")

if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) {
include("errorprone")
} else {
logger.info("Not including errorprone, which requires minimum JDK 11+")
}

if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17) && (System.getenv("ANDROID_SDK_ROOT") != null || File(".local.properties").exists())) {
include("androidTest")
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Map;

import org.assertj.core.api.Assertions;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.Before;
import org.junit.Test;
import org.mockito.exceptions.base.MockitoException;
Expand Down Expand Up @@ -248,34 +249,34 @@ public void shouldNotAllowSettingNullThrowableArray() {
.hasMessageContaining("Cannot stub with null throwable");
}

@Test
public void shouldNotAllowSettingNullThrowableClass() {
assertThatThrownBy(
() -> {
when(mock.isEmpty()).thenThrow((Class) null);
})
private void assertExceptionTypeCanNotBeNull(ThrowingCallable throwingCallable) {
assertThatThrownBy(throwingCallable)
.isInstanceOf(MockitoException.class)
.hasMessageContaining("Exception type cannot be null");
}

@Test
public void shouldNotAllowSettingNullThrowableClass() {
assertExceptionTypeCanNotBeNull(
() -> {
when(mock.isEmpty()).thenThrow((Class) null);
});
}

@Test
public void shouldNotAllowSettingNullThrowableClasses() {
assertThatThrownBy(
() -> {
when(mock.isEmpty()).thenThrow(RuntimeException.class, (Class[]) null);
})
.isInstanceOf(MockitoException.class)
.hasMessageContaining("Exception type cannot be null");
assertExceptionTypeCanNotBeNull(
() -> {
when(mock.isEmpty()).thenThrow(RuntimeException.class, (Class[]) null);
});
}

@Test
public void shouldNotAllowSettingNullVarArgThrowableClass() {
assertThatThrownBy(
() -> {
when(mock.isEmpty()).thenThrow(RuntimeException.class, (Class) null);
})
.isInstanceOf(MockitoException.class)
.hasMessageContaining("Exception type cannot be null");
assertExceptionTypeCanNotBeNull(
() -> {
when(mock.isEmpty()).thenThrow(RuntimeException.class, (Class) null);
});
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class MockitoAnyIncorrectPrimitiveType extends AbstractMockitoAnyForPrimi
};

private static final Matcher<ExpressionTree> METHOD_MATCHER =
staticMethod().onClassAny(CLASS_NAMES).withNameMatching(METHOD_NAME_PATTERN).withParameters();
staticMethod().onClassAny(CLASS_NAMES).withNameMatching(METHOD_NAME_PATTERN).withNoParameters();

@Override
protected Matcher<? super MethodInvocationTree> matcher() {
Expand Down