Skip to content
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 @@ -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.
Expand Down Expand Up @@ -290,7 +291,10 @@ static Stream<DynamicTest> 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.
Expand All @@ -310,7 +314,10 @@ static Stream<DynamicTest> 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.
Expand All @@ -330,7 +337,10 @@ static Stream<DynamicTest> 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();

Expand All @@ -347,7 +357,10 @@ static Stream<DynamicTest> 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();

Expand Down Expand Up @@ -403,7 +416,10 @@ static Stream<DynamicTest> 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);
Expand All @@ -423,7 +439,10 @@ static Stream<DynamicTest> 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);
Expand All @@ -443,7 +462,10 @@ static Stream<DynamicTest> 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();

Expand All @@ -460,7 +482,10 @@ static Stream<DynamicTest> 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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -64,19 +65,19 @@ class SimpleCompilationFactoryTest {

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

Expand Down Expand Up @@ -388,7 +389,7 @@ static Stream<Arguments> loggingDisabledArgs() {
static Diagnostic<JavaFileObject> someDiagnostic(Kind kind, String message) {
var diagnostic = stubCast(
new TypeRef<Diagnostic<JavaFileObject>>() {},
withSettings().lenient()
withSettings().strictness(Strictness.LENIENT)
);
when(diagnostic.getKind()).thenReturn(kind);
when(diagnostic.getMessage(any())).thenReturn(message);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<!-- Mocking -->
<groupId>org.mockito</groupId>
<artifactId>mockito-bom</artifactId>
<version>4.5.1</version>
<version>4.6.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down