arquillian-extension-persistence icon indicating copy to clipboard operation
arquillian-extension-persistence copied to clipboard

Support for regex expression in expected datasets

Open rmpestano opened this issue 8 years ago • 1 comments

example:

expected-users-regex.yml

useraccount:
  - id: "regex:\\d+"
    firstname: regex:^Jo.* #John
    lastname: regex:.*ith$ #Smith
    username: regex:.oovd. #doovde
    password: password
    openDate: regex:^(?:[0-9]{2})?[0-9]{2}-[0-3]?[0-9]-[0-3]?[0-9]$

the test:

    @Test
    @ShouldMatchDataSet("expected-users-regex.yml")
    public void should_verify_database_content_using_regex_in_expected_dataset() {
          UserAccount ua = new UserAccount();
          ua.setFirstName("John");
          ua.setUserName("doovde");
          ua.setOpenDate(newDate()); 
          entityManager.persist(ua);
    }

The main motivation is to deal with dynamic data in datasets. Here in the example is the Id which is generated by JPA and openDate.

Although it helps in some cases in most of the cases we have 'controlled' static data in datasets so I think if we add this feature it should come disabled.

What do you think?

rmpestano avatar May 28 '16 15:05 rmpestano

I would appreciate the "regex:" -possibility using Arquillian integration testing !

jenskreidler avatar May 18 '20 08:05 jenskreidler