de.adorsys.xs2a.adapter.test.TestRequestResponse Maven / Gradle / Ivy
The newest version!
package de.adorsys.xs2a.adapter.test;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import de.adorsys.xs2a.adapter.api.RequestHeaders;
import de.adorsys.xs2a.adapter.api.RequestParams;
import de.adorsys.xs2a.adapter.impl.http.JacksonObjectMapper;
import java.io.File;
import java.io.IOException;
import java.util.Map;
public class TestRequestResponse {
private static final ObjectMapper objectMapper = new JacksonObjectMapper().copyObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
protected static final String REQUEST = "request";
protected static final String RESPONSE = "response";
protected static final String BODY = "body";
protected static final String HEADERS = "headers";
protected static final String PARAMS = "params";
private final JsonNode jsonNode;
public TestRequestResponse(String relativePath) throws IOException {
jsonNode = objectMapper.readTree(new File("src/test/resources/" + relativePath));
}
public RequestHeaders requestHeaders() {
return RequestHeaders.fromMap(objectMapper.convertValue(jsonNode.path(REQUEST).path(HEADERS).require(),
new TypeReference