Skip to content

Commit 5a8e1ee

Browse files
Bug fixes in CgAbstractSpringTestClassConstructor (#2269)
1 parent c7b2536 commit 5a8e1ee

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/builtin/SpringBuiltins.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ package org.utbot.framework.codegen.domain.builtin
33
import org.utbot.framework.plugin.api.BuiltinClassId
44

55
internal val autowiredClassId = BuiltinClassId(
6-
canonicalName = "org.springframework.beans.factory.annotation",
6+
canonicalName = "org.springframework.beans.factory.annotation.Autowired",
77
simpleName = "Autowired",
88
)

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/generator/SpringCodeGenerator.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ class SpringCodeGenerator(
6161
logger.info { "Code generation phase started at ${now()}" }
6262
val astConstructor = when (springTestsType) {
6363
SpringTestsType.UNIT_TESTS -> CgSpringUnitTestClassConstructor(context)
64-
// TODO replace with CgSpringIntegrationTestClassConstructor
65-
SpringTestsType.INTEGRATION_TESTS -> CgSpringUnitTestClassConstructor(context)
64+
SpringTestsType.INTEGRATION_TESTS -> CgSpringIntegrationTestClassConstructor(context)
6665
}
6766
val testClassFile = astConstructor.construct(testClassModel)
6867
logger.info { "Code generation phase finished at ${now()}" }

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgAbstractSpringTestClassConstructor.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.utbot.framework.codegen.tree
22

33
import org.utbot.framework.codegen.domain.builtin.TestClassUtilMethodProvider
4+
import org.utbot.framework.codegen.domain.builtin.autowiredClassId
45
import org.utbot.framework.codegen.domain.builtin.injectMocksClassId
56
import org.utbot.framework.codegen.domain.builtin.mockClassId
67
import org.utbot.framework.codegen.domain.context.CgContext
@@ -87,7 +88,11 @@ abstract class CgAbstractSpringTestClassConstructor(context: CgContext):
8788
groupedModelsByClassId: TypedModelWrappers,
8889
annotationClassId: ClassId
8990
): List<CgFieldDeclaration> {
90-
require(annotationClassId == injectMocksClassId || annotationClassId == mockClassId) {
91+
require(
92+
annotationClassId == injectMocksClassId ||
93+
annotationClassId == mockClassId ||
94+
annotationClassId == autowiredClassId
95+
) {
9196
error("Unexpected annotation classId -- $annotationClassId")
9297
}
9398

0 commit comments

Comments
 (0)