summaryrefslogtreecommitdiffstats
path: root/models-interactions
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions')
-rw-r--r--models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java4
-rw-r--r--models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java5
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java15
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java32
-rw-r--r--models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java10
5 files changed, 51 insertions, 15 deletions
diff --git a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java
index 5e84871cc..3ed23957a 100644
--- a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java
+++ b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java
@@ -145,7 +145,9 @@ public abstract class AppcOperation extends BidirectionalTopicOperation<Request,
@Override
protected Status detmStatus(String rawResponse, Response response) {
if (response.getStatus() == null) {
- throw new IllegalArgumentException("APP-C response is missing the response status");
+ // no status - this must be a request, not a response - just ignore it
+ logger.info("{}: ignoring request message for {}", getFullName(), params.getRequestId());
+ return Status.STILL_WAITING;
}
ResponseCode code = ResponseCode.toResponseCode(response.getStatus().getCode());
diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java
index 204d95aa1..30450d02a 100644
--- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java
+++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java
@@ -177,10 +177,9 @@ public class AppcOperationTest extends BasicAppcOperation {
public void testDetmStatusStringResponse() {
final ResponseStatus status = response.getStatus();
- // null status
+ // null status (i.e., it's a Request, not a Response)
response.setStatus(null);
- assertThatIllegalArgumentException().isThrownBy(() -> oper.detmStatus("", response))
- .withMessage("APP-C response is missing the response status");
+ assertEquals(Status.STILL_WAITING, oper.detmStatus("", response));
response.setStatus(status);
// invalid code
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
index ec522a405..f598d627a 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
@@ -106,7 +106,7 @@ public abstract class BidirectionalTopicOperation<Q, S> extends OperationPartial
@Override
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
- final Pair<String,Q> pair = makeRequest(attempt);
+ final Pair<String, Q> pair = makeRequest(attempt);
final Q request = pair.getRight();
outcome.setSubRequestId(pair.getLeft());
@@ -118,10 +118,15 @@ public abstract class BidirectionalTopicOperation<Q, S> extends OperationPartial
// register a listener BEFORE publishing
BiConsumer<String, StandardCoderObject> listener = (rawResponse, scoResponse) -> {
- OperationOutcome latestOutcome = processResponse(outcome, rawResponse, scoResponse);
- if (latestOutcome != null) {
- // final response - complete the controller
- controller.completeAsync(() -> latestOutcome, executor);
+ try {
+ OperationOutcome latestOutcome = processResponse(outcome, rawResponse, scoResponse);
+ if (latestOutcome != null) {
+ // final response - complete the controller
+ controller.completeAsync(() -> latestOutcome, executor);
+ }
+ } catch (RuntimeException e) {
+ logger.warn("{}: failed to process response for {}", getFullName(), params.getRequestId());
+ controller.completeExceptionally(e);
}
};
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
index 587564a2e..48669f799 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
@@ -168,10 +168,40 @@ public class BidirectionalTopicOperationTest {
}
/**
+ * Tests startOperationAsync() when processResponse() throws an exception.
+ */
+ @Test
+ public void testStartOperationAsyncProcException() throws Exception {
+ oper = new MyOperation() {
+ @Override
+ protected OperationOutcome processResponse(OperationOutcome outcome, String rawResponse,
+ StandardCoderObject scoResponse) {
+ throw EXPECTED_EXCEPTION;
+ }
+ };
+
+ CompletableFuture<OperationOutcome> future = oper.startOperationAsync(1, outcome);
+ assertFalse(future.isDone());
+
+ assertEquals(SUB_REQID, outcome.getSubRequestId());
+
+ verify(forwarder).register(eq(Arrays.asList(REQ_ID)), listenerCaptor.capture());
+
+ verify(forwarder, never()).unregister(any(), any());
+
+ // provide a response
+ listenerCaptor.getValue().accept(responseText, stdResponse);
+ assertTrue(executor.runAll(MAX_REQUESTS));
+ assertTrue(future.isCompletedExceptionally());
+
+ verify(forwarder).unregister(eq(Arrays.asList(REQ_ID)), eq(listenerCaptor.getValue()));
+ }
+
+ /**
* Tests startOperationAsync() when the publisher throws an exception.
*/
@Test
- public void testStartOperationAsyncException() throws Exception {
+ public void testStartOperationAsyncPubException() throws Exception {
// indicate that nothing was published
when(handler.send(any())).thenReturn(false);
diff --git a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java b/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java
index ac700c866..dcb5d1772 100644
--- a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java
+++ b/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java
@@ -29,10 +29,10 @@ public class ControlLoopTargetTypeTest {
@Test
public void test() {
- assertEquals("VM", ControlLoopTargetType.VM);
- assertEquals("VF", ControlLoopTargetType.VF);
- assertEquals("VFC", ControlLoopTargetType.VFC);
- assertEquals("VNF", ControlLoopTargetType.VNF);
- assertEquals("PNF", ControlLoopTargetType.PNF);
+ assertEquals(ControlLoopTargetType.VM, "VM");
+ assertEquals(ControlLoopTargetType.VF, "VF");
+ assertEquals(ControlLoopTargetType.VFC, "VFC");
+ assertEquals(ControlLoopTargetType.VNF, "VNF");
+ assertEquals(ControlLoopTargetType.PNF, "PNF");
}
}