if (!Strings.isNullOrEmpty(request.getBodyAsString())){ curlString.append(" --data '").append(request.getBodyAsString().replace("\'", "\\'")).append("'");
public void clear(HttpRequest request) { HttpRequest requestMatcher = null; if (!Strings.isNullOrEmpty(request.getBodyAsString())) { requestMatcher = httpRequestSerializer.deserialize(request.getBodyAsString()); } try { ClearType retrieveType = ClearType.valueOf(StringUtils.defaultIfEmpty(request.getFirstQueryStringParameter("type").toUpperCase(), "ALL")); switch (retrieveType) { case LOG: mockServerLog.clear(requestMatcher); mockServerLogger.info(CLEARED, requestMatcher, "clearing recorded requests and logs that match:{}", (requestMatcher == null ? "{}" : requestMatcher)); break; case EXPECTATIONS: mockServerMatcher.clear(requestMatcher); mockServerLogger.info(CLEARED, requestMatcher, "clearing expectations that match:{}", (requestMatcher == null ? "{}" : requestMatcher)); break; case ALL: mockServerLog.clear(requestMatcher); mockServerMatcher.clear(requestMatcher); mockServerLogger.info(CLEARED, requestMatcher, "clearing expectations and request logs that match:{}", (requestMatcher == null ? "{}" : requestMatcher)); break; } } catch (IllegalArgumentException iae) { throw new IllegalArgumentException("\"" + request.getFirstQueryStringParameter("type") + "\" is not a valid value for \"type\" parameter, only the following values are supported " + Lists.transform(Arrays.asList(ClearType.values()), new Function<ClearType, String>() { public String apply(ClearType input) { return input.name().toLowerCase(); } })); } }
httpResponse.withBody((BodyWithContentType) request.getBody()); } else { httpResponse.withBody(request.getBodyAsString());
PortBinding requestedPortBindings = portBindingSerializer.deserialize(request.getBodyAsString()); if (requestedPortBindings != null) { try {
if (request != null) { HttpRequest httpRequest = null; if (!Strings.isNullOrEmpty(request.getBodyAsString())) { httpRequest = httpRequestSerializer.deserialize(request.getBodyAsString());
for (Expectation expectation : expectationSerializer.deserializeArray(request.getBodyAsString())) { if (!warDeployment || validateSupportedFeatures(expectation, request, responseWriter)) { add(expectation); Verification verification = verificationSerializer.deserialize(request.getBodyAsString()); mockServerLogger.info(VERIFICATION, verification.getHttpRequest(), "verifying requests that match:{}", verification); String result = verify(verification); VerificationSequence verificationSequence = verificationSequenceSerializer.deserialize(request.getBodyAsString()); mockServerLogger.info(VERIFICATION, verificationSequence.getHttpRequests(), "verifying sequence that match:{}", verificationSequence); String result = verify(verificationSequence);
if (!Strings.isNullOrEmpty(request.getBodyAsString())){ curlString.append(" --data '").append(request.getBodyAsString().replace("\'", "\\'")).append("'");
public void clear(HttpRequest request) { HttpRequest requestMatcher = null; if (!Strings.isNullOrEmpty(request.getBodyAsString())) { requestMatcher = httpRequestSerializer.deserialize(request.getBodyAsString()); } try { ClearType retrieveType = ClearType.valueOf(StringUtils.defaultIfEmpty(request.getFirstQueryStringParameter("type").toUpperCase(), "ALL")); switch (retrieveType) { case LOG: mockServerLog.clear(requestMatcher); mockServerLogger.info(CLEARED, requestMatcher, "clearing recorded requests and logs that match:{}", (requestMatcher == null ? "{}" : requestMatcher)); break; case EXPECTATIONS: mockServerMatcher.clear(requestMatcher); mockServerLogger.info(CLEARED, requestMatcher, "clearing expectations that match:{}", (requestMatcher == null ? "{}" : requestMatcher)); break; case ALL: mockServerLog.clear(requestMatcher); mockServerMatcher.clear(requestMatcher); mockServerLogger.info(CLEARED, requestMatcher, "clearing expectations and request logs that match:{}", (requestMatcher == null ? "{}" : requestMatcher)); break; } } catch (IllegalArgumentException iae) { throw new IllegalArgumentException("\"" + request.getFirstQueryStringParameter("type") + "\" is not a valid value for \"type\" parameter, only the following values are supported " + Lists.transform(Arrays.asList(ClearType.values()), new Function<ClearType, String>() { public String apply(ClearType input) { return input.name().toLowerCase(); } })); } }
httpResponse.withBody((BodyWithContentType) request.getBody()); } else { httpResponse.withBody(request.getBodyAsString());
PortBinding requestedPortBindings = portBindingSerializer.deserialize(request.getBodyAsString()); if (requestedPortBindings != null) { try {
public HttpResponse retrieve(HttpRequest request) { HttpRequest httpRequest = null; if (!Strings.isNullOrEmpty(request.getBodyAsString())) { httpRequest = httpRequestSerializer.deserialize(request.getBodyAsString());
for (Expectation expectation : expectationSerializer.deserializeArray(request.getBodyAsString())) { if (!warDeployment || validateSupportedFeatures(expectation, request, responseWriter)) { add(expectation); Verification verification = verificationSerializer.deserialize(request.getBodyAsString()); mockServerLogger.info(VERIFICATION, verification.getHttpRequest(), "verifying requests that match:{}", verification); String result = verify(verification); VerificationSequence verificationSequence = verificationSequenceSerializer.deserialize(request.getBodyAsString()); mockServerLogger.info(VERIFICATION, verificationSequence.getHttpRequests(), "verifying sequence that match:{}", verificationSequence); String result = verify(verificationSequence);