11package org.evomaster.core.output.service
22
3- import com.fasterxml.jackson.core.JsonProcessingException
4- import com.fasterxml.jackson.databind.ObjectMapper
53import com.google.inject.Inject
64import org.evomaster.core.logging.LoggingUtil
75import org.evomaster.core.output.JsonUtils
@@ -13,6 +11,7 @@ import org.evomaster.core.output.auth.CookieWriter
1311import org.evomaster.core.output.auth.TokenWriter
1412import org.evomaster.core.output.dto.DtoCall
1513import org.evomaster.core.output.dto.GeneToDto
14+ import org.evomaster.core.output.formatter.OutputFormatter
1615import org.evomaster.core.problem.enterprise.EnterpriseActionGroup
1716import org.evomaster.core.problem.externalservice.httpws.HttpExternalServiceAction
1817import 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