summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2018-12-08 11:27:17 +0000
committerliamfallon <liam.fallon@est.tech>2018-12-08 11:27:55 +0000
commit5b97cd4470b9668ed31bf7663808c32087ba696c (patch)
treed60fb5a8d41f4074ca221fc3c8654e5db9985aaa /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src
parente6753352980648bac92aff9a7295639349ea1295 (diff)
Support HTTP headers in REST Client
Fixed REST client plugin to supprot HTTP headers and add unit test to plugin. Change-Id: I6a71ab7f83ed2126b8600bb5e586f971dbdacdc0 Issue-ID: POLICY-1222 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src')
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java32
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java42
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java105
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java338
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java337
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java149
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/SupportApexEventReceiver.java70
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/events/EventsIn.json400
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/events/EventsInMulti.json16
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/policymodels/RequestorModel.json608
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderBadList.json72
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderNotKvPairs.json71
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderNulls.json71
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderOK.json87
14 files changed, 2353 insertions, 45 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java
index 13edea8a6..04397d688 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java
@@ -72,30 +72,29 @@ public class ApexRestClientConsumer implements ApexEventConsumer, Runnable {
@Override
public void init(final String consumerName, final EventHandlerParameters consumerParameters,
- final ApexEventReceiver incomingEventReceiver) throws ApexEventException {
+ final ApexEventReceiver incomingEventReceiver) throws ApexEventException {
this.eventReceiver = incomingEventReceiver;
this.name = consumerName;
// Check and get the REST Properties
if (!(consumerParameters.getCarrierTechnologyParameters() instanceof RestClientCarrierTechnologyParameters)) {
final String errorMessage = "specified consumer properties are not applicable to REST client consumer ("
- + this.name + ")";
+ + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
restConsumerProperties = (RestClientCarrierTechnologyParameters) consumerParameters
- .getCarrierTechnologyParameters();
+ .getCarrierTechnologyParameters();
// Check if the HTTP method has been set
if (restConsumerProperties.getHttpMethod() == null) {
- restConsumerProperties.setHttpMethod(RestClientCarrierTechnologyParameters.CONSUMER_HTTP_METHOD);
+ restConsumerProperties.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.GET);
}
- if (!restConsumerProperties.getHttpMethod()
- .equalsIgnoreCase(RestClientCarrierTechnologyParameters.CONSUMER_HTTP_METHOD)) {
+ if (!RestClientCarrierTechnologyParameters.HttpMethod.GET.equals(restConsumerProperties.getHttpMethod())) {
final String errorMessage = "specified HTTP method of \"" + restConsumerProperties.getHttpMethod()
- + "\" is invalid, only HTTP method \"GET\" "
- + "is supported for event reception on REST client consumer (" + this.name + ")";
+ + "\" is invalid, only HTTP method \"GET\" "
+ + "is supported for event reception on REST client consumer (" + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
@@ -203,13 +202,13 @@ public class ApexRestClientConsumer implements ApexEventConsumer, Runnable {
public void run() {
try {
final Response response = client.target(restConsumerProperties.getUrl()).request("application/json")
- .get();
+ .get();
// Check that the event request worked
if (response.getStatus() != Response.Status.OK.getStatusCode()) {
final String errorMessage = "reception of event from URL \"" + restConsumerProperties.getUrl()
- + "\" failed with status code " + response.getStatus() + " and message \""
- + response.readEntity(String.class) + "\"";
+ + "\" failed with status code " + response.getStatus() + " and message \""
+ + response.readEntity(String.class) + "\"";
throw new ApexEventRuntimeException(errorMessage);
}
@@ -219,7 +218,7 @@ public class ApexRestClientConsumer implements ApexEventConsumer, Runnable {
// Check there is content
if (eventJsonString == null || eventJsonString.trim().length() == 0) {
final String errorMessage = "received an empty event from URL \"" + restConsumerProperties.getUrl()
- + "\"";
+ + "\"";
throw new ApexEventRuntimeException(errorMessage);
}
@@ -230,4 +229,13 @@ public class ApexRestClientConsumer implements ApexEventConsumer, Runnable {
}
}
}
+
+ /**
+ * Hook for unit test mocking of HTTP client.
+ *
+ * @param client the mocked client
+ */
+ protected void setClient(final Client client) {
+ this.client = client;
+ }
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java
index 5556d0310..a7e0ddd52 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java
@@ -67,29 +67,29 @@ public class ApexRestClientProducer implements ApexEventProducer {
*/
@Override
public void init(final String producerName, final EventHandlerParameters producerParameters)
- throws ApexEventException {
+ throws ApexEventException {
this.name = producerName;
// Check and get the REST Properties
if (!(producerParameters.getCarrierTechnologyParameters() instanceof RestClientCarrierTechnologyParameters)) {
- final String errorMessage = "specified consumer properties are not applicable to REST client producer ("
- + this.name + ")";
+ final String errorMessage = "specified producer properties are not applicable to REST client producer ("
+ + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
restProducerProperties = (RestClientCarrierTechnologyParameters) producerParameters
- .getCarrierTechnologyParameters();
+ .getCarrierTechnologyParameters();
// Check if the HTTP method has been set
if (restProducerProperties.getHttpMethod() == null) {
- restProducerProperties.setHttpMethod(RestClientCarrierTechnologyParameters.DEFAULT_PRODUCER_HTTP_METHOD);
+ restProducerProperties.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.POST);
}
- if (!"POST".equalsIgnoreCase(restProducerProperties.getHttpMethod())
- && !"PUT".equalsIgnoreCase(restProducerProperties.getHttpMethod())) {
+ if (!RestClientCarrierTechnologyParameters.HttpMethod.POST.equals(restProducerProperties.getHttpMethod())
+ && !RestClientCarrierTechnologyParameters.HttpMethod.PUT.equals(restProducerProperties.getHttpMethod())) {
final String errorMessage = "specified HTTP method of \"" + restProducerProperties.getHttpMethod()
- + "\" is invalid, only HTTP methods \"POST\" and \"PUT\" are supproted "
- + "for event sending on REST client producer (" + this.name + ")";
+ + "\" is invalid, only HTTP methods \"POST\" and \"PUT\" are supproted "
+ + "for event sending on REST client producer (" + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
@@ -140,7 +140,7 @@ public class ApexRestClientProducer implements ApexEventProducer {
public void sendEvent(final long executionId, final String eventName, final Object event) {
// Check if this is a synchronized event, if so we have received a reply
final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) peerReferenceMap
- .get(EventHandlerPeeredMode.SYNCHRONOUS);
+ .get(EventHandlerPeeredMode.SYNCHRONOUS);
if (synchronousEventCache != null) {
synchronousEventCache.removeCachedEventToApexIfExists(executionId);
}
@@ -151,16 +151,15 @@ public class ApexRestClientProducer implements ApexEventProducer {
// Check that the request worked
if (response.getStatus() != Response.Status.OK.getStatusCode()) {
final String errorMessage = "send of event to URL \"" + restProducerProperties.getUrl() + "\" using HTTP \""
- + restProducerProperties.getHttpMethod() + "\" failed with status code "
- + response.getStatus() + " and message \"" + response.readEntity(String.class)
- + "\", event:\n" + event;
+ + restProducerProperties.getHttpMethod() + "\" failed with status code " + response.getStatus()
+ + " and message \"" + response.readEntity(String.class) + "\", event:\n" + event;
LOGGER.warn(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("event sent from engine using {} to URL {} with HTTP {} : {} and response {} ", this.name,
- restProducerProperties.getUrl(), restProducerProperties.getHttpMethod(), event, response);
+ restProducerProperties.getUrl(), restProducerProperties.getHttpMethod(), event, response);
}
}
@@ -179,14 +178,23 @@ public class ApexRestClientProducer implements ApexEventProducer {
* Send the event as a JSON string as a REST request.
*
* @param event the event to send
- * @return the response tot he JSON request
+ * @return the response to the JSON request
*/
- public Response sendEventAsRestRequest(final String event) {
+ private Response sendEventAsRestRequest(final String event) {
// We have already checked that it is a PUT or POST request
- if ("POST".equalsIgnoreCase(restProducerProperties.getHttpMethod())) {
+ if (RestClientCarrierTechnologyParameters.HttpMethod.POST.equals(restProducerProperties.getHttpMethod())) {
return client.target(restProducerProperties.getUrl()).request("application/json").post(Entity.json(event));
} else {
return client.target(restProducerProperties.getUrl()).request("application/json").put(Entity.json(event));
}
}
+
+ /**
+ * Hook for unit test mocking of HTTP client.
+ *
+ * @param client the mocked client
+ */
+ protected void setClient(final Client client) {
+ this.client = client;
+ }
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java
index 86c8bb4cf..0329d4440 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java
@@ -20,9 +20,15 @@
package org.onap.policy.apex.plugins.event.carrier.restclient;
+import java.util.Arrays;
+
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.common.utils.validation.ParameterValidationUtils;
/**
* Apex parameters for REST as an event carrier technology with Apex as a REST client.
@@ -38,6 +44,10 @@ import org.onap.policy.common.parameters.ValidationStatus;
* @author Joss Armstrong (joss.armstrong@ericsson.com)
*/
public class RestClientCarrierTechnologyParameters extends CarrierTechnologyParameters {
+ /** The supported HTTP methods. */
+ public enum HttpMethod {
+ GET, PUT, POST, DELETE
+ }
/** The label of this carrier technology. */
public static final String RESTCLIENT_CARRIER_TECHNOLOGY_LABEL = "RESTCLIENT";
@@ -48,14 +58,12 @@ public class RestClientCarrierTechnologyParameters extends CarrierTechnologyPara
/** The consumer plugin class for the REST carrier technology. */
public static final String RESTCLIENT_EVENT_CONSUMER_PLUGIN_CLASS = ApexRestClientConsumer.class.getCanonicalName();
- /** The default HTTP method for output of events. */
- public static final String DEFAULT_PRODUCER_HTTP_METHOD = "POST";
-
- /** The HTTP method for input of events. */
- public static final String CONSUMER_HTTP_METHOD = "GET";
+ // Commonly occurring strings
+ private static final String HTTP_HEADERS = "httpHeaders";
private String url = null;
- private String httpMethod = null;
+ private HttpMethod httpMethod = null;
+ private String[][] httpHeaders = null;
/**
* Constructor to create a REST carrier technology parameters instance and register the instance with the parameter
@@ -94,7 +102,7 @@ public class RestClientCarrierTechnologyParameters extends CarrierTechnologyPara
*
* @return the HTTP method
*/
- public String getHttpMethod() {
+ public HttpMethod getHttpMethod() {
return httpMethod;
}
@@ -103,23 +111,59 @@ public class RestClientCarrierTechnologyParameters extends CarrierTechnologyPara
*
* @param httpMethod the HTTP method
*/
- public void setHttpMethod(final String httpMethod) {
+ public void setHttpMethod(final HttpMethod httpMethod) {
this.httpMethod = httpMethod;
}
- /*
- * (non-Javadoc)
+ /**
+ * Check if http headers have been set for the REST request.
*
- * @see java.lang.Object#toString()
+ * @return true if headers have beenset
*/
- @Override
- public String toString() {
- return "RESTClientCarrierTechnologyParameters [url=" + url + ", httpMethod=" + httpMethod + "]";
+ public boolean checkHttpHeadersSet() {
+ return httpHeaders != null && httpHeaders.length > 0;
}
- /*
+ /**
+ * Gets the http headers for the REST request.
*
- * @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
+ * @return the headers
+ */
+ public String[][] getHttpHeaders() {
+ return httpHeaders;
+ }
+
+ /**
+ * Gets the http headers for the REST request as a multivalued map.
+ *
+ * @return the headers
+ */
+ public MultivaluedMap<String, Object> getHttpHeadersAsMultivaluedMap() {
+ if (httpHeaders == null) {
+ return null;
+ }
+
+ // Load the HTTP headers into the map
+ MultivaluedMap<String, Object> httpHeaderMap = new MultivaluedHashMap<>();
+
+ for (String[] httpHeader : httpHeaders) {
+ httpHeaderMap.putSingle(httpHeader[0], httpHeader[1]);
+ }
+
+ return httpHeaderMap;
+ }
+
+ /**
+ * Sets the header for the REST request.
+ *
+ * @param httpHeaders the incoming HTTP headers
+ */
+ public void setHttpHeaders(final String[][] httpHeaders) {
+ this.httpHeaders = httpHeaders;
+ }
+
+ /**
+ * {@inheritDoc}
*/
@Override
public GroupValidationResult validate() {
@@ -130,6 +174,35 @@ public class RestClientCarrierTechnologyParameters extends CarrierTechnologyPara
result.setResult("url", ValidationStatus.INVALID, "no URL has been set for event sending on REST client");
}
+ if (httpHeaders == null) {
+ return result;
+ }
+
+ for (String[] httpHeader : httpHeaders) {
+ if (httpHeader == null) {
+ result.setResult(HTTP_HEADERS, ValidationStatus.INVALID, "HTTP header array entry is null");
+ } else if (httpHeader.length != 2) {
+ result.setResult(HTTP_HEADERS, ValidationStatus.INVALID,
+ "HTTP header array entries must have one key and one value: "
+ + Arrays.deepToString(httpHeader));
+ } else if (!ParameterValidationUtils.validateStringParameter(httpHeader[0])) {
+ result.setResult(HTTP_HEADERS, ValidationStatus.INVALID,
+ "HTTP header key is null or blank: " + Arrays.deepToString(httpHeader));
+ } else if (!ParameterValidationUtils.validateStringParameter(httpHeader[1])) {
+ result.setResult(HTTP_HEADERS, ValidationStatus.INVALID,
+ "HTTP header value is null or blank: " + Arrays.deepToString(httpHeader));
+ }
+ }
+
return result;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return "RestClientCarrierTechnologyParameters [url=" + url + ", httpMethod=" + httpMethod + ", httpHeaders="
+ + Arrays.deepToString(httpHeaders) + "]";
+ }
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java
new file mode 100644
index 000000000..1498678e9
--- /dev/null
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java
@@ -0,0 +1,338 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.event.carrier.restclient;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Invocation.Builder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
+import org.onap.policy.apex.service.engine.event.ApexEventException;
+import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
+import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
+
+/**
+ * This class tests the ApexRestClientConusmer class.
+ *
+ */
+public class ApexRestClientConusmerTest {
+ private final PrintStream stdout = System.out;
+
+ @Mock
+ private Client httpClientMock;
+
+ @Mock
+ private WebTarget targetMock;
+
+ @Mock
+ private Builder builderMock;
+
+ @Mock
+ private Response responseMock;
+
+ @Test
+ public void testApexRestClientConusmerErrors() {
+ MockitoAnnotations.initMocks(this);
+
+ ApexRestClientConsumer arcc = new ApexRestClientConsumer();
+ assertNotNull(arcc);
+
+ EventHandlerParameters consumerParameters = new EventHandlerParameters();
+ SupportApexEventReceiver incomingEventReceiver = new SupportApexEventReceiver();
+ try {
+ arcc.init("RestClientConsumer", consumerParameters, incomingEventReceiver);
+ fail("test should throw an exception here");
+ } catch (ApexEventException e) {
+ assertEquals(
+ "specified consumer properties are not applicable to REST client consumer (RestClientConsumer)",
+ e.getMessage());
+ }
+
+ RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters();
+ consumerParameters.setCarrierTechnologyParameters(rcctp);
+ rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.DELETE);
+ try {
+ arcc.init("RestClientConsumer", consumerParameters, incomingEventReceiver);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.GET, rcctp.getHttpMethod());
+ fail("test should throw an exception here");
+ } catch (ApexEventException e) {
+ assertEquals("specified HTTP method of \"DELETE\" is invalid, only HTTP method \"GET\" is supported "
+ + "for event reception on REST client consumer (RestClientConsumer)", e.getMessage());
+ }
+
+ rcctp.setHttpMethod(null);
+ try {
+ arcc.init("RestClientConsumer", consumerParameters, incomingEventReceiver);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.GET, rcctp.getHttpMethod());
+
+ assertEquals("RestClientConsumer", arcc.getName());
+
+ arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
+ assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ } catch (ApexEventException e) {
+ fail("test should not throw an exception");
+ }
+
+ rcctp.setUrl("http://some.place.that.does.not/exist");
+ Mockito.doReturn(Response.Status.BAD_REQUEST.getStatusCode()).when(responseMock).getStatus();
+ Mockito.doReturn(responseMock).when(builderMock).get();
+ Mockito.doReturn(builderMock).when(targetMock).request("application/json");
+ Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
+ arcc.setClient(httpClientMock);
+
+ try {
+ // We have not set the URL, this test should not receive any events
+ arcc.start();
+ ThreadUtilities.sleep(200);
+ arcc.stop();
+
+ assertEquals(0, incomingEventReceiver.getEventCount());
+ } catch (Exception e) {
+ fail("test should not throw an exception");
+ }
+
+ Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
+ try {
+ // We have not set the URL, this test should not receive any events
+ arcc.start();
+ ThreadUtilities.sleep(200);
+ arcc.stop();
+
+ assertEquals(0, incomingEventReceiver.getEventCount());
+ } catch (Exception e) {
+ fail("test should not throw an exception");
+ }
+ }
+
+ @Test
+ public void testApexRestClientConusmerHttpError() {
+ MockitoAnnotations.initMocks(this);
+
+ ApexRestClientConsumer arcc = new ApexRestClientConsumer();
+ assertNotNull(arcc);
+
+ EventHandlerParameters consumerParameters = new EventHandlerParameters();
+ RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters();
+ consumerParameters.setCarrierTechnologyParameters(rcctp);
+ rcctp.setUrl("http://some.place.that.does.not/exist");
+ SupportApexEventReceiver incomingEventReceiver = new SupportApexEventReceiver();
+
+ try {
+ arcc.init("RestClientConsumer", consumerParameters, incomingEventReceiver);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.GET, rcctp.getHttpMethod());
+
+ assertEquals("RestClientConsumer", arcc.getName());
+
+ arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
+ assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ } catch (ApexEventException e) {
+ fail("test should not throw an exception");
+ }
+
+ Mockito.doReturn(Response.Status.BAD_REQUEST.getStatusCode()).when(responseMock).getStatus();
+ Mockito.doReturn(responseMock).when(builderMock).get();
+ Mockito.doReturn(builderMock).when(targetMock).request("application/json");
+ Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
+ arcc.setClient(httpClientMock);
+
+ ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+ System.setOut(new PrintStream(outContent));
+
+ try {
+ // We have not set the URL, this test should not receive any events
+ arcc.start();
+ ThreadUtilities.sleep(200);
+ arcc.stop();
+
+ assertEquals(0, incomingEventReceiver.getEventCount());
+ } catch (Exception e) {
+ fail("test should not throw an exception");
+ }
+
+ final String outString = outContent.toString();
+ System.setOut(stdout);
+
+ assertTrue(outString.contains(
+ "reception of event from URL \"http://some.place.that.does.not/exist\" failed with status code 400"));
+ }
+
+ @Test
+ public void testApexRestClientConusmerJsonError() {
+ MockitoAnnotations.initMocks(this);
+
+ ApexRestClientConsumer arcc = new ApexRestClientConsumer();
+ assertNotNull(arcc);
+
+ EventHandlerParameters consumerParameters = new EventHandlerParameters();
+ SupportApexEventReceiver incomingEventReceiver = new SupportApexEventReceiver();
+ RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters();
+ consumerParameters.setCarrierTechnologyParameters(rcctp);
+
+ try {
+ arcc.init("RestClientConsumer", consumerParameters, incomingEventReceiver);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.GET, rcctp.getHttpMethod());
+
+ assertEquals("RestClientConsumer", arcc.getName());
+
+ arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
+ assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ } catch (ApexEventException e) {
+ fail("test should not throw an exception");
+ }
+
+ rcctp.setUrl("http://some.place.that.does.not/exist");
+ Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
+ Mockito.doReturn(responseMock).when(builderMock).get();
+ Mockito.doReturn(builderMock).when(targetMock).request("application/json");
+ Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
+ arcc.setClient(httpClientMock);
+
+ ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+ System.setOut(new PrintStream(outContent));
+
+ try {
+ // We have not set the URL, this test should not receive any events
+ arcc.start();
+ ThreadUtilities.sleep(200);
+ arcc.stop();
+
+ assertEquals(0, incomingEventReceiver.getEventCount());
+ } catch (Exception e) {
+ fail("test should not throw an exception");
+ }
+
+ final String outString = outContent.toString();
+ System.setOut(stdout);
+
+ assertTrue(outString.contains(
+ "received an empty event from URL \"http://some.place.that.does.not/exist\""));
+ }
+
+ @Test
+ public void testApexRestClientConusmerJsonEmpty() {
+ MockitoAnnotations.initMocks(this);
+
+ ApexRestClientConsumer arcc = new ApexRestClientConsumer();
+ assertNotNull(arcc);
+
+ EventHandlerParameters consumerParameters = new EventHandlerParameters();
+ SupportApexEventReceiver incomingEventReceiver = new SupportApexEventReceiver();
+ RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters();
+ consumerParameters.setCarrierTechnologyParameters(rcctp);
+
+ try {
+ arcc.init("RestClientConsumer", consumerParameters, incomingEventReceiver);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.GET, rcctp.getHttpMethod());
+
+ assertEquals("RestClientConsumer", arcc.getName());
+
+ arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
+ assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ } catch (ApexEventException e) {
+ fail("test should not throw an exception");
+ }
+
+ rcctp.setUrl("http://some.place.that.does.not/exist");
+ Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
+ Mockito.doReturn("").when(responseMock).readEntity(String.class);
+ Mockito.doReturn(responseMock).when(builderMock).get();
+ Mockito.doReturn(builderMock).when(targetMock).request("application/json");
+ Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
+ arcc.setClient(httpClientMock);
+
+ ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+ System.setOut(new PrintStream(outContent));
+
+ try {
+ // We have not set the URL, this test should not receive any events
+ arcc.start();
+ ThreadUtilities.sleep(200);
+ arcc.stop();
+
+ assertEquals(0, incomingEventReceiver.getEventCount());
+ } catch (Exception e) {
+ fail("test should not throw an exception");
+ }
+
+ final String outString = outContent.toString();
+ System.setOut(stdout);
+
+ assertTrue(outString.contains(
+ "received an empty event from URL \"http://some.place.that.does.not/exist\""));
+ }
+
+ @Test
+ public void testApexRestClientConusmerJsonOk() {
+ MockitoAnnotations.initMocks(this);
+
+ ApexRestClientConsumer arcc = new ApexRestClientConsumer();
+ assertNotNull(arcc);
+
+ EventHandlerParameters consumerParameters = new EventHandlerParameters();
+ SupportApexEventReceiver incomingEventReceiver = new SupportApexEventReceiver();
+ RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters();
+ consumerParameters.setCarrierTechnologyParameters(rcctp);
+
+ try {
+ arcc.init("RestClientConsumer", consumerParameters, incomingEventReceiver);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.GET, rcctp.getHttpMethod());
+
+ assertEquals("RestClientConsumer", arcc.getName());
+
+ arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
+ assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ } catch (ApexEventException e) {
+ fail("test should not throw an exception");
+ }
+
+ rcctp.setUrl("http://some.place.that.does.not/exist");
+ Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
+ Mockito.doReturn("This is an event").when(responseMock).readEntity(String.class);
+ Mockito.doReturn(responseMock).when(builderMock).get();
+ Mockito.doReturn(builderMock).when(targetMock).request("application/json");
+ Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
+ arcc.setClient(httpClientMock);
+
+ try {
+ // We have not set the URL, this test should not receive any events
+ arcc.start();
+ ThreadUtilities.sleep(200);
+ arcc.stop();
+
+ assertEquals("This is an event", incomingEventReceiver.getLastEvent());
+ } catch (Exception e) {
+ fail("test should not throw an exception");
+ }
+ }
+}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java
new file mode 100644
index 000000000..3ef172427
--- /dev/null
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java
@@ -0,0 +1,337 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.event.carrier.restclient;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import ch.qos.logback.classic.Level;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Invocation.Builder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.policy.apex.service.engine.event.ApexEventConsumer;
+import org.onap.policy.apex.service.engine.event.ApexEventException;
+import org.onap.policy.apex.service.engine.event.SynchronousEventCache;
+import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.ApexFileEventConsumer;
+import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
+import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test the ApexRestClientProducer class.
+ *
+ */
+public class ApexRestClientProducerTest {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ApexRestClientProducer.class);
+
+ @Mock
+ private Client httpClientMock;
+
+ @Mock
+ private WebTarget targetMock;
+
+ @Mock
+ private Builder builderMock;
+
+ @Mock
+ private Response responseMock;
+
+ @Test
+ public void testApexRestClientProducerErrors() {
+ ApexRestClientProducer arcp = new ApexRestClientProducer();
+ assertNotNull(arcp);
+
+ EventHandlerParameters producerParameters = new EventHandlerParameters();
+ try {
+ arcp.init("RestClientProducer", producerParameters);
+ fail("test should throw an exception here");
+ } catch (ApexEventException e) {
+ assertEquals(
+ "specified producer properties are not applicable to REST client producer (RestClientProducer)",
+ e.getMessage());
+ }
+
+ RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters();
+ producerParameters.setCarrierTechnologyParameters(rcctp);
+ rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.DELETE);
+ try {
+ arcp.init("RestClientConsumer", producerParameters);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.GET, rcctp.getHttpMethod());
+ fail("test should throw an exception here");
+ } catch (ApexEventException e) {
+ assertEquals("specified HTTP method of \"DELETE\" is invalid, only HTTP methods \"POST\" and \"PUT\" "
+ + "are supproted for event sending on REST client producer (RestClientConsumer)", e.getMessage());
+ }
+
+ rcctp.setHttpMethod(null);
+ try {
+ arcp.init("RestClientConsumer", producerParameters);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.POST, rcctp.getHttpMethod());
+
+ assertEquals("RestClientConsumer", arcp.getName());
+
+ arcp.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
+ assertEquals(null, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+
+ arcp.stop();
+ } catch (ApexEventException e) {
+ fail("test should not throw an exception");
+ }
+
+ rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.POST);
+ try {
+ arcp.init("RestClientConsumer", producerParameters);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.POST, rcctp.getHttpMethod());
+
+ assertEquals("RestClientConsumer", arcp.getName());
+
+ arcp.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
+ assertEquals(null, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+
+ arcp.stop();
+ } catch (ApexEventException e) {
+ fail("test should not throw an exception");
+ }
+
+ rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.PUT);
+ try {
+ arcp.init("RestClientConsumer", producerParameters);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.PUT, rcctp.getHttpMethod());
+
+ assertEquals("RestClientConsumer", arcp.getName());
+
+ arcp.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null);
+ assertEquals(null, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+
+ arcp.stop();
+ } catch (ApexEventException e) {
+ fail("test should not throw an exception");
+ }
+ }
+
+ @Test
+ public void testApexRestClientProducerPutEvent() {
+ MockitoAnnotations.initMocks(this);
+
+ ApexRestClientProducer arcp = new ApexRestClientProducer();
+ assertNotNull(arcp);
+
+ EventHandlerParameters producerParameters = new EventHandlerParameters();
+ RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters();
+ producerParameters.setCarrierTechnologyParameters(rcctp);
+
+ rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.PUT);
+ try {
+ arcp.init("RestClientConsumer", producerParameters);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.PUT, rcctp.getHttpMethod());
+
+ assertEquals("RestClientConsumer", arcp.getName());
+ } catch (ApexEventException e) {
+ fail("test should not throw an exception");
+ }
+
+ rcctp.setUrl("http://some.place.that.does.not/exist");
+ Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
+ Mockito.doReturn(responseMock).when(builderMock).put(Mockito.any());
+ Mockito.doReturn(builderMock).when(targetMock).request("application/json");
+ Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
+ arcp.setClient(httpClientMock);
+
+ try {
+ arcp.sendEvent(123, "EventName", "This is an Event");
+ arcp.stop();
+ } catch (Exception e) {
+ fail("test should not throw an exception");
+ }
+ }
+
+ @Test
+ public void testApexRestClientProducerPostEvent() {
+ MockitoAnnotations.initMocks(this);
+
+ ApexRestClientProducer arcp = new ApexRestClientProducer();
+ assertNotNull(arcp);
+
+ EventHandlerParameters producerParameters = new EventHandlerParameters();
+ RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters();
+ producerParameters.setCarrierTechnologyParameters(rcctp);
+
+ rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.POST);
+ try {
+ arcp.init("RestClientConsumer", producerParameters);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.POST, rcctp.getHttpMethod());
+
+ assertEquals("RestClientConsumer", arcp.getName());
+ } catch (ApexEventException e) {
+ fail("test should not throw an exception");
+ }
+
+ rcctp.setUrl("http://some.place.that.does.not/exist");
+ Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
+ Mockito.doReturn(responseMock).when(builderMock).post(Mockito.any());
+ Mockito.doReturn(builderMock).when(targetMock).request("application/json");
+ Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
+ arcp.setClient(httpClientMock);
+
+ try {
+ arcp.sendEvent(123, "EventName", "This is an Event");
+ arcp.stop();
+ } catch (Exception e) {
+ fail("test should not throw an exception");
+ }
+ }
+
+ @Test
+ public void testApexRestClientProducerPostEventCache() {
+ MockitoAnnotations.initMocks(this);
+
+ ApexRestClientProducer arcp = new ApexRestClientProducer();
+ assertNotNull(arcp);
+
+ EventHandlerParameters producerParameters = new EventHandlerParameters();
+ RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters();
+ producerParameters.setCarrierTechnologyParameters(rcctp);
+
+ rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.POST);
+
+ ApexEventConsumer consumer = new ApexFileEventConsumer();
+ SynchronousEventCache cache = new SynchronousEventCache(EventHandlerPeeredMode.SYNCHRONOUS, consumer, arcp,
+ 1000);
+ arcp.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, cache);
+ assertEquals(cache, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ try {
+ arcp.init("RestClientConsumer", producerParameters);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.POST, rcctp.getHttpMethod());
+
+ assertEquals("RestClientConsumer", arcp.getName());
+ } catch (ApexEventException e) {
+ fail("test should not throw an exception");
+ }
+
+ rcctp.setUrl("http://some.place.that.does.not/exist");
+ Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
+ Mockito.doReturn(responseMock).when(builderMock).post(Mockito.any());
+ Mockito.doReturn(builderMock).when(targetMock).request("application/json");
+ Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
+ arcp.setClient(httpClientMock);
+
+ try {
+ arcp.sendEvent(123, "EventName", "This is an Event");
+ arcp.stop();
+ } catch (Exception e) {
+ fail("test should not throw an exception");
+ }
+ }
+
+
+ @Test
+ public void testApexRestClientProducerPostEventCacheTrace() {
+ MockitoAnnotations.initMocks(this);
+
+ ch.qos.logback.classic.Logger classicLogger = (ch.qos.logback.classic.Logger) LOGGER;
+ classicLogger.setLevel(Level.TRACE);
+
+ ApexRestClientProducer arcp = new ApexRestClientProducer();
+ assertNotNull(arcp);
+
+ EventHandlerParameters producerParameters = new EventHandlerParameters();
+ RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters();
+ producerParameters.setCarrierTechnologyParameters(rcctp);
+
+ rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.POST);
+
+ ApexEventConsumer consumer = new ApexFileEventConsumer();
+ SynchronousEventCache cache = new SynchronousEventCache(EventHandlerPeeredMode.SYNCHRONOUS, consumer, arcp,
+ 1000);
+ arcp.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, cache);
+ assertEquals(cache, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS));
+ try {
+ arcp.init("RestClientConsumer", producerParameters);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.POST, rcctp.getHttpMethod());
+
+ assertEquals("RestClientConsumer", arcp.getName());
+ } catch (ApexEventException e) {
+ fail("test should not throw an exception");
+ }
+
+ rcctp.setUrl("http://some.place.that.does.not/exist");
+ Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus();
+ Mockito.doReturn(responseMock).when(builderMock).post(Mockito.any());
+ Mockito.doReturn(builderMock).when(targetMock).request("application/json");
+ Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
+ arcp.setClient(httpClientMock);
+
+ try {
+ arcp.sendEvent(123, "EventName", "This is an Event");
+ arcp.stop();
+ } catch (Exception e) {
+ fail("test should not throw an exception");
+ }
+ }
+
+ @Test
+ public void testApexRestClientProducerHttpError() {
+ MockitoAnnotations.initMocks(this);
+
+ ApexRestClientProducer arcp = new ApexRestClientProducer();
+ assertNotNull(arcp);
+
+ EventHandlerParameters producerParameters = new EventHandlerParameters();
+ RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters();
+ producerParameters.setCarrierTechnologyParameters(rcctp);
+
+ rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.POST);
+ try {
+ arcp.init("RestClientConsumer", producerParameters);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.POST, rcctp.getHttpMethod());
+
+ assertEquals("RestClientConsumer", arcp.getName());
+ } catch (ApexEventException e) {
+ fail("test should not throw an exception");
+ }
+
+ rcctp.setUrl("http://some.place.that.does.not/exist");
+ Mockito.doReturn(Response.Status.BAD_REQUEST.getStatusCode()).when(responseMock).getStatus();
+ Mockito.doReturn(responseMock).when(builderMock).post(Mockito.any());
+ Mockito.doReturn(builderMock).when(targetMock).request("application/json");
+ Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl());
+ arcp.setClient(httpClientMock);
+
+ try {
+ arcp.sendEvent(123, "EventName", "This is an Event");
+ fail("test should throw an exception here");
+ } catch (Exception e) {
+ assertEquals(
+ "send of event to URL \"http://some.place.that.does.not/exist\" using HTTP \"POST\" "
+ + "failed with status code 400 and message \"null\", event:\n" + "This is an Event",
+ e.getMessage());
+ }
+ }
+}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java
new file mode 100644
index 000000000..3d0c9b73f
--- /dev/null
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java
@@ -0,0 +1,149 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.event.carrier.restclient;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments;
+import org.onap.policy.apex.service.parameters.ApexParameterHandler;
+import org.onap.policy.apex.service.parameters.ApexParameters;
+import org.onap.policy.common.parameters.ParameterException;
+
+/**
+ * Test REST Requestor carrier technology parameters.
+ */
+public class RestClientCarrierTechnologyParametersTest {
+
+ @Test
+ public void testRestClientCarrierTechnologyParametersBadList() {
+ ApexCommandLineArguments arguments = new ApexCommandLineArguments();
+ arguments.setConfigurationFilePath("src/test/resources/prodcons/RESTClientWithHTTPHeaderBadList.json");
+ arguments.setRelativeFileRoot(".");
+
+ try {
+ new ApexParameterHandler().getParameters(arguments);
+ fail("test should throw an exception here");
+ } catch (ParameterException pe) {
+ assertTrue(pe.getMessage().contains("HTTP header array entry is null\n parameter"));
+ assertTrue(pe.getMessage().trim().endsWith("HTTP header array entry is null"));
+ }
+ }
+
+ @Test
+ public void testRestClientCarrierTechnologyParametersNotKvPairs() {
+ ApexCommandLineArguments arguments = new ApexCommandLineArguments();
+ arguments.setConfigurationFilePath("src/test/resources/prodcons/RESTClientWithHTTPHeaderNotKvPairs.json");
+ arguments.setRelativeFileRoot(".");
+
+ try {
+ new ApexParameterHandler().getParameters(arguments);
+ fail("test should throw an exception here");
+ } catch (ParameterException pe) {
+ assertTrue(pe.getMessage()
+ .contains("HTTP header array entries must have one key and one value: [aaa, bbb, ccc]"));
+ assertTrue(pe.getMessage().trim()
+ .endsWith("HTTP header array entries must have one key and one value: [aaa]"));
+ }
+ }
+
+ @Test
+ public void testRestClientCarrierTechnologyParametersNulls() {
+ ApexCommandLineArguments arguments = new ApexCommandLineArguments();
+ arguments.setConfigurationFilePath("src/test/resources/prodcons/RESTClientWithHTTPHeaderNulls.json");
+ arguments.setRelativeFileRoot(".");
+
+ try {
+ new ApexParameterHandler().getParameters(arguments);
+ fail("test should throw an exception here");
+ } catch (ParameterException pe) {
+ assertTrue(pe.getMessage().contains("HTTP header key is null or blank: [null, bbb]"));
+ assertTrue(pe.getMessage().trim().endsWith("HTTP header value is null or blank: [ccc, null]"));
+ }
+ }
+
+ @Test
+ public void testRestClientCarrierTechnologyParametersOk() {
+ ApexCommandLineArguments arguments = new ApexCommandLineArguments();
+ arguments.setConfigurationFilePath("src/test/resources/prodcons/RESTClientWithHTTPHeaderOK.json");
+ arguments.setRelativeFileRoot(".");
+
+ try {
+ ApexParameters parameters = new ApexParameterHandler().getParameters(arguments);
+
+ RestClientCarrierTechnologyParameters rrctp0 = (RestClientCarrierTechnologyParameters) parameters
+ .getEventInputParameters().get("RestClientConsumer0").getCarrierTechnologyParameters();
+ assertEquals(0, rrctp0.getHttpHeaders().length);
+
+ RestClientCarrierTechnologyParameters rrctp1 = (RestClientCarrierTechnologyParameters) parameters
+ .getEventInputParameters().get("RestClientConsumer1").getCarrierTechnologyParameters();
+ assertEquals(3, rrctp1.getHttpHeaders().length);
+ assertEquals("bbb", rrctp1.getHttpHeadersAsMultivaluedMap().get("aaa").get(0));
+ assertEquals("ddd", rrctp1.getHttpHeadersAsMultivaluedMap().get("ccc").get(0));
+ assertEquals("fff", rrctp1.getHttpHeadersAsMultivaluedMap().get("eee").get(0));
+
+ rrctp1.setHttpHeaders(null);
+ assertEquals(null, rrctp1.getHttpHeadersAsMultivaluedMap());
+ } catch (ParameterException pe) {
+ fail("test should not throw an exception");
+ }
+ }
+
+ @Test
+ public void testGettersAndSetters() {
+ RestClientCarrierTechnologyParameters rrctp = new RestClientCarrierTechnologyParameters();
+
+ rrctp.setUrl("http://some.where");
+ assertEquals("http://some.where", rrctp.getUrl());
+
+ String[][] httpHeaders = new String[2][2];
+ httpHeaders[0][0] = "aaa";
+ httpHeaders[0][1] = "bbb";
+ httpHeaders[1][0] = "ccc";
+ httpHeaders[1][1] = "ddd";
+
+ rrctp.setHttpHeaders(httpHeaders);
+ assertEquals("aaa", rrctp.getHttpHeaders()[0][0]);
+ assertEquals("bbb", rrctp.getHttpHeaders()[0][1]);
+ assertEquals("ccc", rrctp.getHttpHeaders()[1][0]);
+ assertEquals("ddd", rrctp.getHttpHeaders()[1][1]);
+
+ rrctp.setHttpHeaders(null);
+ assertFalse(rrctp.checkHttpHeadersSet());
+
+ String[][] httpHeadersZeroLength = new String[0][0];
+ rrctp.setHttpHeaders(httpHeadersZeroLength);
+ assertFalse(rrctp.checkHttpHeadersSet());
+
+ rrctp.setHttpHeaders(httpHeaders);
+ assertTrue(rrctp.checkHttpHeadersSet());
+
+ rrctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.DELETE);
+ assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.DELETE, rrctp.getHttpMethod());
+
+ assertEquals("RestClientCarrierTechnologyParameters "
+ + "[url=http://some.where, httpMethod=DELETE, httpHeaders=[[aaa, bbb], [ccc, ddd]]]",
+ rrctp.toString());
+ }
+}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/SupportApexEventReceiver.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/SupportApexEventReceiver.java
new file mode 100644
index 000000000..d3f8b9e82
--- /dev/null
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/SupportApexEventReceiver.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.plugins.event.carrier.restclient;
+
+import org.onap.policy.apex.service.engine.event.ApexEventException;
+import org.onap.policy.apex.service.engine.event.ApexEventReceiver;
+
+/**
+ * Support Apex event reveiver for unit test.
+ *
+ */
+public class SupportApexEventReceiver implements ApexEventReceiver {
+ private long lastExecutionId;
+ private Object lastEvent;
+ private int eventCount;
+
+ /* (non-Javadoc)
+ * @see org.onap.policy.apex.service.engine.event.ApexEventReceiver#receiveEvent(long, java.lang.Object)
+ */
+ @Override
+ public void receiveEvent(long executionId, Object event) throws ApexEventException {
+ this.lastExecutionId = executionId;
+ this.lastEvent = event;
+ this.eventCount++;
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.policy.apex.service.engine.event.ApexEventReceiver#receiveEvent(java.lang.Object)
+ */
+ @Override
+ public void receiveEvent(Object event) throws ApexEventException {
+ this.lastEvent = event;
+ this.eventCount++;
+ }
+
+ public long getLastExecutionId() {
+ return lastExecutionId;
+ }
+
+ public Object getLastEvent() {
+ return lastEvent;
+ }
+
+ /**
+ * Get the number of events received.
+ *
+ * @return the number of events received
+ */
+ public int getEventCount() {
+ return eventCount;
+ }
+}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/events/EventsIn.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/events/EventsIn.json
new file mode 100644
index 000000000..48780ba51
--- /dev/null
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/events/EventsIn.json
@@ -0,0 +1,400 @@
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 12345
+}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/events/EventsInMulti.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/events/EventsInMulti.json
new file mode 100644
index 000000000..32aba1f63
--- /dev/null
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/events/EventsInMulti.json
@@ -0,0 +1,16 @@
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 3
+}
+{
+ "nameSpace": "org.onap.policy.apex.events",
+ "name": "BasicEvent",
+ "version": "0.0.1",
+ "source": "test",
+ "target": "apex",
+ "intPar": 6
+} \ No newline at end of file
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/policymodels/RequestorModel.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/policymodels/RequestorModel.json
new file mode 100644
index 000000000..b6fdc617b
--- /dev/null
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/policymodels/RequestorModel.json
@@ -0,0 +1,608 @@
+{
+ "apexPolicyModel" : {
+ "key" : {
+ "name" : "SmallModel",
+ "version" : "0.0.1"
+ },
+ "keyInformation" : {
+ "key" : {
+ "name" : "SmallModel_KeyInfo",
+ "version" : "0.0.1"
+ },
+ "keyInfoMap" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "BasicContextAlbum",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "BasicContextAlbum",
+ "version" : "0.0.1"
+ },
+ "UUID" : "fec1b353-b35f-4384-b7d9-69622059c248",
+ "description" : "Generated description for a concept called \"BasicContextAlbum\" with version \"0.0.1\" and UUID \"fec1b353-b35f-4384-b7d9-69622059c248\""
+ }
+ }, {
+ "key" : {
+ "name" : "BasicEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "BasicEvent",
+ "version" : "0.0.1"
+ },
+ "UUID" : "cc8d3c1a-e975-459a-bcd2-69f423eaa1f3",
+ "description" : "Generated description for a concept called \"BasicEvent\" with version \"0.0.1\" and UUID \"cc8d3c1a-e975-459a-bcd2-69f423eaa1f3\""
+ }
+ }, {
+ "key" : {
+ "name" : "BasicPolicy",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "BasicPolicy",
+ "version" : "0.0.1"
+ },
+ "UUID" : "d0c5d8ee-5fe7-4978-89ce-4a3e69cad043",
+ "description" : "Generated description for a concept called \"BasicPolicy\" with version \"0.0.1\" and UUID \"d0c5d8ee-5fe7-4978-89ce-4a3e69cad043\""
+ }
+ }, {
+ "key" : {
+ "name" : "BasicTask",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "BasicTask",
+ "version" : "0.0.1"
+ },
+ "UUID" : "c5651414-fc1c-493b-878d-75f0ce685c36",
+ "description" : "Generated description for a concept called \"BasicTask\" with version \"0.0.1\" and UUID \"c5651414-fc1c-493b-878d-75f0ce685c36\""
+ }
+ }, {
+ "key" : {
+ "name" : "IntType",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "IntType",
+ "version" : "0.0.1"
+ },
+ "UUID" : "790ff718-8dc0-44e0-89d8-1b3bbe238310",
+ "description" : "Generated description for a concept called \"IntType\" with version \"0.0.1\" and UUID \"790ff718-8dc0-44e0-89d8-1b3bbe238310\""
+ }
+ }, {
+ "key" : {
+ "name" : "RequestEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "RequestEvent",
+ "version" : "0.0.1"
+ },
+ "UUID" : "99875c27-6120-4101-9e73-50ac810e322c",
+ "description" : "Generated description for a concept called \"RequestEvent\" with version \"0.0.1\" and UUID \"99875c27-6120-4101-9e73-50ac810e322c\""
+ }
+ }, {
+ "key" : {
+ "name" : "RequestPolicy",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "RequestPolicy",
+ "version" : "0.0.1"
+ },
+ "UUID" : "0667d905-981e-4249-b572-bc22821c7d29",
+ "description" : "Generated description for a concept called \"RequestPolicy\" with version \"0.0.1\" and UUID \"0667d905-981e-4249-b572-bc22821c7d29\""
+ }
+ }, {
+ "key" : {
+ "name" : "ResponseEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "ResponseEvent",
+ "version" : "0.0.1"
+ },
+ "UUID" : "a5022000-fdd7-491c-af9f-5a36e87c997c",
+ "description" : "Generated description for a concept called \"ResponseEvent\" with version \"0.0.1\" and UUID \"a5022000-fdd7-491c-af9f-5a36e87c997c\""
+ }
+ }, {
+ "key" : {
+ "name" : "ResponsePolicy",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "ResponsePolicy",
+ "version" : "0.0.1"
+ },
+ "UUID" : "e72757c4-d81d-4337-b7ce-5f022f55818d",
+ "description" : "Generated description for a concept called \"ResponsePolicy\" with version \"0.0.1\" and UUID \"e72757c4-d81d-4337-b7ce-5f022f55818d\""
+ }
+ }, {
+ "key" : {
+ "name" : "SmallModel",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "SmallModel",
+ "version" : "0.0.1"
+ },
+ "UUID" : "a1bd1f4e-713b-456b-b1a8-bb48beee28e8",
+ "description" : "Generated description for a concept called \"SmallModel\" with version \"0.0.1\" and UUID \"a1bd1f4e-713b-456b-b1a8-bb48beee28e8\""
+ }
+ }, {
+ "key" : {
+ "name" : "SmallModel_Albums",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "SmallModel_Albums",
+ "version" : "0.0.1"
+ },
+ "UUID" : "72bed9af-ab7d-3379-b9f7-b5eca5c9ef22",
+ "description" : "Generated description for concept referred to by key \"SmallModel_Albums:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "SmallModel_Events",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "SmallModel_Events",
+ "version" : "0.0.1"
+ },
+ "UUID" : "796dc6b0-627d-34ae-a5e2-1bc4b4b486b8",
+ "description" : "Generated description for concept referred to by key \"SmallModel_Events:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "SmallModel_KeyInfo",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "SmallModel_KeyInfo",
+ "version" : "0.0.1"
+ },
+ "UUID" : "b4876774-6907-3d27-a2b8-f05737c5ee4a",
+ "description" : "Generated description for concept referred to by key \"SmallModel_KeyInfo:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "SmallModel_Policies",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "SmallModel_Policies",
+ "version" : "0.0.1"
+ },
+ "UUID" : "5bcf946b-67be-3190-a906-f954896f999f",
+ "description" : "Generated description for concept referred to by key \"SmallModel_Policies:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "SmallModel_Schemas",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "SmallModel_Schemas",
+ "version" : "0.0.1"
+ },
+ "UUID" : "c25bf5c3-7f1e-3667-b8a9-971ba21517bc",
+ "description" : "Generated description for concept referred to by key \"SmallModel_Schemas:0.0.1\""
+ }
+ }, {
+ "key" : {
+ "name" : "SmallModel_Tasks",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "SmallModel_Tasks",
+ "version" : "0.0.1"
+ },
+ "UUID" : "43b015ca-2ed1-3a35-b103-e8a5aa68f1ef",
+ "description" : "Generated description for concept referred to by key \"SmallModel_Tasks:0.0.1\""
+ }
+ } ]
+ }
+ },
+ "policies" : {
+ "key" : {
+ "name" : "SmallModel_Policies",
+ "version" : "0.0.1"
+ },
+ "policyMap" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "RequestPolicy",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "policyKey" : {
+ "name" : "RequestPolicy",
+ "version" : "0.0.1"
+ },
+ "template" : "FREEFORM",
+ "state" : {
+ "entry" : [ {
+ "key" : "RequestState",
+ "value" : {
+ "stateKey" : {
+ "parentKeyName" : "RequestPolicy",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "NULL",
+ "localName" : "RequestState"
+ },
+ "trigger" : {
+ "name" : "BasicEvent",
+ "version" : "0.0.1"
+ },
+ "stateOutputs" : {
+ "entry" : [ {
+ "key" : "RequestOutput",
+ "value" : {
+ "key" : {
+ "parentKeyName" : "RequestPolicy",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "RequestState",
+ "localName" : "RequestOutput"
+ },
+ "outgoingEvent" : {
+ "name" : "RequestEvent",
+ "version" : "0.0.1"
+ },
+ "nextState" : {
+ "parentKeyName" : "NULL",
+ "parentKeyVersion" : "0.0.0",
+ "parentLocalName" : "NULL",
+ "localName" : "NULL"
+ }
+ }
+ } ]
+ },
+ "contextAlbumReference" : [ ],
+ "taskSelectionLogic" : {
+ "key" : "NULL",
+ "logicFlavour" : "UNDEFINED",
+ "logic" : ""
+ },
+ "stateFinalizerLogicMap" : {
+ "entry" : [ ]
+ },
+ "defaultTask" : {
+ "name" : "BasicTask",
+ "version" : "0.0.1"
+ },
+ "taskReferences" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "BasicTask",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "parentKeyName" : "RequestPolicy",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "RequestState",
+ "localName" : "RequestTask"
+ },
+ "outputType" : "DIRECT",
+ "output" : {
+ "parentKeyName" : "RequestPolicy",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "RequestState",
+ "localName" : "RequestOutput"
+ }
+ }
+ } ]
+ }
+ }
+ } ]
+ },
+ "firstState" : "RequestState"
+ }
+ }, {
+ "key" : {
+ "name" : "ResponsePolicy",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "policyKey" : {
+ "name" : "ResponsePolicy",
+ "version" : "0.0.1"
+ },
+ "template" : "FREEFORM",
+ "state" : {
+ "entry" : [ {
+ "key" : "ResponseState",
+ "value" : {
+ "stateKey" : {
+ "parentKeyName" : "ResponsePolicy",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "NULL",
+ "localName" : "ResponseState"
+ },
+ "trigger" : {
+ "name" : "ResponseEvent",
+ "version" : "0.0.1"
+ },
+ "stateOutputs" : {
+ "entry" : [ {
+ "key" : "ResponseOutput",
+ "value" : {
+ "key" : {
+ "parentKeyName" : "ResponsePolicy",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "ResponseState",
+ "localName" : "ResponseOutput"
+ },
+ "outgoingEvent" : {
+ "name" : "BasicEvent",
+ "version" : "0.0.1"
+ },
+ "nextState" : {
+ "parentKeyName" : "NULL",
+ "parentKeyVersion" : "0.0.0",
+ "parentLocalName" : "NULL",
+ "localName" : "NULL"
+ }
+ }
+ } ]
+ },
+ "contextAlbumReference" : [ ],
+ "taskSelectionLogic" : {
+ "key" : "NULL",
+ "logicFlavour" : "UNDEFINED",
+ "logic" : ""
+ },
+ "stateFinalizerLogicMap" : {
+ "entry" : [ ]
+ },
+ "defaultTask" : {
+ "name" : "BasicTask",
+ "version" : "0.0.1"
+ },
+ "taskReferences" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "BasicTask",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "parentKeyName" : "ResponsePolicy",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "ResponseState",
+ "localName" : "ResponseTask"
+ },
+ "outputType" : "DIRECT",
+ "output" : {
+ "parentKeyName" : "ResponsePolicy",
+ "parentKeyVersion" : "0.0.1",
+ "parentLocalName" : "ResponseState",
+ "localName" : "ResponseOutput"
+ }
+ }
+ } ]
+ }
+ }
+ } ]
+ },
+ "firstState" : "ResponseState"
+ }
+ } ]
+ }
+ },
+ "tasks" : {
+ "key" : {
+ "name" : "SmallModel_Tasks",
+ "version" : "0.0.1"
+ },
+ "taskMap" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "BasicTask",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "BasicTask",
+ "version" : "0.0.1"
+ },
+ "inputFields" : {
+ "entry" : [ {
+ "key" : "intPar",
+ "value" : {
+ "key" : "intPar",
+ "fieldSchemaKey" : {
+ "name" : "IntType",
+ "version" : "0.0.1"
+ },
+ "optional" : false
+ }
+ } ]
+ },
+ "outputFields" : {
+ "entry" : [ {
+ "key" : "intPar",
+ "value" : {
+ "key" : "intPar",
+ "fieldSchemaKey" : {
+ "name" : "IntType",
+ "version" : "0.0.1"
+ },
+ "optional" : false
+ }
+ } ]
+ },
+ "taskParameters" : {
+ "entry" : [ ]
+ },
+ "contextAlbumReference" : [ {
+ "name" : "BasicContextAlbum",
+ "version" : "0.0.1"
+ } ],
+ "taskLogic" : {
+ "key" : "TaskLogic",
+ "logicFlavour" : "JAVASCRIPT",
+ "logic" : "executor.logger.debug(executor.subject.id);\nvar gc = executor.getContextAlbum(\"BasicContextAlbum\");\nexecutor.logger.debug(gc.name);\nexecutor.logger.debug(executor.inFields);\n\nexecutor.logger.debug(executor.eo);\n\nvar returnValue = executor.isTrue;"
+ }
+ }
+ } ]
+ }
+ },
+ "events" : {
+ "key" : {
+ "name" : "SmallModel_Events",
+ "version" : "0.0.1"
+ },
+ "eventMap" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "BasicEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "BasicEvent",
+ "version" : "0.0.1"
+ },
+ "nameSpace" : "org.onap.policy.apex.events",
+ "source" : "source",
+ "target" : "target",
+ "parameter" : {
+ "entry" : [ {
+ "key" : "intPar",
+ "value" : {
+ "key" : "intPar",
+ "fieldSchemaKey" : {
+ "name" : "IntType",
+ "version" : "0.0.1"
+ },
+ "optional" : false
+ }
+ } ]
+ }
+ }
+ }, {
+ "key" : {
+ "name" : "RequestEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "RequestEvent",
+ "version" : "0.0.1"
+ },
+ "nameSpace" : "org.onap.policy.apex.events",
+ "source" : "apex",
+ "target" : "server",
+ "parameter" : {
+ "entry" : [ {
+ "key" : "intPar",
+ "value" : {
+ "key" : "intPar",
+ "fieldSchemaKey" : {
+ "name" : "IntType",
+ "version" : "0.0.1"
+ },
+ "optional" : false
+ }
+ } ]
+ }
+ }
+ }, {
+ "key" : {
+ "name" : "ResponseEvent",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "ResponseEvent",
+ "version" : "0.0.1"
+ },
+ "nameSpace" : "org.onap.policy.apex.events",
+ "source" : "server",
+ "target" : "apex",
+ "parameter" : {
+ "entry" : [ {
+ "key" : "intPar",
+ "value" : {
+ "key" : "intPar",
+ "fieldSchemaKey" : {
+ "name" : "IntType",
+ "version" : "0.0.1"
+ },
+ "optional" : false
+ }
+ } ]
+ }
+ }
+ } ]
+ }
+ },
+ "albums" : {
+ "key" : {
+ "name" : "SmallModel_Albums",
+ "version" : "0.0.1"
+ },
+ "albums" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "BasicContextAlbum",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "BasicContextAlbum",
+ "version" : "0.0.1"
+ },
+ "scope" : "GLOBAL",
+ "isWritable" : true,
+ "itemSchema" : {
+ "name" : "IntType",
+ "version" : "0.0.1"
+ }
+ }
+ } ]
+ }
+ },
+ "schemas" : {
+ "key" : {
+ "name" : "SmallModel_Schemas",
+ "version" : "0.0.1"
+ },
+ "schemas" : {
+ "entry" : [ {
+ "key" : {
+ "name" : "IntType",
+ "version" : "0.0.1"
+ },
+ "value" : {
+ "key" : {
+ "name" : "IntType",
+ "version" : "0.0.1"
+ },
+ "schemaFlavour" : "Java",
+ "schemaDefinition" : "java.lang.Integer"
+ }
+ } ]
+ }
+ }
+ }
+}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderBadList.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderBadList.json
new file mode 100644
index 000000000..a3969aead
--- /dev/null
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderBadList.json
@@ -0,0 +1,72 @@
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 4,
+ "deploymentPort": 12561,
+ "policyModelFileName": "src/test/resources/policymodels/RequestorModel.json",
+ "engineParameters": {
+ "executorParameters": {
+ "JAVASCRIPT": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventInputParameters": {
+ "RestClientConsumer0": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent",
+ "httpMethod": "GET",
+ "httpHeaders" : [
+ ["aaa", "bbb"],
+ ["ccc", "ddd"],
+ ]
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ },
+ "RestClientConsumer1": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent",
+ "httpMethod": "GET",
+ "httpHeaders" : [
+ ,
+ ]
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ },
+ "eventOutputParameters": {
+ "RestClientProducer0": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters"
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ },
+ "RestClientProducer1": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters"
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ }
+}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderNotKvPairs.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderNotKvPairs.json
new file mode 100644
index 000000000..790a9bc38
--- /dev/null
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderNotKvPairs.json
@@ -0,0 +1,71 @@
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 4,
+ "deploymentPort": 12561,
+ "policyModelFileName": "src/test/resources/policymodels/RequestorModel.json",
+ "engineParameters": {
+ "executorParameters": {
+ "JAVASCRIPT": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventInputParameters": {
+ "RestClientConsumer0": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent",
+ "httpMethod": "GET",
+ "httpHeaders" : [
+ ["aaa", "bbb", "ccc"]
+ ]
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ },
+ "RestClientConsumer1": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent",
+ "httpMethod": "GET",
+ "httpHeaders" : [
+ ["aaa"]
+ ]
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ },
+ "eventOutputParameters": {
+ "RestClientProducer0": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters"
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ },
+ "RestClientProducer1": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters"
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ }
+}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderNulls.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderNulls.json
new file mode 100644
index 000000000..4b99ca0c2
--- /dev/null
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderNulls.json
@@ -0,0 +1,71 @@
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 4,
+ "deploymentPort": 12561,
+ "policyModelFileName": "src/test/resources/policymodels/RequestorModel.json",
+ "engineParameters": {
+ "executorParameters": {
+ "JAVASCRIPT": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventInputParameters": {
+ "RestClientConsumer0": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent",
+ "httpMethod": "GET",
+ "httpHeaders" : [
+ [null, "bbb"],
+ ["ccc", "ddd"]
+ ]
+ }
+ }
+ },
+ "RestClientConsumer1": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent",
+ "httpMethod": "GET",
+ "httpHeaders" : [
+ ["aaa", "bbb"],
+ ["ccc", null],
+ ["eee", "fff"]
+ ]
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ },
+ "eventOutputParameters": {
+ "RestClientProducer0": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters"
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ },
+ "RestClientProducer1": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters"
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ }
+}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderOK.json b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderOK.json
new file mode 100644
index 000000000..1c4a39d99
--- /dev/null
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/resources/prodcons/RESTClientWithHTTPHeaderOK.json
@@ -0,0 +1,87 @@
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 4,
+ "deploymentPort": 12561,
+ "policyModelFileName": "src/test/resources/policymodels/RequestorModel.json",
+ "engineParameters": {
+ "executorParameters": {
+ "JAVASCRIPT": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventInputParameters": {
+ "RestClientConsumer0": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent",
+ "httpMethod": "GET",
+ "httpHeaders" : [
+ ]
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ },
+ "RestClientConsumer1": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent",
+ "httpMethod": "GET",
+ "httpHeaders" : [
+ ["aaa", "bbb"],
+ ["ccc", "ddd"],
+ ["eee", "fff"]
+ ]
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ },
+ "eventOutputParameters": {
+ "RestClientProducer0": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent",
+ "httpMethod": "GET",
+ "httpHeaders" : [
+ ]
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ },
+ "RestClientProducer1": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/TestRESTRequestor/apex/event/GetEvent",
+ "httpMethod": "GET",
+ "httpHeaders" : [
+ ["aaa", "bbb"],
+ ["ccc", "ddd"],
+ ["eee", "fff"]
+ ]
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ }
+}