Skip to content

Commit

Permalink
add 5 test cases for lukas-krecan#405
Browse files Browse the repository at this point in the history
current date, modify days and hours
  • Loading branch information
rgseyvie committed Apr 24, 2022
1 parent 7e60d54 commit 4a44d07
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,36 @@ void shouldAssertObjectJson() {
void shouldAssertContainsEntry() {
assertThatJson("{\"a\":{\"b\": 1}}").node("a").isObject().contains(entry("b", valueOf(1)));
}

//date issue
@Test
void shouldReplaceDate() {
assertThatJson("{\"root\":{\"test\":1, \"date\": \"2022-04-24: 15\"}}").isEqualTo("{\"root\":{\"test\":1, \"date\": \"${json-unit.current-date.format:yyyy-MM-dd: HH}\"}}");
}

//date issue
@Test
void shouldReplaceDaysAdded() {
assertThatJson("{\"root\":{\"test\":1, \"date\": \"2022-04-25\"}}").isEqualTo("{\"root\":{\"test\":1, \"date\": \"${json-unit.current-date.DAYS#+1.format:yyyy-MM-dd}\"}}");
}

//date issue
@Test
void shouldReplaceDaysDeducted() {
assertThatJson("{\"root\":{\"test\":1, \"date\": \"2022-04-22\"}}").isEqualTo("{\"root\":{\"test\":1, \"date\": \"${json-unit.current-date.DAYS#-2.format:yyyy-MM-dd}\"}}");
}

//date issue
@Test
void shouldReplaceHoursAdded() {
assertThatJson("{\"root\":{\"test\":1, \"date\": \"2022-04-24: 16\"}}").isEqualTo("{\"root\":{\"test\":1, \"date\": \"${json-unit.current-date.HOURS#+1.format:yyyy-MM-dd: HH}\"}}");
}

//date issue
@Test
void shouldReplaceHoursDeducted() {
assertThatJson("{\"root\":{\"test\":1, \"date\": \"2022-04-24: 11\"}}").isEqualTo("{\"root\":{\"test\":1, \"date\": \"${json-unit.current-date.HOURS#-4.format:yyyy-MM-dd: HH}\"}}");
}

@Test
void shouldAssertContainsJsonError() {
Expand Down

0 comments on commit 4a44d07

Please sign in to comment.