From cf7630a3a262751bfdaf481fd2fc675cbc95b6bf Mon Sep 17 00:00:00 2001 From: Martin Kouba Date: Mon, 31 Jul 2023 13:23:25 +0200 Subject: [PATCH] Testing - fix MockitoConfig(convertScopes = true) - fixes #35080 (cherry picked from commit 806c3f86bbc2dc680cb806b18fb0cc0e2f5dfef3) --- .../io/quarkus/it/mockbean/GreetingSingletonResourceTest.java | 4 +++- ...onToApplicationScopedTestBuildChainCustomizerProducer.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/integration-tests/injectmock/src/test/java/io/quarkus/it/mockbean/GreetingSingletonResourceTest.java b/integration-tests/injectmock/src/test/java/io/quarkus/it/mockbean/GreetingSingletonResourceTest.java index 4597a40fcf14f..5a066cf01482e 100644 --- a/integration-tests/injectmock/src/test/java/io/quarkus/it/mockbean/GreetingSingletonResourceTest.java +++ b/integration-tests/injectmock/src/test/java/io/quarkus/it/mockbean/GreetingSingletonResourceTest.java @@ -12,6 +12,7 @@ import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.mockito.InjectMock; +import io.quarkus.test.junit.mockito.MockitoConfig; @QuarkusTest class GreetingSingletonResourceTest { @@ -19,7 +20,8 @@ class GreetingSingletonResourceTest { @InjectMock(convertScopes = true) MessageServiceSingleton messageService; - @InjectMock(convertScopes = true) + @io.quarkus.test.InjectMock + @MockitoConfig(convertScopes = true) SuffixServiceSingleton suffixService; @InjectMock(convertScopes = true) diff --git a/test-framework/junit5-mockito/src/main/java/io/quarkus/test/junit/mockito/internal/SingletonToApplicationScopedTestBuildChainCustomizerProducer.java b/test-framework/junit5-mockito/src/main/java/io/quarkus/test/junit/mockito/internal/SingletonToApplicationScopedTestBuildChainCustomizerProducer.java index c96ad9da4860d..9cfef464fa310 100644 --- a/test-framework/junit5-mockito/src/main/java/io/quarkus/test/junit/mockito/internal/SingletonToApplicationScopedTestBuildChainCustomizerProducer.java +++ b/test-framework/junit5-mockito/src/main/java/io/quarkus/test/junit/mockito/internal/SingletonToApplicationScopedTestBuildChainCustomizerProducer.java @@ -55,7 +55,7 @@ public void execute(BuildContext context) { continue; } if (instance.name().equals(MOCKITO_CONFIG) - && instance.target().asField().hasAnnotation(INJECT_MOCK)) { + && !instance.target().asField().hasAnnotation(INJECT_MOCK)) { continue; } AnnotationValue allowScopeConversionValue = instance.value("convertScopes");