diff options
author | lapentafd <francesco.lapenta@est.tech> | 2021-10-18 10:06:31 +0100 |
---|---|---|
committer | lapentafd <francesco.lapenta@est.tech> | 2021-10-19 12:36:29 +0100 |
commit | 06ea4844bddd197796933775faf8999612daa63d (patch) | |
tree | 09dfa971b72206edb84b217ed5903bfd83c7c7c2 /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java | |
parent | 5db2ed027f3f17be19cb1ff6850129af7525d5d5 (diff) |
HTTP code filter for RestClientProducer
RestClient producer can now consider 2xx response status as success
Issue-ID: POLICY-3743
Change-Id: I40c4dce01b437ea6b9f9bbc317835657cb7ebc8a
Signed-off-by: lapentafd <francesco.lapenta@est.tech>
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java')
-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.java | 29 |
1 files changed, 29 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/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 index 85a6214fb..57f0c4342 100644 --- 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 @@ -190,6 +190,35 @@ public class ApexRestClientProducerTest { } @Test + public void testApexRestClientProducerPostEventAccepted() throws ApexEventException { + ApexRestClientProducer arcp = new ApexRestClientProducer(); + assertNotNull(arcp); + + EventHandlerParameters producerParameters = new EventHandlerParameters(); + RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters(); + producerParameters.setCarrierTechnologyParameters(rcctp); + + rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.PUT); + arcp.init("RestClientConsumer", producerParameters); + assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.PUT, rcctp.getHttpMethod()); + assertEquals("RestClientConsumer", arcp.getName()); + + rcctp.setUrl("http://some.place.{key}.does.not/{tag}"); + Properties properties = new Properties(); + properties.put("tag", "exist"); + properties.put("key", "that"); + Mockito.doReturn(Response.Status.ACCEPTED.getStatusCode()).when(responseMock).getStatus(); + Mockito.doReturn(responseMock).when(builderMock).put(Mockito.any()); + Mockito.doReturn(builderMock).when(targetMock).request("application/json"); + Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any()); + Mockito.doReturn(targetMock).when(httpClientMock).target("http://some.place.that.does.not/exist"); + arcp.setClient(httpClientMock); + + arcp.sendEvent(123, properties, "EventName", "This is an ACCEPTED Event"); + arcp.stop(); + } + + @Test public void testApexRestClientProducerPostEventCache() throws ApexEventException { ApexRestClientProducer arcp = new ApexRestClientProducer(); assertNotNull(arcp); |