vertx/src/test/java/eu/internetofus/common/vertx/AbstractModelFieldResourcesIT.java
/**
   * Should delete element.
   *
   * @param vertx       event bus to use.
   * @param client      to connect to the server.
   * @param testContext context to test.
   */
Should delete element.
@param vertx       event bus to use.
@param client      to connect to the server.
@param testContext context to test.
Should delete element . @param vertx event bus to use . @param client to connect to the server . @param testContext context to test .
@Test
  public void shouldDeleteElement(final Vertx vertx, final WebClient client, final VertxTestContext testContext) {
    testContext.assertComplete(this.storeValidExampleModelWithFieldElements(4, vertx, testContext)).onSuccess(model -> {
      final var modelId = this.idOfModel(model, testContext);
      final var field = this.fieldOf(model, testContext);
      final var element = field.get(field.size() - 1);
      final var elementId = this.idOfElementIn(model, element);
      final var checkpoint = testContext.checkpoint(2);
      final var path = this.modelPath() + "/" + modelId + this.fieldPath() + "/" + elementId;
      testRequest(client, HttpMethod.DELETE, path).expect(res -> {
        assertThat(res.statusCode()).isEqualTo(Status.NO_CONTENT.getStatusCode());
        testRequest(client, HttpMethod.DELETE, path).expect(res2 -> {
          assertThat(res2.statusCode()).isEqualTo(Status.NOT_FOUND.getStatusCode());
          final var error = assertThatBodyIs(ErrorMessage.class, res2);
          assertThat(error.code).isNotEmpty();
          assertThat(error.message).isNotEmpty().isNotEqualTo(error.code);
        }).send(testContext, checkpoint);
      }).send(testContext, checkpoint);
    });
  }
@ Test public void shouldDeleteElement ( final Vertx vertx , final WebClient client , final VertxTestContext testContext ) { testContext . assertComplete ( this . storeValidExampleModelWithFieldElements ( 4 , vertx , testContext ) ) . onSuccess ( model -> { final var modelId = this . idOfModel ( model , testContext ) ; final var field = this . fieldOf ( model , testContext ) ; final var element = field . get ( field . size ( ) - 1 ) ; final var elementId = this . idOfElementIn ( model , element ) ; final var checkpoint = testContext . checkpoint ( 2 ) ; final var path = this . modelPath ( ) + "/" + modelId + this . fieldPath ( ) + "/" + elementId ; testRequest ( client , HttpMethod . DELETE , path ) . expect ( res -> { assertThat ( res . statusCode ( ) ) . isEqualTo ( Status . NO_CONTENT . getStatusCode ( ) ) ; testRequest ( client , HttpMethod . DELETE , path ) . expect ( res2 -> { assertThat ( res2 . statusCode ( ) ) . isEqualTo ( Status . NOT_FOUND . getStatusCode ( ) ) ; final var error = assertThatBodyIs ( ErrorMessage . class , res2 ) ; assertThat ( error . code ) . isNotEmpty ( ) ; assertThat ( error . message ) . isNotEmpty ( ) . isNotEqualTo ( error . code ) ; } ) . send ( testContext , checkpoint ) ; } ) . send ( testContext , checkpoint ) ; } ) ; }
Should delete element.
Should delete element .