model/src/test/java/eu/internetofus/common/model/MergeAsserts.java
/**
   * Assert that a model is not valid because a field is wrong.
   *
   * @param target      model to merge.
   * @param source      model to merge.
   * @param fieldName   name of the field that is not valid.
   * @param context     of the validated models.
   * @param testContext test context to use.
   * @param <T>         type of model to merge.
   * @param <C>         type of context to use.
   */
Assert that a model is not valid because a field is wrong.
@param target      model to merge.
@param source      model to merge.
@param fieldName   name of the field that is not valid.
@param context     of the validated models.
@param testContext test context to use.
@param          type of model to merge.
@param          type of context to use.
Assert that a model is not valid because a field is wrong . @param target model to merge . @param source model to merge . @param fieldName name of the field that is not valid . @param context of the validated models . @param testContext test context to use . @param type of model to merge . @param type of context to use .
public static <C extends ValidateContext<C>, T> void assertCannotMerge(final Mergeable<T, C> target, final T source,
      final String fieldName, final C context, final VertxTestContext testContext) {
    target.merge(source, context).onComplete(testContext.failing(error -> testContext.verify(() -> {
      assertThat(error).isInstanceOf(ValidationErrorException.class);
      var expectedCode = "codePrefix";
      if (fieldName != null) {
        expectedCode += "." + fieldName;
      }
      assertThat(((ValidationErrorException) error).getCode()).isEqualTo(expectedCode);
      testContext.completeNow();
    })));
  }
public static < C extends ValidateContext < C > , T > void assertCannotMerge ( final Mergeable < T , C > target , final T source , final String fieldName , final C context , final VertxTestContext testContext ) { target . merge ( source , context ) . onComplete ( testContext . failing ( error -> testContext . verify ( ( ) -> { assertThat ( error ) . isInstanceOf ( ValidationErrorException . class ) ; var expectedCode = "codePrefix" ; if ( fieldName != null ) { expectedCode += "." + fieldName ; } assertThat ( ( ( ValidationErrorException ) error ) . getCode ( ) ) . isEqualTo ( expectedCode ) ; 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 .