@@ -62,7 +62,6 @@ import org.utbot.framework.plugin.api.TypeReplacementMode.*
62
62
import org.utbot.framework.plugin.api.util.allDeclaredFieldIds
63
63
import org.utbot.framework.plugin.api.util.fieldId
64
64
import org.utbot.framework.plugin.api.util.isSubtypeOf
65
- import org.utbot.framework.plugin.api.util.objectClassId
66
65
import org.utbot.framework.plugin.api.util.utContext
67
66
import org.utbot.framework.process.OpenModulesContainer
68
67
import soot.SootField
@@ -1258,13 +1257,13 @@ open class ApplicationContext(
1258
1257
* Data we get from Spring application context
1259
1258
* to manage engine and code generator behaviour.
1260
1259
*
1261
- * @param beanQualifiedNames describes fqn of types from bean definitions
1260
+ * @param beanDefinitions describes bean definitions (bean name, type, some optional additional data)
1262
1261
* @param shouldUseImplementors describes it we want to replace interfaces with injected types or not
1263
1262
*/
1264
1263
class SpringApplicationContext (
1265
1264
mockInstalled : Boolean ,
1266
1265
staticsMockingIsConfigured : Boolean ,
1267
- private val beanQualifiedNames : List <String > = emptyList(),
1266
+ private val beanDefinitions : List <BeanDefinitionData > = emptyList(),
1268
1267
private val shouldUseImplementors : Boolean ,
1269
1268
): ApplicationContext(mockInstalled, staticsMockingIsConfigured) {
1270
1269
@@ -1278,7 +1277,8 @@ class SpringApplicationContext(
1278
1277
private val springInjectedClasses: Set <ClassId >
1279
1278
get() {
1280
1279
if (! areInjectedClassesInitialized) {
1281
- for (beanFqn in beanQualifiedNames) {
1280
+ // TODO: use more info from SpringBeanDefinitionData than beanTypeFqn offers here
1281
+ for (beanFqn in beanDefinitions.map { it.beanTypeFqn }) {
1282
1282
try {
1283
1283
val beanClass = utContext.classLoader.loadClass(beanFqn)
1284
1284
if (! beanClass.isAbstract && ! beanClass.isInterface &&
@@ -1341,6 +1341,29 @@ class SpringApplicationContext(
1341
1341
): Boolean = field.fieldId in classUnderTest.allDeclaredFieldIds && field.declaringClass.id !in springInjectedClasses
1342
1342
}
1343
1343
1344
+ /* *
1345
+ * Describes information about beans obtained from Spring analysis process.
1346
+ *
1347
+ * Contains the name of the bean, its type (class or interface) and optional additional data.
1348
+ */
1349
+ data class BeanDefinitionData (
1350
+ val beanName : String ,
1351
+ val beanTypeFqn : String ,
1352
+ val additionalData : BeanAdditionalData ? ,
1353
+ )
1354
+
1355
+ /* *
1356
+ * Describes some additional information about beans obtained from Spring analysis process.
1357
+ *
1358
+ * Sometimes the actual type of the bean can not be obtained from bean definition.
1359
+ * Then we try to recover it by method and class defining bean (e.g. using Psi elements).
1360
+ */
1361
+ data class BeanAdditionalData (
1362
+ val factoryMethodName : String ,
1363
+ val configClassFqn : String ,
1364
+ )
1365
+
1366
+
1344
1367
val RefType .isAbstractType
1345
1368
get() = this .sootClass.isAbstract || this .sootClass.isInterface
1346
1369
0 commit comments