diff options
author | liamfallon <liam.fallon@est.tech> | 2018-12-08 11:27:17 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2018-12-08 11:27:55 +0000 |
commit | 5b97cd4470b9668ed31bf7663808c32087ba696c (patch) | |
tree | d60fb5a8d41f4074ca221fc3c8654e5db9985aaa /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test | |
parent | e6753352980648bac92aff9a7295639349ea1295 (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/test')
11 files changed, 2219 insertions, 0 deletions
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" + } + } + } +} |