Fixed quite a few tests
This commit is contained in:
@@ -94,8 +94,8 @@ public class WireMockHttpServerStub implements HttpServerStub {
|
||||
@Override
|
||||
public HttpServerStub start() {
|
||||
if (isRunning()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("The server is already running at port [" + port() + "]");
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("The server is already running at port [" + port() + "]");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -113,8 +113,8 @@ public class WireMockHttpServerStub implements HttpServerStub {
|
||||
@Override
|
||||
public HttpServerStub stop() {
|
||||
if (!isRunning()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Trying to stop a non started server!");
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Trying to stop a non started server!");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -96,9 +96,7 @@ abstract class BaseWireMockStubStrategy {
|
||||
*/
|
||||
String parseBody(Map map, ContentType contentType) {
|
||||
def transformedMap = MapConverter.getStubSideValues(map)
|
||||
String responseSideBody = toJson(MapConverter.getTestSideValues(contract.request.body))
|
||||
DocumentContext context = JsonPath.parse(responseSideBody)
|
||||
transformedMap = processEntriesForTemplating(transformedMap, context)
|
||||
transformedMap = transformMapIfRequestPresent(transformedMap)
|
||||
String json = toJson(transformedMap)
|
||||
// the space is important cause at the end of the json body you also have a }
|
||||
// you can't have 4 } next to each other
|
||||
@@ -106,6 +104,17 @@ abstract class BaseWireMockStubStrategy {
|
||||
return parseBody(unquotedJson, contentType)
|
||||
}
|
||||
|
||||
private Object transformMapIfRequestPresent(Object transformedMap) {
|
||||
def requestBody = contract.request.body
|
||||
if (requestBody == null) {
|
||||
return transformedMap
|
||||
}
|
||||
String testSideBody = toJson(
|
||||
MapConverter.getTestSideValues(requestBody))
|
||||
DocumentContext context = JsonPath.parse(testSideBody)
|
||||
return processEntriesForTemplating(transformedMap, context)
|
||||
}
|
||||
|
||||
private Object processEntriesForTemplating(transformedMap, DocumentContext context) {
|
||||
return transformValues(transformedMap, {
|
||||
if (it instanceof String && processor.containsJsonPathTemplateEntry(it)) {
|
||||
|
||||
Reference in New Issue
Block a user