summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-10-17 10:26:58 -0400
committerPamela Dragosh <pdragosh@research.att.com>2019-10-17 17:12:11 -0400
commite9b8aa0223e6f042c0533176ae8222fb061852de (patch)
treece5ac86f12a3430a688af34e5838c8be79504d12
parent3c95fa7249cccc3d0eb3c9e89ba708a3167d41ba (diff)
Re-format source code
No longer need the onap-java-formatter.xml in the repo - just use command line to set path to it as this process is done manually anyway. Fixed missing javadoc, curly braces and variables names. One minor fix to remove redundant jump and then unnecessary lambda expression. Distance from usage - moved code. Fixed compilation error in PeCryptoUtils due to policy/common change. Fixed some test sources with consecutive capital letter in names. Updated licenses. Added some trivial code coverage. Issue-ID: POLICY-2145 Change-Id: I6c36650554e4fe31a3e71538d898535bc77e7e74 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java11
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java11
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java17
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java8
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/PEDependency.java68
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java8
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java17
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/jpa/BackUpMonitorEntity.java8
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java173
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/std/StdLoadedPolicy.java92
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/std/StdPDPNotification.java7
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/std/StdRemovedPolicy.java56
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFEnvironment.java17
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyClient.java38
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyClientImpl.java69
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyException.java54
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpHandler.java42
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitor.java121
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitorException.java27
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/BusConsumer.java39
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/BusPublisher.java215
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/PeCryptoUtils.java29
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/PolicyAccess.java19
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/PolicyUtils.java318
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/utils/XMLErrorHandler.java8
-rw-r--r--PolicyEngineUtils/src/test/java/org/onap/policy/utils/AAFEnvironmentTest.java39
-rw-r--r--PolicyEngineUtils/src/test/java/org/onap/policy/utils/BusTest.java34
-rw-r--r--PolicyEngineUtils/src/test/java/org/onap/policy/utils/PeCryptoUtilsTest.java9
-rw-r--r--PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/AAFClientTest.java46
-rw-r--r--PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/BackUpMonitorEntityTest.java52
-rw-r--r--PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/BackUpMonitorExceptionTest.java61
-rw-r--r--PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/BackUpMonitorTest.java4
-rw-r--r--PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/DummyBackUpHandler.java26
-rw-r--r--PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/NotificationStoreTest.java74
-rw-r--r--PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/PEDependencyTest.java18
-rw-r--r--PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/PolicyUtilsTest.java313
-rw-r--r--onap-java-formatter.xml295
37 files changed, 1097 insertions, 1346 deletions
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java
index 862b654b8..95ef694d8 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/LoadedPolicy.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -23,7 +23,7 @@ package org.onap.policy.api;
import java.util.Map;
/**
- * <code>LoadedPolicy</code> defines the Policy that has been Loaded into the PDP.
+ * <code>LoadedPolicy</code> defines the Policy that has been Loaded into the PDP.
*
* @version 0.2
*/
@@ -44,7 +44,8 @@ public interface LoadedPolicy {
String getVersionNo();
/**
- * Gets the <code>Map</code> of <code>String,String</code> format of the Matches if the policy Loaded is of Config Type.
+ * Gets the <code>Map</code> of <code>String,String</code> format of the Matches if the policy Loaded is of Config
+ * Type.
*
* @return the <code>Map</code> of <code>String,String</code> format of the matches in the policy.
*/
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java
index 78b79a08f..fe30241dd 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -29,10 +29,11 @@ package org.onap.policy.api;
public interface NotificationHandler {
/**
- * <code>notificationReceived</code> method will be triggered automatically whenever a Notification is received by the PEP.
+ * <code>notificationReceived</code> method will be triggered automatically whenever a Notification is received by
+ * the PEP.
*
* @param notification <code>PDPNotification</code> of {@link org.onap.policy.api.PDPNotification}
- * is the object that has information of the notification.
+ * is the object that has information of the notification.
*/
void notificationReceived(PDPNotification notification);
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java
index 8b65a420d..a86e997b8 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationType.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -21,18 +21,18 @@
package org.onap.policy.api;
/**
- * Enumeration of the Update Type that has occurred in the <code>PDPNotification</code> of
- * {@link org.onap.policy.api.PDPNotification}
+ * Enumeration of the Update Type that has occurred in the <code>PDPNotification</code> of
+ * {@link org.onap.policy.api.PDPNotification}.
*
* @version 0.1
*/
public enum NotificationType {
/**
- * Indicates that a policy has been updated
+ * Indicates that a policy has been updated.
*/
UPDATE("update"),
/**
- * Indicates that a policy has been removed
+ * Indicates that a policy has been removed.
*/
REMOVE("remove"),
/**
@@ -47,7 +47,8 @@ public enum NotificationType {
}
/**
- * Returns the <code>String</code> format of the Type for this <code>UpdateType</code>
+ * Returns the <code>String</code> format of the Type for this <code>UpdateType</code>.
+ *
* @return the <code>String</code> Type of <code>UpdateType</code>
*/
@Override
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java
index 9ab508281..caee7e301 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/PDPNotification.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -23,7 +23,7 @@ package org.onap.policy.api;
import java.util.Collection;
/**
- * Defines the <code>Notification</code> event sent from PDP to Client PEP.
+ * Defines the <code>Notification</code> event sent from PDP to Client PEP.
*
* @version 0.2
*/
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/PEDependency.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/PEDependency.java
index d722f1696..b94872785 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/PEDependency.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/PEDependency.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -20,63 +20,29 @@
package org.onap.policy.api;
+import lombok.Getter;
+import lombok.Setter;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Exclusion;
-public class PEDependency{
-
+@Setter
+@Getter
+public class PEDependency {
+
private String groupId;
private String artifactId;
private String version;
private String classifier;
- private String type;
+ private String type;
private String scope;
private java.util.List<Exclusion> exclusions;
-
- public String getGroupId() {
- return groupId;
- }
- public void setGroupId(String groupId) {
- this.groupId = groupId;
- }
- public String getArtifactId() {
- return artifactId;
- }
- public void setArtifactId(String artifactId) {
- this.artifactId = artifactId;
- }
- public String getVersion() {
- return version;
- }
- public void setVersion(String version) {
- this.version = version;
- }
- public java.util.List<Exclusion> getExclusions() {
- return exclusions;
- }
- public void setExclusions(java.util.List<Exclusion> exclusions) {
- this.exclusions = exclusions;
- }
- public String getClassifier() {
- return classifier;
- }
- public void setClassifier(String classifier) {
- this.classifier = classifier;
- }
- public String getType() {
- return type;
- }
- public void setType(String type) {
- this.type = type;
- }
- public String getScope() {
- return scope;
- }
- public void setScope(String scope) {
- this.scope = scope;
- }
-
- public Dependency getDependency(){
+
+ /**
+ * getDependency.
+ *
+ * @return Dependency
+ */
+ public Dependency getDependency() {
Dependency dependency = new Dependency();
dependency.setArtifactId(artifactId);
dependency.setGroupId(groupId);
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java
index e8125a1dc..db7183ed7 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/RemovedPolicy.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -21,7 +21,7 @@
package org.onap.policy.api;
/**
- * <code>RemovedPolicy</code> defines the Policy that has been removed
+ * <code>RemovedPolicy</code> defines the Policy that has been removed.
*
* @version 0.1
*/
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java
index 7f401fec0..6219928bc 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/UpdateType.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -21,18 +21,18 @@
package org.onap.policy.api;
/**
- * Enumeration of the Update Type that has occurred in the <code>UpdatedPolicy</code> of
- * {@link org.onap.policy.api.LoadedPolicy}
+ * Enumeration of the Update Type that has occurred in the <code>UpdatedPolicy</code> of
+ * {@link org.onap.policy.api.LoadedPolicy}.
*
* @version 0.1
*/
public enum UpdateType {
/**
- * Indicates that a policy has been updated
+ * Indicates that a policy has been updated.
*/
UPDATE("update"),
/**
- * Indicates that a policy is new
+ * Indicates that a policy is new.
*/
NEW("new");
@@ -43,7 +43,8 @@ public enum UpdateType {
}
/**
- * Returns the <code>String</code> format of the Type for this <code>UpdateType</code>
+ * Returns the <code>String</code> format of the Type for this <code>UpdateType</code>.
+ *
* @return the <code>String</code> Type of <code>UpdateType</code>
*/
@Override
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/jpa/BackUpMonitorEntity.java b/PolicyEngineUtils/src/main/java/org/onap/policy/jpa/BackUpMonitorEntity.java
index 1bfffce6c..55daf1e83 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/jpa/BackUpMonitorEntity.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/jpa/BackUpMonitorEntity.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -22,6 +22,7 @@ package org.onap.policy.jpa;
import java.io.Serializable;
import java.util.Date;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -35,7 +36,6 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
-
@Entity
@Table(name = "BackUpMonitorEntity")
@NamedQuery(name = "BackUpMonitorEntity.findAll", query = "SELECT b FROM BackUpMonitorEntity b ")
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java b/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java
index 6164418d9..40c640f9a 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java
@@ -2,15 +2,15 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
* Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* 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.
@@ -25,27 +25,33 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
+
import org.onap.policy.api.LoadedPolicy;
import org.onap.policy.api.NotificationType;
import org.onap.policy.api.PDPNotification;
import org.onap.policy.api.RemovedPolicy;
-
/*
- * This Should Compare and save the Notifications from the beginning of Time.
- * If there is something new (missed) We notify the client.
- * Works for PDP failures.
- *
+ * This Should Compare and save the Notifications from the beginning of Time.
+ * If there is something new (missed) We notify the client.
+ * Works for PDP failures.
+ *
*/
public class NotificationStore {
private static StdPDPNotification notificationRecord = new StdPDPNotification();
- private NotificationStore () {
+ private NotificationStore() {
// Sonar prefers that we have an empty public constructor
// as opposed to an implicit public constructor.
}
-
+
+ /**
+ * getDeltaNotification.
+ *
+ * @param newNotification StdPDPNotification
+ * @return StdPDPNotification
+ */
public static StdPDPNotification getDeltaNotification(StdPDPNotification newNotification) {
StdPDPNotification notificationDelta = new StdPDPNotification();
ArrayList<StdRemovedPolicy> removedDelta = new ArrayList<>();
@@ -72,13 +78,15 @@ public class NotificationStore {
// check for old removed policies.
if (!newNotification.getRemovedPolicies().isEmpty()) {
for (RemovedPolicy newRemovedPolicy : newNotification.getRemovedPolicies()) {
- remove = updateRemovedPolicies(removedDelta, oldUpdatedLostPolicies, oldRemovedPolicies, oldUpdatedPolicies, remove, newRemovedPolicy);
+ remove = updateRemovedPolicies(removedDelta, oldUpdatedLostPolicies, oldRemovedPolicies,
+ oldUpdatedPolicies, remove, newRemovedPolicy);
}
}
// Check for old Updated Policies.
if (!newNotification.getLoadedPolicies().isEmpty()) {
for (LoadedPolicy newUpdatedPolicy : newNotification.getLoadedPolicies()) {
- update = modifyUpdatedPolicies(updatedDelta, oldUpdatedLostPolicies, oldRemovedPolicies, oldUpdatedPolicies, update, newUpdatedPolicy);
+ update = modifyUpdatedPolicies(updatedDelta, oldUpdatedLostPolicies, oldRemovedPolicies,
+ oldUpdatedPolicies, update, newUpdatedPolicy);
}
// Conversion of Update to Remove if that occurred.
if (!oldUpdatedLostPolicies.isEmpty()) {
@@ -118,14 +126,15 @@ public class NotificationStore {
return notificationDelta;
}
- private static Boolean modifyUpdatedPolicies(ArrayList<StdLoadedPolicy> updatedDelta, Collection<LoadedPolicy> oldUpdatedLostPolicies, Collection<RemovedPolicy> oldRemovedPolicies, Collection<LoadedPolicy> oldUpdatedPolicies, Boolean update, LoadedPolicy newUpdatedPolicy) {
+ private static Boolean modifyUpdatedPolicies(ArrayList<StdLoadedPolicy> updatedDelta,
+ Collection<LoadedPolicy> oldUpdatedLostPolicies, Collection<RemovedPolicy> oldRemovedPolicies,
+ Collection<LoadedPolicy> oldUpdatedPolicies, Boolean update, LoadedPolicy newUpdatedPolicy) {
// Look for policies which are not in Update
Boolean updated = true;
String policyName = newUpdatedPolicy.getPolicyName();
String ver = newUpdatedPolicy.getVersionNo();
for (LoadedPolicy oldUpdatedPolicy : notificationRecord.getLoadedPolicies()) {
- if (policyName.equals(oldUpdatedPolicy.getPolicyName())
- && ver.equals(oldUpdatedPolicy.getVersionNo())) {
+ if (policyName.equals(oldUpdatedPolicy.getPolicyName()) && ver.equals(oldUpdatedPolicy.getVersionNo())) {
updated = false;
// Remove the policy from copy.
oldUpdatedLostPolicies.remove(oldUpdatedPolicy);
@@ -135,8 +144,7 @@ public class NotificationStore {
}
// Change the record if the policy has been Removed earlier.
for (RemovedPolicy oldRemovedPolicy : notificationRecord.getRemovedPolicies()) {
- if (oldRemovedPolicy.getPolicyName().equals(policyName)
- && oldRemovedPolicy.getVersionNo().equals(ver)) {
+ if (oldRemovedPolicy.getPolicyName().equals(policyName) && oldRemovedPolicy.getVersionNo().equals(ver)) {
oldRemovedPolicies.remove(oldRemovedPolicy);
}
}
@@ -149,23 +157,23 @@ public class NotificationStore {
return update;
}
- private static Boolean updateRemovedPolicies(ArrayList<StdRemovedPolicy> removedDelta, Collection<LoadedPolicy> oldUpdatedLostPolicies, Collection<RemovedPolicy> oldRemovedPolicies, Collection<LoadedPolicy> oldUpdatedPolicies, Boolean remove, RemovedPolicy newRemovedPolicy) {
- //Look for policy Not in Remove
+ private static Boolean updateRemovedPolicies(ArrayList<StdRemovedPolicy> removedDelta,
+ Collection<LoadedPolicy> oldUpdatedLostPolicies, Collection<RemovedPolicy> oldRemovedPolicies,
+ Collection<LoadedPolicy> oldUpdatedPolicies, Boolean remove, RemovedPolicy newRemovedPolicy) {
+ // Look for policy Not in Remove
Boolean removed = true;
String policyName = newRemovedPolicy.getPolicyName();
String ver = newRemovedPolicy.getVersionNo();
for (RemovedPolicy oldRemovedPolicy : notificationRecord.getRemovedPolicies()) {
- if (policyName.equals(oldRemovedPolicy.getPolicyName())
- && ver.equals(oldRemovedPolicy.getVersionNo())) {
+ if (policyName.equals(oldRemovedPolicy.getPolicyName()) && ver.equals(oldRemovedPolicy.getVersionNo())) {
removed = false;
// Don't want a duplicate.
oldRemovedPolicies.remove(oldRemovedPolicy);
}
}
- //We need to change our record we have an Update record of this remove.
+ // We need to change our record we have an Update record of this remove.
for (LoadedPolicy oldUpdatedPolicy : notificationRecord.getLoadedPolicies()) {
- if (policyName.equals(oldUpdatedPolicy.getPolicyName())
- && ver.equals(oldUpdatedPolicy.getVersionNo())) {
+ if (policyName.equals(oldUpdatedPolicy.getPolicyName()) && ver.equals(oldUpdatedPolicy.getVersionNo())) {
oldUpdatedPolicies.remove(oldUpdatedPolicy);
oldUpdatedLostPolicies.remove(oldUpdatedPolicy);
}
@@ -180,6 +188,11 @@ public class NotificationStore {
return remove;
}
+ /**
+ * recordNotification.
+ *
+ * @param notification StdPDPNotification
+ */
public static void recordNotification(StdPDPNotification notification) {
if (notification == null) {
return;
@@ -187,49 +200,50 @@ public class NotificationStore {
if (notificationRecord.getRemovedPolicies() == null || notificationRecord.getLoadedPolicies() == null) {
notificationRecord = notification;
- } else {
- // Check if there is anything new and update the record.
- if (notificationRecord.getLoadedPolicies() != null || notificationRecord.getRemovedPolicies() != null) {
- HashSet<StdRemovedPolicy> removedPolicies = new HashSet<>();
- for (RemovedPolicy rPolicy : notificationRecord.getRemovedPolicies()) {
- StdRemovedPolicy sRPolicy = new StdRemovedPolicy();
- sRPolicy.setPolicyName(rPolicy.getPolicyName());
- sRPolicy.setVersionNo(rPolicy.getVersionNo());
- removedPolicies.add(sRPolicy);
- }
- HashSet<StdLoadedPolicy> updatedPolicies = new HashSet<>();
- for (LoadedPolicy uPolicy : notificationRecord.getLoadedPolicies()) {
- StdLoadedPolicy sUPolicy = new StdLoadedPolicy();
- sUPolicy.setMatches(uPolicy.getMatches());
- sUPolicy.setPolicyName(uPolicy.getPolicyName());
- sUPolicy.setVersionNo(uPolicy.getVersionNo());
- sUPolicy.setUpdateType(uPolicy.getUpdateType());
- updatedPolicies.add(sUPolicy);
- }
+ return;
+ }
+ // Check if there is anything new and update the record.
+ if (notificationRecord.getLoadedPolicies() != null || notificationRecord.getRemovedPolicies() != null) {
+ HashSet<StdRemovedPolicy> removedPolicies = new HashSet<>();
+ for (RemovedPolicy removedPolicy : notificationRecord.getRemovedPolicies()) {
+ StdRemovedPolicy stdRemovedPolicy = new StdRemovedPolicy();
+ stdRemovedPolicy.setPolicyName(removedPolicy.getPolicyName());
+ stdRemovedPolicy.setVersionNo(removedPolicy.getVersionNo());
+ removedPolicies.add(stdRemovedPolicy);
+ }
+ HashSet<StdLoadedPolicy> updatedPolicies = new HashSet<>();
+ for (LoadedPolicy loadedPolicy : notificationRecord.getLoadedPolicies()) {
+ StdLoadedPolicy stdLoadedPolicy = new StdLoadedPolicy();
+ stdLoadedPolicy.setMatches(loadedPolicy.getMatches());
+ stdLoadedPolicy.setPolicyName(loadedPolicy.getPolicyName());
+ stdLoadedPolicy.setVersionNo(loadedPolicy.getVersionNo());
+ stdLoadedPolicy.setUpdateType(loadedPolicy.getUpdateType());
+ updatedPolicies.add(stdLoadedPolicy);
+ }
- // Checking with the new updated policies.
- if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) {
- checkNewUpdatedPolicies(notification, removedPolicies, updatedPolicies);
- }
- // Checking with New Removed Policies.
- if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) {
- checkNewRemovedPolicies(notification, removedPolicies, updatedPolicies);
- }
- notificationRecord.setRemovedPolicies(removedPolicies);
- notificationRecord.setLoadedPolicies(updatedPolicies);
+ // Checking with the new updated policies.
+ if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) {
+ checkNewUpdatedPolicies(notification, removedPolicies, updatedPolicies);
}
- if (!notificationRecord.getLoadedPolicies().isEmpty() && !notificationRecord.getRemovedPolicies()
- .isEmpty()) {
- notificationRecord.setNotificationType(NotificationType.BOTH);
- } else if (!notificationRecord.getLoadedPolicies().isEmpty()) {
- notificationRecord.setNotificationType(NotificationType.UPDATE);
- } else if (!notificationRecord.getRemovedPolicies().isEmpty()) {
- notificationRecord.setNotificationType(NotificationType.REMOVE);
+ // Checking with New Removed Policies.
+ if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) {
+ checkNewRemovedPolicies(notification, removedPolicies, updatedPolicies);
}
+ notificationRecord.setRemovedPolicies(removedPolicies);
+ notificationRecord.setLoadedPolicies(updatedPolicies);
+ }
+ if (!notificationRecord.getLoadedPolicies().isEmpty()
+ && !notificationRecord.getRemovedPolicies().isEmpty()) {
+ notificationRecord.setNotificationType(NotificationType.BOTH);
+ } else if (!notificationRecord.getLoadedPolicies().isEmpty()) {
+ notificationRecord.setNotificationType(NotificationType.UPDATE);
+ } else if (!notificationRecord.getRemovedPolicies().isEmpty()) {
+ notificationRecord.setNotificationType(NotificationType.REMOVE);
}
}
- private static void checkNewUpdatedPolicies(StdPDPNotification notification, HashSet<StdRemovedPolicy> removedPolicies, HashSet<StdLoadedPolicy> updatedPolicies) {
+ private static void checkNewUpdatedPolicies(StdPDPNotification notification,
+ HashSet<StdRemovedPolicy> removedPolicies, HashSet<StdLoadedPolicy> updatedPolicies) {
for (LoadedPolicy newUpdatedPolicy : notification.getLoadedPolicies()) {
// If it was removed earlier then we need to remove from our record
Iterator<StdRemovedPolicy> oldRemovedPolicy = removedPolicies.iterator();
@@ -237,25 +251,25 @@ public class NotificationStore {
String ver = newUpdatedPolicy.getVersionNo();
while (oldRemovedPolicy.hasNext()) {
RemovedPolicy policy = oldRemovedPolicy.next();
- if (policyName.equals(policy.getPolicyName())
- && ver.equals(policy.getVersionNo())) {
+ if (policyName.equals(policy.getPolicyName()) && ver.equals(policy.getVersionNo())) {
oldRemovedPolicy.remove();
}
}
// If it was previously updated need to Overwrite it to the record.
- updatedPolicies.removeIf(policy -> policyName.equals(policy.getPolicyName())
- && ver.equals(policy.getVersionNo()));
+ updatedPolicies
+ .removeIf(policy -> policyName.equals(policy.getPolicyName()) && ver.equals(policy.getVersionNo()));
- StdLoadedPolicy sUPolicy = new StdLoadedPolicy();
- sUPolicy.setMatches(newUpdatedPolicy.getMatches());
- sUPolicy.setPolicyName(newUpdatedPolicy.getPolicyName());
- sUPolicy.setVersionNo(newUpdatedPolicy.getVersionNo());
- sUPolicy.setUpdateType(newUpdatedPolicy.getUpdateType());
- updatedPolicies.add(sUPolicy);
+ StdLoadedPolicy stdLoadedPolicy = new StdLoadedPolicy();
+ stdLoadedPolicy.setMatches(newUpdatedPolicy.getMatches());
+ stdLoadedPolicy.setPolicyName(newUpdatedPolicy.getPolicyName());
+ stdLoadedPolicy.setVersionNo(newUpdatedPolicy.getVersionNo());
+ stdLoadedPolicy.setUpdateType(newUpdatedPolicy.getUpdateType());
+ updatedPolicies.add(stdLoadedPolicy);
}
}
- private static void checkNewRemovedPolicies(StdPDPNotification notification, HashSet<StdRemovedPolicy> removedPolicies, HashSet<StdLoadedPolicy> updatedPolicies) {
+ private static void checkNewRemovedPolicies(StdPDPNotification notification,
+ HashSet<StdRemovedPolicy> removedPolicies, HashSet<StdLoadedPolicy> updatedPolicies) {
for (RemovedPolicy newRemovedPolicy : notification.getRemovedPolicies()) {
// If it was previously removed Overwrite it to the record.
Iterator<StdRemovedPolicy> oldRemovedPolicy = removedPolicies.iterator();
@@ -263,19 +277,18 @@ public class NotificationStore {
String ver = newRemovedPolicy.getVersionNo();
while (oldRemovedPolicy.hasNext()) {
RemovedPolicy policy = oldRemovedPolicy.next();
- if (policyName.equals(policy.getPolicyName())
- && ver.equals(policy.getVersionNo())) {
+ if (policyName.equals(policy.getPolicyName()) && ver.equals(policy.getVersionNo())) {
oldRemovedPolicy.remove();
}
}
// If it was added earlier then we need to remove from our record.
- updatedPolicies.removeIf(policy -> policyName.equals(policy.getPolicyName())
- && ver.equals(policy.getVersionNo()));
+ updatedPolicies
+ .removeIf(policy -> policyName.equals(policy.getPolicyName()) && ver.equals(policy.getVersionNo()));
- StdRemovedPolicy sRPolicy = new StdRemovedPolicy();
- sRPolicy.setPolicyName(policyName);
- sRPolicy.setVersionNo(ver);
- removedPolicies.add(sRPolicy);
+ StdRemovedPolicy stdRemovedPolicy = new StdRemovedPolicy();
+ stdRemovedPolicy.setPolicyName(policyName);
+ stdRemovedPolicy.setVersionNo(ver);
+ removedPolicies.add(stdRemovedPolicy);
}
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdLoadedPolicy.java b/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdLoadedPolicy.java
index ebbed2100..4d45ebe4e 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdLoadedPolicy.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdLoadedPolicy.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -25,48 +25,48 @@ import java.util.Map;
import org.onap.policy.api.LoadedPolicy;
import org.onap.policy.api.UpdateType;
-public class StdLoadedPolicy implements LoadedPolicy{
- private String policyName = null;
- private String versionNo = null;
- private Map<String,String> matches = null;
- private UpdateType updateType = null;
-
- @Override
- public String getPolicyName() {
- if(policyName!=null && policyName.contains(".xml")){
- return policyName.substring(0, policyName.substring(0, policyName.lastIndexOf('.')).lastIndexOf('.'));
- }
- return this.policyName;
- }
-
- public void setPolicyName(String policyName) {
- this.policyName = policyName;
- }
-
- @Override
- public String getVersionNo() {
- return this.versionNo;
- }
-
- public void setVersionNo(String versionNo) {
- this.versionNo = versionNo;
- }
-
- @Override
- public Map<String,String> getMatches() {
- return this.matches;
- }
-
- public void setMatches(Map<String,String> matches) {
- this.matches = matches;
- }
+public class StdLoadedPolicy implements LoadedPolicy {
+ private String policyName = null;
+ private String versionNo = null;
+ private Map<String, String> matches = null;
+ private UpdateType updateType = null;
- @Override
- public UpdateType getUpdateType() {
- return this.updateType;
- }
-
- public void setUpdateType(UpdateType updateType){
- this.updateType = updateType;
- }
+ @Override
+ public String getPolicyName() {
+ if (policyName != null && policyName.contains(".xml")) {
+ return policyName.substring(0, policyName.substring(0, policyName.lastIndexOf('.')).lastIndexOf('.'));
+ }
+ return this.policyName;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+ @Override
+ public String getVersionNo() {
+ return this.versionNo;
+ }
+
+ public void setVersionNo(String versionNo) {
+ this.versionNo = versionNo;
+ }
+
+ @Override
+ public Map<String, String> getMatches() {
+ return this.matches;
+ }
+
+ public void setMatches(Map<String, String> matches) {
+ this.matches = matches;
+ }
+
+ @Override
+ public UpdateType getUpdateType() {
+ return this.updateType;
+ }
+
+ public void setUpdateType(UpdateType updateType) {
+ this.updateType = updateType;
+ }
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdPDPNotification.java b/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdPDPNotification.java
index 54b9bb0f6..b863fbba5 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdPDPNotification.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdPDPNotification.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -23,6 +23,7 @@ package org.onap.policy.std;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
+
import org.onap.policy.api.LoadedPolicy;
import org.onap.policy.api.NotificationType;
import org.onap.policy.api.PDPNotification;
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdRemovedPolicy.java b/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdRemovedPolicy.java
index 04ec6981b..1a7be3d3c 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdRemovedPolicy.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/std/StdRemovedPolicy.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -22,28 +22,28 @@ package org.onap.policy.std;
import org.onap.policy.api.RemovedPolicy;
-public class StdRemovedPolicy implements RemovedPolicy{
- private String policyName = null;
- private String versionNo = null;
-
- @Override
- public String getVersionNo() {
- return this.versionNo;
- }
-
- public void setVersionNo(String versionNo) {
- this.versionNo = versionNo;
- }
-
- @Override
- public String getPolicyName() {
- if(policyName!=null && policyName.contains(".xml")){
- return policyName.substring(0, policyName.substring(0, policyName.lastIndexOf('.')).lastIndexOf('.'));
- }
- return this.policyName;
- }
-
- public void setPolicyName(String policyName) {
- this.policyName = policyName;
- }
-}
+public class StdRemovedPolicy implements RemovedPolicy {
+ private String policyName = null;
+ private String versionNo = null;
+
+ @Override
+ public String getVersionNo() {
+ return this.versionNo;
+ }
+
+ public void setVersionNo(String versionNo) {
+ this.versionNo = versionNo;
+ }
+
+ @Override
+ public String getPolicyName() {
+ if (policyName != null && policyName.contains(".xml")) {
+ return policyName.substring(0, policyName.substring(0, policyName.lastIndexOf('.')).lastIndexOf('.'));
+ }
+ return this.policyName;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFEnvironment.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFEnvironment.java
index 1fccabcbd..e1849f06b 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFEnvironment.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFEnvironment.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -17,13 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.utils;
public enum AAFEnvironment {
- /*
- * Enumeration for the Resource Node Naming. Add here if required.
- */
- DEVL,
- TEST,
- PROD
+ /*
+ * Enumeration for the Resource Node Naming. Add here if required.
+ */
+ DEVL, TEST, PROD
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyClient.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyClient.java
index e560d0ecc..ab87bc093 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyClient.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyClient.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.utils;
import java.lang.reflect.Method;
@@ -24,17 +25,22 @@ import java.util.Properties;
public interface AAFPolicyClient {
- public boolean checkAuth(String userName, String pass);
- public void updateProperties(Properties properties) throws AAFPolicyException;
- public boolean checkAuthPerm(String mechID, String pass, String type, String instance, String action);
- public boolean checkPerm(String userName, String pass, String type, String instance, String action);
- public static AAFPolicyClient getInstance(Properties properties) throws AAFPolicyException{
- try {
- Class<?> aafPolicyClient = Class.forName(properties.getProperty("aafClient.impl.className", AAFPolicyClientImpl.class.getName()));
- Method method = aafPolicyClient.getMethod("getInstance", Properties.class);
- return (AAFPolicyClient) method.invoke(null, properties);
- } catch (Exception e) {
- throw new AAFPolicyException(e);
- }
- }
+ public boolean checkAuth(String userName, String pass);
+
+ public void updateProperties(Properties properties) throws AAFPolicyException;
+
+ public boolean checkAuthPerm(String mechID, String pass, String type, String instance, String action);
+
+ public boolean checkPerm(String userName, String pass, String type, String instance, String action);
+
+ public static AAFPolicyClient getInstance(Properties properties) throws AAFPolicyException {
+ try {
+ Class<?> aafPolicyClient = Class
+ .forName(properties.getProperty("aafClient.impl.className", AAFPolicyClientImpl.class.getName()));
+ Method method = aafPolicyClient.getMethod("getInstance", Properties.class);
+ return (AAFPolicyClient) method.invoke(null, properties);
+ } catch (Exception e) {
+ throw new AAFPolicyException(e);
+ }
+ }
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyClientImpl.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyClientImpl.java
index 1513507ca..fcdc7e9f8 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyClientImpl.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyClientImpl.java
@@ -2,15 +2,15 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* 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.
@@ -18,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.utils;
import java.security.Principal;
@@ -38,7 +39,7 @@ import org.onap.aaf.cadi.principal.UnAuthPrincipal;
/**
* AAF Client: Generic AAF Client implementation to connect to AAF Resources to
* validate permissions and authorization.
- *
+ *
*/
public class AAFPolicyClientImpl implements AAFPolicyClient {
private static Logger logger = Logger.getLogger(AAFPolicyClientImpl.class.getName());
@@ -60,10 +61,10 @@ public class AAFPolicyClientImpl implements AAFPolicyClient {
* CLIENT_ID, CLIENT_KEY and ENVIRONMENT
*
* @param properties
- * Properties with CLIENT_ID, CLIENT_KEY and ENVIRONMENT
+ * Properties with CLIENT_ID, CLIENT_KEY and ENVIRONMENT
* @return AAFClient instance.
* @throws AAFPolicyException
- * Exceptions.
+ * Exceptions.
*/
public static synchronized AAFPolicyClientImpl getInstance(Properties properties) throws AAFPolicyException {
if (instance == null) {
@@ -83,16 +84,16 @@ public class AAFPolicyClientImpl implements AAFPolicyClient {
logger.error("Required Property value is missing : " + ENVIRONMENT);
throw new AAFPolicyException("Required Property value is missing : " + ENVIRONMENT);
}
- setUpAAF();
+ setUpAaf();
}
/**
* Updates the Properties file in case if required.
*
* @param properties
- * Properties with CLIENT_ID, CLIENT_KEY and ENVIRONMENT
+ * Properties with CLIENT_ID, CLIENT_KEY and ENVIRONMENT
* @throws AAFPolicyException
- * exceptions if any.
+ * exceptions if any.
*/
@Override
public void updateProperties(Properties properties) throws AAFPolicyException {
@@ -103,15 +104,15 @@ public class AAFPolicyClientImpl implements AAFPolicyClient {
* Checks the Authentication and Permissions for the given values.
*
* @param userName
- * Username must be registered under the Name space.
+ * Username must be registered under the Name space.
* @param pass
- * Password pertaining to the Username.
+ * Password pertaining to the Username.
* @param type
- * Permissions Type.
+ * Permissions Type.
* @param instance
- * Permissions Instance.
+ * Permissions Instance.
* @param action
- * Permissions Action.
+ * Permissions Action.
* @return
*/
@Override
@@ -123,9 +124,9 @@ public class AAFPolicyClientImpl implements AAFPolicyClient {
* Checks the Authentication of the UserName and Password Given.
*
* @param userName
- * UserName
+ * UserName
* @param pass
- * Password.
+ * Password.
* @return True or False.
*/
@Override
@@ -134,17 +135,18 @@ public class AAFPolicyClientImpl implements AAFPolicyClient {
return false;
}
try {
- int i = 0;
+ int index = 0;
do {
String aafAuthResponse = aafAuthn.validate(userName, pass);
- if (aafAuthResponse==null) {
+ if (aafAuthResponse == null) {
return true;
} else {
- logger.warn("User, " + userName + ", failed to authenticate with AAF. \n"
- + "AAF Response is " + aafAuthResponse);
+ logger.warn("User, " + userName + ", failed to authenticate with AAF. \n" + "AAF Response is "
+ + aafAuthResponse);
}
- i++;
- } while (i < 2);
+ index++;
+ }
+ while (index < 2);
} catch (Exception e) {
logger.error(e.getMessage() + e);
}
@@ -157,27 +159,27 @@ public class AAFPolicyClientImpl implements AAFPolicyClient {
* Action.
*
* @param userName
- * UserName
+ * UserName
* @param pass
- * Password.
+ * Password.
* @param type
- * Permissions Type.
+ * Permissions Type.
* @param instance
- * Permissions Instance.
+ * Permissions Instance.
* @param action
- * Permissions Action.
+ * Permissions Action.
* @return True or False.
*/
@Override
public boolean checkPerm(String userName, String pass, String type, String instance, String action) {
- int i = 0;
+ int index = 0;
Boolean result = false;
do {
if (aafCon != null && aafLurPerm != null) {
try {
aafCon.basicAuth(userName, pass);
- AAFPermission perm = new AAFPermission(cadiprops.getProperty("policy.aaf.namespace"), type,
- instance, action);
+ AAFPermission perm =
+ new AAFPermission(cadiprops.getProperty("policy.aaf.namespace"), type, instance, action);
final Principal p = new UnAuthPrincipal(userName);
result = aafLurPerm.fish(p, perm);
} catch (CadiException e) {
@@ -185,12 +187,13 @@ public class AAFPolicyClientImpl implements AAFPolicyClient {
aafLurPerm.destroy();
}
}
- i++;
- } while (i < 2 && !result); // Try once more to check if this can be passed. AAF has some issues.
+ index++;
+ }
+ while (index < 2 && !result); // Try once more to check if this can be passed. AAF has some issues.
return result;
}
- private static boolean setUpAAF() {
+ private static boolean setUpAaf() {
try {
aafCon = new AAFConHttp(access,
new PropertyLocator("https://" + cadiprops.getProperty("aaf_fqdn") + ":8100"));
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyException.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyException.java
index b67b02243..c64c3c4d2 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyException.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyException.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -21,30 +21,30 @@
package org.onap.policy.utils;
/**
- * AAFPolicyException to show exception messages.
- *
+ * AAFPolicyException to show exception messages.
+ *
*/
public class AAFPolicyException extends Exception {
- private static final long serialVersionUID = 1910606668038621L;
-
- public AAFPolicyException() {
- // Empty constructor.
- // Nothing needs to be initialized in this exception class.
- }
-
- public AAFPolicyException(String message) {
- super(message);
- }
-
- public AAFPolicyException(Throwable cause){
- super(cause);
- }
-
- public AAFPolicyException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public AAFPolicyException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
+ private static final long serialVersionUID = 1910606668038621L;
+
+ public AAFPolicyException() {
+ // Empty constructor.
+ // Nothing needs to be initialized in this exception class.
+ }
+
+ public AAFPolicyException(String message) {
+ super(message);
+ }
+
+ public AAFPolicyException(Throwable cause) {
+ super(cause);
+ }
+
+ public AAFPolicyException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public AAFPolicyException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpHandler.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpHandler.java
index 4dfc64c39..09cfe7832 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpHandler.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpHandler.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -23,20 +23,24 @@ package org.onap.policy.utils;
import org.onap.policy.api.NotificationHandler;
import org.onap.policy.api.PDPNotification;
-public interface BackUpHandler extends NotificationHandler{
-
- /**
- * <code>notificationReceived</code> method will be triggered automatically whenever a Notification is received by the PEP.
- *
- * @param notification <code>PDPNotification</code> of {@link org.onap.policy.api.PDPNotification} is the object that has information of the notification.
- */
- @Override
- public void notificationReceived(PDPNotification notification);
-
- /**
- * <code>runOnNotification</code> method will be triggered automatically whenever a Notification is received by the PEP This needs to be the main implementation.
- *
- * @param notification <code>PDPNotification</code> of {@link org.onap.policy.api.PDPNotification} is the object that has information of the notification.
- */
- public void runOnNotification(PDPNotification notification);
+public interface BackUpHandler extends NotificationHandler {
+
+ /**
+ * <code>notificationReceived</code> method will be triggered automatically whenever a Notification is received by
+ * the PEP.
+ *
+ * @param notification <code>PDPNotification</code> of {@link org.onap.policy.api.PDPNotification} is the object
+ * that has information of the notification.
+ */
+ @Override
+ public void notificationReceived(PDPNotification notification);
+
+ /**
+ * <code>runOnNotification</code> method will be triggered automatically whenever a Notification is received by the
+ * PEP This needs to be the main implementation.
+ *
+ * @param notification <code>PDPNotification</code> of {@link org.onap.policy.api.PDPNotification} is the object
+ * that has information of the notification.
+ */
+ public void runOnNotification(PDPNotification notification);
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitor.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitor.java
index 4f8a82100..c82e6968f 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitor.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitor.java
@@ -2,15 +2,15 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
* Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* 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.
@@ -21,6 +21,13 @@
package org.onap.policy.utils;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.github.fge.jackson.JsonLoader;
+import com.github.fge.jsonpatch.JsonPatch;
+import com.github.fge.jsonpatch.JsonPatchException;
+import com.github.fge.jsonpatch.diff.JsonDiff;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
@@ -41,16 +48,9 @@ import org.onap.policy.jpa.BackUpMonitorEntity;
import org.onap.policy.std.NotificationStore;
import org.onap.policy.std.StdPDPNotification;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jackson.JsonLoader;
-import com.github.fge.jsonpatch.JsonPatch;
-import com.github.fge.jsonpatch.JsonPatchException;
-import com.github.fge.jsonpatch.diff.JsonDiff;
-
/**
* BackUp Monitor checks Backup Status with the Database and maintains Redundancy for Gateway Applications.
- *
+ *
*/
public class BackUpMonitor {
private static final Logger LOGGER = Logger.getLogger(BackUpMonitor.class.getName());
@@ -58,7 +58,7 @@ public class BackUpMonitor {
private static final String PING_INTERVAL = "ping_interval";
private static final String MASTER = "MASTER";
private static final String SLAVE = "SLAVE";
-
+
private static BackUpMonitor instance = null;
private static String resourceName = null;
private static String resourceNodeName = null;
@@ -85,7 +85,7 @@ public class BackUpMonitor {
throws BackUpMonitorException {
init(resourceName, resourceNodeName, handler);
// Create Persistence Entity
- if(!properties.containsKey(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML)){
+ if (!properties.containsKey(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML)) {
properties.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "META-INF/persistencePU.xml");
}
emf = Persistence.createEntityManagerFactory("PolicyEngineUtils", properties);
@@ -100,15 +100,20 @@ public class BackUpMonitor {
// Start thread.
startThread(new BMonitor());
}
-
- private static void startThread(BMonitor bMonitor) {
- t = new Thread(bMonitor);
+
+ private static void startThread(BMonitor monitor) {
+ t = new Thread(monitor);
t.start();
}
- public static void stop() throws InterruptedException{
+ /**
+ * Stop.
+ *
+ * @throws InterruptedException InterruptedException
+ */
+ public static void stop() throws InterruptedException {
stopFlag = true;
- if(t!=null){
+ if (t != null) {
t.interrupt();
t.join();
}
@@ -124,13 +129,13 @@ public class BackUpMonitor {
/**
* Gets the BackUpMonitor Instance if given proper resourceName and properties. Else returns null.
- *
+ *
* @param resourceNodeName
- * String format of the Resource Node to which the resource Belongs to.
+ * String format of the Resource Node to which the resource Belongs to.
* @param resourceName
- * String format of the ResourceName. This needs to be Unique.
+ * String format of the ResourceName. This needs to be Unique.
* @param properties
- * Properties format of the properties file.
+ * Properties format of the properties file.
* @return BackUpMonitor instance.
*/
public static synchronized BackUpMonitor getInstance(String resourceNodeName, String resourceName,
@@ -164,8 +169,7 @@ public class BackUpMonitor {
LOGGER.error("javax.persistence.jdbc.user property is empty");
return false;
}
- if (properties.getProperty(PING_INTERVAL) == null
- || "".equals(properties.getProperty(PING_INTERVAL).trim())) {
+ if (properties.getProperty(PING_INTERVAL) == null || "".equals(properties.getProperty(PING_INTERVAL).trim())) {
LOGGER.info("ping_interval property not specified. Taking default value");
} else {
try {
@@ -186,8 +190,8 @@ public class BackUpMonitor {
}
/**
- * Gets the Boolean value of Master(True) or Slave mode (False)
- *
+ * Gets the Boolean value of Master(True) or Slave mode (False).
+ *
* @return Boolean flag which if True means that the operation needs to be performed(Master mode) or if false the
* operation is in slave mode.
*/
@@ -214,17 +218,17 @@ public class BackUpMonitor {
}
// Set Master
- private static BackUpMonitorEntity setMaster(BackUpMonitorEntity bMEntity) {
- bMEntity.setFlag(MASTER);
+ private static BackUpMonitorEntity setMaster(BackUpMonitorEntity entity) {
+ entity.setFlag(MASTER);
setFlag(true);
- return bMEntity;
+ return entity;
}
// Set Slave
- private static BackUpMonitorEntity setSlave(BackUpMonitorEntity bMEntity) {
- bMEntity.setFlag(SLAVE);
+ private static BackUpMonitorEntity setSlave(BackUpMonitorEntity entity) {
+ entity.setFlag(SLAVE);
setFlag(false);
- return bMEntity;
+ return entity;
}
// Check Database and set the Flag.
@@ -244,45 +248,45 @@ public class BackUpMonitor {
} else if (resourceNodeName.equals(ResourceNode.BRMS.toString())) {
query.setParameter("nn", ResourceNode.BRMS.toString());
}
- List<?> bMList = query.getResultList();
- if (bMList.isEmpty()) {
+ List<?> entityList = query.getResultList();
+ if (entityList.isEmpty()) {
// This is New. create an entry as Master.
LOGGER.info("Adding resource " + resourceName + " to Database");
- BackUpMonitorEntity bMEntity = new BackUpMonitorEntity();
- bMEntity.setResourceNodeName(resourceNodeName);
- bMEntity.setResourceName(resourceName);
- bMEntity = setMaster(bMEntity);
- bMEntity.setTimeStamp(new Date());
- em.persist(bMEntity);
+ BackUpMonitorEntity entity = new BackUpMonitorEntity();
+ entity.setResourceNodeName(resourceNodeName);
+ entity.setResourceName(resourceName);
+ entity = setMaster(entity);
+ entity.setTimeStamp(new Date());
+ em.persist(entity);
em.flush();
} else {
- checkOtherMaster(bMList);
+ checkOtherMaster(entityList);
}
et.commit();
} catch (Exception e) {
LOGGER.error("failed Database Operation " + e.getMessage(), e);
- if (et!=null && et.isActive()) {
+ if (et != null && et.isActive()) {
et.rollback();
}
throw new BackUpMonitorException(e);
}
}
- private void checkOtherMaster(List<?> bMList) {
+ private void checkOtherMaster(List<?> entityList) {
// Check for other Master(s)
ArrayList<BackUpMonitorEntity> masterEntities = new ArrayList<>();
// Check for self.
BackUpMonitorEntity selfEntity = null;
// Check backup monitor entities.
- for (int i = 0; i < bMList.size(); i++) {
- BackUpMonitorEntity bMEntity = (BackUpMonitorEntity) bMList.get(i);
+ for (Object entity : entityList) {
+ BackUpMonitorEntity backupEntity = (BackUpMonitorEntity) entity;
LOGGER.info("Refreshing Entity. ");
- em.refresh(bMEntity);
- if (bMEntity.getFlag().equalsIgnoreCase(MASTER)) {
- masterEntities.add(bMEntity);
+ em.refresh(backupEntity);
+ if (backupEntity.getFlag().equalsIgnoreCase(MASTER)) {
+ masterEntities.add(backupEntity);
}
- if (bMEntity.getResourceName().equals(resourceName)) {
- selfEntity = bMEntity;
+ if (backupEntity.getResourceName().equals(resourceName)) {
+ selfEntity = backupEntity;
}
}
if (selfEntity != null) {
@@ -338,8 +342,7 @@ public class BackUpMonitor {
if (masterEntities.size() == 1) {
singleMasterEntity(masterEntities, selfEntity);
} else {
- LOGGER.error(
- "Backup Monitor Issue, Masters out of sync, This will be fixed in next interval.");
+ LOGGER.error("Backup Monitor Issue, Masters out of sync, This will be fixed in next interval.");
}
}
}
@@ -365,7 +368,6 @@ public class BackUpMonitor {
em.persist(masterEntity);
em.flush();
// Lets Become Master.
- selfEntity = setMaster(selfEntity);
LOGGER.info("Changing " + resourceName + " from slave to Master Mode");
selfEntity.setTimeStamp(new Date());
selfEntity.setNotificationRecord(notificationRecord);
@@ -383,8 +385,7 @@ public class BackUpMonitor {
if (currentEntity.getFlag().equalsIgnoreCase(MASTER)) {
if (masterEntity == null) {
masterEntity = currentEntity;
- } else if (currentEntity.getTimeStamp().getTime() > masterEntity.getTimeStamp()
- .getTime()) {
+ } else if (currentEntity.getTimeStamp().getTime() > masterEntity.getTimeStamp().getTime()) {
// False Master, Update master to slave and take currentMaster as Master.
masterEntity.setFlag(SLAVE);
masterEntity.setTimeStamp(new Date());
@@ -441,10 +442,8 @@ public class BackUpMonitor {
/**
* Updates Notification in the Database while Performing the health check.
- *
- * @param notification
- * String format of notification record to store in the Database.
- * @throws Exception
+ *
+ * @throws BackUpMonitorException BackUpMonitorException
*/
public synchronized void updateNotification() throws BackUpMonitorException {
checkDataBase();
@@ -454,8 +453,8 @@ public class BackUpMonitor {
private static void callHandler(String notification) {
if (handler != null) {
try {
- PDPNotification notificationObject = PolicyUtils.jsonStringToObject(notification,
- StdPDPNotification.class);
+ PDPNotification notificationObject =
+ PolicyUtils.jsonStringToObject(notification, StdPDPNotification.class);
if (notificationObject.getNotificationType() != null) {
LOGGER.info("Performing Patched notification ");
performPatchNotification(notificationObject);
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitorException.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitorException.java
index 4f7883800..60dd5e569 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitorException.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BackUpMonitorException.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -20,27 +20,28 @@
package org.onap.policy.utils;
-public class BackUpMonitorException extends Exception{
+public class BackUpMonitorException extends Exception {
private static final long serialVersionUID = 6778134503685443473L;
-
+
public BackUpMonitorException() {
- // Nothing for this constructor to initialize
- // in an exception class.
+ // Nothing for this constructor to initialize
+ // in an exception class.
}
-
+
public BackUpMonitorException(String message) {
super(message);
}
-
- public BackUpMonitorException(Throwable cause){
+
+ public BackUpMonitorException(Throwable cause) {
super(cause);
}
-
+
public BackUpMonitorException(String message, Throwable cause) {
super(message, cause);
}
-
- public BackUpMonitorException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+
+ public BackUpMonitorException(String message, Throwable cause, boolean enableSuppression,
+ boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BusConsumer.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BusConsumer.java
index c3fe9023f..b64d6143e 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BusConsumer.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BusConsumer.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
* Modifications copyright (c) 2019 Nokia
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,6 +24,7 @@ package org.onap.policy.utils;
import java.net.MalformedURLException;
import java.util.List;
import java.util.Properties;
+
import org.onap.dmaap.mr.client.MRClient.MRApiException;
import org.onap.dmaap.mr.client.impl.MRConsumerImpl;
import org.onap.dmaap.mr.test.clients.ProtocolTypeConstants;
@@ -31,7 +32,7 @@ import org.onap.dmaap.mr.test.clients.ProtocolTypeConstants;
public interface BusConsumer {
/**
- * fetch messages
+ * fetch messages.
*
* @return list of messages
* @throws MRApiException when error encountered by underlying libraries
@@ -39,22 +40,22 @@ public interface BusConsumer {
Iterable<String> fetch() throws MRApiException;
/**
- * close underlying library consumer
+ * close underlying library consumer.
*/
void close();
/**
- * MR based consumer
+ * MR based consumer.
*/
class DmaapConsumerWrapper implements BusConsumer {
/**
- * MR Consumer
+ * MR Consumer.
*/
protected MRConsumerImpl consumer;
/**
- * MR Consumer Wrapper
+ * MR Consumer Wrapper.
*
* @param servers messaging bus hosts
* @param topic topic
@@ -67,15 +68,12 @@ public interface BusConsumer {
* @param fetchTimeout Fetch Timeout
* @param fetchLimit Fetch Limit
*/
- public DmaapConsumerWrapper(List<String> servers, String topic,
- String aafLogin, String aafPassword,
- String consumerGroup, String consumerInstance,
- int fetchTimeout, int fetchLimit) throws MalformedURLException {
+ public DmaapConsumerWrapper(List<String> servers, String topic, String aafLogin, String aafPassword,
+ String consumerGroup, String consumerInstance, int fetchTimeout, int fetchLimit)
+ throws MalformedURLException {
- this(new MRConsumerImpl(servers, topic,
- consumerGroup, consumerInstance,
- fetchTimeout, fetchLimit,
- null, aafLogin, aafPassword), aafLogin, aafPassword, servers.get(0));
+ this(new MRConsumerImpl(servers, topic, consumerGroup, consumerInstance, fetchTimeout, fetchLimit, null,
+ aafLogin, aafPassword), aafLogin, aafPassword, servers.get(0));
}
@@ -114,14 +112,11 @@ public interface BusConsumer {
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
- builder.
- append("DmaapConsumerWrapper [").
- append("consumer.getAuthDate()=").append(consumer.getAuthDate()).
- append(", consumer.getAuthKey()=").append(consumer.getAuthKey()).
- append(", consumer.getHost()=").append(consumer.getHost()).
- append(", consumer.getProtocolFlag()=").append(consumer.getProtocolFlag()).
- append(", consumer.getUsername()=").append(consumer.getUsername()).
- append("]");
+ builder.append("DmaapConsumerWrapper [").append("consumer.getAuthDate()=").append(consumer.getAuthDate())
+ .append(", consumer.getAuthKey()=").append(consumer.getAuthKey()).append(", consumer.getHost()=")
+ .append(consumer.getHost()).append(", consumer.getProtocolFlag()=")
+ .append(consumer.getProtocolFlag()).append(", consumer.getUsername()=")
+ .append(consumer.getUsername()).append("]");
return builder.toString();
}
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BusPublisher.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BusPublisher.java
index 745213529..f5c792caf 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BusPublisher.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BusPublisher.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
+
import org.onap.dmaap.mr.client.impl.MRSimplerBatchPublisher;
import org.onap.dmaap.mr.test.clients.ProtocolTypeConstants;
import org.onap.policy.common.logging.eelf.PolicyLogger;
@@ -31,109 +32,109 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
public interface BusPublisher {
-
- /**
- * sends a message
- *
- * @param partition id
- * @param message the message
- * @return true if success, false otherwise
- * @throws IllegalArgumentException if no message provided
- */
- public boolean send(String partitionId, String message);
-
- /**
- * closes the publisher
- */
- public void close();
-
- /**
- * DmaapClient library wrapper
- */
- public static class DmaapPublisherWrapper implements BusPublisher {
- private static Logger logger = FlexLogger.getLogger(DmaapPublisherWrapper.class);
- /**
- * MR based Publisher
- */
- protected MRSimplerBatchPublisher publisher;
-
- public DmaapPublisherWrapper(List<String> servers, String topic,
- String aafLogin,
- String aafPassword) {
-
- ArrayList<String> dmaapServers = new ArrayList<>();
- for (String server: servers) {
- dmaapServers.add(server + ":3904");
- }
-
- this.publisher =
- new MRSimplerBatchPublisher.Builder().
- againstUrls(dmaapServers).
- onTopic(topic).
- build();
-
- this.publisher.setProtocolFlag(ProtocolTypeConstants.AAF_AUTH.getValue());
-
- this.publisher.setUsername(aafLogin);
- this.publisher.setPassword(aafPassword);
-
- Properties props = new Properties();
- props.setProperty("Protocol", "http");
- props.setProperty("contenttype", "application/json");
-
- this.publisher.setProps(props);
-
- this.publisher.setHost(servers.get(0));
-
- if (PolicyLogger.isInfoEnabled())
- PolicyLogger.info(DmaapPublisherWrapper.class.getName(),
- "CREATION: " + this);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void close() {
- if (logger.isInfoEnabled())
- logger.info(DmaapPublisherWrapper.class.getName()+
- "CREATION: " + this);
-
- try {
- this.publisher.close(1, TimeUnit.SECONDS);
- } catch (Exception e) {
- logger.warn(DmaapPublisherWrapper.class.getName()+
- "CLOSE: " + this + " because of " +
- e.getMessage(), e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean send(String partitionId, String message){
- if (message == null)
- throw new IllegalArgumentException("No message provided");
-
- this.publisher.send(partitionId, message);
- return true;
-
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("DmaapPublisherWrapper [").
- append("publisher.getAuthDate()=").append(publisher.getAuthDate()).
- append(", publisher.getAuthKey()=").append(publisher.getAuthKey()).
- append(", publisher.getHost()=").append(publisher.getHost()).
- append(", publisher.getProtocolFlag()=").append(publisher.getProtocolFlag()).
- append(", publisher.getUsername()=").append(publisher.getUsername()).
- append(", publisher.getPendingMessageCount()=").append(publisher.getPendingMessageCount()).
- append("]");
- return builder.toString();
- }
- }
+
+ /**
+ * sends a message
+ * .
+ * @param partitionId id
+ * @param message the message
+ * @return true if success, false otherwise
+ * @throws IllegalArgumentException if no message provided
+ */
+ public boolean send(String partitionId, String message);
+
+ /**
+ * closes the publisher.
+ */
+ public void close();
+
+ /**
+ * DmaapClient library wrapper.
+ */
+ public static class DmaapPublisherWrapper implements BusPublisher {
+ private static Logger logger = FlexLogger.getLogger(DmaapPublisherWrapper.class);
+ /**
+ * MR based Publisher.
+ */
+ protected MRSimplerBatchPublisher publisher;
+
+ /**
+ * DmaapPublisherWrapper constructor.
+ *
+ * @param servers list of servers
+ * @param topic topic
+ * @param aafLogin login
+ * @param aafPassword password
+ */
+ public DmaapPublisherWrapper(List<String> servers, String topic, String aafLogin, String aafPassword) {
+
+ ArrayList<String> dmaapServers = new ArrayList<>();
+ for (String server : servers) {
+ dmaapServers.add(server + ":3904");
+ }
+
+ this.publisher = new MRSimplerBatchPublisher.Builder().againstUrls(dmaapServers).onTopic(topic).build();
+
+ this.publisher.setProtocolFlag(ProtocolTypeConstants.AAF_AUTH.getValue());
+
+ this.publisher.setUsername(aafLogin);
+ this.publisher.setPassword(aafPassword);
+
+ Properties props = new Properties();
+ props.setProperty("Protocol", "http");
+ props.setProperty("contenttype", "application/json");
+
+ this.publisher.setProps(props);
+
+ this.publisher.setHost(servers.get(0));
+
+ if (PolicyLogger.isInfoEnabled()) {
+ PolicyLogger.info(DmaapPublisherWrapper.class.getName(), "CREATION: " + this);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void close() {
+ if (logger.isInfoEnabled()) {
+ logger.info(DmaapPublisherWrapper.class.getName() + "CREATION: " + this);
+ }
+
+ try {
+ this.publisher.close(1, TimeUnit.SECONDS);
+ } catch (Exception e) {
+ logger.warn(DmaapPublisherWrapper.class.getName() + "CLOSE: " + this + " because of " + e.getMessage(),
+ e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean send(String partitionId, String message) {
+ if (message == null) {
+ throw new IllegalArgumentException("No message provided");
+ }
+
+ this.publisher.send(partitionId, message);
+ return true;
+
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("DmaapPublisherWrapper [").append("publisher.getAuthDate()=").append(publisher.getAuthDate())
+ .append(", publisher.getAuthKey()=").append(publisher.getAuthKey()).append(", publisher.getHost()=")
+ .append(publisher.getHost()).append(", publisher.getProtocolFlag()=")
+ .append(publisher.getProtocolFlag()).append(", publisher.getUsername()=")
+ .append(publisher.getUsername()).append(", publisher.getPendingMessageCount()=")
+ .append(publisher.getPendingMessageCount()).append("]");
+ return builder.toString();
+ }
+ }
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PeCryptoUtils.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PeCryptoUtils.java
index 9863f03ad..2ffdae159 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PeCryptoUtils.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PeCryptoUtils.java
@@ -20,25 +20,22 @@
package org.onap.policy.utils;
-import java.security.GeneralSecurityException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+
import org.apache.commons.lang3.StringUtils;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.common.utils.security.CryptoUtils;
public class PeCryptoUtils {
- private static Logger logger = FlexLogger.getLogger(PeCryptoUtils.class);
private static final String PROP_AES_KEY = "org.onap.policy.encryption.aes.key";
private static CryptoUtils cryptoUtils = null;
private static String secretKey = System.getenv("AES_ENCRYPTION_KEY");
private static final Map<String, String> decryptCache = new ConcurrentHashMap<>();
private static final Map<String, String> encryptCache = new ConcurrentHashMap<>();
-
- private PeCryptoUtils() {}
+ private PeCryptoUtils() {
+ }
/**
* Inits the aes key.
@@ -65,19 +62,10 @@ public class PeCryptoUtils {
* @return The encrypted String
*/
public static String encrypt(String value) {
-
if (cryptoUtils == null || StringUtils.isBlank(value)) {
return value;
}
-
- return encryptCache.computeIfAbsent(value, k -> {
- try {
- return cryptoUtils.encrypt(k);
- } catch (GeneralSecurityException e) {
- logger.error("Could not decrypt value - exception: ", e);
- return value;
- }
- });
+ return encryptCache.computeIfAbsent(value, cryptoUtils::encrypt);
}
/**
@@ -90,13 +78,6 @@ public class PeCryptoUtils {
if (cryptoUtils == null || StringUtils.isBlank(value)) {
return value;
}
- return decryptCache.computeIfAbsent(value, k -> {
- try {
- return cryptoUtils.decrypt(k);
- } catch (GeneralSecurityException e) {
- logger.error("Could not decrypt value - exception: ", e);
- return value;
- }
- });
+ return decryptCache.computeIfAbsent(value, cryptoUtils::decrypt);
}
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PolicyAccess.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PolicyAccess.java
index 1994578e6..950103c86 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PolicyAccess.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PolicyAccess.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -24,14 +24,13 @@ import java.util.Properties;
import org.onap.aaf.cadi.PropAccess;
-
/**
- * PolicyAccess used by AAF for logging purposes.
- *
+ * PolicyAccess used by AAF for logging purposes.
+ *
*/
public class PolicyAccess extends PropAccess {
- public PolicyAccess (Properties props, Level level) {
- super(props);
- this.setLogLevel(level);
- }
+ public PolicyAccess(Properties props, Level level) {
+ super(props);
+ this.setLogLevel(level);
+ }
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PolicyUtils.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PolicyUtils.java
index 67210c814..9c1294540 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PolicyUtils.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/PolicyUtils.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. 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.
@@ -20,6 +20,12 @@
package org.onap.policy.utils;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.CharMatcher;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonSyntaxException;
+
import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
@@ -38,7 +44,6 @@ import javax.xml.parsers.SAXParserFactory;
import org.drools.core.io.impl.ReaderResource;
import org.drools.verifier.Verifier;
import org.drools.verifier.VerifierError;
-import org.drools.verifier.builder.VerifierBuilder;
import org.drools.verifier.builder.VerifierBuilderFactory;
import org.kie.api.io.ResourceType;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -46,295 +51,288 @@ import org.onap.policy.common.logging.flexlogger.Logger;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.base.CharMatcher;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonSyntaxException;
-
public class PolicyUtils {
private static final Logger LOGGER = FlexLogger.getLogger(PolicyUtils.class);
- public static final String CATCH_EXCEPTION = "PE500: An exception was caught.";
+ public static final String CATCH_EXCEPTION = "PE500: An exception was caught.";
public static final String EMAIL_PATTERN =
- "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
- + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
+ "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
private static final String PACKAGE_ERROR = "mismatched input '{' expecting one of the following tokens: '[package";
public static final String SUCCESS = "success";
-
- private PolicyUtils(){
+
+ private PolicyUtils() {
// Private Constructor
}
-
+
/**
- * Converts an Object to JSON String
- *
- * @param o Object
- * @return String format of Object JSON.
- * @throws JsonProcessingException
+ * Converts an Object to JSON String.
+ *
+ * @param object Object
+ * @return String format of Object JSON.
+ * @throws JsonProcessingException JsonProcessingException
*/
- public static String objectToJsonString(Object o) throws JsonProcessingException{
- ObjectMapper mapper = new ObjectMapper();
- return mapper.writeValueAsString(o);
+ public static String objectToJsonString(Object object) throws JsonProcessingException {
+ return new ObjectMapper().writeValueAsString(object);
}
-
+
/**
- * Converts JSON string into Object
- *
- * @param jsonString
- * @param className equivalent Class of the given JSON string
- * @return T instance of the class given.
- * @throws IOException
+ * Converts JSON string into Object.
+ *
+ * @param jsonString Input JSON String
+ * @param className equivalent Class of the given JSON string
+ * @return T instance of the class given.
+ * @throws IOException IOException
*/
- public static <T> T jsonStringToObject(String jsonString, Class<T> className) throws IOException{
+ public static <T> T jsonStringToObject(String jsonString, Class<T> className) throws IOException {
ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(jsonString, className);
}
-
+
/**
- * Decode a base64 string
- *
- * @param encodedString
+ * Decode a base64 string.
+ *
+ * @param encodedString String to encode
* @return String
- * @throws UnsupportedEncodingException
+ * @throws UnsupportedEncodingException UnsupportedEncodingException
*/
- public static String decode(String encodedString) throws UnsupportedEncodingException {
- if(encodedString!=null && !encodedString.isEmpty()){
- return new String(Base64.getDecoder().decode(encodedString) ,"UTF-8");
- }else{
- return null;
- }
+ public static String decode(String encodedString) throws UnsupportedEncodingException {
+ if (encodedString != null && !encodedString.isEmpty()) {
+ return new String(Base64.getDecoder().decode(encodedString), "UTF-8");
+ } else {
+ return null;
+ }
}
-
+
/**
- * Decodes Basic Authentication
- *
- * @param encodedValue
- * @return
- * @throws UnsupportedEncodingException
+ * Decodes Basic Authentication.
+ *
+ * @param encodedValue value to encode
+ * @return list of String
+ * @throws UnsupportedEncodingException UnsupportedEncodingException
*/
public static String[] decodeBasicEncoding(String encodedValue) throws UnsupportedEncodingException {
- if(encodedValue!=null && encodedValue.contains("Basic ")){
- String encodedUserPassword = encodedValue.replaceFirst("Basic" + " ", "");
+ if (encodedValue != null && encodedValue.contains("Basic ")) {
+ String encodedUserPassword = encodedValue.replaceFirst("Basic" + " ", "");
String usernameAndPassword;
byte[] decodedBytes = Base64.getDecoder().decode(encodedUserPassword);
usernameAndPassword = new String(decodedBytes, "UTF-8");
StringTokenizer tokenizer = new StringTokenizer(usernameAndPassword, ":");
String username = tokenizer.nextToken();
String password = tokenizer.nextToken();
- return new String[]{username, password};
- }else{
- return new String[]{};
+ return new String[] {username, password};
+ } else {
+ return new String[] {};
}
}
-
+
/**
- * Validate a field if contains space or unacceptable policy input and return "success" if good.
- *
- * @param field
- * @return
+ * Validate a field if contains space or unacceptable policy input and return "success" if good.
+ *
+ * @param field String
+ * @return String
*/
- public static String policySpecialCharValidator(String field){
+ public static String policySpecialCharValidator(String field) {
String error;
if ("".equals(field) || field.contains(" ") || !field.matches("^[a-zA-Z0-9_]*$")) {
- error = "The Value in Required Field will allow only '{0-9}, {a-z}, {A-Z}, _' following set of Combinations";
- return error;
+ error = "The Value in Required Field will allow only"
+ + " '{0-9}, {a-z}, {A-Z}, _' following set of Combinations";
+ return error;
}
- return SUCCESS;
- }
-
+ return SUCCESS;
+ }
+
/**
- * Validate a field (accepts space) if it contains unacceptable policy input and return "success" if good.
- *
- * @param field
+ * Validate a field (accepts space) if it contains unacceptable policy input and return "success" if good.
+ *
+ * @param field Input field String
* @return
*/
- public static String policySpecialCharWithSpaceValidator(String field){
+ public static String policySpecialCharWithSpaceValidator(String field) {
String error;
if ("".equals(field) || !field.matches("^[a-zA-Z0-9_ ]*$")) {
- error = "The Value in Required Field will allow only '{0-9}, {a-z}, {A-Z}, _' following set of Combinations";
+ error = "The Value in Required Field will allow only "
+ + "'{0-9}, {a-z}, {A-Z}, _' following set of Combinations";
return error;
}
- return SUCCESS;
- }
-
+ return SUCCESS;
+ }
+
/**
- * Validate a field (accepts Dash) if it contains unacceptable policy input and return "success" if good.
- *
- * @param field
- * @return
+ * Validate a field (accepts Dash) if it contains unacceptable policy input and return "success" if good.
+ *
+ * @param field String
+ * @return String
*/
- public static String policySpecialCharWithDashValidator(String field){
+ public static String policySpecialCharWithDashValidator(String field) {
String error;
if ("".equals(field) || !field.matches("^[a-zA-Z0-9_-]*$")) {
- error = "The Value in Required Field will allow only '{0-9}, {a-z}, {A-Z}, _, -' following set of Combinations";
+ error = "The Value in Required Field will allow only "
+ + "'{0-9}, {a-z}, {A-Z}, _, -' following set of Combinations";
return error;
}
- return SUCCESS;
- }
-
+ return SUCCESS;
+ }
+
/**
- * Validate the XACML description tag and return "success" if good.
- *
- * @param field
- * @return
+ * Validate the XACML description tag and return "success" if good.
+ *
+ * @param field String
+ * @return String
*/
public static String descriptionValidator(String field) {
String error;
if (field.contains("@CreatedBy:") || field.contains("@ModifiedBy:")) {
- error = "The value in the description shouldn't contain @CreatedBy: or @ModifiedBy:";
- return error;
+ error = "The value in the description shouldn't contain @CreatedBy: or @ModifiedBy:";
+ return error;
} else {
error = SUCCESS;
}
- return error;
+ return error;
}
-
+
/**
- * Validate if string contains non ASCII characters
- *
- * @param value
- * @return
+ * Validate if string contains non ASCII characters.
+ *
+ * @param value String
+ * @return true if contains non ASCII characters
*/
public static boolean containsNonAsciiEmptyChars(String value) {
- return (value == null || value.contains(" ") || "".equals(value.trim()) || !CharMatcher.ascii().matchesAllOf((CharSequence) value)) ? true : false;
+ return (value == null || value.contains(" ") || "".equals(value.trim())
+ || !CharMatcher.ascii().matchesAllOf(value)) ? true : false;
}
-
+
/**
- * Validate if given string is an integer.
- *
- * @param number
- * @return
+ * Validate if given string is an integer.
+ *
+ * @param number String representing a number
+ * @return true if integer
*/
- public static Boolean isInteger(String number){
- if(number==null) {
+ public static Boolean isInteger(String number) {
+ if (number == null) {
return false;
}
- for (char c : number.toCharArray()){
+ for (char c : number.toCharArray()) {
if (!Character.isDigit(c)) {
- return false;
+ return false;
}
}
return true;
}
-
+
/**
- * Validate Email Address and return "success" if good.
- *
- * @param emailAddressValue
- * @return
+ * Validate Email Address and return "success" if good.
+ *
+ * @param emailAddressValue String email address
+ * @return SUCCESS String if valid
*/
public static String validateEmailAddress(String emailAddressValue) {
String error = SUCCESS;
List<String> emailList = Arrays.asList(emailAddressValue.split(","));
- for(int i =0 ; i < emailList.size() ; i++){
+ for (int i = 0; i < emailList.size(); i++) {
Pattern pattern = Pattern.compile(EMAIL_PATTERN);
Matcher matcher = pattern.matcher(emailList.get(i).trim());
- if(!matcher.matches()){
- error = "Please check the Following Email Address is not Valid .... " +emailList.get(i);
+ if (!matcher.matches()) {
+ error = "Please check the Following Email Address is not Valid .... " + emailList.get(i);
return error;
- }else{
+ } else {
error = SUCCESS;
}
}
- return error;
+ return error;
}
-
+
/**
* Validates BRMS rule as per Policy Platform and return string contains "[ERR" if there are any errors.
- *
- * @param rule
+ *
+ * @param rule BRMS Rule
* @return String error message
*/
- public static String brmsRawValidate(String rule){
- VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
- Verifier verifier = vBuilder.newVerifier();
+ public static String brmsRawValidate(String rule) {
+ Verifier verifier = VerifierBuilderFactory.newVerifierBuilder().newVerifier();
verifier.addResourcesToVerify(new ReaderResource(new StringReader(rule)), ResourceType.DRL);
- // Check if there are any Errors in Verification.
- if(!verifier.getErrors().isEmpty()){
+ // Check if there are any Errors in Verification.
+ if (!verifier.getErrors().isEmpty()) {
boolean ignore = false;
- StringBuilder message = new StringBuilder("Not a Valid DRL rule");
- for(VerifierError error: verifier.getErrors()){
+ StringBuilder message = new StringBuilder("Not a Valid DRL rule");
+ for (VerifierError error : verifier.getErrors()) {
// Ignore annotations Error Messages
- if(!error.getMessage().contains("'@'") && !error.getMessage().contains(PACKAGE_ERROR)){
- ignore= true;
+ if (!error.getMessage().contains("'@'") && !error.getMessage().contains(PACKAGE_ERROR)) {
+ ignore = true;
message.append("\n" + error.getMessage());
}
}
// Ignore new package names with '{'
// More checks for message to check if its a package error.
- if(ignore && !message.toString().contains("Parser returned a null Package")){
+ if (ignore && !message.toString().contains("Parser returned a null Package")) {
message.append("[ERR 107]");
}
return message.toString();
}
return "";
}
-
+
/**
- * Validates if the given string is proper JSON format.
- *
- * @param data
- * @return
+ * Validates if the given string is proper JSON format.
+ *
+ * @param data JSON data
+ * @return true if it is JSON
*/
public static boolean isJSONValid(String data) {
- try{
+ try {
JsonParser parser = new JsonParser();
parser.parse(data);
- }catch(JsonSyntaxException e){
- LOGGER.error("Exception Occurred While Validating"+e);
+ } catch (JsonSyntaxException e) {
+ LOGGER.error("Exception Occurred While Validating" + e);
return false;
}
return true;
}
/**
- * Validates if the given string is proper XML format.
- *
- * @param data
- * @return
+ * Validates if the given string is proper XML format.
+ *
+ * @param data XML data
+ * @return true if it is XML
*/
public static boolean isXMLValid(String data) {
- if(data == null || data.isEmpty()){
- return false;
+ if (data == null || data.isEmpty()) {
+ return false;
}
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(true);
-
- try {
- factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+
+ try {
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
SAXParser parser = factory.newSAXParser();
XMLReader reader = parser.getXMLReader();
reader.setErrorHandler(new XMLErrorHandler());
reader.parse(new InputSource(new StringReader(data)));
} catch (Exception e) {
- LOGGER.error("Exception Occured While Validating"+e);
+ LOGGER.error("Exception Occured While Validating" + e);
return false;
}
return true;
}
/**
- * Validates if given string is valid Properties format.
- *
- * @param prop
- * @return
+ * Validates if given string is valid Properties format.
+ *
+ * @param prop String of properties
+ * @return is valid property format
*/
public static boolean isPropValid(String prop) {
Scanner scanner = new Scanner(prop);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
line = line.replaceAll("\\s+", "");
- if (line.startsWith("#")) {
- continue;
- } else {
+ if (! line.startsWith("#")) {
if (line.contains("=")) {
String[] parts = line.split("=");
if (parts.length < 2) {
scanner.close();
return false;
}
- } else if(!line.trim().isEmpty()){
+ } else if (!line.trim().isEmpty()) {
scanner.close();
return false;
}
@@ -343,15 +341,15 @@ public class PolicyUtils {
scanner.close();
return true;
}
-
+
/**
* Given a version string consisting of integers with dots between them, convert it into an array of integers.
- *
- * @param version
- * @return
- * @throws NumberFormatException
+ *
+ * @param version String representing the version
+ * @return array of int
+ * @throws NumberFormatException NumberFormatException
*/
- public static int[] versionStringToArray(String version){
+ public static int[] versionStringToArray(String version) {
if (version == null || version.length() == 0) {
return new int[0];
}
@@ -362,4 +360,4 @@ public class PolicyUtils {
}
return resultArray;
}
-} \ No newline at end of file
+}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/XMLErrorHandler.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/XMLErrorHandler.java
index 3037a423c..00251ee2d 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/XMLErrorHandler.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/XMLErrorHandler.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -28,7 +28,7 @@ import org.xml.sax.SAXParseException;
public class XMLErrorHandler implements ErrorHandler {
private static final Logger LOGGER = FlexLogger.getLogger(XMLErrorHandler.class);
-
+
@Override
public void warning(SAXParseException exception) throws SAXException {
LOGGER.debug(exception);
diff --git a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/AAFEnvironmentTest.java b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/AAFEnvironmentTest.java
new file mode 100644
index 000000000..cf997251c
--- /dev/null
+++ b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/AAFEnvironmentTest.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineUtils
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.utils;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class AAFEnvironmentTest {
+
+ @Test
+ public void test() {
+ AAFEnvironment env = AAFEnvironment.DEVL;
+ assertEquals(AAFEnvironment.DEVL, env);
+ env = AAFEnvironment.PROD;
+ assertEquals(AAFEnvironment.PROD, env);
+ env = AAFEnvironment.TEST;
+ assertEquals(AAFEnvironment.TEST, env);
+ }
+
+}
diff --git a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/BusTest.java b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/BusTest.java
index 58262d97c..50d91c6fc 100644
--- a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/BusTest.java
+++ b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/BusTest.java
@@ -2,15 +2,15 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
* Modifications copyright (c) 2019 Nokia
* ================================================================================
* 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.
@@ -35,30 +35,34 @@ import org.onap.dmaap.mr.client.impl.MRConsumerImpl;
import org.onap.policy.utils.BusConsumer.DmaapConsumerWrapper;
public class BusTest {
-
- @Test
- public void busPublisherTest(){
+
+ @Test
+ public void busPublisherTest() {
BusPublisher bus = new BusPublisher.DmaapPublisherWrapper(Arrays.asList("test"), "test", "test", "test");
assertTrue(bus.send("test123", "Hello World!"));
- assertEquals("DmaapPublisherWrapper [publisher.getAuthDate()=null, publisher.getAuthKey()=null, publisher.getHost()=test, publisher.getProtocolFlag()=HTTPAAF, publisher.getUsername()=test, publisher.getPendingMessageCount()=1]",bus.toString());
+ assertEquals(
+ "DmaapPublisherWrapper [publisher.getAuthDate()=null, publisher.getAuthKey()=null, publisher.getHost()=test, publisher.getProtocolFlag()=HTTPAAF, publisher.getUsername()=test, publisher.getPendingMessageCount()=1]",
+ bus.toString());
bus.close();
}
-
- @Test (expected = MRApiException.class)
+
+ @Test(expected = MRApiException.class)
public void busConsumerFailTest() throws Exception {
- //given
+ // given
MRConsumerImpl mrConsumer = mock(MRConsumerImpl.class);
when(mrConsumer.fetch()).thenThrow(new Exception());
DmaapConsumerWrapper dmaapConsumerWrapper = new DmaapConsumerWrapper(mrConsumer, "", "", "");
- //when
+ // when
dmaapConsumerWrapper.fetch();
}
-
+
@Test
- public void busConsumerTest() throws MalformedURLException, MRApiException{
- BusConsumer bus = new BusConsumer.DmaapConsumerWrapper(Arrays.asList("test"), "test", "test", "test", "test", "test", 1, 1);
- assertEquals(bus.toString(),"DmaapConsumerWrapper [consumer.getAuthDate()=null, consumer.getAuthKey()=null, consumer.getHost()=test:3904, consumer.getProtocolFlag()=HTTPAAF, consumer.getUsername()=test]");
+ public void busConsumerTest() throws MalformedURLException, MRApiException {
+ BusConsumer bus = new BusConsumer.DmaapConsumerWrapper(Arrays.asList("test"), "test", "test", "test", "test",
+ "test", 1, 1);
+ assertEquals(bus.toString(),
+ "DmaapConsumerWrapper [consumer.getAuthDate()=null, consumer.getAuthKey()=null, consumer.getHost()=test:3904, consumer.getProtocolFlag()=HTTPAAF, consumer.getUsername()=test]");
bus.close();
}
diff --git a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/PeCryptoUtilsTest.java b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/PeCryptoUtilsTest.java
index 3765ff2e3..28b1fb4e8 100644
--- a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/PeCryptoUtilsTest.java
+++ b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/PeCryptoUtilsTest.java
@@ -22,12 +22,13 @@ package org.onap.policy.utils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+
import java.security.GeneralSecurityException;
+
import org.junit.Before;
import org.junit.Test;
import org.powermock.reflect.Whitebox;
-
public class PeCryptoUtilsTest {
private final String pass = "policy_user";
private final String secretKey = "bmpybWJrbGN4dG9wbGF3Zg==";
@@ -36,7 +37,7 @@ public class PeCryptoUtilsTest {
@Before
public void reset() {
- Whitebox.setInternalState( PeCryptoUtils.class, "cryptoUtils", (PeCryptoUtils)null);
+ Whitebox.setInternalState(PeCryptoUtils.class, "cryptoUtils", (PeCryptoUtils) null);
}
@@ -55,8 +56,8 @@ public class PeCryptoUtilsTest {
PeCryptoUtils.initAesKey(null);
System.clearProperty(PROP_AES_KEY);
assertEquals(pass, PeCryptoUtils.decrypt(encryptedPass));
- Whitebox.setInternalState( PeCryptoUtils.class, "cryptoUtils", (PeCryptoUtils)null);
- Whitebox.setInternalState( PeCryptoUtils.class, "secretKey", secretKey);
+ Whitebox.setInternalState(PeCryptoUtils.class, "cryptoUtils", (PeCryptoUtils) null);
+ Whitebox.setInternalState(PeCryptoUtils.class, "secretKey", secretKey);
PeCryptoUtils.initAesKey(" ");
assertEquals(pass, PeCryptoUtils.decrypt(pass));
}
diff --git a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/AAFClientTest.java b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/AAFClientTest.java
index 2fa822a33..23060688d 100644
--- a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/AAFClientTest.java
+++ b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/AAFClientTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -33,23 +33,33 @@ import org.onap.policy.utils.AAFPolicyException;
public class AAFClientTest {
AAFPolicyClient afClient;
String pass = "test";
-
+ String user = "test";
+
+ /**
+ * setUp.
+ *
+ * @throws AAFPolicyException AAFPolicyException
+ */
@Before
- public void setUp() throws AAFPolicyException{
+ public void setUp() throws AAFPolicyException {
Properties props = new Properties();
props.setProperty("ENVIRONMENT", "TEST");
props.setProperty("aafClient.impl.className", AAFPolicyClientImpl.class.getName());
- afClient = AAFPolicyClient.getInstance(props);
+ afClient = AAFPolicyClient.getInstance(props);
}
-
+
@Test
- public void invalidClientTest() throws AAFPolicyException{
- assertFalse(afClient.checkAuth("test", pass));
- assertFalse(afClient.checkPerm("test", pass, "policy-engine.config", "*", "*"));
+ public void invalidClientTest() throws AAFPolicyException {
+ assertFalse(afClient.checkPerm(null, null, null, null, null));
+ assertFalse(afClient.checkPerm(user, null, null, null, null));
+ assertFalse(afClient.checkAuth(user, pass));
+ assertFalse(afClient.checkAuth(null, pass));
+ assertFalse(afClient.checkAuth(user, null));
+ assertFalse(afClient.checkPerm(user, pass, "policy-engine.config", "*", "*"));
Properties props = new Properties();
props.setProperty("aafClient.impl.className", AAFPolicyClientImpl.class.getName());
- afClient = AAFPolicyClient.getInstance(props);
- assertFalse(afClient.checkAuth("test", pass));
+ afClient = AAFPolicyClient.getInstance(props);
+ assertFalse(afClient.checkAuth(user, pass));
props.setProperty("ENVIRONMENT", "PROD");
props.setProperty("aafClient.impl.className", AAFPolicyClientImpl.class.getName());
afClient.updateProperties(props);
@@ -63,14 +73,14 @@ public class AAFClientTest {
assertFalse(afClient.checkAuth("test", pass));
assertFalse(afClient.checkAuthPerm("test", pass, "decision", "*", "read"));
}
-
+
@Test(expected = AAFPolicyException.class)
- public void invalidAAFInstance() throws AAFPolicyException{
+ public void invalidAafInstance() throws AAFPolicyException {
Properties props = new Properties();
props.setProperty("aafClient.impl.className", "errorClass");
- afClient = AAFPolicyClient.getInstance(props);
+ afClient = AAFPolicyClient.getInstance(props);
}
-
+
@Test(expected = AAFPolicyException.class)
public void testPropNullException() throws AAFPolicyException {
afClient.updateProperties(null);
@@ -80,9 +90,9 @@ public class AAFClientTest {
public void testPropEmptyException() throws AAFPolicyException {
afClient.updateProperties(new Properties());
}
-
+
@Test(expected = AAFPolicyException.class)
- public void testAAFException() throws AAFPolicyException{
+ public void testAafException() throws AAFPolicyException {
new AAFPolicyException();
new AAFPolicyException("error", new Exception());
throw new AAFPolicyException("error", new Exception(), false, false);
diff --git a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/BackUpMonitorEntityTest.java b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/BackUpMonitorEntityTest.java
index f77fe72c9..4bbe008e3 100644
--- a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/BackUpMonitorEntityTest.java
+++ b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/BackUpMonitorEntityTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. 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.
@@ -22,31 +22,33 @@ package org.onap.policy.utils.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+
import java.util.Date;
+
import org.junit.Test;
import org.onap.policy.jpa.BackUpMonitorEntity;
public class BackUpMonitorEntityTest {
- @Test
- public void testEntity() {
- String value = "testVal";
- Date date = new Date();
-
- BackUpMonitorEntity entity = new BackUpMonitorEntity();
- assertNotNull(entity);
-
- entity.setResourceName(value);
- entity.setResourceNodeName(value);
- entity.setFlag(value);
- entity.setNotificationRecord(value);
- entity.prePersist();
- entity.preUpdate();
- entity.setTimeStamp(date);
-
- assertEquals(value, entity.getResourceName());
- assertEquals(value, entity.getResourceNodeName());
- assertEquals(value, entity.getFlag());
- assertEquals(value, entity.getNotificationRecord());
- assertEquals(date, entity.getTimeStamp());
- }
+ @Test
+ public void testEntity() {
+ String value = "testVal";
+
+ BackUpMonitorEntity entity = new BackUpMonitorEntity();
+ assertNotNull(entity);
+
+ entity.setResourceName(value);
+ entity.setResourceNodeName(value);
+ entity.setFlag(value);
+ entity.setNotificationRecord(value);
+ entity.prePersist();
+ entity.preUpdate();
+ Date date = new Date();
+ entity.setTimeStamp(date);
+
+ assertEquals(value, entity.getResourceName());
+ assertEquals(value, entity.getResourceNodeName());
+ assertEquals(value, entity.getFlag());
+ assertEquals(value, entity.getNotificationRecord());
+ assertEquals(date, entity.getTimeStamp());
+ }
}
diff --git a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/BackUpMonitorExceptionTest.java b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/BackUpMonitorExceptionTest.java
index b9700124d..eb56c6f24 100644
--- a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/BackUpMonitorExceptionTest.java
+++ b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/BackUpMonitorExceptionTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. 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.
@@ -21,35 +21,36 @@
package org.onap.policy.utils.test;
import java.io.IOException;
+
import org.junit.Test;
import org.onap.policy.utils.BackUpMonitorException;
public class BackUpMonitorExceptionTest {
- @Test(expected = BackUpMonitorException.class)
- public void testException1() throws BackUpMonitorException {
- throw new BackUpMonitorException();
- }
-
- @Test(expected = BackUpMonitorException.class)
- public void testException2() throws BackUpMonitorException {
- throw new BackUpMonitorException("test");
- }
-
- @Test(expected = BackUpMonitorException.class)
- public void testException3() throws BackUpMonitorException {
- Throwable cause = new IOException();
- throw new BackUpMonitorException(cause);
- }
-
- @Test(expected = BackUpMonitorException.class)
- public void testException4() throws BackUpMonitorException {
- Throwable cause = new IOException();
- throw new BackUpMonitorException("test", cause);
- }
-
- @Test(expected = BackUpMonitorException.class)
- public void testException5() throws BackUpMonitorException {
- Throwable cause = new IOException();
- throw new BackUpMonitorException("test", cause, true, true);
- }
+ @Test(expected = BackUpMonitorException.class)
+ public void testException1() throws BackUpMonitorException {
+ throw new BackUpMonitorException();
+ }
+
+ @Test(expected = BackUpMonitorException.class)
+ public void testException2() throws BackUpMonitorException {
+ throw new BackUpMonitorException("test");
+ }
+
+ @Test(expected = BackUpMonitorException.class)
+ public void testException3() throws BackUpMonitorException {
+ Throwable cause = new IOException();
+ throw new BackUpMonitorException(cause);
+ }
+
+ @Test(expected = BackUpMonitorException.class)
+ public void testException4() throws BackUpMonitorException {
+ Throwable cause = new IOException();
+ throw new BackUpMonitorException("test", cause);
+ }
+
+ @Test(expected = BackUpMonitorException.class)
+ public void testException5() throws BackUpMonitorException {
+ Throwable cause = new IOException();
+ throw new BackUpMonitorException("test", cause, true, true);
+ }
}
diff --git a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/BackUpMonitorTest.java b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/BackUpMonitorTest.java
index 5182c5329..c692ab8c4 100644
--- a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/BackUpMonitorTest.java
+++ b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/BackUpMonitorTest.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import com.fasterxml.jackson.core.JsonProcessingException;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -34,11 +35,13 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
+
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.PersistenceException;
import javax.persistence.Query;
+
import org.apache.commons.io.FileUtils;
import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
@@ -56,7 +59,6 @@ import org.onap.policy.utils.BackUpMonitor.ResourceNode;
import org.onap.policy.utils.BackUpMonitorException;
import org.onap.policy.utils.PolicyUtils;
-
public class BackUpMonitorTest {
@Test(expected = PersistenceException.class)
public void backUpMonitorTestFail() throws Exception {
diff --git a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/DummyBackUpHandler.java b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/DummyBackUpHandler.java
index 15fb33944..232652fa5 100644
--- a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/DummyBackUpHandler.java
+++ b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/DummyBackUpHandler.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -23,16 +23,16 @@ package org.onap.policy.utils.test;
import org.onap.policy.api.PDPNotification;
import org.onap.policy.utils.BackUpHandler;
-public class DummyBackUpHandler implements BackUpHandler{
+public class DummyBackUpHandler implements BackUpHandler {
- @Override
- public void notificationReceived(PDPNotification notification) {
- System.out.println("Received Notification from PDP. ");
- }
+ @Override
+ public void notificationReceived(PDPNotification notification) {
+ System.out.println("Received Notification from PDP. ");
+ }
+
+ @Override
+ public void runOnNotification(PDPNotification notification) {
+ System.out.println("Running main Notification Function. ");
+ }
- @Override
- public void runOnNotification(PDPNotification notification) {
- System.out.println("Running main Notification Function. ");
- }
-
}
diff --git a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/NotificationStoreTest.java b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/NotificationStoreTest.java
index 774bf8a7e..a7e3a9478 100644
--- a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/NotificationStoreTest.java
+++ b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/NotificationStoreTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -38,16 +38,16 @@ import org.onap.policy.std.StdRemovedPolicy;
import org.onap.policy.utils.PolicyUtils;
public class NotificationStoreTest {
-
+
@Test
- public void notificationTest() throws IOException{
- // Notification Delta test first.
+ public void notificationTest() throws IOException {
+ // Notification Delta test first.
NotificationStore.recordNotification(new StdPDPNotification());
- assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}", PolicyUtils.objectToJsonString(NotificationStore.getDeltaNotification(new StdPDPNotification())));
- // Initialize test
+ assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}",
+ PolicyUtils.objectToJsonString(NotificationStore.getDeltaNotification(new StdPDPNotification())));
+ // Initialize test
StdPDPNotification notification = new StdPDPNotification();
notification.setNotificationType(NotificationType.BOTH);
- List<StdLoadedPolicy> loadedPolicies = new ArrayList<>();
StdLoadedPolicy loadedPolicy = new StdLoadedPolicy();
loadedPolicy.setPolicyName("com.testing");
loadedPolicy.setUpdateType(UpdateType.UPDATE);
@@ -55,6 +55,7 @@ public class NotificationStoreTest {
Map<String, String> matches = new HashMap<>();
matches.put("test", "test");
loadedPolicy.setMatches(matches);
+ List<StdLoadedPolicy> loadedPolicies = new ArrayList<>();
loadedPolicies.add(loadedPolicy);
notification.setLoadedPolicies(loadedPolicies);
List<StdRemovedPolicy> removedPolicies = new ArrayList<>();
@@ -64,8 +65,10 @@ public class NotificationStoreTest {
removedPolicies.add(removedPolicy);
notification.setRemovedPolicies(removedPolicies);
NotificationStore.recordNotification(notification);
- assertEquals("{\"removedPolicies\":[{\"policyName\":\"com.testing\",\"versionNo\":\"1\"}],\"loadedPolicies\":[{\"policyName\":\"com.testing\",\"versionNo\":\"2\",\"matches\":{\"test\":\"test\"},\"updateType\":\"UPDATE\"}],\"notificationType\":\"BOTH\"}", PolicyUtils.objectToJsonString(NotificationStore.getNotificationRecord()));
- // Add new Notifications.
+ assertEquals(
+ "{\"removedPolicies\":[{\"policyName\":\"com.testing\",\"versionNo\":\"1\"}],\"loadedPolicies\":[{\"policyName\":\"com.testing\",\"versionNo\":\"2\",\"matches\":{\"test\":\"test\"},\"updateType\":\"UPDATE\"}],\"notificationType\":\"BOTH\"}",
+ PolicyUtils.objectToJsonString(NotificationStore.getNotificationRecord()));
+ // Add new Notifications.
notification = new StdPDPNotification();
notification.setNotificationType(NotificationType.BOTH);
loadedPolicies = new ArrayList<>();
@@ -85,9 +88,12 @@ public class NotificationStoreTest {
removedPolicies.add(removedPolicy);
notification.setRemovedPolicies(removedPolicies);
NotificationStore.recordNotification(notification);
- StdPDPNotification check = NotificationStore.getDeltaNotification(PolicyUtils.jsonStringToObject("{\"removedPolicies\":[{\"policyName\":\"com.testing\",\"versionNo\":\"1\"},{\"policyName\":\"com.testing\",\"versionNo\":\"2\"}],\"loadedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\",\"matches\":{\"test\":\"test\"},\"updateType\":\"NEW\"}],\"notificationType\":\"BOTH\"}", StdPDPNotification.class));
- assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}", PolicyUtils.objectToJsonString(check));
- // Remove Notifications.
+ StdPDPNotification check = NotificationStore.getDeltaNotification(PolicyUtils.jsonStringToObject(
+ "{\"removedPolicies\":[{\"policyName\":\"com.testing\",\"versionNo\":\"1\"},{\"policyName\":\"com.testing\",\"versionNo\":\"2\"}],\"loadedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\",\"matches\":{\"test\":\"test\"},\"updateType\":\"NEW\"}],\"notificationType\":\"BOTH\"}",
+ StdPDPNotification.class));
+ assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}",
+ PolicyUtils.objectToJsonString(check));
+ // Remove Notifications.
notification = new StdPDPNotification();
notification.setNotificationType(NotificationType.REMOVE);
removedPolicies = new ArrayList<>();
@@ -97,9 +103,12 @@ public class NotificationStoreTest {
removedPolicies.add(removedPolicy);
notification.setRemovedPolicies(removedPolicies);
NotificationStore.recordNotification(notification);
- check = NotificationStore.getDeltaNotification(PolicyUtils.jsonStringToObject("{\"removedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\"},{\"policyName\":\"com.testing\",\"versionNo\":\"1\"},{\"policyName\":\"com.testing\",\"versionNo\":\"2\"}],\"loadedPolicies\":[],\"notificationType\":\"REMOVE\"}", StdPDPNotification.class));
- assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}", PolicyUtils.objectToJsonString(check));
- // Remove on remove duplicate Notifications.
+ check = NotificationStore.getDeltaNotification(PolicyUtils.jsonStringToObject(
+ "{\"removedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\"},{\"policyName\":\"com.testing\",\"versionNo\":\"1\"},{\"policyName\":\"com.testing\",\"versionNo\":\"2\"}],\"loadedPolicies\":[],\"notificationType\":\"REMOVE\"}",
+ StdPDPNotification.class));
+ assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}",
+ PolicyUtils.objectToJsonString(check));
+ // Remove on remove duplicate Notifications.
notification = new StdPDPNotification();
notification.setNotificationType(NotificationType.REMOVE);
removedPolicies = new ArrayList<>();
@@ -109,9 +118,12 @@ public class NotificationStoreTest {
removedPolicies.add(removedPolicy);
notification.setRemovedPolicies(removedPolicies);
NotificationStore.recordNotification(notification);
- check = NotificationStore.getDeltaNotification(PolicyUtils.jsonStringToObject("{\"removedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\"},{\"policyName\":\"com.testing\",\"versionNo\":\"1\"},{\"policyName\":\"com.testing\",\"versionNo\":\"2\"}],\"loadedPolicies\":[],\"notificationType\":\"REMOVE\"}", StdPDPNotification.class));
- assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}", PolicyUtils.objectToJsonString(check));
- // Update Notification
+ check = NotificationStore.getDeltaNotification(PolicyUtils.jsonStringToObject(
+ "{\"removedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\"},{\"policyName\":\"com.testing\",\"versionNo\":\"1\"},{\"policyName\":\"com.testing\",\"versionNo\":\"2\"}],\"loadedPolicies\":[],\"notificationType\":\"REMOVE\"}",
+ StdPDPNotification.class));
+ assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}",
+ PolicyUtils.objectToJsonString(check));
+ // Update Notification
notification = new StdPDPNotification();
notification.setNotificationType(NotificationType.UPDATE);
loadedPolicies = new ArrayList<>();
@@ -125,9 +137,12 @@ public class NotificationStoreTest {
loadedPolicies.add(loadedPolicy);
notification.setLoadedPolicies(loadedPolicies);
NotificationStore.recordNotification(notification);
- check = NotificationStore.getDeltaNotification(PolicyUtils.jsonStringToObject("{\"removedPolicies\":[{\"policyName\":\"com.testing\",\"versionNo\":\"1\"},{\"policyName\":\"com.testing\",\"versionNo\":\"2\"}],\"loadedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\",\"matches\":{\"test\":\"test\"},\"updateType\":\"NEW\"}],\"notificationType\":\"BOTH\"}", StdPDPNotification.class));
- assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}", PolicyUtils.objectToJsonString(check));
- // Update on update duplicate Notification
+ check = NotificationStore.getDeltaNotification(PolicyUtils.jsonStringToObject(
+ "{\"removedPolicies\":[{\"policyName\":\"com.testing\",\"versionNo\":\"1\"},{\"policyName\":\"com.testing\",\"versionNo\":\"2\"}],\"loadedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\",\"matches\":{\"test\":\"test\"},\"updateType\":\"NEW\"}],\"notificationType\":\"BOTH\"}",
+ StdPDPNotification.class));
+ assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}",
+ PolicyUtils.objectToJsonString(check));
+ // Update on update duplicate Notification
notification = new StdPDPNotification();
notification.setNotificationType(NotificationType.UPDATE);
loadedPolicies = new ArrayList<>();
@@ -141,9 +156,12 @@ public class NotificationStoreTest {
loadedPolicies.add(loadedPolicy);
notification.setLoadedPolicies(loadedPolicies);
NotificationStore.recordNotification(notification);
- check = NotificationStore.getDeltaNotification(PolicyUtils.jsonStringToObject("{\"removedPolicies\":[{\"policyName\":\"com.testing\",\"versionNo\":\"1\"},{\"policyName\":\"com.testing\",\"versionNo\":\"2\"}],\"loadedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\",\"matches\":{\"test\":\"test\"},\"updateType\":\"NEW\"}],\"notificationType\":\"BOTH\"}", StdPDPNotification.class));
- assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}", PolicyUtils.objectToJsonString(check));
- //
+ check = NotificationStore.getDeltaNotification(PolicyUtils.jsonStringToObject(
+ "{\"removedPolicies\":[{\"policyName\":\"com.testing\",\"versionNo\":\"1\"},{\"policyName\":\"com.testing\",\"versionNo\":\"2\"}],\"loadedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\",\"matches\":{\"test\":\"test\"},\"updateType\":\"NEW\"}],\"notificationType\":\"BOTH\"}",
+ StdPDPNotification.class));
+ assertEquals("{\"removedPolicies\":[],\"loadedPolicies\":[],\"notificationType\":null}",
+ PolicyUtils.objectToJsonString(check));
+ //
// Notification Delta Tests
//
notification = new StdPDPNotification();
@@ -165,7 +183,9 @@ public class NotificationStoreTest {
removedPolicies.add(removedPolicy);
notification.setRemovedPolicies(removedPolicies);
check = NotificationStore.getDeltaNotification(notification);
- assertEquals("{\"removedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\"}],\"loadedPolicies\":[{\"policyName\":\"com.testing\",\"versionNo\":\"3\",\"matches\":{\"test\":\"test\"},\"updateType\":\"NEW\"}],\"notificationType\":\"BOTH\"}", PolicyUtils.objectToJsonString(check));
+ assertEquals(
+ "{\"removedPolicies\":[{\"policyName\":\"com.test\",\"versionNo\":\"3\"}],\"loadedPolicies\":[{\"policyName\":\"com.testing\",\"versionNo\":\"3\",\"matches\":{\"test\":\"test\"},\"updateType\":\"NEW\"}],\"notificationType\":\"BOTH\"}",
+ PolicyUtils.objectToJsonString(check));
}
}
diff --git a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/PEDependencyTest.java b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/PEDependencyTest.java
index 4cc6c90f2..e3cf67f30 100644
--- a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/PEDependencyTest.java
+++ b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/PEDependencyTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* PolicyEngineUtils
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. 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.
@@ -30,9 +30,9 @@ import org.junit.Test;
import org.onap.policy.api.PEDependency;
public class PEDependencyTest {
-
+
@Test
- public void pojoTests(){
+ public void pojoTests() {
PEDependency pe = new PEDependency();
pe.setArtifactId("test");
pe.setGroupId("test");
@@ -41,10 +41,10 @@ public class PEDependencyTest {
pe.setScope("test");
pe.setClassifier("pom");
List<Exclusion> exclusions = new ArrayList<>();
- Exclusion e = new Exclusion();
- e.setArtifactId("ex1");
- e.setGroupId("eG");
- exclusions.add(e);
+ Exclusion exclusion = new Exclusion();
+ exclusion.setArtifactId("ex1");
+ exclusion.setGroupId("eG");
+ exclusions.add(exclusion);
pe.setExclusions(exclusions);
pe.getDependency();
assertEquals(exclusions, pe.getExclusions());
diff --git a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/PolicyUtilsTest.java b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/PolicyUtilsTest.java
index 8445ad7c8..8d9116d32 100644
--- a/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/PolicyUtilsTest.java
+++ b/PolicyEngineUtils/src/test/java/org/onap/policy/utils/test/PolicyUtilsTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -45,165 +45,162 @@ import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public class PolicyUtilsTest {
-
- private static final String ERROR = "The Value in Required Field will allow only '{0-9}, {a-z}, {A-Z}, _' following set of Combinations";
- private static final String SUCCESS = "success";
-
- @Test
- public void testJsonConversions() throws Exception{
- StdPDPNotification notification = new StdPDPNotification();
- notification.setNotificationType(NotificationType.BOTH);
- Collection<StdRemovedPolicy> removedPolicies = new ArrayList<>();
- Collection<StdLoadedPolicy> loadedPolicies = new ArrayList<>();
- StdRemovedPolicy removedPolicy = new StdRemovedPolicy();
- StdLoadedPolicy updatedPolicy = new StdLoadedPolicy();
- removedPolicy.setPolicyName("Test");
- removedPolicy.setVersionNo("1");
- removedPolicies.add(removedPolicy);
- updatedPolicy.setPolicyName("Testing");
- updatedPolicy.setVersionNo("1");
- updatedPolicy.setUpdateType(UpdateType.NEW);
- Map<String, String> matches = new HashMap<>();
- matches.put("key", "value");
- updatedPolicy.setMatches(matches);
- loadedPolicies.add(updatedPolicy);
- notification.setRemovedPolicies(removedPolicies);
- notification.setLoadedPolicies(loadedPolicies);
-
- String json = PolicyUtils.objectToJsonString(notification);
- PDPNotification getBackObject = PolicyUtils.jsonStringToObject(json, StdPDPNotification.class);
- assertEquals(0,getBackObject.getNotificationType().compareTo(notification.getNotificationType()));
-
- }
-
- private String encodedValue(String input){
- return new String(Base64.getEncoder().encode(input.getBytes()));
- }
-
- @Test
- public void testDecode() throws Exception{
- String value = "test";
- assertEquals(value, PolicyUtils.decode(encodedValue(value)));
- assertNull(PolicyUtils.decode(null));
- assertNull(PolicyUtils.decode(""));
- }
-
- @Test
- public void testBasicEncoding() throws Exception{
- String userName = "test";
- String key = "pass";
- String[] decodedValue = PolicyUtils.decodeBasicEncoding("Basic "+encodedValue(userName+":"+key));
- assertEquals(userName,decodedValue[0]);
- assertEquals(key,decodedValue[1]);
- assertEquals(0, PolicyUtils.decodeBasicEncoding(encodedValue(userName+":"+key)).length);
- assertEquals(0, PolicyUtils.decodeBasicEncoding(null).length);
- }
-
- @Test
- public void testSpecialCharValidator(){
- assertEquals(ERROR, PolicyUtils.policySpecialCharValidator("$TEST_"));
- assertEquals(ERROR, PolicyUtils.policySpecialCharValidator("$TEST _"));
- assertEquals(ERROR, PolicyUtils.policySpecialCharValidator(""));
- assertEquals(ERROR, PolicyUtils.policySpecialCharValidator("TæST"));
- assertEquals(SUCCESS, PolicyUtils.policySpecialCharValidator("TEST"));
- }
-
- @Test
- public void testSpecialCharWithSpaceValidator(){
- assertEquals(ERROR, PolicyUtils.policySpecialCharWithSpaceValidator(""));
- assertEquals(ERROR, PolicyUtils.policySpecialCharWithSpaceValidator("$TEST _"));
- assertEquals(SUCCESS, PolicyUtils.policySpecialCharWithSpaceValidator("TE ST"));
- }
-
- @Test
- public void testDescription() {
- assertEquals(SUCCESS, PolicyUtils.descriptionValidator("Test"));
- assertNotEquals(SUCCESS, PolicyUtils.descriptionValidator("@ModifiedBy:TesterB"));
- assertNotEquals(SUCCESS, PolicyUtils.descriptionValidator("@CreatedBy:TesterA"));
- }
-
- @Test
- public void testNonAscii(){
- assertTrue(PolicyUtils.containsNonAsciiEmptyChars(null));
- assertTrue(PolicyUtils.containsNonAsciiEmptyChars(""));
- assertTrue(PolicyUtils.containsNonAsciiEmptyChars("T æST"));
- assertTrue(PolicyUtils.containsNonAsciiEmptyChars("TæST"));
- assertFalse(PolicyUtils.containsNonAsciiEmptyChars("TEST"));
- }
-
- @Test
- public void testInteger(){
- assertFalse(PolicyUtils.isInteger(null));
- assertTrue(PolicyUtils.isInteger("123"));
- assertFalse(PolicyUtils.isInteger("1a23"));
- }
-
- @Test
- public void testEmailAddress(){
- assertEquals(SUCCESS, PolicyUtils.validateEmailAddress("test@onap.org"));
- assertNotEquals(SUCCESS, PolicyUtils.validateEmailAddress("test@onap"));
- }
-
- @Test
- public void testBRMSValidate(){
- String rule = "package com.sample;\n"
- + "import com.sample.DroolsTest.Message;\n"
- + "declare Params\n"
- + "samPoll : int\n"
- + "value : String\n"
- + "end\n"
- + "///This Rule will be generated by the UI.\n"
- + "rule \"Create parameters structure\"\n"
- + "salience 1000 \n"
- + "when\n"
- + "then\n"
- + "Params params = new Params();\n"
- + "params.setSamPoll(76);\n"
- + "params.setValue(\"test\");\n"
- + "insertLogical(params);\n"
- + "end\n"
- + "rule \"Rule 1: Check parameter structure access from when/then\"\n"
- + "when\n"
- + "$param: Params()\n"
- + "Params($param.samPoll > 50)\n"
- + "then\n"
- + "System.out.println(\"Firing rule 1\");\n"
- + "System.out.println($param);\n"
- + "end\n";
- assertEquals(PolicyUtils.brmsRawValidate(rule),"");
- assertTrue(PolicyUtils.brmsRawValidate("error").contains("[ERR"));
- assertFalse(PolicyUtils.brmsRawValidate("package com.att.ecomp.policy.controlloop.p_${unique};").contains("[ERR"));
- }
-
- @Test
- public void testiIsJsonValid(){
- assertTrue(PolicyUtils.isJSONValid("{\"test\":\"test\"}"));
- String value = "{\"test\":\"test\", \"t1\": {\"test\": 12 , \"t2\":\"34\"},\"t2\":[{\"test\":\"val\"}]}";
- assertTrue(PolicyUtils.isJSONValid(value));
- assertFalse(PolicyUtils.isJSONValid("{\"test\":\"test"));
- }
-
- @Test
- public void testIsXMLValid() throws SAXException{
- XMLErrorHandler error = new XMLErrorHandler();
+
+ private static final String ERROR =
+ "The Value in Required Field will allow only '{0-9}, {a-z}, {A-Z}, _' following set of Combinations";
+ private static final String SUCCESS = "success";
+
+ @Test
+ public void testJsonConversions() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+ notification.setNotificationType(NotificationType.BOTH);
+ Collection<StdRemovedPolicy> removedPolicies = new ArrayList<>();
+ StdRemovedPolicy removedPolicy = new StdRemovedPolicy();
+ removedPolicy.setPolicyName("Test");
+ removedPolicy.setVersionNo("1");
+ removedPolicies.add(removedPolicy);
+ StdLoadedPolicy updatedPolicy = new StdLoadedPolicy();
+ updatedPolicy.setPolicyName("Testing");
+ updatedPolicy.setVersionNo("1");
+ updatedPolicy.setUpdateType(UpdateType.NEW);
+ Map<String, String> matches = new HashMap<>();
+ matches.put("key", "value");
+ updatedPolicy.setMatches(matches);
+ Collection<StdLoadedPolicy> loadedPolicies = new ArrayList<>();
+ loadedPolicies.add(updatedPolicy);
+ notification.setRemovedPolicies(removedPolicies);
+ notification.setLoadedPolicies(loadedPolicies);
+
+ String json = PolicyUtils.objectToJsonString(notification);
+ PDPNotification getBackObject = PolicyUtils.jsonStringToObject(json, StdPDPNotification.class);
+ assertEquals(0, getBackObject.getNotificationType().compareTo(notification.getNotificationType()));
+
+ }
+
+ private String encodedValue(String input) {
+ return new String(Base64.getEncoder().encode(input.getBytes()));
+ }
+
+ @Test
+ public void testDecode() throws Exception {
+ String value = "test";
+ assertEquals(value, PolicyUtils.decode(encodedValue(value)));
+ assertNull(PolicyUtils.decode(null));
+ assertNull(PolicyUtils.decode(""));
+ }
+
+ @Test
+ public void testBasicEncoding() throws Exception {
+ String userName = "test";
+ String key = "pass";
+ String[] decodedValue = PolicyUtils.decodeBasicEncoding("Basic " + encodedValue(userName + ":" + key));
+ assertEquals(userName, decodedValue[0]);
+ assertEquals(key, decodedValue[1]);
+ assertEquals(0, PolicyUtils.decodeBasicEncoding(encodedValue(userName + ":" + key)).length);
+ assertEquals(0, PolicyUtils.decodeBasicEncoding(null).length);
+ }
+
+ @Test
+ public void testSpecialCharValidator() {
+ assertEquals(ERROR, PolicyUtils.policySpecialCharValidator("$TEST_"));
+ assertEquals(ERROR, PolicyUtils.policySpecialCharValidator("$TEST _"));
+ assertEquals(ERROR, PolicyUtils.policySpecialCharValidator(""));
+ assertEquals(ERROR, PolicyUtils.policySpecialCharValidator("TæST"));
+ assertEquals(SUCCESS, PolicyUtils.policySpecialCharValidator("TEST"));
+ }
+
+ @Test
+ public void testSpecialCharWithSpaceValidator() {
+ assertEquals(ERROR, PolicyUtils.policySpecialCharWithSpaceValidator(""));
+ assertEquals(ERROR, PolicyUtils.policySpecialCharWithSpaceValidator("$TEST _"));
+ assertEquals(SUCCESS, PolicyUtils.policySpecialCharWithSpaceValidator("TE ST"));
+ }
+
+ @Test
+ public void testDescription() {
+ assertEquals(SUCCESS, PolicyUtils.descriptionValidator("Test"));
+ assertNotEquals(SUCCESS, PolicyUtils.descriptionValidator("@ModifiedBy:TesterB"));
+ assertNotEquals(SUCCESS, PolicyUtils.descriptionValidator("@CreatedBy:TesterA"));
+ }
+
+ @Test
+ public void testNonAscii() {
+ assertTrue(PolicyUtils.containsNonAsciiEmptyChars(null));
+ assertTrue(PolicyUtils.containsNonAsciiEmptyChars(""));
+ assertTrue(PolicyUtils.containsNonAsciiEmptyChars("T æST"));
+ assertTrue(PolicyUtils.containsNonAsciiEmptyChars("TæST"));
+ assertFalse(PolicyUtils.containsNonAsciiEmptyChars("TEST"));
+ }
+
+ @Test
+ public void testInteger() {
+ assertFalse(PolicyUtils.isInteger(null));
+ assertTrue(PolicyUtils.isInteger("123"));
+ assertFalse(PolicyUtils.isInteger("1a23"));
+ }
+
+ @Test
+ public void testEmailAddress() {
+ assertEquals(SUCCESS, PolicyUtils.validateEmailAddress("test@onap.org"));
+ assertNotEquals(SUCCESS, PolicyUtils.validateEmailAddress("test@onap"));
+ }
+
+ @Test
+ public void testBrmsValidate() {
+ String rule = "package com.sample;\n" + "import com.sample.DroolsTest.Message;\n" + "declare Params\n"
+ + "samPoll : int\n" + "value : String\n" + "end\n" + "///This Rule will be generated by the UI.\n"
+ + "rule \"Create parameters structure\"\n" + "salience 1000 \n" + "when\n" + "then\n"
+ + "Params params = new Params();\n" + "params.setSamPoll(76);\n" + "params.setValue(\"test\");\n"
+ + "insertLogical(params);\n" + "end\n"
+ + "rule \"Rule 1: Check parameter structure access from when/then\"\n" + "when\n" + "$param: Params()\n"
+ + "Params($param.samPoll > 50)\n" + "then\n" + "System.out.println(\"Firing rule 1\");\n"
+ + "System.out.println($param);\n" + "end\n";
+ assertEquals(PolicyUtils.brmsRawValidate(rule), "");
+ assertTrue(PolicyUtils.brmsRawValidate("error").contains("[ERR"));
+ assertFalse(
+ PolicyUtils.brmsRawValidate("package com.att.ecomp.policy.controlloop.p_${unique};").contains("[ERR"));
+ }
+
+ @Test
+ public void testiIsJsonValid() {
+ assertTrue(PolicyUtils.isJSONValid("{\"test\":\"test\"}"));
+ String value = "{\"test\":\"test\", \"t1\": {\"test\": 12 , \"t2\":\"34\"},\"t2\":[{\"test\":\"val\"}]}";
+ assertTrue(PolicyUtils.isJSONValid(value));
+ assertFalse(PolicyUtils.isJSONValid("{\"test\":\"test"));
+ }
+
+ @Test
+ public void testIsXmlValid() throws SAXException {
+ assertFalse(PolicyUtils.isXMLValid(null));
+ assertFalse(PolicyUtils.isXMLValid(""));
+ XMLErrorHandler error = new XMLErrorHandler();
error.error(new SAXParseException(null, null));
error.warning(new SAXParseException(null, null));
- assertTrue(PolicyUtils.isXMLValid("<test>123</test>"));
- assertFalse(PolicyUtils.isXMLValid("<test>123</test"));
- }
-
- @Test
- public void testIsPropValid(){
+ assertTrue(PolicyUtils.isXMLValid("<test>123</test>"));
+ assertFalse(PolicyUtils.isXMLValid("<test>123</test"));
+ }
+
+ @Test
+ public void testIsPropValid() {
assertTrue(PolicyUtils.isPropValid("test=123\n\tval=123"));
assertFalse(PolicyUtils.isPropValid("test"));
assertFalse(PolicyUtils.isPropValid("test="));
assertTrue(PolicyUtils.isPropValid("#test\n\nval=123"));
- }
-
- @Test
- public void testVersionStringToArray(){
- assertTrue(PolicyUtils.versionStringToArray(null).length==0);
- assertTrue(PolicyUtils.versionStringToArray("").length==0);
- assertTrue(PolicyUtils.versionStringToArray("1.2.3").length==3);
- }
-} \ No newline at end of file
+ }
+
+ @Test
+ public void testVersionStringToArray() {
+ assertTrue(PolicyUtils.versionStringToArray(null).length == 0);
+ assertTrue(PolicyUtils.versionStringToArray("").length == 0);
+ assertTrue(PolicyUtils.versionStringToArray("1.2.3").length == 3);
+ }
+
+ @Test
+ public void testSpecialChar() {
+ assertEquals(PolicyUtils.SUCCESS, PolicyUtils.policySpecialCharWithDashValidator("test"));
+ assertEquals(PolicyUtils.SUCCESS, PolicyUtils.policySpecialCharWithDashValidator("test-"));
+ assertEquals(PolicyUtils.SUCCESS, PolicyUtils.policySpecialCharWithDashValidator("test_"));
+ assertNotEquals(PolicyUtils.SUCCESS, PolicyUtils.policySpecialCharWithDashValidator(""));
+ assertNotEquals(PolicyUtils.SUCCESS, PolicyUtils.policySpecialCharWithDashValidator("test*"));
+ }
+}
diff --git a/onap-java-formatter.xml b/onap-java-formatter.xml
deleted file mode 100644
index 1dd9de63c..000000000
--- a/onap-java-formatter.xml
+++ /dev/null
@@ -1,295 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<profiles version="12">
-<profile kind="CodeFormatterProfile" name="onap-java-formatter" version="12">
-<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
-<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8"/>
-<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8"/>
-<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
-<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
-<setting id="org.eclipse.jdt.core.compiler.source" value="1.8"/>
-<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="48"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="0"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="0"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="2"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
-<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
-<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
-<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
-<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
-<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
-<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
-<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
-<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
-</profile>
-</profiles>