vertx/src/test/java/eu/internetofus/common/vertx/ModelResourcesTest.java
/**
   * Should obtain models page.
   *
   * @param resultHandler handler to manage the HTTP result.
   * @param searcher      the function to obtain the page.
   *
   * @see ModelResources#toModel(JsonObject, ModelContext, ServiceContext,
   *      Runnable)
   */
Should obtain models page.
@param resultHandler handler to manage the HTTP result.
@param searcher      the function to obtain the page.


Should obtain models page . @param resultHandler handler to manage the HTTP result . @param searcher the function to obtain the page .
@Test
  public void shouldRetrieveModelsPage(@Mock final Handler<AsyncResult<ServiceResponse>> resultHandler,
      @Mock final BiConsumer<ModelsPageContext, Promise<JsonObject>> searcher) {
    final var context = this.createServiceContext(resultHandler);
    ModelResources.retrieveModelsPage(0, 100, searcher, context);
    @SuppressWarnings("unchecked")
    final ArgumentCaptor<Promise<JsonObject>> searchHandler = ArgumentCaptor.forClass(Promise.class);
    verify(searcher, timeout(30000).times(1)).accept(any(), searchHandler.capture());
    final var expectedPage = new JsonObject().put("models", new JsonArray()).put("offset", 0).put("limit", 100);
    searchHandler.getValue().complete(expectedPage);
    @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 page = Json.decodeValue(result.getPayload());
    assertThat(page).isNotNull().isEqualTo(expectedPage);
  }
@ Test public void shouldRetrieveModelsPage ( @ Mock final Handler < AsyncResult < ServiceResponse > > resultHandler , @ Mock final BiConsumer < ModelsPageContext , Promise < JsonObject > > searcher ) { final var context = this . createServiceContext ( resultHandler ) ; ModelResources . retrieveModelsPage ( 0 , 100 , searcher , context ) ; @ SuppressWarnings ( "unchecked" ) final ArgumentCaptor < Promise < JsonObject > > searchHandler = ArgumentCaptor . forClass ( Promise . class ) ; verify ( searcher , timeout ( 30000 ) . times ( 1 ) ) . accept ( any ( ) , searchHandler . capture ( ) ) ; final var expectedPage = new JsonObject ( ) . put ( "models" , new JsonArray ( ) ) . put ( "offset" , 0 ) . put ( "limit" , 100 ) ; searchHandler . getValue ( ) . complete ( expectedPage ) ; @ 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 page = Json . decodeValue ( result . getPayload ( ) ) ; assertThat ( page ) . isNotNull ( ) . isEqualTo ( expectedPage ) ; }
Should obtain models page.
Should obtain models page .