Skip to content

Commit

Permalink
Merge pull request #567 from treblereel/questionMarkAtTheEndOfStateme…
Browse files Browse the repository at this point in the history
…ntAndHashInString

* If there is a question mark at the end of an expression, it can cau…
  • Loading branch information
amihaiemil committed Apr 23, 2023
2 parents 05b18ab + dfea534 commit a3abd49
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/test/java/com/amihaiemil/eoyaml/RtYamlInputTest.java
Expand Up @@ -1633,6 +1633,38 @@ public void mappingScalarstoSequencesComplexCase() throws IOException {
);
}

@Test
public void questionMarkAtTheEndOfStatementAndHashInString() throws IOException {
final String filename = "questionMarkAtTheEndOfStatementAndHashInString.yml";
final YamlMapping mapping = new RtYamlInput(
Files.newInputStream(
Paths.get("src/test/resources/" + filename)
)
).readYamlMapping();

MatcherAssert.assertThat(mapping.keys().size(), Matchers.equalTo(4));
YamlMapping start = mapping.value("start").asMapping();
MatcherAssert.assertThat(start.keys().size(), Matchers.equalTo(2));
MatcherAssert.assertThat(start.string("stateName"), Matchers.equalTo("CheckInbox"));
MatcherAssert.assertThat(start.yamlMapping("schedule").keys().size(), Matchers.equalTo(1));
MatcherAssert.assertThat(start.yamlMapping("schedule").string("cron"), Matchers.equalTo("0 0/15 * * * ?"));

YamlSequence functions = mapping.value("functions").asSequence();
MatcherAssert.assertThat(functions.size(), Matchers.equalTo(2));

YamlMapping function1 = functions.yamlMapping(0);
MatcherAssert.assertThat(function1.keys().size(), Matchers.equalTo(2));
MatcherAssert.assertThat(function1.string("name"), Matchers.equalTo("checkInboxFunction"));
MatcherAssert.assertThat(function1.string("operation"), Matchers.equalTo("http://myapis.org/inboxapi.json#checkNewMessages"));


YamlMapping function2 = functions.yamlMapping(1);
MatcherAssert.assertThat(function2.keys().size(), Matchers.equalTo(2));
MatcherAssert.assertThat(function2.string("name"), Matchers.equalTo("sendTextFunction"));
MatcherAssert.assertThat(function2.string("operation"), Matchers.equalTo("http://myapis.org/inboxapi.json#sendText"));

}

/**
* Unit test for Issue 559. Original ticket indentation.
* @throws IOException If something goes wrong.
Expand Down
@@ -0,0 +1,11 @@
version: '1.0.0'
specVersion: '0.8'
start:
stateName: CheckInbox
schedule:
cron: 0 0/15 * * * ?
functions:
- name: checkInboxFunction
operation: http://myapis.org/inboxapi.json#checkNewMessages
- name: sendTextFunction
operation: http://myapis.org/inboxapi.json#sendText

0 comments on commit a3abd49

Please sign in to comment.