diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2018-02-01 12:22:30 -0500 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2018-02-01 12:37:59 -0500 |
commit | 06f456d8d06840a21f48531b0bd35b1a429b10f9 (patch) | |
tree | a72db2dbec1a520589e98809d03424cf81c6aab1 /PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientUEB.java | |
parent | 066fc4529f36d210a4a4700e8dbfd2cb42f4dc66 (diff) |
Reduce technical debt and add JUnit
* Addressed some very simple cyclic complexity
* Added simple JUnit tests and finished others
* Removed useless assignments
Issue-ID: POLICY-477
Change-Id: Ic919bbf78ad2732a430c32f1feb3c88678be710d
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientUEB.java')
-rw-r--r-- | PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientUEB.java | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientUEB.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientUEB.java index f84568aba..6bfcd2c7a 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientUEB.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientUEB.java @@ -103,44 +103,44 @@ public class AutoClientUEB implements Runnable { String group = UUID.randomUUID ().toString (); String id = "0"; // Stop and Start needs to be done. - if (scheme != null && handler!=null) { - if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS) || scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) { - URL aURL; - try { - aURL = new URL(AutoClientUEB.topic); - setTopic(aURL.getHost() + aURL.getPort()); - } catch (MalformedURLException e) { - setTopic(AutoClientUEB.url.replace("[:/]", "")); - } - try { - ConsumerBuilder builder = new CambriaClientBuilders.ConsumerBuilder(); - builder.knownAs(group, id) - .usingHosts(uebURLList) - .onTopic(topic) - .waitAtServer(15*1000) - .receivingAtMost(1000) - .authenticatedBy(apiKey, apiSecret); - setConsumer(builder.build()); - } catch (Exception e1) { - logger.error("Exception Occured" + e1); - } - while (this.isRunning()) { - try { - for (String msg : cConsumer.fetch()) { - logger.debug("Auto Notification Recieved Message " + msg + " from UEB cluster : " - + uebURLList.toString()); - setNotification(NotificationUnMarshal.notificationJSON(msg)); - callHandler(); - } - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Error in processing UEB message" - + e.getMessage(), e); - } - - } - logger.debug("Stopping UEB Consumer loop will not logger fetch messages from the cluster"); - } + if (scheme == null || handler == null || + ! (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS) || scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) ) { + return; } + URL aURL; + try { + aURL = new URL(AutoClientUEB.topic); + setTopic(aURL.getHost() + aURL.getPort()); + } catch (MalformedURLException e) { + setTopic(AutoClientUEB.url.replace("[:/]", "")); + } + try { + ConsumerBuilder builder = new CambriaClientBuilders.ConsumerBuilder(); + builder.knownAs(group, id) + .usingHosts(uebURLList) + .onTopic(topic) + .waitAtServer(15*1000) + .receivingAtMost(1000) + .authenticatedBy(apiKey, apiSecret); + setConsumer(builder.build()); + } catch (Exception e1) { + logger.error("Exception Occured" + e1); + } + while (this.isRunning()) { + try { + for (String msg : cConsumer.fetch()) { + logger.debug("Auto Notification Recieved Message " + msg + " from UEB cluster : " + + uebURLList.toString()); + setNotification(NotificationUnMarshal.notificationJSON(msg)); + callHandler(); + } + } catch (Exception e) { + logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Error in processing UEB message" + + e.getMessage(), e); + } + + } + logger.debug("Stopping UEB Consumer loop will not logger fetch messages from the cluster"); } private static void setNotification(StdPDPNotification notificationJSON) { |