vertx/src/test/java/eu/internetofus/common/vertx/ModelResourcesTest.java
/**
   * Should delete a model.
   *
   * @param deleter       the function that will delete the model.
   * @param resultHandler handler to manage the HTTP result.
   *
   * @see ModelResources#deleteModel(ModelContext, BiConsumer, ServiceContext)
   */
Should delete a model.
@param deleter       the function that will delete the model.
@param resultHandler handler to manage the HTTP result.


Should delete a model . @param deleter the function that will delete the model . @param resultHandler handler to manage the HTTP result .
@Test
  public void shouldDeleteModel(@Mock final BiConsumer<String, Handler<AsyncResult<Void>>> deleter,
      @Mock final Handler<AsyncResult<ServiceResponse>> resultHandler) {
    final var model = this.createModelContext();
    final var context = this.createServiceContext(resultHandler);
    ModelResources.deleteModel(model, deleter, context);
    @SuppressWarnings("unchecked")
    final ArgumentCaptor<Handler<AsyncResult<Void>>> deleteHandler = ArgumentCaptor.forClass(Handler.class);
    verify(deleter, timeout(30000).times(1)).accept(any(), deleteHandler.capture());
    deleteHandler.getValue().handle(Future.succeededFuture());
    @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.NO_CONTENT.getStatusCode());
    assertThat(result.getPayload()).isNull();
  }
@ Test public void shouldDeleteModel ( @ Mock final BiConsumer < String , Handler < AsyncResult < Void > > > deleter , @ Mock final Handler < AsyncResult < ServiceResponse > > resultHandler ) { final var model = this . createModelContext ( ) ; final var context = this . createServiceContext ( resultHandler ) ; ModelResources . deleteModel ( model , deleter , context ) ; @ SuppressWarnings ( "unchecked" ) final ArgumentCaptor < Handler < AsyncResult < Void > > > deleteHandler = ArgumentCaptor . forClass ( Handler . class ) ; verify ( deleter , timeout ( 30000 ) . times ( 1 ) ) . accept ( any ( ) , deleteHandler . capture ( ) ) ; deleteHandler . getValue ( ) . handle ( Future . succeededFuture ( ) ) ; @ 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 . NO_CONTENT . getStatusCode ( ) ) ; assertThat ( result . getPayload ( ) ) . isNull ( ) ; }
Should delete a model.
Should delete a model .