vertx/src/test/java/eu/internetofus/common/vertx/AbstractModelFieldResourcesIT.java
/**
   * Should not create an element if the JSON object is not valid.
   *
   * @param vertx       event bus to use.
   * @param client      to connect to the server.
   * @param testContext context to test.
   */
Should not create an element if the JSON object is not valid.
@param vertx       event bus to use.
@param client      to connect to the server.
@param testContext context to test.
Should not create an element if the JSON object is not valid . @param vertx event bus to use . @param client to connect to the server . @param testContext context to test .
@Test
  public void shouldNotCreateElementWithBadJsonObject(final Vertx vertx, final WebClient client,
      final VertxTestContext testContext) {
    testContext.assertComplete(this.storeValidExampleModelWithFieldElements(1, vertx, testContext)).onSuccess(model -> {
      final var path = this.modelPath() + "/" + this.idOfModel(model, testContext) + this.fieldPath();
      testRequest(client, HttpMethod.POST, path).expect(res -> {
        assertThat(res.statusCode()).isEqualTo(Status.BAD_REQUEST.getStatusCode());
        final var error = assertThatBodyIs(ErrorMessage.class, res);
        assertThat(error.code).isNotEmpty();
        assertThat(error.message).isNotEmpty().isNotEqualTo(error.code);
      }).sendJson(this.createBadJsonObjectModelFieldElement(), testContext);
    });
  }
@ Test public void shouldNotCreateElementWithBadJsonObject ( final Vertx vertx , final WebClient client , final VertxTestContext testContext ) { testContext . assertComplete ( this . storeValidExampleModelWithFieldElements ( 1 , vertx , testContext ) ) . onSuccess ( model -> { final var path = this . modelPath ( ) + "/" + this . idOfModel ( model , testContext ) + this . fieldPath ( ) ; testRequest ( client , HttpMethod . POST , path ) . expect ( res -> { assertThat ( res . statusCode ( ) ) . isEqualTo ( Status . BAD_REQUEST . getStatusCode ( ) ) ; final var error = assertThatBodyIs ( ErrorMessage . class , res ) ; assertThat ( error . code ) . isNotEmpty ( ) ; assertThat ( error . message ) . isNotEmpty ( ) . isNotEqualTo ( error . code ) ; } ) . sendJson ( this . createBadJsonObjectModelFieldElement ( ) , testContext ) ; } ) ; }
Should not create an element if the JSON object is not valid.
Should not create an element if the JSON object is not valid .