summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event
diff options
context:
space:
mode:
authorning.xi <ning.xi@est.tech>2019-07-12 08:02:09 +0000
committerning.xi <ning.xi@est.tech>2019-07-12 08:02:09 +0000
commitf2ecd3282507c418ee7da5cd22c6e7613975d480 (patch)
tree98ea6845c80265d5152c8cfdc36af61d86ef6342 /plugins/plugins-event
parent45d7389dacffb824b66e8a7c43583dc0212cb7d5 (diff)
fix sonar issues in restclient/restrequest
Issue-ID: POLICY-1743 Change-Id: I2bd2224904e459d56f5802e8b5276823e7f5d454 Signed-off-by: ning.xi <ning.xi@est.tech>
Diffstat (limited to 'plugins/plugins-event')
-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.java15
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java18
2 files changed, 14 insertions, 19 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/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 822ac46a2..ea60e3915 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
@@ -23,10 +23,9 @@ 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;
-import java.util.Optional;
-import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@@ -40,8 +39,6 @@ import org.onap.policy.apex.service.engine.event.PeeredReference;
import org.onap.policy.apex.service.engine.event.SynchronousEventCache;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -145,12 +142,12 @@ public class ApexRestClientProducer implements ApexEventProducer {
Set<String> names = restProducerProperties.getKeysFromUrl();
Set<String> inputProperty = executionProperties.stringPropertyNames();
- names.stream().map(key -> Optional.of(key)).forEach(op -> {
- op.filter(str -> inputProperty.contains(str))
+ 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)));
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java
index f1024d0fc..82d16273f 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java
@@ -27,16 +27,14 @@ import java.util.Arrays;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Optional;
import java.util.Map.Entry;
+import java.util.Optional;
import java.util.Properties;
+import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@@ -254,15 +252,15 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable {
Set<String> names = restConsumerProperties.getKeysFromUrl();
Set<String> inputProperty = inputExecutionProperties.stringPropertyNames();
- names.stream().map(key -> Optional.of(key)).forEach(op -> {
- op.filter(str -> inputProperty.contains(str))
+ names.stream().map(Optional::of).forEach(op ->
+ op.filter(inputProperty::contains)
.orElseThrow(() -> new ApexEventRuntimeException(
- "key\"" + op.get() + "\"specified on url \"" + restConsumerProperties.getUrl() +
- "\"not found in execution properties passed by the current policy"));
- });
+ "key\"" + op.get() + "\"specified on url \"" + restConsumerProperties.getUrl()
+ + "\"not found in execution properties passed by the current policy"))
+ );
untaggedUrl = names.stream().reduce(untaggedUrl,
- (acc, str) -> acc.replace("{" + str + "}", (String) inputExecutionProperties.get(str)));
+ (acc, str) -> acc.replace("{" + str + "}", (String) inputExecutionProperties.get(str)));
}
// Set the time stamp of the REST request