Skip to content

Commit

Permalink
JBEHAVE-1531 Make separators properties accessible from outer transfo…
Browse files Browse the repository at this point in the history
…rmers (#82)
  • Loading branch information
uarlouski authored Nov 6, 2024
1 parent d2e70fc commit d8a9fd2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ public ExamplesTable createExamplesTable(String input) {
String loadedTable = resourceLoader.loadResourceAsText(tableAsString.trim());
tablePropertiesQueue = tableParsers.parseProperties(loadedTable);
Deque<TableProperties> target = tablePropertiesQueue.getProperties();
TableProperties headProperties = target.peekFirst();
for (TableProperties outerProperties : properties) {
outerProperties.overrideSeparatorsFrom(headProperties);
target.addLast(outerProperties);
}

boolean hasTransformers = target.getFirst().getTransformer() != null;
if (hasTransformers) {
Expand All @@ -115,7 +120,6 @@ public ExamplesTable createExamplesTable(String input) {
target = tablePropertiesQueue.getProperties();
}
}
properties.descendingIterator().forEachRemaining(target::addFirst);

tablePropertiesQueue = new TablePropertiesQueue(tablePropertiesQueue.getTable(), target);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ void shouldLoadAndProperlyApplyTransformersForExamplesTableFromResourceInput() {

// Then
assertThat(examplesTable.asString(), equalTo(
innerTransformers
+ lineFromFirstOuterTransformer
lineFromFirstOuterTransformer
+ lineFromSecondOuterTransformer
+ lineFromFirstInnerTransformer
+ lineFromSecondInnerTransformer));
Expand Down Expand Up @@ -179,7 +178,7 @@ void shouldLoadTableFromPathAndPreserveSeparators() {
ExamplesTableFactory factory = new ExamplesTableFactory(new LoadFromClasspath(), new TableTransformers());

// When
ExamplesTable table = factory.createExamplesTable("data.table");
ExamplesTable table = factory.createExamplesTable("{transformer=FORMATTING}\ndata.table");

// Then
assertThat(table.getHeaders(), equalTo(asList("symbol", "threshold", "price", "status")));
Expand Down

0 comments on commit d8a9fd2

Please sign in to comment.