Codota Logo
RequestMethod
Code IndexAdd Codota to your IDE (free)

How to use
RequestMethod
in
com.github.tomakehurst.wiremock.http

Best Java code snippets using com.github.tomakehurst.wiremock.http.RequestMethod (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ScheduledThreadPoolExecutor s =
  • Codota Iconnew ScheduledThreadPoolExecutor(corePoolSize)
  • Codota IconThreadFactory threadFactory;new ScheduledThreadPoolExecutor(corePoolSize, threadFactory)
  • Codota IconString str;new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat(str).build())
  • Smart code suggestions by Codota
}
origin: com.github.tomakehurst/wiremock-jre8

@Override
public RequestMethod getMethod() {
  return RequestMethod.fromString(request.getMethod().toUpperCase());
}
origin: com.github.tomakehurst/wiremock-jre8

@Override
public String getExpected() {
  return getName();
}
origin: com.github.tomakehurst/wiremock-jre8

@JsonCreator
public static RequestMethod fromString(String value) {
  return new RequestMethod(value);
}
origin: com.github.tomakehurst/wiremock-jre8

  public static HttpUriRequest getHttpRequestFor(RequestMethod method, String url) {
    notifier().info("Proxying: " + method + " " + url);

    if (method.equals(GET))
      return new HttpGet(url);
    else if (method.equals(POST))
      return new HttpPost(url);
    else if (method.equals(PUT))
      return new HttpPut(url);
    else if (method.equals(DELETE))
      return new HttpDelete(url);
    else if (method.equals(HEAD))
      return new HttpHead(url);
    else if (method.equals(OPTIONS))
      return new HttpOptions(url);
    else if (method.equals(TRACE))
      return new HttpTrace(url);
    else if (method.equals(PATCH))
      return new HttpPatch(url);
    else
      return new GenericHttpUriRequest(method.toString(), url);
  }
}
origin: com.github.tomakehurst/wiremock-jre8

public boolean matches(RequestMethod method, String path) {
  return (this.method.equals(ANY) || this.method.equals(method)) && uriTemplate.matches(path);
}
origin: aws/aws-sdk-java-v2

  @Override
  protected void doAssert(LoggedRequest actual) {
    assertEquals(expectedMethodName.name(), actual.getMethod().value());
  }
}
origin: com.github.tomakehurst/wiremock-jre8

  @Override
  public int hashCode() {
    int result = method.hashCode();
    result = 31 * result + uriTemplate.hashCode();
    return result;
  }
}
origin: com.github.tomakehurst/wiremock-jre8

private static void addBodyIfPostPutOrPatch(HttpRequest httpRequest, ResponseDefinition response) throws UnsupportedEncodingException {
  Request originalRequest = response.getOriginalRequest();
  if (originalRequest.getMethod().isOneOf(PUT, POST, PATCH)) {
    HttpEntityEnclosingRequest requestWithEntity = (HttpEntityEnclosingRequest) httpRequest;
    requestWithEntity.setEntity(buildEntityFrom(originalRequest));
  }
}
origin: com.github.tomakehurst/wiremock-jre8

@Override
public MatchResult match(Request request) {
  List<WeightedMatchResult> matchResults = new ArrayList<>(asList(
      weight(RequestPattern.this.url.match(request.getUrl()), 10.0),
      weight(RequestPattern.this.method.match(request.getMethod()), 3.0),
      weight(allHeadersMatchResult(request)),
      weight(allQueryParamsMatch(request)),
      weight(allCookiesMatch(request)),
      weight(allBodyPatternsMatch(request)),
      weight(allMultipartPatternsMatch(request))
  ));
  if (hasInlineCustomMatcher) {
    matchResults.add(weight(customMatcher.match(request)));
  }
  return MatchResult.aggregateWeighted(matchResults);
}
origin: com.github.tomakehurst/wiremock-jre8

public MatchResult match(RequestMethod method) {
  return MatchResult.of(this.equals(ANY) || this.equals(method));
}
origin: software.amazon.awssdk/protocol-tests-core

  @Override
  protected void doAssert(LoggedRequest actual) throws Exception {
    assertEquals(expectedMethodName.name(), actual.getMethod().value());
  }
}
origin: stackoverflow.com

 private void setStub(WireMockServer server, String url, RequestMethod requestMethod, Object body)
   throws JsonProcessingException {

 ObjectMapper mapper = new ObjectMapper();
 String jsonInString = mapper.writeValueAsString(body);

 server.addStubMapping(
    WireMock.request(requestMethod.getName(), WireMock.urlMatching(url))
       .willReturn(WireMock.aResponse().withStatus(200).withBody(jsonInString)
          .withHeader("Content-Type", "text/plain").withHeader("Access-Control-Allow-Origin", "*")
          )
       .build());
}
origin: com.github.tomakehurst/wiremock-jre8

public static MappingBuilder request(String method, UrlPattern urlPattern) {
  return new BasicMappingBuilder(RequestMethod.fromString(method), urlPattern);
}
origin: com.github.tomakehurst/wiremock-jre8

@Override
public boolean equals(Object o) {
  if (this == o) return true;
  if (o == null || getClass() != o.getClass()) return false;
  RequestSpec that = (RequestSpec) o;
  if (!method.equals(that.method)) return false;
  if (!uriTemplate.equals(that.uriTemplate)) return false;
  return true;
}
origin: com.atlassian.oai/swagger-request-validator-wiremock

  /**
   * Builds a {@link Request} for the OpenAPI validator out of the
   * original {@link com.github.tomakehurst.wiremock.http.Request}.
   *
   * @param originalRequest the original {@link com.github.tomakehurst.wiremock.http.Request}
   */
  @Nonnull
  public static Request of(@Nonnull final com.github.tomakehurst.wiremock.http.Request originalRequest) {
    requireNonNull(originalRequest, "An original request is required");

    final URI uri = URI.create(originalRequest.getUrl());
    final Map<String, QueryParameter> queryParameterMap = Urls.splitQuery(uri);

    final SimpleRequest.Builder builder =
        new SimpleRequest.Builder(originalRequest.getMethod().getName(), uri.getPath())
            .withBody(originalRequest.getBodyAsString());
    originalRequest.getHeaders().all().forEach(header -> builder.withHeader(header.key(), header.values()));
    queryParameterMap.forEach((key, value) -> builder.withQueryParam(key, value.values()));
    return builder.build();
  }
}
origin: HotelsDotCom/styx

@Override
public RequestMethod getMethod() {
  return RequestMethod.fromString(styxRequest.method().name());
}
origin: com.github.tomakehurst/wiremock-jre8

  private void respondTo(Request request, Response response) {
    try {
      if (response.wasConfigured()) {
        applyResponse(response, httpServletRequest, httpServletResponse);
      } else if (request.getMethod().equals(GET) && shouldForwardToFilesContext) {
        forwardToFilesContext(httpServletRequest, httpServletResponse, request);
      } else {
        httpServletResponse.sendError(HTTP_NOT_FOUND);
      }
    } catch (Exception e) {
      throwUnchecked(e);
    }
  }
}
origin: com.github.tomakehurst/wiremock-jre8

private <B, R> R executeRequest(RequestSpec requestSpec, PathParams pathParams, B requestBody, Class<R> responseType) {
  String url = String.format(ADMIN_URL_PREFIX + requestSpec.path(pathParams), scheme, host, port, urlPathPrefix);
  RequestBuilder requestBuilder = RequestBuilder
      .create(requestSpec.method().getName())
      .setUri(url);
  if (requestBody != null) {
    requestBuilder.setEntity(jsonStringEntity(Json.write(requestBody)));
  }
  String responseBodyString = safelyExecuteRequest(url, requestBuilder.build());
  return responseType == Void.class ?
      null :
      Json.read(responseBodyString, responseType);
}
origin: aws/aws-sdk-java-v2

private void validateResponse(HttpExecuteResponse response, int returnCode, SdkHttpMethod method) throws IOException {
  RequestMethod requestMethod = RequestMethod.fromString(method.name());
  RequestPatternBuilder patternBuilder = RequestPatternBuilder.newRequestPattern(requestMethod, urlMatching("/"))
                                    .withHeader("Host", containing("localhost"))
                                    .withHeader("User-Agent", equalTo("hello-world!"));
  if (method == SdkHttpMethod.HEAD) {
    patternBuilder.withRequestBody(equalTo(""));
  } else {
    patternBuilder.withRequestBody(equalTo("Body"));
  }
  verify(1, patternBuilder);
  if (method == SdkHttpMethod.HEAD) {
    assertThat(response.responseBody()).isEmpty();
  } else {
    assertThat(IoUtils.toUtf8String(response.responseBody().orElse(null))).isEqualTo("hello");
  }
  assertThat(response.httpResponse().firstMatchingHeader("Some-Header")).contains("With Value");
  assertThat(response.httpResponse().statusCode()).isEqualTo(returnCode);
  mockServer.resetMappings();
}
origin: com.github.tomakehurst/wiremock-jre8

public List<DiffLine<?>> getLines(Map<String, RequestMatcherExtension> customMatcherExtensions) {
  ImmutableList.Builder<DiffLine<?>> builder = ImmutableList.builder();
  DiffLine<RequestMethod> methodSection = new DiffLine<>("HTTP method", requestPattern.getMethod(), request.getMethod(), requestPattern.getMethod().getName());
  builder.add(methodSection);
com.github.tomakehurst.wiremock.httpRequestMethod

Most used methods

  • fromString
  • getName
  • <init>
  • equals
  • hashCode
  • isOneOf
  • match
  • toString
  • value

Popular in Java

  • Start an intent from android
  • addToBackStack (FragmentTransaction)
  • getSystemService (Context)
  • getContentResolver (Context)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registery of org.quartz
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now