Skip to content

Replace Class<*> with ClassId in the CodeGenerator constructor #659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.utbot.framework.plugin.api.TreatOverflowAsError
import org.utbot.framework.plugin.api.TestCaseGenerator
import org.utbot.framework.plugin.api.UtMethod
import org.utbot.framework.plugin.api.UtMethodTestSet
import org.utbot.framework.plugin.api.util.id
import org.utbot.summary.summarize
import java.io.File
import java.lang.reflect.Method
Expand Down Expand Up @@ -205,7 +206,7 @@ abstract class GenerateTestsAbstractCommand(name: String, help: String) :
forceStaticMocking == ForceStaticMocking.FORCE && staticsMocking is NoStaticMocking
return CodeGenerator(
testFramework = testFrameworkByName(testFramework),
classUnderTest = classUnderTest.java,
classUnderTest = classUnderTest.id,
codegenLanguage = codegenLanguage,
staticsMocking = staticsMocking,
forceStaticMocking = forceStaticMocking,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ object UtBotJavaApi {

return withUtContext(utContext) {
val codeGenerator = CodeGenerator(
classUnderTest = classUnderTest,
classUnderTest = classUnderTest.id,
testFramework = testFramework,
mockFramework = mockFramework,
codegenLanguage = codegenLanguage,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.utbot.framework.codegen.model

import org.utbot.common.packageName
import org.utbot.framework.codegen.ForceStaticMocking
import org.utbot.framework.codegen.HangingTestsTimeout
import org.utbot.framework.codegen.ParametrizedTestSource
Expand All @@ -13,14 +12,14 @@ import org.utbot.framework.codegen.model.constructor.tree.TestsGenerationReport
import org.utbot.framework.codegen.model.tree.CgTestClassFile
import org.utbot.framework.codegen.model.visitor.CgAbstractRenderer
import org.utbot.framework.plugin.api.CgMethodTestSet
import org.utbot.framework.plugin.api.ClassId
import org.utbot.framework.plugin.api.CodegenLanguage
import org.utbot.framework.plugin.api.ExecutableId
import org.utbot.framework.plugin.api.MockFramework
import org.utbot.framework.plugin.api.UtMethodTestSet
import org.utbot.framework.plugin.api.util.id

class CodeGenerator(
private val classUnderTest: Class<*>,
private val classUnderTest: ClassId,
paramNames: MutableMap<ExecutableId, List<String>> = mutableMapOf(),
testFramework: TestFramework = TestFramework.defaultItem,
mockFramework: MockFramework? = MockFramework.defaultItem,
Expand All @@ -35,7 +34,7 @@ class CodeGenerator(
testClassPackageName: String = classUnderTest.packageName,
) {
private var context: CgContext = CgContext(
classUnderTest = classUnderTest.id,
classUnderTest = classUnderTest,
paramNames = paramNames,
testFramework = testFramework,
mockFramework = mockFramework ?: MockFramework.MOCKITO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.utbot.framework.codegen.NoStaticMocking
import org.utbot.framework.codegen.model.CodeGenerator
import org.utbot.framework.plugin.api.TestCaseGenerator
import org.utbot.framework.plugin.api.UtMethodTestSet
import org.utbot.framework.plugin.api.util.id
import org.utbot.sarif.SarifReport
import org.utbot.sarif.SourceFindingStrategy
import org.utbot.summary.summarize
Expand Down Expand Up @@ -70,7 +71,7 @@ class GenerateTestsAndSarifReportFacade(
val isForceStaticMocking = sarifProperties.forceStaticMocking == ForceStaticMocking.FORCE

return CodeGenerator(
classUnderTest = targetClass.classUnderTest.java,
classUnderTest = targetClass.classUnderTest.id,
testFramework = sarifProperties.testFramework,
mockFramework = sarifProperties.mockFramework,
staticsMocking = sarifProperties.staticsMocking,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.utbot.framework.plugin.api.MockStrategyApi
import org.utbot.framework.plugin.api.UtMethodTestSet
import org.utbot.framework.plugin.api.util.UtContext
import org.utbot.framework.plugin.api.util.description
import org.utbot.framework.plugin.api.util.id
import org.utbot.framework.plugin.api.util.withUtContext
import kotlin.reflect.KClass

Expand Down Expand Up @@ -220,7 +221,7 @@ class TestCodeGeneratorPipeline(private val testFrameworkConfiguration: TestFram

val codeGenerator = with(testFrameworkConfiguration) {
CodeGenerator(
classUnderTest.java,
classUnderTest.id,
paramNames = params,
testFramework = testFramework,
staticsMocking = staticsMocking,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import org.utbot.framework.plugin.api.ExecutableId
import org.utbot.framework.plugin.api.UtMethodTestSet
import org.utbot.framework.plugin.api.util.UtContext
import org.utbot.framework.plugin.api.util.executableId
import org.utbot.framework.plugin.api.util.id
import org.utbot.framework.plugin.api.util.withUtContext
import org.utbot.framework.util.Conflict
import org.utbot.intellij.plugin.generator.CodeGenerationController.Target.*
Expand Down Expand Up @@ -265,7 +266,7 @@ object CodeGenerationController {
.runReadActionInSmartMode(Computable { findMethodParamNames(classUnderTest, classMethods) })

val codeGenerator = CodeGenerator(
classUnderTest = classUnderTest.java,
classUnderTest = classUnderTest.id,
paramNames = paramNames.toMutableMap(),
testFramework = model.testFramework,
mockFramework = model.mockFramework,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ fun runGeneration(
val statsForClass = StatsForClass()

val codeGenerator = CodeGenerator(
cut.classId.jClass,
cut.classId,
testFramework = junitByVersion(junitVersion),
staticsMocking = staticsMocking,
forceStaticMocking = forceStaticMocking,
Expand Down