vertx/src/test/java/eu/internetofus/common/vertx/AbstractModelFieldResourcesIT.java
/**
   * Should update element.
   *
   * @param vertx       event bus to use.
   * @param client      to connect to the server.
   * @param testContext context to test.
   */
Should update element.
@param vertx       event bus to use.
@param client      to connect to the server.
@param testContext context to test.
Should update element . @param vertx event bus to use . @param client to connect to the server . @param testContext context to test .
@Test
  public void shouldUpdateElement(final Vertx vertx, final WebClient client, final VertxTestContext testContext) {
    testContext.assertComplete(this.storeValidExampleModelWithFieldElements(4, vertx, testContext)).onSuccess(model -> {
      testContext.assertComplete(this.createValidModelFieldElementExample(11, vertx, testContext))
          .onSuccess(element -> {
            final var modelId = this.idOfModel(model, testContext);
            final var field = this.fieldOf(model, testContext);
            final var elementId = this.idOfElementIn(model, field.get(field.size() - 1));
            final var checkpoint = testContext.checkpoint(2);
            final var path = this.modelPath() + "/" + modelId + this.fieldPath() + "/" + elementId;
            testRequest(client, HttpMethod.PUT, path).expect(res -> {
              assertThat(res.statusCode()).isEqualTo(Status.OK.getStatusCode());
              @SuppressWarnings("unchecked")
              final var updated = (E) assertThatBodyIs(element.getClass(), res);
              this.assertEqualsAdded(element, updated);
              final var getPath = this.modelPath() + "/" + this.idOfModel(model, testContext);
              testRequest(client, HttpMethod.GET, getPath).expect(resRetrieve -> {
                assertThat(resRetrieve.statusCode()).isEqualTo(Status.OK.getStatusCode());
                @SuppressWarnings("unchecked")
                final var updatedModel = (T) assertThatBodyIs(model.getClass(), resRetrieve);
                final var updatedField = this.fieldOf(updatedModel);
                assertThat(updatedField).isNotEmpty().contains(updated);
              }).sendJson(element.toJsonObject(), testContext, checkpoint);
            }).sendJson(element.toJsonObject(), testContext, checkpoint);
          });
    });
  }
@ Test public void shouldUpdateElement ( final Vertx vertx , final WebClient client , final VertxTestContext testContext ) { testContext . assertComplete ( this . storeValidExampleModelWithFieldElements ( 4 , vertx , testContext ) ) . onSuccess ( model -> { testContext . assertComplete ( this . createValidModelFieldElementExample ( 11 , vertx , testContext ) ) . onSuccess ( element -> { final var modelId = this . idOfModel ( model , testContext ) ; final var field = this . fieldOf ( model , testContext ) ; final var elementId = this . idOfElementIn ( model , field . get ( field . size ( ) - 1 ) ) ; final var checkpoint = testContext . checkpoint ( 2 ) ; final var path = this . modelPath ( ) + "/" + modelId + this . fieldPath ( ) + "/" + elementId ; testRequest ( client , HttpMethod . PUT , path ) . expect ( res -> { assertThat ( res . statusCode ( ) ) . isEqualTo ( Status . OK . getStatusCode ( ) ) ; @ SuppressWarnings ( "unchecked" ) final var updated = ( E ) assertThatBodyIs ( element . getClass ( ) , res ) ; this . assertEqualsAdded ( element , updated ) ; final var getPath = this . modelPath ( ) + "/" + this . idOfModel ( model , testContext ) ; testRequest ( client , HttpMethod . GET , getPath ) . expect ( resRetrieve -> { assertThat ( resRetrieve . statusCode ( ) ) . isEqualTo ( Status . OK . getStatusCode ( ) ) ; @ SuppressWarnings ( "unchecked" ) final var updatedModel = ( T ) assertThatBodyIs ( model . getClass ( ) , resRetrieve ) ; final var updatedField = this . fieldOf ( updatedModel ) ; assertThat ( updatedField ) . isNotEmpty ( ) . contains ( updated ) ; } ) . sendJson ( element . toJsonObject ( ) , testContext , checkpoint ) ; } ) . sendJson ( element . toJsonObject ( ) , testContext , checkpoint ) ; } ) ; } ) ; }
Should update element.
Should update element .