diff options
author | liamfallon <liam.fallon@est.tech> | 2020-03-02 17:08:47 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2020-03-04 08:33:25 +0000 |
commit | 9e5c4b882728ebf3330568d068f109965d599410 (patch) | |
tree | 8ad948a28268b50b97946168b7a8ceab54872dc5 /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main | |
parent | 5922128637471bfa1897b8808561000988da733d (diff) |
Preparing integration tests for Graal Javascript
Graal enforces Javascript more strictly than Nashorn does. This review
changes the tests in apex-pdp to comply with the stricter -Javascript
checking, re-enabling the integration test module.
- All log calls must be passed as strings, using toString()
- Byte/Float/Long Java types not supported in Javascript
Disable integration tests so that other changes can be brought in.
JMS integration test is disabled for now, it will be re-enabled in a
review shortly.
Issue-ID: POLICY-2106
Change-Id: I14bdb930eff735e862b51802cf72e4793cec3699
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main')
2 files changed, 17 insertions, 17 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 aa8185fdb..a3d273dfd 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 @@ -22,9 +22,9 @@ package org.onap.policy.apex.plugins.event.carrier.restclient; import java.util.Properties; - import java.util.regex.Matcher; import java.util.regex.Pattern; + import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response; @@ -35,6 +35,7 @@ import org.onap.policy.apex.service.engine.event.ApexEventException; import org.onap.policy.apex.service.engine.event.ApexEventReceiver; import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; import org.onap.policy.apex.service.engine.event.ApexPluginsEventConsumer; +import org.onap.policy.apex.service.parameters.carriertechnology.RestPluginCarrierTechnologyParameters; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -86,10 +87,10 @@ public class ApexRestClientConsumer extends ApexPluginsEventConsumer { // Check if the HTTP method has been set if (restConsumerProperties.getHttpMethod() == null) { - restConsumerProperties.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.GET); + restConsumerProperties.setHttpMethod(RestPluginCarrierTechnologyParameters.HttpMethod.GET); } - if (!RestClientCarrierTechnologyParameters.HttpMethod.GET.equals(restConsumerProperties.getHttpMethod())) { + if (!RestPluginCarrierTechnologyParameters.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 + ")"; 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 3506ace3c..cf3500065 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 @@ -21,8 +21,6 @@ package org.onap.policy.apex.plugins.event.carrier.restclient; -import java.util.EnumMap; -import java.util.Map; import java.util.Optional; import java.util.Properties; import java.util.Set; @@ -33,12 +31,10 @@ import javax.ws.rs.client.Entity; import javax.ws.rs.core.Response; import org.onap.policy.apex.service.engine.event.ApexEventException; -import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer; import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; -import org.onap.policy.apex.service.engine.event.PeeredReference; -import org.onap.policy.apex.service.engine.event.SynchronousEventCache; +import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer; +import org.onap.policy.apex.service.parameters.carriertechnology.RestPluginCarrierTechnologyParameters; 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; @@ -77,14 +73,14 @@ public class ApexRestClientProducer extends ApexPluginsEventProducer { // Check if the HTTP method has been set if (restProducerProperties.getHttpMethod() == null) { - restProducerProperties.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.POST); + restProducerProperties.setHttpMethod(RestPluginCarrierTechnologyParameters.HttpMethod.POST); } - if (!RestClientCarrierTechnologyParameters.HttpMethod.POST.equals(restProducerProperties.getHttpMethod()) - && !RestClientCarrierTechnologyParameters.HttpMethod.PUT + if (!RestPluginCarrierTechnologyParameters.HttpMethod.POST.equals(restProducerProperties.getHttpMethod()) + && !RestPluginCarrierTechnologyParameters.HttpMethod.PUT .equals(restProducerProperties.getHttpMethod())) { final String errorMessage = "specified HTTP method of \"" + restProducerProperties.getHttpMethod() - + "\" is invalid, only HTTP methods \"POST\" and \"PUT\" are supproted " + + "\" is invalid, only HTTP methods \"POST\" and \"PUT\" are supported " + "for event sending on REST client producer (" + this.name + ")"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); @@ -97,6 +93,7 @@ public class ApexRestClientProducer extends ApexPluginsEventProducer { /** * {@inheritDoc}. */ + @Override public void sendEvent(final long executionId, final Properties executionProperties, final String eventName, final Object event) { super.sendEvent(executionId, executionProperties, eventName, event); @@ -106,15 +103,17 @@ public class ApexRestClientProducer extends ApexPluginsEventProducer { Set<String> names = restProducerProperties.getKeysFromUrl(); Set<String> inputProperty = executionProperties.stringPropertyNames(); + // @formatter:off names.stream().map(Optional::of).forEach(op -> op.filter(inputProperty::contains) .orElseThrow(() -> new ApexEventRuntimeException( - "key\"" + op.get() + "\"specified on url \"" + restProducerProperties.getUrl() - + "\"not found in execution properties passed by the current policy")) + "key \"" + op.get() + "\" specified on url \"" + restProducerProperties.getUrl() + + "\" not found in execution properties passed by the current policy")) ); untaggedUrl = names.stream().reduce(untaggedUrl, (acc, str) -> acc.replace("{" + str + "}", (String) executionProperties.get(str))); + // @formatter:on } // Send the event as a REST request @@ -131,7 +130,7 @@ public class ApexRestClientProducer extends ApexPluginsEventProducer { if (LOGGER.isTraceEnabled()) { LOGGER.trace("event sent from engine using {} to URL {} with HTTP {} : {} and response {} ", this.name, - untaggedUrl, restProducerProperties.getHttpMethod(), event, response); + untaggedUrl, restProducerProperties.getHttpMethod(), event, response); } } @@ -152,7 +151,7 @@ public class ApexRestClientProducer extends ApexPluginsEventProducer { */ private Response sendEventAsRestRequest(final String untaggedUrl, final String event) { // We have already checked that it is a PUT or POST request - if (RestClientCarrierTechnologyParameters.HttpMethod.POST.equals(restProducerProperties.getHttpMethod())) { + if (RestPluginCarrierTechnologyParameters.HttpMethod.POST.equals(restProducerProperties.getHttpMethod())) { return client.target(untaggedUrl).request("application/json") .headers(restProducerProperties.getHttpHeadersAsMultivaluedMap()).post(Entity.json(event)); } else { |