import java.util.List;
import java.util.concurrent.CompletableFuture;
-import org.onap.policy.controlloop.ControlLoopResponse;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation;
outcome.setResponse(responseWrapper);
if (responseWrapper.getBody() == null || responseWrapper.getBody().getOutput() == null) {
- outcome.setControlLoopResponse(makeControlLoopResponse(null));
return setOutcome(outcome, result);
}
PciResponse pciResponse = responseWrapper.getBody().getOutput();
if (pciResponse.getStatus() == null || pciResponse.getStatus().getValue() == null) {
- outcome.setControlLoopResponse(makeControlLoopResponse(pciResponse.getPayload()));
return setOutcome(outcome, result);
}
outcome.setResult(result);
outcome.setMessage(pciResponse.getStatus().getValue());
- outcome.setControlLoopResponse(makeControlLoopResponse(pciResponse.getPayload()));
return outcome;
}
- /**
- * Converts the SDNR response to a ControlLoopResponse.
- *
- * @param responsePayload payload from the response
- *
- * @return a new ControlLoopResponse
- */
- private ControlLoopResponse makeControlLoopResponse(String responsePayload) {
- VirtualControlLoopEvent event = params.getContext().getEvent();
-
- ControlLoopResponse clRsp = new ControlLoopResponse();
- clRsp.setPayload(responsePayload);
- clRsp.setFrom(params.getActor());
- clRsp.setTarget("DCAE");
- clRsp.setClosedLoopControlName(event.getClosedLoopControlName());
- clRsp.setPolicyName(event.getPolicyName());
- clRsp.setPolicyVersion(event.getPolicyVersion());
- clRsp.setRequestId(event.getRequestId());
- clRsp.setVersion(event.getVersion());
-
- return clRsp;
- }
-
@Override
protected PciMessage makeRequest(int attempt) {
VirtualControlLoopEvent onset = params.getContext().getEvent();
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.onap.policy.controlloop.ControlLoopResponse;
import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext;
outcome = operation.start().get();
assertEquals(PolicyResult.SUCCESS, outcome.getResult());
assertTrue(outcome.getResponse() instanceof PciMessage);
-
- ControlLoopResponse clresp = outcome.getControlLoopResponse();
- assertNotNull(clresp);
-
- assertEquals(DEFAULT_ACTOR, clresp.getFrom());
- assertEquals("DCAE", clresp.getTarget());
- assertEquals(CL_NAME, clresp.getClosedLoopControlName());
- assertEquals(EVENT_POLICY_NAME, clresp.getPolicyName());
- assertEquals(EVENT_POLICY_VERSION, clresp.getPolicyVersion());
- assertEquals(EVENT_VERSION, clresp.getVersion());
- assertEquals(REQ_ID, clresp.getRequestId());
- assertNotNull(clresp.getPayload());
}
@Test
import lombok.NoArgsConstructor;
import lombok.NonNull;
import org.onap.policy.controlloop.ControlLoopOperation;
-import org.onap.policy.controlloop.ControlLoopResponse;
import org.onap.policy.controlloop.policy.PolicyResult;
/**
private String message;
private boolean finalOutcome;
private Object response;
- private ControlLoopResponse controlLoopResponse;
/**
* Copy constructor.
this.message = source.message;
this.finalOutcome = source.finalOutcome;
this.response = source.response;
- this.controlLoopResponse = source.controlLoopResponse;
}
/**
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.controlloop.ControlLoopOperation;
-import org.onap.policy.controlloop.ControlLoopResponse;
import org.onap.policy.controlloop.policy.PolicyResult;
public class OperationOutcomeTest {
private static final String MESSAGE = "my-message";
private static final String RESPONSE = "my-response";
- private ControlLoopResponse response;
private OperationOutcome outcome;
/**
*/
@Before
public void setUp() {
- response = new ControlLoopResponse();
-
outcome = new OperationOutcome();
}
assertEquals(RESULT, outcome2.getResult());
assertEquals(MESSAGE, outcome2.getMessage());
assertSame(RESPONSE, outcome2.getResponse());
- assertSame(response, outcome2.getControlLoopResponse());
}
@Test
outcome.setSubRequestId(SUB_REQ_ID);
outcome.setTarget(TARGET);
outcome.setResponse(RESPONSE);
- outcome.setControlLoopResponse(response);
}
}