Skip to content

Commit d57eae1

Browse files
authored
fix: XML now treated as raw String in HttpSteps (#114)
1 parent 46663cf commit d57eae1

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

tzatziki-http/src/main/java/com/decathlon/tzatziki/steps/HttpSteps.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public void calling_on_will_return_a_status_and(Guard guard, Method method, Stri
138138
@NotNull
139139
private String getTypeString(Type type, String content) {
140140
return ofNullable(type).map(Type::getTypeName).orElseGet(() -> {
141-
if (content == null) {
141+
if (content == null || Mapper.firstNonWhitespaceCharacterIs(content, '<')) {
142142
return "String";
143143
}
144144
return Mapper.isList(content) ? "java.util.List" : "java.util.Map";

tzatziki-http/src/test/resources/com/decathlon/tzatziki/steps/http.feature

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,3 +1190,17 @@ Feature: to interact with an http service and setup mocks
11901190
Then we received a status OK_200
11911191
But when we call "http://backend/LOWERCASE"
11921192
Then we received a status NOT_FOUND_404
1193+
1194+
Scenario: XML can be sent through 'we send...' step
1195+
Given that "http://backend/xml" is mocked as:
1196+
"""
1197+
request:
1198+
method: POST
1199+
body.payload: '<?xml version="1.0" encoding="utf-8"?><ns:user xmlns:ns="http://www.namespace.com">bob</ns:user>'
1200+
response.status: OK_200
1201+
"""
1202+
When we post on "http://backend/xml":
1203+
"""
1204+
<?xml version="1.0" encoding="utf-8"?><ns:user xmlns:ns="http://www.namespace.com">bob</ns:user>
1205+
"""
1206+
Then we received a status OK_200

0 commit comments

Comments
 (0)