aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2018-02-21 17:50:16 +0000
committerGerrit Code Review <gerrit@onap.org>2018-02-21 17:50:16 +0000
commit84c300435499e438bdfc9c30fe0988c7105d5b35 (patch)
treefdae02477e12482bdfff43b44cc0b23b1a0befe7
parent881074dbf97b3a2d52d28fdd404e083b8e974d0d (diff)
parent5450bdbfb94fb5217617da6c41971fd26f7e81b5 (diff)
Merge "JUnit test for policy/engine PolicyEngineAPI"
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyCondition.java57
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryType.java144
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyClass.java68
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java97
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecision.java69
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponseStatus.java108
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyType.java79
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/RuleProvider.java86
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/models/APIDictionaryResponse.java22
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/std/MatchStore.java342
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/std/Matches.java79
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/std/NotificationUnMarshal.java80
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchStoreTest.java1174
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchesTest.java369
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationUnMarshalTest.java505
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyConfigTest.java1545
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/APIDictionaryResponseTest.java50
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyConditionTest.java103
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyParametersTest.java449
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/DictionaryTypeTest.java35
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyClassTest.java107
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigStatusTest.java171
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionTest.java98
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseStatusTest.java278
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyTypeTest.java114
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/RuleProviderTest.java37
26 files changed, 2973 insertions, 3293 deletions
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyCondition.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyCondition.java
index 117ac716e..34b481719 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyCondition.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyCondition.java
@@ -29,38 +29,41 @@ import com.fasterxml.jackson.annotation.JsonCreator;
* @version 0.1
*/
public enum DeletePolicyCondition {
-
- /**
- * Indicates a condition to only delete the current version of the policy.
- */
- ONE("Current Version"),
-
- /**
- * Indicates a condition to delete all versions of the policy.
- */
- ALL("All Versions");
- private String name;
- private DeletePolicyCondition(String name){
- this.name = name;
- }
+ /**
+ * Indicates a condition to only delete the current version of the policy.
+ */
+ ONE("Current Version"),
- /**
- * Returns the <code>String</code> format of delete condition for this Policy
- * @return the <code>String</code> of the delete condition for this Policy
- */
- @Override
- public String toString(){
- return this.name;
- }
+ /**
+ * Indicates a condition to delete all versions of the policy.
+ */
+ ALL("All Versions");
- @JsonCreator
- public static DeletePolicyCondition create (String value) {
- for(DeletePolicyCondition type: values()){
- if(type.toString().equals(value) || type.equals(DeletePolicyCondition.valueOf(value))){
+ private final String name;
+
+ private DeletePolicyCondition(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the <code>String</code> format of delete condition for this
+ * Policy
+ *
+ * @return the <code>String</code> of the delete condition for this Policy
+ */
+ @Override
+ public String toString() {
+ return this.name;
+ }
+
+ @JsonCreator
+ public static DeletePolicyCondition create(final String value) {
+ for (final DeletePolicyCondition type : values()) {
+ if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
return type;
}
}
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Invalid value: " + value);
}
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryType.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryType.java
index 499295d65..56b73221f 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryType.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryType.java
@@ -22,80 +22,82 @@ package org.onap.policy.api;
import com.fasterxml.jackson.annotation.JsonCreator;
-public enum DictionaryType{
- /**
- * Indicates Common Dictionaries.
- */
- Common("Common"),
- /**
- * Indicates Action Policy Dictionaries
- */
- Action("Action"),
- /**
- * Indicates ClosedLoop Policy Dictionaries.
- */
- ClosedLoop("ClosedLoop"),
- /**
- * Indicates Firewall Config Policy Dictionaries.
- */
- Firewall("Firewall"),
- /**
- * Indicates Decision Policy Dictionaries.
- */
- Decision("Decision"),
- /**
- * Indicates BRMS Policy Dictionaries.
- */
- BRMS("BRMS"),
- /**
- * Indicates DCAE Micro Service Policy Dictionaries.
- */
- MicroService("MicroService"),
- /**
- * Indicates Descriptive Scope Dictionaries
- */
- DescriptiveScope("DescriptiveScope"),
- /**
- * Indicates Policy Scope Dictionaries
- */
- PolicyScope("PolicyScope"),
- /**
- * Indicates Enforcer Dictionaries
- */
- Enforcer("Enforcer"),
- /**
- * Indicates SafePolicy Dictionaries
- */
- SafePolicy("SafePolicy"),
- /**
- * Enum support entry to extend dictionary
- */
- Extended("Extended"),
- ;
-
- private String name;
-
- private DictionaryType(String typeName){
- this.name = typeName;
- }
-
- /**
- * Returns the <code>String</code> format of Type for this <code>PolicyClass</code>
- * @return the <code>String</code> of the Type for this <code>PolicyClass</code>
- */
- @Override
- public String toString() {
- return this.name;
- }
-
- @JsonCreator
- public static DictionaryType create (String value) {
- for(DictionaryType type: values()){
- if(type.toString().equals(value) || type.equals(DictionaryType.valueOf(value))){
+public enum DictionaryType {
+ /**
+ * Indicates Common Dictionaries.
+ */
+ Common("Common"),
+ /**
+ * Indicates Action Policy Dictionaries
+ */
+ Action("Action"),
+ /**
+ * Indicates ClosedLoop Policy Dictionaries.
+ */
+ ClosedLoop("ClosedLoop"),
+ /**
+ * Indicates Firewall Config Policy Dictionaries.
+ */
+ Firewall("Firewall"),
+ /**
+ * Indicates Decision Policy Dictionaries.
+ */
+ Decision("Decision"),
+ /**
+ * Indicates BRMS Policy Dictionaries.
+ */
+ BRMS("BRMS"),
+ /**
+ * Indicates DCAE Micro Service Policy Dictionaries.
+ */
+ MicroService("MicroService"),
+ /**
+ * Indicates Descriptive Scope Dictionaries
+ */
+ DescriptiveScope("DescriptiveScope"),
+ /**
+ * Indicates Policy Scope Dictionaries
+ */
+ PolicyScope("PolicyScope"),
+ /**
+ * Indicates Enforcer Dictionaries
+ */
+ Enforcer("Enforcer"),
+ /**
+ * Indicates SafePolicy Dictionaries
+ */
+ SafePolicy("SafePolicy"),
+ /**
+ * Enum support entry to extend dictionary
+ */
+ Extended("Extended");
+
+ private final String name;
+
+ private DictionaryType(final String typeName) {
+ this.name = typeName;
+ }
+
+ /**
+ * Returns the <code>String</code> format of Type for this
+ * <code>PolicyClass</code>
+ *
+ * @return the <code>String</code> of the Type for this
+ * <code>PolicyClass</code>
+ */
+ @Override
+ public String toString() {
+ return this.name;
+ }
+
+ @JsonCreator
+ public static DictionaryType create(final String value) {
+ for (final DictionaryType type : values()) {
+ if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
return type;
}
}
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Invalid value: " + value);
}
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyClass.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyClass.java
index 6a648e8e6..fb389bb03 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyClass.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyClass.java
@@ -29,40 +29,44 @@ import com.fasterxml.jackson.annotation.JsonCreator;
* @version 0.1
*/
public enum PolicyClass {
- /**
- * Indicates Config based Policy.
- */
- Config("Config"),
- /**
- * Indicates Action based Policy.
- */
- Action("Action"),
- /**
- * Indicates Decision based Policy.
- */
- Decision("Decision")
- ;
- private String name;
-
- private PolicyClass(String typeName){
- this.name = typeName;
- }
-
- /**
- * Returns the <code>String</code> format of Type for this <code>PolicyClass</code>
- * @return the <code>String</code> of the Type for this <code>PolicyClass</code>
- */
- @Override
- public String toString() {
- return this.name;
- }
- @JsonCreator
- public static PolicyClass create (String value) {
- for(PolicyClass type: values()){
- if(type.toString().equals(value) || type.equals(PolicyClass.valueOf(value))){
+ /**
+ * Indicates Config based Policy.
+ */
+ Config("Config"),
+ /**
+ * Indicates Action based Policy.
+ */
+ Action("Action"),
+ /**
+ * Indicates Decision based Policy.
+ */
+ Decision("Decision");
+
+ private final String name;
+
+ private PolicyClass(final String typeName) {
+ this.name = typeName;
+ }
+
+ /**
+ * Returns the <code>String</code> format of Type for this
+ * <code>PolicyClass</code>
+ *
+ * @return the <code>String</code> of the Type for this
+ * <code>PolicyClass</code>
+ */
+ @Override
+ public String toString() {
+ return this.name;
+ }
+
+ @JsonCreator
+ public static PolicyClass create(final String value) {
+ for (final PolicyClass type : values()) {
+ if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
return type;
}
}
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Invalid value: " + value);
}
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java
index cee156786..f1bbea167 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java
@@ -23,58 +23,63 @@ package org.onap.policy.api;
import com.fasterxml.jackson.annotation.JsonCreator;
/**
- * Enumeration of PolicyConfigStatus that can be returned as a part of
+ * Enumeration of PolicyConfigStatus that can be returned as a part of
* {@link org.onap.policy.api.PolicyConfig}.
*
* @version 0.1
*/
-public enum PolicyConfigStatus {
- /**
- * Indicates that the Configuration has been successfully retrieved.
- */
- CONFIG_RETRIEVED("retrieved"),
- /**
- * Indicates that there is no Configuration Retrieved from PolicyConfig.
- */
- CONFIG_NOT_FOUND("not_found"),
- ;
-
- private String name;
- private PolicyConfigStatus(String name){
- this.name = name;
- }
-
- /**
- * Get the <code>PolicyConfigStatus</code> based on <code>String</code> representation of <code>PolicyConfig</code>
- *
- * @param configStatus the <code>String</code> Configuration Status
- * @return the <code>PolicyConfigResponse</code> with the name matching <code>CONFIG_RETRIEVED</code> or <code>CONFIG_NOT_FOUND</code>
- * if no match is found
- */
- public static PolicyConfigStatus getStatus(String configStatus) {
- if("retrieved".equalsIgnoreCase(configStatus)) {
- return CONFIG_RETRIEVED;
- }else {
- return CONFIG_NOT_FOUND;
- }
- }
-
- /**
- * Returns the <code>String</code> name for this <code>PolicyConfigStatus</code>
- *
- * @return the <code>String</code> name for this <code>PolicyConfigStatus</code>
- */
- @Override
- public String toString(){
- return this.name;
- }
- @JsonCreator
- public static PolicyConfigStatus create (String value) {
- for(PolicyConfigStatus type: values()){
- if(type.toString().equals(value) || type.equals(PolicyConfigStatus.valueOf(value))){
+public enum PolicyConfigStatus {
+ /**
+ * Indicates that the Configuration has been successfully retrieved.
+ */
+ CONFIG_RETRIEVED("retrieved"),
+ /**
+ * Indicates that there is no Configuration Retrieved from PolicyConfig.
+ */
+ CONFIG_NOT_FOUND("not_found");
+
+ private final String name;
+
+ private PolicyConfigStatus(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get the <code>PolicyConfigStatus</code> based on <code>String</code>
+ * representation of <code>PolicyConfig</code>
+ *
+ * @param configStatus
+ * the <code>String</code> Configuration Status
+ * @return the <code>PolicyConfigResponse</code> with the name matching
+ * <code>CONFIG_RETRIEVED</code> or <code>CONFIG_NOT_FOUND</code> if
+ * no match is found
+ */
+ public static PolicyConfigStatus getStatus(final String configStatus) {
+ if (CONFIG_RETRIEVED.name.equalsIgnoreCase(configStatus)) {
+ return CONFIG_RETRIEVED;
+ }
+ return CONFIG_NOT_FOUND;
+ }
+
+ /**
+ * Returns the <code>String</code> name for this
+ * <code>PolicyConfigStatus</code>
+ *
+ * @return the <code>String</code> name for this
+ * <code>PolicyConfigStatus</code>
+ */
+ @Override
+ public String toString() {
+ return this.name;
+ }
+
+ @JsonCreator
+ public static PolicyConfigStatus create(final String value) {
+ for (final PolicyConfigStatus type : values()) {
+ if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
return type;
}
}
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Invalid value: " + value);
}
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecision.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecision.java
index 6bae84cc7..782d44459 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecision.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecision.java
@@ -23,47 +23,48 @@ package org.onap.policy.api;
import com.fasterxml.jackson.annotation.JsonCreator;
/**
- * Enumeration of PolicyDecision that can be returned as a part of
+ * Enumeration of PolicyDecision that can be returned as a part of
* {@link org.onap.policy.api.DecisionResponse} getDecision().
*
* @version 0.1
*/
public enum PolicyDecision {
- /**
- * Indicates that the Decision is to Permit.
- */
- PERMIT("permit"),
- /**
- * Indicates that the Decision is to Deny.
- */
- DENY("deny"),
- /**
- * Indicates that the Decision process has some issues.
- */
- ERROR("error")
- ;
-
- private String name;
- private PolicyDecision(String name){
- this.name = name;
- }
-
- /**
- * Returns the <code>String</code> name for this <code>PolicyDecision</code>
- *
- * @return the <code>String</code> name for this <code>PolicyDecision</code>
- */
- @Override
- public String toString(){
- return this.name;
- }
- @JsonCreator
- public static PolicyDecision create (String value) {
- for(PolicyDecision type: values()){
- if(type.toString().equals(value) || type.equals(PolicyDecision.valueOf(value))){
+ /**
+ * Indicates that the Decision is to Permit.
+ */
+ PERMIT("permit"),
+ /**
+ * Indicates that the Decision is to Deny.
+ */
+ DENY("deny"),
+ /**
+ * Indicates that the Decision process has some issues.
+ */
+ ERROR("error");
+
+ private final String name;
+
+ private PolicyDecision(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the <code>String</code> name for this <code>PolicyDecision</code>
+ *
+ * @return the <code>String</code> name for this <code>PolicyDecision</code>
+ */
+ @Override
+ public String toString() {
+ return this.name;
+ }
+
+ @JsonCreator
+ public static PolicyDecision create(final String value) {
+ for (final PolicyDecision type : values()) {
+ if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
return type;
}
}
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Invalid value: " + value);
}
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponseStatus.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponseStatus.java
index 63cb9185c..0db373ced 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponseStatus.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponseStatus.java
@@ -28,59 +28,65 @@ import com.fasterxml.jackson.annotation.JsonCreator;
*
* @version 0.2
*/
-public enum PolicyResponseStatus {
- /**
- * Indicates there is no action required.
- */
- NO_ACTION_REQUIRED("no_action"),
- /**
- * Indicates that an action has been advised.
- */
- ACTION_ADVISED("action_advised"),
- /**
- * Indicates that an action has been taken.
- */
- ACTION_TAKEN("action_taken")
- ;
-
- private String name;
- private PolicyResponseStatus(String name){
- this.name = name;
- }
-
- /**
- * Get the <code>PolicyResponseStatus</code> based on <code>String</code> representation of <code>PolicyResponse</code>
- *
- * @param responseStatus the <code>String</code> Response Status
- * @return the <code>PolicyResponseStatus</code> with the name matching <code>ACTION_ADVISED</code> or <code>ACTION_TAKEN</code> or <code>NO_ACTION_REQUIRED</code>
- */
- public static PolicyResponseStatus getStatus(String responseStatus) {
- if("action_advised".equalsIgnoreCase(responseStatus)) {
- return ACTION_ADVISED;
- }else if("action_taken".equalsIgnoreCase(responseStatus)) {
- return ACTION_TAKEN;
- }else {
- return NO_ACTION_REQUIRED;
- }
- }
-
- /**
- * Returns the <code>String</code> name for this <code>PolicyResponseStatus</code>
- *
- * @return the <code>String</code> name for this <code>PolicyResponseStatus</code>
- */
- @Override
- public String toString(){
- return this.name;
- }
-
- @JsonCreator
- public static PolicyResponseStatus create (String value) {
- for(PolicyResponseStatus type: values()){
- if(type.toString().equals(value) || type.equals(PolicyResponseStatus.valueOf(value))){
+public enum PolicyResponseStatus {
+ /**
+ * Indicates there is no action required.
+ */
+ NO_ACTION_REQUIRED("no_action"),
+ /**
+ * Indicates that an action has been advised.
+ */
+ ACTION_ADVISED("action_advised"),
+ /**
+ * Indicates that an action has been taken.
+ */
+ ACTION_TAKEN("action_taken");
+
+ private final String name;
+
+ private PolicyResponseStatus(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get the <code>PolicyResponseStatus</code> based on <code>String</code>
+ * representation of <code>PolicyResponse</code>
+ *
+ * @param responseStatus
+ * the <code>String</code> Response Status
+ * @return the <code>PolicyResponseStatus</code> with the name matching
+ * <code>ACTION_ADVISED</code> or <code>ACTION_TAKEN</code> or
+ * <code>NO_ACTION_REQUIRED</code>
+ */
+ public static PolicyResponseStatus getStatus(final String responseStatus) {
+ if (ACTION_ADVISED.name.equalsIgnoreCase(responseStatus)) {
+ return ACTION_ADVISED;
+ } else if (ACTION_TAKEN.name.equalsIgnoreCase(responseStatus)) {
+ return ACTION_TAKEN;
+ } else {
+ return NO_ACTION_REQUIRED;
+ }
+ }
+
+ /**
+ * Returns the <code>String</code> name for this
+ * <code>PolicyResponseStatus</code>
+ *
+ * @return the <code>String</code> name for this
+ * <code>PolicyResponseStatus</code>
+ */
+ @Override
+ public String toString() {
+ return this.name;
+ }
+
+ @JsonCreator
+ public static PolicyResponseStatus create(final String value) {
+ for (final PolicyResponseStatus type : values()) {
+ if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
return type;
}
}
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Invalid value: " + value);
}
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyType.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyType.java
index a29a6c440..0ff5480bf 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyType.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyType.java
@@ -29,45 +29,48 @@ import com.fasterxml.jackson.annotation.JsonCreator;
* @version 0.2
*/
public enum PolicyType {
- /**
- * Indicates the response is Properties type
- */
- PROPERTIES("Properties"),
- /**
- * Indicates the response is JSON type
- */
- JSON("json"),
- /**
- * Indicates the response is XML type
- */
- XML("xml"),
- /**
- * Indicates the response is Other type
- */
- OTHER("other")
- ;
-
- private String name;
-
- private PolicyType(String typeName) {
- this.name = typeName;
- }
-
- /**
- * Returns the <code>String</code> format of Type for this <code>PolicyType</code>
- * @return the <code>String</code> of the Type for this <code>PolicyType</code>
- */
- @Override
- public String toString() {
- return this.name;
- }
- @JsonCreator
- public static PolicyType create (String value) {
- for(PolicyType type: values()){
- if(type.toString().equalsIgnoreCase(value)){
+ /**
+ * Indicates the response is Properties type
+ */
+ PROPERTIES("Properties"),
+ /**
+ * Indicates the response is JSON type
+ */
+ JSON("json"),
+ /**
+ * Indicates the response is XML type
+ */
+ XML("xml"),
+ /**
+ * Indicates the response is Other type
+ */
+ OTHER("other");
+
+ private final String name;
+
+ private PolicyType(final String typeName) {
+ this.name = typeName;
+ }
+
+ /**
+ * Returns the <code>String</code> format of Type for this
+ * <code>PolicyType</code>
+ *
+ * @return the <code>String</code> of the Type for this
+ * <code>PolicyType</code>
+ */
+ @Override
+ public String toString() {
+ return this.name;
+ }
+
+ @JsonCreator
+ public static PolicyType create(final String value) {
+ for (final PolicyType type : values()) {
+ if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
return type;
}
}
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException("Invalid value: " + value);
+ }
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/RuleProvider.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/RuleProvider.java
index 2e45549fc..913f32517 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/RuleProvider.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/RuleProvider.java
@@ -29,50 +29,52 @@ import com.fasterxml.jackson.annotation.JsonCreator;
* @version 0.1
*/
public enum RuleProvider {
- /**
- * Indicates User will be defining the Rule information.
- */
- CUSTOM("Custom"),
- /**
- * Indicates AAF will be providing the Rule information.
- */
- AAF("AAF"),
- /**
- * Indicates Guard YAML will be providing the Rule information.
- */
- GUARD_YAML("GUARD_YAML"),
- /**
- * Indicates Guard BLACKLIST YAML
- */
- GUARD_BL_YAML("GUARD_BL_YAML"),
- /**
- * Indicates Guard BLACKLIST YAML
- */
- RAINY_DAY("Rainy_Day")
- ;
-
- private String name;
-
- private RuleProvider(String typeName){
- this.name = typeName;
- }
-
- /**
- * Returns the <code>String</code> format of Type for this <code>AttributeType</code>
- * @return the <code>String</code> of the Type for this <code>AttributeType</code>
- */
- @Override
- public String toString() {
- return this.name;
- }
-
- @JsonCreator
- public static RuleProvider create (String value) {
- for(RuleProvider type: values()){
- if(type.toString().equals(value) || type.equals(RuleProvider.valueOf(value))){
+ /**
+ * Indicates User will be defining the Rule information.
+ */
+ CUSTOM("Custom"),
+ /**
+ * Indicates AAF will be providing the Rule information.
+ */
+ AAF("AAF"),
+ /**
+ * Indicates Guard YAML will be providing the Rule information.
+ */
+ GUARD_YAML("GUARD_YAML"),
+ /**
+ * Indicates Guard BLACKLIST YAML
+ */
+ GUARD_BL_YAML("GUARD_BL_YAML"),
+ /**
+ * Indicates Guard BLACKLIST YAML
+ */
+ RAINY_DAY("Rainy_Day");
+
+ private final String name;
+
+ private RuleProvider(final String typeName) {
+ this.name = typeName;
+ }
+
+ /**
+ * Returns the <code>String</code> format of Type for this
+ * <code>AttributeType</code>
+ *
+ * @return the <code>String</code> of the Type for this
+ * <code>AttributeType</code>
+ */
+ @Override
+ public String toString() {
+ return this.name;
+ }
+
+ @JsonCreator
+ public static RuleProvider create(final String value) {
+ for (final RuleProvider type : values()) {
+ if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) {
return type;
}
}
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Invalid value: " + value);
}
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIDictionaryResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIDictionaryResponse.java
index 050f36bf4..79c6196e6 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIDictionaryResponse.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIDictionaryResponse.java
@@ -21,33 +21,43 @@ package org.onap.policy.models;
public class APIDictionaryResponse {
private Object dictionaryData;
+
private Object dictionaryJson;
+
private int responseCode;
+
private String responseMessage;
+
public Object getDictionaryData() {
return dictionaryData;
}
- public void setDictionaryData(Object dictionaryData) {
+
+ public void setDictionaryData(final Object dictionaryData) {
this.dictionaryData = dictionaryData;
}
+
public Object getDictionaryJson() {
return dictionaryJson;
}
- public void setDictionaryJson(Object dictionaryJson) {
+
+ public void setDictionaryJson(final Object dictionaryJson) {
this.dictionaryJson = dictionaryJson;
}
+
public int getResponseCode() {
return responseCode;
}
- public void setResponseCode(int responseCode) {
+
+ public void setResponseCode(final int responseCode) {
this.responseCode = responseCode;
}
+
public String getResponseMessage() {
return responseMessage;
}
- public void setResponseMessage(String responseMessage) {
+
+ public void setResponseMessage(final String responseMessage) {
this.responseMessage = responseMessage;
}
-
-
+
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/MatchStore.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/MatchStore.java
index e5204d894..fa8029908 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/MatchStore.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/MatchStore.java
@@ -21,7 +21,9 @@
package org.onap.policy.std;
import java.util.Collection;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import org.onap.policy.api.LoadedPolicy;
@@ -29,220 +31,132 @@ import org.onap.policy.api.NotificationType;
import org.onap.policy.api.PDPNotification;
import org.onap.policy.api.RemovedPolicy;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.logging.flexlogger.Logger;
public class MatchStore {
- private static HashSet<Matches> matchStore = new HashSet<>();
- private static Logger logger = FlexLogger.getLogger(MatchStore.class.getName());
-
- private MatchStore() {
- // Empty Constructor
- }
-
- public static Set<Matches> getMatchStore() {
- return matchStore;
- }
-
- public static void storeMatch(Matches newMatch){
- // Initialization..
- if(newMatch!=null){
- if(matchStore.isEmpty()){
- matchStore.add(newMatch);
- }else{
- // Check if it is a new Match
- Boolean match = false;
- for(Matches oldMatch: matchStore){
- // Compare ONAPName
- if(oldMatch.getOnapName().equals(newMatch.getOnapName())){
- // Compare ConfigName if it exists.
- if(newMatch.getConfigName()!=null && oldMatch.getConfigName()!=null){
- if(oldMatch.getConfigName().equals(newMatch.getConfigName())){
- // Compare the Config Attributes if they exist.
- if(newMatch.getConfigAttributes()!= null && oldMatch.getConfigAttributes()!=null) {
- //Simple thing would be comparing their size.
- if(newMatch.getConfigAttributes().size()==oldMatch.getConfigAttributes().size()){
- // Now need to compare each of them..
- int count= 0;
- for(String oldkey: oldMatch.getConfigAttributes().keySet()){
- boolean check = false;
- for(String newKey: newMatch.getConfigAttributes().keySet()){
- if(oldkey.equals(newKey)){
- if(oldMatch.getConfigAttributes().get(oldkey).equals(newMatch.getConfigAttributes().get(newKey))){
- check = true;
- }
- }
- }
- if(check){
- count++;
- }else{
- break;
- }
- }
- if(count==oldMatch.getConfigAttributes().size()){
- match = true;
- break;
- }
- }
- }else if(newMatch.getConfigAttributes()== null && oldMatch.getConfigAttributes()==null){
- match = true;
- break;
- }
- }
- }else if(newMatch.getConfigName()==null && oldMatch.getConfigName()==null){
- match = true;
- break;
- }
- }
-
- }
- // IF not a match then add it to the MatchStore
- if(! match){
- matchStore.add(newMatch);
- }
- }
- }
- }
-
- //Logic changes for Requested Policies notifications..
- public static PDPNotification checkMatch(PDPNotification oldNotification) {
- boolean removed = false;
- boolean updated = false;
- if(oldNotification==null){
- return null;
- }
- StdPDPNotification newNotification = new StdPDPNotification();
- if(matchStore.isEmpty()) {
- logger.debug("No Success Config Calls made yet.. ");
- return null;
- }
- if(oldNotification.getRemovedPolicies()!=null && !oldNotification.getRemovedPolicies().isEmpty()){
- // send all removed policies to client.
- Collection<StdRemovedPolicy> removedPolicies = new HashSet<>();
- StdRemovedPolicy newRemovedPolicy;
- for(RemovedPolicy removedPolicy: oldNotification.getRemovedPolicies()){
- newRemovedPolicy = new StdRemovedPolicy();
- newRemovedPolicy.setPolicyName(removedPolicy.getPolicyName());
- newRemovedPolicy.setVersionNo(removedPolicy.getVersionNo());
- removedPolicies.add(newRemovedPolicy);
- }
- newNotification.setRemovedPolicies(removedPolicies);
- removed = true;
- }
- if(oldNotification.getLoadedPolicies()!=null && !oldNotification.getLoadedPolicies().isEmpty()){
- Collection<StdLoadedPolicy> updatedPolicies = new HashSet<>();
- StdLoadedPolicy newUpdatedPolicy;
- for(LoadedPolicy updatedPolicy: oldNotification.getLoadedPolicies()){
- // if it is config policies check their matches..
- if(updatedPolicy.getMatches()!=null && !updatedPolicy.getMatches().isEmpty()){
- boolean matched;
- for(Matches match : matchStore){
- matched = false;
- // Again Better way would be comparing sizes first.
- // Matches are different need to check if has configAttributes
- if(match.getConfigAttributes()!=null && !match.getConfigAttributes().isEmpty()){
- // adding onap and config to config-attributes.
- int compValues = match.getConfigAttributes().size() + 2;
- if(updatedPolicy.getMatches().size()== compValues){
- // Comparing both the values..
- boolean matchAttributes = false;
- for(String newKey: updatedPolicy.getMatches().keySet()){
- if("ONAPName".equals(newKey)){
- if(updatedPolicy.getMatches().get(newKey).equals(match.getOnapName())){
- matchAttributes = true;
- }else {
- matchAttributes = false;
- break;
- }
- }else if("ConfigName".equals(newKey)) {
- if(updatedPolicy.getMatches().get(newKey).equals(match.getConfigName())){
- matchAttributes = true;
- }else{
- matchAttributes = false;
- break;
- }
- }else {
- if(match.getConfigAttributes().containsKey(newKey)){
- if(updatedPolicy.getMatches().get(newKey).equals(match.getConfigAttributes().get(newKey))){
- matchAttributes = true;
- }else{
- matchAttributes = false;
- break;
- }
- }else{
- matchAttributes = false;
- break;
- }
- }
- }
- if(matchAttributes){
- // Match..
- matched = true;
- }else{
- break;
- }
- }else {
- break;
- }
- }else if(match.getConfigName()!=null){
- // If there are no config Attributes then check if it has Config Name
- if(updatedPolicy.getMatches().size()== 2){
- if(updatedPolicy.getMatches().get("ONAPName").equals(match.getOnapName())){
- if(updatedPolicy.getMatches().get("ConfigName").equals(match.getConfigName())){
- // Match..
- matched = true;
- }else{
- break;
- }
- }else {
- break;
- }
- }else{
- break;
- }
- }else {
- // If non exist then assuming the ONAP Name to be there.
- if(updatedPolicy.getMatches().size()== 1){
- if(updatedPolicy.getMatches().get("ONAPName").equals(match.getOnapName())){
- // Match..
- matched = true;
- }else {
- break;
- }
- }else{
- break;
- }
- }
- // Add logic to add the policy.
- if(matched){
- newUpdatedPolicy = new StdLoadedPolicy();
- newUpdatedPolicy.setPolicyName(updatedPolicy.getPolicyName());
- newUpdatedPolicy.setVersionNo(updatedPolicy.getVersionNo());
- newUpdatedPolicy.setMatches(updatedPolicy.getMatches());
- updatedPolicies.add(newUpdatedPolicy);
- updated = true;
- }
- }
-
- }else {
- //send all non config notifications to client.
- newUpdatedPolicy = new StdLoadedPolicy();
- newUpdatedPolicy.setPolicyName(updatedPolicy.getPolicyName());
- newUpdatedPolicy.setVersionNo(updatedPolicy.getVersionNo());
- updatedPolicies.add(newUpdatedPolicy);
- updated = true;
- }
- }
- newNotification.setLoadedPolicies(updatedPolicies);
- }
- // Need to set the type of Update..
- if(removed && updated) {
- newNotification.setNotificationType(NotificationType.BOTH);
- }else if(removed){
- newNotification.setNotificationType(NotificationType.REMOVE);
- }else if(updated){
- newNotification.setNotificationType(NotificationType.UPDATE);
- }
- return newNotification;
- }
-
+ private static final String CONFIG_NAME = "ConfigName";
+
+ private static final String ONAP_NAME = "ONAPName";
+
+ private static final Set<Matches> MATCH_STORE = new HashSet<>();
+
+ private static final Logger LOGGER = FlexLogger.getLogger(MatchStore.class.getName());
+
+ private MatchStore() {
+ // Empty Constructor
+ }
+
+ public static Set<Matches> getMatchStore() {
+ return MATCH_STORE;
+ }
+
+ public static void storeMatch(final Matches newMatch) {
+ if (newMatch != null && !MATCH_STORE.contains(newMatch)) {
+ MATCH_STORE.add(newMatch);
+ }
+ }
+
+ // Logic changes for Requested Policies notifications..
+ public static PDPNotification checkMatch(final PDPNotification oldNotification) {
+ if (oldNotification == null) {
+ return null;
+ }
+ if (MATCH_STORE.isEmpty()) {
+ LOGGER.debug("No Success Config Calls made yet.. ");
+ return null;
+ }
+ return getPDPNotification(oldNotification);
+ }
+
+ private static PDPNotification getPDPNotification(final PDPNotification oldNotification) {
+ boolean removed = false;
+ boolean updated = false;
+ final StdPDPNotification newNotification = new StdPDPNotification();
+ if (isValid(oldNotification.getRemovedPolicies())) {
+ // send all removed policies to client.
+ newNotification.setRemovedPolicies(getStdRemovedPolicies(oldNotification.getRemovedPolicies()));
+ removed = true;
+ }
+ if (isValid(oldNotification.getLoadedPolicies())) {
+ final Collection<StdLoadedPolicy> updatedPolicies = new HashSet<>();
+ for (final LoadedPolicy updatedPolicy : oldNotification.getLoadedPolicies()) {
+ updated = updateStdLoadedPolicy(updated, updatedPolicies, updatedPolicy);
+ }
+ newNotification.setLoadedPolicies(updatedPolicies);
+ }
+ // Need to set the type of Update..
+ if (removed && updated) {
+ newNotification.setNotificationType(NotificationType.BOTH);
+ } else if (removed) {
+ newNotification.setNotificationType(NotificationType.REMOVE);
+ } else if (updated) {
+ newNotification.setNotificationType(NotificationType.UPDATE);
+ }
+ return newNotification;
+ }
+
+ private static boolean updateStdLoadedPolicy(boolean updated, final Collection<StdLoadedPolicy> updatedPolicies,
+ final LoadedPolicy updatedPolicy) {
+ // if it is config policies check their matches
+ if (isValid(updatedPolicy.getMatches())) {
+ final Map<String, String> matchesMap = updatedPolicy.getMatches();
+ final Matches policyMatches = getMatches(matchesMap);
+ for (final Matches match : MATCH_STORE) {
+ if (match.equals(policyMatches)) {
+ final StdLoadedPolicy newUpdatedPolicy = new StdLoadedPolicy();
+ newUpdatedPolicy.setPolicyName(updatedPolicy.getPolicyName());
+ newUpdatedPolicy.setVersionNo(updatedPolicy.getVersionNo());
+ newUpdatedPolicy.setMatches(updatedPolicy.getMatches());
+ updatedPolicies.add(newUpdatedPolicy);
+ updated = true;
+ } else {
+ break;
+ }
+ }
+
+ } else {
+ // send all non config notifications to client.
+ final StdLoadedPolicy newUpdatedPolicy = new StdLoadedPolicy();
+ newUpdatedPolicy.setPolicyName(updatedPolicy.getPolicyName());
+ newUpdatedPolicy.setVersionNo(updatedPolicy.getVersionNo());
+ updatedPolicies.add(newUpdatedPolicy);
+ updated = true;
+ }
+ return updated;
+ }
+
+ private static Matches getMatches(final Map<String, String> attributes) {
+ final Matches matches = new Matches();
+ matches.setOnapName(attributes.get(ONAP_NAME));
+ matches.setConfigName(attributes.get(CONFIG_NAME));
+
+ final Map<String, String> configAttributes = new HashMap<>(attributes);
+ // remove onap and config to config-attributes.
+ configAttributes.remove(ONAP_NAME);
+ configAttributes.remove(CONFIG_NAME);
+
+ matches.setConfigAttributes(configAttributes);
+
+ return matches;
+ }
+
+ private static boolean isValid(final Map<String, String> map) {
+ return map != null && !map.isEmpty();
+ }
+
+ private static Collection<StdRemovedPolicy> getStdRemovedPolicies(final Collection<RemovedPolicy> policies) {
+ final Set<StdRemovedPolicy> removedPolicies = new HashSet<>();
+ for (final RemovedPolicy removedPolicy : policies) {
+ final StdRemovedPolicy newRemovedPolicy = new StdRemovedPolicy();
+ newRemovedPolicy.setPolicyName(removedPolicy.getPolicyName());
+ newRemovedPolicy.setVersionNo(removedPolicy.getVersionNo());
+ removedPolicies.add(newRemovedPolicy);
+ }
+ return removedPolicies;
+ }
+
+ private static boolean isValid(final Collection<?> collection) {
+ return collection != null && !collection.isEmpty();
+ }
+
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/Matches.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/Matches.java
index eb382a63d..b3486e45b 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/Matches.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/Matches.java
@@ -23,26 +23,61 @@ package org.onap.policy.std;
import java.util.Map;
public class Matches {
- private String onapName = null;
- private String configName = null;
- private Map<String,String> configAttributes = null;
- public String getOnapName() {
- return onapName;
- }
- public void setOnapName(String onapName) {
- this.onapName = onapName;
- }
- public String getConfigName() {
- return configName;
- }
- public void setConfigName(String configName) {
- this.configName = configName;
- }
- public Map<String,String> getConfigAttributes() {
- return configAttributes;
- }
- public void setConfigAttributes(Map<String,String> configAttributes) {
- this.configAttributes = configAttributes;
- }
-
+ private String onapName = null;
+
+ private String configName = null;
+
+ private Map<String, String> configAttributes = null;
+
+ public String getOnapName() {
+ return onapName;
+ }
+
+ public void setOnapName(final String onapName) {
+ this.onapName = onapName;
+ }
+
+ public String getConfigName() {
+ return configName;
+ }
+
+ public void setConfigName(final String configName) {
+ this.configName = configName;
+ }
+
+ public Map<String, String> getConfigAttributes() {
+ return configAttributes;
+ }
+
+ public void setConfigAttributes(final Map<String, String> configAttributes) {
+ this.configAttributes = configAttributes;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((configAttributes == null) ? 0 : configAttributes.hashCode());
+ result = prime * result + ((configName == null) ? 0 : configName.hashCode());
+ result = prime * result + ((onapName == null) ? 0 : onapName.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj instanceof Matches) {
+ final Matches other = (Matches) obj;
+ return isEqual(onapName, other.onapName) && isEqual(configName, other.configName)
+ && isEqual(configAttributes, other.configAttributes);
+ }
+ return false;
+ }
+
+ private boolean isEqual(final Object objectA, final Object objectB) {
+ if (objectA == null) {
+ return objectB == null;
+ }
+ return objectA.equals(objectB);
+ }
+
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/NotificationUnMarshal.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/NotificationUnMarshal.java
index 6772f5a9b..fb7029800 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/NotificationUnMarshal.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/NotificationUnMarshal.java
@@ -31,40 +31,48 @@ import org.onap.policy.api.UpdateType;
import com.fasterxml.jackson.databind.ObjectMapper;
public class NotificationUnMarshal {
-
- private NotificationUnMarshal() {
- // Empty constructor
- }
-
- public static StdPDPNotification notificationJSON(String json) throws IOException{
- ObjectMapper mapper = new ObjectMapper();
- StdPDPNotification notification = mapper.readValue(json, StdPDPNotification.class);
- if(notification == null || notification.getLoadedPolicies() == null){
- return notification;
- }
- Collection<StdLoadedPolicy> stdLoadedPolicies = new ArrayList<>();
- for(LoadedPolicy loadedPolicy: notification.getLoadedPolicies()){
- StdLoadedPolicy stdLoadedPolicy = (StdLoadedPolicy) loadedPolicy;
- if(notification.getRemovedPolicies()!=null){
- Boolean updated = false;
- for(RemovedPolicy removedPolicy: notification.getRemovedPolicies()){
- String regex = ".(\\d)*.xml";
- if(removedPolicy.getPolicyName().replaceAll(regex, "").equals(stdLoadedPolicy.getPolicyName().replaceAll(regex, ""))){
- updated = true;
- break;
- }
- }
- if(updated){
- stdLoadedPolicy.setUpdateType(UpdateType.UPDATE);
- }else{
- stdLoadedPolicy.setUpdateType(UpdateType.NEW);
- }
- }else{
- stdLoadedPolicy.setUpdateType(UpdateType.NEW);
- }
- stdLoadedPolicies.add(stdLoadedPolicy);
- }
- notification.setLoadedPolicies(stdLoadedPolicies);
- return notification;
- }
+
+ private static final String EMPTY_STRING = "";
+
+ private static final String REGEX = ".(\\d)*.xml";
+
+ private NotificationUnMarshal() {
+ // Empty constructor
+ }
+
+ public static StdPDPNotification notificationJSON(final String json) throws IOException {
+ final ObjectMapper mapper = new ObjectMapper();
+ final StdPDPNotification notification = mapper.readValue(json, StdPDPNotification.class);
+ if (notification == null || notification.getLoadedPolicies() == null) {
+ return notification;
+ }
+ final Collection<StdLoadedPolicy> stdLoadedPolicies = new ArrayList<>();
+ for (final LoadedPolicy loadedPolicy : notification.getLoadedPolicies()) {
+ final StdLoadedPolicy stdLoadedPolicy = (StdLoadedPolicy) loadedPolicy;
+ if (notification.getRemovedPolicies() != null) {
+ if (isUpdated(notification, stdLoadedPolicy)) {
+ stdLoadedPolicy.setUpdateType(UpdateType.UPDATE);
+ } else {
+ stdLoadedPolicy.setUpdateType(UpdateType.NEW);
+ }
+ } else {
+ stdLoadedPolicy.setUpdateType(UpdateType.NEW);
+ }
+ stdLoadedPolicies.add(stdLoadedPolicy);
+ }
+ notification.setLoadedPolicies(stdLoadedPolicies);
+ return notification;
+ }
+
+ private static Boolean isUpdated(final StdPDPNotification notification, final StdLoadedPolicy stdLoadedPolicy) {
+ for (final RemovedPolicy removedPolicy : notification.getRemovedPolicies()) {
+ final String removedPolicyName = removedPolicy.getPolicyName();
+ final String loadedPolicyName = stdLoadedPolicy.getPolicyName();
+ if (removedPolicyName.replaceAll(REGEX, EMPTY_STRING)
+ .equals(loadedPolicyName.replaceAll(REGEX, EMPTY_STRING))) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchStoreTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchStoreTest.java
index f5a86d17d..e3ea73563 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchStoreTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchStoreTest.java
@@ -20,745 +20,477 @@
package org.onap.policy.std.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
-import java.util.Hashtable;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.policy.api.LoadedPolicy;
+import org.onap.policy.api.NotificationType;
import org.onap.policy.api.PDPNotification;
import org.onap.policy.std.MatchStore;
import org.onap.policy.std.Matches;
+import org.onap.policy.std.StdLoadedPolicy;
import org.onap.policy.std.StdPDPNotification;
+import org.onap.policy.std.StdRemovedPolicy;
/**
- * The class <code>MatchStoreTest</code> contains tests for the class <code>{@link MatchStore}</code>.
+ * The class <code>MatchStoreTest</code> contains tests for the class
+ * <code>{@link MatchStore}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class MatchStoreTest {
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_1()
- throws Exception {
- PDPNotification oldNotification = null;
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNull(result);
- }
-
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_2()
- throws Exception {
- PDPNotification oldNotification = new StdPDPNotification();
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNotNull(result);
- }
-
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_3()
- throws Exception {
- PDPNotification oldNotification = new StdPDPNotification();
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNotNull(result);
- }
-
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_4()
- throws Exception {
- PDPNotification oldNotification = new StdPDPNotification();
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNotNull(result);
- }
-
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_5()
- throws Exception {
- PDPNotification oldNotification = new StdPDPNotification();
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNotNull(result);
- }
-
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_6()
- throws Exception {
- PDPNotification oldNotification = new StdPDPNotification();
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNotNull(result);
- }
-
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_7()
- throws Exception {
- PDPNotification oldNotification = new StdPDPNotification();
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNotNull(result);
- }
-
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_8()
- throws Exception {
- PDPNotification oldNotification = new StdPDPNotification();
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNotNull(result);
- }
-
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_9()
- throws Exception {
- PDPNotification oldNotification = new StdPDPNotification();
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNotNull(result);
- }
-
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_10()
- throws Exception {
- PDPNotification oldNotification = new StdPDPNotification();
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNotNull(result);
- }
-
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_11()
- throws Exception {
- PDPNotification oldNotification = new StdPDPNotification();
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNotNull(result);
- }
-
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_12()
- throws Exception {
- PDPNotification oldNotification = new StdPDPNotification();
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNotNull(result);
- }
-
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_13()
- throws Exception {
- PDPNotification oldNotification = new StdPDPNotification();
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNotNull(result);
- }
-
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_14()
- throws Exception {
- PDPNotification oldNotification = new StdPDPNotification();
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNotNull(result);
- }
-
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_15()
- throws Exception {
- PDPNotification oldNotification = new StdPDPNotification();
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNotNull(result);
- }
-
- /**
- * Run the PDPNotification checkMatch(PDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testCheckMatch_16()
- throws Exception {
- PDPNotification oldNotification = new StdPDPNotification();
-
- PDPNotification result = MatchStore.checkMatch(oldNotification);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- assertNotNull(result);
- }
-
- /**
- * Run the HashSet<Matches> getMatchStore() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetMatchStore_1()
- throws Exception {
-
- Set<Matches> result = MatchStore.getMatchStore();
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.ExceptionInInitializerError
- // at org.apache.log4j.Logger.getLogger(Logger.java:104)
- // at org.onap.policy.std.MatchStore.<clinit>(MatchStore.java:15)
- assertNotNull(result);
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_1()
- throws Exception {
- Matches newMatch = new Matches();
- newMatch.setConfigName("");
- newMatch.setOnapName("");
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_2()
- throws Exception {
- Matches newMatch = new Matches();
- newMatch.setConfigName("");
- newMatch.setOnapName("");
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_3()
- throws Exception {
- Matches newMatch = new Matches();
- newMatch.setConfigName("");
- newMatch.setOnapName("");
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_4()
- throws Exception {
- Matches newMatch = new Matches();
- newMatch.setConfigAttributes(new Hashtable<String, String>());
- newMatch.setConfigName("");
- newMatch.setOnapName("");
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_5()
- throws Exception {
- Matches newMatch = new Matches();
- newMatch.setConfigAttributes(new Hashtable<String, String>());
- newMatch.setConfigName("");
- newMatch.setOnapName("");
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_6()
- throws Exception {
- Matches newMatch = new Matches();
- newMatch.setConfigAttributes(new Hashtable<String, String>());
- newMatch.setConfigName("");
- newMatch.setOnapName("");
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_7()
- throws Exception {
- Matches newMatch = new Matches();
- newMatch.setConfigAttributes(new Hashtable<String, String>());
- newMatch.setConfigName("");
- newMatch.setOnapName("");
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_8()
- throws Exception {
- Matches newMatch = new Matches();
- newMatch.setConfigName("");
- newMatch.setOnapName("");
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_9()
- throws Exception {
- Matches newMatch = new Matches();
- newMatch.setOnapName("");
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_10()
- throws Exception {
- Matches newMatch = new Matches();
- newMatch.setConfigAttributes(new Hashtable<String, String>());
- newMatch.setConfigName("");
- newMatch.setOnapName("");
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_11()
- throws Exception {
- Matches newMatch = new Matches();
- newMatch.setConfigAttributes(new Hashtable<String, String>());
- newMatch.setConfigName("");
- newMatch.setOnapName("");
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_12()
- throws Exception {
- Matches newMatch = new Matches();
- newMatch.setConfigAttributes(new Hashtable<String, String>());
- newMatch.setConfigName("");
- newMatch.setOnapName("");
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_13()
- throws Exception {
- Matches newMatch = new Matches();
- newMatch.setConfigAttributes(new Hashtable<String, String>());
- newMatch.setConfigName("");
- newMatch.setOnapName("");
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_14()
- throws Exception {
- Matches newMatch = new Matches();
- newMatch.setConfigAttributes(new Hashtable<String, String>());
- newMatch.setConfigName("");
- newMatch.setOnapName("");
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_15()
- throws Exception {
- Matches newMatch = new Matches();
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Run the void storeMatch(Matches) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStoreMatch_16()
- throws Exception {
- Matches newMatch = null;
-
- MatchStore.storeMatch(newMatch);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.MatchStore
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(MatchStoreTest.class);
- }
+ private static final String ATTRIBUTE_DUMMY_VALUE = "Value";
+
+ private static final String ATTRIBUTE_DUMMY_KEY = "Key";
+
+ private static final String POLICY_NAME = "ONAP";
+
+ private static final String POLICY_VERSION = "1.0.0";
+
+ private static final String ONAP_NAME_VAL = "ONAPName";
+
+ private static final String CONFIG_NAME_VAL = "ConfigName";
+
+ private static final String EMPTY_STRING = "";
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ */
+ @Before
+ public void setUp() throws Exception {
+ MatchStore.getMatchStore().clear();
+ }
+
+ @Test
+ public void testCheckMatch_ShouldReturnNullWithNullPDPNotification() throws Exception {
+ final PDPNotification oldNotification = null;
+
+ final PDPNotification result = MatchStore.checkMatch(oldNotification);
+
+ assertNull(result);
+ }
+
+ @Test
+ public void testCheckMatch_ShouldReturnNullIfMatchStoreCacheIsEmpty() throws Exception {
+ final PDPNotification oldNotification = new StdPDPNotification();
+
+ final PDPNotification result = MatchStore.checkMatch(oldNotification);
+ assertNull(result);
+ }
+
+ @Test
+ public void testCheckMatch_ShouldNotReturnNullIfMatchStoreCacheIsNotEmpty() throws Exception {
+ final Matches newMatch = getMatchesInstance(EMPTY_STRING, EMPTY_STRING);
+ MatchStore.storeMatch(newMatch);
+ final PDPNotification oldNotification = new StdPDPNotification();
+
+ final PDPNotification result = MatchStore.checkMatch(oldNotification);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetMatchStore_ShouldNotBeNullOnStartUP() throws Exception {
+ final Set<Matches> result = MatchStore.getMatchStore();
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testStoreMatch_ShouldRetrunEmptyLoadedRemovedPolicesIfNotMatchFoundInMatchStore() throws Exception {
+ final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL);
+
+ MatchStore.storeMatch(newMatch);
+
+ assertFalse(MatchStore.getMatchStore().isEmpty());
+
+ final PDPNotification oldNotification = new StdPDPNotification();
+ final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+ assertTrue(actualPDPNotification.getLoadedPolicies().isEmpty());
+ assertTrue(actualPDPNotification.getRemovedPolicies().isEmpty());
+ assertNull(actualPDPNotification.getNotificationType());
+ }
+
+ @Test
+ public void testStoreMatch_NotificationTypeRemoved_IfRemovedPolicyExistInOldNotification() throws Exception {
+ final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL);
+ final StdRemovedPolicy removedPolicy = getRemovedPolicy(POLICY_VERSION, POLICY_NAME);
+ final PDPNotification oldNotification = getPDPNotification(Arrays.asList(removedPolicy),
+ Collections.emptySet());
+
+ MatchStore.storeMatch(newMatch);
+
+ assertFalse(MatchStore.getMatchStore().isEmpty());
+
+ final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+ assertEquals(NotificationType.REMOVE, actualPDPNotification.getNotificationType());
+ assertFalse(actualPDPNotification.getRemovedPolicies().isEmpty());
+
+ }
+
+ @Test
+ public void testStoreMatch_NoticficationTypeUpdate_IfStdLoadPolicyExistsWithEmptyMatches() throws Exception {
+ final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL);
+ final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, Collections.emptyMap());
+ final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
+ Arrays.asList(stdLoadedPolicy));
+
+ MatchStore.storeMatch(newMatch);
+
+ assertFalse(MatchStore.getMatchStore().isEmpty());
+
+ final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+ assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
+ assertFalse(actualPDPNotification.getLoadedPolicies().isEmpty());
+ }
+
+ @Test
+ public void testStoreMatch_NoticficationTypeUpdate_IfStdLoadPolicyExistsWithMatches() throws Exception {
+ final Map<String, String> attribute = getAttributesMap();
+
+ final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, attribute);
+ final Map<String, String> matches = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
+ matches.putAll(attribute);
+
+ final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
+ final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
+ Arrays.asList(stdLoadedPolicy));
+
+ MatchStore.storeMatch(newMatch);
+
+ assertFalse(MatchStore.getMatchStore().isEmpty());
+
+ final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+ assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
+
+ final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+ assertFalse(actualLoadPolicies.isEmpty());
+
+ final LoadedPolicy loadedPolicy = actualLoadPolicies.iterator().next();
+ assertEquals(stdLoadedPolicy.getPolicyName(), loadedPolicy.getPolicyName());
+ assertEquals(stdLoadedPolicy.getVersionNo(), loadedPolicy.getVersionNo());
+ }
+
+ @Test
+ public void testStoreMatch_NoticficationTypeUpdate_IfStdLoadPolicyExistsWithNullMatches() throws Exception {
+ final Map<String, String> attribute = getAttributesMap();
+
+ final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, attribute);
+
+ final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, null);
+ final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
+ Arrays.asList(stdLoadedPolicy));
+
+ MatchStore.storeMatch(newMatch);
+
+ assertFalse(MatchStore.getMatchStore().isEmpty());
+
+ final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+ assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
+
+ final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+ assertFalse(actualLoadPolicies.isEmpty());
+
+ final LoadedPolicy loadedPolicy = actualLoadPolicies.iterator().next();
+ assertEquals(stdLoadedPolicy.getPolicyName(), loadedPolicy.getPolicyName());
+ assertEquals(stdLoadedPolicy.getVersionNo(), loadedPolicy.getVersionNo());
+ }
+
+ @Test
+ public void testStoreMatch_NoticficationTypeNull_IfStdLoadPolicyExistsWithMatchesWithOutMatchingConfigAttribute()
+ throws Exception {
+ final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, getAttributesMap());
+ final Map<String, String> matches = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
+
+ final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
+ final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
+ Arrays.asList(stdLoadedPolicy));
+
+ MatchStore.storeMatch(newMatch);
+
+ assertFalse(MatchStore.getMatchStore().isEmpty());
+
+ final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+ assertNull(actualPDPNotification.getNotificationType());
+
+ final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+ assertTrue(actualLoadPolicies.isEmpty());
+
+ }
+
+ @Test
+ public void testStoreMatch_NoticficationTypeUpdate_IfMatchStoreContainMatchesWithNullConStdLoadPolicyExistsWithMatches()
+ throws Exception {
+
+ final Matches newMatch = getMatchesInstance(null, ONAP_NAME_VAL, Collections.emptyMap());
+ final Map<String, String> matches = new HashMap<>();
+ matches.put(ONAP_NAME_VAL, ONAP_NAME_VAL);
+
+ final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
+ final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
+ Arrays.asList(stdLoadedPolicy));
+
+ MatchStore.storeMatch(newMatch);
+
+ assertFalse(MatchStore.getMatchStore().isEmpty());
+
+ final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+ assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
+
+ final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+ assertFalse(actualLoadPolicies.isEmpty());
+
+ }
+
+ @Test
+ public void testStoreMatch_NoticficationTypeUpdate_IfMatchStoreContainMatchingMatches() throws Exception {
+
+ final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
+ final Map<String, String> matches = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
+
+ final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
+ final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
+ Arrays.asList(stdLoadedPolicy));
+
+ MatchStore.storeMatch(newMatch);
+
+ assertFalse(MatchStore.getMatchStore().isEmpty());
+
+ final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+ assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
+
+ final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+ assertFalse(actualLoadPolicies.isEmpty());
+
+ final LoadedPolicy loadedPolicy = actualLoadPolicies.iterator().next();
+ assertEquals(stdLoadedPolicy.getPolicyName(), loadedPolicy.getPolicyName());
+ assertEquals(stdLoadedPolicy.getVersionNo(), loadedPolicy.getVersionNo());
+ }
+
+ @Test
+ public void testStoreMatch_NoticficationTypeUpdate_IfMatchStoreContainMatchingMatches2() throws Exception {
+
+ final Matches firstObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
+ final Map<String, String> firstPolicyObj = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
+ final Map<String, String> attributesMap = getAttributesMap();
+
+ final Matches secondObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, attributesMap);
+ final Map<String, String> secondPolicyObj = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
+ secondPolicyObj.putAll(attributesMap);
+
+ final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, firstPolicyObj);
+ final StdLoadedPolicy secondStdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, secondPolicyObj);
+ final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
+ Arrays.asList(stdLoadedPolicy, secondStdLoadedPolicy));
+
+ MatchStore.storeMatch(firstObj);
+ MatchStore.storeMatch(secondObj);
+
+ assertFalse(MatchStore.getMatchStore().isEmpty());
+
+ final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+ assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
+
+ final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+ assertFalse(actualLoadPolicies.isEmpty());
+ assertEquals(1, actualLoadPolicies.size());
+ }
+
+ @Test
+ public void testStoreMatch_NoticficationTypeBoth_IfOldNotificationContainRemovedAndLoadedPolicies()
+ throws Exception {
+
+ final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
+ final Map<String, String> matches = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
+
+ final StdRemovedPolicy removedPolicy = getRemovedPolicy(POLICY_VERSION, POLICY_NAME);
+ final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
+ final PDPNotification oldNotification = getPDPNotification(Arrays.asList(removedPolicy),
+ Arrays.asList(stdLoadedPolicy));
+
+ MatchStore.storeMatch(newMatch);
+
+ assertFalse(MatchStore.getMatchStore().isEmpty());
+
+ final PDPNotification actualPDPNotification = MatchStore.checkMatch(oldNotification);
+
+ assertEquals(NotificationType.BOTH, actualPDPNotification.getNotificationType());
+ assertFalse(actualPDPNotification.getRemovedPolicies().isEmpty());
+ assertFalse(actualPDPNotification.getLoadedPolicies().isEmpty());
+ }
+
+ private Map<String, String> getPolicyMatches(final String onapName, final String configName) {
+ final Map<String, String> matches = new HashMap<>();
+ matches.put(ONAP_NAME_VAL, onapName);
+ matches.put(CONFIG_NAME_VAL, configName);
+ return matches;
+ }
+
+ @Test
+ public void testStoreMatch_MatchesObjectShouldbeAddOnceToMatchStoreAndNoDuplication() throws Exception {
+ final String[] configNames = new String[] { CONFIG_NAME_VAL, CONFIG_NAME_VAL, "ConfigName1", CONFIG_NAME_VAL,
+ "ConfigName1", null };
+ final String[] onapNames = new String[] { ONAP_NAME_VAL, ONAP_NAME_VAL, "ONAPName1", "ONAPName1", ONAP_NAME_VAL,
+ ONAP_NAME_VAL };
+
+ for (int i = 0; i < configNames.length; i++) {
+
+ final Matches matches = getMatchesInstance(configNames[i], onapNames[i], getAttributesMap());
+ MatchStore.storeMatch(matches);
+ MatchStore.storeMatch(matches);
+ }
+
+ assertEquals(configNames.length - 1, MatchStore.getMatchStore().size());
+
+ }
+
+ @Test
+ public void testStoreMatch_MatchesObjectShouldBeAddedToMatchStore_ConfigAttrValuesAreDifferentThenExistingOne()
+ throws Exception {
+ final Matches firstObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, getAttributesMap());
+ final Matches secondObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
+
+ MatchStore.storeMatch(firstObj);
+ MatchStore.storeMatch(secondObj);
+ MatchStore.storeMatch(firstObj);
+
+ assertEquals(2, MatchStore.getMatchStore().size());
+
+ }
+
+ @Test
+ public void testStoreMatch_MatchesObjectShouldBeAddedToMatchStore_ConfigAttrValuesNull() throws Exception {
+ final Matches firstObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, null);
+ final Matches secondObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, null);
+
+ MatchStore.storeMatch(firstObj);
+ MatchStore.storeMatch(secondObj);
+ MatchStore.storeMatch(firstObj);
+
+ assertEquals(1, MatchStore.getMatchStore().size());
+
+ }
+
+ @Test
+ public void testStoreMatch_MatchesObjectShouldBeAddedToMatchStore_OnapNameIsDifferentThenExistingOne()
+ throws Exception {
+ final Matches firstObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, getAttributesMap());
+ final Matches secondObj = getMatchesInstance(CONFIG_NAME_VAL, "ONAPName1", getAttributesMap());
+
+ MatchStore.storeMatch(firstObj);
+ MatchStore.storeMatch(secondObj);
+ MatchStore.storeMatch(firstObj);
+
+ assertEquals(2, MatchStore.getMatchStore().size());
+
+ }
+
+ private Map<String, String> getAttributesMap() {
+ final Map<String, String> attribute = new HashMap<>();
+ attribute.put(ATTRIBUTE_DUMMY_KEY, ATTRIBUTE_DUMMY_VALUE);
+ return attribute;
+ }
+
+ private Matches getMatchesInstance(final String configName, final String onapName) {
+ return getMatchesInstance(configName, onapName, null);
+ }
+
+ private Matches getMatchesInstance(final String configName, final String onapName,
+ final Map<String, String> configAttributes) {
+ final Matches matches = new Matches();
+ matches.setConfigName(configName);
+ matches.setOnapName(onapName);
+ matches.setConfigAttributes(configAttributes);
+ return matches;
+ }
+
+ private StdRemovedPolicy getRemovedPolicy(final String version, final String policyName) {
+ return new StdRemovedPolicy() {
+
+ @Override
+ public String getVersionNo() {
+ return version;
+ }
+
+ @Override
+ public String getPolicyName() {
+ return policyName;
+ }
+ };
+ }
+
+ private PDPNotification getPDPNotification(final Collection<StdRemovedPolicy> removedPolicies,
+ final Collection<StdLoadedPolicy> loadedPolicies) {
+ final StdPDPNotification oldNotification = new StdPDPNotification();
+ oldNotification.setLoadedPolicies(loadedPolicies);
+ oldNotification.setRemovedPolicies(removedPolicies);
+ return oldNotification;
+ }
+
+ private StdLoadedPolicy getStdLoadedPolicy(final String version, final String policyName,
+ final Map<String, String> matches) {
+ return new StdLoadedPolicy() {
+
+ @Override
+ public String getVersionNo() {
+ return version;
+ }
+
+ @Override
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ @Override
+ public Map<String, String> getMatches() {
+ return matches;
+ }
+ };
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args
+ * the command line arguments
+ */
+ public static void main(final String[] args) {
+ new org.junit.runner.JUnitCore().run(MatchStoreTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchesTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchesTest.java
index f71d93cb8..3a76ff455 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchesTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchesTest.java
@@ -20,197 +20,200 @@
package org.onap.policy.std.test;
-import java.util.Hashtable;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
-import org.junit.*;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
import org.onap.policy.std.Matches;
-import static org.junit.Assert.*;
-
/**
- * The class <code>MatchesTest</code> contains tests for the class <code>{@link Matches}</code>.
+ * The class <code>MatchesTest</code> contains tests for the class
+ * <code>{@link Matches}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class MatchesTest {
- /**
- * Run the Matches() constructor test.
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testMatches_1()
- throws Exception {
- Matches result = new Matches();
- assertNotNull(result);
- // add additional test code here
- }
-
- /**
- * Run the Map<String, String> getConfigAttributes() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetConfigAttributes_1()
- throws Exception {
- Matches fixture = new Matches();
- fixture.setOnapName("");
- fixture.setConfigAttributes(new Hashtable<String, String>());
- fixture.setConfigName("");
-
- Map<String, String> result = fixture.getConfigAttributes();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the String getConfigName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetConfigName_1()
- throws Exception {
- Matches fixture = new Matches();
- fixture.setOnapName("");
- fixture.setConfigAttributes(new Hashtable<String, String>());
- fixture.setConfigName("");
-
- String result = fixture.getConfigName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the String getOnapName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetOnapName_1()
- throws Exception {
- Matches fixture = new Matches();
- fixture.setOnapName("");
- fixture.setConfigAttributes(new Hashtable<String, String>());
- fixture.setConfigName("");
-
- String result = fixture.getOnapName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the void setConfigAttributes(Map<String,String>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetConfigAttributes_1()
- throws Exception {
- Matches fixture = new Matches();
- fixture.setOnapName("");
- fixture.setConfigAttributes(new Hashtable<String, String>());
- fixture.setConfigName("");
- Map<String, String> configAttributes = new Hashtable<String, String>();
-
- fixture.setConfigAttributes(configAttributes);
-
- // add additional test code here
- }
-
- /**
- * Run the void setConfigName(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetConfigName_1()
- throws Exception {
- Matches fixture = new Matches();
- fixture.setOnapName("");
- fixture.setConfigAttributes(new Hashtable<String, String>());
- fixture.setConfigName("");
- String configName = "";
-
- fixture.setConfigName(configName);
-
- // add additional test code here
- }
-
- /**
- * Run the void setOnapName(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetOnapName_1()
- throws Exception {
- Matches fixture = new Matches();
- fixture.setOnapName("");
- fixture.setConfigAttributes(new Hashtable<String, String>());
- fixture.setConfigName("");
- String onapName = "";
-
- fixture.setOnapName(onapName);
-
- // add additional test code here
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(MatchesTest.class);
- }
+ private static final String DUMMY_VAL = "SomethingElse";
+
+ private static final String CONFIG_NAME = "CONFIG_NAME";
+
+ private static final String ONAP_NAME = "ONAP_NAME";
+
+ @Test
+ public void testMatches_SetterGetterMethods() {
+ final Matches objUnderTest = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+
+ final Map<String, String> result = objUnderTest.getConfigAttributes();
+
+ assertEquals(ONAP_NAME, objUnderTest.getOnapName());
+ assertEquals(CONFIG_NAME, objUnderTest.getConfigName());
+ assertEquals(0, result.size());
+ }
+
+ @Test
+ public void testMatches_EqualsMethod_SameObjectsAndSameHasCode() {
+ final Matches firstObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+ final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+
+ assertEquals(firstObject, secondObject);
+ assertEquals(firstObject.hashCode(), secondObject.hashCode());
+ }
+
+ @Test
+ public void testMatchesEqualsMethod_differentConfigName_NotEqualsAndDifferentHashCode() {
+ final Matches firstObject = getMatches(ONAP_NAME, DUMMY_VAL, Collections.emptyMap());
+ final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+
+ assertNotEquals(firstObject, secondObject);
+ assertNotEquals(firstObject.hashCode(), secondObject.hashCode());
+ }
+
+ @Test
+ public void testMatchesEqualsMethod_differentObjects_NotEquals() {
+ final String firstObject = new String();
+ final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+ Assert.assertFalse(secondObject.equals(firstObject));
+ }
+
+ @Test
+ public void testMatchesEqualsMethod_nullObject_NotEqualsAndDifferentHashCode() {
+ final String firstObject = null;
+ final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+
+ assertNotEquals(firstObject, secondObject);
+ }
+
+ @Test
+ public void testMatchesEqualsMethod_NullConfigName_NotEqualsAndDifferentHashCode() {
+ final Matches firstObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+ final Matches secondObject = getMatches(ONAP_NAME, null, Collections.emptyMap());
+
+ assertNotEquals(firstObject, secondObject);
+ assertNotEquals(firstObject.hashCode(), secondObject.hashCode());
+ }
+
+ @Test
+ public void testMatchesEqualsMethod_differentOnapName_NotEqualsAndDifferentHashCode() throws Exception {
+ final Matches firstObject = getMatches(DUMMY_VAL, CONFIG_NAME, Collections.emptyMap());
+ final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+
+ assertNotEquals(firstObject, secondObject);
+ assertNotEquals(firstObject.hashCode(), secondObject.hashCode());
+ }
+
+ @Test
+ public void testMatchesEqualsMethod_NullOnapName_NotEqualsAndDifferentHashCode() throws Exception {
+ final Matches firstObject = getMatches(null, CONFIG_NAME, Collections.emptyMap());
+ final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, Collections.emptyMap());
+
+ assertNotEquals(firstObject, secondObject);
+ assertNotEquals(firstObject.hashCode(), secondObject.hashCode());
+ }
+
+ @Test
+ public void testMatchesEqualsMethod_BothNullOnapName_Equals() throws Exception {
+ final Matches firstObject = getMatches(null, CONFIG_NAME, Collections.emptyMap());
+ final Matches secondObject = getMatches(null, CONFIG_NAME, Collections.emptyMap());
+
+ assertEquals(firstObject, secondObject);
+ assertEquals(firstObject.hashCode(), secondObject.hashCode());
+ }
+
+ @Test
+ public void testMatchesEqualsMethod_BothNullConfigName_Equals() throws Exception {
+ final Matches firstObject = getMatches(ONAP_NAME, null, Collections.emptyMap());
+ final Matches secondObject = getMatches(ONAP_NAME, null, Collections.emptyMap());
+
+ assertEquals(firstObject, secondObject);
+ assertEquals(firstObject.hashCode(), secondObject.hashCode());
+ }
+
+ @Test
+ public void testMatchesEqualsMethod_DifferentConfigAttr_NotEqualsAndDifferentHashCode() throws Exception {
+ final Map<String, String> firstMap = Collections.emptyMap();
+ final Map<String, String> secondMap = new HashMap<>();
+ secondMap.put("key", "value");
+
+ final Matches firstObject = getMatches(ONAP_NAME, CONFIG_NAME, firstMap);
+ final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, secondMap);
+
+ assertNotEquals(firstObject, secondObject);
+ assertNotEquals(firstObject.hashCode(), secondObject.hashCode());
+ }
+
+ @Test
+ public void testMatchesEqualsMethod_NullConfigAttr_NotEqualsAndDifferentHashCode() throws Exception {
+ final Map<String, String> secondMap = new HashMap<>();
+ secondMap.put("key", "value");
+
+ final Matches firstObject = getMatches(ONAP_NAME, CONFIG_NAME, null);
+ final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, secondMap);
+
+ assertNotEquals(firstObject, secondObject);
+ assertNotEquals(firstObject.hashCode(), secondObject.hashCode());
+ }
+
+ @Test
+ public void testMatchesEqualsMethod_BothNullConfigAttr_Equals() throws Exception {
+
+ final Matches firstObject = getMatches(ONAP_NAME, CONFIG_NAME, null);
+ final Matches secondObject = getMatches(ONAP_NAME, CONFIG_NAME, null);
+
+ assertEquals(firstObject, secondObject);
+ assertEquals(firstObject.hashCode(), secondObject.hashCode());
+ }
+
+ private Matches getMatches(final String onapName, final String configName, final Map<String, String> attributes) {
+ final Matches objUnderTest = new Matches();
+ objUnderTest.setOnapName(onapName);
+ objUnderTest.setConfigName(configName);
+ objUnderTest.setConfigAttributes(attributes);
+ return objUnderTest;
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args
+ * the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(final String[] args) {
+ new org.junit.runner.JUnitCore().run(MatchesTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationUnMarshalTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationUnMarshalTest.java
index fb42f98aa..d26a1b254 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationUnMarshalTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationUnMarshalTest.java
@@ -20,237 +20,304 @@
package org.onap.policy.std.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.policy.api.UpdateType;
import org.onap.policy.std.NotificationUnMarshal;
+import org.onap.policy.std.StdLoadedPolicy;
import org.onap.policy.std.StdPDPNotification;
+import org.onap.policy.std.StdRemovedPolicy;
+
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
/**
- * The class <code>NotificationUnMarshalTest</code> contains tests for the class <code>{@link NotificationUnMarshal}</code>.
+ * The class <code>NotificationUnMarshalTest</code> contains tests for the class
+ * <code>{@link NotificationUnMarshal}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class NotificationUnMarshalTest {
- /**
- * Run the StdPDPNotification notificationJSON(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
- public void testNotificationJSON_1()
- throws Exception {
- String json = "";
-
- StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
- // add additional test code here
- assertNotNull(result);
- }
-
- /**
- * Run the StdPDPNotification notificationJSON(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
- public void testNotificationJSON_2()
- throws Exception {
- String json = "";
-
- StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
- // add additional test code here
- assertNotNull(result);
- }
-
- /**
- * Run the StdPDPNotification notificationJSON(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
- public void testNotificationJSON_3()
- throws Exception {
- String json = "";
-
- StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
- // add additional test code here
- assertNotNull(result);
- }
-
- /**
- * Run the StdPDPNotification notificationJSON(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
- public void testNotificationJSON_4()
- throws Exception {
- String json = "";
-
- StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
- // add additional test code here
- assertNotNull(result);
- }
-
- /**
- * Run the StdPDPNotification notificationJSON(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
- public void testNotificationJSON_5()
- throws Exception {
- String json = "";
-
- StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
- // add additional test code here
- assertNotNull(result);
- }
-
- /**
- * Run the StdPDPNotification notificationJSON(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
- public void testNotificationJSON_6()
- throws Exception {
- String json = "";
-
- StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
- // add additional test code here
- assertNotNull(result);
- }
-
- /**
- * Run the StdPDPNotification notificationJSON(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
- public void testNotificationJSON_7()
- throws Exception {
- String json = "";
-
- StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
- // add additional test code here
- assertNotNull(result);
- }
-
- /**
- * Run the StdPDPNotification notificationJSON(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
- public void testNotificationJSON_8()
- throws Exception {
- String json = "";
-
- StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
- // add additional test code here
- assertNotNull(result);
- }
-
- /**
- * Run the StdPDPNotification notificationJSON(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
- public void testNotificationJSON_9()
- throws Exception {
- String json = "";
-
- StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
- // add additional test code here
- assertNotNull(result);
- }
-
- /**
- * Run the StdPDPNotification notificationJSON(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
- public void testNotificationJSON_10()
- throws Exception {
- String json = "";
-
- StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
-
- // add additional test code here
- assertNotNull(result);
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(NotificationUnMarshalTest.class);
- }
+ private static final String EMPTY_STRING = "";
+
+ private static final String POLICY_NAME = "ONAP";
+
+ private static final String POLICY_VERSION = "1.0.0";
+
+ /**
+ * Run the StdPDPNotification notificationJSON(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test(expected = JsonMappingException.class)
+ public void testNotificationJSON_EmptyString_ShouldThrowException() throws Exception {
+ final StdPDPNotification result = NotificationUnMarshal.notificationJSON(EMPTY_STRING);
+
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testNotificationJSON_StdPDPNotificationJsonStringWithEmptyLoadedAndRemovedPolicies_emptyLoadedPolices()
+ throws Exception {
+ final String json = getPDPNotificationAsJsonString(new StdPDPNotification());
+
+ final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+ assertNotNull(result);
+ assertTrue(result.getLoadedPolicies().isEmpty());
+ }
+
+ @Test
+ public void testNotificationJSON_StdPDPNotificationJsonStringWithEmptyLoadedpolicy_emptyLoadedPolices()
+ throws Exception {
+ final StdPDPNotification notification = getPDPNotification(
+ Arrays.asList(getRemovedPolicy(POLICY_VERSION, POLICY_NAME)), Collections.emptyList());
+ final String json = getPDPNotificationAsJsonString(notification);
+
+ final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+ assertNotNull(result);
+ assertTrue(result.getLoadedPolicies().isEmpty());
+ }
+
+ @Test
+ public void testNotificationJSON_validPDPNotificationJsonStringWithRemovedAndLoadedPolicies_UpdateTypeUpdateAndLoadedPolicyAdded()
+ throws Exception {
+ final List<StdRemovedPolicy> removedPolicies = Arrays.asList(getRemovedPolicy(POLICY_VERSION, POLICY_NAME));
+ final List<StdLoadedPolicy> loadedPolicies = Arrays.asList(getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME));
+ final StdPDPNotification notification = getPDPNotification(removedPolicies, loadedPolicies);
+
+ final String json = getPDPNotificationAsJsonString(notification);
+
+ final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+ assertNotNull(result);
+ assertFalse(result.getLoadedPolicies().isEmpty());
+
+ final StdLoadedPolicy actualPolicy = (StdLoadedPolicy) result.getLoadedPolicies().iterator().next();
+ assertEquals(POLICY_VERSION, actualPolicy.getVersionNo());
+ assertEquals(POLICY_NAME, actualPolicy.getPolicyName());
+ assertEquals(UpdateType.UPDATE, actualPolicy.getUpdateType());
+ }
+
+ /**
+ * Run the StdPDPNotification notificationJSON(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testNotificationJSON_validPDPNotificationJsonStringWithRemovedAndLoadedPolicies_UpdateTypeNewAndLoadedPolicyAdded()
+ throws Exception {
+ final List<StdRemovedPolicy> removedPolicies = Arrays.asList(getRemovedPolicy(POLICY_VERSION, "Something"));
+ final List<StdLoadedPolicy> loadedPolices = Arrays.asList(getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME));
+ final StdPDPNotification notification = getPDPNotification(removedPolicies, loadedPolices);
+
+ final String json = getPDPNotificationAsJsonString(notification);
+
+ final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+ assertNotNull(result);
+ assertFalse(result.getLoadedPolicies().isEmpty());
+
+ final StdLoadedPolicy actualPolicy = (StdLoadedPolicy) result.getLoadedPolicies().iterator().next();
+ assertEquals(POLICY_VERSION, actualPolicy.getVersionNo());
+ assertEquals(POLICY_NAME, actualPolicy.getPolicyName());
+ assertEquals(UpdateType.NEW, actualPolicy.getUpdateType());
+ }
+
+ @Test
+ public void testNotificationJSON_validPDPNotificationJsonStringLoadedPoliciesAndNullRemovedPolicies_UpdateTypeNewAndLoadedPolicyAdded()
+ throws Exception {
+ final List<StdLoadedPolicy> loadedPolices = Arrays.asList(getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME));
+ final StdPDPNotification notification = getPDPNotification(null, loadedPolices);
+
+ final String json = getPDPNotificationAsJsonString(notification);
+
+ final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+ assertNotNull(result);
+ assertFalse(result.getLoadedPolicies().isEmpty());
+
+ final StdLoadedPolicy actualPolicy = (StdLoadedPolicy) result.getLoadedPolicies().iterator().next();
+ assertEquals(POLICY_VERSION, actualPolicy.getVersionNo());
+ assertEquals(POLICY_NAME, actualPolicy.getPolicyName());
+ assertEquals(UpdateType.NEW, actualPolicy.getUpdateType());
+ }
+
+ /**
+ * Run the StdPDPNotification notificationJSON(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
+ public void testNotificationJSON_7() throws Exception {
+ final String json = EMPTY_STRING;
+
+ final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+ // add additional test code here
+ assertNotNull(result);
+ }
+
+ /**
+ * Run the StdPDPNotification notificationJSON(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
+ public void testNotificationJSON_8() throws Exception {
+ final String json = EMPTY_STRING;
+
+ final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+ // add additional test code here
+ assertNotNull(result);
+ }
+
+ /**
+ * Run the StdPDPNotification notificationJSON(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
+ public void testNotificationJSON_9() throws Exception {
+ final String json = EMPTY_STRING;
+
+ final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+ // add additional test code here
+ assertNotNull(result);
+ }
+
+ /**
+ * Run the StdPDPNotification notificationJSON(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test(expected = com.fasterxml.jackson.databind.JsonMappingException.class)
+ public void testNotificationJSON_10() throws Exception {
+ final String json = EMPTY_STRING;
+
+ final StdPDPNotification result = NotificationUnMarshal.notificationJSON(json);
+
+ // add additional test code here
+ assertNotNull(result);
+ }
+
+ private String getPDPNotificationAsJsonString(final StdPDPNotification notification) {
+ final ObjectMapper mapper = new ObjectMapper();
+
+ try {
+ return mapper.writeValueAsString(notification);
+ } catch (final Exception expection) {
+ throw new RuntimeException(expection);
+ }
+
+ }
+
+ private StdPDPNotification getPDPNotification(final Collection<StdRemovedPolicy> removedPolicies,
+ final Collection<StdLoadedPolicy> loadedPolicies) {
+ final StdPDPNotification oldNotification = new StdPDPNotification();
+ oldNotification.setLoadedPolicies(loadedPolicies);
+ oldNotification.setRemovedPolicies(removedPolicies);
+ return oldNotification;
+ }
+
+ private StdRemovedPolicy getRemovedPolicy(final String version, final String policyName) {
+ return new StdRemovedPolicy() {
+
+ @Override
+ public String getVersionNo() {
+ return version;
+ }
+
+ @Override
+ public String getPolicyName() {
+ return policyName;
+ }
+ };
+ }
+
+ private StdLoadedPolicy getStdLoadedPolicy(final String version, final String policyName) {
+ return new StdLoadedPolicy() {
+
+ @Override
+ public String getVersionNo() {
+ return version;
+ }
+
+ @Override
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ @Override
+ public Map<String, String> getMatches() {
+ return Collections.emptyMap();
+ }
+ };
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args
+ * the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(final String[] args) {
+ new org.junit.runner.JUnitCore().run(NotificationUnMarshalTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyConfigTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyConfigTest.java
index 736f51b57..e754a42aa 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyConfigTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyConfigTest.java
@@ -20,6 +20,7 @@
package org.onap.policy.std.test;
+import java.util.Collections;
import java.util.Hashtable;
import java.util.Map;
import java.util.Properties;
@@ -28,6 +29,7 @@ import javax.json.JsonObject;
import org.junit.*;
import org.onap.policy.api.PolicyConfigStatus;
+import org.onap.policy.api.PolicyConfigType;
import org.onap.policy.api.PolicyType;
import org.onap.policy.std.StdPolicyConfig;
@@ -36,786 +38,775 @@ import static org.junit.Assert.*;
import org.w3c.dom.Document;
/**
- * The class <code>StdPolicyConfigTest</code> contains tests for the class <code>{@link StdPolicyConfig}</code>.
+ * The class <code>StdPolicyConfigTest</code> contains tests for the class
+ * <code>{@link StdPolicyConfig}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class StdPolicyConfigTest {
- /**
- * Run the Map<String, String> getMatchingConditions() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetMatchingConditions_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
-
- Map<String, String> result = fixture.getMatchingConditions();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the String getPolicyConfigMessage() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetPolicyConfigMessage_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
-
- String result = fixture.getPolicyConfigMessage();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the PolicyConfigStatus getPolicyConfigStatus() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetPolicyConfigStatus_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
-
- PolicyConfigStatus result = fixture.getPolicyConfigStatus();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("not_found", result.toString());
- assertEquals("CONFIG_NOT_FOUND", result.name());
- assertEquals(1, result.ordinal());
- }
-
- /**
- * Run the String getPolicyName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetPolicyName_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
-
- String result = fixture.getPolicyName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the String getPolicyName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetPolicyName_2()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName((String) null);
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
-
- String result = fixture.getPolicyName();
-
- // add additional test code here
- assertEquals(null, result);
- }
-
- /**
- * Run the String getPolicyName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetPolicyName_3()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
-
- String result = fixture.getPolicyName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the String getPolicyVersion() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetPolicyVersion_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
-
- String result = fixture.getPolicyVersion();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the Map<String, String> getResponseAttributes() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetResponseAttributes_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
-
- Map<String, String> result = fixture.getResponseAttributes();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the PolicyType getType() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetType_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
-
- PolicyType result = fixture.getType();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("json", result.toString());
- assertEquals("JSON", result.name());
- assertEquals(1, result.ordinal());
- }
-
- /**
- * Run the void setConfigStatus(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetConfigStatus_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
- String configStatus = "";
-
- fixture.setConfigStatus(configStatus);
-
- // add additional test code here
- }
-
- /**
- * Run the void setConfigStatus(String,PolicyConfigStatus) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetConfigStatus_2()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
- String configStatus = "";
- PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND;
-
- fixture.setConfigStatus(configStatus, policyConfigStatus);
-
- // add additional test code here
- }
-
- /**
- * Run the void setDocument(Document) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetDocument_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
- Document document = null;
-
- fixture.setDocument(document);
-
- // add additional test code here
- }
-
- /**
- * Run the void setJsonObject(JsonObject) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetJsonObject_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
- JsonObject jsonObject = null;
-
- fixture.setJsonObject(jsonObject);
-
- // add additional test code here
- }
-
- /**
- * Run the void setMatchingConditions(Map<String,String>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetMatchingConditions_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
- Map<String, String> matchingConditions = new Hashtable<String, String>();
-
- fixture.setMatchingConditions(matchingConditions);
-
- // add additional test code here
- }
-
- /**
- * Run the void setOther(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetOther_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
- String other = "";
-
- fixture.setOther(other);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyConfigStatus(PolicyConfigStatus) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetPolicyConfigStatus_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
- PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND;
-
- fixture.setPolicyConfigStatus(policyConfigStatus);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyName(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetPolicyName_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
- String policyName = "";
-
- fixture.setPolicyName(policyName);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyType(PolicyType) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetPolicyType_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
- PolicyType policyType = PolicyType.JSON;
-
- fixture.setPolicyType(policyType);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyVersion(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetPolicyVersion_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
- String policyVersion = "";
-
- fixture.setPolicyVersion(policyVersion);
-
- // add additional test code here
- }
-
- /**
- * Run the void setProperties(Properties) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetProperties_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
- Properties properties = new Properties();
-
- fixture.setProperties(properties);
-
- // add additional test code here
- }
-
- /**
- * Run the void setResponseAttributes(Map<String,String>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetResponseAttributes_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
- Map<String, String> responseAttributes = new Hashtable<String, String>();
-
- fixture.setResponseAttributes(responseAttributes);
-
- // add additional test code here
- }
-
- /**
- * Run the JsonObject toJSON() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testToJSON_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
-
- JsonObject result = fixture.toJSON();
-
- // add additional test code here
- assertEquals(null, result);
- }
-
- /**
- * Run the String toOther() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testToOther_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
-
- String result = fixture.toOther();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the Properties toProperties() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testToProperties_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
-
- Properties result = fixture.toProperties();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the String toString() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testToString_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("test");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
-
- String result = fixture.toString();
-
- // add additional test code here
- assertEquals("PolicyConfig [ policyConfigStatus=not_found, policyConfigMessage=, policyName=test]", result);
- }
-
- /**
- * Run the Document toXML() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testToXML_1()
- throws Exception {
- StdPolicyConfig fixture = new StdPolicyConfig();
- fixture.setConfigStatus("", PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setDocument((Document) null);
- fixture.setResponseAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setOther("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setPolicyName("");
- fixture.setProperties(new Properties());
- fixture.setJsonObject((JsonObject) null);
- fixture.setMatchingConditions(new Hashtable<String, String>());
-
- Document result = fixture.toXML();
-
- // add additional test code here
- assertEquals(null, result);
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(StdPolicyConfigTest.class);
- }
+ private static final String POLICY_NAME = "PolicyName";
+
+ private static final String POLICY_NAME_WITH_XML_EXT = POLICY_NAME + ".1.xml";
+
+ private static final String EMPTY_STRING = "";
+
+ /**
+ * Run the Map<String, String> getMatchingConditions() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetMatchingConditions_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+
+ final Map<String, String> result = fixture.getMatchingConditions();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the String getPolicyConfigMessage() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetPolicyConfigMessage_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+
+ final String result = fixture.getPolicyConfigMessage();
+
+ // add additional test code here
+ assertEquals(EMPTY_STRING, result);
+ }
+
+ /**
+ * Run the PolicyConfigStatus getPolicyConfigStatus() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetPolicyConfigStatus_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+
+ final PolicyConfigStatus result = fixture.getPolicyConfigStatus();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("not_found", result.toString());
+ assertEquals("CONFIG_NOT_FOUND", result.name());
+ assertEquals(1, result.ordinal());
+ }
+
+ /**
+ * Run the String getPolicyName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetPolicyName_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+
+ final String result = fixture.getPolicyName();
+
+ // add additional test code here
+ assertEquals(EMPTY_STRING, result);
+ }
+
+ /**
+ * Run the String getPolicyName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetPolicyName_2() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName((String) null);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+
+ final String result = fixture.getPolicyName();
+
+ // add additional test code here
+ assertEquals(null, result);
+ }
+
+ /**
+ * Run the String getPolicyName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetPolicyName_3() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+
+ final String result = fixture.getPolicyName();
+
+ // add additional test code here
+ assertEquals(EMPTY_STRING, result);
+ }
+
+ /**
+ * Run the String getPolicyVersion() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetPolicyVersion_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+
+ final String result = fixture.getPolicyVersion();
+
+ // add additional test code here
+ assertEquals(EMPTY_STRING, result);
+ }
+
+ /**
+ * Run the Map<String, String> getResponseAttributes() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetResponseAttributes_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+
+ final Map<String, String> result = fixture.getResponseAttributes();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the PolicyType getType() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetType_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+
+ final PolicyType result = fixture.getType();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("json", result.toString());
+ assertEquals("JSON", result.name());
+ assertEquals(1, result.ordinal());
+ }
+
+ /**
+ * Run the void setConfigStatus(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetGetPolicyConfigType_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyType(PolicyConfigType.BRMS_RAW);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setConfigStatus(EMPTY_STRING);
+
+ assertEquals(PolicyConfigType.BRMS_RAW, fixture.getPolicyType());
+
+ }
+
+ /**
+ * Run the void setConfigStatus(String,PolicyConfigStatus) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetConfigStatus_2() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ final String configStatus = EMPTY_STRING;
+ final PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND;
+
+ fixture.setConfigStatus(configStatus, policyConfigStatus);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setDocument(Document) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetDocument_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ final Document document = null;
+
+ fixture.setDocument(document);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setJsonObject(JsonObject) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetJsonObject_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ final JsonObject jsonObject = null;
+
+ fixture.setJsonObject(jsonObject);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setMatchingConditions(Map<String,String>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetMatchingConditions_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ final Map<String, String> matchingConditions = new Hashtable<String, String>();
+
+ fixture.setMatchingConditions(matchingConditions);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setOther(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetOther_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ final String other = EMPTY_STRING;
+
+ fixture.setOther(other);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyConfigStatus(PolicyConfigStatus) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetPolicyConfigStatus_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ final PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND;
+
+ fixture.setPolicyConfigStatus(policyConfigStatus);
+
+ assertEquals(policyConfigStatus, fixture.getPolicyConfigStatus());
+ }
+
+ @Test
+ public void testSetGetPolicyName_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(Collections.emptyMap());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(Collections.emptyMap());
+ fixture.setPolicyName(EMPTY_STRING);
+
+ assertEquals(EMPTY_STRING, fixture.getPolicyName());
+
+ }
+
+ @Test
+ public void testSetGetPolicyName_2() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(Collections.emptyMap());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(POLICY_NAME_WITH_XML_EXT);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(Collections.emptyMap());
+
+ assertEquals(POLICY_NAME, fixture.getPolicyName());
+
+ }
+
+ /**
+ * Run the void setPolicyType(PolicyType) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetPolicyType_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(Collections.emptyMap());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(Collections.emptyMap());
+ final PolicyType policyType = PolicyType.JSON;
+
+ fixture.setPolicyType(policyType);
+
+ assertEquals(policyType, fixture.getType());
+ }
+
+ /**
+ * Run the void setPolicyVersion(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetPolicyVersion_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(Collections.emptyMap());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(Collections.emptyMap());
+ fixture.setPolicyVersion(EMPTY_STRING);
+
+ assertEquals(EMPTY_STRING, fixture.getPolicyVersion());
+
+ }
+
+ /**
+ * Run the void setProperties(Properties) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetProperties_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(Collections.emptyMap());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(Collections.emptyMap());
+ final Properties properties = new Properties();
+
+ fixture.setProperties(properties);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setResponseAttributes(Map<String,String>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetResponseAttributes_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ final Map<String, String> responseAttributes = new Hashtable<String, String>();
+
+ fixture.setResponseAttributes(responseAttributes);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the JsonObject toJSON() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testToJSON_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+
+ final JsonObject result = fixture.toJSON();
+
+ // add additional test code here
+ assertEquals(null, result);
+ }
+
+ /**
+ * Run the String toOther() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testToOther_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+
+ final String result = fixture.toOther();
+
+ // add additional test code here
+ assertEquals(EMPTY_STRING, result);
+ }
+
+ /**
+ * Run the Properties toProperties() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testToProperties_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+
+ final Properties result = fixture.toProperties();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the String toString() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testToString_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName("test");
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+
+ final String result = fixture.toString();
+
+ // add additional test code here
+ assertEquals("PolicyConfig [ policyConfigStatus=not_found, policyConfigMessage=, policyName=test]", result);
+ }
+
+ /**
+ * Run the Document toXML() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testToXML_1() throws Exception {
+ final StdPolicyConfig fixture = new StdPolicyConfig();
+ fixture.setConfigStatus(EMPTY_STRING, PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setDocument((Document) null);
+ fixture.setResponseAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion(EMPTY_STRING);
+ fixture.setOther(EMPTY_STRING);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setPolicyName(EMPTY_STRING);
+ fixture.setProperties(new Properties());
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+
+ final Document result = fixture.toXML();
+
+ // add additional test code here
+ assertEquals(null, result);
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args
+ * the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(final String[] args) {
+ new org.junit.runner.JUnitCore().run(StdPolicyConfigTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/APIDictionaryResponseTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/APIDictionaryResponseTest.java
new file mode 100644
index 000000000..44bf759dd
--- /dev/null
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/APIDictionaryResponseTest.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * APIDictionaryResponse
+ * ================================================================================
+ * Copyright (C) 2018 Ericsson. 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.test;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.ws.rs.core.Response.Status;
+
+import org.junit.Test;
+import org.onap.policy.models.APIDictionaryResponse;
+
+public class APIDictionaryResponseTest {
+
+ private static final String JSON_STRING = "JSON_STRING";
+
+ private static final String DICTIONARY_DATA = "DICTIONARY_DATA";
+
+ @Test
+ public final void testSetAndGet() {
+ final APIDictionaryResponse objUnderTest = new APIDictionaryResponse();
+ objUnderTest.setDictionaryData(DICTIONARY_DATA);
+ objUnderTest.setDictionaryJson(JSON_STRING);
+ objUnderTest.setResponseCode(Status.BAD_GATEWAY.getStatusCode());
+ objUnderTest.setResponseMessage(Status.BAD_GATEWAY.toString());
+
+ assertEquals(DICTIONARY_DATA, objUnderTest.getDictionaryData());
+ assertEquals(JSON_STRING, objUnderTest.getDictionaryJson());
+ assertEquals(Status.BAD_GATEWAY.getStatusCode(), objUnderTest.getResponseCode());
+ assertEquals(Status.BAD_GATEWAY.toString(), objUnderTest.getResponseMessage());
+
+ }
+}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyConditionTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyConditionTest.java
index d59a14658..7255f1c86 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyConditionTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyConditionTest.java
@@ -26,73 +26,58 @@ import org.onap.policy.api.DeletePolicyCondition;
import static org.junit.Assert.*;
/**
- * The class <code>DeletePolicyConditionTest</code> contains tests for the class <code>{@link DeletePolicyCondition}</code>.
+ * The class <code>DeletePolicyConditionTest</code> contains tests for the class
+ * <code>{@link DeletePolicyCondition}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class DeletePolicyConditionTest {
- /**
- * Run the String toString() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testToString_1()
- throws Exception {
- DeletePolicyCondition fixture = DeletePolicyCondition.ALL;
- String result = fixture.toString();
+ @Test
+ public void testToString_1() throws Exception {
+ final DeletePolicyCondition fixture = DeletePolicyCondition.ALL;
- // add additional test code here
- assertEquals("All Versions", result);
-
- assertEquals(DeletePolicyCondition.ALL, DeletePolicyCondition.create(DeletePolicyCondition.ALL.name()));
- }
+ final String result = fixture.toString();
- @Test(expected = IllegalArgumentException.class)
- public void testException() {
- DeletePolicyCondition.create("foobar");
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ // add additional test code here
+ assertEquals("All Versions", result);
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ assertEquals(DeletePolicyCondition.ALL, DeletePolicyCondition.create(DeletePolicyCondition.ALL.name()));
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(DeletePolicyConditionTest.class);
- }
+ @Test
+ public void testCreate_EnumName_DeletePolicyConditionEnum() {
+ for (final DeletePolicyCondition condition : DeletePolicyCondition.values()) {
+ final DeletePolicyCondition actualCondition = DeletePolicyCondition.create(condition.name());
+ assertEquals(condition, actualCondition);
+ assertEquals(condition.toString(), actualCondition.toString());
+ }
+ }
+
+ @Test
+ public void testCreate_StringValue_DeletePolicyConditionEnum() {
+ for (final DeletePolicyCondition condition : DeletePolicyCondition.values()) {
+ final DeletePolicyCondition actualCondition = DeletePolicyCondition.create(condition.toString());
+ assertEquals(condition, actualCondition);
+ }
+
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testException() {
+ DeletePolicyCondition.create("foobar");
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args
+ * the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(final String[] args) {
+ new org.junit.runner.JUnitCore().run(DeletePolicyConditionTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyParametersTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyParametersTest.java
index 423b839f6..14e1360ce 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyParametersTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyParametersTest.java
@@ -29,286 +29,181 @@ import org.onap.policy.api.DeletePolicyParameters;
import static org.junit.Assert.*;
/**
- * The class <code>DeletePolicyParametersTest</code> contains tests for the class <code>{@link DeletePolicyParameters}</code>.
+ * The class <code>DeletePolicyParametersTest</code> contains tests for the
+ * class <code>{@link DeletePolicyParameters}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class DeletePolicyParametersTest {
- /**
- * Run the DeletePolicyCondition getDeleteCondition() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetDeleteCondition_1()
- throws Exception {
- DeletePolicyParameters fixture = new DeletePolicyParameters();
- fixture.setPolicyComponent("");
- fixture.setPolicyName("");
- fixture.setDeleteCondition(DeletePolicyCondition.ALL);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setPdpGroup("");
-
- DeletePolicyCondition result = fixture.getDeleteCondition();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("All Versions", result.toString());
- assertEquals("ALL", result.name());
- assertEquals(1, result.ordinal());
- }
-
- /**
- * Run the String getPdpGroup() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPdpGroup_1()
- throws Exception {
- DeletePolicyParameters fixture = new DeletePolicyParameters();
- fixture.setPolicyComponent("");
- fixture.setPolicyName("");
- fixture.setDeleteCondition(DeletePolicyCondition.ALL);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setPdpGroup("");
-
- String result = fixture.getPdpGroup();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the String getPolicyComponent() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyComponent_1()
- throws Exception {
- DeletePolicyParameters fixture = new DeletePolicyParameters();
- fixture.setPolicyComponent("");
- fixture.setPolicyName("");
- fixture.setDeleteCondition(DeletePolicyCondition.ALL);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setPdpGroup("");
-
- String result = fixture.getPolicyComponent();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the String getPolicyName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyName_1()
- throws Exception {
- DeletePolicyParameters fixture = new DeletePolicyParameters();
- fixture.setPolicyComponent("");
- fixture.setPolicyName("");
- fixture.setDeleteCondition(DeletePolicyCondition.ALL);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setPdpGroup("");
-
- String result = fixture.getPolicyName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the UUID getRequestID() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetRequestID_1()
- throws Exception {
- DeletePolicyParameters fixture = new DeletePolicyParameters();
- fixture.setPolicyComponent("");
- fixture.setPolicyName("");
- fixture.setDeleteCondition(DeletePolicyCondition.ALL);
- fixture.setRequestID(UUID.fromString("482e90e2-2ad7-4265-9893-4cfe08ef1e3d"));
- fixture.setPdpGroup("");
-
- UUID result = fixture.getRequestID();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("482e90e2-2ad7-4265-9893-4cfe08ef1e3d", result.toString());
- assertEquals(4, result.version());
- assertEquals(2, result.variant());
- assertEquals(-7452528304412746179L, result.getLeastSignificantBits());
- assertEquals(5201253920715260517L, result.getMostSignificantBits());
- }
-
- /**
- * Run the void setDeleteCondition(DeletePolicyCondition) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetDeleteCondition_1()
- throws Exception {
- DeletePolicyParameters fixture = new DeletePolicyParameters();
- fixture.setPolicyComponent("");
- fixture.setPolicyName("");
- fixture.setDeleteCondition(DeletePolicyCondition.ALL);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setPdpGroup("");
- DeletePolicyCondition deleteCondition = DeletePolicyCondition.ALL;
-
- fixture.setDeleteCondition(deleteCondition);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPdpGroup(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPdpGroup_1()
- throws Exception {
- DeletePolicyParameters fixture = new DeletePolicyParameters();
- fixture.setPolicyComponent("");
- fixture.setPolicyName("");
- fixture.setDeleteCondition(DeletePolicyCondition.ALL);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setPdpGroup("");
- String pdpGroup = "";
-
- fixture.setPdpGroup(pdpGroup);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyComponent(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyComponent_1()
- throws Exception {
- DeletePolicyParameters fixture = new DeletePolicyParameters();
- fixture.setPolicyComponent("");
- fixture.setPolicyName("");
- fixture.setDeleteCondition(DeletePolicyCondition.ALL);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setPdpGroup("");
- String policyComponent = "";
-
- fixture.setPolicyComponent(policyComponent);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyName(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyName_1()
- throws Exception {
- DeletePolicyParameters fixture = new DeletePolicyParameters();
- fixture.setPolicyComponent("");
- fixture.setPolicyName("");
- fixture.setDeleteCondition(DeletePolicyCondition.ALL);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setPdpGroup("");
- String policyName = "";
-
- fixture.setPolicyName(policyName);
-
- // add additional test code here
- }
-
- /**
- * Run the void setRequestID(UUID) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetRequestID_1()
- throws Exception {
- DeletePolicyParameters fixture = new DeletePolicyParameters();
- fixture.setPolicyComponent("");
- fixture.setPolicyName("");
- fixture.setDeleteCondition(DeletePolicyCondition.ALL);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setPdpGroup("");
- UUID requestID = UUID.randomUUID();
-
- fixture.setRequestID(requestID);
-
- // add additional test code here
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(DeletePolicyParametersTest.class);
- }
+ private static final String POLICY_TYPE = "POLICYTYPE";
+
+ private static final String PDP_GROUP = "PDPGROUP";
+
+ private static final String POLICY_NAME = "Apex";
+
+ private static final String POLICY_COMPONENT = "ApexComponent";
+
+ /**
+ * Run the DeletePolicyCondition getDeleteCondition() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetDeleteCondition_1() throws Exception {
+ final DeletePolicyParameters fixture = new DeletePolicyParameters();
+ fixture.setPolicyComponent("");
+ fixture.setPolicyName("");
+ fixture.setDeleteCondition(DeletePolicyCondition.ALL);
+ fixture.setRequestID(UUID.randomUUID());
+ fixture.setPdpGroup("");
+
+ final DeletePolicyCondition result = fixture.getDeleteCondition();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("All Versions", result.toString());
+ assertEquals("ALL", result.name());
+ assertEquals(1, result.ordinal());
+ }
+
+ /**
+ * Run the String getPdpGroup() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPdpGroup_1() throws Exception {
+ final DeletePolicyParameters fixture = new DeletePolicyParameters();
+ fixture.setPolicyComponent("");
+ fixture.setPolicyName("");
+ fixture.setDeleteCondition(DeletePolicyCondition.ALL);
+ fixture.setRequestID(UUID.randomUUID());
+ fixture.setPdpGroup("");
+
+ final String result = fixture.getPdpGroup();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the String getPolicyComponent() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyComponent_1() throws Exception {
+ final DeletePolicyParameters fixture = new DeletePolicyParameters();
+ fixture.setPolicyComponent("");
+ fixture.setPolicyName("");
+ fixture.setDeleteCondition(DeletePolicyCondition.ALL);
+ fixture.setRequestID(UUID.randomUUID());
+ fixture.setPdpGroup("");
+
+ final String result = fixture.getPolicyComponent();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the UUID getRequestID() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetRequestID_1() throws Exception {
+ final UUID requestID = UUID.fromString("482e90e2-2ad7-4265-9893-4cfe08ef1e3d");
+
+ final DeletePolicyParameters objUnderTest = new DeletePolicyParameters();
+ objUnderTest.setPolicyComponent(POLICY_COMPONENT);
+ objUnderTest.setPolicyName(POLICY_NAME);
+ objUnderTest.setDeleteCondition(DeletePolicyCondition.ALL);
+ objUnderTest.setRequestID(requestID);
+ objUnderTest.setPdpGroup(PDP_GROUP);
+ objUnderTest.setPolicyType(POLICY_TYPE);
+
+ final UUID result = objUnderTest.getRequestID();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("482e90e2-2ad7-4265-9893-4cfe08ef1e3d", result.toString());
+ assertEquals(4, result.version());
+ assertEquals(2, result.variant());
+ assertEquals(-7452528304412746179L, result.getLeastSignificantBits());
+ assertEquals(5201253920715260517L, result.getMostSignificantBits());
+ }
+
+ /**
+ * Run the void setDeleteCondition(DeletePolicyCondition) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetDeleteCondition_1() throws Exception {
+ final UUID requestID = UUID.fromString("482e90e2-2ad7-4265-9893-4cfe08ef1e3d");
+
+ final DeletePolicyParameters objUnderTest = new DeletePolicyParameters();
+ objUnderTest.setPolicyComponent(POLICY_COMPONENT);
+ objUnderTest.setPolicyName(POLICY_NAME);
+ objUnderTest.setDeleteCondition(DeletePolicyCondition.ALL);
+ objUnderTest.setRequestID(requestID);
+ objUnderTest.setPdpGroup(PDP_GROUP);
+ objUnderTest.setPolicyType(POLICY_TYPE);
+
+ assertEquals(POLICY_COMPONENT, objUnderTest.getPolicyComponent());
+ assertEquals(POLICY_NAME, objUnderTest.getPolicyName());
+ assertEquals(POLICY_TYPE, objUnderTest.getPolicyType());
+ assertEquals(DeletePolicyCondition.ALL, objUnderTest.getDeleteCondition());
+ assertEquals(requestID, objUnderTest.getRequestID());
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args
+ * the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(final String[] args) {
+ new org.junit.runner.JUnitCore().run(DeletePolicyParametersTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/DictionaryTypeTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DictionaryTypeTest.java
index bbab6d318..ca85f69c5 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/DictionaryTypeTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DictionaryTypeTest.java
@@ -19,27 +19,34 @@
*/
package org.onap.policy.test;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.onap.policy.api.DictionaryType;
public class DictionaryTypeTest {
- @Before
- public void setUp() throws Exception {
- }
+ @Test
+ public void testCreate_EnumName_DictionaryTypeEnum() {
+ for (final DictionaryType dictionaryType : DictionaryType.values()) {
+ final DictionaryType actualDictionaryType = DictionaryType.create(dictionaryType.name());
+ assertEquals(dictionaryType, actualDictionaryType);
+ assertEquals(dictionaryType.toString(), actualDictionaryType.toString());
+ }
+ }
- @After
- public void tearDown() throws Exception {
- }
+ @Test
+ public void testCreate_StringValue_DictionaryTypeEnum() {
+ for (final DictionaryType dictionaryType : DictionaryType.values()) {
+ final DictionaryType actualDictionaryType = DictionaryType.create(dictionaryType.toString());
+ assertEquals(dictionaryType, actualDictionaryType);
+ }
+ }
- @Test(expected = IllegalArgumentException.class)
- public void test() {
- assertEquals(DictionaryType.Action, DictionaryType.create(DictionaryType.Action.toString()));
- DictionaryType.create("foobar");
- }
+ @Test(expected = IllegalArgumentException.class)
+ public void test() {
+ assertEquals(DictionaryType.Action, DictionaryType.create(DictionaryType.Action.toString()));
+ DictionaryType.create("foobar");
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyClassTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyClassTest.java
index b4aaa64d8..88b3bc8cb 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyClassTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyClassTest.java
@@ -20,78 +20,63 @@
package org.onap.policy.test;
-import org.junit.*;
-import org.onap.policy.api.PolicyClass;
+import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.*;
+import org.junit.Test;
+import org.onap.policy.api.PolicyClass;
/**
- * The class <code>PolicyClassTest</code> contains tests for the class <code>{@link PolicyClass}</code>.
+ * The class <code>PolicyClassTest</code> contains tests for the class
+ * <code>{@link PolicyClass}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class PolicyClassTest {
- /**
- * Run the String toString() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testToString_1() {
- PolicyClass fixture = PolicyClass.Action;
- String result = fixture.toString();
+ @Test
+ public void testToString_1() {
+ final PolicyClass fixture = PolicyClass.Action;
+
+ final String result = fixture.toString();
+
+ // add additional test code here
+ assertEquals("Action", result);
+
+ assertEquals(PolicyClass.Decision, PolicyClass.create(PolicyClass.Decision.toString()));
+ }
- // add additional test code here
- assertEquals("Action", result);
-
- assertEquals(PolicyClass.Decision, PolicyClass.create(PolicyClass.Decision.toString()));
- }
+ @Test
+ public void testCreate_EnumName_PolicyClassEnum() {
+ for (final PolicyClass policyClass : PolicyClass.values()) {
+ final PolicyClass actualPolicyClass = PolicyClass.create(policyClass.name());
+ assertEquals(policyClass, actualPolicyClass);
+ assertEquals(policyClass.toString(), actualPolicyClass.toString());
+ }
+ }
- @Test(expected = IllegalArgumentException.class)
- public void testException() {
- PolicyClass.create("foobar");
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ @Test
+ public void testCreate_StringValue_PolicyClassEnum() {
+ for (final PolicyClass policyClass : PolicyClass.values()) {
+ final PolicyClass actualPolicyClass = PolicyClass.create(policyClass.toString());
+ assertEquals(policyClass, actualPolicyClass);
+ }
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ @Test(expected = IllegalArgumentException.class)
+ public void testException() {
+ PolicyClass.create("foobar");
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PolicyClassTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args
+ * the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(final String[] args) {
+ new org.junit.runner.JUnitCore().run(PolicyClassTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigStatusTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigStatusTest.java
index 49691724a..e7d82499f 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigStatusTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigStatusTest.java
@@ -20,120 +20,95 @@
package org.onap.policy.test;
-import org.junit.*;
-import org.onap.policy.api.PolicyConfigStatus;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.*;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.api.PolicyConfigStatus;
/**
- * The class <code>PolicyConfigStatusTest</code> contains tests for the class <code>{@link PolicyConfigStatus}</code>.
+ * The class <code>PolicyConfigStatusTest</code> contains tests for the class
+ * <code>{@link PolicyConfigStatus}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class PolicyConfigStatusTest {
- /**
- * Run the PolicyConfigStatus getStatus(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetStatus_1()
- throws Exception {
- String configStatus = "";
-
- PolicyConfigStatus result = PolicyConfigStatus.getStatus(configStatus);
+ /**
+ * Run the PolicyConfigStatus getStatus(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetStatus_1() throws Exception {
+ final String configStatus = "";
- // add additional test code here
- assertNotNull(result);
- assertEquals("not_found", result.toString());
- assertEquals("CONFIG_NOT_FOUND", result.name());
- assertEquals(1, result.ordinal());
-
- assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED, PolicyConfigStatus.create("retrieved"));
- }
+ final PolicyConfigStatus result = PolicyConfigStatus.getStatus(configStatus);
- /**
- * Run the PolicyConfigStatus getStatus(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetStatus_2()
- throws Exception {
- String configStatus = "retrieved";
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("not_found", result.toString());
+ assertEquals("CONFIG_NOT_FOUND", result.name());
+ assertEquals(1, result.ordinal());
- PolicyConfigStatus result = PolicyConfigStatus.getStatus(configStatus);
+ assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED, PolicyConfigStatus.create("retrieved"));
+ }
- // add additional test code here
- assertNotNull(result);
- assertEquals("retrieved", result.toString());
- assertEquals("CONFIG_RETRIEVED", result.name());
- assertEquals(0, result.ordinal());
- }
+ /**
+ * Run the PolicyConfigStatus getStatus(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetStatus_2() throws Exception {
+ final String configStatus = "retrieved";
- /**
- * Run the String toString() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testToString_1()
- throws Exception {
- PolicyConfigStatus fixture = PolicyConfigStatus.CONFIG_NOT_FOUND;
+ final PolicyConfigStatus result = PolicyConfigStatus.getStatus(configStatus);
- String result = fixture.toString();
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("retrieved", result.toString());
+ assertEquals("CONFIG_RETRIEVED", result.name());
+ assertEquals(0, result.ordinal());
+ }
- // add additional test code here
- assertEquals("not_found", result);
- }
+ @Test
+ public void testCreate_EnumName_PolicyConfigStatusEnum() {
+ for (final PolicyConfigStatus policyConfigStatus : PolicyConfigStatus.values()) {
+ final PolicyConfigStatus actualPolicyConfigStatus = PolicyConfigStatus.create(policyConfigStatus.name());
+ assertEquals(policyConfigStatus, actualPolicyConfigStatus);
+ assertEquals(policyConfigStatus.toString(), actualPolicyConfigStatus.toString());
+ }
+ }
- @Test(expected = IllegalArgumentException.class)
- public void testException () {
- PolicyConfigStatus.create("foobar");
- }
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ @Test
+ public void testCreate_StringValue_PolicyClassEnum() {
+ for (final PolicyConfigStatus policyConfigStatus : PolicyConfigStatus.values()) {
+ final PolicyConfigStatus actualPolicyClass = PolicyConfigStatus.create(policyConfigStatus.toString());
+ assertEquals(policyConfigStatus, actualPolicyClass);
+ }
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ @Test(expected = IllegalArgumentException.class)
+ public void testException() {
+ PolicyConfigStatus.create("foobar");
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PolicyConfigStatusTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args
+ * the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(final String[] args) {
+ new org.junit.runner.JUnitCore().run(PolicyConfigStatusTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionTest.java
index a6391700f..a63094a7b 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionTest.java
@@ -20,79 +20,51 @@
package org.onap.policy.test;
-import org.junit.*;
-import org.onap.policy.api.PolicyDecision;
+import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.*;
+import org.junit.Test;
+import org.onap.policy.api.PolicyDecision;
/**
- * The class <code>PolicyDecisionTest</code> contains tests for the class <code>{@link PolicyDecision}</code>.
+ * The class <code>PolicyDecisionTest</code> contains tests for the class
+ * <code>{@link PolicyDecision}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class PolicyDecisionTest {
- /**
- * Run the String toString() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testToString_1()
- throws Exception {
- PolicyDecision fixture = PolicyDecision.DENY;
-
- String result = fixture.toString();
- // add additional test code here
- assertEquals("deny", result);
-
- assertEquals(PolicyDecision.PERMIT, PolicyDecision.create(PolicyDecision.PERMIT.name()));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testException() {
- PolicyDecision.create("foobar");
- }
+ @Test
+ public void testCreate_EnumName_PolicyDecisionEnum() {
+ for (final PolicyDecision policyDecision : PolicyDecision.values()) {
+ final PolicyDecision actualPolicyDecision = PolicyDecision.create(policyDecision.name());
+ assertEquals(policyDecision, actualPolicyDecision);
+ assertEquals(policyDecision.toString(), actualPolicyDecision.toString());
+ }
+ }
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ @Test
+ public void testCreate_StringValue_PolicyDecisionEnum() {
+ for (final PolicyDecision policyDecision : PolicyDecision.values()) {
+ final PolicyDecision autalPolicyDecision = PolicyDecision.create(policyDecision.toString());
+ assertEquals(policyDecision, autalPolicyDecision);
+ }
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ @Test(expected = IllegalArgumentException.class)
+ public void testException() {
+ PolicyDecision.create("foobar");
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PolicyDecisionTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args
+ * the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(final String[] args) {
+ new org.junit.runner.JUnitCore().run(PolicyDecisionTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseStatusTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseStatusTest.java
index 4803a8ece..587b19332 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseStatusTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseStatusTest.java
@@ -20,142 +20,160 @@
package org.onap.policy.test;
-import org.junit.*;
-import org.onap.policy.api.PolicyResponseStatus;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.*;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.api.PolicyResponseStatus;
/**
- * The class <code>PolicyResponseStatusTest</code> contains tests for the class <code>{@link PolicyResponseStatus}</code>.
+ * The class <code>PolicyResponseStatusTest</code> contains tests for the class
+ * <code>{@link PolicyResponseStatus}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class PolicyResponseStatusTest {
- /**
- * Run the PolicyResponseStatus getStatus(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetStatus_1()
- throws Exception {
- String responseStatus = "";
-
- PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("no_action", result.toString());
- assertEquals("NO_ACTION_REQUIRED", result.name());
- assertEquals(0, result.ordinal());
- }
-
- /**
- * Run the PolicyResponseStatus getStatus(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetStatus_2()
- throws Exception {
- String responseStatus = "action_advised";
-
- PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("action_advised", result.toString());
- assertEquals("ACTION_ADVISED", result.name());
- assertEquals(1, result.ordinal());
- }
-
- /**
- * Run the PolicyResponseStatus getStatus(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetStatus_3()
- throws Exception {
- String responseStatus = "action_taken";
-
- PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("action_taken", result.toString());
- assertEquals("ACTION_TAKEN", result.name());
- assertEquals(2, result.ordinal());
- }
-
- /**
- * Run the String toString() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testToString_1()
- throws Exception {
- PolicyResponseStatus fixture = PolicyResponseStatus.ACTION_ADVISED;
-
- String result = fixture.toString();
-
- // add additional test code here
- assertEquals("action_advised", result);
-
- assertEquals(PolicyResponseStatus.ACTION_ADVISED, PolicyResponseStatus.create("ACTION_ADVISED"));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testTheRest() {
- PolicyResponseStatus.create("foobar");
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PolicyResponseStatusTest.class);
- }
+ /**
+ * Run the PolicyResponseStatus getStatus(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetStatus_1() throws Exception {
+ final String responseStatus = "";
+
+ final PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("no_action", result.toString());
+ assertEquals("NO_ACTION_REQUIRED", result.name());
+ assertEquals(0, result.ordinal());
+ }
+
+ @Test
+ public void testCreate_EnumName_PolicyResponseStatusEnum() {
+ for (final PolicyResponseStatus policyResponseStatus : PolicyResponseStatus.values()) {
+ final PolicyResponseStatus actualPolicyResponseStatus = PolicyResponseStatus
+ .create(policyResponseStatus.name());
+ assertEquals(policyResponseStatus, actualPolicyResponseStatus);
+ assertEquals(policyResponseStatus.toString(), actualPolicyResponseStatus.toString());
+ }
+ }
+
+ @Test
+ public void testCreate_StringValue_PolicyResponseStatusEnum() {
+ for (final PolicyResponseStatus policyResponseStatus : PolicyResponseStatus.values()) {
+ final PolicyResponseStatus actualPolicyResponseStatus = PolicyResponseStatus
+ .create(policyResponseStatus.toString());
+ assertEquals(policyResponseStatus, actualPolicyResponseStatus);
+ }
+ }
+
+ /**
+ * Run the PolicyResponseStatus getStatus(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetStatus_2() throws Exception {
+ final String responseStatus = "action_advised";
+
+ final PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("action_advised", result.toString());
+ assertEquals("ACTION_ADVISED", result.name());
+ assertEquals(1, result.ordinal());
+ }
+
+ /**
+ * Run the PolicyResponseStatus getStatus(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetStatus_3() throws Exception {
+ final String responseStatus = "action_taken";
+
+ final PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("action_taken", result.toString());
+ assertEquals("ACTION_TAKEN", result.name());
+ assertEquals(2, result.ordinal());
+ }
+
+ /**
+ * Run the String toString() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testToString_1() throws Exception {
+ final PolicyResponseStatus fixture = PolicyResponseStatus.ACTION_ADVISED;
+
+ final String result = fixture.toString();
+
+ // add additional test code here
+ assertEquals("action_advised", result);
+
+ assertEquals(PolicyResponseStatus.ACTION_ADVISED, PolicyResponseStatus.create("ACTION_ADVISED"));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testTheRest() {
+ PolicyResponseStatus.create("foobar");
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args
+ * the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(final String[] args) {
+ new org.junit.runner.JUnitCore().run(PolicyResponseStatusTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyTypeTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyTypeTest.java
index 267dd9771..49bdfe876 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyTypeTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyTypeTest.java
@@ -20,79 +20,69 @@
package org.onap.policy.test;
-import org.junit.*;
-import org.onap.policy.api.PolicyType;
+import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.*;
+import org.junit.Test;
+import org.onap.policy.api.PolicyType;
/**
- * The class <code>PolicyTypeTest</code> contains tests for the class <code>{@link PolicyType}</code>.
+ * The class <code>PolicyTypeTest</code> contains tests for the class
+ * <code>{@link PolicyType}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class PolicyTypeTest {
- /**
- * Run the String toString() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testToString_1()
- throws Exception {
- PolicyType fixture = PolicyType.JSON;
+ /**
+ * Run the String toString() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testToString_1() throws Exception {
+ final PolicyType fixture = PolicyType.JSON;
+
+ final String result = fixture.toString();
+
+ // add additional test code here
+ assertEquals("json", result);
- String result = fixture.toString();
+ assertEquals(PolicyType.JSON, PolicyType.create("json"));
+ }
- // add additional test code here
- assertEquals("json", result);
-
- assertEquals(PolicyType.JSON, PolicyType.create("json"));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testException() {
- PolicyType.create("foobar");
- }
+ @Test
+ public void testCreate_EnumName_PolicyTypeEnum() {
+ for (final PolicyType policyType : PolicyType.values()) {
+ final PolicyType actualPolicyType = PolicyType.create(policyType.name());
+ assertEquals(policyType, actualPolicyType);
+ assertEquals(policyType.toString(), actualPolicyType.toString());
+ }
+ }
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ @Test
+ public void testCreate_StringValue_PolicyTypeEnum() {
+ for (final PolicyType policyType : PolicyType.values()) {
+ final PolicyType actualPolicyType = PolicyType.create(policyType.toString());
+ assertEquals(policyType, actualPolicyType);
+ }
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ @Test(expected = IllegalArgumentException.class)
+ public void testException() {
+ PolicyType.create("foobar");
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PolicyTypeTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args
+ * the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(final String[] args) {
+ new org.junit.runner.JUnitCore().run(PolicyTypeTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/RuleProviderTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/RuleProviderTest.java
index 23353232e..756997e78 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/RuleProviderTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/RuleProviderTest.java
@@ -19,21 +19,38 @@
*/
package org.onap.policy.test;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.onap.policy.api.RuleProvider;
public class RuleProviderTest {
- @Test
- public void test() {
- assertEquals(RuleProvider.RAINY_DAY, RuleProvider.create(RuleProvider.RAINY_DAY.name()));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testException() {
- RuleProvider.create("foobar");
- }
+ @Test
+ public void test() {
+ assertEquals(RuleProvider.RAINY_DAY, RuleProvider.create(RuleProvider.RAINY_DAY.name()));
+ }
+
+ @Test
+ public void testCreate_EnumName_RuleProviderEnum() {
+ for (final RuleProvider ruleProvider : RuleProvider.values()) {
+ final RuleProvider actualRuleProvider = RuleProvider.create(ruleProvider.name());
+ assertEquals(ruleProvider, actualRuleProvider);
+ assertEquals(ruleProvider.toString(), actualRuleProvider.toString());
+ }
+ }
+
+ @Test
+ public void testCreate_StringValue_RuleProviderEnum() {
+ for (final RuleProvider ruleProvider : RuleProvider.values()) {
+ final RuleProvider actualRuleProvider = RuleProvider.create(ruleProvider.toString());
+ assertEquals(ruleProvider, actualRuleProvider);
+ }
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testException() {
+ RuleProvider.create("foobar");
+ }
}