Skip to content

String parser/verifier for well-known formats #25

@mohamnag

Description

@mohamnag

I'm testing a REST API which returns ISO8601 serialized date and times in JSON using hamcrest matchers combined with JsonPath. Current situation is that if a date has to be verified, it must first be parsed and then the matcher in this library can be used for verification.

If this package provided some matchers which accepted String as input and verified a well-known format and additionally accepted further matchers which operate on specific date and time formats, a far better testing code could be written.

As an example imagine response contains a JSON string that has a ISO 8601 date and time under key timestamp, this could be verified like:

assertThat(response, 
    hasJsonPath("$.timestamp", 
        isIso8601DateAndTime(
            within(1, DAY, ZonedDateTime.now()))))

every piece here is already provided by either hamcrest core, JsonPath or this library but not the Matcher<String> isIso8601DateAndTime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions