summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.so
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-actors/actor.so')
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java11
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java11
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/RestManagerResponseTest.java1
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java5
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java2
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java2
6 files changed, 20 insertions, 12 deletions
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
index 86b910176..a4c802c9a 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
@@ -116,6 +116,7 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
*/
protected void resetGetCount() {
getCount = 0;
+ setSubRequestId(null);
}
/**
@@ -214,7 +215,7 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
// still incomplete
// need a request ID with which to query
- if (!extractSubRequestId(response)) {
+ if (getSubRequestId() == null && !extractSubRequestId(response)) {
throw new IllegalArgumentException("missing request ID in response");
}
@@ -227,7 +228,7 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
}
// sleep and then perform a "get" operation
- Function<Void, CompletableFuture<OperationOutcome>> doGet = unused -> issueGet(outcome, response);
+ Function<Void, CompletableFuture<OperationOutcome>> doGet = unused -> issueGet(outcome);
return sleep(getWaitMsGet(), TimeUnit.MILLISECONDS).thenComposeAsync(doGet);
}
@@ -257,18 +258,16 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
* Issues a "get" request to see if the original request is complete yet.
*
* @param outcome outcome to be populated with the response
- * @param response previous response
* @return a future that can be used to cancel the "get" request or await its response
*/
- private CompletableFuture<OperationOutcome> issueGet(OperationOutcome outcome, SoResponse response) {
- String path = getPathGet() + response.getRequestReferences().getRequestId();
+ private CompletableFuture<OperationOutcome> issueGet(OperationOutcome outcome) {
+ String path = getPathGet() + getSubRequestId();
String url = getClient().getBaseUrl() + path;
logger.debug("{}: 'get' count {} for {}", getFullName(), getCount, params.getRequestId());
logMessage(EventType.OUT, CommInfrastructure.REST, url, null);
- // TODO should this use "path" or the full "url"?
return handleResponse(outcome, url, callback -> getClient().get(callback, path, null));
}
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
index e6a3615ad..0232226e0 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
@@ -33,9 +33,11 @@ import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
+import org.onap.policy.common.gson.GsonMessageBodyHandler;
import org.onap.policy.controlloop.actor.test.BasicHttpOperation;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.policy.Target;
+import org.onap.policy.simulators.SoSimulatorJaxRs;
import org.onap.policy.so.SoRequest;
import org.onap.policy.so.SoRequestParameters;
import org.onap.policy.so.SoRequestReferences;
@@ -89,13 +91,16 @@ public abstract class BasicSoOperation extends BasicHttpOperation<SoRequest> {
protected static void initBeforeClass() throws Exception {
org.onap.policy.simulators.Util.buildSoSim();
- BusTopicParams clientParams =
- BusTopicParams.builder().clientName(MY_CLIENT).basePath("").hostname("localhost")
- .managed(true).port(org.onap.policy.simulators.Util.SOSIM_SERVER_PORT).build();
+ BusTopicParams clientParams = BusTopicParams.builder().clientName(MY_CLIENT).basePath("").hostname("localhost")
+ .managed(true).port(org.onap.policy.simulators.Util.SOSIM_SERVER_PORT)
+ .serializationProvider(GsonMessageBodyHandler.class.getName()).build();
HttpClientFactoryInstance.getClientFactory().build(clientParams);
+
+ SoSimulatorJaxRs.setYieldIncomplete(true);
}
protected static void destroyAfterClass() {
+ SoSimulatorJaxRs.setYieldIncomplete(false);
HttpClientFactoryInstance.getClientFactory().destroy();
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/RestManagerResponseTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/RestManagerResponseTest.java
index 7a9541cc4..a544a6234 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/RestManagerResponseTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/RestManagerResponseTest.java
@@ -81,6 +81,7 @@ public class RestManagerResponseTest {
assertThatThrownBy(() -> resp.bufferEntity()).isInstanceOf(UnsupportedOperationException.class);
assertThatThrownBy(() -> resp.getLength()).isInstanceOf(UnsupportedOperationException.class);
assertThatThrownBy(() -> resp.readEntity(generic)).isInstanceOf(UnsupportedOperationException.class);
+ assertThatThrownBy(() -> resp.readEntity(String.class, null)).isInstanceOf(UnsupportedOperationException.class);
assertThatThrownBy(() -> resp.readEntity(generic, null)).isInstanceOf(UnsupportedOperationException.class);
assertThatThrownBy(() -> resp.getStatusInfo()).isInstanceOf(UnsupportedOperationException.class);
assertThatThrownBy(() -> resp.getEntity()).isInstanceOf(UnsupportedOperationException.class);
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
index ce0d2c24f..70093967c 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
@@ -185,6 +185,8 @@ public class SoOperationTest extends BasicSoOperation {
assertNotNull(oper.getSubRequestId());
// no request id in the response
+ oper.generateSubRequestId(2);
+ assertNull(oper.getSubRequestId());
response.getRequestReferences().setRequestId(null);
response.getRequest().getRequestStatus().setRequestState("unknown");
assertThatIllegalArgumentException()
@@ -231,7 +233,7 @@ public class SoOperationTest extends BasicSoOperation {
CompletableFuture<OperationOutcome> future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response);
- assertSame(outcome, future2.get(500, TimeUnit.SECONDS));
+ assertSame(outcome, future2.get(5, TimeUnit.SECONDS));
assertEquals(PolicyResult.SUCCESS, outcome.getResult());
assertEquals(2, oper.getGetCount());
@@ -248,6 +250,7 @@ public class SoOperationTest extends BasicSoOperation {
oper.resetGetCount();
assertEquals(0, oper.getGetCount());
+ assertNull(oper.getSubRequestId());
}
@Test
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java
index 918559a20..def107441 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java
@@ -88,7 +88,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
@Test
public void testSuccess() throws Exception {
SoParams opParams = SoParams.builder().clientName(MY_CLIENT).path("serviceInstantiation/v7/serviceInstances")
- .pathGet("orchestrationRequests/v5/").build();
+ .pathGet("orchestrationRequests/v5/").maxGets(2).build();
config = new SoConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
index 16775fe5d..0ec1a1df0 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
@@ -122,7 +122,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
@Test
public void testSuccess() throws Exception {
SoParams opParams = SoParams.builder().clientName(MY_CLIENT).path("serviceInstances/v7")
- .pathGet("orchestrationRequests/v5/").build();
+ .pathGet("orchestrationRequests/v5/").maxGets(2).build();
config = new SoConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();