com.capitalone.dashboard.testutil.TestRestOperations Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
Core package shared by API layer and Microservices
package com.capitalone.dashboard.testutil;
import com.capitalone.dashboard.client.RestOperationsSupplier;
import org.springframework.http.HttpStatus;
import org.springframework.web.client.RestOperations;
import java.util.HashMap;
import java.util.Map;
public class TestRestOperations implements RestOperationsSupplier {
TestRestTemplate extends T> template;
private Map> response;
public TestRestOperations(Map> response) {
this.response = response;
}
public Map> getResponse() {
return response;
}
public void addResponse(String key, TestResponse testResponse) {
if (response == null) {
response = new HashMap<>();
}
this.response.put(key, testResponse);
}
public void addResponse(String key, T body, HttpStatus httpStatus) {
if (response == null) {
response = new HashMap<>();
}
this.response.put(key, new TestResponse<>(body, httpStatus));
if (template != null) {
template.addResponse(key, new TestResponse<>(body, httpStatus));
}
}
public TestRestTemplate extends T> getTemplate() {
return template;
}
public void setTemplate(TestRestTemplate extends T> template) {
this.template = template;
}
@Override
public RestOperations get() {
if (template == null) {
template = new TestRestTemplate<>(response);
}
return template;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy