model/src/test/java/eu/internetofus/common/model/ValidableAsserts.java
/**
   * Assert that a model is not valid because a field is wrong.
   *
   * @param model       to validate.
   * @param fieldName   name of the field that is not valid.
   * @param context     with the loaded components.
   * @param testContext test context to use.
   * @param <C>         type of context.
   */
Assert that a model is not valid because a field is wrong.
@param model       to validate.
@param fieldName   name of the field that is not valid.
@param context     with the loaded components.
@param testContext test context to use.
@param          type of context.
Assert that a model is not valid because a field is wrong . @param model to validate . @param fieldName name of the field that is not valid . @param context with the loaded components . @param testContext test context to use . @param type of context .
public static <C extends ValidateContext<C>> void assertIsNotValid(final Validable<C> model, final String fieldName,
      final C context, final VertxTestContext testContext) {
    model.validate(context).onComplete(testContext.failing(error -> testContext.verify(() -> {
      assertThat(error).isInstanceOf(ValidationErrorException.class);
      final var code = ((ValidationErrorException) error).getCode();
      if (fieldName != null) {
        assertThat(code).isEqualTo(context.fieldErrorCode(fieldName));
      } else {
        assertThat(code).startsWith(context.errorCode());
      }
      testContext.completeNow();
    })));
  }
public static < C extends ValidateContext < C > > void assertIsNotValid ( final Validable < C > model , final String fieldName , final C context , final VertxTestContext testContext ) { model . validate ( context ) . onComplete ( testContext . failing ( error -> testContext . verify ( ( ) -> { assertThat ( error ) . isInstanceOf ( ValidationErrorException . class ) ; final var code = ( ( ValidationErrorException ) error ) . getCode ( ) ; if ( fieldName != null ) { assertThat ( code ) . isEqualTo ( context . fieldErrorCode ( fieldName ) ) ; } else { assertThat ( code ) . startsWith ( context . errorCode ( ) ) ; } testContext . completeNow ( ) ; } ) ) ) ; }
Assert that a model is not valid because a field is wrong.
Assert that a model is not valid because a field is wrong .