Skip to content

Commit ef579d1

Browse files
committed
changes requested
1 parent fcccea3 commit ef579d1

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

core/src/main/kotlin/org/evomaster/core/output/service/HttpWsTestCaseWriter.kt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package org.evomaster.core.output.service
22

3-
import com.fasterxml.jackson.core.JsonProcessingException
4-
import com.fasterxml.jackson.databind.ObjectMapper
53
import com.google.inject.Inject
64
import org.evomaster.core.logging.LoggingUtil
75
import org.evomaster.core.output.JsonUtils
@@ -13,6 +11,7 @@ import org.evomaster.core.output.auth.CookieWriter
1311
import org.evomaster.core.output.auth.TokenWriter
1412
import org.evomaster.core.output.dto.DtoCall
1513
import org.evomaster.core.output.dto.GeneToDto
14+
import org.evomaster.core.output.formatter.OutputFormatter
1615
import org.evomaster.core.problem.enterprise.EnterpriseActionGroup
1716
import org.evomaster.core.problem.externalservice.httpws.HttpExternalServiceAction
1817
import org.evomaster.core.problem.httpws.HttpWsAction
@@ -126,7 +125,6 @@ abstract class HttpWsTestCaseWriter : ApiTestCaseWriter() {
126125
private fun writeDto(call: HttpWsAction, lines: Lines): String {
127126
val bodyParam = call.parameters.find { p -> p is BodyParam } as BodyParam?
128127
if (bodyParam != null && bodyParam.isJson() && payloadIsValidJson(bodyParam)) {
129-
130128
val primaryGene = bodyParam.primaryGene()
131129
val choiceGene = primaryGene.getWrappedGene(ChoiceGene::class.java)
132130
val actionName = call.getName()
@@ -155,13 +153,7 @@ abstract class HttpWsTestCaseWriter : ApiTestCaseWriter() {
155153
*/
156154
private fun payloadIsValidJson(bodyParam: BodyParam): Boolean {
157155
val json = bodyParam.getValueAsPrintableString(mode = GeneUtils.EscapeMode.JSON, targetFormat = format)
158-
val mapper = ObjectMapper()
159-
return try {
160-
mapper.readTree(json)
161-
true
162-
} catch (e: JsonProcessingException) {
163-
false
164-
}
156+
return OutputFormatter.JSON_FORMATTER.isValid(json)
165157
}
166158

167159
private fun generateDtoCall(gene: Gene, actionName: String, lines: Lines): DtoCall {

0 commit comments

Comments
 (0)