Polish "Improve exception message when subsection is empty array"

See gh-732
This commit is contained in:
Andy Wilkinson
2021-06-14 21:12:02 +01:00
parent cbe6d775f3
commit 6c0960d304
2 changed files with 4 additions and 4 deletions

View File

@@ -93,7 +93,7 @@ public class FieldPathPayloadSubsectionExtractor
if (value instanceof List) {
List<?> extractedList = (List<?>) value;
if (extractedList.isEmpty()) {
throw new PayloadHandlingException(this.fieldPath + " identifies a section of payload, but the section is empty");
throw new PayloadHandlingException(this.fieldPath + " identifies an empty section of the payload");
}
JsonContentHandler contentHandler = new JsonContentHandler(payload, descriptorsByPath.values());
Set<JsonFieldPath> uncommonPaths = JsonFieldPaths.from(extractedList).getUncommon().stream()

View File

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