public String apply(ClearType input) { return input.name().toLowerCase(); } }));
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(); } })); } }
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(); } })); } }
/** * Clear expectations, logs or both that match the http * * @param httpRequest the http request that is matched against when deciding whether to clear each expectation if null all expectations are cleared * @param type the type to clear, EXPECTATION, LOG or BOTH */ public MockServerClient clear(HttpRequest httpRequest, ClearType type) { sendRequest(request().withMethod("PUT").withPath(calculatePath("clear")).withQueryStringParameter("type", type.name().toLowerCase()).withBody(httpRequest != null ? httpRequestSerializer.serialize(httpRequest) : "", StandardCharsets.UTF_8)); return clientClass.cast(this); }
public String apply(ClearType input) { return input.name().toLowerCase(); } }));
/** * Clear expectations, logs or both that match the http * * @param httpRequest the http request that is matched against when deciding whether to clear each expectation if null all expectations are cleared * @param type the type to clear, EXPECTATION, LOG or BOTH */ public MockServerClient clear(HttpRequest httpRequest, ClearType type) { sendRequest(request().withMethod("PUT").withPath(calculatePath("clear")).withQueryStringParameter("type", type.name().toLowerCase()).withBody(httpRequest != null ? httpRequestSerializer.serialize(httpRequest) : "", StandardCharsets.UTF_8)); return clientClass.cast(this); }