From 442d299e8450369c7625a975d81adec52226ee6d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 May 2022 12:31:25 +0000 Subject: [PATCH 1/2] Bump mockito-bom from 4.5.1 to 4.6.0 Bumps [mockito-bom](https://github.com/mockito/mockito) from 4.5.1 to 4.6.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.5.1...v4.6.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-bom dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2cabbf7b0..dad1c77aa 100644 --- a/pom.xml +++ b/pom.xml @@ -129,7 +129,7 @@ org.mockito mockito-bom - 4.5.1 + 4.6.0 import pom From 58ad08a26503446411def7c4ecda558dde53be59 Mon Sep 17 00:00:00 2001 From: Ashley Scopes <73482956+ascopes@users.noreply.github.com> Date: Mon, 30 May 2022 15:36:48 +0100 Subject: [PATCH 2/2] Replace MockSettings.lenient() with MockSettings.strictness(...) --- .../unit/compilers/CompilableTest.java | 41 +++++++++++++++---- .../SimpleCompilationFactoryTest.java | 11 ++--- .../TracingDiagnosticListenerTest.java | 3 +- 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/java-compiler-testing/src/test/java/io/github/ascopes/jct/testing/unit/compilers/CompilableTest.java b/java-compiler-testing/src/test/java/io/github/ascopes/jct/testing/unit/compilers/CompilableTest.java index 3bb5b8590..92b5888b3 100644 --- a/java-compiler-testing/src/test/java/io/github/ascopes/jct/testing/unit/compilers/CompilableTest.java +++ b/java-compiler-testing/src/test/java/io/github/ascopes/jct/testing/unit/compilers/CompilableTest.java @@ -47,6 +47,7 @@ import org.junit.jupiter.params.provider.ValueSource; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.quality.Strictness; /** * {@link Compilable} tests. @@ -290,7 +291,10 @@ static Stream addPackagePathTestsFor( () -> { // Given var pathLike = stub(PathLike.class); - Compilable compiler = mockCast(new TypeRef<>() {}, withSettings().lenient()); + Compilable compiler = mockCast( + new TypeRef<>() {}, + withSettings().strictness(Strictness.LENIENT) + ); given(compiler.addPath(any(), any(PathLike.class))).will(ctx -> compiler); // Stub this method to keep results consistent, even though we shouldn't call it. // Just keeps the failure test results consistent and meaningful. @@ -310,7 +314,10 @@ static Stream addPackagePathTestsFor( () -> { // Given var path = stub(Path.class); - Compilable compiler = mockCast(new TypeRef<>() {}, withSettings().lenient()); + Compilable compiler = mockCast( + new TypeRef<>() {}, + withSettings().strictness(Strictness.LENIENT) + ); given(compiler.addPath(any(), any(Path.class))).will(ctx -> compiler); // Stub this method to keep results consistent, even though we shouldn't call it. // Just keeps the failure test results consistent and meaningful. @@ -330,7 +337,10 @@ static Stream addPackagePathTestsFor( () -> { // Given var pathLike = stub(PathLike.class); - Compilable compiler = mockCast(new TypeRef<>() {}, withSettings().lenient()); + Compilable compiler = mockCast( + new TypeRef<>() {}, + withSettings().strictness(Strictness.LENIENT) + ); given(compiler.addPath(any(), any(PathLike.class))).will(ctx -> compiler); given(pathLikeAdder.add(compiler, pathLike)).willCallRealMethod(); @@ -347,7 +357,10 @@ static Stream addPackagePathTestsFor( () -> { // Given var path = stub(Path.class); - Compilable compiler = mockCast(new TypeRef<>() {}, withSettings().lenient()); + Compilable compiler = mockCast( + new TypeRef<>() {}, + withSettings().strictness(Strictness.LENIENT) + ); given(compiler.addPath(any(), any(Path.class))).will(ctx -> compiler); given(pathAdder.add(compiler, path)).willCallRealMethod(); @@ -403,7 +416,10 @@ static Stream addModulePathTestsFor( () -> { // Given var pathLike = stub(PathLike.class); - Compilable compiler = mockCast(new TypeRef<>() {}, withSettings().lenient()); + Compilable compiler = mockCast( + new TypeRef<>() {}, + withSettings().strictness(Strictness.LENIENT) + ); // Stub this method to keep results consistent, even though we shouldn't call it. // Just keeps the failure test results consistent and meaningful. given(compiler.addPath(any(), any(PathLike.class))).will(ctx -> compiler); @@ -423,7 +439,10 @@ static Stream addModulePathTestsFor( () -> { // Given var path = stub(Path.class); - Compilable compiler = mockCast(new TypeRef<>() {}, withSettings().lenient()); + Compilable compiler = mockCast( + new TypeRef<>() {}, + withSettings().strictness(Strictness.LENIENT) + ); // Stub this method to keep results consistent, even though we shouldn't call it. // Just keeps the failure test results consistent and meaningful. given(compiler.addPath(any(), any(Path.class))).will(ctx -> compiler); @@ -443,7 +462,10 @@ static Stream addModulePathTestsFor( () -> { // Given var pathLike = stub(PathLike.class); - Compilable compiler = mockCast(new TypeRef<>() {}, withSettings().lenient()); + Compilable compiler = mockCast( + new TypeRef<>() {}, + withSettings().strictness(Strictness.LENIENT) + ); given(compiler.addPath(any(), any(PathLike.class))).will(ctx -> compiler); given(pathLikeAdder.add(compiler, moduleName, pathLike)).willCallRealMethod(); @@ -460,7 +482,10 @@ static Stream addModulePathTestsFor( () -> { // Given var path = stub(Path.class); - Compilable compiler = mockCast(new TypeRef<>() {}, withSettings().lenient()); + Compilable compiler = mockCast( + new TypeRef<>() {}, + withSettings().strictness(Strictness.LENIENT) + ); given(compiler.addPath(any(), any(Path.class))).will(ctx -> compiler); given(pathAdder.add(compiler, moduleName, path)).willCallRealMethod(); diff --git a/java-compiler-testing/src/test/java/io/github/ascopes/jct/testing/unit/compilers/SimpleCompilationFactoryTest.java b/java-compiler-testing/src/test/java/io/github/ascopes/jct/testing/unit/compilers/SimpleCompilationFactoryTest.java index d1c3b317c..6ca843f8d 100644 --- a/java-compiler-testing/src/test/java/io/github/ascopes/jct/testing/unit/compilers/SimpleCompilationFactoryTest.java +++ b/java-compiler-testing/src/test/java/io/github/ascopes/jct/testing/unit/compilers/SimpleCompilationFactoryTest.java @@ -50,6 +50,7 @@ import org.mockito.Answers; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.quality.Strictness; /** * {@link SimpleCompilationFactory} tests. @@ -64,19 +65,19 @@ class SimpleCompilationFactoryTest { SimpleCompilationFactory compilationFactory; - @Mock(lenient = true, answer = Answers.RETURNS_DEEP_STUBS) + @Mock(strictness = Strictness.LENIENT, answer = Answers.RETURNS_DEEP_STUBS) StubbedCompiler compiler; - @Mock(lenient = true, answer = Answers.RETURNS_SMART_NULLS) + @Mock(strictness = Strictness.LENIENT, answer = Answers.RETURNS_SMART_NULLS) JavaCompiler jsr199Compiler; - @Mock(lenient = true, answer = Answers.RETURNS_SELF) + @Mock(strictness = Strictness.LENIENT, answer = Answers.RETURNS_SELF) FlagBuilder flagBuilder; - @Mock(lenient = true, answer = Answers.RETURNS_SMART_NULLS) + @Mock(strictness = Strictness.LENIENT, answer = Answers.RETURNS_SMART_NULLS) CompilationTask compilationTask; - @Mock(lenient = true, answer = Answers.RETURNS_DEEP_STUBS) + @Mock(strictness = Strictness.LENIENT, answer = Answers.RETURNS_DEEP_STUBS) SimpleFileManagerTemplate fileManagerTemplate; Boolean expectedCompilationResult; diff --git a/java-compiler-testing/src/test/java/io/github/ascopes/jct/testing/unit/jsr199/diagnostics/TracingDiagnosticListenerTest.java b/java-compiler-testing/src/test/java/io/github/ascopes/jct/testing/unit/jsr199/diagnostics/TracingDiagnosticListenerTest.java index eb63b11dd..14de8bf3b 100644 --- a/java-compiler-testing/src/test/java/io/github/ascopes/jct/testing/unit/jsr199/diagnostics/TracingDiagnosticListenerTest.java +++ b/java-compiler-testing/src/test/java/io/github/ascopes/jct/testing/unit/jsr199/diagnostics/TracingDiagnosticListenerTest.java @@ -53,6 +53,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.quality.Strictness; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -388,7 +389,7 @@ static Stream loggingDisabledArgs() { static Diagnostic someDiagnostic(Kind kind, String message) { var diagnostic = stubCast( new TypeRef>() {}, - withSettings().lenient() + withSettings().strictness(Strictness.LENIENT) ); when(diagnostic.getKind()).thenReturn(kind); when(diagnostic.getMessage(any())).thenReturn(message);