vertx/src/test/java/eu/internetofus/common/vertx/ModelResourcesTest.java
/**
   * Should not convert a {@code null} JSON object to a model.
   *
   * @param resultHandler handler to manage the HTTP result.
   * @param success       the function to call if the conversion was a success.
   *
   * @see ModelResources#toModel(JsonObject, ModelContext, ServiceContext,
   *      Runnable)
   */
Should not convert a  null JSON object to a model.
@param resultHandler handler to manage the HTTP result.
@param success       the function to call if the conversion was a success.


Should not convert a null JSON object to a model . @param resultHandler handler to manage the HTTP result . @param success the function to call if the conversion was a success .
@Test
  public void shouldNotConvertANullJsonObject(@Mock final Handler<AsyncResult<ServiceResponse>> resultHandler,
      @Mock final Runnable success) {
    final var model = this.createModelContext();
    final var context = this.createServiceContext(resultHandler);
    ModelResources.toModel(null, model, context, success);
    @SuppressWarnings("unchecked")
    final ArgumentCaptor<AsyncResult<ServiceResponse>> resultCaptor = ArgumentCaptor.forClass(AsyncResult.class);
    verify(resultHandler, timeout(30000).times(1)).handle(resultCaptor.capture());
    final var asyncResult = resultCaptor.getValue();
    assertThat(asyncResult.failed()).isFalse();
    final var result = asyncResult.result();
    assertThat(result.getStatusCode()).isEqualTo(Status.BAD_REQUEST.getStatusCode());
    final var error = Model.fromBuffer(result.getPayload(), ErrorMessage.class);
    assertThat(error).isNotNull();
    assertThat(error.code).contains(model.name);
    assertThat(error.message).contains(model.name).isNotEqualTo(error.code);
    verify(success, never()).run();
  }
@ Test public void shouldNotConvertANullJsonObject ( @ Mock final Handler < AsyncResult < ServiceResponse > > resultHandler , @ Mock final Runnable success ) { final var model = this . createModelContext ( ) ; final var context = this . createServiceContext ( resultHandler ) ; ModelResources . toModel ( null , model , context , success ) ; @ SuppressWarnings ( "unchecked" ) final ArgumentCaptor < AsyncResult < ServiceResponse > > resultCaptor = ArgumentCaptor . forClass ( AsyncResult . class ) ; verify ( resultHandler , timeout ( 30000 ) . times ( 1 ) ) . handle ( resultCaptor . capture ( ) ) ; final var asyncResult = resultCaptor . getValue ( ) ; assertThat ( asyncResult . failed ( ) ) . isFalse ( ) ; final var result = asyncResult . result ( ) ; assertThat ( result . getStatusCode ( ) ) . isEqualTo ( Status . BAD_REQUEST . getStatusCode ( ) ) ; final var error = Model . fromBuffer ( result . getPayload ( ) , ErrorMessage . class ) ; assertThat ( error ) . isNotNull ( ) ; assertThat ( error . code ) . contains ( model . name ) ; assertThat ( error . message ) . contains ( model . name ) . isNotEqualTo ( error . code ) ; verify ( success , never ( ) ) . run ( ) ; }
Should not convert a {@code null} JSON object to a model.
Should not convert a { @code null } JSON object to a model .