Skip to content

Commit

Permalink
Update the parsing of dynamic values to also consider element from js…
Browse files Browse the repository at this point in the history
…on payloads
  • Loading branch information
en-milie committed Oct 5, 2020
1 parent 5b1c759 commit 02b158b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/test/java/com/endava/cats/util/CatsDSLParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,37 @@ public void setup() {
@Test
void shouldReturnSameValue() {
String initial = "test";
String actual = catsDSLParser.parseAndGetResult(initial);
String actual = catsDSLParser.parseAndGetResult(initial, null);

Assertions.assertThat(actual).isEqualTo(initial);
}

@Test
void shouldParseAsDate() {
String initial = "T(java.time.OffsetDateTime).now().plusDays(2)";
String actual = catsDSLParser.parseAndGetResult(initial);
String actual = catsDSLParser.parseAndGetResult(initial, null);
OffsetDateTime actualDate = OffsetDateTime.parse(actual);
Assertions.assertThat(actualDate).isAfter(OffsetDateTime.now().plusDays(1));
}

@Test
void shouldIgnoreAsMethodInvalid() {
String initial = "T(java.time.OffsetDateTime).nowMe().plusDays(2)";
String actual = catsDSLParser.parseAndGetResult(initial);
String actual = catsDSLParser.parseAndGetResult(initial, null);

Assertions.assertThat(actual).isEqualTo(initial);
}

@Test
void shouldParseValueFromJson() {
String json = "{\n" +
" \"filed1\": \"113\",\n" +
" \"expiry\": \"2018-06-25\",\n" +
" \"match\": \"NOT\"\n" +
" }";
String initial = "T(java.time.LocalDate).now().isAfter(T(java.time.LocalDate).parse(expiry.toString()))";
String actual = catsDSLParser.parseAndGetResult(initial, json);

Assertions.assertThat(actual).isEqualTo("true");
}
}

0 comments on commit 02b158b

Please sign in to comment.