Package fr.gouv.vitam.common.client

# Class VitamRestTestClient

java.lang.Object
fr.gouv.vitam.common.client.DefaultClient
fr.gouv.vitam.common.client.VitamRestTestClient

All Implemented Interfaces:
  `BasicClient`, `MockOrRestClient`, `VitamAutoCloseable`, `AutoCloseable`

public class VitamRestTestClient extends DefaultClient
Vitam Restassured like client for Junit test Example:

       GET http://host:port/service/v1/resource/path1/monid1/path2/monid2
          Header: X-Request-Id = abcd
          Body = Json(body)
          Expected: OK
       int statusCode = testClient.given().accept(MediaType.APPLICATION_JSON_TYPE)
             .addHeader("X-Request-Id", "abcd")
             .addPathParameter("path1", "monid1").addPathParameter("path2", "monid2")
             .body(body, MediaType.APPLICATION_JSON_TYPE)
             .status(Status.OK).get("resource");

       POST http://host:port/service/v1/resource/path1/monid1/path2/monid2
          Header: X-Request-Id = abcd
          Body = Json(body)
          Expected: OK + Body: InputStream
       InputStream stream = testClient.given().accept(MediaType.APPLICATION_OCTET_STREAM_TYPE)
             .addHeader("X-Request-Id", "abcd")
             .addPathParameter("path1", "monid1").addPathParameter("path2", "monid2")
             .body(body, MediaType.APPLICATION_JSON_TYPE)
             .status(Status.OK).get("resource", InputStream.class);

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `VitamRestTestClient.VitamRestTest`
  VItam Rest Test: mimic of Restassured.RequestSpecification

- ## Field Summary

  ### Fields inherited from interface fr.gouv.vitam.common.client.BasicClient

  `STATUS_URL`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VitamRestTestClient(VitamClientFactoryInterface<?> factory)`
  Constructor using given scheme (http) and allowing multipart but no chunk

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `checkStatus()`
  Check the status from the service
  `void`
  `checkStatus(jakarta.ws.rs.core.MultivaluedHashMap<String,Object> headers)`
  Check the status from the service used to passe "X-SSL-CLIENT-CERT" header that contain a pem certificate
  `void`
  `close()`
  Close the underneath http client
  `final void`
  `consumeAnyEntityAndClose(jakarta.ws.rs.core.Response response)`
  Helper when an error occurs on client usage side to consume response however
  `jakarta.ws.rs.client.Client`
  `getChunkedClient()`
  `jakarta.ws.rs.client.Client`
  `getClient()`
  `VitamClientFactory<?>`
  `getClientFactory()`
  `String`
  `getResourcePath()`
  Get the resource path of the server.
  `String`
  `getServiceUrl()`
  Get the service URL
  `VitamRestTestClient.VitamRestTest`
  `given()`
  `jakarta.ws.rs.core.Response`
  `make(VitamRequestBuilder request)`
  `jakarta.ws.rs.core.Response`
  `makeSpecifyingUrl(VitamRequestBuilder request)`
  `static void`
  `staticConsumeAnyEntityAndClose(jakarta.ws.rs.core.Response response)`
  This method consume everything (in particular InputStream) and close the response.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### VitamRestTestClient

    public VitamRestTestClient(VitamClientFactoryInterface<?> factory)
    Constructor using given scheme (http) and allowing multipart but no chunk
    Parameters:
      `factory` - The client factory

- ## Method Details

  - ### given

    public VitamRestTestClient.VitamRestTest given()
    Returns:
      a VitamRestTest using this client

  - ### staticConsumeAnyEntityAndClose

    public static void staticConsumeAnyEntityAndClose(jakarta.ws.rs.core.Response response)
    This method consume everything (in particular InputStream) and close the response.
    Parameters:
      `response` -

  - ### consumeAnyEntityAndClose

    public final void consumeAnyEntityAndClose(jakarta.ws.rs.core.Response response)
    Description copied from interface: `MockOrRestClient`
    Helper when an error occurs on client usage side to consume response however
    Specified by:
      `consumeAnyEntityAndClose` in interface `MockOrRestClient`
    Parameters:
      `response` -

  - ### checkStatus

    public void checkStatus() throws VitamApplicationServerException
    Description copied from interface: `MockOrRestClient`
    Check the status from the service
    Specified by:
      `checkStatus` in interface `MockOrRestClient`
    Throws:
      `VitamApplicationServerException` - if the Server is unavailable

  - ### checkStatus

    public void checkStatus(jakarta.ws.rs.core.MultivaluedHashMap<String,Object> headers) throws VitamApplicationServerException
    Description copied from interface: `MockOrRestClient`
    Check the status from the service used to passe "X-SSL-CLIENT-CERT" header that contain a pem certificate
    Specified by:
      `checkStatus` in interface `MockOrRestClient`
    Parameters:
      `headers` -
    Throws:
      `VitamApplicationServerException` - if the Server is unavailable

  - ### getResourcePath

    public String getResourcePath()
    Description copied from interface: `MockOrRestClient`
    Get the resource path of the server.
    Specified by:
      `getResourcePath` in interface `MockOrRestClient`
    Returns:
      the resource path as string

  - ### getServiceUrl

    public String getServiceUrl()
    Description copied from interface: `MockOrRestClient`
    Get the service URL
    Specified by:
      `getServiceUrl` in interface `MockOrRestClient`
    Returns:
      the service URL

  - ### close

    public void close()
    Description copied from interface: `MockOrRestClient`
    Close the underneath http client
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `MockOrRestClient`
    Specified by:
      `close` in interface `VitamAutoCloseable`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### makeSpecifyingUrl

    public jakarta.ws.rs.core.Response makeSpecifyingUrl(VitamRequestBuilder request) throws VitamClientInternalException
    Throws:
      `VitamClientInternalException`

  - ### make

    public jakarta.ws.rs.core.Response make(VitamRequestBuilder request) throws VitamClientInternalException
    Throws:
      `VitamClientInternalException`

  - ### getClientFactory

    public VitamClientFactory<?> getClientFactory()

  - ### getClient

    public jakarta.ws.rs.client.Client getClient()

  - ### getChunkedClient

    public jakarta.ws.rs.client.Client getChunkedClient()