package org.onap.policy.controlloop.actor.sdnr;
-import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import java.util.function.BiConsumer;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
+import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
import org.onap.policy.controlloop.actorserviceprovider.Util;
-import org.onap.policy.controlloop.actorserviceprovider.impl.OperationMaker;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
-import org.onap.policy.controlloop.policy.PolicyResult;
+import org.onap.policy.sdnr.PciBody;
+import org.onap.policy.sdnr.PciMessage;
import org.onap.policy.sdnr.PciResponse;
-import org.onap.policy.sdnr.PciResponseWrapper;
import org.onap.policy.sdnr.Status;
import org.onap.policy.sdnr.util.StatusCodeEnum;
-import org.powermock.reflect.Whitebox;
+import org.onap.policy.simulators.SdnrTopicServer;
+import org.onap.policy.simulators.TopicServer;
-public abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperation {
+public abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperation<PciMessage> {
- protected PciResponseWrapper response;
+ protected PciMessage response;
/**
* Constructs the object using a default actor and operation name.
public void setUp() throws Exception {
super.setUpBasic();
- response = new PciResponseWrapper();
+ response = new PciMessage();
+
+ PciBody body = new PciBody();
+ response.setBody(body);
+
+ PciResponse output = new PciResponse();
+ body.setOutput(output);
- PciResponse body = new PciResponse();
Status status = new Status();
+ output.setStatus(status);
status.setCode(100);
status.setValue(StatusCodeEnum.SUCCESS.toString());
- body.setStatus(status);
- response.setBody(body);
+ }
+
+ public void tearDown() {
+ super.tearDownBasic();
+ }
+
+ @Override
+ protected TopicServer<PciMessage> makeServer(TopicSink sink, TopicSource source) {
+ return new SdnrTopicServer(sink, source);
}
/**
assertTrue(future2.isDone());
outcome = future2.get();
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
- }
-
- /**
- * Verifies that an exception is thrown if a field is missing from the enrichment
- * data.
- *
- * @param fieldName name of the field to be removed from the enrichment data
- * @param expectedText text expected in the exception message
- */
- protected void verifyMissing(String fieldName, String expectedText,
- OperationMaker<BidirectionalTopicConfig, SdnrOperation> maker) {
-
- makeContext();
- enrichment.remove(fieldName);
-
- SdnrOperation oper = maker.apply(params, config);
-
- assertThatIllegalArgumentException().isThrownBy(() -> Whitebox.invokeMethod(oper, "makeRequest", 1))
- .withMessageContaining("missing").withMessageContaining(expectedText);
+ assertEquals(OperationResult.SUCCESS, outcome.getResult());
}
/**