Skip to content

Commit 871d176

Browse files
committed
Add origin to UtSpringMockMvcResultActionsModel
1 parent 9740202 commit 871d176

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ data class SpringRepositoryId(
761761

762762
class UtSpringMockMvcResultActionsModel(
763763
id: Int?,
764+
origin: UtCompositeModel?,
764765
val status: Int,
765766
val errorMessage: String?,
766767
val contentAsString: String,
@@ -769,6 +770,7 @@ class UtSpringMockMvcResultActionsModel(
769770
val model: UtModel?
770771
// TODO add headers and other data
771772
) : UtCustomModel(
773+
origin = origin,
772774
classId = SpringModelUtils.resultActionsClassId,
773775
id = id,
774776
modelName = "mockMvcResultActions@$id"

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/execution/constructors/UtModelConstructor.kt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ interface UtModelConstructorInterface {
1717
* Constructs a UtModel from a concrete [value] with a specific [classId].
1818
*/
1919
fun construct(value: Any?, classId: ClassId): UtModel
20+
21+
/**
22+
* Constructs UtCompositeModel.
23+
*
24+
* Uses runtime javaClass to collect ALL fields, except final static fields, and builds this model recursively.
25+
*/
26+
fun constructCompositeModel(value: Any): UtCompositeModel
2027
}
2128

2229
/**
@@ -314,12 +321,12 @@ class UtModelConstructor(
314321
}
315322
}
316323

317-
/**
318-
* Constructs UtCompositeModel.
319-
*
320-
* Uses runtime javaClass to collect ALL fields, except final static fields, and builds this model recursively.
321-
*/
322-
private fun constructCompositeModel(value: Any, remainingDepth: Long): UtModel {
324+
override fun constructCompositeModel(value: Any): UtCompositeModel = constructCompositeModel(
325+
value,
326+
remainingDepth = maxDepth
327+
)
328+
329+
private fun constructCompositeModel(value: Any, remainingDepth: Long): UtCompositeModel {
323330
// value can be mock only if it was previously constructed from UtCompositeModel
324331
val isMock = objectToModelCache[value]?.isMockModel() ?: false
325332

@@ -350,6 +357,9 @@ class UtModelConstructor(
350357
private fun withMaxDepth(newMaxDepth: Long) = object : UtModelConstructorInterface {
351358
override fun construct(value: Any?, classId: ClassId): UtModel =
352359
construct(value, classId, newMaxDepth)
360+
361+
override fun constructCompositeModel(value: Any): UtCompositeModel =
362+
constructCompositeModel(value, newMaxDepth)
353363
}
354364
}
355365

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/instrumentation/spring/UtMockMvcResultActionsModelConstructor.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class UtMockMvcResultActionsModelConstructor : UtCustomModelConstructor {
3030

3131
return UtSpringMockMvcResultActionsModel(
3232
id = id,
33+
origin = internalConstructor.constructCompositeModel(value),
3334
status = responseGetStatusMethodId.method.invoke(response) as Int,
3435
errorMessage = responseGetErrorMessageMethodId.method.invoke(response) as String?,
3536
contentAsString = responseGetContentAsStringMethodId.method.invoke(response) as String,

0 commit comments

Comments
 (0)