Skip to content

Commit 8973401

Browse files
Extract duplicated code
1 parent 6b48ffa commit 8973401

1 file changed

Lines changed: 0 additions & 24 deletions

File tree

  • core-tests/e2e-tests/spring/spring-rest-openapi-v3/src/test/kotlin/org/evomaster/e2etests/spring/openapi/v3/dtoreflectiveassert

core-tests/e2e-tests/spring/spring-rest-openapi-v3/src/test/kotlin/org/evomaster/e2etests/spring/openapi/v3/dtoreflectiveassert/DtoReflectiveAssertEMTest.kt

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
package org.evomaster.e2etests.spring.openapi.v3.dtoreflectiveassert
22

33
import com.foo.rest.examples.spring.openapi.v3.dtoreflectiveassert.DtoReflectiveAssertController
4-
import org.evomaster.client.java.instrumentation.shared.ClassName
54
import org.evomaster.core.problem.rest.data.HttpVerb
65
import org.evomaster.e2etests.spring.openapi.v3.SpringTestBase
76
import org.junit.jupiter.api.Assertions
87
import org.junit.jupiter.api.BeforeAll
98
import org.junit.jupiter.api.Test
10-
import java.util.Optional.ofNullable
119
import kotlin.reflect.KClass
12-
import kotlin.reflect.KMutableProperty1
13-
import kotlin.reflect.full.createInstance
1410
import kotlin.reflect.full.memberFunctions
15-
import kotlin.reflect.full.memberProperties
1611
import kotlin.reflect.jvm.isAccessible
1712
import kotlin.reflect.jvm.javaMethod
1813

@@ -161,25 +156,6 @@ class DtoReflectiveAssertEMTest: SpringTestBase() {
161156
assertAdditionalPropertiesFunction(parentKlass, parentInstance, "no_root_key", childInstance)
162157
}
163158

164-
private fun initDtoClass(name: String): Pair<KClass<out Any>, Any> {
165-
val className = ClassName("org.foo.dto.$name")
166-
val klass = loadClass(className).kotlin
167-
Assertions.assertNotNull(klass)
168-
return Pair(klass, klass.createInstance())
169-
}
170-
171-
private fun assertProperty(klass: KClass<out Any>, instance: Any, propertyName: String, propertyValue: Any?) {
172-
val property = klass.memberProperties
173-
.firstOrNull { it.name == propertyName } as? KMutableProperty1<Any, Any?>
174-
Assertions.assertNotNull(property)
175-
176-
property?.let {
177-
it.isAccessible = true
178-
it.set(instance, ofNullable(propertyValue)) // Set the value
179-
}
180-
Assertions.assertEquals(ofNullable(propertyValue), property?.get(instance))
181-
}
182-
183159
private fun assertAdditionalPropertiesFunction(klass: KClass<out Any>, instance: Any, propertyName: String, propertyValue: Any?) {
184160
val setterFunction = klass.memberFunctions.firstOrNull {
185161
it.name == "addAdditionalProperty"

0 commit comments

Comments
 (0)