model/src/test/java/eu/internetofus/common/model/ValidateContextTest.java
/**
   * Check that a telephone value is not valid.
   *
   * @param value       to be valid.
   * @param testContext test context to use.
   *
   * @see ValidateContext#validateNullableTelephoneField(String, String, String,
   *      Promise)
   */
Check that a telephone value is not valid.
@param value       to be valid.
@param testContext test context to use.


Check that a telephone value is not valid . @param value to be valid . @param testContext test context to use .
@ParameterizedTest(name = "Should {0} not be valid")
  @ValueSource(strings = { "+349876543211", "bad telephone number", "1234567890123456789012345678" })
  public void shouldFailValidateNullableTelephone(final String value, final VertxTestContext testContext) {
    final Promise<Void> promise = Promise.promise();
    doReturn("codePrefixTelephone").when(this.context).errorCode();
    assertThat(this.context.validateNullableTelephoneField("telephone", value, null, promise)).isEqualTo(value);
    testContext.assertFailure(promise.future()).onFailure(error -> {
      testContext.verify(() -> {
        assertThat(error).isInstanceOf(ValidationErrorException.class);
        final var cause = (ValidationErrorException) error;
        assertThat(cause.getCode()).isEqualTo("codePrefixTelephone.telephone");
        assertThat(cause.getMessage()).isNotEmpty();
      });
      testContext.completeNow();
    });
  }
@ ParameterizedTest ( name = "Should {0} not be valid" ) @ ValueSource ( strings = { "+349876543211" , "bad telephone number" , "1234567890123456789012345678" } ) public void shouldFailValidateNullableTelephone ( final String value , final VertxTestContext testContext ) { final Promise < Void > promise = Promise . promise ( ) ; doReturn ( "codePrefixTelephone" ) . when ( this . context ) . errorCode ( ) ; assertThat ( this . context . validateNullableTelephoneField ( "telephone" , value , null , promise ) ) . isEqualTo ( value ) ; testContext . assertFailure ( promise . future ( ) ) . onFailure ( error -> { testContext . verify ( ( ) -> { assertThat ( error ) . isInstanceOf ( ValidationErrorException . class ) ; final var cause = ( ValidationErrorException ) error ; assertThat ( cause . getCode ( ) ) . isEqualTo ( "codePrefixTelephone.telephone" ) ; assertThat ( cause . getMessage ( ) ) . isNotEmpty ( ) ; } ) ; testContext . completeNow ( ) ; } ) ; }
Check that a telephone value is not valid.
Check that a telephone value is not valid .