aboutsummaryrefslogtreecommitdiffstats
path: root/vid-automation/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'vid-automation/src/main/java')
-rw-r--r--vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java b/vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java
index 3778e4b16..8492b9baa 100644
--- a/vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java
+++ b/vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java
@@ -77,9 +77,20 @@ public class BaseApiTest {
}
public void login(UserCredentials userCredentials) {
+ final List<ClientHttpRequestInterceptor> interceptors = loginWithChosenRESTClient(userCredentials, restTemplate);
+ restTemplateErrorAgnostic.setInterceptors(interceptors);
+ restTemplateErrorAgnostic.setErrorHandler(new DefaultResponseErrorHandler() {
+ @Override
+ public boolean hasError(ClientHttpResponse response) {
+ return false;
+ }
+ });
+ }
+
+ public List<ClientHttpRequestInterceptor> loginWithChosenRESTClient(UserCredentials userCredentials,RestTemplate givenRestTemplate) {
final List<ClientHttpRequestInterceptor> interceptors = singletonList(new CookieAndJsonHttpHeadersInterceptor(getUri(), userCredentials));
- restTemplate.setInterceptors(interceptors);
- restTemplate.setErrorHandler(new DefaultResponseErrorHandler() {
+ givenRestTemplate.setInterceptors(interceptors);
+ givenRestTemplate.setErrorHandler(new DefaultResponseErrorHandler() {
@Override
public void handleError(ClientHttpResponse response) throws IOException {
try {
@@ -90,14 +101,7 @@ public class BaseApiTest {
}
}
});
-
- restTemplateErrorAgnostic.setInterceptors(interceptors);
- restTemplateErrorAgnostic.setErrorHandler(new DefaultResponseErrorHandler() {
- @Override
- public boolean hasError(ClientHttpResponse response) {
- return false;
- }
- });
+ return interceptors;
}