@When("^the client performs (.+) request on \"(.+)\"$") public void perform_Http_Request(String httpMethod, String url) throws Throwable { facade.setResponsePrefix(""); facade.doRequest(httpMethod, url); } }
private void authenticate() { Optional<String> $type = world.get(CukesOptions.AUTH_TYPE); if (!$type.isPresent()) { return; } if ($type.get().equalsIgnoreCase("BASIC")) { authBasic(); } }
@Override public void failureOccurs(String exceptionClass) { assertThat(this.facade.getException().getClass().getSimpleName(), is(exceptionClass)); }
@Override public void bodyDoesNotContain(String body) { this.facade.response().then().body(not(containsString(body))); }
public void doRequest(String httpMethod, final String url) throws Exception { final HttpMethod method = HttpMethod.parse(httpMethod); // TODO: Should be refactored into CukesHttpPlugin boolean filterEnabled = world.getBoolean(CukesOptions.LOADRUNNER_FILTER_BLOCKS_REQUESTS); AwaitCondition awaitCondition = specification.awaitCondition(); try { if (awaitCondition != null && !filterEnabled) { int intervalTime = awaitCondition.getInterval().getValue(); TimeUnit intervalUnit = awaitCondition.getInterval().getUnitDict().getTimeUnit(); int waitTime = awaitCondition.getWaitTime().getValue(); TimeUnit unit = awaitCondition.getWaitTime().getUnitDict().getTimeUnit(); // TODO Fix Awaitility.with().pollInterval(intervalTime, intervalUnit) .await() .atMost(waitTime, unit) .until(doRequest(url, method), new AwaitConditionMatcher(awaitCondition)); } else { doRequest(url, method).call(); } } catch (RuntimeException e) { if (!expectException) { throw e; } exception = e; } specification.initNewSpecification(); }
private Callable<Response> doRequest(final String url, final HttpMethod method) { final boolean filterEnabled = world.getBoolean(CukesOptions.LOADRUNNER_FILTER_BLOCKS_REQUESTS); return () -> { authenticate(); final RequestSpecification requestSpec = specification.value(); for (CukesHttpPlugin plugin : pluginSet) { plugin.beforeRequest(requestSpec); } response = method.doRequest(requestSpec, url); for (CukesHttpPlugin plugin : pluginSet) { plugin.afterRequest(response); } if (!filterEnabled) { cacheHeaders(response); } return response; }; }
private void cacheHeaders(Response response) { clearOldHeaders(); Headers headers = response.getHeaders(); for (Header header : headers) { String headerName = CukesOptions.HEADER_PREFIX + header.getName(); world.put(headerName, header.getValue()); } }
private String getPath(String path) { if (!StringUtils.isEmpty(facade.getResponsePrefix())) { return facade.getResponsePrefix() + path; } else { return path; } }
@Override public void headerNotEqualTo(String headerName, String value) { this.facade.response().then().header(headerName, not(equalTo(value))); }
public void doRequest(String httpMethod, final String url) throws Exception { final HttpMethod method = HttpMethod.parse(httpMethod); // TODO: Should be refactored into CukesHttpPlugin boolean filterEnabled = world.getBoolean(CukesOptions.LOADRUNNER_FILTER_BLOCKS_REQUESTS); AwaitCondition awaitCondition = specification.awaitCondition(); try { if (awaitCondition != null && !filterEnabled) { int intervalTime = awaitCondition.getInterval().getValue(); TimeUnit intervalUnit = awaitCondition.getInterval().getUnitDict().getTimeUnit(); int waitTime = awaitCondition.getWaitTime().getValue(); TimeUnit unit = awaitCondition.getWaitTime().getUnitDict().getTimeUnit(); // TODO Fix Awaitility.with().pollInterval(intervalTime, intervalUnit) .await() .atMost(waitTime, unit) .until(doRequest(url, method), new AwaitConditionMatcher(awaitCondition)); } else { doRequest(url, method).call(); } } catch (RuntimeException e) { if (!expectException) { throw e; } exception = e; } specification.initNewSpecification(); }
private Callable<Response> doRequest(final String url, final HttpMethod method) { final boolean filterEnabled = world.getBoolean(CukesOptions.LOADRUNNER_FILTER_BLOCKS_REQUESTS); return () -> { authenticate(); final RequestSpecification requestSpec = specification.value(); for (CukesHttpPlugin plugin : pluginSet) { plugin.beforeRequest(requestSpec); } response = method.doRequest(requestSpec, url); for (CukesHttpPlugin plugin : pluginSet) { plugin.afterRequest(response); } if (!filterEnabled) { cacheHeaders(response); } return response; }; }
private void cacheHeaders(Response response) { clearOldHeaders(); Headers headers = response.getHeaders(); for (Header header : headers) { String headerName = CukesOptions.HEADER_PREFIX + header.getName(); world.put(headerName, header.getValue()); } }
private String getPath(String path) { if (!StringUtils.isEmpty(facade.getResponsePrefix())) { return facade.getResponsePrefix() + path; } else { return path; } }
@Override public void bodyNotEqualTo(String body) { this.facade.response().then().body(not(equalTo(body))); }
@When("^the query is executed$") public void execute_Query() throws Throwable { String contentType = ContentType.JSON.toString(); requestFacade.accept(contentType); requestFacade.contentType(contentType); responseFacade.setResponsePrefix("data."); responseFacade.doRequest("POST", ""); } }
private void authenticate() { Optional<String> $type = world.get(CukesOptions.AUTH_TYPE); if (!$type.isPresent()) { return; } if ($type.get().equalsIgnoreCase("BASIC")) { authBasic(); } }
@Override public void failureOccurs(String exceptionClass) { assertThat(this.facade.getException().getClass().getSimpleName(), is(exceptionClass)); }
@Override public void headerDoesNotContain(String headerName, String text) { this.facade.response().then().header(headerName, not(containsString(text))); }
@Override public void headerNotEqualTo(String headerName, String value) { this.facade.response().then().header(headerName, not(equalTo(value))); }
@Override public void statusCodeIsNot(int statusCode) { this.facade.response().then().statusCode(not(statusCode)); }