Skip to content

Commit 29898c7

Browse files
izeyephilwebb
authored andcommitted
Remove superflous if in MockitoPostProcessor
The `if` in registerSpies() is not required as it's covered by the Assert check. Closes gh-5889
1 parent 6cdbdf9 commit 29898c7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoPostProcessor.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,10 @@ private void createSpy(BeanDefinitionRegistry registry, SpyDefinition definition
246246

247247
private void registerSpies(SpyDefinition definition, Field field,
248248
String[] existingBeans) {
249-
if (field != null) {
250-
Assert.state(field == null || existingBeans.length == 1,
251-
"Unable to register spy bean " + definition.getClassToSpy().getName()
252-
+ " expected a single existing bean to replace but found "
253-
+ new TreeSet<String>(Arrays.asList(existingBeans)));
254-
}
249+
Assert.state(field == null || existingBeans.length == 1,
250+
"Unable to register spy bean " + definition.getClassToSpy().getName()
251+
+ " expected a single existing bean to replace but found "
252+
+ new TreeSet<String>(Arrays.asList(existingBeans)));
255253
for (String beanName : existingBeans) {
256254
registerSpy(definition, field, beanName);
257255
}

0 commit comments

Comments
 (0)