Skip to content

Commit 9fe794a

Browse files
Rename UtValueTestCase to UtMethodValueTestSet and remove relevant parts
1 parent fab8ed2 commit 9fe794a

File tree

9 files changed

+18
-43
lines changed

9 files changed

+18
-43
lines changed

utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/ValueBasedApi.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@
66

77
package org.utbot.framework.plugin.api
88

9-
import kotlin.reflect.KClass
109
import org.apache.commons.lang3.builder.RecursiveToStringStyle
1110
import org.apache.commons.lang3.builder.ReflectionToStringBuilder
12-
import soot.jimple.JimpleBody
1311

14-
data class UtValueTestCase<R>(
12+
data class UtMethodValueTestSet<R>(
1513
val method: UtMethod<out R>,
1614
val executions: List<UtValueExecution<out R>> = emptyList(),
17-
val jimpleBody: JimpleBody? = null,
1815
val errors: Map<String, Int> = emptyMap(),
1916
)
2017

utbot-framework/src/main/kotlin/org/utbot/framework/coverage/CoverageCalculator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package org.utbot.framework.coverage
22

33
import org.utbot.framework.plugin.api.UtMethod
44
import org.utbot.framework.plugin.api.UtValueExecution
5-
import org.utbot.framework.plugin.api.UtValueTestCase
5+
import org.utbot.framework.plugin.api.UtMethodValueTestSet
66
import org.utbot.framework.plugin.api.util.signature
77
import org.utbot.framework.util.anyInstance
88
import org.utbot.instrumentation.ConcreteExecutor
@@ -140,7 +140,7 @@ class MemoryClassLoader : ClassLoader() {
140140
}
141141
}
142142

143-
fun classCoverage(testCases: List<UtValueTestCase<*>>): Coverage =
143+
fun classCoverage(testCases: List<UtMethodValueTestSet<*>>): Coverage =
144144
testCases.map { methodCoverageWithJaCoCo(it.method, it.executions) }.toClassCoverage()
145145

146146
fun methodCoverageWithJaCoCo(utMethod: UtMethod<*>, executions: List<UtValueExecution<*>>): Coverage {

utbot-framework/src/main/kotlin/org/utbot/framework/util/EngineUtils.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import org.utbot.framework.plugin.api.MissingState
77
import org.utbot.framework.plugin.api.UtExecution
88
import org.utbot.framework.plugin.api.UtModel
99
import org.utbot.framework.plugin.api.UtMethodTestSet
10-
import org.utbot.framework.plugin.api.UtValueTestCase
10+
import org.utbot.framework.plugin.api.UtMethodValueTestSet
1111
import org.utbot.framework.plugin.api.UtVoidModel
1212
import org.utbot.framework.plugin.api.classId
1313
import org.utbot.framework.plugin.api.id
@@ -17,7 +17,6 @@ import org.utbot.framework.plugin.api.util.methodId
1717
import org.utbot.framework.plugin.api.util.objectClassId
1818
import java.util.concurrent.atomic.AtomicInteger
1919
import soot.SootMethod
20-
import soot.jimple.JimpleBody
2120

2221

2322
@Suppress("DEPRECATION")
@@ -74,9 +73,9 @@ val instanceCounter = AtomicInteger(0)
7473

7574
fun nextModelName(base: String): String = "$base${instanceCounter.incrementAndGet()}"
7675

77-
fun UtMethodTestSet.toValueTestCase(jimpleBody: JimpleBody? = null): UtValueTestCase<*> {
76+
fun UtMethodTestSet.toValueTestCase(): UtMethodValueTestSet<*> {
7877
val valueExecutions = executions.map { ValueConstructor().construct(it) }
79-
return UtValueTestCase(method, valueExecutions, jimpleBody, errors)
78+
return UtMethodValueTestSet(method, valueExecutions, errors)
8079
}
8180

8281
fun UtModel.isUnit(): Boolean =

utbot-framework/src/test/kotlin/org/utbot/examples/UtValueTestCaseChecker.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ import org.utbot.framework.plugin.api.UtValueExecution
5454
import org.utbot.framework.plugin.api.util.UtContext
5555
import org.utbot.framework.plugin.api.util.executableId
5656
import org.utbot.framework.plugin.api.util.withUtContext
57-
import org.utbot.framework.util.jimpleBody
5857
import org.utbot.framework.util.toValueTestCase
5958
import org.utbot.summary.summarize
6059
import java.io.File
@@ -2343,7 +2342,7 @@ abstract class UtValueTestCaseChecker(
23432342
walk(utMethod, mockStrategy, additionalDependenciesClassPath)
23442343
}
23452344
testCase.summarize(searchDirectory)
2346-
val valueTestCase = testCase.toValueTestCase(jimpleBody(utMethod))
2345+
val valueTestCase = testCase.toValueTestCase()
23472346

23482347
assertTrue(testCase.errors.isEmpty()) {
23492348
"We have errors: ${
@@ -2478,10 +2477,9 @@ abstract class UtValueTestCaseChecker(
24782477
additionalDependenciesClassPath: String = ""
24792478
): MethodResult {
24802479
val testCase = executions(method, mockStrategy, additionalDependenciesClassPath)
2481-
val jimpleBody = jimpleBody(method)
24822480
val methodCoverage = methodCoverage(
24832481
method,
2484-
testCase.toValueTestCase(jimpleBody).executions,
2482+
testCase.toValueTestCase().executions,
24852483
buildDir.toString() + File.pathSeparator + additionalDependenciesClassPath
24862484
)
24872485
return MethodResult(testCase, methodCoverage)

utbot-fuzzers/src/main/java/org/utbot/fuzzer/baseline/generator/Generator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import org.utbot.framework.plugin.api.UtMethod;
44
import org.utbot.framework.plugin.api.UtValueExecution;
5-
import org.utbot.framework.plugin.api.UtValueTestCase;
5+
import org.utbot.framework.plugin.api.UtMethodValueTestSet;
66
import java.lang.reflect.Method;
77
import java.lang.reflect.Modifier;
88
import java.util.Arrays;
@@ -38,11 +38,11 @@ private static boolean isSameMethod(UtMethod<?> utMethod, Method method) {
3838
return utJavaMethod.equals(method);
3939
}
4040

41-
public static UtValueTestCase<?> generateTests(UtMethod<?> method) throws IllegalAccessException, InstantiationException {
41+
public static UtMethodValueTestSet<?> generateTests(UtMethod<?> method) throws IllegalAccessException, InstantiationException {
4242
KClass<?> kClass = method.getClazz();
4343
Class<?> clazz = JvmClassMappingKt.getJavaClass(kClass);
4444
// TODO: newInstance() is deprecated, need to create an instance in another way
4545
Object object = clazz.newInstance();
46-
return new UtValueTestCase<>(method, executions(method, clazz, object), null, emptyMap());
46+
return new UtMethodValueTestSet<>(method, executions(method, clazz, object), emptyMap());
4747
}
4848
}

utbot-fuzzers/src/main/kotlin/org/utbot/fuzzer/ObsoleteTestCaseGenerator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package org.utbot.fuzzer
22

33
import org.utbot.framework.plugin.api.MockStrategyApi
44
import org.utbot.framework.plugin.api.UtMethod
5-
import org.utbot.framework.plugin.api.UtValueTestCase
5+
import org.utbot.framework.plugin.api.UtMethodValueTestSet
66

77
interface ObsoleteTestCaseGenerator {
8-
fun generate(method: UtMethod<*>, mockStrategy: MockStrategyApi): UtValueTestCase<*>
8+
fun generate(method: UtMethod<*>, mockStrategy: MockStrategyApi): UtMethodValueTestSet<*>
99
}

utbot-fuzzers/src/main/kotlin/org/utbot/fuzzer/baseline/BaselineFuzzer.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import org.utbot.framework.plugin.api.MockStrategyApi
44
import org.utbot.framework.plugin.api.UtConcreteValue
55
import org.utbot.framework.plugin.api.UtMethod
66
import org.utbot.framework.plugin.api.UtValueExecution
7-
import org.utbot.framework.plugin.api.UtValueTestCase
7+
import org.utbot.framework.plugin.api.UtMethodValueTestSet
88
import org.utbot.fuzzer.ObsoleteTestCaseGenerator
99
import org.utbot.fuzzer.baseline.generator.Generator
1010
import kotlin.Result.Companion.failure
1111
import kotlin.Result.Companion.success
1212

1313
object BaselineFuzzer : ObsoleteTestCaseGenerator {
14-
override fun generate(method: UtMethod<*>, mockStrategy: MockStrategyApi): UtValueTestCase<*> =
14+
override fun generate(method: UtMethod<*>, mockStrategy: MockStrategyApi): UtMethodValueTestSet<*> =
1515
Generator.generateTests(method)
1616
}
1717

utbot-fuzzers/src/main/kotlin/org/utbot/fuzzer/primitive/PrimitiveFuzzer.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.utbot.framework.plugin.api.MockStrategyApi
44
import org.utbot.framework.plugin.api.UtConcreteValue
55
import org.utbot.framework.plugin.api.UtMethod
66
import org.utbot.framework.plugin.api.UtValueExecution
7-
import org.utbot.framework.plugin.api.UtValueTestCase
7+
import org.utbot.framework.plugin.api.UtMethodValueTestSet
88
import org.utbot.fuzzer.ObsoleteTestCaseGenerator
99
import kotlin.Result.Companion.success
1010
import kotlin.reflect.KCallable
@@ -13,8 +13,8 @@ import kotlin.reflect.KParameter.Kind
1313
import kotlin.reflect.KType
1414

1515
object PrimitiveFuzzer : ObsoleteTestCaseGenerator {
16-
override fun generate(method: UtMethod<*>, mockStrategy: MockStrategyApi): UtValueTestCase<*> =
17-
UtValueTestCase(method, executions(method.callable))
16+
override fun generate(method: UtMethod<*>, mockStrategy: MockStrategyApi): UtMethodValueTestSet<*> =
17+
UtMethodValueTestSet(method, executions(method.callable))
1818
}
1919

2020
private fun executions(method: KCallable<Any?>) = listOf(execution(method))

utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import org.utbot.framework.plugin.api.UtError
3434
import org.utbot.framework.plugin.api.UtExecution
3535
import org.utbot.framework.plugin.api.UtMethod
3636
import org.utbot.framework.plugin.api.UtMethodTestSet
37-
import org.utbot.framework.plugin.api.UtValueTestCase
3837
import org.utbot.framework.plugin.api.util.UtContext
3938
import org.utbot.framework.plugin.api.util.id
4039
import org.utbot.framework.plugin.api.util.jClass
@@ -43,9 +42,6 @@ import org.utbot.framework.plugin.api.util.withUtContext
4342
import org.utbot.instrumentation.ConcreteExecutor
4443
import org.utbot.instrumentation.ConcreteExecutorPool
4544
import org.utbot.instrumentation.Settings
46-
import org.utbot.instrumentation.execute
47-
import org.utbot.instrumentation.instrumentation.coverage.CoverageInstrumentation
48-
import org.utbot.instrumentation.util.StaticEnvironment
4945
import org.utbot.instrumentation.warmup.Warmup
5046
import java.io.File
5147
import java.lang.reflect.Method
@@ -423,21 +419,6 @@ fun runGeneration(
423419
statsForClass
424420
}
425421

426-
private fun ConcreteExecutor<Result<*>, CoverageInstrumentation>.executeTestCase(testCase: UtValueTestCase<*>) {
427-
testCase.executions.forEach {
428-
val method = testCase.method.callable
429-
for (execution in testCase.executions) {
430-
val args = (listOfNotNull(execution.stateBefore.caller) + execution.stateBefore.params)
431-
.map { it.value }.toMutableList()
432-
val staticEnvironment = StaticEnvironment(
433-
execution.stateBefore.statics.map { it.key to it.value.value }
434-
)
435-
this.execute(method, args.toTypedArray(), parameters = staticEnvironment)
436-
}
437-
}
438-
439-
}
440-
441422
private fun prepareClass(kotlinClass: KClass<*>, methodNameFilter: String?): List<UtMethod<*>> {
442423
//1. all methods and properties from cut
443424
val kotlin2java = kotlinClass.declaredMembers

0 commit comments

Comments
 (0)