vertx/src/test/java/eu/internetofus/common/vertx/ModelResourcesTest.java
/**
   * Should retrieve model field value.
   *
   * @param resultHandler handler to manage the HTTP result.
   * @param searcher      the function used to search a model.
   *
   * @see ModelResources#retrieveModelField(ModelContext, BiConsumer,
   *      java.util.function.Function, ServiceContext)
   */
Should retrieve model field value.
@param resultHandler handler to manage the HTTP result.
@param searcher      the function used to search a model.


Should retrieve model field value . @param resultHandler handler to manage the HTTP result . @param searcher the function used to search a model .
@Test
  public void shouldRetrieveModelField(@Mock final Handler<AsyncResult<ServiceResponse>> resultHandler,
      @Mock final BiConsumer<String, Handler<AsyncResult<DummyComplexModel>>> searcher) {
    final var model = this.createModelContext();
    final var context = this.createServiceContext(resultHandler);
    ModelResources.retrieveModelField(model, searcher, dummy -> dummy.siblings, context);
    @SuppressWarnings("unchecked")
    final ArgumentCaptor<Handler<AsyncResult<DummyComplexModel>>> searchHandler = ArgumentCaptor
        .forClass(Handler.class);
    verify(searcher, timeout(30000).times(1)).accept(any(), searchHandler.capture());
    final var target = new DummyComplexModelTest().createModelExample(2);
    searchHandler.getValue().handle(Future.succeededFuture(target));
    @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.OK.getStatusCode());
    final var retrieveModel = Model.fromJsonArray(result.getPayload(), DummyComplexModel.class);
    assertThat(retrieveModel).isNotNull().isEqualTo(target.siblings);
  }
@ Test public void shouldRetrieveModelField ( @ Mock final Handler < AsyncResult < ServiceResponse > > resultHandler , @ Mock final BiConsumer < String , Handler < AsyncResult < DummyComplexModel > > > searcher ) { final var model = this . createModelContext ( ) ; final var context = this . createServiceContext ( resultHandler ) ; ModelResources . retrieveModelField ( model , searcher , dummy -> dummy . siblings , context ) ; @ SuppressWarnings ( "unchecked" ) final ArgumentCaptor < Handler < AsyncResult < DummyComplexModel > > > searchHandler = ArgumentCaptor . forClass ( Handler . class ) ; verify ( searcher , timeout ( 30000 ) . times ( 1 ) ) . accept ( any ( ) , searchHandler . capture ( ) ) ; final var target = new DummyComplexModelTest ( ) . createModelExample ( 2 ) ; searchHandler . getValue ( ) . handle ( Future . succeededFuture ( target ) ) ; @ 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 . OK . getStatusCode ( ) ) ; final var retrieveModel = Model . fromJsonArray ( result . getPayload ( ) , DummyComplexModel . class ) ; assertThat ( retrieveModel ) . isNotNull ( ) . isEqualTo ( target . siblings ) ; }
Should retrieve model field value.
Should retrieve model field value .