Skip to content

Infinite loop in jakarta-validation module due to constraints on container elements #1231

@momoysm

Description

@momoysm

Describe the bug

@NotNull@NotBlank를 사용한 컨테이너 내부 요소에 잘못된 제약조건을 검증할 때 테스트가 완료되지 않는 문제가 있습니다.

Your environment

  • version of Fixture Monkey: 1.1.4
  • version of Java/Kotlin: JDK 17

Steps to reproduce

해당 테스트 케이스는 성공하는 테스트 케이스 입니다.

   FixtureMonkey SUT = FixtureMonkey.builder()
      .plugin(new JakartaValidationPlugin()) // JavaxValidationPlugin()
      .nullableContainer(false)
      .nullableElement(false)
      .build();

   @Property(tries = 1)
   void testElementNotEmpty() {
      thenThrownBy(
         () -> SUT.giveMeBuilder(SimpleObject.class)
            .size("notEmptyElement", 1)
            .setNull("notEmptyElement[0]")
            .sample()
      )
         .getCause()
         .isExactlyInstanceOf(RetryableFilterMissException.class)
         .hasMessageContaining("is not validated by annotations.");
   }

   @Data
   public static class SimpleObject {
       @NotEmpty
       private List<@NotEmpty String> notEmptyElement;
    
       @NotEmpty
       private List<@NotNull String> notNullElement;
    
       @NotEmpty
       private List<@NotBlank String> notBlankElement;
   
   }

아래는 테스트 실행이 완료되지 않는 케이스입니다.

   @Property(tries = 1)
   void testElementNotNull() {
      thenThrownBy(
         () -> SUT.giveMeBuilder(SimpleObject.class)
            .size("notNullElement", 1)
            .setNull("notNullElement[0]")
            .sample()
      ).getCause()
         .isExactlyInstanceOf(RetryableFilterMissException.class)
         .hasMessageContaining("is not validated by annotations.");
   }

   @Property(tries = 1)
   void testElementNotBlank() {
      thenThrownBy(
         () -> SUT.giveMeBuilder(SimpleObject.class)
            .size("notBlankElement", 1)
            .setNull("notBlankElement[0]")
            .sample()
      ).getCause()
         .isExactlyInstanceOf(RetryableFilterMissException.class)
         .hasMessageContaining("is not validated by annotations.");
   }

Expected behaviour

@NotEmpty @NotNull @NotBlank로 컨테이너 내부 요소를 검증할 때 잘못된 제약조건으로 인한 테스트 성공을 기대함.

Actual behaviour

testElementNotEmpty 테스트는 정상적으로 성공함.
testElementNotNull, testElementNotBlank 테스트 실행 시 테스트가 완료되지 않는 문제 발생.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions