aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org/onap/vid/testUtils/StubServerUtil.java
diff options
context:
space:
mode:
authorWojciech Sliwka <wojciech.sliwka@nokia.com>2018-08-20 15:45:03 +0200
committerWojciech Sliwka <wojciech.sliwka@nokia.com>2018-08-24 12:26:03 +0200
commit17e8b54e83547d8dc37c335c5df1b989f8b5ff3c (patch)
tree87201581f26048e7c88a1d9339392f7c11d05b8e /vid-app-common/src/test/java/org/onap/vid/testUtils/StubServerUtil.java
parent5adc0b0ee92d1e39ddaacd27e67a327dd5988f11 (diff)
Replace sdc client
Replace old SDC client to use genericRestClient Change-Id: I9b3b567871ac3f319742fca9457e42b6d4db0a8a Issue-ID: VID-268 Signed-off-by: Wojciech Sliwka <wojciech.sliwka@nokia.com>
Diffstat (limited to 'vid-app-common/src/test/java/org/onap/vid/testUtils/StubServerUtil.java')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/testUtils/StubServerUtil.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/testUtils/StubServerUtil.java b/vid-app-common/src/test/java/org/onap/vid/testUtils/StubServerUtil.java
index e84655f7e..f7ffd9a9c 100644
--- a/vid-app-common/src/test/java/org/onap/vid/testUtils/StubServerUtil.java
+++ b/vid-app-common/src/test/java/org/onap/vid/testUtils/StubServerUtil.java
@@ -23,9 +23,12 @@ package org.onap.vid.testUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xebialabs.restito.semantics.Action;
+import com.xebialabs.restito.semantics.Call;
import com.xebialabs.restito.semantics.Condition;
import com.xebialabs.restito.server.StubServer;
+import java.util.List;
+
import static com.xebialabs.restito.builder.stub.StubHttp.whenHttp;
import static com.xebialabs.restito.semantics.Action.contentType;
import static com.xebialabs.restito.semantics.Action.stringContent;
@@ -48,6 +51,10 @@ public class StubServerUtil {
stubServer.run();
}
+ public void runSecuredServer(){
+ stubServer.secured().run();
+ }
+
public void stopServer() {
stubServer.stop();
}
@@ -57,10 +64,15 @@ public class StubServerUtil {
return String.format("%s://localhost:%s/%s", protocol, stubServer.getPort(), relativePath);
}
- public void prepareGetCall(String path, Object returnObj, Action expectedAction) throws JsonProcessingException {
+ public void prepareGetCall(String path, Action actionToReturn,Object returnObj, Action expectedAction, String contentType) throws JsonProcessingException {
whenHttp(stubServer)
.match(Condition.get(path))
- .then(expectedAction, jsonContent(returnObj), contentType(APPLICATION_JSON));
+ .then(expectedAction, actionToReturn, contentType(contentType));
+ }
+
+
+ public void prepareGetCall(String path, Object returnObj, Action expectedAction) throws JsonProcessingException {
+ prepareGetCall(path, jsonContent(returnObj),returnObj, expectedAction, APPLICATION_JSON);
}
public void prepareDeleteCall(String path, Object returnObj, Action expectedAction) throws JsonProcessingException {
@@ -83,6 +95,10 @@ public class StubServerUtil {
.then(expectedStatus, jsonContent(returnObj), contentType(APPLICATION_JSON));
}
+ public List<Call> getServerCalls() {
+ return stubServer.getCalls();
+ }
+
private Action jsonContent(Object returnObj) throws JsonProcessingException {
return stringContent(objectMapper.writeValueAsString(returnObj));
}