@@ -2,7 +2,6 @@ package org.utbot.framework.codegen.model.constructor.tree
22
33import org.utbot.common.PathUtil
44import org.utbot.common.packageName
5- import org.utbot.engine.isStatic
65import org.utbot.framework.assemble.assemble
76import org.utbot.framework.codegen.ForceStaticMocking
87import org.utbot.framework.codegen.Junit4
@@ -86,6 +85,7 @@ import org.utbot.framework.fields.ExecutionStateAnalyzer
8685import org.utbot.framework.fields.FieldPath
8786import org.utbot.framework.plugin.api.BuiltinClassId
8887import org.utbot.framework.plugin.api.BuiltinMethodId
88+ import org.utbot.framework.plugin.api.CgMethodTestSet
8989import org.utbot.framework.plugin.api.ClassId
9090import org.utbot.framework.plugin.api.CodegenLanguage
9191import org.utbot.framework.plugin.api.ConcreteExecutionFailureException
@@ -106,8 +106,6 @@ import org.utbot.framework.plugin.api.UtExecution
106106import org.utbot.framework.plugin.api.UtExecutionFailure
107107import org.utbot.framework.plugin.api.UtExecutionSuccess
108108import org.utbot.framework.plugin.api.UtExplicitlyThrownException
109- import org.utbot.framework.plugin.api.UtMethod
110- import org.utbot.framework.plugin.api.UtMethodTestSet
111109import org.utbot.framework.plugin.api.UtModel
112110import org.utbot.framework.plugin.api.UtNewInstanceInstrumentation
113111import org.utbot.framework.plugin.api.UtNullModel
@@ -123,6 +121,7 @@ import org.utbot.framework.plugin.api.util.builtinStaticMethodId
123121import org.utbot.framework.plugin.api.util.doubleArrayClassId
124122import org.utbot.framework.plugin.api.util.doubleClassId
125123import org.utbot.framework.plugin.api.util.doubleWrapperClassId
124+ import org.utbot.framework.plugin.api.util.executable
126125import org.utbot.framework.plugin.api.util.field
127126import org.utbot.framework.plugin.api.util.floatArrayClassId
128127import org.utbot.framework.plugin.api.util.floatClassId
@@ -149,7 +148,6 @@ import org.utbot.framework.util.isUnit
149148import org.utbot.summary.SummarySentenceConstants.TAB
150149import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
151150import java.lang.reflect.InvocationTargetException
152- import kotlin.reflect.jvm.javaType
153151
154152private const val DEEP_EQUALS_MAX_DEPTH = 5 // TODO move it to plugin settings?
155153
@@ -1086,11 +1084,11 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
10861084 }
10871085 }
10881086
1089- fun createTestMethod (utMethod : UtMethod < * > , execution : UtExecution ): CgTestMethod =
1087+ fun createTestMethod (executableId : ExecutableId , execution : UtExecution ): CgTestMethod =
10901088 withTestMethodScope(execution) {
1091- val testMethodName = nameGenerator.testMethodNameFor(utMethod , execution.testMethodName)
1089+ val testMethodName = nameGenerator.testMethodNameFor(executableId , execution.testMethodName)
10921090 // TODO: remove this line when SAT-1273 is completed
1093- execution.displayName = execution.displayName?.let { " ${utMethod.callable .name} : $it " }
1091+ execution.displayName = execution.displayName?.let { " ${executableId .name} : $it " }
10941092 testMethod(testMethodName, execution.displayName) {
10951093 rememberInitialStaticFields()
10961094 val stateAnalyzer = ExecutionStateAnalyzer (execution)
@@ -1105,7 +1103,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
11051103 }
11061104 // build arguments
11071105 for ((index, param) in execution.stateBefore.parameters.withIndex()) {
1108- val name = paramNames[utMethod ]?.get(index)
1106+ val name = paramNames[executableId ]?.get(index)
11091107 methodArguments + = variableConstructor.getOrCreateVariable(param, name)
11101108 }
11111109 rememberInitialEnvironmentState(modificationInfo)
@@ -1165,7 +1163,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
11651163 private val expectedResultVarName = " expectedResult"
11661164 private val expectedErrorVarName = " expectedError"
11671165
1168- fun createParameterizedTestMethod (testSet : UtMethodTestSet , dataProviderMethodName : String ): CgTestMethod {
1166+ fun createParameterizedTestMethod (testSet : CgMethodTestSet , dataProviderMethodName : String ): CgTestMethod {
11691167 // TODO: orientation on generic execution may be misleading, but what is the alternative?
11701168 // may be a heuristic to select a model with minimal number of internal nulls should be used
11711169 val genericExecution = testSet.executions
@@ -1217,11 +1215,11 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
12171215 }
12181216
12191217 private fun createParameterDeclarations (
1220- testSet : UtMethodTestSet ,
1218+ testSet : CgMethodTestSet ,
12211219 genericExecution : UtExecution ,
12221220 ): List <CgParameterDeclaration > {
1223- val methodUnderTest = testSet.method
1224- val methodUnderTestParameters = testSet.method.callable .parameters
1221+ val executableUnderTest = testSet.executableId
1222+ val executableUnderTestParameters = testSet.executableId.executable .parameters
12251223
12261224 return mutableListOf<CgParameterDeclaration >().apply {
12271225 // this instance
@@ -1240,9 +1238,9 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
12401238 }
12411239 // arguments
12421240 for (index in genericExecution.stateBefore.parameters.indices) {
1243- val argumentName = paramNames[methodUnderTest ]?.get(index)
1244- val paramIndex = if (methodUnderTest .isStatic) index else index + 1
1245- val paramType = methodUnderTestParameters [paramIndex].type.javaType
1241+ val argumentName = paramNames[executableUnderTest ]?.get(index)
1242+ val paramIndex = if (executableUnderTest is MethodId && executableUnderTest .isStatic) index else index + 1
1243+ val paramType = executableUnderTestParameters [paramIndex].parameterizedType
12461244
12471245 val argumentType = when {
12481246 paramType is Class <* > && paramType.isArray -> paramType.id
@@ -1310,7 +1308,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
13101308 * Standard logic for generating each test case parameter code is used.
13111309 */
13121310 fun createParameterizedTestDataProvider (
1313- testSet : UtMethodTestSet ,
1311+ testSet : CgMethodTestSet ,
13141312 dataProviderMethodName : String
13151313 ): CgParameterizedTestDataProviderMethod {
13161314 return withDataProviderScope {
@@ -1335,14 +1333,14 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
13351333 }
13361334 }
13371335
1338- private fun createExecutionArguments (testSet : UtMethodTestSet , execution : UtExecution ): List <CgExpression > {
1336+ private fun createExecutionArguments (testSet : CgMethodTestSet , execution : UtExecution ): List <CgExpression > {
13391337 val arguments = mutableListOf<CgExpression >()
13401338 execution.stateBefore.thisInstance?.let {
13411339 arguments + = variableConstructor.getOrCreateVariable(it)
13421340 }
13431341
13441342 for ((paramIndex, paramModel) in execution.stateBefore.parameters.withIndex()) {
1345- val argumentName = paramNames[testSet.method ]?.get(paramIndex)
1343+ val argumentName = paramNames[testSet.executableId ]?.get(paramIndex)
13461344 arguments + = variableConstructor.getOrCreateVariable(paramModel, argumentName)
13471345 }
13481346
@@ -1567,7 +1565,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
15671565 arguments = arrayOf(objectArrayClassId)
15681566 )
15691567
1570- private fun containsFailureExecution (testSet : UtMethodTestSet ) =
1568+ private fun containsFailureExecution (testSet : CgMethodTestSet ) =
15711569 testSet.executions.any { it.result is UtExecutionFailure }
15721570
15731571
@@ -1668,7 +1666,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
16681666 }
16691667 }
16701668
1671- fun errorMethod (method : UtMethod < * > , errors : Map <String , Int >): CgRegion <CgMethod > {
1669+ fun errorMethod (method : ExecutableId , errors : Map <String , Int >): CgRegion <CgMethod > {
16721670 val name = nameGenerator.errorMethodNameFor(method)
16731671 val body = block {
16741672 comment(" Couldn't generate some tests. List of errors:" )
@@ -1697,7 +1695,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
16971695 }
16981696 }
16991697 val errorTestMethod = CgErrorTestMethod (name, body)
1700- return CgSimpleRegion (" Errors report for ${method.callable. name} " , listOf (errorTestMethod))
1698+ return CgSimpleRegion (" Errors report for ${method.name} " , listOf (errorTestMethod))
17011699 }
17021700
17031701 private fun getJvmReportDocumentation (jvmReportPath : String ): String {
0 commit comments