vertx/src/test/java/eu/internetofus/common/vertx/ComponentClientTest.java
/**
   * Check that create a handler that can manage any content with a response with
   * an error.
   *
   * @param response    to process.
   * @param testContext context that manage the test.
   *
   * @see ComponentClient#createHandlerWithAnyBodyAndSuccessResponse(io.vertx.core.Promise,
   *      String)
   */
Check that create a handler that can manage any content with a response with
an error.

@param response    to process.
@param testContext context that manage the test.


Check that create a handler that can manage any content with a response with an error . @param response to process . @param testContext context that manage the test .
@Test
  public void shouldHandleWithBodyAndErrorReponse(@Mock final HttpResponse<Buffer> response,
      final VertxTestContext testContext) {
    final var service = new ComponentClient(null, null);
    final var code = Status.BAD_REQUEST.getStatusCode();
    doReturn(code).when(response).statusCode();
    final var error = new ErrorMessageTest().createModelExample(2);
    doReturn(error.toBuffer()).when(response).bodyAsBuffer();
    final var message = UUID.randomUUID().toString();
    doReturn(message).when(response).statusMessage();
    final Promise<Model> promise = Promise.promise();
    service.createHandlerWithAnyBodyAndSuccessResponse(promise, "actionId").handle(response);
    promise.future().onComplete(testContext.failing(cause -> testContext.verify(() -> {
      assertThat(cause).isNotNull().isInstanceOf(ServiceException.class);
      final var exception = (ServiceException) cause;
      assertThat(exception.failureCode()).isEqualTo(code);
      assertThat(exception.getMessage()).isEqualTo(message);
      assertThat(exception.getDebugInfo()).isEqualTo(error.toJsonObject());
      testContext.completeNow();
    })));
  }
@ Test public void shouldHandleWithBodyAndErrorReponse ( @ Mock final HttpResponse < Buffer > response , final VertxTestContext testContext ) { final var service = new ComponentClient ( null , null ) ; final var code = Status . BAD_REQUEST . getStatusCode ( ) ; doReturn ( code ) . when ( response ) . statusCode ( ) ; final var error = new ErrorMessageTest ( ) . createModelExample ( 2 ) ; doReturn ( error . toBuffer ( ) ) . when ( response ) . bodyAsBuffer ( ) ; final var message = UUID . randomUUID ( ) . toString ( ) ; doReturn ( message ) . when ( response ) . statusMessage ( ) ; final Promise < Model > promise = Promise . promise ( ) ; service . createHandlerWithAnyBodyAndSuccessResponse ( promise , "actionId" ) . handle ( response ) ; promise . future ( ) . onComplete ( testContext . failing ( cause -> testContext . verify ( ( ) -> { assertThat ( cause ) . isNotNull ( ) . isInstanceOf ( ServiceException . class ) ; final var exception = ( ServiceException ) cause ; assertThat ( exception . failureCode ( ) ) . isEqualTo ( code ) ; assertThat ( exception . getMessage ( ) ) . isEqualTo ( message ) ; assertThat ( exception . getDebugInfo ( ) ) . isEqualTo ( error . toJsonObject ( ) ) ; testContext . completeNow ( ) ; } ) ) ) ; }
Check that create a handler that can manage any content with a response with
 an error.
Check that create a handler that can manage any content with a response with an error .