List of usage examples for org.springframework.restdocs.operation Operation getResponse
OperationResponse getResponse();
From source file:io.spring.initializr.web.test.ResponseFieldSnippet.java
@Override protected Map<String, Object> createModel(Operation operation) { try {/*from ww w . jav a 2s . com*/ Object object = objectMapper.readValue(operation.getResponse().getContentAsString(), Object.class); Object field = fieldProcessor.extract(JsonFieldPath.compile(path), object); if (field instanceof List && index != null) { field = ((List<?>) field).get(index); } return Collections.singletonMap("value", objectMapper.writeValueAsString(field)); } catch (Exception ex) { throw new IllegalStateException(ex); } }