Skip to content

Commit b7173ef

Browse files
authored
Ft/better dot notation (#112)
* fix: border case for dot notation wasn't working
1 parent f87d007 commit b7173ef

File tree

2 files changed

+17
-1
lines changed
  • tzatziki-core/src/test/resources/com/decathlon/tzatziki/steps
  • tzatziki-mapper/src/main/java/com/decathlon/tzatziki/utils

2 files changed

+17
-1
lines changed

tzatziki-core/src/test/resources/com/decathlon/tzatziki/steps/objects.feature

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,22 @@ Feature: to interact with objects in the context
915915
]
916916
"""
917917

918+
Scenario: a nested list with dot notation
919+
Given that listWithNestedList is a List:
920+
"""
921+
- element.nestedList:
922+
- element.message: a message
923+
message: another message
924+
"""
925+
Then listWithNestedList is equal to:
926+
"""
927+
- element:
928+
nestedList:
929+
- element:
930+
message: a message
931+
message: another message
932+
"""
933+
918934
Scenario: contains should work even if an expected with a map is matched against a non-map (empty string for eg.)
919935
Given that aList is a List<Map>:
920936
"""

tzatziki-mapper/src/main/java/com/decathlon/tzatziki/utils/Mapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private static String dotNotationToYamlObject(String content) {
7474
String subObjectIndent = " " + rootObjectIndent;
7575
lines.set(idx, line.replaceAll(captureDotNotation, "$1$2:"));
7676
lines.add(idx + 1, line.replaceAll(captureDotNotation, subObjectIndent + "$3"));
77-
for (int subIdx = idx + 2; subIdx < lines.size() && lines.get(subIdx).startsWith(subObjectIndent); subIdx++) {
77+
for (int subIdx = idx + 2; subIdx < lines.size() && (lines.get(subIdx).startsWith(subObjectIndent) || lines.get(subIdx).startsWith(rootObjectIndent + "-")); subIdx++) {
7878
lines.set(subIdx, " " + lines.get(subIdx));
7979
}
8080
}

0 commit comments

Comments
 (0)