Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinemeyer committed Nov 12, 2024
1 parent a06e030 commit dc7e2d6
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void beforeTestMethod(TestContext testContext) throws Exception {
final Map<Definition, Object> mockOrSpys = new HashMap<>();
final LinkedList<FieldState> fieldStates = (LinkedList<FieldState>) applicableTestContext.getAttribute(ORIGINAL_VALUES_ATTRIBUTE_NAME);
final Map<Object, Object> spyTracker = new IdentityHashMap<>();
// First loop to setup all the mocks and spies
//First loop to setup all the mocks and spies
fieldStates
.stream()
.filter(BeanFieldState.class::isInstance)
Expand All @@ -117,14 +117,14 @@ public void beforeTestMethod(TestContext testContext) throws Exception {
}
}
});
// Second loop to process the injections (handling mocks in spies)
//Second loop to process the injections (handling mocks in spies)
fieldStates
.forEach(fieldState -> {
final Object mockOrSpy = mockOrSpys.get(fieldState.definition);
final Object bean = fieldState.resolveTarget(applicableTestContext);
// inject in original bean
//inject in original bean
inject(fieldState.field, bean, mockOrSpy);
// if the target bean has been spied on, need to push into this spy as well (to allow mock in spies)
//if the target bean has been spied on, need to push into this spy as well (to allow mock in spies)
Optional.ofNullable(spyTracker.get(bean))
.ifPresent(spy ->inject(fieldState.field, spy, mockOrSpy));

Expand Down

0 comments on commit dc7e2d6

Please sign in to comment.