Skip to content

Commit dd998af

Browse files
committed
Polish mocking code
1 parent 07965d6 commit dd998af

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

test-framework/junit5-mockito/src/main/java/io/quarkus/test/junit/mockito/internal/MockitoMocksTracker.java

+1-8
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ static Optional<Object> currentMock(Object testInstance, Object beanInstance) {
4040
return Optional.empty();
4141
}
4242

43-
static class Mocked {
44-
final Object mock;
45-
final Object beanInstance;
46-
47-
public Mocked(Object mock, Object beanInstance) {
48-
this.mock = mock;
49-
this.beanInstance = beanInstance;
50-
}
43+
record Mocked(Object mock, Object beanInstance) {
5144
}
5245
}

test-framework/junit5-mockito/src/main/java/io/quarkus/test/junit/mockito/internal/SetMockitoMockAsBeanMockCallback.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public void beforeEach(QuarkusTestMethodContext context) {
1818

1919
private void installMock(MockitoMocksTracker.Mocked mocked) {
2020
try {
21-
QuarkusMock.installMockForInstance(mocked.mock, mocked.beanInstance);
21+
QuarkusMock.installMockForInstance(mocked.mock(), mocked.beanInstance());
2222
} catch (Exception e) {
23-
throw new RuntimeException(mocked.beanInstance
23+
throw new RuntimeException(mocked.beanInstance()
2424
+ " is not a normal scoped CDI bean, make sure the bean is a normal scope like @ApplicationScoped or @RequestScoped."
2525
+ " Alternatively you can use '@InjectMock(convertScopes=true)' instead of '@InjectMock' if you would like"
2626
+ " Quarkus to automatically make that conversion (you should only use this if you understand the implications).");

0 commit comments

Comments
 (0)