Class Matchers

java.lang.Object
org.keycloak.tests.utils.matchers.Matchers

public class Matchers extends Object
Additional hamcrest matchers
Author:
hmlnarik
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.hamcrest.Matcher<jakarta.ws.rs.core.Response>
    body(org.hamcrest.Matcher<String> matcher)
    Matcher on HTTP status code of a Response instance.
    static org.hamcrest.Matcher<org.apache.http.HttpResponse>
    bodyHC(org.hamcrest.Matcher<String> matcher)
    Matcher on HTTP body of a Response instance.
    static <T> org.hamcrest.Matcher<jakarta.ws.rs.core.Response>
    header(org.hamcrest.Matcher<Map<String,T>> matcher)
    Matches when the HTTP status code of a Response instance is equal to the given code.
    static <T> org.hamcrest.Matcher<org.keycloak.dom.saml.v2.SAML2Object>
    Matches when the type of a SAML object is instance of AuthnRequestType.
    static <T> org.hamcrest.Matcher<org.keycloak.dom.saml.v2.SAML2Object>
    Matches when the destination of a SAML LogoutRequestType instance is equal to the given destination.
    static <T> org.hamcrest.Matcher<org.keycloak.dom.saml.v2.SAML2Object>
    isSamlResponse(org.keycloak.saml.common.constants.JBossSAMLURIConstants expectedStatus)
    Matches when the SAML status code of a ResponseType instance is equal to the given code.
    static <T> org.hamcrest.Matcher<org.keycloak.dom.saml.v2.SAML2Object>
    isSamlStatusResponse(org.keycloak.saml.common.constants.JBossSAMLURIConstants... expectedStatus)
    Matches when the SAML status of a StatusResponseType instance is equal to the given code.
    static org.hamcrest.Matcher<jakarta.ws.rs.core.Response>
    statusCode(org.hamcrest.Matcher<? extends Number> matcher)
    Matcher on HTTP status code of a Response instance.
    static org.hamcrest.Matcher<org.apache.http.HttpResponse>
    statusCodeHC(org.hamcrest.Matcher<? extends Number> matcher)
    Matcher on HTTP status code of a Response instance (HttpClient variant).
    static org.hamcrest.Matcher<jakarta.ws.rs.core.Response>
    statusCodeIs(int expectedStatusCode)
    Matches when the HTTP status code of a Response instance is equal to the given code.
    static org.hamcrest.Matcher<jakarta.ws.rs.core.Response>
    statusCodeIs(jakarta.ws.rs.core.Response.Status expectedStatusCode)
    Matches when the HTTP status code of a Response instance is equal to the given code.
    static org.hamcrest.Matcher<org.apache.http.HttpResponse>
    statusCodeIsHC(int expectedStatusCode)
    Matches when the HTTP status code of a Response instance is equal to the given code (HttpClient variant).
    static org.hamcrest.Matcher<org.apache.http.HttpResponse>
    statusCodeIsHC(jakarta.ws.rs.core.Response.Status expectedStatusCode)
    Matches when the HTTP status code of a Response instance is equal to the given code (HttpClient variant).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Matchers

      public Matchers()
  • Method Details

    • body

      public static org.hamcrest.Matcher<jakarta.ws.rs.core.Response> body(org.hamcrest.Matcher<String> matcher)
      Matcher on HTTP status code of a Response instance.
      Parameters:
      matcher -
      Returns:
    • bodyHC

      public static org.hamcrest.Matcher<org.apache.http.HttpResponse> bodyHC(org.hamcrest.Matcher<String> matcher)
      Matcher on HTTP body of a Response instance.
      Parameters:
      matcher -
      Returns:
    • statusCode

      public static org.hamcrest.Matcher<jakarta.ws.rs.core.Response> statusCode(org.hamcrest.Matcher<? extends Number> matcher)
      Matcher on HTTP status code of a Response instance.
      Parameters:
      matcher -
      Returns:
    • statusCodeHC

      public static org.hamcrest.Matcher<org.apache.http.HttpResponse> statusCodeHC(org.hamcrest.Matcher<? extends Number> matcher)
      Matcher on HTTP status code of a Response instance (HttpClient variant).
      Parameters:
      matcher -
      Returns:
    • statusCodeIs

      public static org.hamcrest.Matcher<jakarta.ws.rs.core.Response> statusCodeIs(jakarta.ws.rs.core.Response.Status expectedStatusCode)
      Matches when the HTTP status code of a Response instance is equal to the given code.
      Parameters:
      expectedStatusCode -
      Returns:
    • statusCodeIsHC

      public static org.hamcrest.Matcher<org.apache.http.HttpResponse> statusCodeIsHC(jakarta.ws.rs.core.Response.Status expectedStatusCode)
      Matches when the HTTP status code of a Response instance is equal to the given code (HttpClient variant).
      Parameters:
      expectedStatusCode -
      Returns:
    • statusCodeIs

      public static org.hamcrest.Matcher<jakarta.ws.rs.core.Response> statusCodeIs(int expectedStatusCode)
      Matches when the HTTP status code of a Response instance is equal to the given code.
      Parameters:
      expectedStatusCode -
      Returns:
    • statusCodeIsHC

      public static org.hamcrest.Matcher<org.apache.http.HttpResponse> statusCodeIsHC(int expectedStatusCode)
      Matches when the HTTP status code of a Response instance is equal to the given code (HttpClient variant).
      Parameters:
      expectedStatusCode -
      Returns:
    • header

      public static <T> org.hamcrest.Matcher<jakarta.ws.rs.core.Response> header(org.hamcrest.Matcher<Map<String,T>> matcher)
      Matches when the HTTP status code of a Response instance is equal to the given code.
      Parameters:
      matcher -
      Returns:
    • isSamlResponse

      public static <T> org.hamcrest.Matcher<org.keycloak.dom.saml.v2.SAML2Object> isSamlResponse(org.keycloak.saml.common.constants.JBossSAMLURIConstants expectedStatus)
      Matches when the SAML status code of a ResponseType instance is equal to the given code.
      Parameters:
      expectedStatus -
      Returns:
    • isSamlLogoutRequest

      public static <T> org.hamcrest.Matcher<org.keycloak.dom.saml.v2.SAML2Object> isSamlLogoutRequest(String destination)
      Matches when the destination of a SAML LogoutRequestType instance is equal to the given destination.
      Parameters:
      destination -
      Returns:
    • isSamlAuthnRequest

      public static <T> org.hamcrest.Matcher<org.keycloak.dom.saml.v2.SAML2Object> isSamlAuthnRequest()
      Matches when the type of a SAML object is instance of AuthnRequestType.
      Returns:
    • isSamlStatusResponse

      public static <T> org.hamcrest.Matcher<org.keycloak.dom.saml.v2.SAML2Object> isSamlStatusResponse(org.keycloak.saml.common.constants.JBossSAMLURIConstants... expectedStatus)
      Matches when the SAML status of a StatusResponseType instance is equal to the given code.
      Parameters:
      expectedStatus -
      Returns: