-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Description
[Copied over from #681]
It is quite a normal use case for developers to have a baseBean in the production files and have an overridden one in the test files. The bean in the test file is marked with @Primary so that it takes precedence when being invoked from tests.
Now, in case of using transactionoutbox-spring, the following method
@Override
public String getName(Class<?> clazz) {
String[] beanNames = applicationContext.getBeanNamesForType(clazz);
if (beanNames.length > 1) {
throw new IllegalArgumentException(
"Type "
+ clazz.getName()
+ " exists under multiple names in the context: "
+ Arrays.toString(beanNames)
+ ". Use a unique type.");
}
if (beanNames.length == 0) {
throw new IllegalArgumentException(
"Type " + clazz.getName() + " not available in the context");
}
return beanNames[0];
}
throws errors when there are more than 2 beans for the same class.
Action Items :
- Modify above mentioned class to return the bean definition for a class which has a higher precedence (marked using
@Primary) - Add tests for above corner case.
Metadata
Metadata
Assignees
Labels
No labels