Skip to content

Commit 6c0960d

Browse files
committed
Polish "Improve exception message when subsection is empty array"
See gh-732
1 parent cbe6d77 commit 6c0960d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldPathPayloadSubsectionExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public byte[] extractSubsection(byte[] payload, MediaType contentType, List<Fiel
9393
if (value instanceof List) {
9494
List<?> extractedList = (List<?>) value;
9595
if (extractedList.isEmpty()) {
96-
throw new PayloadHandlingException(this.fieldPath + " identifies a section of payload, but the section is empty");
96+
throw new PayloadHandlingException(this.fieldPath + " identifies an empty section of the payload");
9797
}
9898
JsonContentHandler contentHandler = new JsonContentHandler(payload, descriptorsByPath.values());
9999
Set<JsonFieldPath> uncommonPaths = JsonFieldPaths.from(extractedList).getUncommon().stream()

spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/FieldPathPayloadSubsectionExtractorTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ public void extractNonExistentSubsection() throws JsonParseException, JsonMappin
184184
}
185185

186186
@Test
187-
public void extractEmptySubsection() throws JsonParseException, JsonMappingException, IOException {
187+
public void extractEmptyArraySubsection() throws JsonParseException, JsonMappingException, IOException {
188188
assertThatThrownBy(() -> new FieldPathPayloadSubsectionExtractor("a")
189189
.extractSubsection("{\"a\":[]}}".getBytes(), MediaType.APPLICATION_JSON))
190-
.isInstanceOf(PayloadHandlingException.class)
191-
.hasMessage("a identifies a section of payload, but the section is empty");
190+
.isInstanceOf(PayloadHandlingException.class)
191+
.hasMessage("a identifies an empty section of the payload");
192192
}
193193

194194
}

0 commit comments

Comments
 (0)