vertx/src/test/java/eu/internetofus/common/vertx/ModelResourcesTest.java
/**
   * Should not update the model field element because the value to update is not
   * right.
   *
   * @param resultHandler     handler to manage the HTTP result.
   * @param searcher          the function used to search a model.
   * @param storerUpdateModel the function to update the model.
   *
   * @see ModelResources#updateModelFieldElement( JsonObject, ModelFieldContext,
   *      BiConsumer, java.util.function.Function, java.util.function.BiFunction,
   *      BiConsumer, ServiceContext)
   */
Should not update the model field element because the value to update is not
right.

@param resultHandler     handler to manage the HTTP result.
@param searcher          the function used to search a model.
@param storerUpdateModel the function to update the model.


Should not update the model field element because the value to update is not right . @param resultHandler handler to manage the HTTP result . @param searcher the function used to search a model . @param storerUpdateModel the function to update the model .
@Test
  public void shouldNotUpdateModelFieldElementBecauseBadValue(
      @Mock final Handler<AsyncResult<ServiceResponse>> resultHandler,
      @Mock final BiConsumer<String, Handler<AsyncResult<DummyComplexModel>>> searcher,
      @Mock final BiConsumer<DummyComplexModel, Handler<AsyncResult<Void>>> storerUpdateModel) {
    final var element = this.createModelFieldContextById();
    final var context = this.createServiceContext(resultHandler);
    final var valueToUpdate = new JsonObject().put("undefined", "value");
    ModelResources.updateModelFieldElement(valueToUpdate, element, searcher, dummy -> dummy.siblings,
        ModelResources.searchElementById((dummy, id) -> id != null && id.equals(dummy.id)), storerUpdateModel, context);
    @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("siblings");
    assertThat(error.message).contains("siblings");
  }
@ Test public void shouldNotUpdateModelFieldElementBecauseBadValue ( @ Mock final Handler < AsyncResult < ServiceResponse > > resultHandler , @ Mock final BiConsumer < String , Handler < AsyncResult < DummyComplexModel > > > searcher , @ Mock final BiConsumer < DummyComplexModel , Handler < AsyncResult < Void > > > storerUpdateModel ) { final var element = this . createModelFieldContextById ( ) ; final var context = this . createServiceContext ( resultHandler ) ; final var valueToUpdate = new JsonObject ( ) . put ( "undefined" , "value" ) ; ModelResources . updateModelFieldElement ( valueToUpdate , element , searcher , dummy -> dummy . siblings , ModelResources . searchElementById ( ( dummy , id ) -> id != null && id . equals ( dummy . id ) ) , storerUpdateModel , context ) ; @ 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 ( "siblings" ) ; assertThat ( error . message ) . contains ( "siblings" ) ; }
Should not update the model field element because the value to update is not
 right.
Should not update the model field element because the value to update is not right .