File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
integration-tests/rest-client-reactive/src/test/java/io/quarkus/it/rest/client
test-framework/junit5-mockito/src/main/java/io/quarkus/test/junit/mockito/internal Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change 13
13
import io .quarkus .it .rest .client .main .MyResponseExceptionMapper ;
14
14
import io .quarkus .test .InjectMock ;
15
15
import io .quarkus .test .junit .QuarkusTest ;
16
+ import io .quarkus .test .junit .mockito .InjectSpy ;
16
17
import io .restassured .RestAssured ;
17
18
18
19
@ QuarkusTest
19
20
@ Order (100 ) // used in order to make sure this is run before ShouldNotUseMockTest
20
21
public class InjectMockTest {
21
22
22
23
@ InjectMock
24
+ @ InjectSpy
23
25
@ RestClient
24
26
ClientWithExceptionMapper mock ;
25
27
Original file line number Diff line number Diff line change 12
12
import io .quarkus .arc .ClientProxy ;
13
13
import io .quarkus .arc .InjectableContext ;
14
14
import io .quarkus .arc .InstanceHandle ;
15
+ import io .quarkus .test .InjectMock ;
15
16
import io .quarkus .test .junit .callback .QuarkusTestAfterAllCallback ;
16
17
import io .quarkus .test .junit .callback .QuarkusTestAfterConstructCallback ;
17
18
import io .quarkus .test .junit .callback .QuarkusTestContext ;
@@ -35,6 +36,12 @@ public void afterConstruct(Object testInstance) {
35
36
while (current .getSuperclass () != null ) {
36
37
for (Field field : current .getDeclaredFields ()) {
37
38
InjectSpy injectSpyAnnotation = field .getAnnotation (InjectSpy .class );
39
+ InjectMock injectMockAnnotation = field .getAnnotation (InjectMock .class );
40
+ if (injectMockAnnotation != null ) {
41
+ throw new IllegalArgumentException (
42
+ "Fields cannot be annotated with both @InjectSpy and @InjectMock. Offending field is '"
43
+ + field .getDeclaringClass ().getName () + "#" + field .getName () + "'" );
44
+ }
38
45
if (injectSpyAnnotation != null ) {
39
46
InstanceHandle <?> beanHandle = CreateMockitoMocksCallback .getBeanHandle (testInstance , field ,
40
47
InjectSpy .class );
You can’t perform that action at this time.
0 commit comments