Fixed the bug with bad sent msgs
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
package org.springframework.cloud.contract.stubrunner.messaging.camel
|
||||
|
||||
import groovy.transform.PackageScope
|
||||
import org.springframework.cloud.contract.verifier.util.BodyAsStringUtil
|
||||
import org.springframework.cloud.contract.verifier.util.BodyExtractor
|
||||
import org.apache.camel.Exchange
|
||||
import org.apache.camel.Message
|
||||
import org.apache.camel.Processor
|
||||
@@ -47,7 +47,7 @@ class StubRunnerCamelProcessor implements Processor {
|
||||
if (!groovyDsl.outputMessage) {
|
||||
return
|
||||
}
|
||||
input.body = BodyAsStringUtil.extractStubValueFrom(groovyDsl.outputMessage.body)
|
||||
input.body = BodyExtractor.extractStubValueFrom(groovyDsl.outputMessage.body)
|
||||
groovyDsl.outputMessage.headers?.entries?.each {
|
||||
input.setHeader(it.name, it.clientValue)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.cloud.contract.stubrunner.messaging.integration
|
||||
|
||||
import org.springframework.cloud.contract.verifier.dsl.Contract
|
||||
import org.springframework.cloud.contract.verifier.util.BodyAsStringUtil
|
||||
import org.springframework.cloud.contract.verifier.util.BodyExtractor
|
||||
import org.springframework.integration.transformer.GenericTransformer
|
||||
import org.springframework.messaging.Message
|
||||
import org.springframework.messaging.MessageHeaders
|
||||
@@ -41,7 +41,7 @@ class StubRunnerIntegrationTransformer implements GenericTransformer<Message<?>,
|
||||
if (!groovyDsl.outputMessage) {
|
||||
return source
|
||||
}
|
||||
String payload = BodyAsStringUtil.extractStubValueFrom(groovyDsl.outputMessage.body)
|
||||
String payload = BodyExtractor.extractStubValueFrom(groovyDsl.outputMessage.body)
|
||||
Map<String, Object> headers = groovyDsl.outputMessage.headers.asStubSideMap()
|
||||
return MessageBuilder.createMessage(payload, new MessageHeaders(headers))
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.contract.stubrunner.messaging.stream
|
||||
|
||||
import org.springframework.cloud.contract.verifier.util.BodyAsStringUtil
|
||||
import org.springframework.cloud.contract.verifier.util.BodyExtractor
|
||||
import org.springframework.cloud.contract.verifier.dsl.Contract
|
||||
import org.springframework.integration.transformer.GenericTransformer
|
||||
import org.springframework.messaging.Message
|
||||
@@ -41,7 +41,7 @@ class StubRunnerStreamTransformer implements GenericTransformer<Message<?>, Mess
|
||||
if (!groovyDsl.outputMessage) {
|
||||
return source
|
||||
}
|
||||
String payload = BodyAsStringUtil.extractStubValueFrom(groovyDsl.outputMessage.body)
|
||||
String payload = BodyExtractor.extractStubValueFrom(groovyDsl.outputMessage.body)
|
||||
Map<String, Object> headers = groovyDsl.outputMessage.headers.asStubSideMap()
|
||||
return MessageBuilder.createMessage(payload, new MessageHeaders(headers))
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.cloud.contract.verifier.dsl.Contract
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessage
|
||||
import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessaging
|
||||
import org.springframework.cloud.contract.verifier.messaging.noop.NoOpContractVerifierMessaging
|
||||
import org.springframework.cloud.contract.verifier.util.BodyExtractor
|
||||
|
||||
/**
|
||||
* Runs stubs for a particular {@link StubServer}
|
||||
@@ -127,7 +128,8 @@ class StubRunnerExecutor implements StubFinder {
|
||||
if (!groovyDsl.outputMessage) {
|
||||
return
|
||||
}
|
||||
ContractVerifierMessage message = contractVerifierMessaging.create(groovyDsl.outputMessage?.body?.clientValue,
|
||||
ContractVerifierMessage message = contractVerifierMessaging.create(
|
||||
BodyExtractor.extractClientValueFromBody(groovyDsl.outputMessage?.body?.clientValue),
|
||||
groovyDsl.outputMessage?.headers?.asStubSideMap())
|
||||
contractVerifierMessaging.send(message, groovyDsl.outputMessage.sentTo.clientValue)
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ import static ContentUtils.extractValue
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@CompileStatic
|
||||
class BodyAsStringUtil {
|
||||
class BodyExtractor {
|
||||
|
||||
private BodyAsStringUtil() {}
|
||||
private BodyExtractor() {}
|
||||
|
||||
/**
|
||||
* Returns the string representation of the body for the server side.
|
||||
@@ -63,7 +63,7 @@ class BodyAsStringUtil {
|
||||
return toTrim.startsWith('"') ? toTrim.replaceAll('"', '') : toTrim
|
||||
}
|
||||
|
||||
private static Object extractServerValueFromBody(bodyValue) {
|
||||
static Object extractServerValueFromBody(bodyValue) {
|
||||
if (bodyValue instanceof GString) {
|
||||
bodyValue = extractValue(bodyValue, { DslProperty dslProperty -> dslProperty.serverValue })
|
||||
} else {
|
||||
@@ -72,7 +72,7 @@ class BodyAsStringUtil {
|
||||
return bodyValue
|
||||
}
|
||||
|
||||
private static Object extractClientValueFromBody(bodyValue) {
|
||||
static Object extractClientValueFromBody(bodyValue) {
|
||||
if (bodyValue instanceof GString) {
|
||||
return extractValue(bodyValue, { DslProperty dslProperty -> dslProperty.clientValue })
|
||||
} else if (bodyValue instanceof DslProperty) {
|
||||
Reference in New Issue
Block a user