From 073cc188efe9abb4c010cf674e34e2cf46ef1c52 Mon Sep 17 00:00:00 2001 From: Guo Ruijing Date: Mon, 31 Jul 2017 08:47:35 +0000 Subject: [POLICY-73] replace openecomp for policy-engine Change-Id: I54072f6bcd388c0e05562614ee89b4ae7ad67004 Signed-off-by: Guo Ruijing Signed-off-by: Pamela Dragosh --- .../java/org/onap/policy/api/AttributeType.java | 78 ++ .../onap/policy/api/ConfigRequestParameters.java | 148 ++ .../onap/policy/api/DecisionRequestParameters.java | 104 ++ .../java/org/onap/policy/api/DecisionResponse.java | 43 + .../org/onap/policy/api/DeletePolicyCondition.java | 65 + .../onap/policy/api/DeletePolicyParameters.java | 114 ++ .../org/onap/policy/api/DictionaryParameters.java | 82 ++ .../org/onap/policy/api/DictionaryResponse.java | 41 + .../java/org/onap/policy/api/DictionaryType.java | 100 ++ .../onap/policy/api/EventRequestParameters.java | 89 ++ .../java/org/onap/policy/api/ImportParameters.java | 175 +++ .../onap/policy/api/MetricsRequestParameters.java | 21 + .../java/org/onap/policy/api/MetricsResponse.java | 45 + .../org/onap/policy/api/NotificationScheme.java | 61 + .../org/onap/policy/api/PolicyChangeResponse.java | 44 + .../main/java/org/onap/policy/api/PolicyClass.java | 67 + .../java/org/onap/policy/api/PolicyConfig.java | 123 ++ .../org/onap/policy/api/PolicyConfigException.java | 49 + .../org/onap/policy/api/PolicyConfigStatus.java | 79 ++ .../java/org/onap/policy/api/PolicyConfigType.java | 87 ++ .../java/org/onap/policy/api/PolicyDecision.java | 68 + .../onap/policy/api/PolicyDecisionException.java | 50 + .../java/org/onap/policy/api/PolicyEngine.java | 602 ++++++++ .../org/onap/policy/api/PolicyEngineException.java | 49 + .../org/onap/policy/api/PolicyEventException.java | 49 + .../java/org/onap/policy/api/PolicyException.java | 29 + .../java/org/onap/policy/api/PolicyParameters.java | 557 ++++++++ .../java/org/onap/policy/api/PolicyResponse.java | 77 ++ .../org/onap/policy/api/PolicyResponseStatus.java | 85 ++ .../main/java/org/onap/policy/api/PolicyType.java | 72 + .../org/onap/policy/api/PushPolicyParameters.java | 131 ++ .../java/org/onap/policy/api/RuleProvider.java | 73 + .../java/org/onap/policy/api/package-info.java | 36 + .../org/onap/policy/models/APIConfigResponse.java | 37 + .../onap/policy/models/APIDictionaryResponse.java | 53 + .../policy/models/APIPolicyConfigResponse.java | 91 ++ .../java/org/onap/policy/std/AutoClientDMAAP.java | 132 ++ .../java/org/onap/policy/std/AutoClientEnd.java | 248 ++++ .../java/org/onap/policy/std/AutoClientUEB.java | 178 +++ .../java/org/onap/policy/std/ManualClientEnd.java | 138 ++ .../org/onap/policy/std/ManualClientEndDMAAP.java | 107 ++ .../org/onap/policy/std/ManualClientEndUEB.java | 160 +++ .../main/java/org/onap/policy/std/MatchStore.java | 246 ++++ .../src/main/java/org/onap/policy/std/Matches.java | 48 + .../org/onap/policy/std/NotificationUnMarshal.java | 69 + .../org/onap/policy/std/StdDecisionResponse.java | 55 + .../org/onap/policy/std/StdDictionaryResponse.java | 73 + .../org/onap/policy/std/StdMetricsResponse.java | 78 ++ .../onap/policy/std/StdPolicyChangeResponse.java | 47 + .../java/org/onap/policy/std/StdPolicyConfig.java | 168 +++ .../java/org/onap/policy/std/StdPolicyEngine.java | 1254 +++++++++++++++++ .../org/onap/policy/std/StdPolicyResponse.java | 98 ++ .../main/java/org/onap/policy/std/StdStatus.java | 235 ++++ .../java/org/onap/policy/std/package-info.java | 27 + .../org/openecomp/policy/api/AttributeType.java | 78 -- .../policy/api/ConfigRequestParameters.java | 148 -- .../policy/api/DecisionRequestParameters.java | 104 -- .../org/openecomp/policy/api/DecisionResponse.java | 43 - .../policy/api/DeletePolicyCondition.java | 65 - .../policy/api/DeletePolicyParameters.java | 114 -- .../openecomp/policy/api/DictionaryParameters.java | 82 -- .../openecomp/policy/api/DictionaryResponse.java | 41 - .../org/openecomp/policy/api/DictionaryType.java | 100 -- .../policy/api/EventRequestParameters.java | 89 -- .../org/openecomp/policy/api/ImportParameters.java | 175 --- .../policy/api/MetricsRequestParameters.java | 21 - .../org/openecomp/policy/api/MetricsResponse.java | 45 - .../openecomp/policy/api/NotificationScheme.java | 61 - .../openecomp/policy/api/PolicyChangeResponse.java | 44 - .../java/org/openecomp/policy/api/PolicyClass.java | 67 - .../org/openecomp/policy/api/PolicyConfig.java | 123 -- .../policy/api/PolicyConfigException.java | 49 - .../openecomp/policy/api/PolicyConfigStatus.java | 79 -- .../org/openecomp/policy/api/PolicyConfigType.java | 87 -- .../org/openecomp/policy/api/PolicyDecision.java | 68 - .../policy/api/PolicyDecisionException.java | 50 - .../org/openecomp/policy/api/PolicyEngine.java | 602 -------- .../policy/api/PolicyEngineException.java | 49 - .../openecomp/policy/api/PolicyEventException.java | 49 - .../org/openecomp/policy/api/PolicyException.java | 29 - .../org/openecomp/policy/api/PolicyParameters.java | 557 -------- .../org/openecomp/policy/api/PolicyResponse.java | 77 -- .../openecomp/policy/api/PolicyResponseStatus.java | 85 -- .../java/org/openecomp/policy/api/PolicyType.java | 72 - .../openecomp/policy/api/PushPolicyParameters.java | 131 -- .../org/openecomp/policy/api/RuleProvider.java | 73 - .../org/openecomp/policy/api/package-info.java | 36 - .../openecomp/policy/models/APIConfigResponse.java | 37 - .../policy/models/APIDictionaryResponse.java | 53 - .../policy/models/APIPolicyConfigResponse.java | 91 -- .../org/openecomp/policy/std/AutoClientDMAAP.java | 132 -- .../org/openecomp/policy/std/AutoClientEnd.java | 248 ---- .../org/openecomp/policy/std/AutoClientUEB.java | 178 --- .../org/openecomp/policy/std/ManualClientEnd.java | 138 -- .../openecomp/policy/std/ManualClientEndDMAAP.java | 107 -- .../openecomp/policy/std/ManualClientEndUEB.java | 160 --- .../java/org/openecomp/policy/std/MatchStore.java | 246 ---- .../java/org/openecomp/policy/std/Matches.java | 48 - .../policy/std/NotificationUnMarshal.java | 69 - .../openecomp/policy/std/StdDecisionResponse.java | 55 - .../policy/std/StdDictionaryResponse.java | 73 - .../openecomp/policy/std/StdMetricsResponse.java | 78 -- .../policy/std/StdPolicyChangeResponse.java | 47 - .../org/openecomp/policy/std/StdPolicyConfig.java | 168 --- .../org/openecomp/policy/std/StdPolicyEngine.java | 1254 ----------------- .../openecomp/policy/std/StdPolicyResponse.java | 98 -- .../java/org/openecomp/policy/std/StdStatus.java | 235 ---- .../org/openecomp/policy/std/package-info.java | 27 - PolicyEngineAPI/src/main/resources/logback.xml | 2 +- .../onap/policy/std/test/AutoClientEndTest.java | 228 ++++ .../onap/policy/std/test/AutoClientUEBTest.java | 567 ++++++++ .../java/org/onap/policy/std/test/Handler.java | 126 ++ .../onap/policy/std/test/ManualClientEndTest.java | 126 ++ .../policy/std/test/ManualClientEndUEBTest.java | 119 ++ .../org/onap/policy/std/test/MatchStoreTest.java | 776 +++++++++++ .../java/org/onap/policy/std/test/MatchesTest.java | 216 +++ .../policy/std/test/NotificationStoreTest.java | 359 +++++ .../policy/std/test/NotificationUnMarshalTest.java | 256 ++++ .../onap/policy/std/test/StdLoadedPolicyTest.java | 314 +++++ .../policy/std/test/StdPDPNotificationTest.java | 311 +++++ .../std/test/StdPolicyChangeResponseTest.java | 166 +++ .../onap/policy/std/test/StdPolicyConfigTest.java | 821 +++++++++++ .../policy/std/test/StdPolicyResponseTest.java | 348 +++++ .../onap/policy/std/test/StdRemovedPolicyTest.java | 206 +++ .../org/onap/policy/std/test/StdStatusTest.java | 1433 ++++++++++++++++++++ .../org/onap/policy/std/test/package-info.java | 27 + .../org/onap/policy/test/ActionPolicyApiTest.java | 239 ++++ .../org/onap/policy/test/AttributeTypeTest.java | 81 ++ .../org/onap/policy/test/ConfigBasePolicyTest.java | 325 +++++ .../onap/policy/test/ConfigFirewallPolicyTest.java | 254 ++++ .../policy/test/ConfigRequestParametersTest.java | 362 +++++ .../onap/policy/test/DecisionPolicyApiTest.java | 219 +++ .../policy/test/DecisionRequestParametersTest.java | 232 ++++ .../policy/test/DeletePolicyConditionTest.java | 91 ++ .../policy/test/DeletePolicyParametersTest.java | 314 +++++ .../policy/test/EventRequestParametersTest.java | 193 +++ .../policy/test/GetConfigByPolicyNameTest.java | 63 + .../policy/test/GetConfigStringStringMapTest.java | 259 ++++ .../policy/test/GetConfigStringStringTest.java | 213 +++ .../org/onap/policy/test/GetConfigStringTest.java | 170 +++ .../org/onap/policy/test/ImportParametersTest.java | 403 ++++++ .../org/onap/policy/test/LoadedPolicyTest.java | 72 + .../onap/policy/test/NotificationHandlerTest.java | 72 + .../onap/policy/test/NotificationSchemeTest.java | 91 ++ .../org/onap/policy/test/NotificationTypeTest.java | 91 ++ .../org/onap/policy/test/PDPNotificationTest.java | 72 + .../onap/policy/test/PolicyChangeResponseTest.java | 72 + .../java/org/onap/policy/test/PolicyClassTest.java | 91 ++ .../policy/test/PolicyConfigExceptionTest.java | 183 +++ .../onap/policy/test/PolicyConfigStatusTest.java | 133 ++ .../org/onap/policy/test/PolicyConfigTest.java | 72 + .../org/onap/policy/test/PolicyConfigTypeTest.java | 91 ++ .../policy/test/PolicyDecisionExceptionTest.java | 183 +++ .../org/onap/policy/test/PolicyDecisionTest.java | 91 ++ .../policy/test/PolicyEngineExceptionTest.java | 183 +++ .../policy/test/PolicyEngineInterfaceTest.java | 670 +++++++++ .../org/onap/policy/test/PolicyEngineTest.java | 170 +++ .../onap/policy/test/PolicyEventExceptionTest.java | 183 +++ .../org/onap/policy/test/PolicyParametersTest.java | 1409 +++++++++++++++++++ .../onap/policy/test/PolicyResponseStatusTest.java | 154 +++ .../org/onap/policy/test/PolicyResponseTest.java | 72 + .../java/org/onap/policy/test/PolicyTypeTest.java | 91 ++ .../onap/policy/test/PushPolicyParametersTest.java | 269 ++++ .../org/onap/policy/test/RemovedPolicyTest.java | 72 + .../java/org/onap/policy/test/SendEventTest.java | 155 +++ .../test/java/org/onap/policy/test/TestRunner.java | 49 + .../java/org/onap/policy/test/UpdateTypeTest.java | 91 ++ .../java/org/onap/policy/test/package-info.java | 24 + .../policy/std/test/AutoClientEndTest.java | 228 ---- .../policy/std/test/AutoClientUEBTest.java | 567 -------- .../org/openecomp/policy/std/test/Handler.java | 126 -- .../policy/std/test/ManualClientEndTest.java | 126 -- .../policy/std/test/ManualClientEndUEBTest.java | 119 -- .../openecomp/policy/std/test/MatchStoreTest.java | 776 ----------- .../org/openecomp/policy/std/test/MatchesTest.java | 216 --- .../policy/std/test/NotificationStoreTest.java | 359 ----- .../policy/std/test/NotificationUnMarshalTest.java | 256 ---- .../policy/std/test/StdLoadedPolicyTest.java | 314 ----- .../policy/std/test/StdPDPNotificationTest.java | 311 ----- .../std/test/StdPolicyChangeResponseTest.java | 166 --- .../policy/std/test/StdPolicyConfigTest.java | 821 ----------- .../policy/std/test/StdPolicyResponseTest.java | 348 ----- .../policy/std/test/StdRemovedPolicyTest.java | 206 --- .../openecomp/policy/std/test/StdStatusTest.java | 1433 -------------------- .../openecomp/policy/std/test/package-info.java | 27 - .../openecomp/policy/test/ActionPolicyApiTest.java | 239 ---- .../openecomp/policy/test/AttributeTypeTest.java | 81 -- .../policy/test/ConfigBasePolicyTest.java | 325 ----- .../policy/test/ConfigFirewallPolicyTest.java | 254 ---- .../policy/test/ConfigRequestParametersTest.java | 362 ----- .../policy/test/DecisionPolicyApiTest.java | 219 --- .../policy/test/DecisionRequestParametersTest.java | 232 ---- .../policy/test/DeletePolicyConditionTest.java | 91 -- .../policy/test/DeletePolicyParametersTest.java | 314 ----- .../policy/test/EventRequestParametersTest.java | 193 --- .../policy/test/GetConfigByPolicyNameTest.java | 63 - .../policy/test/GetConfigStringStringMapTest.java | 259 ---- .../policy/test/GetConfigStringStringTest.java | 213 --- .../openecomp/policy/test/GetConfigStringTest.java | 170 --- .../policy/test/ImportParametersTest.java | 403 ------ .../openecomp/policy/test/LoadedPolicyTest.java | 72 - .../policy/test/NotificationHandlerTest.java | 72 - .../policy/test/NotificationSchemeTest.java | 91 -- .../policy/test/NotificationTypeTest.java | 91 -- .../openecomp/policy/test/PDPNotificationTest.java | 72 - .../policy/test/PolicyChangeResponseTest.java | 72 - .../org/openecomp/policy/test/PolicyClassTest.java | 91 -- .../policy/test/PolicyConfigExceptionTest.java | 183 --- .../policy/test/PolicyConfigStatusTest.java | 133 -- .../openecomp/policy/test/PolicyConfigTest.java | 72 - .../policy/test/PolicyConfigTypeTest.java | 91 -- .../policy/test/PolicyDecisionExceptionTest.java | 183 --- .../openecomp/policy/test/PolicyDecisionTest.java | 91 -- .../policy/test/PolicyEngineExceptionTest.java | 183 --- .../policy/test/PolicyEngineInterfaceTest.java | 670 --------- .../openecomp/policy/test/PolicyEngineTest.java | 170 --- .../policy/test/PolicyEventExceptionTest.java | 183 --- .../policy/test/PolicyParametersTest.java | 1409 ------------------- .../policy/test/PolicyResponseStatusTest.java | 154 --- .../openecomp/policy/test/PolicyResponseTest.java | 72 - .../org/openecomp/policy/test/PolicyTypeTest.java | 91 -- .../policy/test/PushPolicyParametersTest.java | 269 ---- .../openecomp/policy/test/RemovedPolicyTest.java | 72 - .../org/openecomp/policy/test/SendEventTest.java | 155 --- .../java/org/openecomp/policy/test/TestRunner.java | 49 - .../org/openecomp/policy/test/UpdateTypeTest.java | 91 -- .../org/openecomp/policy/test/package-info.java | 24 - 227 files changed, 21759 insertions(+), 21759 deletions(-) create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/AttributeType.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/ConfigRequestParameters.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/DecisionRequestParameters.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/DecisionResponse.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyCondition.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyParameters.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryParameters.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryResponse.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryType.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/EventRequestParameters.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/ImportParameters.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/MetricsRequestParameters.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/MetricsResponse.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/NotificationScheme.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyChangeResponse.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyClass.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfig.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigException.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigType.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecision.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecisionException.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngineException.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEventException.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyException.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyParameters.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponse.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponseStatus.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyType.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/PushPolicyParameters.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/RuleProvider.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/api/package-info.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/models/APIConfigResponse.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/models/APIDictionaryResponse.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/models/APIPolicyConfigResponse.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientDMAAP.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientEnd.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientUEB.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEnd.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndDMAAP.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndUEB.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/MatchStore.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/Matches.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/NotificationUnMarshal.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/StdDecisionResponse.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/StdDictionaryResponse.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/StdMetricsResponse.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyChangeResponse.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyConfig.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyResponse.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/StdStatus.java create mode 100644 PolicyEngineAPI/src/main/java/org/onap/policy/std/package-info.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/AttributeType.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ConfigRequestParameters.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionRequestParameters.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionResponse.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyCondition.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyParameters.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryParameters.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryResponse.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryType.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/EventRequestParameters.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ImportParameters.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/MetricsRequestParameters.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/MetricsResponse.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/NotificationScheme.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyChangeResponse.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyClass.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfig.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigException.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigStatus.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigType.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecision.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecisionException.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngine.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngineException.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEventException.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyException.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyParameters.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponse.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponseStatus.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyType.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PushPolicyParameters.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/RuleProvider.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/api/package-info.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/models/APIConfigResponse.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/models/APIDictionaryResponse.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/models/APIPolicyConfigResponse.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientDMAAP.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientEnd.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEnd.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndDMAAP.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/Matches.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDecisionResponse.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDictionaryResponse.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdMetricsResponse.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyChangeResponse.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyConfig.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyResponse.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdStatus.java delete mode 100644 PolicyEngineAPI/src/main/java/org/openecomp/policy/std/package-info.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/AutoClientEndTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/AutoClientUEBTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/Handler.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndUEBTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchStoreTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchesTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationStoreTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationUnMarshalTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdLoadedPolicyTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPDPNotificationTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyChangeResponseTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyConfigTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyResponseTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdRemovedPolicyTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdStatusTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/std/test/package-info.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/ActionPolicyApiTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/AttributeTypeTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigBasePolicyTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigFirewallPolicyTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigRequestParametersTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionPolicyApiTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionRequestParametersTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyConditionTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyParametersTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/EventRequestParametersTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigByPolicyNameTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringMapTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/ImportParametersTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/LoadedPolicyTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationHandlerTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationSchemeTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationTypeTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PDPNotificationTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyChangeResponseTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyClassTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigExceptionTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigStatusTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTypeTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionExceptionTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineExceptionTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineInterfaceTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEventExceptionTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyParametersTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseStatusTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyTypeTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/PushPolicyParametersTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/RemovedPolicyTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/SendEventTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/TestRunner.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/UpdateTypeTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/onap/policy/test/package-info.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/AutoClientEndTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/AutoClientUEBTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/Handler.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/ManualClientEndTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/ManualClientEndUEBTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/MatchStoreTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/MatchesTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/NotificationStoreTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/NotificationUnMarshalTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdLoadedPolicyTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPDPNotificationTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPolicyChangeResponseTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPolicyConfigTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPolicyResponseTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdRemovedPolicyTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdStatusTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/package-info.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ActionPolicyApiTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/AttributeTypeTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigBasePolicyTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigFirewallPolicyTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigRequestParametersTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DecisionPolicyApiTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DecisionRequestParametersTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DeletePolicyConditionTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DeletePolicyParametersTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/EventRequestParametersTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigByPolicyNameTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringStringMapTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringStringTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ImportParametersTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/LoadedPolicyTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationHandlerTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationSchemeTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationTypeTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PDPNotificationTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyChangeResponseTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyClassTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigExceptionTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigStatusTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTypeTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyDecisionExceptionTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyDecisionTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineExceptionTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineInterfaceTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEventExceptionTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyParametersTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseStatusTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyTypeTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PushPolicyParametersTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/RemovedPolicyTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/SendEventTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/TestRunner.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/UpdateTypeTest.java delete mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/package-info.java (limited to 'PolicyEngineAPI/src') diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/AttributeType.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/AttributeType.java new file mode 100644 index 000000000..8cfa51212 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/AttributeType.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import com.fasterxml.jackson.annotation.JsonCreator; + +/** + * Enumeration of the Attribute Types that is used as a part of + * {@link org.onap.policy.api.PolicyParameters}. + * + * @version 0.1 + */ +public enum AttributeType { + /** + * Indicates Attributes required to Match the Policy. + */ + MATCHING("matching"), + /** + * Indicates Attributes required to create DRL based Rules. + */ + RULE("rule"), + /** + * Indicates Attributes required to create MicroService policy. + */ + MICROSERVICE("microService"), + /** + * Indicates Attributes required to create settings for Decision Policy. + */ + SETTINGS("settings"), + /** + * Indicates Attributes required to create dictionary fields for creating Dictionary Items + */ + DICTIONARY("dictionary") + ; + + + private String name; + + private AttributeType(String typeName){ + this.name = typeName; + } + + /** + * Returns the String format of Type for this AttributeType + * @return the String of the Type for this AttributeType + */ + public String toString() { + return this.name; + } + + @JsonCreator + public static AttributeType create (String value) { + for(AttributeType type: values()){ + if(type.toString().equalsIgnoreCase(value)){ + return type; + } + } + throw new IllegalArgumentException(); + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/ConfigRequestParameters.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/ConfigRequestParameters.java new file mode 100644 index 000000000..cdee9672b --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/ConfigRequestParameters.java @@ -0,0 +1,148 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import java.util.Map; +import java.util.UUID; + +/** + * ConfigRequestParameters defines the Config Policy Request Parameters + * which retrieve(s) the policy from PDP if the request parameters match with any Config Policy. + * + * @version 0.1 + */ +public class ConfigRequestParameters { + private String policyName; + private String onapComponentName; + private String configName; + private Map configAttributes; + private UUID requestID; + private Boolean unique = false; + + /** + * Sets the PolicyName of the Config policy which needs to be retrieved. + * + * @param policyName the String format of the PolicyFile Name whose configuration is required. + */ + public void setPolicyName(String policyName){ + this.policyName = policyName; + } + + /** + * Sets the ONAP Component Name of the Config policy which needs to be retrieved. + * + * @param onapComponentName the String format of the onapComponentName whose configuration is required. + */ + public void setOnapName(String onapComponentName){ + this.onapComponentName = onapComponentName; + } + + /** + * Sets the Config Name of the Config policy which needs to be retrieved. + * + * @param configName the String format of the configurationName whose configuration is required. + */ + public void setConfigName(String configName){ + this.configName = configName; + } + + /** + * Sets the ConfigAttributes of the Config policy which needs to be retrieved. + * + * @param configAttributes the Map of String,String format of the configuration attributes which are required. + */ + public void setConfigAttributes(Map configAttributes){ + this.configAttributes = configAttributes; + } + + /** + * Sets the Request ID of the ONAP request. + * + * @param requestID unique UUID requestID which will be passed throughout the ONAP components to correlate logging messages. + */ + public void setRequestID(UUID requestID){ + this.requestID = requestID; + } + + /** + * Gets the policyName of the Request Parameters. + * + * @return String format of the policyName. + */ + public String getPolicyName(){ + return policyName; + } + + /** + * Gets the ONAP Component Name of the Request Parameters. + * + * @return String format of the ONAP Component Name. + */ + public String getOnapName(){ + return onapComponentName; + } + + /** + * Gets the Config name of the Request Parameters. + * + * @return String format of the Config Name. + */ + public String getConfigName(){ + return configName; + } + + /** + * Gets the Config Attributes of the Request Parameters. + * + * @return Map of String,String format of the config Attributes. + */ + public Map getConfigAttributes(){ + return configAttributes; + } + + /** + * Gets the Request ID of the Request Paramters. + * + * @return UUID format of requestID. + */ + public UUID getRequestID(){ + return requestID; + } + + /** + * Makes the results Unique, priority based. If set to True. Default Value is set to False. + * + * @param unique flag which is either true or false. + */ + public void makeUnique(Boolean unique){ + this.unique = unique; + } + + /** + * Gets the Unique flag value from the Config Request Parameters. + * + * @return unique flag which is either true or false. + */ + public Boolean getUnique(){ + return this.unique; + } + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DecisionRequestParameters.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DecisionRequestParameters.java new file mode 100644 index 000000000..27e419fb1 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DecisionRequestParameters.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import java.util.Map; +import java.util.UUID; + +/** + * DecisionRequestParameters defines the Decision Policy Request Parameters + * which retrieve(s) the response from PDP if the request parameters match with any Decision Policy. + * + * @version 0.1 + */ +public class DecisionRequestParameters { + private String onapComponentName; + private Map decisionAttributes; + private UUID requestID; + + /** + * Constructor with no Parameters + */ + public DecisionRequestParameters(){ + } + + /** + * Constructor with Parameters + * + * @param onapComponentName the String format of the onapComponentName whose Decision is required. + * @param decisionAttributes the Map of String,String format of the decisionAttributes that contain the ID and values. + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + */ + public DecisionRequestParameters(String onapComponentName, Map decisionAttributes, UUID requestID){ + this.onapComponentName = onapComponentName; + this.decisionAttributes = decisionAttributes; + this.requestID = requestID; + } + + /** + * Gets the ONAPComponentName of the Decision Request Parameters. + * + * @return ONAPComponentName the String format of the onapComponentName of the Decision Request Parameters. + */ + public String getONAPComponentName() { + return onapComponentName; + } + /** + * Sets the ONAPComponentName of the Decision Request parameters. + * + * @param onapComponentName the String format of the onapComponentName whose Decision is required. + */ + public void setONAPComponentName(String onapComponentName) { + this.onapComponentName = onapComponentName; + } + /** + * Gets the Decision Attributes from Decision Request Parameters. + * + * @return decisionAttributes the Map of String,String format of the decisionAttributes that contain the ID and values. + */ + public Map getDecisionAttributes() { + return decisionAttributes; + } + /** + * Sets the Decision Attributes which contain ID and values for obtaining Decision from PDP. + * + * @param decisionAttributes the Map of String,String format of the decisionAttributes that must contain the ID and values. + */ + public void setDecisionAttributes(Map decisionAttributes) { + this.decisionAttributes = decisionAttributes; + } + /** + * Gets the request ID of Decision Request Parameters. + * + * @return the requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + */ + public UUID getRequestID() { + return requestID; + } + /** + * Sets the ReqestID of Decision Request Parameters which will be passed around ONAP requests. + * + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + */ + public void setRequestID(UUID requestID) { + this.requestID = requestID; + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DecisionResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DecisionResponse.java new file mode 100644 index 000000000..78e80f07b --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DecisionResponse.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +/** + * Defines the Object that represents the Policy Decision Response elements. + * DecisionResponse communicates the decision and details + * + * @version 0.1 + */ +public interface DecisionResponse { + /** + * Gets the Decision of the Policy, Either a Permit or Deny. + * + * @return {@link org.onap.policy.api.PolicyDecision} Enumeration. + */ + public PolicyDecision getDecision(); + + /** + * Gets the details of the result. Would be required in case of Deny. + * + * @return String format of the details of Deny cause. + */ + public String getDetails(); +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyCondition.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyCondition.java new file mode 100644 index 000000000..4001d3fa6 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyCondition.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import com.fasterxml.jackson.annotation.JsonCreator; + +/** + * Enumeration of the Policy Delete Condition that is used as a part of + * {@link org.onap.policy.api.DeletePolicyParameters}. + * + * @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; + } + + /** + * Returns the String format of delete condition for this Policy + * @return the String of the delete condition for this Policy + */ + public String toString(){ + return this.name; + } + + @JsonCreator + public static DeletePolicyCondition create (String value) { + for(DeletePolicyCondition type: values()){ + if(type.toString().equals(value) || type.equals(DeletePolicyCondition.valueOf(value))){ + return type; + } + } + throw new IllegalArgumentException(); + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyParameters.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyParameters.java new file mode 100644 index 000000000..4f6779291 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyParameters.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import java.util.UUID; + +/** + * PushPolicyParameters defines the Policy Parameters + * which are required to Push a Policy to PDPGroup. + * + * @version 0.1 + */ +public class DeletePolicyParameters { + + private String policyName; + private String policyType; + private String policyComponent; + private DeletePolicyCondition deleteCondition; + private String pdpGroup; + private UUID requestID; + + + /** + * @return the policyName + */ + public String getPolicyName() { + return policyName; + } + /** + * @param policyName the policyName to set + */ + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + /** + * @return the policyComponent + */ + public String getPolicyComponent() { + return policyComponent; + } + /** + * @return the policyType + */ + public String getPolicyType() { + return policyType; + } + /** + * @param policyType the policyType to set + */ + public void setPolicyType(String policyType) { + this.policyType = policyType; + } + /** + * @param policyComponent the policyComponent to set + */ + public void setPolicyComponent(String policyComponent) { + this.policyComponent = policyComponent; + } + /** + * @return the deleteCondition + */ + public DeletePolicyCondition getDeleteCondition() { + return deleteCondition; + } + /** + * @param deleteCondition the deleteCondition to set + */ + public void setDeleteCondition(DeletePolicyCondition deleteCondition) { + this.deleteCondition = deleteCondition; + } + /** + * @return the requestID + */ + public UUID getRequestID() { + return requestID; + } + /** + * @param requestID the requestID to set + */ + public void setRequestID(UUID requestID) { + this.requestID = requestID; + } + /** + * @return the pdpGroup + */ + public String getPdpGroup() { + return pdpGroup; + } + /** + * @param pdpGroup the pdpGroup to set + */ + public void setPdpGroup(String pdpGroup) { + this.pdpGroup = pdpGroup; + } + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryParameters.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryParameters.java new file mode 100644 index 000000000..e4aa5e1a5 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryParameters.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import java.util.UUID; + +public class DictionaryParameters { + + private DictionaryType dictionaryType; + private String dictionary; + private String dictionaryJson; + private UUID requestID; + + + /** + * @return the dictionaryType + */ + public DictionaryType getDictionaryType() { + return dictionaryType; + } + /** + * @param dictionaryType the dictionaryType to set + */ + public void setDictionaryType(DictionaryType dictionaryType) { + this.dictionaryType = dictionaryType; + } + /** + * @return the dictionary + */ + public String getDictionary() { + return dictionary; + } + /** + * @param dictionary the dictionary to set + */ + public void setDictionary(String dictionary) { + this.dictionary = dictionary; + } + /** + * @return the dictionaryFields + */ + public String getDictionaryJson() { + return dictionaryJson; + } + /** + * @param dictionaryFields the dictionaryFields to set + */ + public void setDictionaryJson(String dictionaryJson) { + this.dictionaryJson = dictionaryJson; + } + /** + * @return the requestID + */ + public UUID getRequestID() { + return requestID; + } + /** + * @param requestID the requestID to set + */ + public void setRequestID(UUID requestID) { + this.requestID = requestID; + } + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryResponse.java new file mode 100644 index 000000000..4381e694f --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryResponse.java @@ -0,0 +1,41 @@ +package org.onap.policy.api; + +import java.util.Map; + +import javax.json.JsonObject; + +public interface DictionaryResponse { + + /** + * Gets the String of the DictionaryItemsMessage from DictionaryResponse. + * + * @return the String which consists of DictionaryItemsMessage from DictionaryResponse + */ + public String getResponseMessage(); + + /** + * Response code of type Integer which corresponds to the HTTP Response code explaining the response from Policy Engine. + * + * @return the responseCode in Integer format corresponding to the HTTP response code from Policy Engine. + */ + public int getResponseCode(); + + + /** + * Gets the JsonObject of all the Dictionary data retrieved + * + * @return the JsonObject which consists of Dictionary data which has been retrieved. + */ + public JsonObject getDictionaryJson(); + + + /** + * Gets the Key and Value pairs for each Dictionary item retrieved which can be used in the getDictionaryItems call. + * + * @return Map of String, String which consists of the Key and Value pairs for each Dictionary item retrieved. + */ + public Map getDictionaryData(); + + + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryType.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryType.java new file mode 100644 index 000000000..5ac6d5ed8 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryType.java @@ -0,0 +1,100 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.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 String format of Type for this PolicyClass + * @return the String of the Type for this PolicyClass + */ + 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))){ + return type; + } + } + throw new IllegalArgumentException(); + } + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/EventRequestParameters.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/EventRequestParameters.java new file mode 100644 index 000000000..6e4bbbd51 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/EventRequestParameters.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import java.util.Map; +import java.util.UUID; + +/** + * EventRequestParameters defines the Event Policy Request Parameters + * which retrieve(s) the response from PDP if the request parameters match with any Action Policy. + * + * @version 0.1 + */ +public class EventRequestParameters { + private Map eventAttributes; + private UUID requestID; + + /** + * Constructor with no Parameters + */ + public EventRequestParameters(){ + } + + /** + * Constructor with Parameters + * + * @param eventAttributes the Map of String,String format of the eventAttributes that contains the event ID and values. + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + */ + public EventRequestParameters(Map eventAttributes, UUID requestID){ + this.eventAttributes = eventAttributes; + this.requestID = requestID; + } + + /** + * Gets the eventAttributes of Event Request Parameters. + * + * @return eventAttributes the Map of String,String format of the eventAttributes that contains the event ID and values. + */ + public Map getEventAttributes() { + return eventAttributes; + } + + /** + * Sets the eventAttributes that contain the eventID and values to the Event Request Parameters. + * + * @param eventAttributes the Map of String,String format of the eventAttributes that must contain the event ID and values. + */ + public void setEventAttributes(Map eventAttributes) { + this.eventAttributes = eventAttributes; + } + + /** + * Gets the ReqestID of Event Request Parameters which will be passed around ONAP requests. + * + * @return requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + */ + public UUID getRequestID() { + return requestID; + } + + /** + * Sets the ReqestID of Event Request Parameters which will be passed around ONAP requests. + * + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + */ + public void setRequestID(UUID requestID) { + this.requestID = requestID; + } + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/ImportParameters.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/ImportParameters.java new file mode 100644 index 000000000..3914864bf --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/ImportParameters.java @@ -0,0 +1,175 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import java.util.UUID; + + +/** + * ImportParameters defines the Policy Engine Import Parameters + * which are required to import a new Policy Service or Value. + * + * @version 0.1 + */ +public class ImportParameters { + private String serviceName; + private String description; + private UUID requestID; + private String filePath; + private String version; + private IMPORT_TYPE importType; + + public enum IMPORT_TYPE { + MICROSERVICE, + BRMSPARAM + } + + /** + * Sets Import Policy Parameters. + * + * @param serviceName the String format of the Service Name + * @param description the String format of the i Description + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + * @param filePath the List format of the file paths for the service files + * @param importType the {@link IMPORT_TYPE} format of the Policy Service List + * @param version the String format of the Policy Import Version + * A different request ID should be passed for each request. + */ + public void setImportParameters(String serviceName, String description, UUID requestID, String filePath, IMPORT_TYPE importType, String version){ + + this.setServiceName(serviceName); + this.setDescription(description); + this.setRequestID(requestID); + this.setFilePath(filePath); + this.setServiceType(importType); + this.setVersion(version); + + } + + /** + * Gets the Policy Service of the Policy Service Import Parameters. + * + * @return serviceName the String format of the Policy Service Name + */ + public String getServiceName() { + return serviceName; + } + + /** + * Sets the serviceName of the Policy Service Parameters. + * + * @param serviceName the String format of the Policy Service Name + */ + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + + /** + * Gets the Policy Import Description. + * + * @return description the String format of the Policy Import Description + */ + public String getDescription() { + return description; + } + + /** + * Sets the Description of the new Policy Import Description. + * + * @param description the String format of the Policy Import Description + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Gets the requestID of the Policy Parameters. + * + * @return unique request ID which will be passed throughout the ONAP components to correlate logging messages. + */ + public UUID getRequestID() { + return requestID; + } + + /** + * Sets the requestID of the Policy Parameters. + * + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + */ + public void setRequestID(UUID requestID) { + this.requestID = requestID; + } + + /** + * Gets the List of File Paths of the new import. + * + * @return filePath the List format of the Policy Import File + */ + public String getFilePath() { + return filePath; + } + + /** + * Sets the policy Import File List of the new Policy Import. + * + * @param filePath the List format of the Policy Import File + */ + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + /** + * Gets the Service Type of the new policy import. + * + * @return ImportType {@link IMPORT_TYPE} format of the Policy Service List + */ + public IMPORT_TYPE getServiceType() { + return importType; + } + + /** + * Sets the policy Service Type of the new Policy Service. + * + * @param enumImportType the enumServiceType format of the Policy Service List + */ + public void setServiceType(IMPORT_TYPE enumImportType) { + this.importType = enumImportType; + } + + /** + * + * Gets the Import Version of the new policy import. + * + * @return version the String format of the Policy Import Version + */ + public String getVersion() { + return version; + } + + /** + * Sets the policy Import Version of the new Policy Import. + * + * @param version the String format of the Policy Import Version + */ + public void setVersion(String version) { + this.version = version; + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/MetricsRequestParameters.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/MetricsRequestParameters.java new file mode 100644 index 000000000..8820ca31c --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/MetricsRequestParameters.java @@ -0,0 +1,21 @@ +package org.onap.policy.api; + +import java.util.UUID; + +public class MetricsRequestParameters { + private UUID requestID; + + /** + * @return the requestID + */ + public UUID getRequestID() { + return requestID; + } + /** + * @param requestID the requestID to set + */ + public void setRequestID(UUID requestID) { + this.requestID = requestID; + } + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/MetricsResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/MetricsResponse.java new file mode 100644 index 000000000..dc48caf1f --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/MetricsResponse.java @@ -0,0 +1,45 @@ +package org.onap.policy.api; + +public interface MetricsResponse { + + /** + * Gets the String of the metrics message from MetricsResponse. + * + * @return the String which consists of the metrics message from MetricsResponse + */ + public String getResponseMessage(); + + /** + * Gets the response code of type Integer which corresponds to the HTTP Response code explaining the response from Policy Engine. + * + * @return the responseCode in Integer format corresponding to the HTTP response code from Policy Engine. + */ + public int getResponseCode(); + + + /** + * Gets the Integer value of the count of policies that reside on the PAP. + * + * @return the Integer which consists of count of policies that reside on the PAP. + */ + public int getPapMetrics(); + + + /** + * Gets the Integer value of the count of policies that reside on the PDP. + * + * @return the Integer which consists of count of policies that reside on the PDP. + */ + public int getPdpMetrics(); + + + /** + * Gets the Integer value of the total count of policies. + * + * @return the Integer which consists of the total count of policies. + */ + public int getMetricsTotal(); + + + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/NotificationScheme.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/NotificationScheme.java new file mode 100644 index 000000000..4df83e5e7 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/NotificationScheme.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +/** + * Enumeration of NotificationScheme describes the Notification Scheme that will be used by the PolicyEngine. + * + * @version 0.1 + */ +public enum NotificationScheme { + /** + * Notifications for policyUpdates on policy Configs already retrieved + */ + AUTO_NOTIFICATIONS("auto_notifications"), + /** + * Subscribing to all notifications from the PDP + */ + AUTO_ALL_NOTIFICATIONS("auto_all_notifications"), + /** + * Client can poll for updates that receive policyUpdates on policy Configs that have already been retrieved + */ + MANUAL_NOTIFICATIONS("manual_notifications"), + /** + * Client can poll for updates that receive all notifications from the PDP + */ + MANUAL_ALL_NOTIFICATIONS("manual_all_notifications") + ; + + private String name; + private NotificationScheme(String name){ + this.name = name; + } + + /** + * Returns the String name for this NotificationScheme + * + * @return the String name for this NotificationScheme + */ + @Override + public String toString(){ + return this.name; + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyChangeResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyChangeResponse.java new file mode 100644 index 000000000..249cf24a2 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyChangeResponse.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +/** + * PolicyChangeResponse defines the Policy Response + * which is Contains responseCode corresponding to HTTP response Codes with response Message. + * + * @version 0.1 + */ +public interface PolicyChangeResponse { + + /** + * Policy Change Response Message in String format from the Policy Engine. + * + * @return the responseMessage in String format related to Response from Policy Engine. + */ + public String getResponseMessage(); + + /** + * Response code of type Integer which corresponds to the HTTP Response code explaining the response from Policy Engine. + * + * @return the responseCode in Integer format corresponding to the HTTP response code from Policy Engine. + */ + public int getResponseCode(); +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyClass.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyClass.java new file mode 100644 index 000000000..5132a44be --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyClass.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import com.fasterxml.jackson.annotation.JsonCreator; + +/** + * Enumeration of the Policy Types that is used as a part of + * {@link org.onap.policy.api.PolicyParameters}. + * + * @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 String format of Type for this PolicyClass + * @return the String of the Type for this PolicyClass + */ + 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))){ + return type; + } + } + throw new IllegalArgumentException(); + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfig.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfig.java new file mode 100644 index 000000000..652fd4da3 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfig.java @@ -0,0 +1,123 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import java.util.Map; +import java.util.Properties; + +import javax.json.JsonObject; + +import org.w3c.dom.Document; +/** + * Defines the objects that represent PolicyEngine config elements. PolicyConfig communicates the PolicyConfigStatus, + * PolicyConfigMessage, PolicyType, Properties, JsonObject, String and Document. + * + * @version 0.7 + */ + +public interface PolicyConfig { + /** + * Gets the {@link org.onap.policy.api.PolicyType} associated with PolicyConfig + * + * @return the PolicyType associated with this PolicyConfig + */ + public PolicyType getType(); + + /** + * Gives the Properties response associated with the PolicyConfig + * + * @return the Properties associated with this PolicyConfig + */ + public Properties toProperties(); + + /** + * Gives the JsonObject response associated with the PolicyConfig + * + * @return the JsonObject result associated with PolicyConfig + */ + public JsonObject toJSON(); + + /** + * Gives the XML Document result associated with PolicyConfig + * + * @return the Document result associated with PolicyConfig + */ + public Document toXML(); + + /** + * Gives the Other String response associated with PolicyConfig + * + * @return the String result associated with PolicyConfig + */ + public String toOther(); + + /** + * Gets the {@link org.onap.policy.api.PolicyConfigStatus} associated with this PolicyConfig. + * + * @return the PolicyConfigStatus associated with this PolicyConfig + */ + public PolicyConfigStatus getPolicyConfigStatus(); + + /** + * Gets the String of the PolicyConfigMessage from PolicyConfig. + * + * @return the String which consists of PolicyConfigMessage from PolicyConfig + */ + public String getPolicyConfigMessage(); + + /** + * Gets the String of the PolicyName retrieved. + * + * @return the String which consists of Policy Name which has been retrieved. + */ + public String getPolicyName(); + + + /** + * Gets the String of the PolicyVersion retrieved. + * + * @return the String which consists of the Policy Version number which has been retrieved. + */ + public String getPolicyVersion(); + + /** + * Gets the Matching Conditions of the policy retrieved which can be used in the getConfig call. + * + * @return Map of String, String which consists of the Matching conditions of the Policy retrieved. + */ + public Map getMatchingConditions(); + + /** + * Gets the Response Attributes of the policy retrieved. Which can hold additional information about the policy retrieved. + * + * @return Map of String, String which consists of the Response Attributes of the Policy retrieved. + */ + public Map getResponseAttributes(); + + /** + * Returns the String version of the PolicyConfig object. + * + * @return String of the PolicyConfig Object. + */ + @Override + public String toString(); + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigException.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigException.java new file mode 100644 index 000000000..b42d8b280 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigException.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +/** + * PolicyConfigException extends Exception to implement exceptions thrown by {@link org.onap.policy.api.PolicyEngine} + * + * @version 0.1 + */ +public class PolicyConfigException extends Exception{ + private static final long serialVersionUID = -188355220060684215L; + + public PolicyConfigException() { + } + + public PolicyConfigException(String message) { + super(message); + } + + public PolicyConfigException(Throwable cause){ + super(cause); + } + + public PolicyConfigException(String message, Throwable cause) { + super(message, cause); + } + + public PolicyConfigException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java new file mode 100644 index 000000000..23291c9b9 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import com.fasterxml.jackson.annotation.JsonCreator; + +/** + * 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 PolicyConfigStatus based on String representation of PolicyConfig + * + * @param configStatus the String Configuration Status + * @return the PolicyConfigResponse with the name matching CONFIG_RETRIEVED or CONFIG_NOT_FOUND + * if no match is found + */ + public static PolicyConfigStatus getStatus(String configStatus) { + if(configStatus.equalsIgnoreCase("retrieved")) { + return CONFIG_RETRIEVED; + }else { + return CONFIG_NOT_FOUND; + } + } + + /** + * Returns the String name for this PolicyConfigStatus + * + * @return the String name for this PolicyConfigStatus + */ + 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))){ + return type; + } + } + throw new IllegalArgumentException(); + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigType.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigType.java new file mode 100644 index 000000000..77c978da4 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigType.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import com.fasterxml.jackson.annotation.JsonCreator; + +/** + * Enumeration of the Policy Config Types that is used as a part of + * {@link org.onap.policy.api.PolicyParameters}. + * + * @version 0.1 + */ +public enum PolicyConfigType{ + /** + * Indicates Base Config Policy. + */ + Base("Base"), + /** + * Indicates ClosedLoop Fault Policy. + */ + ClosedLoop_Fault("Fault"), + /** + * Indicates ClosedLoop Performance Metrics Policy. + */ + ClosedLoop_PM("PM"), + /** + * Indicates Firewall Config Policy. + */ + Firewall("FW"), + /** + * Indicates BRMS based raw DRL Rule Policy. + */ + BRMS_RAW("BRMS_Raw"), + /** + * Indicates BRMS based Param DRL policy. + */ + BRMS_PARAM("BRMS_Param"), + /** + * Indicates DCAE Micro Service based Policy. + */ + MicroService("MS"), + + Extended("EXTENDED") + ; + + private String name; + + private PolicyConfigType(String name){ + this.name = name; + } + + /** + * Returns the String format of Type for this PolicyClass + * @return the String of the Type for this PolicyClass + */ + public String toString() { + return name; + } + + @JsonCreator + public static PolicyConfigType create (String value) { + for(PolicyConfigType type: values()){ + if(type.toString().equals(value) || type.equals(PolicyConfigType.valueOf(value))){ + return type; + } + } + throw new IllegalArgumentException(); + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecision.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecision.java new file mode 100644 index 000000000..b5fdc1e01 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecision.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import com.fasterxml.jackson.annotation.JsonCreator; + +/** + * 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 String name for this PolicyDecision + * + * @return the String name for this PolicyDecision + */ + 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))){ + return type; + } + } + throw new IllegalArgumentException(); + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecisionException.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecisionException.java new file mode 100644 index 000000000..38081de7e --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecisionException.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +/** + * PolicyDecisionException extends Exception to implement exceptions thrown by {@link org.onap.policy.api.PolicyEngine} + * + * @version 0.1 + */ +public class PolicyDecisionException extends Exception { + + private static final long serialVersionUID = -2080072039363261175L; + + public PolicyDecisionException() { + } + + public PolicyDecisionException(String message) { + super(message); + } + + public PolicyDecisionException(Throwable cause){ + super(cause); + } + + public PolicyDecisionException(String message, Throwable cause) { + super(message, cause); + } + + public PolicyDecisionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java new file mode 100644 index 000000000..bfb4f1e4f --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java @@ -0,0 +1,602 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import java.util.Collection; +import java.util.Map; +import java.util.UUID; + +import javax.json.JsonObject; + +import org.onap.policy.api.NotificationHandler; +import org.onap.policy.api.PDPNotification; +import org.onap.policy.std.StdPolicyEngine; + +/** + * PolicyEngine is the Interface that applications use to make policy queries against a PEPEngine + * + * @version 2.0 + */ +public class PolicyEngine{ + private String propertyFilePath = null; + private StdPolicyEngine stdPolicyEngine; + private NotificationScheme scheme = null; + private NotificationHandler handler = null; + + /** + * PolicyEngine Constructor with String format of propertiesFilePathname + * + * @param propertiesFilePathname the String format of the propertiesFilePathname + * @throws PolicyEngineException PolicyEngine Exception + */ + public PolicyEngine(String propertiesFilePathname) throws PolicyEngineException { + this.propertyFilePath = propertiesFilePathname ; + this.stdPolicyEngine= new StdPolicyEngine(this.propertyFilePath, (String)null); + } + + /** + * PolicyEngine Constructor with String format of propertiesFilePathname + * + * @param propertiesFilePathname the String format of the propertiesFilePathname + * @param clientKey depicts String format of Password/ Client_Key. + * @throws PolicyEngineException PolicyEngine Exception + */ + public PolicyEngine(String propertiesFilePathname, String clientKey) throws PolicyEngineException { + this.propertyFilePath = propertiesFilePathname ; + this.stdPolicyEngine= new StdPolicyEngine(this.propertyFilePath, clientKey); + } + + /** + * PolicyEngine Constructor with String format of PropertiesFilePathname and NotificationScheme + * + * @param propertiesFilePathname the String format of the propertiesFilePathname + * @param scheme the NotificationScheme of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme + * @throws PolicyEngineException PolicyEngine Exception + */ + public PolicyEngine(String propertiesFilePathname, NotificationScheme scheme) throws PolicyEngineException{ + this.propertyFilePath = propertiesFilePathname; + this.scheme = scheme; + this.stdPolicyEngine = new StdPolicyEngine(this.propertyFilePath, this.scheme); + } + + /** + * PolicyEngine Constructor with String format of PropertiesFilePathname, NotificationScheme and NotificationHandler + * + * @param propertiesFilePathname the String format of the propertiesFilePathname + * @param scheme the NotificationScheme of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme + * @param handler the NotificationHandler of {@link org.onap.policy.api.NotificationHandler} which defines what should happen when a notification is received. + * @throws PolicyEngineException PolicyEngine Exception + */ + public PolicyEngine(String propertiesFilePathname, NotificationScheme scheme, NotificationHandler handler) throws PolicyEngineException { + this.propertyFilePath = propertiesFilePathname ; + this.scheme = scheme; + this.handler = handler; + this.stdPolicyEngine= new StdPolicyEngine(this.propertyFilePath,this.scheme,this.handler); + } + + /** + * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the Policy File Name + * + * @param policyName the String format of the PolicyFile Name whose configuration is required. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters configRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfigByPolicyName(String policyName) throws PolicyConfigException { + return getConfig(setConfigRequestParameters(policyName, null, null, null, null)); + } + + /** + * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the Policy File Name + * + * @param policyName the String format of the PolicyFile Name whose configuration is required. + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + * A different request ID should be passed for each request. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters configRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfigByPolicyName(String policyName, UUID requestID) throws PolicyConfigException { + return getConfig(setConfigRequestParameters(policyName, null, null, null, requestID)); + } + + /** + * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the onapComponentName + * + * @param onapComponentName the String format of the onapComponentName whose configuration is required. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfig(String onapComponentName) throws PolicyConfigException { + return getConfig(setConfigRequestParameters(null, onapComponentName, null, null, null)); + } + + /** + * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the onapComponentName + * + * @param onapComponentName the String format of the onapComponentName whose configuration is required. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + * A different request ID should be passed for each request. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfig(String onapComponentName, UUID requestID) throws PolicyConfigException { + return getConfig(setConfigRequestParameters(null, onapComponentName, null, null, requestID)); + } + + /** + * Requests the configuration of the String which represents the onapComponentName and String + * which represents the configName and returns the configuration if different Configurations exist for the + * particular onapComponentName. + * + * @param onapComponentName the String format of the onapComponentName whose configuration is required. + * @param configName the String format of the configurationName whose configuration is required. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfig(String onapComponentName, String configName) throws PolicyConfigException { + return getConfig(setConfigRequestParameters(null, onapComponentName, configName, null, null)); + } + + /** + * Requests the configuration of the String which represents the onapComponentName and String + * which represents the configName and returns the configuration if different Configurations exist for the + * particular onapComponentName. + * + * @param onapComponentName the String format of the onapComponentName whose configuration is required. + * @param configName the String format of the configurationName whose configuration is required. + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + * A different request ID should be passed for each request. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfig(String onapComponentName, String configName, UUID requestID) throws PolicyConfigException { + return getConfig(setConfigRequestParameters(null, onapComponentName, configName, null, requestID)); + } + + /** + * Requests the configuration of the String which represents the onapComponentName, String + * which represents the configName and Map of String,String which has the configAttribute and returns the specific + * configuration related to the configAttributes mentioned. + * + * @param onapComponentName the String format of the onapComponentName whose configuration is required. + * @param configName the String format of the configurationName whose configuration is required. + * @param configAttributes the Map of String,String format of the configuration attributes which are required. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfig(String onapComponentName, String configName, Map configAttributes) throws PolicyConfigException{ + return getConfig(setConfigRequestParameters(null, onapComponentName, configName, configAttributes, null)); + } + + /** + * Requests the configuration of the String which represents the onapComponentName, String + * which represents the configName and Map of String,String which has the configAttribute and returns the specific + * configuration related to the configAttributes mentioned. + * + * @param onapComponentName the String format of the onapComponentName whose configuration is required. + * @param configName the String format of the configurationName whose configuration is required. + * @param configAttributes the Map of String,String format of the configuration attributes which are required. + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + * A different request ID should be passed for each request. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfig(String onapComponentName, String configName, Map configAttributes, UUID requestID) throws PolicyConfigException{ + return getConfig(setConfigRequestParameters(null, onapComponentName, configName, configAttributes, requestID)); + } + + /** + * Requests the configuration of the ConfigRequestParameters which represents the Config policy request parameters + * and returns the specific configuration related to the matching parameters. + * + * @param configRequestParameters {@link org.onap.policy.api.ConfigRequestParameters} which represents the Config policy request parameters. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. + * @throws PolicyConfigException PolicyConfig Exception + */ + public Collection getConfig(ConfigRequestParameters configRequestParameters) throws PolicyConfigException{ + return stdPolicyEngine.getConfig(configRequestParameters); + } + + /** + * Requests the list of policies based on the ConfigRequestParameters which represents the policy request parameters + * and returns the list of policies filtered by the parameters. + * + * @param configRequestParameters {@link org.onap.policy.api.ConfigRequestParameters} which represents the List Policy request parameters. + * @return Collection of String which returns the list of policies. + * @throws PolicyConfigException PolicyConfig Exception + */ + public Collection listConfig(ConfigRequestParameters listPolicyRequestParameters) throws PolicyConfigException{ + return stdPolicyEngine.listConfig(listPolicyRequestParameters); + } + + + /** + * Sends the Events specified to the PEP and returns back the PolicyResponse. + * + * @param eventAttributes the Map of String,String format of the eventAttributes that must contain the event ID and values. + * @return Collection of {@link org.onap.policy.api.PolicyResponse} which has the Response. + * @throws PolicyEventException PolicyEvent Exception + * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead. + */ + @Deprecated + public Collection sendEvent(Map eventAttributes) throws PolicyEventException { + return stdPolicyEngine.sendEvent(eventAttributes, (UUID) null); + } + + /** + * Sends the Events specified to the PEP and returns back the PolicyResponse. + * + * @param eventAttributes the Map of String,String format of the eventAttributes that must contain the event ID and values. + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + * A different request ID should be passed for each request. + * @return Collection of {@link org.onap.policy.api.PolicyResponse} which has the Response. + * @throws PolicyEventException PolicyEvent Exception + * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead. + */ + @Deprecated + public Collection sendEvent(Map eventAttributes, UUID requestID) throws PolicyEventException { + return stdPolicyEngine.sendEvent(eventAttributes, requestID); + } + + /** + * Sends the Events specified to the PEP and returns back the PolicyResponse. + * + * @param eventRequestParameters {@link org.onap.policy.api.EventRequestParameters} which represents the Event Request Parameters. + * @return Collection of {@link org.onap.policy.api.PolicyResponse} which has the Response. + * @throws PolicyEventException PolicyEvent Exception + */ + public Collection sendEvent(EventRequestParameters eventRequestParameters) throws PolicyEventException { + return stdPolicyEngine.sendEvent(eventRequestParameters); + } + + /** + * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. + * + * @param onapComponentName the String format of the onapComponentName whose Decision is required. + * @param decisionAttributes the Map of String,String format of the decisionAttributes that must contain the ID and values. + * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision. + * @throws PolicyDecisionException PolicyDecision Exception + * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead. + */ + @Deprecated + public DecisionResponse getDecision(String onapComponentName, Map decisionAttributes) throws PolicyDecisionException { + return stdPolicyEngine.getDecision(onapComponentName, decisionAttributes, null); + } + + /** + * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. + * + * @param onapComponentName the String format of the onapComponentName whose Decision is required. + * @param decisionAttributes the Map of String,String format of the decisionAttributes that must contain the ID and values. + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + * A different request ID should be passed for each request. + * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision. + * @throws PolicyDecisionException PolicyDecision Exception + * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead. + */ + @Deprecated + public DecisionResponse getDecision(String onapComponentName, Map decisionAttributes, UUID requestID) throws PolicyDecisionException { + return stdPolicyEngine.getDecision(onapComponentName, decisionAttributes, requestID); + } + + /** + * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. + * + * @param decisionRequestParameters {@link org.onap.policy.api.DecisionRequestParameters} which represents the Decision Request Parameters. + * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision. + * @throws PolicyDecisionException PolicyDecision Exception + */ + public DecisionResponse getDecision(DecisionRequestParameters decisionRequestParameters) throws PolicyDecisionException { + return stdPolicyEngine.getDecision(decisionRequestParameters); + } + + /** + * Retrieves the count of policies on the PAP, PDP, and Policy Engine as a whole + * + * @param parameters {@link org.onap.policy.api.MetricsRequestParameters} which represents the Parameters required to get the Policy Metrics + * @return {@link org.onap.policy.api.MetricsResponse} which consists of the response related to getMetrics Request. + * @throws PolicyException PolicyException related to the operation + * + * */ + public MetricsResponse getMetrics(MetricsRequestParameters parameters) throws PolicyException { + return stdPolicyEngine.getMetrics(parameters); + } + + /** + * Creates a Config Policy based on given arguments + * @param policyName the String format of the Policy Name + * @param policyDescription the String format of the Policy Description + * @param onapName the String format of the ONAP Name + * @param configName the String format of the Config Name + * @param configAttributes the List the Map Attributes that must contain the key and value. + * @param configType the String format of the Config Type + * @param body the String format of the Policy Body + * @param policyScope the String value of the sub scope directory where the policy will be created and stored + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + * A different request ID should be passed for each request. + * @param riskLevel the String value of risk Level. + * @param riskType the String value of risk Type. + * @param guard the String value of guard. + * @param ttlDate the String value of time to live Date. + * @throws PolicyException PolicyException related to the operation. + * @return String format of response + * @deprecated use {@link #createPolicy(PolicyParameters)} Instead. + */ + @Deprecated + public String createConfigPolicy(String policyName, String policyDescription, String onapName, String configName, + Map configAttributes, String configType, String body, String policyScope, UUID requestID, + String riskLevel, String riskType, String guard, String ttlDate) throws PolicyException { + return stdPolicyEngine.createUpdateConfigPolicy(policyName, policyDescription, onapName, configName, + configAttributes, configType, body, policyScope, requestID, + riskLevel, riskType, guard, ttlDate, false); + } + + /** + * Creates a Config Policy based on given arguments + * @param policyName the String format of the Policy Name + * @param policyDescription the String format of the Policy Description + * @param onapName the String format of the ONAP Name + * @param configName the String format of the Config Name + * @param configAttributes the List the Map Attributes that must contain the key and value. + * @param configType the String format of the Config Type + * @param body the String format of the Policy Body + * @param policyScope the String value of the sub scope directory where the policy will be created and stored + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + * A different request ID should be passed for each request. + * @param riskLevel the String value of risk Level. + * @param riskType the String value of risk Type. + * @param guard the String value of guard. + * @param ttlDate the String value of time to live Date. + * @throws PolicyException PolicyException related to the operation. + * @return String format of response + * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead. + */ + @Deprecated + public String updateConfigPolicy(String policyName, String policyDescription, String onapName, String configName, + Map configAttributes, String configType, String body, String policyScope, UUID requestID, + String riskLevel, String riskType, String guard, String ttlDate) throws PolicyException { + return stdPolicyEngine.createUpdateConfigPolicy(policyName, policyDescription, onapName, configName, + configAttributes, configType, body, policyScope, requestID,riskLevel, riskType, guard, ttlDate, true); + } + + /** + * Creates a Config Firewall Policy based on given arguments + * @param policyName the String format of the Policy Name + * @param firewallJson the JsonObject representation of the Firewall Rules List + * @param policyScope the String value of the sub scope directory where the policy will be created and stored + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + * A different request ID should be passed for each request. + * @param riskLevel the String value of risk Level. + * @param riskType the String value of risk Type. + * @param guard the String value of guard. + * @param ttlDate the String value of time to live Date. + * @throws PolicyException PolicyException related to the operation. + * @return String format of response. + * @deprecated use {@link #createPolicy(PolicyParameters)} Instead. + */ + @Deprecated + public String createConfigFirewallPolicy(String policyName, JsonObject firewallJson, String policyScope, UUID requestID, + String riskLevel, String riskType, String guard, String ttlDate) throws PolicyException { + return stdPolicyEngine.createUpdateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID,riskLevel, + riskType, guard, ttlDate, false); + } + + /** + * Updates a Config Firewall Policy based on given arguments + * @param policyName the String format of the Policy Name + * @param firewallJson the JsonObject representation of the Firewall Rules List + * @param policyScope the String value of the sub scope directory where the policy will be created and stored + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + * A different request ID should be passed for each request. + * @param riskLevel the String value of risk Level. + * @param riskType the String value of risk Type. + * @param guard the String value of guard. + * @param ttlDate the String value of time to live Date. + * @throws PolicyException PolicyException related to the operation. + * @return String format of response. + * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead. + */ + @Deprecated + public String updateConfigFirewallPolicy(String policyName, JsonObject firewallJson, String policyScope, UUID requestID, + String riskLevel, String riskType, String guard, String ttlDate) throws PolicyException { + return stdPolicyEngine.createUpdateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID,riskLevel, riskType, guard, ttlDate, true); + } + + /** + * Retrieves Dictionary Items for a specified dictionary + * + * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to create a Dictionary Item. + * @return {@link org.onap.policy.api.DictionaryResponse} which consists of the response related to create dictionary item Request. + * @throws PolicyException PolicyException related to the operation + * + * */ + public DictionaryResponse getDictionaryItem(DictionaryParameters parameters) throws PolicyException { + return stdPolicyEngine.getDictionaryItem(parameters); + } + + /** + * Creates a Dictionary Item based on given Dictionary Parameters + * + * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to create a Dictionary Item. + * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create dictionary item Request. + * @throws PolicyException PolicyException related to the operation. + */ + public PolicyChangeResponse createDictionaryItem(DictionaryParameters parameters) throws PolicyException { + return stdPolicyEngine.createDictionaryItem(parameters); + } + + /** + * Updates a Dictionary Item based on given Dictionary Parameters + * + * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to update a Dictionary Item. + * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to update dictionary item Request. + * @throws PolicyException PolicyException related to the operation. + */ + public PolicyChangeResponse updateDictionaryItem(DictionaryParameters parameters) throws PolicyException { + return stdPolicyEngine.updateDictionaryItem(parameters); + } + + /** + * Creates a Policy based on given Policy Parameters. + * + * @param policyParameters {@link org.onap.policy.api.PolicyParameters} which represents the Policy Parameters required to create a Policy. + * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create policy Request. + * @throws PolicyException PolicyException related to the operation. + */ + public PolicyChangeResponse createPolicy(PolicyParameters policyParameters) throws PolicyException { + return stdPolicyEngine.createPolicy(policyParameters); + } + + /** + * Update Policy based on given Policy Parameters. + * + * @param policyParameters {@link org.onap.policy.api.PolicyParameters} which represents the Policy Parameters required to update a Policy. + * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create policy Request. + * @throws PolicyException PolicyException related to the operation. + */ + public PolicyChangeResponse updatePolicy(PolicyParameters policyParameters) throws PolicyException { + return stdPolicyEngine.updatePolicy(policyParameters); + } + + /** + * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used. + * + * @param policyScope the String value of the sub scope directory where the policy is located + * @param policyName the String format of the Policy Name being pushed. + * @param policyType the String format of the Policy Type which is being pushed. + * @param pdpGroup the String format of the PDP Group name to which the policy needs to be pushed to. + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + * @return String format of the response related to the push Policy Request. + * @throws PolicyException PolicyException related to the operation. + * @deprecated use {@link #pushPolicy(PushPolicyParameters)} instead. + */ + @Deprecated + public String pushPolicy(String policyScope, String policyName, String policyType, String pdpGroup, UUID requestID) throws PolicyException { + return stdPolicyEngine.pushPolicy(policyScope, policyName, policyType, pdpGroup, requestID); + } + + /** + * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used. + * + * @param pushPolicyParameters {@link org.onap.policy.api.PushPolicyParameters} which represents the Push Policy parameters required to push a policy. + * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to the push Policy Request. + * @throws PolicyException PolicyException related to the operation. + */ + public PolicyChangeResponse pushPolicy(PushPolicyParameters pushPolicyParameters) throws PolicyException { + return stdPolicyEngine.pushPolicy(pushPolicyParameters); + } + + /** + * Deletes the specified policy from the PAP or PDP. + * + * @param deletePolicyParameters {@link org.onap.policy.api.DeletePolicyParameters} which represents the Delete Policy parameters to delete a policy. + * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to the Delete Policy Request. + * @throws PolicyException PolicyException related to the operation. + */ + public PolicyChangeResponse deletePolicy(DeletePolicyParameters deletePolicyParameters) throws PolicyException { + return stdPolicyEngine.deletePolicy(deletePolicyParameters); + } + + /** + * Creates a new Policy Service based on given Service Parameters. + * + * @param importParameters {@link org.onap.policy.api.ImportParameters} which represents the Service Parameters required to create a Policy Service. + * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create import Service. + * @throws PolicyException PolicyException related to the operation. + */ + public PolicyChangeResponse policyEngineImport(ImportParameters importParameters) throws PolicyException { + return stdPolicyEngine.policyEngineImport(importParameters); + } + + /** + * setNotification allows changes to the Notification Scheme and Notification Handler + * + * @param scheme the NotificationScheme of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme + * @param handler the NotificationHandler of {@link org.onap.policy.api.NotificationHandler} which defines what should happen when a notification is received. + */ + public void setNotification(NotificationScheme scheme, NotificationHandler handler) { + this.scheme = scheme; + this.handler = handler; + stdPolicyEngine.notification(this.scheme,this.handler); + } + + /** + * clearNotification shutsDown the Notification Service if the Auto Scehme Notification service is running. + */ + public void clearNotification(){ + stdPolicyEngine.stopNotification(); + } + + /** + * setNotification allows changes to the Notification Scheme + * + * @param scheme the NotificationScheme of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme + */ + public void setScheme(NotificationScheme scheme){ + this.scheme = scheme; + stdPolicyEngine.setScheme(this.scheme); + } + + /** + * Gets the PDPNotification if there is one exists. This is used for Polling Patterns. + * + * @return PDPNotification of {@link org.onap.policy.api.PDPNotification} which has the Notification. + */ + public PDPNotification getNotification() { + return stdPolicyEngine.getNotification(); + } + + /** + * setClientKey allows the client to use their own implementation logic for Password Protection + * and will be used to set the clear text password, this will be used while making Requests. + * + * @param clientKey depicts String format of Password/ Client_Key. + */ + public void setClientKey(String clientKey){ + stdPolicyEngine.setClientKey(clientKey); + } + + // Internal Setter Method to help build configRequestParameters. + private ConfigRequestParameters setConfigRequestParameters(String policyName, String onapComponentName, String configName, Map configAttributes, UUID requestID){ + ConfigRequestParameters configRequestParameters = new ConfigRequestParameters(); + configRequestParameters.setPolicyName(policyName); + configRequestParameters.setOnapName(onapComponentName); + configRequestParameters.setConfigName(configName); + configRequestParameters.setConfigAttributes(configAttributes); + configRequestParameters.setRequestID(requestID); + return configRequestParameters; + } +} \ No newline at end of file diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngineException.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngineException.java new file mode 100644 index 000000000..6529a159e --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngineException.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +/** + * PolicyEngineException extends Exception to implement exceptions thrown by {@link org.onap.policy.api.PolicyEngine} + * + * @version 0.1 + */ +public class PolicyEngineException extends Exception{ + private static final long serialVersionUID = 4945973094200118969L; + + public PolicyEngineException() { + } + + public PolicyEngineException(String message) { + super(message); + } + + public PolicyEngineException(Throwable cause){ + super(cause); + } + + public PolicyEngineException(String message, Throwable cause) { + super(message, cause); + } + + public PolicyEngineException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEventException.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEventException.java new file mode 100644 index 000000000..335c4905b --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEventException.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +/** + * PolicyEventException extends Exception to implement exceptions thrown by {@link org.onap.policy.api.PolicyEngine} + * + * @version 0.1 + */ +public class PolicyEventException extends Exception { + private static final long serialVersionUID = -1477625011320634608L; + + public PolicyEventException() { + } + + public PolicyEventException(String message) { + super(message); + } + + public PolicyEventException(Throwable cause){ + super(cause); + } + + public PolicyEventException(String message, Throwable cause) { + super(message, cause); + } + + public PolicyEventException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyException.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyException.java new file mode 100644 index 000000000..e61560146 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyException.java @@ -0,0 +1,29 @@ +package org.onap.policy.api; + +/** + * PolicyException extends Exception to implement exceptions thrown by {@link org.onap.policy.api.PolicyEngine} + * + * @version 0.1 + */ +public class PolicyException extends Exception { + private static final long serialVersionUID = -5006203722296799708L; + + public PolicyException() { + } + + public PolicyException(String message) { + super(message); + } + + public PolicyException(Throwable cause){ + super(cause); + } + + public PolicyException(String message, Throwable cause) { + super(message, cause); + } + + public PolicyException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyParameters.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyParameters.java new file mode 100644 index 000000000..0d76d8f13 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyParameters.java @@ -0,0 +1,557 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** + * PolicyParameters defines the Policy Parameters + * which are required to Create/Update a Policy. + * + * @version 0.1 + */ +public class PolicyParameters { + private PolicyClass policyClass; + private PolicyConfigType policyConfigType; + private String policyName; + private String policyDescription; + private String onapName; + private String configName; + private Map> attributes; + private String configBody; + private PolicyType configBodyType; + private String actionPerformer; + private String actionAttribute; + private UUID requestID; + private List dynamicRuleAlgorithmLabels; + private List dynamicRuleAlgorithmFunctions; + private List dynamicRuleAlgorithmField1; + private List dynamicRuleAlgorithmField2; + private String priority; + private RuleProvider ruleProvider; + private String controllerName; + private ArrayList dependencyNames; + private Date TTLDate; + private boolean guard = false; + private String riskLevel = "5"; + private String riskType = "default"; + private String extendedOption; + + /** + * Sets Config Policy Parameters. + * + * @param policyConfigType the {@link org.onap.policy.api.PolicyConfigType} Enum format of the Config Type + * @param policyName the String format of the Policy Name + * @param policyDescription the String format of the Policy Description + * @param onapName the String format of the ONAP Name + * @param configName the String format of the Config Name + * @param attributes the Map Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it. + * @param configBodyType the {@link org.onap.policy.api.PolicyType} Enum format of the config Body Type. + * @param configBody the String format of the Policy Body + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + * A different request ID should be passed for each request. + */ + public void setConfigPolicyParameters(PolicyConfigType policyConfigType, String policyName, String policyDescription, String onapName, String configName, + Map> attributes, PolicyType configBodyType, String configBody, UUID requestID){ + this.setPolicyConfigType(policyConfigType); + this.setPolicyName(policyName); + this.setPolicyDescription(policyDescription); + this.setOnapName(onapName); + this.setConfigName(configName); + this.setAttributes(attributes); + this.setConfigBody(configBody); + this.setConfigBodyType(configBodyType); + this.setRequestID(requestID); + } + + /** + * Sets config Firewall Policy Parameters. + * + * @param policyName the String format of the Policy Name + * @param firewallJson the String representation of the Firewall Rules List + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + * A different request ID should be passed for each request. + */ + public void setConfigFirewallPolicyParameters(String policyName, String firewallJson, UUID requestID){ + this.setPolicyConfigType(PolicyConfigType.Firewall); + this.setPolicyName(policyName); + this.setConfigBody(firewallJson); + this.setConfigBodyType(PolicyType.JSON); + this.setRequestID(requestID); + } + + /** + * Gets the PolicyName of the Policy Parameters. + * + * @return policyName the String format of the Policy Name + */ + public String getPolicyName() { + return policyName; + } + + /** + * Sets the policyName of the Policy Parameters. + * + * @param policyName the String format of the Policy Name + */ + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + /** + * Gets the policy Description. + * + * @return the String format of the Policy Description + */ + public String getPolicyDescription() { + return policyDescription; + } + + /** + * Sets the policy Description of the Policy Description. + * + * @param policyDescription the String format of the Policy Description + */ + public void setPolicyDescription(String policyDescription) { + this.policyDescription = policyDescription; + } + + /** + * Gets the ONAP Name value of the Policy Paramters. + * + * @return String format of the ONAP Name + */ + public String getOnapName() { + return onapName; + } + + /** + * Sets the ONAP Name field of the Policy Parameters. + * + * @param onapName the String format of the ONAP Name + */ + public void setOnapName(String onapName) { + this.onapName = onapName; + } + + /** + * Gets the Config Name value of the Policy Parameters. + * + * @return String format of the Config Name + */ + public String getConfigName() { + return configName; + } + + /** + * Sets the Config Name field of the Policy Parameters. + * + * @param configName the String format of the Config Name + */ + public void setConfigName(String configName) { + this.configName = configName; + } + + /** + * Gets the Attributes of the policy Parameters. + * + * @return List the Map Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it. + */ + public Map> getAttributes() { + return attributes; + } + + /** + * Sets the Attributes of the Policy Parameters. + * + * @param attributes the Map Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it. + */ + public void setAttributes(Map> attributes) { + this.attributes = attributes; + } + + /** + * Gets the Policy Config Type value the Policy parameters. + * + * @return {@link org.onap.policy.api.PolicyConfigType} Enum of the Config Type + */ + public PolicyConfigType getPolicyConfigType() { + return policyConfigType; + } + + /** + * Sets the Policy Config Type field of the policy Parameters. + * + * @param policyConfigType the {@link org.onap.policy.api.PolicyConfigType} Enum format of the Config Type + */ + public void setPolicyConfigType(PolicyConfigType policyConfigType) { + if(policyConfigType!=null){ + setPolicyClass(PolicyClass.Config); + } + this.policyConfigType = policyConfigType; + } + + /** + * Gets the configBody value of the Policy Parameters. + * + * @return the String format of the Policy Body + */ + public String getConfigBody() { + return configBody; + } + + /** + * Sets the configBody field of the Policy Parameters. + * + * @param configBody the String format of the Policy Body + */ + public void setConfigBody(String configBody) { + this.configBody = configBody; + } + + /** + * Gets the config Body Type value of the Policy Parameters. + * + * @return the PolicyType representation of the configBodyType + */ + public PolicyType getConfigBodyType() { + return configBodyType; + } + + /** + * Sets the configBodyType field of the Policy Parameters. + * + * @param configBodyType the PolicyType representation of the config BodyType + */ + public void setConfigBodyType(PolicyType configBodyType) { + this.configBodyType = configBodyType; + } + + /** + * Gets the requestID of the Policy Parameters. + * + * @return unique request ID which will be passed throughout the ONAP components to correlate logging messages. + */ + public UUID getRequestID() { + return requestID; + } + + /** + * Sets the requestID of the Policy Parameters. + * + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + */ + public void setRequestID(UUID requestID) { + this.requestID = requestID; + } + + /** + * Gets the Policy Class of the Policy Parameters. + * + * @return {@link org.onap.policy.api.PolicyClass} of the Policy Parameters. + */ + public PolicyClass getPolicyClass() { + return policyClass; + } + + /** + * Sets the Policy Class of the Policy Parameters. + * + * @param policyClass the Enum {@link org.onap.policy.api.PolicyClass} to set Policy Class Type of Policy parameters. + */ + public void setPolicyClass(PolicyClass policyClass) { + this.policyClass = policyClass; + } + + /** + * Gets the Action Performer value of the Policy Parameters for Action Policies. + * + * @return the String value of the Action Performer for Action Policies + */ + public String getActionPerformer() { + return actionPerformer; + } + + /** + * Sets the Action Performer value of the Policy Parameters for Action Policies. + * + * @param actionPerformer the String format of the Action Performer + */ + public void setActionPerformer(String actionPerformer) { + this.actionPerformer = actionPerformer; + } + + /** + * Gets the Action Attribute value of the Policy Parameters for Action Policies. + * + * @return the String value of the Action Attribute for Action Policies + */ + public String getActionAttribute() { + return actionAttribute; + } + + /** + * Sets the Action Attribute value of the Policy Parameters for Action Policies. + * + * @param actionAttribute the String format of the Action Attribute + */ + public void setActionAttribute(String actionAttribute) { + this.actionAttribute = actionAttribute; + } + + /** + * Gets the Dynamic Rule Algorithm Label of the policy Parameters. Used in conjunction with the Label, Field1, + * Function, and Field2 to complete the complex and simple Rule Algorithms + * + * @return List the Dynamic Rule Algorithm Label that must contain the Labels in order + */ + public List getDynamicRuleAlgorithmLabels() { + return dynamicRuleAlgorithmLabels; + } + + /** + * Sets the Dynamic Rule Algorithm Labels used in conjunction with the Label, Field1, + * Function, and Field2 to complete the complex and simple Rule Algorithms + * + * @param dynamicRuleAlgorithmLabels the List dynamicRuleAlgoritmLabels in order + */ + public void setDynamicRuleAlgorithmLabels( + List dynamicRuleAlgorithmLabels) { + this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels; + } + + /** + * Gets the Dynamic Rule Algorithm Function of the policy Parameters. Used in conjunction with the Label, Field1, + * FunctionDef, and Field2 to complete the complex and simple Rule Algorithms + * + * @return List the Dynamic Rule Algorithm Functions that must contain the values in order + */ + public List getDynamicRuleAlgorithmFunctions() { + return dynamicRuleAlgorithmFunctions; + } + + /** + * Sets the Dynamic Rule Algorithm Functions used in conjunction with the Label, Field1, + * Function, and Field2 to complete the complex and simple Rule Algorithms + * + * @param dynamicRuleAlgorithmFunctions the List dynamicRuleAlgorithmFunctions in order + */ + public void setDynamicRuleAlgorithmFunctions(List dynamicRuleAlgorithmFunctions) { + this.dynamicRuleAlgorithmFunctions = dynamicRuleAlgorithmFunctions; + } + + /** + * Gets the Dynamic Rule Algorithm Field1 of the policy Parameters. Used in conjunction with the Label, Field1, + * Function, and Field2 to complete the complex and simple Rule Algorithms + * + * @return List the Dynamic Rule Algorithm Field1 that must contain the Field1 values in order + */ + public List getDynamicRuleAlgorithmField1() { + return dynamicRuleAlgorithmField1; + } + + /** + * Sets the Dynamic Rule Algorithm Field1 used in conjunction with the Label, Field1, + * Function, and Field2 to complete the complex and simple Rule Algorithms + * + * @param dynamicRuleAlgorithmField1 the List dynamicRuleAlgorithmField1 in order + */ + public void setDynamicRuleAlgorithmField1( + List dynamicRuleAlgorithmField1) { + this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1; + } + + /** + * Gets the Dynamic Rule Algorithm Field2 of the policy Parameters. Used in conjunction with the Label, Field1, + * Operator, and Field2 to complete the complex and simple Rule Algorithms + * + * @return List the Dynamic Rule Algorithm Field2 that must contain the Field2 values in order + */ + public List getDynamicRuleAlgorithmField2() { + return dynamicRuleAlgorithmField2; + } + + /** + * Sets the Dynamic Rule Algorithm Field2 used in conjunction with the Label, Field1, + * Function, and Field2 to complete the complex and simple Rule Algorithms + * + * @param dynamicRuleAlgorithmField2 the List dynamicRuleAlgorithmField2 in order + */ + public void setDynamicRuleAlgorithmField2( + List dynamicRuleAlgorithmField2) { + this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2; + } + + /** + * Gets the Priority of the Policy Parameters. + * + * @return priority the String format of the Micro Services priority + */ + public String getPriority() { + return priority; + } + + /** + * Sets the Priority of the Policy Parameters. + * + * @param priority the String format of the Micro Services priority + */ + public void setPriority(String priority) { + this.priority = priority; + } + + public RuleProvider getRuleProvider() { + return ruleProvider; + } + + public void setRuleProvider(RuleProvider ruleProvider) { + this.ruleProvider = ruleProvider; + } + /** + * Sets the Guard field of the Policy Parameters. + * + * @param guard the Boolean format of the guard value + */ + public void setGuard(boolean guard){ + this.guard = guard; + } + + /** + * Gets the guard value of the Policy Parameters for Action Policies. + * + * @return the boolean value of the Guard for Config Policies + */ + public boolean getGuard(){ + return guard; + } + + /** + * Sets the riskType field of the Policy Parameters. + * + * @param riskType the String format of the riskType value + */ + public void setRiskType(String riskType){ + this.riskType = riskType; + } + + /** + * Gets the riskType value of the Policy Parameters for Config Policies. + * + * @return the String value of the riskType for Config Policies + */ + public String getRiskType(){ + return riskType; + } + + /** + * Sets the riskLevel field of the Policy Parameters. + * + * @param riskLevel the String format of the riskType value + */ + public void setRiskLevel(String riskLevel){ + this.riskLevel = riskLevel; + } + + /** + * Gets the riskLevel value of the Policy Parameters for Config Policies. + * + * @return the String value of the riskLevel for Config Policies + */ + public String getRiskLevel(){ + return riskLevel; + } + + /** + * Sets the TTLDate field of the Policy Parameters. + * + * @param TTLDate the Date format of the TTLDate value + */ + public void setTtlDate(Date TTLDate){ + this.TTLDate = TTLDate; + } + + /** + * Gets the TTLDate value of the Policy Parameters for Config Policies. + * + * @return the Date value of the TTLDate for Config Policies + */ + public Date getTtlDate(){ + return TTLDate; + } + + /** + * Gets the Controller Name for your policy. + * + * @return String format of the controller Name. + */ + public String getControllerName() { + return controllerName; + } + + /** + * Sets Controller Name for your policy. + * + * @param controllerName to identify the controller information for your policy. + */ + public void setControllerName(String controllerName) { + this.controllerName = controllerName; + } + + /** + * Gets Dependency Names for your policy. + * + * @return ArrayList of String(s) format of dependency names. + */ + public ArrayList getDependencyNames() { + return dependencyNames; + } + + /** + * Sets Dependency that your policy is dependent on. + * + * @param dependencyNames ArrayList of String(s). + */ + public void setDependencyNames(ArrayList dependencyNames) { + this.dependencyNames = dependencyNames; + } + + public String getExtendedOption() { + return extendedOption; + } + + public void setExtendedOption(String extendedOption) { + this.extendedOption = extendedOption; + } + + public String toString() { + return "PolicyParameters [ policyName=" + policyName + ", policyDescription=" + policyDescription + ", onapName="+ onapName + + ", configName=" + configName + ", attributes=" + attributes + ", configBody=" + configBody + + ",dynamicRuleAlgorithmLabels=" + dynamicRuleAlgorithmLabels + ",dynamicRuleAlgorithmFunctions=" + dynamicRuleAlgorithmFunctions + + ",dynamicRuleAlgorithmField1=" + dynamicRuleAlgorithmField1 + ",dynamicRuleAlgorithmField2=" + dynamicRuleAlgorithmField2 + + ", actionPerformer=" + actionPerformer + ", actionAttribute=" + actionAttribute + ", priority=" + priority + + ", ruleProvider= " + ruleProvider + ", riskLevel= " + riskLevel + ", riskType= " + riskType + ", extendedOption= " + extendedOption + + "]"; + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponse.java new file mode 100644 index 000000000..ae29585de --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponse.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + +package org.onap.policy.api; + +import java.util.Map; + +/** + * Defines the objects that represent PolicyEngine Response elements. PolicyResponse communicates the PolicyResponseStatus, + * PolicyResponseMessage, ActionAdvised, ActionTaken and RequestAttributes. + * + * @version 0.3 + */ +public interface PolicyResponse { + /** + * Gets the {@link org.onap.policy.api.PolicyResponseStatus} associated with this PolicyResponse. + * + * @return the PolicyResponseStatus associated with this PolicyResponse + */ + public PolicyResponseStatus getPolicyResponseStatus(); + + /** + * Gets the Map of String,String which consists of ActionAdvised in this PolicyResponse. + * If there is no ActionAdvised this method must return an empty Map. + * + * @return the Map of String,String which consists of AdviceAttributes in PolicyResponse + */ + public Map getActionAdvised(); + + /** + * Gets the Map of String,String which consists of ActionTaken in this PolicyResponse. + * If there are no ActionTaken this method must return an empty Map. + * + * @return the Map of String,String which consists of ActionTaken in PolicyResponse + */ + public Map getActionTaken(); + + /** + * Gets the Map of String,String which consists of RequestAttributes in this PolicyResponse. + * + * @return the Map of String,String which consists of RequestAttributes from PolicyResponse + */ + public Map getRequestAttributes(); + + /** + * Gets the String of the PolicyResponseMessage from PolicyResponse + * + * @return the String which consists of PolicyResponseMessage from PolicyResponse + */ + public String getPolicyResponseMessage(); + + /** + * Returns the String version of the PolicyResponse object. + * + * @return String of the PolicyResponse Object. + */ + @Override + public String toString(); +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponseStatus.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponseStatus.java new file mode 100644 index 000000000..4368b646d --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponseStatus.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import com.fasterxml.jackson.annotation.JsonCreator; + +/** + * Enumeration of PolicyResponseStatus that can be returned as a part of + * {@link org.onap.policy.api.PolicyResponse}. + * + * @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 PolicyResponseStatus based on String representation of PolicyResponse + * + * @param responseStatus the String Response Status + * @return the PolicyResponseStatus with the name matching ACTION_ADVISED or ACTION_TAKEN or NO_ACTION_REQUIRED + */ + public static PolicyResponseStatus getStatus(String responseStatus) { + if(responseStatus.equalsIgnoreCase("action_advised")) { + return ACTION_ADVISED; + }else if(responseStatus.equalsIgnoreCase("action_taken")) { + return ACTION_TAKEN; + }else { + return NO_ACTION_REQUIRED; + } + } + + /** + * Returns the String name for this PolicyResponseStatus + * + * @return the String name for this PolicyResponseStatus + */ + 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))){ + return type; + } + } + throw new IllegalArgumentException(); + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyType.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyType.java new file mode 100644 index 000000000..f026596e9 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyType.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import com.fasterxml.jackson.annotation.JsonCreator; + +/** + * Enumeration of the Policy Return Types that can be returned as part of a + * {@link org.onap.policy.api.PolicyConfig}. + * + * @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 String format of Type for this PolicyType + * @return the String of the Type for this PolicyType + */ + public String toString() { + return this.name; + } + @JsonCreator + public static PolicyType create (String value) { + for(PolicyType type: values()){ + if(type.toString().equalsIgnoreCase(value)){ + return type; + } + } + throw new IllegalArgumentException(); + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PushPolicyParameters.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PushPolicyParameters.java new file mode 100644 index 000000000..211be7e65 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PushPolicyParameters.java @@ -0,0 +1,131 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import java.util.UUID; + +/** + * PushPolicyParameters defines the Policy Parameters + * which are required to Push a Policy to PDPGroup. + * + * @version 0.1 + */ +public class PushPolicyParameters { + private String policyName; + private String policyType; + private String pdpGroup; + private UUID requestID; + + /** + * Constructor with no Parameters. + */ + public PushPolicyParameters(){ + } + + /** + * Constructor with Parameters. + * + * @param policyName the String format of the Policy Name + * @param policyType the String format of the Policy Type + * @param pdpGroup the String format of the PDPGroup + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + */ + public PushPolicyParameters(String policyName, String policyType, String pdpGroup, UUID requestID){ + this.policyName = policyName; + this.policyType = policyType; + this.pdpGroup = pdpGroup; + this.requestID = requestID; + } + + /** + * Gets the PolicyName of the Push Policy Parameters. + * + * @return policyName the String format of the Policy Name + */ + public String getPolicyName() { + return policyName; + } + + /** + * Sets the policyName of the Push Policy Parameters. + * + * @param policyName the String format of the Policy Name + */ + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + /** + * Gets the PolicyType of the Push Policy Parameters. + * + * @return policyType the String format of the Policy Type + */ + public String getPolicyType() { + return policyType; + } + + /** + * Sets the policyType of the Push Policy Parameters. + * + * @param policyType the String format of the Policy Type + */ + public void setPolicyType(String policyType) { + this.policyType = policyType; + } + + /** + * Gets the PDPGroup of the Push Policy Parameters. + * + * @return pdpGroup the String format of the PDPGroup + */ + public String getPdpGroup() { + return pdpGroup; + } + + /** + * Sets the PDPGroup of the Push Policy Parameters. + * + * @param pdpGroup the String format of the PDPGroup + */ + public void setPdpGroup(String pdpGroup) { + this.pdpGroup = pdpGroup; + } + + /** + * Gets the requestID of the Push Policy Parameters. + * + * @return unique request ID which will be passed throughout the ONAP components to correlate logging messages. + */ + public UUID getRequestID() { + return requestID; + } + + /** + * Sets the requestID of the Push Policy Parameters. + * + * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. + */ + public void setRequestID(UUID requestID) { + this.requestID = requestID; + } + + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/RuleProvider.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/RuleProvider.java new file mode 100644 index 000000000..c34e05e89 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/RuleProvider.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.api; + +import com.fasterxml.jackson.annotation.JsonCreator; + +/** + * Enumeration of the Attribute Types that is used as a part of + * {@link org.onap.policy.api.PolicyParameters}. + * + * @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") + ; + + private String name; + + private RuleProvider(String typeName){ + this.name = typeName; + } + + /** + * Returns the String format of Type for this AttributeType + * @return the String of the Type for this AttributeType + */ + 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))){ + return type; + } + } + throw new IllegalArgumentException(); + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/package-info.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/package-info.java new file mode 100644 index 000000000..07875bc4c --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/package-info.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + +package org.onap.policy.api; + +/** + * org.onap.policy.api contains the API for the PolicyEngine ProtoType + * + * @version 0.9 + * + * Changes: + * Addition of Notifications methods to the Client API. + * Combining Multiple results. and Minor changes to retrieve all policies. + * Retrieve config policy using policyFile Name and the matching conditions of the policy in the results. + * Addition of Decision policy call + * + * + */ diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIConfigResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIConfigResponse.java new file mode 100644 index 000000000..a83f743e8 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIConfigResponse.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.policy.models; + +import java.util.Map; + +import org.onap.policy.api.PolicyConfigStatus; +import org.onap.policy.api.PolicyType; + +public interface APIConfigResponse { + public String getPolicyConfigMessage(); + public PolicyConfigStatus getPolicyConfigStatus(); + public PolicyType getType(); // PolicyType + public String getConfig(); + public String getPolicyName(); + public String getPolicyVersion(); + public Map getMatchingConditions(); + public Map getResponseAttributes(); + public Map getProperty(); +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIDictionaryResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIDictionaryResponse.java new file mode 100644 index 000000000..050f36bf4 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIDictionaryResponse.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.policy.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) { + this.dictionaryData = dictionaryData; + } + public Object getDictionaryJson() { + return dictionaryJson; + } + public void setDictionaryJson(Object dictionaryJson) { + this.dictionaryJson = dictionaryJson; + } + public int getResponseCode() { + return responseCode; + } + public void setResponseCode(int responseCode) { + this.responseCode = responseCode; + } + public String getResponseMessage() { + return responseMessage; + } + public void setResponseMessage(String responseMessage) { + this.responseMessage = responseMessage; + } + + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIPolicyConfigResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIPolicyConfigResponse.java new file mode 100644 index 000000000..7efee00b8 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIPolicyConfigResponse.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.policy.models; + +import java.util.Map; + +import org.onap.policy.api.PolicyConfigStatus; +import org.onap.policy.api.PolicyType; + +public class APIPolicyConfigResponse implements APIConfigResponse { + private String policyConfigMessage; + private PolicyConfigStatus policyConfigStatus; + private PolicyType type; + private String config; + private String policyName; + private String policyVersion; + private Map matchingConditions; + private Map responseAttributes; + private Map property; + public String getConfig() { + return config; + } + public void setConfig(String config) { + this.config = config; + } + public PolicyType getType() { + return type; + } + public void setType(PolicyType type) { + this.type = type; + } + public PolicyConfigStatus getPolicyConfigStatus() { + return policyConfigStatus; + } + public void setPolicyConfigStatus(PolicyConfigStatus policyConfigStatus) { + this.policyConfigStatus = policyConfigStatus; + } + public String getPolicyConfigMessage() { + return policyConfigMessage; + } + public void setPolicyConfigMessage(String policyConfigMessage) { + this.policyConfigMessage = policyConfigMessage; + } + public Map getProperty() { + return property; + } + public void setProperty(Map property) { + this.property = property; + } + public String getPolicyName(){ + return policyName; + } + public void setPolicyName(String policyName){ + this.policyName = policyName; + } + public String getPolicyVersion(){ + return policyVersion; + } + public void setPolicyVersion(String policyVersion){ + this.policyVersion = policyVersion; + } + public Map getMatchingConditions(){ + return matchingConditions; + } + public void setMatchingConditions(Map matchingConditions){ + this.matchingConditions = matchingConditions; + } + public void setResponseAttributes(Map responseAttributes){ + this.responseAttributes = responseAttributes; + } + public Map getResponseAttributes(){ + return responseAttributes; + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientDMAAP.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientDMAAP.java new file mode 100644 index 000000000..3699bfcfb --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientDMAAP.java @@ -0,0 +1,132 @@ +package org.onap.policy.std; + +import java.util.List; +import java.util.UUID; + +import org.onap.policy.api.NotificationHandler; +import org.onap.policy.api.NotificationScheme; +import org.onap.policy.api.NotificationType; +import org.onap.policy.api.PDPNotification; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; +import org.onap.policy.utils.BusConsumer; +import org.onap.policy.xacml.api.XACMLErrorConstants; + +public class AutoClientDMAAP implements Runnable { + private static StdPDPNotification notification = null; + private static NotificationScheme scheme = null; + private static NotificationHandler handler = null; + private static String topic = null; + private static boolean status = false; + private static Logger logger = FlexLogger.getLogger(AutoClientDMAAP.class.getName()); + private static String notficatioinType = null; + private static BusConsumer dmaapConsumer = null; + private static List dmaapList = null; + private static String aafLogin = null; + private static String aafPassword = null; + public volatile boolean isRunning = false; + + + public AutoClientDMAAP(List dmaapList, String topic, String aafLogin, String aafPassword) { + AutoClientDMAAP.topic = topic; + AutoClientDMAAP.dmaapList = dmaapList; + AutoClientDMAAP.aafLogin = aafLogin; + AutoClientDMAAP.aafPassword = aafPassword; + } + + public void setAuto(NotificationScheme scheme, + NotificationHandler handler) { + AutoClientDMAAP.scheme = scheme; + AutoClientDMAAP.handler = handler; + } + + public static void setScheme(NotificationScheme scheme) { + AutoClientDMAAP.scheme = scheme; + } + + public static boolean getStatus(){ + return AutoClientDMAAP.status; + } + + public static String getTopic() { + return AutoClientDMAAP.topic; + } + + public static String getNotficationType(){ + return AutoClientDMAAP.notficatioinType; + } + + public synchronized boolean isRunning() { + return this.isRunning; + } + + public synchronized void terminate() { + this.isRunning = false; + } + + @Override + public void run() { + synchronized(this) { + this.isRunning = true; + } + String group = UUID.randomUUID ().toString (); + String id = "0"; + + // Stop and Start needs to be done. + if (scheme != null && handler!=null) { + if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS) || scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) { + + // create a loop to listen for messages from DMaaP server + try { + dmaapConsumer = new BusConsumer.DmaapConsumerWrapper(dmaapList, topic, aafLogin, aafPassword, group, id, 15*1000, 1000 ); + } catch (Exception e) { + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to create DMaaP Consumer: ", e); + } + + while (this.isRunning() ) + { + try { + for ( String msg : dmaapConsumer.fetch () ) + { + logger.debug("Auto Notification Recieved Message " + msg + " from DMAAP server : " + dmaapList.toString()); + notification = NotificationUnMarshal.notificationJSON(msg); + callHandler(); + } + } catch (Exception e) { + logger.debug("Error in processing DMAAP message"); + } + + } + logger.debug("Stopping DMAAP Consumer loop will no longer fetch messages from the servers"); + } + } + } + + private static void callHandler() { + if (handler != null && scheme != null) { + if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS)) { + boolean removed = false, updated = false; + if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) { + removed = true; + } + if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) { + updated = true; + } + if (removed && updated) { + notification.setNotificationType(NotificationType.BOTH); + } else if (removed) { + notification.setNotificationType(NotificationType.REMOVE); + } else if (updated) { + notification.setNotificationType(NotificationType.UPDATE); + } + handler.notificationReceived(notification); + } else if (scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) { + PDPNotification newNotification = MatchStore.checkMatch(notification); + if (newNotification.getNotificationType() != null) { + handler.notificationReceived(newNotification); + } + } + } + } + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientEnd.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientEnd.java new file mode 100644 index 000000000..976b57058 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientEnd.java @@ -0,0 +1,248 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +import javax.websocket.ClientEndpoint; +import javax.websocket.DeploymentException; +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; + +//import org.apache.log4j.Logger; +import org.glassfish.tyrus.client.ClientManager; +import org.onap.policy.api.NotificationHandler; +import org.onap.policy.api.NotificationScheme; +import org.onap.policy.api.NotificationType; +import org.onap.policy.api.PDPNotification; +import org.onap.policy.std.NotificationStore; +import org.onap.policy.std.StdPDPNotification; + +import org.onap.policy.xacml.api.XACMLErrorConstants; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import org.onap.policy.common.logging.flexlogger.*; + +@ClientEndpoint +public class AutoClientEnd { + private static StdPDPNotification notification = null; + private static StdPDPNotification oldNotification = null; + private static ClientManager client = null; + private static NotificationScheme scheme = null; + private static NotificationHandler handler = null; + private static String url = null; + private static Session session = null; + private static boolean status = false; + private static boolean stop = false; + private static boolean message = false; + private static boolean error = false; + private static Logger logger = FlexLogger.getLogger(AutoClientEnd.class.getName()); + + public static void setAuto(NotificationScheme scheme, + NotificationHandler handler) { + AutoClientEnd.scheme = scheme; + AutoClientEnd.handler = handler; + } + + public static void setScheme(NotificationScheme scheme) { + AutoClientEnd.scheme = scheme; + } + + public static boolean getStatus(){ + return AutoClientEnd.status; + } + + public static String getURL() { + return AutoClientEnd.url; + } + + public static void start(String url) { + AutoClientEnd.url = url; + // Stop and Start needs to be done. + if (scheme != null && handler!=null) { + if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS) || scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) { + if (AutoClientEnd.client == null) { + client = ClientManager.createClient(); + if(url.contains("https")){ + url = url.replaceAll("https", "wss"); + }else { + url = url.replaceAll("http", "ws"); + } + try { + logger.info("Starting Auto Notification with the PDP server : " + url); + client.connectToServer(AutoClientEnd.class, new URI(url + "notifications")); + status = true; + if(error){ + // The URL's will be in Sync according to design Spec. + ManualClientEnd.start(AutoClientEnd.url); + StdPDPNotification notification = NotificationStore.getDeltaNotification((StdPDPNotification)ManualClientEnd.result(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)); + if(notification.getNotificationType()!=null){ + if(oldNotification!=notification){ + oldNotification= notification; + AutoClientEnd.notification = notification; + callHandler(); + } + } + error = false; + } + // + } catch (DeploymentException | IOException | URISyntaxException e) { + logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e); + client = null; + status = false; + changeURL(); + } + } + } + } + } + + private static void changeURL(){ + // Change the PDP if it is not Up. + StdPolicyEngine.rotatePDPList(); + start(StdPolicyEngine.getPDPURL()); + } + + public static void stop() { + if (client != null) { + client.shutdown(); + if(session!=null){ + try { + stop = true; + logger.info("\n Closing Auto Notification WebSocket Connection.. "); + session.close(); + session = null; + } catch (IOException e) { + // + } + } + client = null; + status = false; + stop = false; + } + } + + private static void callHandler() { + if (handler != null && scheme != null) { + if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS)) { + boolean removed = false, updated = false; + if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) { + removed = true; + } + if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) { + updated = true; + } + if (removed && updated) { + notification.setNotificationType(NotificationType.BOTH); + } else if (removed) { + notification.setNotificationType(NotificationType.REMOVE); + } else if (updated) { + notification.setNotificationType(NotificationType.UPDATE); + } + try{ + handler.notificationReceived(notification); + }catch (Exception e){ + logger.error("Error in Clients Handler Object : ", e); + } + } else if (scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) { + PDPNotification newNotification = MatchStore.checkMatch(notification); + if (newNotification.getNotificationType() != null) { + try{ + handler.notificationReceived(newNotification); + }catch (Exception e){ + logger.error("Error in Clients Handler Object : ", e); + } + } + } + } + } + + // WebSockets Code.. + @OnOpen + public void onOpen(Session session) throws IOException { + // session.getBasicRemote().sendText("Connected to Client with Session: " + // + session.getId()); + logger.debug("Auto Notification Session Started... " + session.getId()); + if(AutoClientEnd.session == null){ + AutoClientEnd.session = session; + } + } + + @OnError + public void onError(Session session, Throwable e) { + // trying to Restart by self. + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Session Error.. "+ session.getId() + "\n Error is : " + e ); + // logger.error("Exception Occured"+e); + stop(); + if (url != null) { + client = null; + status = false; + error= true; + start(url); + } + } + + @OnClose + public void onClose(Session session) { + logger.info("Session ended with "+ session.getId()); + if(!stop && !message){ + // This Block of code is executed if there is any Network Failure or if the Notification is Down. + logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Disconnected from Notification Server"); + client = null; + status = false; + AutoClientEnd.session=null; + // Try to connect Back to available PDP. + error = true; + start(url); + } + AutoClientEnd.message=false; + } + + @OnMessage + public void onMessage(String message, Session session) throws JsonParseException, JsonMappingException, IOException { + AutoClientEnd.message = true; + logger.debug("Auto Notification Recieved Message " + message + " Session info is : " + session.getId()); + try { + notification = NotificationUnMarshal.notificationJSON(message); + } catch (Exception e) { + logger.error("PE500 " + e); + } + if(AutoClientEnd.session == session){ + try{ + NotificationStore.recordNotification(notification); + }catch(Exception e){ + logger.error(e); + } + if(oldNotification!=notification){ + oldNotification= notification; + callHandler(); + } + }else{ + session.close(); + } + AutoClientEnd.message = false; + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientUEB.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientUEB.java new file mode 100644 index 000000000..37413f416 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientUEB.java @@ -0,0 +1,178 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.List; +import java.util.UUID; + +import org.onap.policy.api.NotificationHandler; +import org.onap.policy.api.NotificationScheme; +import org.onap.policy.api.NotificationType; +import org.onap.policy.api.PDPNotification; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; +import org.onap.policy.xacml.api.XACMLErrorConstants; + +import com.att.nsa.cambria.client.CambriaClientBuilders; +import com.att.nsa.cambria.client.CambriaClientBuilders.ConsumerBuilder; +import com.att.nsa.cambria.client.CambriaConsumer; +/** + * Create a UEB Consumer to receive policy update notification. + * + * + * + */ +public class AutoClientUEB implements Runnable { + private static StdPDPNotification notification = null; + private static NotificationScheme scheme = null; + private static NotificationHandler handler = null; + private static String topic = null; + private static String url = null; + private static boolean status = false; + private static Logger logger = FlexLogger.getLogger(AutoClientUEB.class.getName()); + private static String notficatioinType = null; + private static CambriaConsumer CConsumer = null; + private static String apiKey = null; + private static String apiSecret = null; + private static List uebURLList = null; + public volatile boolean isRunning = false; + + + public AutoClientUEB(String url, List uebURLList, String apiKey, String apiSecret) { + AutoClientUEB.url = url; + AutoClientUEB.uebURLList = uebURLList; + AutoClientUEB.apiKey = apiKey; + AutoClientUEB.apiKey = apiKey; + } + + public void setAuto(NotificationScheme scheme, + NotificationHandler handler) { + AutoClientUEB.scheme = scheme; + AutoClientUEB.handler = handler; + } + + public static void setScheme(NotificationScheme scheme) { + AutoClientUEB.scheme = scheme; + } + + public static boolean getStatus(){ + return AutoClientUEB.status; + } + + public static String getURL() { + return AutoClientUEB.url; + } + + public static String getNotficationType(){ + return AutoClientUEB.notficatioinType; + } + + public synchronized boolean isRunning() { + return this.isRunning; + } + + public synchronized void terminate() { + this.isRunning = false; + } + + @Override + public void run() { + synchronized(this) { + this.isRunning = true; + } + String group = UUID.randomUUID ().toString (); + String id = "0"; + //String topic = null; + // Stop and Start needs to be done. + if (scheme != null && handler!=null) { + if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS) || scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) { + URL aURL; + try { + aURL = new URL(AutoClientUEB.topic); + topic = aURL.getHost() + aURL.getPort(); + } catch (MalformedURLException e) { + topic = AutoClientUEB.url.replace("[:/]", ""); + } + + try { + //CConsumer = CambriaClientFactory.createConsumer ( null, uebURLList, topic, group, id, 15*1000, 1000 ); + ConsumerBuilder builder = new CambriaClientBuilders.ConsumerBuilder(); + builder.knownAs(group, id) + .usingHosts(uebURLList) + .onTopic(topic) + .waitAtServer(15*1000) + .receivingAtMost(1000) + .authenticatedBy(apiKey, apiSecret); + + CConsumer = builder.build(); + + } catch (Exception e1) { + logger.error("Exception Occured" + e1); + } + while (this.isRunning() ) + { + try { + for ( String msg : CConsumer.fetch () ) + { + logger.debug("Auto Notification Recieved Message " + msg + " from UEB cluster : " + uebURLList.toString()); + notification = NotificationUnMarshal.notificationJSON(msg); + callHandler(); + } + } catch (Exception e) { + logger.debug(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Error in processing UEB message" + e.getMessage()); + } + + } + logger.debug("Stopping UEB Consumer loop will not logger fetch messages from the cluster"); + } + } + } + + private static void callHandler() { + if (handler != null && scheme != null) { + if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS)) { + boolean removed = false, updated = false; + if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) { + removed = true; + } + if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) { + updated = true; + } + if (removed && updated) { + notification.setNotificationType(NotificationType.BOTH); + } else if (removed) { + notification.setNotificationType(NotificationType.REMOVE); + } else if (updated) { + notification.setNotificationType(NotificationType.UPDATE); + } + handler.notificationReceived(notification); + } else if (scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) { + PDPNotification newNotification = MatchStore.checkMatch(notification); + if (newNotification.getNotificationType() != null) { + handler.notificationReceived(newNotification); + } + } + } + } + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEnd.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEnd.java new file mode 100644 index 000000000..7e4ba07e8 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEnd.java @@ -0,0 +1,138 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.concurrent.CountDownLatch; + +import javax.websocket.ClientEndpoint; +import javax.websocket.DeploymentException; +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; + +//import org.apache.log4j.Logger; +import org.glassfish.tyrus.client.ClientManager; +import org.onap.policy.api.NotificationScheme; +import org.onap.policy.api.NotificationType; +import org.onap.policy.api.PDPNotification; +import org.onap.policy.std.StdPDPNotification; + +import org.onap.policy.xacml.api.XACMLErrorConstants; + +import org.onap.policy.common.logging.flexlogger.*; + +@ClientEndpoint +public class ManualClientEnd { + private static CountDownLatch latch; + private static StdPDPNotification notification = null; + private static String resultJson = null; + private static Logger logger = FlexLogger.getLogger(ManualClientEnd.class.getName()); + + public static void start(String url) { + latch = new CountDownLatch(1); + ClientManager client = ClientManager.createClient(); + if(url.contains("https")){ + url = url.replaceAll("https", "wss"); + }else { + url = url.replaceAll("http", "ws"); + } + try { + client.connectToServer(ManualClientEnd.class, new URI(url+"notifications")); + latch.await(); + } catch (DeploymentException | URISyntaxException | InterruptedException e) { + logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e); + } catch (IOException e) { + logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e); + } + } + + public static PDPNotification result(NotificationScheme scheme) { + if (resultJson == null || notification == null) { + logger.debug("No Result" ); + return null; + } else { + if(scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) { + boolean removed = false, updated = false; + if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){ + removed = true; + } + if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){ + updated = true; + } + if(removed && updated) { + notification.setNotificationType(NotificationType.BOTH); + }else if(removed){ + notification.setNotificationType(NotificationType.REMOVE); + }else if(updated){ + notification.setNotificationType(NotificationType.UPDATE); + } + return notification; + }else if(scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) { + return MatchStore.checkMatch(notification); + }else { + return null; + } + } + } + + // WebSockets Code.. + @OnOpen + public void onOpen(Session session) throws IOException { + logger.info("Session Started with : " + session.getId()); + session.getBasicRemote().sendText("Manual"); + } + + @OnError + public void onError(Session session, Throwable e) { + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in: "+ session.getId()); + latch.countDown(); + } + + @OnClose + public void onClose(Session session) { + logger.info("Session ended with "+ session.getId()); + latch.countDown(); + } + + @OnMessage + public void onMessage(String message, Session session){ + logger.debug(" Manual Notification Recieved Message : " + message +" Session info is : "+ session.getId()); + resultJson = message; + try { + notification = NotificationUnMarshal.notificationJSON(message); + } catch (Exception e) { + logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e); + latch.countDown(); + } + try { + session.close(); + } catch (IOException e) { + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e); + latch.countDown(); + } // For Manual Client.. + latch.countDown(); + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndDMAAP.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndDMAAP.java new file mode 100644 index 000000000..72ad7ce4a --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndDMAAP.java @@ -0,0 +1,107 @@ +package org.onap.policy.std; + +import java.util.List; + +import org.json.JSONObject; +import org.onap.policy.api.NotificationScheme; +import org.onap.policy.api.NotificationType; +import org.onap.policy.api.PDPNotification; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; +import org.onap.policy.utils.BusConsumer; +import org.onap.policy.utils.BusPublisher; +import org.onap.policy.xacml.api.XACMLErrorConstants; + +public class ManualClientEndDMAAP { + private static StdPDPNotification notification = null; + private static String resultJson = null; + private static Logger logger = FlexLogger.getLogger(ManualClientEndDMAAP.class.getName()); + private static BusConsumer dmaapConsumer = null; + private static String uniquID = null; + private static String topic = null; + + + public static PDPNotification result(NotificationScheme scheme) { + if (resultJson == null || notification == null) { + logger.debug("No Result" ); + return null; + } else { + if(scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) { + boolean removed = false, updated = false; + if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){ + removed = true; + } + if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){ + updated = true; + } + if(removed && updated) { + notification.setNotificationType(NotificationType.BOTH); + }else if(removed){ + notification.setNotificationType(NotificationType.REMOVE); + }else if(updated){ + notification.setNotificationType(NotificationType.UPDATE); + } + return notification; + }else if(scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) { + return MatchStore.checkMatch(notification); + }else { + return null; + } + } + } + + private static void publishMessage(String pubTopic, String uniqueID, List dmaapList, String aafLogin, String aafPassword) { + BusPublisher pub = null; + try { + pub = new BusPublisher.DmaapPublisherWrapper(dmaapList, topic, aafLogin, aafPassword); + final JSONObject msg1 = new JSONObject (); + msg1.put ( "JSON", "DMaaP Update Request UID=" + uniqueID); + pub.send ( "MyPartitionKey", msg1.toString () ); + } catch (Exception e) { + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to create DMaaP Publisher: ", e); + } + if(pub != null){ + pub.close (); + } + } + + //NOTE: should be able to remove this for DMAAP since we will not be creating topics dynamically + public static void createTopic (String topic, String uniquID, List dmaapList, String aafLogin, String aafPassword){ + ManualClientEndDMAAP.topic = topic; + publishMessage(topic, uniquID, dmaapList, aafLogin, aafPassword); + } + + + public static void start(List dmaapList, String topic, String aafLogin, String aafPassword, String uniqueID) { + + ManualClientEndDMAAP.uniquID = uniqueID; + ManualClientEndDMAAP.topic = topic; + + String id = "0"; + + try { + dmaapConsumer = new BusConsumer.DmaapConsumerWrapper(dmaapList, topic, aafLogin, aafPassword, "clientGroup", id, 15*1000, 1000); + } catch (Exception e) { + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to create DMaaP Consumer: ", e); + } + + int count = 1; + while (count < 4) { + publishMessage(topic, uniquID, dmaapList, aafLogin, aafPassword); + try { + for ( String msg : dmaapConsumer.fetch () ) + { + logger.debug("Manual Notification Recieved Message " + msg + " from DMaaP server : " + dmaapList.toString()); + resultJson = msg; + if (!msg.contains("DMaaP Update")){ + notification = NotificationUnMarshal.notificationJSON(msg); + count = 4; + } + } + }catch (Exception e) { + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to fetch messages from DMaaP servers: ", e); + } + count++; + } + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndUEB.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndUEB.java new file mode 100644 index 000000000..dcd86eb1f --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndUEB.java @@ -0,0 +1,160 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.List; + +import org.json.JSONObject; +import org.onap.policy.api.NotificationScheme; +import org.onap.policy.api.NotificationType; +import org.onap.policy.api.PDPNotification; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; + +import com.att.nsa.cambria.client.CambriaClientFactory; +import com.att.nsa.cambria.client.CambriaConsumer; +import com.att.nsa.cambria.client.CambriaPublisher; + + +@SuppressWarnings("deprecation") +public class ManualClientEndUEB { + private static StdPDPNotification notification = null; + private static String resultJson = null; + private static Logger logger = FlexLogger.getLogger(ManualClientEndUEB.class.getName()); + private static CambriaConsumer CConsumer = null; + @SuppressWarnings("unused") + private static List uebURLList = null; + @SuppressWarnings("unused") + private static boolean messageNotReceived = false; + @SuppressWarnings("unused") + private static String url = null; + private static String uniquID = null; + private static String topic = null; + + + public static PDPNotification result(NotificationScheme scheme) { + if (resultJson == null || notification == null) { + logger.debug("No Result" ); + return null; + } else { + if(scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) { + boolean removed = false, updated = false; + if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){ + removed = true; + } + if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){ + updated = true; + } + if(removed && updated) { + notification.setNotificationType(NotificationType.BOTH); + }else if(removed){ + notification.setNotificationType(NotificationType.REMOVE); + }else if(updated){ + notification.setNotificationType(NotificationType.UPDATE); + } + return notification; + }else if(scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) { + return MatchStore.checkMatch(notification); + }else { + return null; + } + } + } + + private static void publishMessage(String pubTopic, String uniqueID , List uebURLList) { + + String UEBlist = uebURLList.toString(); + UEBlist = UEBlist.substring(1,UEBlist.length()-1); + CambriaPublisher pub = null; + try { + pub = CambriaClientFactory.createSimplePublisher(null, UEBlist, pubTopic); + } catch (Exception e1) { + logger.error("Exception Occured"+e1); + } + final JSONObject msg1 = new JSONObject (); + + msg1.put ( "JSON", "UEB Update Ruest UID=" + uniqueID); + if(pub != null){ + try { + pub.send ( "MyPartitionKey", msg1.toString () ); + pub.close (); + } catch (IOException e) { + logger.error("Exception Occured"+e); + } + } + } + + public static void createTopic (String url, String uniquID, List uebURLList){ + URL aURL; + try { + aURL = new URL(url); + topic = aURL.getHost() + aURL.getPort(); + } catch (MalformedURLException e) { + topic = url.replace("[:/]", ""); + } + + publishMessage(topic+ uniquID , uniquID, uebURLList); + + } + public static void start(String url, List uebURLList, + String uniqueID) { + ManualClientEndUEB.uebURLList = uebURLList; + ManualClientEndUEB.url = url; + ManualClientEndUEB.uniquID = uniqueID; + URL aURL; + try { + aURL = new URL(url); + ManualClientEndUEB.topic = aURL.getHost() + aURL.getPort(); + } catch (MalformedURLException e) { + ManualClientEndUEB.topic = url.replace("[:/]", ""); + } + String id = "0"; + try { + CConsumer = CambriaClientFactory.createConsumer ( null, uebURLList, topic + uniquID, "clientGroup", id, 15*1000, 1000 ); + } catch (Exception e1) { + logger.error("Exception Occured"+e1); + } + int count = 1; + while (count < 4) { + publishMessage(topic + "UpdateRequest", uniquID, uebURLList); + try { + for ( String msg : CConsumer.fetch () ) + { + + logger.debug("Manual Notification Recieved Message " + msg + " from UEB cluster : " + uebURLList.toString()); + resultJson = msg; + if (!msg.contains("UEB Update")){ +// System.out.println("Manual Notification Recieved Message " + msg + " from UEB cluster : " + uebURLList.toString()); + notification = NotificationUnMarshal.notificationJSON(msg); + count = 4; + } + } + }catch (Exception e) { + + } + count++; + } + } + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/MatchStore.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/MatchStore.java new file mode 100644 index 000000000..a243c1fc1 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/MatchStore.java @@ -0,0 +1,246 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std; + +import java.util.Collection; +import java.util.HashSet; + +import org.onap.policy.api.LoadedPolicy; +import org.onap.policy.api.NotificationType; +import org.onap.policy.api.PDPNotification; +import org.onap.policy.api.RemovedPolicy; +import org.onap.policy.std.StdLoadedPolicy; +import org.onap.policy.std.StdPDPNotification; +import org.onap.policy.std.StdRemovedPolicy; + +import org.onap.policy.common.logging.flexlogger.*; + +public class MatchStore { + private static HashSet matchStore = new HashSet<>(); + private static Logger logger = FlexLogger.getLogger(MatchStore.class.getName()); + + public static HashSet 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==false){ + matchStore.add(newMatch); + } + } + } + } + + //Logic changes for Requested Policies notifications.. + public static PDPNotification checkMatch(PDPNotification oldNotification) { + boolean removed = false, updated = false; + if(oldNotification==null){ + return null; + } + StdPDPNotification newNotification = new StdPDPNotification(); + if(matchStore.isEmpty()) { + logger.debug("No Success Config Calls made yet.. "); + System.out.println("No success Config calls made yet. "); + return null; + } + if(oldNotification.getRemovedPolicies()!=null && !oldNotification.getRemovedPolicies().isEmpty()){ + // send all removed policies to client. + Collection 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 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 = false; + 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(newKey.equals("ONAPName")){ + if(updatedPolicy.getMatches().get(newKey).equals(match.getOnapName())){ + matchAttributes = true; + }else { + matchAttributes = false; + break; + } + }else if(newKey.equals("ConfigName")) { + 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; + } + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/Matches.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/Matches.java new file mode 100644 index 000000000..eb382a63d --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/Matches.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std; + +import java.util.Map; + +public class Matches { + private String onapName = null; + private String configName = null; + private Map 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 getConfigAttributes() { + return configAttributes; + } + public void setConfigAttributes(Map configAttributes) { + this.configAttributes = configAttributes; + } + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/NotificationUnMarshal.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/NotificationUnMarshal.java new file mode 100644 index 000000000..2ec174c84 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/NotificationUnMarshal.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std; + +import java.util.ArrayList; +import java.util.Collection; + +import org.onap.policy.api.LoadedPolicy; +import org.onap.policy.api.RemovedPolicy; +import org.onap.policy.api.UpdateType; +import org.onap.policy.std.StdLoadedPolicy; +import org.onap.policy.std.StdPDPNotification; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class NotificationUnMarshal { + private static StdPDPNotification notification; + + public static StdPDPNotification notificationJSON(String json) throws Exception{ + ObjectMapper mapper = new ObjectMapper(); + notification = mapper.readValue(json, StdPDPNotification.class); + if(notification!=null){ + if(notification.getLoadedPolicies()!=null){ + Collection 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; + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdDecisionResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdDecisionResponse.java new file mode 100644 index 000000000..ee3f18e9f --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdDecisionResponse.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + +package org.onap.policy.std; + +import org.onap.policy.api.DecisionResponse; +import org.onap.policy.api.PolicyDecision; + +/** + * Decision Response Implementation Class. + * + * @version 0.1 + */ +public class StdDecisionResponse implements DecisionResponse { + + private PolicyDecision decision = PolicyDecision.DENY; + private String details; + + @Override + public PolicyDecision getDecision() { + return decision; + } + + @Override + public String getDetails() { + return details; + } + + public void setDecision(PolicyDecision decision){ + this.decision = decision; + } + + public void setDetails(String details) { + this.details = details; + } + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdDictionaryResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdDictionaryResponse.java new file mode 100644 index 000000000..9e0f93d23 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdDictionaryResponse.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std; + +import java.util.Map; + +import javax.json.JsonObject; + +import org.onap.policy.api.DictionaryResponse; + +public class StdDictionaryResponse implements DictionaryResponse { + private String dictionaryMessage; + private JsonObject dictionaryJson; + private Map dictionaryData; + private int responseCode; + + @Override + public String getResponseMessage() { + return dictionaryMessage; + } + + @Override + public JsonObject getDictionaryJson() { + return dictionaryJson; + } + + @Override + public Map getDictionaryData() { + return dictionaryData; + } + + @Override + public int getResponseCode() { + return responseCode; + } + + public void setResponseMessage(String dictionaryMessage) { + this.dictionaryMessage = dictionaryMessage; + } + + public void setDictionaryJson(JsonObject dictionaryJson) { + this.dictionaryJson = dictionaryJson; + } + + public void setDictionaryData(Map dictionaryData) { + this.dictionaryData = dictionaryData; + } + + public void setResponseCode(int responseCode) { + this.responseCode = responseCode; + } + + + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdMetricsResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdMetricsResponse.java new file mode 100644 index 000000000..539863d60 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdMetricsResponse.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std; + +import org.onap.policy.api.MetricsResponse; + +public class StdMetricsResponse implements MetricsResponse { + private String responseMessage; + private int pdpMetrics; + private int papMetrics; + private int metricsTotal; + private int responseCode; + + @Override + public String getResponseMessage() { + return responseMessage; + } + + @Override + public int getResponseCode() { + return responseCode; + } + + @Override + public int getPapMetrics() { + return papMetrics; + } + + @Override + public int getPdpMetrics() { + return pdpMetrics; + } + + @Override + public int getMetricsTotal() { + metricsTotal = papMetrics + pdpMetrics; + return metricsTotal; + } + + public void setResponseMessage(String responseMessage) { + this.responseMessage = responseMessage; + } + + public void setPdpMetrics(int pdpMetrics) { + this.pdpMetrics = pdpMetrics; + } + + public void setPapMetrics(int papMetrics) { + this.papMetrics = papMetrics; + } + + public void setMetricsTotal(int metricsTotal) { + this.metricsTotal = metricsTotal; + } + + public void setResponseCode(int responseCode) { + this.responseCode = responseCode; + } + +} \ No newline at end of file diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyChangeResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyChangeResponse.java new file mode 100644 index 000000000..240a53c3d --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyChangeResponse.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std; + +import org.onap.policy.api.PolicyChangeResponse; + +public class StdPolicyChangeResponse implements PolicyChangeResponse{ + private String responseMessage = null; + private int responseCode; + + @Override + public String getResponseMessage() { + return responseMessage; + } + + @Override + public int getResponseCode() { + return responseCode; + } + + public void setResponseMessage(String responseMessage){ + this.responseMessage = responseMessage; + } + + public void setResponseCode(int responseCode){ + this.responseCode = responseCode; + } + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyConfig.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyConfig.java new file mode 100644 index 000000000..8a9b0a0b4 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyConfig.java @@ -0,0 +1,168 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + +package org.onap.policy.std; + +import java.util.Map; +import java.util.Properties; + +import javax.json.JsonObject; + +import org.onap.policy.api.PolicyConfig; +import org.onap.policy.api.PolicyConfigStatus; +import org.onap.policy.api.PolicyType; +import org.w3c.dom.Document; + +/** + * PolicyConfig Implementation. + * + * @version 0.3 + * + */ + +public class StdPolicyConfig implements PolicyConfig{ + private PolicyType policyType; + private Properties properties; + private JsonObject jsonObject; + private Document document; + private String other; + private PolicyConfigStatus policyConfigStatus; + private String configStatus; + private String policyName; + private String policyVersion; + private Map matchingConditions; + private Map responseAttributes; + + @Override + public PolicyType getType() { + return policyType; + } + + @Override + public Properties toProperties() { + return properties; + } + + @Override + public JsonObject toJSON() { + return jsonObject; + } + + @Override + public Document toXML() { + return document; + } + + @Override + public String toOther() { + return other; + } + + @Override + public PolicyConfigStatus getPolicyConfigStatus() { + return policyConfigStatus; + } + + @Override + public String getPolicyConfigMessage() { + return configStatus; + } + + @Override + public String getPolicyName() { + if(policyName!=null && policyName.contains(".xml")){ + return (policyName.substring(0, policyName.substring(0, policyName.lastIndexOf(".")).lastIndexOf("."))); + } + return policyName; + } + + @Override + public String getPolicyVersion() { + return policyVersion; + } + + @Override + public Map getMatchingConditions(){ + return matchingConditions; + } + + @Override + public Map getResponseAttributes(){ + return responseAttributes; + } + + public void setPolicyType(PolicyType policyType) { + this.policyType = policyType; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + public void setPolicyVersion(String policyVersion) { + this.policyVersion = policyVersion; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } + + public void setJsonObject(JsonObject jsonObject) { + this.jsonObject = jsonObject; + } + + public void setDocument(Document document) { + this.document = document; + } + + public void setOther(String other) { + this.other = other; + } + + public void setConfigStatus(String configStatus) { + this.configStatus = configStatus; + } + + public void setPolicyConfigStatus(PolicyConfigStatus policyConfigStatus) { + this.policyConfigStatus = policyConfigStatus; + } + + public void setConfigStatus(String configStatus, PolicyConfigStatus policyConfigStatus) { + this.configStatus = configStatus; + this.policyConfigStatus = policyConfigStatus; + } + + public void setMatchingConditions(Map matchingConditions){ + this.matchingConditions = matchingConditions; + } + + public void setResponseAttributes(Map responseAttributes){ + this.responseAttributes = responseAttributes; + } + + @Override + public String toString() { + return "PolicyConfig [ policyConfigStatus=" + policyConfigStatus + ", policyConfigMessage=" + configStatus + ", policyName=" + policyName + + "" + + "]"; + } + +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java new file mode 100644 index 000000000..608bb8de0 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java @@ -0,0 +1,1254 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + +package org.onap.policy.std; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringReader; +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Base64; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + +import javax.json.Json; +import javax.json.JsonObject; +import javax.json.JsonReader; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.onap.policy.api.AttributeType; +import org.onap.policy.api.ConfigRequestParameters; +import org.onap.policy.api.DecisionRequestParameters; +import org.onap.policy.api.DecisionResponse; +import org.onap.policy.api.DeletePolicyParameters; +import org.onap.policy.api.DictionaryParameters; +import org.onap.policy.api.DictionaryResponse; +import org.onap.policy.api.EventRequestParameters; +import org.onap.policy.api.ImportParameters; +import org.onap.policy.api.MetricsRequestParameters; +import org.onap.policy.api.MetricsResponse; +import org.onap.policy.api.NotificationHandler; +import org.onap.policy.api.NotificationScheme; +import org.onap.policy.api.PDPNotification; +import org.onap.policy.api.PolicyChangeResponse; +import org.onap.policy.api.PolicyClass; +import org.onap.policy.api.PolicyConfig; +import org.onap.policy.api.PolicyConfigException; +import org.onap.policy.api.PolicyConfigType; +import org.onap.policy.api.PolicyDecisionException; +import org.onap.policy.api.PolicyEngineException; +import org.onap.policy.api.PolicyEventException; +import org.onap.policy.api.PolicyException; +import org.onap.policy.api.PolicyParameters; +import org.onap.policy.api.PolicyResponse; +import org.onap.policy.api.PolicyType; +import org.onap.policy.api.PushPolicyParameters; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; +import org.onap.policy.models.APIDictionaryResponse; +import org.onap.policy.models.APIPolicyConfigResponse; +import org.onap.policy.utils.AAFEnvironment; +import org.onap.policy.utils.PolicyUtils; +import org.onap.policy.xacml.api.XACMLErrorConstants; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.RestTemplate; +import org.xml.sax.InputSource; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * PolicyEngine Implementation class + * + * @version 1.0 + */ +public class StdPolicyEngine { + private static final String ERROR_AUTH_GET_PERM = "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to: "; + private static final String DEFAULT_NOTIFICATION = "websocket"; + + private String propertyFilePath = null; + private String clientEncoding = null; + private String contentType = null; + private static List pdps = null; + private static String environment= null; + private static String userName = null; + private static String pass = null; + private static List encoding = null; + private static boolean junit = false; + private List pdpDefault = null; + private List typeDefault = null; + private List notificationType = new ArrayList(); + private List notificationURLList = new ArrayList(); + private NotificationScheme scheme = null; + private NotificationHandler handler = null; + private AutoClientUEB uebClientThread = null; + private Thread registerUEBThread = null; + private boolean uebThread = false; + private AutoClientDMAAP dmaapClientThread = null; + private Thread registerDMAAPThread = null; + private boolean dmaapThread = false; + private String topic = null; + private String apiKey = null; + private String apiSecret = null; + + private static final String UNIQUEID = UUID.randomUUID ().toString (); + private static final Logger LOGGER = FlexLogger.getLogger(StdPolicyConfig.class.getName()); + + /* + * Taking the Property file even if it null. + */ + public StdPolicyEngine(String propertyFilePath, String clientKey) throws PolicyEngineException { + setProperty(propertyFilePath, clientKey); + } + + /* + * Taking the Notification Constructor. + */ + public StdPolicyEngine(String propertyFilePath, + NotificationScheme scheme, + NotificationHandler handler) throws PolicyEngineException { + setProperty(propertyFilePath, null); + this.scheme = scheme; + this.handler = handler; + if ((!"ueb".equals(notificationType.get(0)))||(!"dmaap".equals(notificationType.get(0)))){ + AutoClientEnd.setAuto(scheme, handler); + } + notification(scheme, handler); + } + + /* + * Taking the Notification Constructor. + */ + public StdPolicyEngine(String propertyFilePath, NotificationScheme scheme) throws PolicyEngineException { + setProperty(propertyFilePath, null); + this.scheme = scheme; + setScheme(scheme); + } + + /* + * sendEvent API Implementation + */ + public Collection sendEvent(Map eventAttributes, UUID requestID) throws PolicyEventException { + return sendEventImpl(eventAttributes, requestID); + } + + /* + * sendEvent API Implementation for eventRequestParameters + */ + public Collection sendEvent(EventRequestParameters eventRequestParameters) throws PolicyEventException{ + if(eventRequestParameters==null){ + String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No event Request Parameters Given. "; + LOGGER.error(message); + throw new PolicyEventException(message); + } + return sendEventImpl(eventRequestParameters.getEventAttributes(), eventRequestParameters.getRequestID()); + } + + /* + * getConfig using configRequestParameters Implementation + */ + public Collection getConfig(ConfigRequestParameters configRequestParameters) throws PolicyConfigException{ + return getConfigImpl(configRequestParameters); + } + + /* + * listPolicies using configRequestParameters Implementation + */ + public Collection listConfig(ConfigRequestParameters listPolicyRequestParameters) throws PolicyConfigException{ + return listConfigImpl(listPolicyRequestParameters); + } + + /* + * getDecision using the decision Attributes. + */ + public DecisionResponse getDecision(String onapComponentName, Map decisionAttributes, UUID requestID) throws PolicyDecisionException { + return getDecisionImpl(onapComponentName, decisionAttributes, requestID); + } + + /* + * getDecision Using decisionRequestParameters. + */ + public DecisionResponse getDecision(DecisionRequestParameters decisionRequestParameters) throws PolicyDecisionException{ + if(decisionRequestParameters==null){ + String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Decision Request Parameters Given. "; + LOGGER.error(message); + throw new PolicyDecisionException(message); + } + return getDecisionImpl(decisionRequestParameters.getONAPComponentName(), decisionRequestParameters.getDecisionAttributes(), decisionRequestParameters.getRequestID()); + } + + /* + * getMetrics using metricsRequestParameters + */ + public MetricsResponse getMetrics(MetricsRequestParameters parameters) throws PolicyException{ + return getMetricsImpl(parameters); + } + + public MetricsResponse getMetricsImpl(MetricsRequestParameters parameters) throws PolicyException{ + StdMetricsResponse response = new StdMetricsResponse(); + String resource = "getMetrics"; + String body = new String(); + + // Create the Request + try { + if (parameters!=null) { + body = PolicyUtils.objectToJsonString(parameters); + } + } catch (JsonProcessingException e) { + String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; + LOGGER.error(message); + throw new PolicyException(message, e); + } + // Get Response. + try { + ResponseEntity result = callNewPDP(resource, HttpMethod.GET, body, String.class); + // Process response + response.setResponseMessage(result.getBody()); + response.setResponseCode(result.getStatusCode().value()); + } catch (PolicyException exception) { + if(exception.getCause()!=null && exception.getCause() instanceof HttpClientErrorException){ + LOGGER.error(exception); + HttpClientErrorException ex = (HttpClientErrorException) exception.getCause(); + response.setResponseCode(ex.getRawStatusCode()); + response.setResponseMessage(exception.getMessage()); + return response; + }else{ + String message = XACMLErrorConstants.ERROR_SYSTEM_ERROR+ "Error while processing results. please check logs."; + LOGGER.error(message, exception); + throw new PolicyException(message, exception); + } + } + return response; + } + + /* + * PushPolicy using pushPolicyParameters. + */ + public PolicyChangeResponse pushPolicy(PushPolicyParameters pushPolicyParameters) throws PolicyException{ + return pushPolicyImpl(pushPolicyParameters); + } + + public PolicyChangeResponse pushPolicyImpl(PushPolicyParameters pushPolicyParameters) throws PolicyException{ + StdPolicyChangeResponse response = new StdPolicyChangeResponse(); + String resource= "pushPolicy"; + String body = new String(); + // Create Request. + try { + body = PolicyUtils.objectToJsonString(pushPolicyParameters); + } catch (JsonProcessingException e) { + String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; + LOGGER.error(message); + throw new PolicyException(message, e); + } + // Get Response. + try { + ResponseEntity result = callNewPDP(resource, HttpMethod.PUT, body, String.class); + // Process response + response.setResponseMessage(result.getBody()); + response.setResponseCode(result.getStatusCode().value()); + } catch (PolicyException exception) { + return processException(exception); + } + return response; + } + + /* + * Delete a Policy using deletePolicyParameters + */ + public PolicyChangeResponse deletePolicy(DeletePolicyParameters parameters) throws PolicyException { + return deletePolicyImpl(parameters); + } + + public PolicyChangeResponse deletePolicyImpl(DeletePolicyParameters parameters) throws PolicyException { + StdPolicyChangeResponse response = new StdPolicyChangeResponse(); + String resource= "deletePolicy"; + String body = new String(); + // Create Request. + try { + body = PolicyUtils.objectToJsonString(parameters); + } catch (JsonProcessingException e) { + String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; + LOGGER.error(message); + throw new PolicyException(message, e); + } + // Get Response. + try { + ResponseEntity result = callNewPDP(resource, HttpMethod.DELETE, body, String.class); + // Process response + response.setResponseMessage(result.getBody()); + response.setResponseCode(result.getStatusCode().value()); + } catch (PolicyException exception) { + return processException(exception); + } + return response; + } + + /* + * getDictionaryItem Using dictionaryParameters + */ + public DictionaryResponse getDictionaryItem(DictionaryParameters parameters) throws PolicyException { + return getDictionaryItemImpl(parameters); + } + + public DictionaryResponse getDictionaryItemImpl(DictionaryParameters parameters) throws PolicyException{ + StdDictionaryResponse response = new StdDictionaryResponse(); + String resource="getDictionaryItems"; + String body = "{}"; + // Create Request. + try { + body = PolicyUtils.objectToJsonString(parameters); + } catch (JsonProcessingException e) { + String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; + LOGGER.error(message); + throw new PolicyException(message, e); + } + // Get Response. + try { + ResponseEntity result = callNewPDP(resource, HttpMethod.POST, body, APIDictionaryResponse.class); + // Process response + response = dictionaryResult(result.getBody()); + } catch (Exception exception) { + if(exception.getCause().getMessage().contains("401")){ + String message = XACMLErrorConstants.ERROR_PERMISSIONS + ERROR_AUTH_GET_PERM + resource; + LOGGER.error(message); + response.setResponseMessage(message); + response.setResponseCode(401); + return response; + }if(exception.getCause().getMessage().contains("400")){ + String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given."; + response.setResponseMessage(message); + response.setResponseCode(400); + return response; + } + String message = XACMLErrorConstants.ERROR_PERMISSIONS+ "Unable to get valid Response from PDP(s) " + pdps; + LOGGER.error(message, exception); + response.setResponseMessage(message); + response.setResponseCode(500); + return response; + } + return response; + } + + @SuppressWarnings("unchecked") + private StdDictionaryResponse dictionaryResult(APIDictionaryResponse body) { + StdDictionaryResponse response = new StdDictionaryResponse(); + response.setResponseCode(body.getResponseCode()); + response.setResponseMessage(body.getResponseMessage()); + response.setDictionaryData((Map) body.getDictionaryData()); + if(body.getDictionaryJson()!=null){ + Gson objGson = new GsonBuilder().create(); + String mapToJson = objGson.toJson(body.getDictionaryJson()); + JsonReader jsonReader = Json.createReader(new StringReader(mapToJson)); + JsonObject object = jsonReader.readObject(); + jsonReader.close(); + response.setDictionaryJson(object); + } + return response; + } + + /* + * createDictinaryItem Using dictionaryParameters. + */ + public PolicyChangeResponse createDictionaryItem(DictionaryParameters parameters) throws PolicyException{ + return createUpdateDictionaryItemImpl(parameters, false); + } + + /* + * updateDictinaryItem Using dictionaryParameters. + */ + public PolicyChangeResponse updateDictionaryItem(DictionaryParameters parameters) throws PolicyException{ + return createUpdateDictionaryItemImpl(parameters, true); + } + + public PolicyChangeResponse createUpdateDictionaryItemImpl(DictionaryParameters parameters, boolean updateFlag) throws PolicyException{ + StdPolicyChangeResponse response = new StdPolicyChangeResponse(); + String resource = "createDictionaryItem"; + if(updateFlag){ + resource = "updateDictionaryItem"; + } + String body = new String(); + // Create Request. + try { + body = PolicyUtils.objectToJsonString(parameters); + } catch (JsonProcessingException e) { + String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; + LOGGER.error(message); + throw new PolicyException(message, e); + } + // Get Response. + try { + ResponseEntity result = callNewPDP(resource, HttpMethod.PUT, body, String.class); + // Process response + response.setResponseMessage(result.getBody()); + response.setResponseCode(result.getStatusCode().value()); + } catch (PolicyException exception) { + return processException(exception); + } + return response; + } + + /* + * PolicyEngine Import + */ + public PolicyChangeResponse policyEngineImport(ImportParameters importParameters) throws PolicyException { + return policyEngineImportImpl(importParameters); + } + + public PolicyChangeResponse policyEngineImportImpl(ImportParameters importParameters) throws PolicyException { + StdPolicyChangeResponse response = new StdPolicyChangeResponse(); + String resource= "policyEngineImport"; + LinkedMultiValueMap parameters = new LinkedMultiValueMap(); + // Create Request. + try { + String body = PolicyUtils.objectToJsonString(importParameters); + parameters.set("importParametersJson", body); + parameters.set("file", new FileSystemResource(importParameters.getFilePath())); + } catch (Exception e) { + String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; + LOGGER.error(message); + throw new PolicyException(message, e); + } + contentType = MediaType.MULTIPART_FORM_DATA_VALUE; + // Get Response. + try { + ResponseEntity result = callNewPDP(resource, HttpMethod.POST, parameters, String.class); + // Process response + response.setResponseMessage(result.getBody()); + response.setResponseCode(result.getStatusCode().value()); + } catch (PolicyException exception) { + return processException(exception); + } finally{ + contentType = null; + } + return response; + } + + /* + * createPolicy Using policyParameters. + */ + public PolicyChangeResponse createPolicy(PolicyParameters policyParameters) throws PolicyException{ + return createUpdatePolicyImpl(policyParameters, false); + } + + /* + * updatePolicy using policyParameters. + */ + public PolicyChangeResponse updatePolicy(PolicyParameters policyParameters) throws PolicyException{ + return createUpdatePolicyImpl(policyParameters, true); + } + + public PolicyChangeResponse createUpdatePolicyImpl(PolicyParameters policyParameters, boolean updateFlag) throws PolicyException{ + StdPolicyChangeResponse response = new StdPolicyChangeResponse(); + String resource= "createPolicy"; + if(updateFlag){ + resource="updatePolicy"; + } + String body = new String(); + // Create Request. + try { + body = PolicyUtils.objectToJsonString(policyParameters); + } catch (JsonProcessingException e) { + String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; + LOGGER.error(message); + throw new PolicyException(message, e); + } + // Get Response. + try { + ResponseEntity result = callNewPDP(resource, HttpMethod.PUT, body, String.class); + // Process response + response.setResponseMessage(result.getBody()); + response.setResponseCode(result.getStatusCode().value()); + } catch (PolicyException exception) { + return processException(exception); + } + return response; + } + + private PolicyChangeResponse processException(PolicyException exception) throws PolicyException { + StdPolicyChangeResponse response = new StdPolicyChangeResponse(); + if(exception.getCause()!=null && exception.getCause() instanceof HttpClientErrorException){ + LOGGER.error(exception); + HttpClientErrorException ex = (HttpClientErrorException) exception.getCause(); + response.setResponseCode(ex.getRawStatusCode()); + response.setResponseMessage(exception.getMessage()); + return response; + }else{ + String message = XACMLErrorConstants.ERROR_SYSTEM_ERROR+ "Error while processing results. please check logs."; + LOGGER.error(message, exception); + throw new PolicyException(message, exception); + } + } + + public DecisionResponse getDecisionImpl(String onapComponentName, + Map decisionAttributes, + UUID requestID) throws PolicyDecisionException { + String resource= "getDecision"; + StdDecisionResponse response = new StdDecisionResponse(); + String body = new String(); + // Create Request. + try { + DecisionRequestParameters decisionRequestParameters = new DecisionRequestParameters(); + decisionRequestParameters.setDecisionAttributes(decisionAttributes); + decisionRequestParameters.setONAPComponentName(onapComponentName); + decisionRequestParameters.setRequestID(requestID); + body = PolicyUtils.objectToJsonString(decisionRequestParameters); + } catch (JsonProcessingException e) { + String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; + LOGGER.error(message); + throw new PolicyDecisionException(message, e); + } + // Get Response. + try { + ResponseEntity result = callNewPDP(resource, HttpMethod.POST, body, StdDecisionResponse.class); + // Process response + response = result.getBody(); + } catch (Exception exception) { + if(exception.getCause().getMessage().contains("401")){ + String message = XACMLErrorConstants.ERROR_PERMISSIONS + ERROR_AUTH_GET_PERM + resource; + LOGGER.error(message); + throw new PolicyDecisionException(message, exception); + }if(exception.getCause().getMessage().contains("400")){ + String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given."; + LOGGER.error(message); + throw new PolicyDecisionException(message, exception); + } + String message = XACMLErrorConstants.ERROR_PERMISSIONS+ "Unable to get valid Response from PDP(s) " + pdps; + LOGGER.error(message, exception); + throw new PolicyDecisionException(message, exception); + } + return response; + } + + public Collection getConfigImpl(ConfigRequestParameters configRequestParameters) throws PolicyConfigException{ + String resource= "getConfig"; + ArrayList response = new ArrayList<>(); + String body = new String(); + // Create Request. + try { + body = PolicyUtils.objectToJsonString(configRequestParameters); + } catch (JsonProcessingException e) { + String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; + LOGGER.error(message); + throw new PolicyConfigException(message, e); + } + // Get Response. + try { + ResponseEntity result = callNewPDP(resource, HttpMethod.POST, body, APIPolicyConfigResponse[].class); + // Process Response + response = configResult(result.getBody()); + } catch (Exception exception) { + if(exception.getCause().getMessage().contains("401")){ + String message = XACMLErrorConstants.ERROR_PERMISSIONS + ERROR_AUTH_GET_PERM + resource; + LOGGER.error(message); + throw new PolicyConfigException(message, exception); + }if(exception.getCause().getMessage().contains("400")){ + String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given."; + LOGGER.error(message); + throw new PolicyConfigException(message, exception); + } + String message = XACMLErrorConstants.ERROR_PROCESS_FLOW+ "Unable to get valid Response from PDP(s) " + pdps; + LOGGER.error(message, exception); + throw new PolicyConfigException(message, exception); + } + return response; + } + + private ArrayList configResult(APIPolicyConfigResponse[] response) throws PolicyConfigException { + ArrayList result = new ArrayList<>(); + if(response!=null && response.length>0){ + for(APIPolicyConfigResponse policyConfigResponse: response){ + StdPolicyConfig policyConfig = new StdPolicyConfig(); + policyConfig.setConfigStatus(policyConfigResponse.getPolicyConfigMessage()); + policyConfig.setMatchingConditions(policyConfigResponse.getMatchingConditions()); + policyConfig.setPolicyConfigStatus(policyConfigResponse.getPolicyConfigStatus()); + policyConfig.setPolicyName(policyConfigResponse.getPolicyName()); + policyConfig.setPolicyType(policyConfigResponse.getType()); + policyConfig.setPolicyVersion(policyConfigResponse.getPolicyVersion()); + policyConfig.setResponseAttributes(policyConfigResponse.getResponseAttributes()); + setMatches(policyConfig.getMatchingConditions()); + if(policyConfigResponse.getType()!=null){ + try { + switch (policyConfigResponse.getType()) { + case JSON: + JsonReader jsonReader = Json.createReader(new StringReader(policyConfigResponse.getConfig())); + JsonObject object = jsonReader.readObject(); + jsonReader.close(); + policyConfig.setJsonObject(object); + break; + case OTHER: + policyConfig.setOther(policyConfigResponse.getConfig()); + break; + case PROPERTIES: + Properties props = new Properties(); + props.putAll(policyConfigResponse.getProperty()); + policyConfig.setProperties(props); + break; + case XML: + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder; + builder = factory.newDocumentBuilder(); + policyConfig.setDocument(builder.parse(new InputSource(new StringReader(policyConfigResponse.getConfig())))); + break; + } + } catch (Exception e) { + LOGGER.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID+ e); + throw new PolicyConfigException(XACMLErrorConstants.ERROR_SCHEMA_INVALID+ "Unable to parse the config", e); + } + } + result.add(policyConfig); + } + } + return result; + } + + private void setMatches(Map matchingConditions) { + Matches match = new Matches(); + HashMap configAttributes = new HashMap<>(); + try{ + for(String key: matchingConditions.keySet()){ + if(key.equalsIgnoreCase("ONAPName")){ + match.setOnapName(matchingConditions.get(key)); + }else if(key.equalsIgnoreCase("ConfigName")){ + match.setConfigName(matchingConditions.get(key)); + }else{ + configAttributes.put(key, matchingConditions.get(key)); + } + } + if(!configAttributes.isEmpty()){ + match.setConfigAttributes(configAttributes); + } + MatchStore.storeMatch(match); + }catch(Exception e){ + LOGGER.info("StoreMatch failed for Onap:" + + match.getOnapName() + " Config: " + + match.getConfigName()); + } + } + + /* + * Generic Rest Client to call PDP services. + */ + private ResponseEntity callNewPDP(String resource, + HttpMethod method, Object body, Class responseType) throws PolicyException{ + RestTemplate restTemplate = new RestTemplate(); + HttpEntity requestEntity = new HttpEntity<>(body, getHeaders()); + ResponseEntity result = null; + HttpClientErrorException exception = null; + int pdpsCount = 0; + while(pdpsCount < pdps.size()){ + try{ + result = restTemplate.exchange(pdps.get(0)+"/api/" + resource, method, requestEntity, responseType); + }catch(HttpClientErrorException e){ + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while connecting to " + pdps.get(0), e); + exception = e; + }catch(Exception e){ + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while connecting to " + pdps.get(0), e); + exception = new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage()); + } + if(result == null){ + Collections.rotate(pdps, -1); + Collections.rotate(encoding, -1); + pdpsCount++; + }else{ + break; + } + } + if(exception != null && exception.getStatusCode()!=null){ + if(exception.getStatusCode().equals(HttpStatus.UNAUTHORIZED)){ + String message = XACMLErrorConstants.ERROR_PERMISSIONS +":"+exception.getStatusCode()+":" +ERROR_AUTH_GET_PERM + resource; + LOGGER.error(message); + throw new PolicyException(message, exception); + } + if(exception.getStatusCode().equals(HttpStatus.BAD_REQUEST)){ + String message = XACMLErrorConstants.ERROR_DATA_ISSUE + ":"+exception.getStatusCode()+":" + exception.getResponseBodyAsString(); + LOGGER.error(message); + throw new PolicyException(message, exception); + } + if(exception.getStatusCode().equals(HttpStatus.NOT_FOUND)){ + String message = XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while connecting to " + pdps + exception; + LOGGER.error(message); + throw new PolicyException(message, exception); + } + String message = XACMLErrorConstants.ERROR_PROCESS_FLOW + ":"+exception.getStatusCode()+":" + exception.getResponseBodyAsString(); + LOGGER.error(message); + throw new PolicyException(message, exception); + } + return result; + } + + private HttpHeaders getHeaders() { + HttpHeaders headers = new HttpHeaders(); + headers.set("ClientAuth", "Basic " + clientEncoding); + headers.set("Authorization", "Basic " + encoding.get(0)); + if(contentType!=null){ + headers.set("Content-Type", contentType.toString()); + }else{ + headers.set("Content-Type", MediaType.APPLICATION_JSON_VALUE); + } + headers.set("Environment", environment); + return headers; + } + + private void setClientEncoding() { + Base64.Encoder encoder = Base64.getEncoder(); + clientEncoding = encoder.encodeToString((userName+":"+pass).getBytes(StandardCharsets.UTF_8)); + } + + public Collection listConfigImpl(ConfigRequestParameters listRequestParameters) throws PolicyConfigException{ + Collection policyList = new ArrayList<>(); + if (junit){ + policyList.add("Policy Name: listConfigTest"); + return policyList; + } + Collection policyConfig = getConfigImpl(listRequestParameters); + for(PolicyConfig policy : policyConfig){ + if(policy.getPolicyConfigMessage()!=null && policy.getPolicyConfigMessage().contains("PE300")){ + policyList.add(policy.getPolicyConfigMessage()); + } else { + policyList.add("Policy Name: " + policy.getPolicyName()); + } + } + return policyList; + } + + public Collection sendEventImpl(Map eventAttributes, UUID requestID) throws PolicyEventException { + String resource= "sendEvent"; + ArrayList response = new ArrayList(); + String body = new String(); + // Create Request. + try { + // Long way here, can be shortened and will be done. + EventRequestParameters eventRequestParameters = new EventRequestParameters(); + eventRequestParameters.setEventAttributes(eventAttributes); + eventRequestParameters.setRequestID(requestID); + body = PolicyUtils.objectToJsonString(eventRequestParameters); + } catch (JsonProcessingException e) { + String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; + LOGGER.error(message); + throw new PolicyEventException(message, e); + } + // Get Response. + try { + ResponseEntity result = callNewPDP(resource, HttpMethod.POST, body, StdPolicyResponse[].class); + // Process Response + response = eventResult(result.getBody()); + } catch (Exception exception) { + if(exception.getCause().getMessage().contains("401")){ + String message = XACMLErrorConstants.ERROR_PERMISSIONS + ERROR_AUTH_GET_PERM + resource; + LOGGER.error(message); + throw new PolicyEventException(message, exception); + }if(exception.getCause().getMessage().contains("400")){ + String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given."; + LOGGER.error(message); + throw new PolicyEventException(message, exception); + } + String message = XACMLErrorConstants.ERROR_PERMISSIONS+ "Unable to get valid Response from PDP(s) " + pdps; + LOGGER.error(message, exception); + throw new PolicyEventException(message, exception); + } + return response; + } + + private ArrayList eventResult(StdPolicyResponse[] response) throws PolicyEventException{ + ArrayList eventResult = new ArrayList<>(); + if(response!=null && response.length>0){ + for(StdPolicyResponse policyConfigResponse: response){ + eventResult.add(policyConfigResponse); + } + } + return eventResult; + } + + private void setProperty(String propertyFilePath, String clientKey) + throws PolicyEngineException { + this.propertyFilePath = propertyFilePath; + if (this.propertyFilePath == null) { + throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error NO PropertyFile Path provided"); + } else { + // Adding logic for remote Properties file. + Properties prop = new Properties(); + if (propertyFilePath.startsWith("http")) { + URL configURL; + try { + configURL = new URL(propertyFilePath); + URLConnection connection = null; + connection = configURL.openConnection(); + prop.load(connection.getInputStream()); + } catch (IOException e) { + LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e); + throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Maformed property URL "+ e.getMessage()); + } + } else { + Path file = Paths.get(propertyFilePath); + if (Files.notExists(file)) { + throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "File doesn't exist in the specified Path " + file.toString()); + } + if (file.toString().endsWith(".properties")) { + InputStream in; + prop = new Properties(); + try { + in = new FileInputStream(file.toFile()); + prop.load(in); + } catch (IOException e) { + LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e); + throw new PolicyEngineException(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Cannot Load the Properties file", e); + } + } else { + LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Not a .properties file " + propertyFilePath); + throw new PolicyEngineException(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Not a .properties file"); + } + } + // UEB and DMAAP Settings + String check_type = prop.getProperty("NOTIFICATION_TYPE"); + String serverList = prop.getProperty("NOTIFICATION_SERVERS"); + topic = prop.getProperty("NOTIFICATION_TOPIC"); + apiKey = prop.getProperty("UEB_API_KEY"); + apiSecret = prop.getProperty("UEB_API_SECRET"); + + if(check_type==null) { + notificationType.add(DEFAULT_NOTIFICATION); + LOGGER.info("Properties file doesn't have the NOTIFICATION_TYPE parameter system will use defualt websockets"); + }else{ + check_type = check_type.trim(); + if(check_type.contains(",")) { + typeDefault = new ArrayList(Arrays.asList(prop.getProperty("NOTIFICATION_TYPE").split(","))); + notificationType = typeDefault; + } else { + notificationType = new ArrayList<>(); + notificationType.add(check_type); + } + } + if(serverList==null) { + notificationType.clear(); + notificationType.add(DEFAULT_NOTIFICATION); + LOGGER.info("Properties file doesn't have the NOTIFICATION_SERVERS parameter system will use defualt websockets"); + }else{ + serverList = serverList.trim(); + if(serverList.contains(",")) { + notificationURLList = new ArrayList(Arrays.asList(serverList.split(","))); + } else { + notificationURLList = new ArrayList<>(); + notificationURLList.add(serverList); + } + } + + if(topic!=null) { + topic = topic.trim(); + } else { + LOGGER.error("Properties file doesn't have the NOTIFICATION_TOPIC parameter."); + } + + // Client ID Authorization Settings. + String clientID = prop.getProperty("CLIENT_ID"); + if(clientKey==null){ + clientKey = prop.getProperty("CLIENT_KEY"); + try { + clientKey = PolicyUtils.decode(clientKey); + } catch (UnsupportedEncodingException|IllegalArgumentException e) { + LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS+" Cannot Decode the given Password Proceeding with given Password!!"); + } + } + if(clientID ==null || clientKey == null || clientID.isEmpty() || clientKey.isEmpty()){ + LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS+" Cannot proceed without the CLIENT_KEY and CLIENT_ID values !!"); + throw new PolicyEngineException(XACMLErrorConstants.ERROR_PERMISSIONS+ " Cannot proceed without the CLIENT_KEY and CLIENT_ID values !!"); + }else{ + userName = clientID.trim(); + pass = clientKey.trim(); + } + setClientEncoding(); + environment = prop.getProperty("ENVIRONMENT", AAFEnvironment.DEVL.toString()); + if(environment.equalsIgnoreCase(AAFEnvironment.TEST.toString())){ + environment = AAFEnvironment.TEST.toString(); + }else if(environment.equalsIgnoreCase(AAFEnvironment.PROD.toString())){ + environment = AAFEnvironment.PROD.toString(); + }else{ + environment = AAFEnvironment.DEVL.toString(); + } + // Initializing the values. + pdps = new ArrayList<>(); + encoding = new ArrayList<>(); + // Check the Keys for PDP_URLs + Collection unsorted = prop.keySet(); + @SuppressWarnings({ "rawtypes", "unchecked" }) + List sorted = new ArrayList(unsorted); + Collections.sort(sorted); + for (String propKey : sorted) { + if (propKey.startsWith("PDP_URL")) { + String check_val = prop.getProperty(propKey); + if (check_val == null) { + throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Properties file doesn't have the PDP_URL parameter"); + } + if (check_val.contains(";")) { + pdpDefault = new ArrayList(Arrays.asList(check_val.split("\\s*;\\s*"))); + int pdpCount = 0; + while (pdpCount < pdpDefault.size()) { + String pdpVal = pdpDefault.get(pdpCount); + readPDPParam(pdpVal); + pdpCount++; + } + } else { + readPDPParam(check_val); + } + } + } + if (pdps == null || pdps.isEmpty()) { + LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot Proceed without PDP_URLs"); + throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot Proceed without PDP_URLs"); + } + + // Get JUNIT property from properties file when running tests + String junit = prop.getProperty("JUNIT"); + if(junit == null || junit.isEmpty()){ + LOGGER.info("No JUNIT property provided, this will not be executed as a test."); + }else{ + if(junit.equalsIgnoreCase("test")){ + StdPolicyEngine.junit = true; + } else { + StdPolicyEngine.junit = false; + } + } + } + } + + /* + * Read the PDP_URL parameter + */ + private void readPDPParam(String pdpVal) throws PolicyEngineException{ + if(pdpVal.contains(",")){ + List pdpValues = new ArrayList(Arrays.asList(pdpVal.split("\\s*,\\s*"))); + if(pdpValues.size()==3){ + // 0 - PDPURL + pdps.add(pdpValues.get(0)); + // 1:2 will be UserID:Password + String userID = pdpValues.get(1); + String pass = pdpValues.get(2); + Base64.Encoder encoder = Base64.getEncoder(); + encoding.add(encoder.encodeToString((userID+":"+pass).getBytes(StandardCharsets.UTF_8))); + }else{ + LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Credentials to send Request: " + pdpValues); + throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "No enough Credentials to send Request. " + pdpValues); + } + }else{ + LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "PDP value is improper/missing required values: " + pdpVal); + throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "PDP value is improper/missing required values."); + } + } + /* + * Allowing changes to the scheme and Handler. + */ + public void notification(NotificationScheme scheme, NotificationHandler handler) { + this.scheme = scheme; + this.handler = handler; + LOGGER.debug("Scheme is : " + scheme.toString()); + LOGGER.debug("Handler is : " + handler.getClass().getName()); + + if (notificationType.get(0).equals("ueb")){ + if (this.uebThread) { + uebClientThread.setAuto(scheme, handler); + this.uebThread = registerUEBThread.isAlive(); + } + } else if (notificationType.get(0).equals("dmaap")){ + if (this.dmaapThread) { + dmaapClientThread.setAuto(scheme, handler); + this.dmaapThread = registerDMAAPThread.isAlive(); + } + } else { + AutoClientEnd.setAuto(scheme, handler); + } + + if(junit){ + return; + } + + if(pdps!=null){ + if (notificationType.get(0).equals("ueb") && !this.uebThread){ + this.uebClientThread = new AutoClientUEB(pdps.get(0), notificationURLList, apiKey, apiSecret); + this.uebClientThread.setAuto(scheme, handler); + this.registerUEBThread = new Thread(this.uebClientThread); + this.registerUEBThread.start(); + this.uebThread = true; + }else if (notificationType.get(0).equals("dmaap") && !this.dmaapThread){ + this.dmaapClientThread = new AutoClientDMAAP(notificationURLList,topic,userName,pass); + this.dmaapClientThread.setAuto(scheme, handler); + this.registerDMAAPThread = new Thread(this.dmaapClientThread); + this.registerDMAAPThread.start(); + this.dmaapThread = true; + }else{ + if(pdps.get(0)!=null){ + if(AutoClientEnd.getURL()==null){ + AutoClientEnd.start(pdps.get(0)); + }else { + AutoClientEnd.stop(); + AutoClientEnd.start(pdps.get(0)); + } + } + } + } + } + + /* + * Gets the Notification if one exists. Used only for Manual Polling + * purposes. + */ + public PDPNotification getNotification(){ + //Check if there is proper scheme.. + PDPNotification notification = null; + if(this.scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS) || this.scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) { + if (notificationType.get(0).equals("ueb")){ + ManualClientEndUEB.start(pdps.get(0), notificationURLList, UNIQUEID); + notification = ManualClientEndUEB.result(scheme); + }else if (notificationType.get(0).equals("dmaap")){ + ManualClientEndDMAAP.start(notificationURLList, topic, UNIQUEID, userName, pass); + notification = ManualClientEndDMAAP.result(scheme); + }else{ + ManualClientEnd.start(pdps.get(0)); + LOGGER.debug("manual notification requested.. : " + scheme.toString()); + notification = ManualClientEnd.result(scheme); + } + if (notification == null){ + LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Notification yet.."); + return null; + } else { + return notification; + } + }else { + return null; + } + } + + /* + * Setting the Scheme. + */ + public void setScheme(NotificationScheme scheme) { + this.scheme = scheme; + if (notificationType.get(0).equals("ueb")){ + AutoClientUEB.setScheme(this.scheme); + if (this.scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)){ + ManualClientEndUEB.createTopic(pdps.get(0), UNIQUEID, notificationURLList); + } + }else if (notificationType.get(0).equals("dmaap")){ + AutoClientDMAAP.setScheme(this.scheme); + if (this.scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)){ + ManualClientEndDMAAP.createTopic(topic, UNIQUEID, notificationURLList, userName, pass); + } + }else{ + AutoClientEnd.setScheme(this.scheme); + } + } + + /* + * Returns the Scheme + */ + public NotificationScheme getScheme() { + return this.scheme; + } + + /* + * Returns the NotificationHandler + */ + public NotificationHandler getNotificationHandler() { + return this.handler; + } + + /* + * Stop the Notification Service if its running. + */ + public void stopNotification() { + if (this.scheme != null && this.handler != null) { + if (this.scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS) + || this.scheme + .equals(NotificationScheme.AUTO_NOTIFICATIONS)) { + LOGGER.info("Clear Notification called.. "); + if (notificationType.get(0).equals("ueb")){ + this.uebClientThread.terminate(); + this.uebThread = false; + }else if (notificationType.get(0).equals("dmaap")){ + this.dmaapClientThread.terminate(); + this.dmaapThread = false; + }else{ + AutoClientEnd.stop(); + } + } + } + } + + /* + * Push a policy to the PDP API implementation + */ + public String pushPolicy(String policyScope, String policyName, String policyType, String pdpGroup, UUID requestID) throws PolicyException { + PushPolicyParameters pushPolicyParameters = new PushPolicyParameters(); + if(policyScope==null|| policyScope.trim().isEmpty()){ + String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given."; + LOGGER.error(message); + throw new PolicyException(message); + } + if(policyName==null|| policyName.trim().isEmpty()){ + String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given."; + LOGGER.error(message); + throw new PolicyException(message); + } + pushPolicyParameters.setPolicyName(policyScope+"."+policyName); + pushPolicyParameters.setPolicyType(policyType); + pushPolicyParameters.setPdpGroup(pdpGroup); + pushPolicyParameters.setRequestID(requestID); + return pushPolicyImpl(pushPolicyParameters).getResponseMessage(); + } + + public String createUpdateConfigPolicy(String policyName, String policyDescription, String onapName, String configName, + Map configAttributes, String configType, String body, String policyScope, UUID requestID, + String riskLevel, String riskType, String guard, String ttlDate, boolean updateFlag) throws PolicyException { + return createUpdateConfigPolicyImpl(policyName, policyDescription, onapName, configName, + configAttributes, configType, body, policyScope, requestID, + riskLevel, riskType, guard, ttlDate, updateFlag); + } + + /* + * Create Config Policy API Implementation + */ + public String createUpdateConfigPolicyImpl(String policyName, String policyDescription, String onapName, String configName, + Map configAttributes, String configType, String body, String policyScope, UUID requestID, + String riskLevel, String riskType, String guard, String ttlDate, boolean updateFlag) throws PolicyException { + PolicyParameters policyParameters = new PolicyParameters(); + policyParameters.setPolicyClass(PolicyClass.Config); + policyParameters.setPolicyConfigType(PolicyConfigType.Base); + if(policyScope==null|| policyScope.trim().isEmpty()){ + String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given."; + LOGGER.error(message); + throw new PolicyException(message); + } + if(policyName==null|| policyName.trim().isEmpty()){ + String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given."; + LOGGER.error(message); + throw new PolicyException(message); + } + policyParameters.setPolicyName(policyScope+"."+policyName); + policyParameters.setPolicyDescription(policyDescription); + policyParameters.setOnapName(onapName); + policyParameters.setConfigName(configName); + Map> attributes = new HashMap>(); + attributes.put(AttributeType.MATCHING, configAttributes); + policyParameters.setAttributes(attributes); + policyParameters.setConfigBodyType(PolicyType.valueOf(configType)); + policyParameters.setConfigBody(body); + policyParameters.setRequestID(requestID); + policyParameters.setRiskLevel(riskLevel); + policyParameters.setRiskType(riskType); + policyParameters.setGuard(Boolean.parseBoolean(guard)); + try { + policyParameters.setTtlDate(new SimpleDateFormat("dd-MM-yyyy").parse(ttlDate)); + } catch (ParseException e) { + LOGGER.warn("Error Parsing date given " + ttlDate); + policyParameters.setTtlDate(null); + } + return createUpdatePolicyImpl(policyParameters, updateFlag).getResponseMessage(); + } + + public String createUpdateConfigFirewallPolicy(String policyName, JsonObject firewallJson, String policyScope, UUID requestID, + String riskLevel, String riskType, String guard, String ttlDate, boolean updateFlag) throws PolicyException { + return createUpdateConfigFirewallPolicyImpl(policyName, firewallJson, policyScope, requestID, + riskLevel, riskType, guard, ttlDate, updateFlag); + } + + /* + * Create Update Config Firewall Policy API implementation + */ + public String createUpdateConfigFirewallPolicyImpl(String policyName, JsonObject firewallJson, String policyScope, UUID requestID, + String riskLevel, String riskType, String guard, String ttlDate, boolean updateFlag) throws PolicyException { + PolicyParameters policyParameters = new PolicyParameters(); + policyParameters.setPolicyClass(PolicyClass.Config); + policyParameters.setPolicyConfigType(PolicyConfigType.Firewall); + if(policyScope==null|| policyScope.trim().isEmpty()){ + String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given."; + LOGGER.error(message); + throw new PolicyException(message); + } + if(policyName==null|| policyName.trim().isEmpty()){ + String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given."; + LOGGER.error(message); + throw new PolicyException(message); + } + policyParameters.setPolicyName(policyScope+"."+policyName); + policyParameters.setConfigBody(firewallJson.toString()); + policyParameters.setRequestID(requestID); + policyParameters.setRiskLevel(riskLevel); + policyParameters.setRiskType(riskType); + policyParameters.setGuard(Boolean.parseBoolean(guard)); + try { + policyParameters.setTtlDate(new SimpleDateFormat("dd-MM-yyyy").parse(ttlDate)); + } catch (NullPointerException | ParseException e) { + LOGGER.warn("Error Parsing date given " + ttlDate); + policyParameters.setTtlDate(null); + } + return createUpdatePolicyImpl(policyParameters, updateFlag).getResponseMessage(); + } + + public void setClientKey(String clientKey){ + if(clientKey!=null && !clientKey.isEmpty()){ + StdPolicyEngine.pass = clientKey; + setClientEncoding(); + } + } + /* + * Get the Environment. + */ + public static String getEnvironment() { + return environment; + } + /* + * Rotate the PDP list upon WEBsocket Failures + */ + public static void rotatePDPList() { + Collections.rotate(pdps, -1); + Collections.rotate(encoding, -1); + } + /* + * Get the latest PDP + */ + public static String getPDPURL() { + return pdps.get(0); + } +} \ No newline at end of file diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyResponse.java new file mode 100644 index 000000000..3ab57f2be --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyResponse.java @@ -0,0 +1,98 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + +package org.onap.policy.std; + +import java.util.Map; + +import org.onap.policy.api.PolicyResponse; +import org.onap.policy.api.PolicyResponseStatus; + +/** + * PolicyResponse Implementation class. + * + * @version 0.1 + * + */ +public class StdPolicyResponse implements PolicyResponse{ + private PolicyResponseStatus policyResponseStatus; + private Map actionAdvised; + private Map actionTaken; + private Map requestAttributes; + private String policyResponseMessage; + + @Override + public PolicyResponseStatus getPolicyResponseStatus() { + return policyResponseStatus; + } + + @Override + public Map getActionAdvised() { + return actionAdvised; + } + + @Override + public Map getActionTaken() { + return actionTaken; + } + + @Override + public Map getRequestAttributes() { + return requestAttributes; + } + + @Override + public String getPolicyResponseMessage() { + return policyResponseMessage; + } + + public void setPolicyResponseStatus(PolicyResponseStatus policyResponseStatus) { + this.policyResponseStatus = policyResponseStatus; + } + + public void setActionAdvised(Map actionAdvised) { + this.actionAdvised = actionAdvised; + } + + public void setActionTaken(Map actionTaken) { + this.actionTaken = actionTaken; + } + + public void setRequestAttributes(Map requestAttributes) { + this.requestAttributes = requestAttributes; + } + + public void setPolicyResponseMessage(String policyResponseMessage) { + this.policyResponseMessage = policyResponseMessage; + } + + public void setPolicyResponseStatus(String policyResponseMessage, PolicyResponseStatus policyResponseStatus) { + this.policyResponseMessage = policyResponseMessage; + this.policyResponseStatus = policyResponseStatus; + } + + @Override + public String toString() { + return "PolicyResponse [ policyResponseStatus=" + policyResponseStatus + ", policyResponseMessage=" + policyResponseMessage + ", " + + "" + + "]"; + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdStatus.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdStatus.java new file mode 100644 index 000000000..798cbde37 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdStatus.java @@ -0,0 +1,235 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + +package org.onap.policy.std; + +import java.util.Map; +import java.util.Properties; + +import javax.json.JsonObject; + +import org.onap.policy.api.DecisionResponse; +import org.onap.policy.api.PolicyConfig; +import org.onap.policy.api.PolicyConfigStatus; +import org.onap.policy.api.PolicyDecision; +import org.onap.policy.api.PolicyResponse; +import org.onap.policy.api.PolicyResponseStatus; +import org.onap.policy.api.PolicyType; +import org.w3c.dom.Document; + +public class StdStatus extends StdPolicyResponse implements PolicyConfig, PolicyResponse, DecisionResponse{ + private PolicyType policyType; + private Properties properties; + private JsonObject jsonObject; + private Document document; + private String other; + private PolicyConfigStatus policyConfigStatus; + private String configStatus; + private PolicyResponseStatus policyResponseStatus; + private Map actionAdvised; + private Map actionTaken; + private Map requestAttributes; + private String policyResponseMessage; + private String policyName; + private String policyVersion; + private Map matchingConditions; + private Map responseAttributes; + private PolicyDecision policyDecision; + private String details; + + public void setStatus(String message, PolicyResponseStatus policyResponseStatus, PolicyConfigStatus policyConfigStatus) { + this.configStatus = message; + this.policyResponseMessage = message; + this.policyResponseStatus = policyResponseStatus; + this.policyConfigStatus = policyConfigStatus; + } + @Override + public PolicyResponseStatus getPolicyResponseStatus() { + return policyResponseStatus; + } + + @Override + public Map getActionAdvised() { + return actionAdvised; + } + + @Override + public Map getActionTaken() { + return actionTaken; + } + + @Override + public Map getRequestAttributes() { + return requestAttributes; + } + + @Override + public String getPolicyResponseMessage() { + return policyResponseMessage; + } + + public void setPolicyResponseStatus(PolicyResponseStatus policyResponseStatus) { + this.policyResponseStatus = policyResponseStatus; + } + + public void setActionAdvised(Map actionAdvised) { + this.actionAdvised = actionAdvised; + } + + public void setActionTaken(Map actionTaken) { + this.actionTaken = actionTaken; + } + + public void setRequestAttributes(Map requestAttributes) { + this.requestAttributes = requestAttributes; + } + + public void setPolicyResponseMessage(String policyResponseMessage) { + this.policyResponseMessage = policyResponseMessage; + } + + public void setPolicyResponseStatus(String policyResponseMessage, PolicyResponseStatus policyResponseStatus) { + this.policyResponseMessage = policyResponseMessage; + this.policyResponseStatus = policyResponseStatus; + } + + @Override + public PolicyType getType() { + return policyType; + } + + @Override + public Properties toProperties() { + return properties; + } + + @Override + public JsonObject toJSON() { + return jsonObject; + } + + @Override + public Document toXML() { + return document; + } + + @Override + public PolicyConfigStatus getPolicyConfigStatus() { + return policyConfigStatus; + } + + @Override + public String getPolicyConfigMessage() { + return configStatus; + } + + @Override + public String getPolicyName() { + if(policyName!=null && policyName.contains(".xml")){ + return (policyName.substring(0, policyName.substring(0, policyName.lastIndexOf(".")).lastIndexOf("."))); + } + return policyName; + } + + @Override + public String getPolicyVersion() { + return policyVersion; + } + + @Override + public Map getMatchingConditions(){ + return matchingConditions; + } + + @Override + public Map getResponseAttributes(){ + return responseAttributes; + } + + public void setPolicyType(PolicyType policyType) { + this.policyType = policyType; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } + + public void setJsonObject(JsonObject jsonObject) { + this.jsonObject = jsonObject; + } + + public void setDocument(Document document) { + this.document = document; + } + + public void setConfigStatus(String configStatus) { + this.configStatus = configStatus; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + public void setPolicyVersion(String policyVersion) { + this.policyVersion = policyVersion; + } + + public void setMatchingConditions(Map matchingConditions){ + this.matchingConditions = matchingConditions; + } + + public void setResposneAttributes(Map responseAttributes){ + this.responseAttributes = responseAttributes; + } + + public void setPolicyConfigStatus(PolicyConfigStatus policyConfigStatus) { + this.policyConfigStatus = policyConfigStatus; + } + + public void setPolicyConfigStatus(String configStatus, PolicyConfigStatus policyConfigStatus) { + this.policyConfigStatus = policyConfigStatus; + this.configStatus = configStatus; + } + + @Override + public String toOther() { + return other; + } + + public void setOther(String other) { + this.other = other; + } + + public PolicyDecision getDecision() { + return policyDecision; + } + public void setDecision(PolicyDecision policyDecision) { + this.policyDecision = policyDecision; + } + + public void setDetails(String details){ + this.details = details; + } + + public String getDetails(){ + return details; + } +} diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/package-info.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/package-info.java new file mode 100644 index 000000000..5d6bbcb92 --- /dev/null +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/package-info.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std; +/** + * Provides standard implementations of the interfaces from the {@link org.onap.policy.api} package. + * + * @version 0.3 + * + */ diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/AttributeType.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/AttributeType.java deleted file mode 100644 index 44cf441ca..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/AttributeType.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import com.fasterxml.jackson.annotation.JsonCreator; - -/** - * Enumeration of the Attribute Types that is used as a part of - * {@link org.openecomp.policy.api.PolicyParameters}. - * - * @version 0.1 - */ -public enum AttributeType { - /** - * Indicates Attributes required to Match the Policy. - */ - MATCHING("matching"), - /** - * Indicates Attributes required to create DRL based Rules. - */ - RULE("rule"), - /** - * Indicates Attributes required to create MicroService policy. - */ - MICROSERVICE("microService"), - /** - * Indicates Attributes required to create settings for Decision Policy. - */ - SETTINGS("settings"), - /** - * Indicates Attributes required to create dictionary fields for creating Dictionary Items - */ - DICTIONARY("dictionary") - ; - - - private String name; - - private AttributeType(String typeName){ - this.name = typeName; - } - - /** - * Returns the String format of Type for this AttributeType - * @return the String of the Type for this AttributeType - */ - public String toString() { - return this.name; - } - - @JsonCreator - public static AttributeType create (String value) { - for(AttributeType type: values()){ - if(type.toString().equalsIgnoreCase(value)){ - return type; - } - } - throw new IllegalArgumentException(); - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ConfigRequestParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ConfigRequestParameters.java deleted file mode 100644 index 1830679e0..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ConfigRequestParameters.java +++ /dev/null @@ -1,148 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import java.util.Map; -import java.util.UUID; - -/** - * ConfigRequestParameters defines the Config Policy Request Parameters - * which retrieve(s) the policy from PDP if the request parameters match with any Config Policy. - * - * @version 0.1 - */ -public class ConfigRequestParameters { - private String policyName; - private String eCOMPComponentName; - private String configName; - private Map configAttributes; - private UUID requestID; - private Boolean unique = false; - - /** - * Sets the PolicyName of the Config policy which needs to be retrieved. - * - * @param policyName the String format of the PolicyFile Name whose configuration is required. - */ - public void setPolicyName(String policyName){ - this.policyName = policyName; - } - - /** - * Sets the ECOMP Component Name of the Config policy which needs to be retrieved. - * - * @param eCOMPComponentName the String format of the eCOMPComponentName whose configuration is required. - */ - public void setEcompName(String eCOMPComponentName){ - this.eCOMPComponentName = eCOMPComponentName; - } - - /** - * Sets the Config Name of the Config policy which needs to be retrieved. - * - * @param configName the String format of the configurationName whose configuration is required. - */ - public void setConfigName(String configName){ - this.configName = configName; - } - - /** - * Sets the ConfigAttributes of the Config policy which needs to be retrieved. - * - * @param configAttributes the Map of String,String format of the configuration attributes which are required. - */ - public void setConfigAttributes(Map configAttributes){ - this.configAttributes = configAttributes; - } - - /** - * Sets the Request ID of the ECOMP request. - * - * @param requestID unique UUID requestID which will be passed throughout the ECOMP components to correlate logging messages. - */ - public void setRequestID(UUID requestID){ - this.requestID = requestID; - } - - /** - * Gets the policyName of the Request Parameters. - * - * @return String format of the policyName. - */ - public String getPolicyName(){ - return policyName; - } - - /** - * Gets the ECOMP Component Name of the Request Parameters. - * - * @return String format of the ECOMP Component Name. - */ - public String getEcompName(){ - return eCOMPComponentName; - } - - /** - * Gets the Config name of the Request Parameters. - * - * @return String format of the Config Name. - */ - public String getConfigName(){ - return configName; - } - - /** - * Gets the Config Attributes of the Request Parameters. - * - * @return Map of String,String format of the config Attributes. - */ - public Map getConfigAttributes(){ - return configAttributes; - } - - /** - * Gets the Request ID of the Request Paramters. - * - * @return UUID format of requestID. - */ - public UUID getRequestID(){ - return requestID; - } - - /** - * Makes the results Unique, priority based. If set to True. Default Value is set to False. - * - * @param unique flag which is either true or false. - */ - public void makeUnique(Boolean unique){ - this.unique = unique; - } - - /** - * Gets the Unique flag value from the Config Request Parameters. - * - * @return unique flag which is either true or false. - */ - public Boolean getUnique(){ - return this.unique; - } - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionRequestParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionRequestParameters.java deleted file mode 100644 index dc485f7b3..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionRequestParameters.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import java.util.Map; -import java.util.UUID; - -/** - * DecisionRequestParameters defines the Decision Policy Request Parameters - * which retrieve(s) the response from PDP if the request parameters match with any Decision Policy. - * - * @version 0.1 - */ -public class DecisionRequestParameters { - private String eCOMPComponentName; - private Map decisionAttributes; - private UUID requestID; - - /** - * Constructor with no Parameters - */ - public DecisionRequestParameters(){ - } - - /** - * Constructor with Parameters - * - * @param eCOMPComponentName the String format of the eCOMPComponentName whose Decision is required. - * @param decisionAttributes the Map of String,String format of the decisionAttributes that contain the ID and values. - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - */ - public DecisionRequestParameters(String eCOMPComponentName, Map decisionAttributes, UUID requestID){ - this.eCOMPComponentName = eCOMPComponentName; - this.decisionAttributes = decisionAttributes; - this.requestID = requestID; - } - - /** - * Gets the ECOMPComponentName of the Decision Request Parameters. - * - * @return ECOMPComponentName the String format of the eCOMPComponentName of the Decision Request Parameters. - */ - public String getECOMPComponentName() { - return eCOMPComponentName; - } - /** - * Sets the ECOMPComponentName of the Decision Request parameters. - * - * @param eCOMPComponentName the String format of the eCOMPComponentName whose Decision is required. - */ - public void setECOMPComponentName(String eCOMPComponentName) { - this.eCOMPComponentName = eCOMPComponentName; - } - /** - * Gets the Decision Attributes from Decision Request Parameters. - * - * @return decisionAttributes the Map of String,String format of the decisionAttributes that contain the ID and values. - */ - public Map getDecisionAttributes() { - return decisionAttributes; - } - /** - * Sets the Decision Attributes which contain ID and values for obtaining Decision from PDP. - * - * @param decisionAttributes the Map of String,String format of the decisionAttributes that must contain the ID and values. - */ - public void setDecisionAttributes(Map decisionAttributes) { - this.decisionAttributes = decisionAttributes; - } - /** - * Gets the request ID of Decision Request Parameters. - * - * @return the requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - */ - public UUID getRequestID() { - return requestID; - } - /** - * Sets the ReqestID of Decision Request Parameters which will be passed around ECOMP requests. - * - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - */ - public void setRequestID(UUID requestID) { - this.requestID = requestID; - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionResponse.java deleted file mode 100644 index caa9fda74..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionResponse.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -/** - * Defines the Object that represents the Policy Decision Response elements. - * DecisionResponse communicates the decision and details - * - * @version 0.1 - */ -public interface DecisionResponse { - /** - * Gets the Decision of the Policy, Either a Permit or Deny. - * - * @return {@link org.openecomp.policy.api.PolicyDecision} Enumeration. - */ - public PolicyDecision getDecision(); - - /** - * Gets the details of the result. Would be required in case of Deny. - * - * @return String format of the details of Deny cause. - */ - public String getDetails(); -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyCondition.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyCondition.java deleted file mode 100644 index 4ef348c7d..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyCondition.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import com.fasterxml.jackson.annotation.JsonCreator; - -/** - * Enumeration of the Policy Delete Condition that is used as a part of - * {@link org.openecomp.policy.api.DeletePolicyParameters}. - * - * @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; - } - - /** - * Returns the String format of delete condition for this Policy - * @return the String of the delete condition for this Policy - */ - public String toString(){ - return this.name; - } - - @JsonCreator - public static DeletePolicyCondition create (String value) { - for(DeletePolicyCondition type: values()){ - if(type.toString().equals(value) || type.equals(DeletePolicyCondition.valueOf(value))){ - return type; - } - } - throw new IllegalArgumentException(); - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyParameters.java deleted file mode 100644 index 3121297e1..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyParameters.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import java.util.UUID; - -/** - * PushPolicyParameters defines the Policy Parameters - * which are required to Push a Policy to PDPGroup. - * - * @version 0.1 - */ -public class DeletePolicyParameters { - - private String policyName; - private String policyType; - private String policyComponent; - private DeletePolicyCondition deleteCondition; - private String pdpGroup; - private UUID requestID; - - - /** - * @return the policyName - */ - public String getPolicyName() { - return policyName; - } - /** - * @param policyName the policyName to set - */ - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - /** - * @return the policyComponent - */ - public String getPolicyComponent() { - return policyComponent; - } - /** - * @return the policyType - */ - public String getPolicyType() { - return policyType; - } - /** - * @param policyType the policyType to set - */ - public void setPolicyType(String policyType) { - this.policyType = policyType; - } - /** - * @param policyComponent the policyComponent to set - */ - public void setPolicyComponent(String policyComponent) { - this.policyComponent = policyComponent; - } - /** - * @return the deleteCondition - */ - public DeletePolicyCondition getDeleteCondition() { - return deleteCondition; - } - /** - * @param deleteCondition the deleteCondition to set - */ - public void setDeleteCondition(DeletePolicyCondition deleteCondition) { - this.deleteCondition = deleteCondition; - } - /** - * @return the requestID - */ - public UUID getRequestID() { - return requestID; - } - /** - * @param requestID the requestID to set - */ - public void setRequestID(UUID requestID) { - this.requestID = requestID; - } - /** - * @return the pdpGroup - */ - public String getPdpGroup() { - return pdpGroup; - } - /** - * @param pdpGroup the pdpGroup to set - */ - public void setPdpGroup(String pdpGroup) { - this.pdpGroup = pdpGroup; - } - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryParameters.java deleted file mode 100644 index cf70caf07..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryParameters.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import java.util.UUID; - -public class DictionaryParameters { - - private DictionaryType dictionaryType; - private String dictionary; - private String dictionaryJson; - private UUID requestID; - - - /** - * @return the dictionaryType - */ - public DictionaryType getDictionaryType() { - return dictionaryType; - } - /** - * @param dictionaryType the dictionaryType to set - */ - public void setDictionaryType(DictionaryType dictionaryType) { - this.dictionaryType = dictionaryType; - } - /** - * @return the dictionary - */ - public String getDictionary() { - return dictionary; - } - /** - * @param dictionary the dictionary to set - */ - public void setDictionary(String dictionary) { - this.dictionary = dictionary; - } - /** - * @return the dictionaryFields - */ - public String getDictionaryJson() { - return dictionaryJson; - } - /** - * @param dictionaryFields the dictionaryFields to set - */ - public void setDictionaryJson(String dictionaryJson) { - this.dictionaryJson = dictionaryJson; - } - /** - * @return the requestID - */ - public UUID getRequestID() { - return requestID; - } - /** - * @param requestID the requestID to set - */ - public void setRequestID(UUID requestID) { - this.requestID = requestID; - } - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryResponse.java deleted file mode 100644 index dd7379871..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryResponse.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.openecomp.policy.api; - -import java.util.Map; - -import javax.json.JsonObject; - -public interface DictionaryResponse { - - /** - * Gets the String of the DictionaryItemsMessage from DictionaryResponse. - * - * @return the String which consists of DictionaryItemsMessage from DictionaryResponse - */ - public String getResponseMessage(); - - /** - * Response code of type Integer which corresponds to the HTTP Response code explaining the response from Policy Engine. - * - * @return the responseCode in Integer format corresponding to the HTTP response code from Policy Engine. - */ - public int getResponseCode(); - - - /** - * Gets the JsonObject of all the Dictionary data retrieved - * - * @return the JsonObject which consists of Dictionary data which has been retrieved. - */ - public JsonObject getDictionaryJson(); - - - /** - * Gets the Key and Value pairs for each Dictionary item retrieved which can be used in the getDictionaryItems call. - * - * @return Map of String, String which consists of the Key and Value pairs for each Dictionary item retrieved. - */ - public Map getDictionaryData(); - - - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryType.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryType.java deleted file mode 100644 index 823a56ba9..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryType.java +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.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 String format of Type for this PolicyClass - * @return the String of the Type for this PolicyClass - */ - 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))){ - return type; - } - } - throw new IllegalArgumentException(); - } - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/EventRequestParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/EventRequestParameters.java deleted file mode 100644 index 155d9c6a5..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/EventRequestParameters.java +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import java.util.Map; -import java.util.UUID; - -/** - * EventRequestParameters defines the Event Policy Request Parameters - * which retrieve(s) the response from PDP if the request parameters match with any Action Policy. - * - * @version 0.1 - */ -public class EventRequestParameters { - private Map eventAttributes; - private UUID requestID; - - /** - * Constructor with no Parameters - */ - public EventRequestParameters(){ - } - - /** - * Constructor with Parameters - * - * @param eventAttributes the Map of String,String format of the eventAttributes that contains the event ID and values. - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - */ - public EventRequestParameters(Map eventAttributes, UUID requestID){ - this.eventAttributes = eventAttributes; - this.requestID = requestID; - } - - /** - * Gets the eventAttributes of Event Request Parameters. - * - * @return eventAttributes the Map of String,String format of the eventAttributes that contains the event ID and values. - */ - public Map getEventAttributes() { - return eventAttributes; - } - - /** - * Sets the eventAttributes that contain the eventID and values to the Event Request Parameters. - * - * @param eventAttributes the Map of String,String format of the eventAttributes that must contain the event ID and values. - */ - public void setEventAttributes(Map eventAttributes) { - this.eventAttributes = eventAttributes; - } - - /** - * Gets the ReqestID of Event Request Parameters which will be passed around ECOMP requests. - * - * @return requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - */ - public UUID getRequestID() { - return requestID; - } - - /** - * Sets the ReqestID of Event Request Parameters which will be passed around ECOMP requests. - * - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - */ - public void setRequestID(UUID requestID) { - this.requestID = requestID; - } - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ImportParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ImportParameters.java deleted file mode 100644 index 882379397..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ImportParameters.java +++ /dev/null @@ -1,175 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import java.util.UUID; - - -/** - * ImportParameters defines the Policy Engine Import Parameters - * which are required to import a new Policy Service or Value. - * - * @version 0.1 - */ -public class ImportParameters { - private String serviceName; - private String description; - private UUID requestID; - private String filePath; - private String version; - private IMPORT_TYPE importType; - - public enum IMPORT_TYPE { - MICROSERVICE, - BRMSPARAM - } - - /** - * Sets Import Policy Parameters. - * - * @param serviceName the String format of the Service Name - * @param description the String format of the i Description - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - * @param filePath the List format of the file paths for the service files - * @param importType the {@link IMPORT_TYPE} format of the Policy Service List - * @param version the String format of the Policy Import Version - * A different request ID should be passed for each request. - */ - public void setImportParameters(String serviceName, String description, UUID requestID, String filePath, IMPORT_TYPE importType, String version){ - - this.setServiceName(serviceName); - this.setDescription(description); - this.setRequestID(requestID); - this.setFilePath(filePath); - this.setServiceType(importType); - this.setVersion(version); - - } - - /** - * Gets the Policy Service of the Policy Service Import Parameters. - * - * @return serviceName the String format of the Policy Service Name - */ - public String getServiceName() { - return serviceName; - } - - /** - * Sets the serviceName of the Policy Service Parameters. - * - * @param serviceName the String format of the Policy Service Name - */ - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } - - /** - * Gets the Policy Import Description. - * - * @return description the String format of the Policy Import Description - */ - public String getDescription() { - return description; - } - - /** - * Sets the Description of the new Policy Import Description. - * - * @param description the String format of the Policy Import Description - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * Gets the requestID of the Policy Parameters. - * - * @return unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - */ - public UUID getRequestID() { - return requestID; - } - - /** - * Sets the requestID of the Policy Parameters. - * - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - */ - public void setRequestID(UUID requestID) { - this.requestID = requestID; - } - - /** - * Gets the List of File Paths of the new import. - * - * @return filePath the List format of the Policy Import File - */ - public String getFilePath() { - return filePath; - } - - /** - * Sets the policy Import File List of the new Policy Import. - * - * @param filePath the List format of the Policy Import File - */ - public void setFilePath(String filePath) { - this.filePath = filePath; - } - - /** - * Gets the Service Type of the new policy import. - * - * @return ImportType {@link IMPORT_TYPE} format of the Policy Service List - */ - public IMPORT_TYPE getServiceType() { - return importType; - } - - /** - * Sets the policy Service Type of the new Policy Service. - * - * @param enumImportType the enumServiceType format of the Policy Service List - */ - public void setServiceType(IMPORT_TYPE enumImportType) { - this.importType = enumImportType; - } - - /** - * - * Gets the Import Version of the new policy import. - * - * @return version the String format of the Policy Import Version - */ - public String getVersion() { - return version; - } - - /** - * Sets the policy Import Version of the new Policy Import. - * - * @param version the String format of the Policy Import Version - */ - public void setVersion(String version) { - this.version = version; - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/MetricsRequestParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/MetricsRequestParameters.java deleted file mode 100644 index 4c10f391f..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/MetricsRequestParameters.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.openecomp.policy.api; - -import java.util.UUID; - -public class MetricsRequestParameters { - private UUID requestID; - - /** - * @return the requestID - */ - public UUID getRequestID() { - return requestID; - } - /** - * @param requestID the requestID to set - */ - public void setRequestID(UUID requestID) { - this.requestID = requestID; - } - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/MetricsResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/MetricsResponse.java deleted file mode 100644 index d96a6dc9c..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/MetricsResponse.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.openecomp.policy.api; - -public interface MetricsResponse { - - /** - * Gets the String of the metrics message from MetricsResponse. - * - * @return the String which consists of the metrics message from MetricsResponse - */ - public String getResponseMessage(); - - /** - * Gets the response code of type Integer which corresponds to the HTTP Response code explaining the response from Policy Engine. - * - * @return the responseCode in Integer format corresponding to the HTTP response code from Policy Engine. - */ - public int getResponseCode(); - - - /** - * Gets the Integer value of the count of policies that reside on the PAP. - * - * @return the Integer which consists of count of policies that reside on the PAP. - */ - public int getPapMetrics(); - - - /** - * Gets the Integer value of the count of policies that reside on the PDP. - * - * @return the Integer which consists of count of policies that reside on the PDP. - */ - public int getPdpMetrics(); - - - /** - * Gets the Integer value of the total count of policies. - * - * @return the Integer which consists of the total count of policies. - */ - public int getMetricsTotal(); - - - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/NotificationScheme.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/NotificationScheme.java deleted file mode 100644 index 2e88d9c38..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/NotificationScheme.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -/** - * Enumeration of NotificationScheme describes the Notification Scheme that will be used by the PolicyEngine. - * - * @version 0.1 - */ -public enum NotificationScheme { - /** - * Notifications for policyUpdates on policy Configs already retrieved - */ - AUTO_NOTIFICATIONS("auto_notifications"), - /** - * Subscribing to all notifications from the PDP - */ - AUTO_ALL_NOTIFICATIONS("auto_all_notifications"), - /** - * Client can poll for updates that receive policyUpdates on policy Configs that have already been retrieved - */ - MANUAL_NOTIFICATIONS("manual_notifications"), - /** - * Client can poll for updates that receive all notifications from the PDP - */ - MANUAL_ALL_NOTIFICATIONS("manual_all_notifications") - ; - - private String name; - private NotificationScheme(String name){ - this.name = name; - } - - /** - * Returns the String name for this NotificationScheme - * - * @return the String name for this NotificationScheme - */ - @Override - public String toString(){ - return this.name; - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyChangeResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyChangeResponse.java deleted file mode 100644 index 98bfdc2e3..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyChangeResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -/** - * PolicyChangeResponse defines the Policy Response - * which is Contains responseCode corresponding to HTTP response Codes with response Message. - * - * @version 0.1 - */ -public interface PolicyChangeResponse { - - /** - * Policy Change Response Message in String format from the Policy Engine. - * - * @return the responseMessage in String format related to Response from Policy Engine. - */ - public String getResponseMessage(); - - /** - * Response code of type Integer which corresponds to the HTTP Response code explaining the response from Policy Engine. - * - * @return the responseCode in Integer format corresponding to the HTTP response code from Policy Engine. - */ - public int getResponseCode(); -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyClass.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyClass.java deleted file mode 100644 index 8b87f408b..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyClass.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import com.fasterxml.jackson.annotation.JsonCreator; - -/** - * Enumeration of the Policy Types that is used as a part of - * {@link org.openecomp.policy.api.PolicyParameters}. - * - * @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 String format of Type for this PolicyClass - * @return the String of the Type for this PolicyClass - */ - 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))){ - return type; - } - } - throw new IllegalArgumentException(); - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfig.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfig.java deleted file mode 100644 index 5cb7d8176..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfig.java +++ /dev/null @@ -1,123 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import java.util.Map; -import java.util.Properties; - -import javax.json.JsonObject; - -import org.w3c.dom.Document; -/** - * Defines the objects that represent PolicyEngine config elements. PolicyConfig communicates the PolicyConfigStatus, - * PolicyConfigMessage, PolicyType, Properties, JsonObject, String and Document. - * - * @version 0.7 - */ - -public interface PolicyConfig { - /** - * Gets the {@link org.openecomp.policy.api.PolicyType} associated with PolicyConfig - * - * @return the PolicyType associated with this PolicyConfig - */ - public PolicyType getType(); - - /** - * Gives the Properties response associated with the PolicyConfig - * - * @return the Properties associated with this PolicyConfig - */ - public Properties toProperties(); - - /** - * Gives the JsonObject response associated with the PolicyConfig - * - * @return the JsonObject result associated with PolicyConfig - */ - public JsonObject toJSON(); - - /** - * Gives the XML Document result associated with PolicyConfig - * - * @return the Document result associated with PolicyConfig - */ - public Document toXML(); - - /** - * Gives the Other String response associated with PolicyConfig - * - * @return the String result associated with PolicyConfig - */ - public String toOther(); - - /** - * Gets the {@link org.openecomp.policy.api.PolicyConfigStatus} associated with this PolicyConfig. - * - * @return the PolicyConfigStatus associated with this PolicyConfig - */ - public PolicyConfigStatus getPolicyConfigStatus(); - - /** - * Gets the String of the PolicyConfigMessage from PolicyConfig. - * - * @return the String which consists of PolicyConfigMessage from PolicyConfig - */ - public String getPolicyConfigMessage(); - - /** - * Gets the String of the PolicyName retrieved. - * - * @return the String which consists of Policy Name which has been retrieved. - */ - public String getPolicyName(); - - - /** - * Gets the String of the PolicyVersion retrieved. - * - * @return the String which consists of the Policy Version number which has been retrieved. - */ - public String getPolicyVersion(); - - /** - * Gets the Matching Conditions of the policy retrieved which can be used in the getConfig call. - * - * @return Map of String, String which consists of the Matching conditions of the Policy retrieved. - */ - public Map getMatchingConditions(); - - /** - * Gets the Response Attributes of the policy retrieved. Which can hold additional information about the policy retrieved. - * - * @return Map of String, String which consists of the Response Attributes of the Policy retrieved. - */ - public Map getResponseAttributes(); - - /** - * Returns the String version of the PolicyConfig object. - * - * @return String of the PolicyConfig Object. - */ - @Override - public String toString(); - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigException.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigException.java deleted file mode 100644 index ad6948e77..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigException.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -/** - * PolicyConfigException extends Exception to implement exceptions thrown by {@link org.openecomp.policy.api.PolicyEngine} - * - * @version 0.1 - */ -public class PolicyConfigException extends Exception{ - private static final long serialVersionUID = -188355220060684215L; - - public PolicyConfigException() { - } - - public PolicyConfigException(String message) { - super(message); - } - - public PolicyConfigException(Throwable cause){ - super(cause); - } - - public PolicyConfigException(String message, Throwable cause) { - super(message, cause); - } - - public PolicyConfigException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigStatus.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigStatus.java deleted file mode 100644 index 95d890de8..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigStatus.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import com.fasterxml.jackson.annotation.JsonCreator; - -/** - * Enumeration of PolicyConfigStatus that can be returned as a part of - * {@link org.openecomp.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 PolicyConfigStatus based on String representation of PolicyConfig - * - * @param configStatus the String Configuration Status - * @return the PolicyConfigResponse with the name matching CONFIG_RETRIEVED or CONFIG_NOT_FOUND - * if no match is found - */ - public static PolicyConfigStatus getStatus(String configStatus) { - if(configStatus.equalsIgnoreCase("retrieved")) { - return CONFIG_RETRIEVED; - }else { - return CONFIG_NOT_FOUND; - } - } - - /** - * Returns the String name for this PolicyConfigStatus - * - * @return the String name for this PolicyConfigStatus - */ - 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))){ - return type; - } - } - throw new IllegalArgumentException(); - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigType.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigType.java deleted file mode 100644 index 028696462..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigType.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import com.fasterxml.jackson.annotation.JsonCreator; - -/** - * Enumeration of the Policy Config Types that is used as a part of - * {@link org.openecomp.policy.api.PolicyParameters}. - * - * @version 0.1 - */ -public enum PolicyConfigType{ - /** - * Indicates Base Config Policy. - */ - Base("Base"), - /** - * Indicates ClosedLoop Fault Policy. - */ - ClosedLoop_Fault("Fault"), - /** - * Indicates ClosedLoop Performance Metrics Policy. - */ - ClosedLoop_PM("PM"), - /** - * Indicates Firewall Config Policy. - */ - Firewall("FW"), - /** - * Indicates BRMS based raw DRL Rule Policy. - */ - BRMS_RAW("BRMS_Raw"), - /** - * Indicates BRMS based Param DRL policy. - */ - BRMS_PARAM("BRMS_Param"), - /** - * Indicates DCAE Micro Service based Policy. - */ - MicroService("MS"), - - Extended("EXTENDED") - ; - - private String name; - - private PolicyConfigType(String name){ - this.name = name; - } - - /** - * Returns the String format of Type for this PolicyClass - * @return the String of the Type for this PolicyClass - */ - public String toString() { - return name; - } - - @JsonCreator - public static PolicyConfigType create (String value) { - for(PolicyConfigType type: values()){ - if(type.toString().equals(value) || type.equals(PolicyConfigType.valueOf(value))){ - return type; - } - } - throw new IllegalArgumentException(); - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecision.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecision.java deleted file mode 100644 index a6b4bd2b4..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecision.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import com.fasterxml.jackson.annotation.JsonCreator; - -/** - * Enumeration of PolicyDecision that can be returned as a part of - * {@link org.openecomp.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 String name for this PolicyDecision - * - * @return the String name for this PolicyDecision - */ - 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))){ - return type; - } - } - throw new IllegalArgumentException(); - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecisionException.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecisionException.java deleted file mode 100644 index 7f08fcb36..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecisionException.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -/** - * PolicyDecisionException extends Exception to implement exceptions thrown by {@link org.openecomp.policy.api.PolicyEngine} - * - * @version 0.1 - */ -public class PolicyDecisionException extends Exception { - - private static final long serialVersionUID = -2080072039363261175L; - - public PolicyDecisionException() { - } - - public PolicyDecisionException(String message) { - super(message); - } - - public PolicyDecisionException(Throwable cause){ - super(cause); - } - - public PolicyDecisionException(String message, Throwable cause) { - super(message, cause); - } - - public PolicyDecisionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngine.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngine.java deleted file mode 100644 index 4e2c092c1..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngine.java +++ /dev/null @@ -1,602 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import java.util.Collection; -import java.util.Map; -import java.util.UUID; - -import javax.json.JsonObject; - -import org.openecomp.policy.api.NotificationHandler; -import org.openecomp.policy.api.PDPNotification; -import org.openecomp.policy.std.StdPolicyEngine; - -/** - * PolicyEngine is the Interface that applications use to make policy queries against a PEPEngine - * - * @version 2.0 - */ -public class PolicyEngine{ - private String propertyFilePath = null; - private StdPolicyEngine stdPolicyEngine; - private NotificationScheme scheme = null; - private NotificationHandler handler = null; - - /** - * PolicyEngine Constructor with String format of propertiesFilePathname - * - * @param propertiesFilePathname the String format of the propertiesFilePathname - * @throws PolicyEngineException PolicyEngine Exception - */ - public PolicyEngine(String propertiesFilePathname) throws PolicyEngineException { - this.propertyFilePath = propertiesFilePathname ; - this.stdPolicyEngine= new StdPolicyEngine(this.propertyFilePath, (String)null); - } - - /** - * PolicyEngine Constructor with String format of propertiesFilePathname - * - * @param propertiesFilePathname the String format of the propertiesFilePathname - * @param clientKey depicts String format of Password/ Client_Key. - * @throws PolicyEngineException PolicyEngine Exception - */ - public PolicyEngine(String propertiesFilePathname, String clientKey) throws PolicyEngineException { - this.propertyFilePath = propertiesFilePathname ; - this.stdPolicyEngine= new StdPolicyEngine(this.propertyFilePath, clientKey); - } - - /** - * PolicyEngine Constructor with String format of PropertiesFilePathname and NotificationScheme - * - * @param propertiesFilePathname the String format of the propertiesFilePathname - * @param scheme the NotificationScheme of {@link org.openecomp.policy.api.NotificationScheme} which defines the Notification Scheme - * @throws PolicyEngineException PolicyEngine Exception - */ - public PolicyEngine(String propertiesFilePathname, NotificationScheme scheme) throws PolicyEngineException{ - this.propertyFilePath = propertiesFilePathname; - this.scheme = scheme; - this.stdPolicyEngine = new StdPolicyEngine(this.propertyFilePath, this.scheme); - } - - /** - * PolicyEngine Constructor with String format of PropertiesFilePathname, NotificationScheme and NotificationHandler - * - * @param propertiesFilePathname the String format of the propertiesFilePathname - * @param scheme the NotificationScheme of {@link org.openecomp.policy.api.NotificationScheme} which defines the Notification Scheme - * @param handler the NotificationHandler of {@link org.openecomp.policy.api.NotificationHandler} which defines what should happen when a notification is received. - * @throws PolicyEngineException PolicyEngine Exception - */ - public PolicyEngine(String propertiesFilePathname, NotificationScheme scheme, NotificationHandler handler) throws PolicyEngineException { - this.propertyFilePath = propertiesFilePathname ; - this.scheme = scheme; - this.handler = handler; - this.stdPolicyEngine= new StdPolicyEngine(this.propertyFilePath,this.scheme,this.handler); - } - - /** - * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the Policy File Name - * - * @param policyName the String format of the PolicyFile Name whose configuration is required. - * @return Collection of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters configRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfigByPolicyName(String policyName) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(policyName, null, null, null, null)); - } - - /** - * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the Policy File Name - * - * @param policyName the String format of the PolicyFile Name whose configuration is required. - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - * A different request ID should be passed for each request. - * @return Collection of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters configRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfigByPolicyName(String policyName, UUID requestID) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(policyName, null, null, null, requestID)); - } - - /** - * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the eCOMPComponentName - * - * @param eCOMPComponentName the String format of the eCOMPComponentName whose configuration is required. - * @return Collection of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfig(String eCOMPComponentName) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(null, eCOMPComponentName, null, null, null)); - } - - /** - * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the eCOMPComponentName - * - * @param eCOMPComponentName the String format of the eCOMPComponentName whose configuration is required. - * @return Collection of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration. - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - * A different request ID should be passed for each request. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfig(String eCOMPComponentName, UUID requestID) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(null, eCOMPComponentName, null, null, requestID)); - } - - /** - * Requests the configuration of the String which represents the eCOMPComponentName and String - * which represents the configName and returns the configuration if different Configurations exist for the - * particular eCOMPComponentName. - * - * @param eCOMPComponentName the String format of the eCOMPComponentName whose configuration is required. - * @param configName the String format of the configurationName whose configuration is required. - * @return Collection of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfig(String eCOMPComponentName, String configName) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(null, eCOMPComponentName, configName, null, null)); - } - - /** - * Requests the configuration of the String which represents the eCOMPComponentName and String - * which represents the configName and returns the configuration if different Configurations exist for the - * particular eCOMPComponentName. - * - * @param eCOMPComponentName the String format of the eCOMPComponentName whose configuration is required. - * @param configName the String format of the configurationName whose configuration is required. - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - * A different request ID should be passed for each request. - * @return Collection of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfig(String eCOMPComponentName, String configName, UUID requestID) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(null, eCOMPComponentName, configName, null, requestID)); - } - - /** - * Requests the configuration of the String which represents the eCOMPComponentName, String - * which represents the configName and Map of String,String which has the configAttribute and returns the specific - * configuration related to the configAttributes mentioned. - * - * @param eCOMPComponentName the String format of the eCOMPComponentName whose configuration is required. - * @param configName the String format of the configurationName whose configuration is required. - * @param configAttributes the Map of String,String format of the configuration attributes which are required. - * @return Collection of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfig(String eCOMPComponentName, String configName, Map configAttributes) throws PolicyConfigException{ - return getConfig(setConfigRequestParameters(null, eCOMPComponentName, configName, configAttributes, null)); - } - - /** - * Requests the configuration of the String which represents the eCOMPComponentName, String - * which represents the configName and Map of String,String which has the configAttribute and returns the specific - * configuration related to the configAttributes mentioned. - * - * @param eCOMPComponentName the String format of the eCOMPComponentName whose configuration is required. - * @param configName the String format of the configurationName whose configuration is required. - * @param configAttributes the Map of String,String format of the configuration attributes which are required. - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - * A different request ID should be passed for each request. - * @return Collection of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfig(String eCOMPComponentName, String configName, Map configAttributes, UUID requestID) throws PolicyConfigException{ - return getConfig(setConfigRequestParameters(null, eCOMPComponentName, configName, configAttributes, requestID)); - } - - /** - * Requests the configuration of the ConfigRequestParameters which represents the Config policy request parameters - * and returns the specific configuration related to the matching parameters. - * - * @param configRequestParameters {@link org.openecomp.policy.api.ConfigRequestParameters} which represents the Config policy request parameters. - * @return Collection of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - */ - public Collection getConfig(ConfigRequestParameters configRequestParameters) throws PolicyConfigException{ - return stdPolicyEngine.getConfig(configRequestParameters); - } - - /** - * Requests the list of policies based on the ConfigRequestParameters which represents the policy request parameters - * and returns the list of policies filtered by the parameters. - * - * @param configRequestParameters {@link org.openecomp.policy.api.ConfigRequestParameters} which represents the List Policy request parameters. - * @return Collection of String which returns the list of policies. - * @throws PolicyConfigException PolicyConfig Exception - */ - public Collection listConfig(ConfigRequestParameters listPolicyRequestParameters) throws PolicyConfigException{ - return stdPolicyEngine.listConfig(listPolicyRequestParameters); - } - - - /** - * Sends the Events specified to the PEP and returns back the PolicyResponse. - * - * @param eventAttributes the Map of String,String format of the eventAttributes that must contain the event ID and values. - * @return Collection of {@link org.openecomp.policy.api.PolicyResponse} which has the Response. - * @throws PolicyEventException PolicyEvent Exception - * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead. - */ - @Deprecated - public Collection sendEvent(Map eventAttributes) throws PolicyEventException { - return stdPolicyEngine.sendEvent(eventAttributes, (UUID) null); - } - - /** - * Sends the Events specified to the PEP and returns back the PolicyResponse. - * - * @param eventAttributes the Map of String,String format of the eventAttributes that must contain the event ID and values. - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - * A different request ID should be passed for each request. - * @return Collection of {@link org.openecomp.policy.api.PolicyResponse} which has the Response. - * @throws PolicyEventException PolicyEvent Exception - * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead. - */ - @Deprecated - public Collection sendEvent(Map eventAttributes, UUID requestID) throws PolicyEventException { - return stdPolicyEngine.sendEvent(eventAttributes, requestID); - } - - /** - * Sends the Events specified to the PEP and returns back the PolicyResponse. - * - * @param eventRequestParameters {@link org.openecomp.policy.api.EventRequestParameters} which represents the Event Request Parameters. - * @return Collection of {@link org.openecomp.policy.api.PolicyResponse} which has the Response. - * @throws PolicyEventException PolicyEvent Exception - */ - public Collection sendEvent(EventRequestParameters eventRequestParameters) throws PolicyEventException { - return stdPolicyEngine.sendEvent(eventRequestParameters); - } - - /** - * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. - * - * @param eCOMPComponentName the String format of the eCOMPComponentName whose Decision is required. - * @param decisionAttributes the Map of String,String format of the decisionAttributes that must contain the ID and values. - * @return {@link org.openecomp.policy.api.DecisionResponse} which has the Decision. - * @throws PolicyDecisionException PolicyDecision Exception - * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead. - */ - @Deprecated - public DecisionResponse getDecision(String eCOMPComponentName, Map decisionAttributes) throws PolicyDecisionException { - return stdPolicyEngine.getDecision(eCOMPComponentName, decisionAttributes, null); - } - - /** - * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. - * - * @param eCOMPComponentName the String format of the eCOMPComponentName whose Decision is required. - * @param decisionAttributes the Map of String,String format of the decisionAttributes that must contain the ID and values. - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - * A different request ID should be passed for each request. - * @return {@link org.openecomp.policy.api.DecisionResponse} which has the Decision. - * @throws PolicyDecisionException PolicyDecision Exception - * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead. - */ - @Deprecated - public DecisionResponse getDecision(String eCOMPComponentName, Map decisionAttributes, UUID requestID) throws PolicyDecisionException { - return stdPolicyEngine.getDecision(eCOMPComponentName, decisionAttributes, requestID); - } - - /** - * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. - * - * @param decisionRequestParameters {@link org.openecomp.policy.api.DecisionRequestParameters} which represents the Decision Request Parameters. - * @return {@link org.openecomp.policy.api.DecisionResponse} which has the Decision. - * @throws PolicyDecisionException PolicyDecision Exception - */ - public DecisionResponse getDecision(DecisionRequestParameters decisionRequestParameters) throws PolicyDecisionException { - return stdPolicyEngine.getDecision(decisionRequestParameters); - } - - /** - * Retrieves the count of policies on the PAP, PDP, and Policy Engine as a whole - * - * @param parameters {@link org.openecomp.policy.api.MetricsRequestParameters} which represents the Parameters required to get the Policy Metrics - * @return {@link org.openecomp.policy.api.MetricsResponse} which consists of the response related to getMetrics Request. - * @throws PolicyException PolicyException related to the operation - * - * */ - public MetricsResponse getMetrics(MetricsRequestParameters parameters) throws PolicyException { - return stdPolicyEngine.getMetrics(parameters); - } - - /** - * Creates a Config Policy based on given arguments - * @param policyName the String format of the Policy Name - * @param policyDescription the String format of the Policy Description - * @param ecompName the String format of the ECOMP Name - * @param configName the String format of the Config Name - * @param configAttributes the List the Map Attributes that must contain the key and value. - * @param configType the String format of the Config Type - * @param body the String format of the Policy Body - * @param policyScope the String value of the sub scope directory where the policy will be created and stored - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - * A different request ID should be passed for each request. - * @param riskLevel the String value of risk Level. - * @param riskType the String value of risk Type. - * @param guard the String value of guard. - * @param ttlDate the String value of time to live Date. - * @throws PolicyException PolicyException related to the operation. - * @return String format of response - * @deprecated use {@link #createPolicy(PolicyParameters)} Instead. - */ - @Deprecated - public String createConfigPolicy(String policyName, String policyDescription, String ecompName, String configName, - Map configAttributes, String configType, String body, String policyScope, UUID requestID, - String riskLevel, String riskType, String guard, String ttlDate) throws PolicyException { - return stdPolicyEngine.createUpdateConfigPolicy(policyName, policyDescription, ecompName, configName, - configAttributes, configType, body, policyScope, requestID, - riskLevel, riskType, guard, ttlDate, false); - } - - /** - * Creates a Config Policy based on given arguments - * @param policyName the String format of the Policy Name - * @param policyDescription the String format of the Policy Description - * @param ecompName the String format of the ECOMP Name - * @param configName the String format of the Config Name - * @param configAttributes the List the Map Attributes that must contain the key and value. - * @param configType the String format of the Config Type - * @param body the String format of the Policy Body - * @param policyScope the String value of the sub scope directory where the policy will be created and stored - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - * A different request ID should be passed for each request. - * @param riskLevel the String value of risk Level. - * @param riskType the String value of risk Type. - * @param guard the String value of guard. - * @param ttlDate the String value of time to live Date. - * @throws PolicyException PolicyException related to the operation. - * @return String format of response - * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead. - */ - @Deprecated - public String updateConfigPolicy(String policyName, String policyDescription, String ecompName, String configName, - Map configAttributes, String configType, String body, String policyScope, UUID requestID, - String riskLevel, String riskType, String guard, String ttlDate) throws PolicyException { - return stdPolicyEngine.createUpdateConfigPolicy(policyName, policyDescription, ecompName, configName, - configAttributes, configType, body, policyScope, requestID,riskLevel, riskType, guard, ttlDate, true); - } - - /** - * Creates a Config Firewall Policy based on given arguments - * @param policyName the String format of the Policy Name - * @param firewallJson the JsonObject representation of the Firewall Rules List - * @param policyScope the String value of the sub scope directory where the policy will be created and stored - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - * A different request ID should be passed for each request. - * @param riskLevel the String value of risk Level. - * @param riskType the String value of risk Type. - * @param guard the String value of guard. - * @param ttlDate the String value of time to live Date. - * @throws PolicyException PolicyException related to the operation. - * @return String format of response. - * @deprecated use {@link #createPolicy(PolicyParameters)} Instead. - */ - @Deprecated - public String createConfigFirewallPolicy(String policyName, JsonObject firewallJson, String policyScope, UUID requestID, - String riskLevel, String riskType, String guard, String ttlDate) throws PolicyException { - return stdPolicyEngine.createUpdateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID,riskLevel, - riskType, guard, ttlDate, false); - } - - /** - * Updates a Config Firewall Policy based on given arguments - * @param policyName the String format of the Policy Name - * @param firewallJson the JsonObject representation of the Firewall Rules List - * @param policyScope the String value of the sub scope directory where the policy will be created and stored - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - * A different request ID should be passed for each request. - * @param riskLevel the String value of risk Level. - * @param riskType the String value of risk Type. - * @param guard the String value of guard. - * @param ttlDate the String value of time to live Date. - * @throws PolicyException PolicyException related to the operation. - * @return String format of response. - * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead. - */ - @Deprecated - public String updateConfigFirewallPolicy(String policyName, JsonObject firewallJson, String policyScope, UUID requestID, - String riskLevel, String riskType, String guard, String ttlDate) throws PolicyException { - return stdPolicyEngine.createUpdateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID,riskLevel, riskType, guard, ttlDate, true); - } - - /** - * Retrieves Dictionary Items for a specified dictionary - * - * @param parameters {@link org.openecomp.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to create a Dictionary Item. - * @return {@link org.openecomp.policy.api.DictionaryResponse} which consists of the response related to create dictionary item Request. - * @throws PolicyException PolicyException related to the operation - * - * */ - public DictionaryResponse getDictionaryItem(DictionaryParameters parameters) throws PolicyException { - return stdPolicyEngine.getDictionaryItem(parameters); - } - - /** - * Creates a Dictionary Item based on given Dictionary Parameters - * - * @param parameters {@link org.openecomp.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to create a Dictionary Item. - * @return {@link org.openecomp.policy.api.PolicyChangeResponse} which consists of the response related to create dictionary item Request. - * @throws PolicyException PolicyException related to the operation. - */ - public PolicyChangeResponse createDictionaryItem(DictionaryParameters parameters) throws PolicyException { - return stdPolicyEngine.createDictionaryItem(parameters); - } - - /** - * Updates a Dictionary Item based on given Dictionary Parameters - * - * @param parameters {@link org.openecomp.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to update a Dictionary Item. - * @return {@link org.openecomp.policy.api.PolicyChangeResponse} which consists of the response related to update dictionary item Request. - * @throws PolicyException PolicyException related to the operation. - */ - public PolicyChangeResponse updateDictionaryItem(DictionaryParameters parameters) throws PolicyException { - return stdPolicyEngine.updateDictionaryItem(parameters); - } - - /** - * Creates a Policy based on given Policy Parameters. - * - * @param policyParameters {@link org.openecomp.policy.api.PolicyParameters} which represents the Policy Parameters required to create a Policy. - * @return {@link org.openecomp.policy.api.PolicyChangeResponse} which consists of the response related to create policy Request. - * @throws PolicyException PolicyException related to the operation. - */ - public PolicyChangeResponse createPolicy(PolicyParameters policyParameters) throws PolicyException { - return stdPolicyEngine.createPolicy(policyParameters); - } - - /** - * Update Policy based on given Policy Parameters. - * - * @param policyParameters {@link org.openecomp.policy.api.PolicyParameters} which represents the Policy Parameters required to update a Policy. - * @return {@link org.openecomp.policy.api.PolicyChangeResponse} which consists of the response related to create policy Request. - * @throws PolicyException PolicyException related to the operation. - */ - public PolicyChangeResponse updatePolicy(PolicyParameters policyParameters) throws PolicyException { - return stdPolicyEngine.updatePolicy(policyParameters); - } - - /** - * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used. - * - * @param policyScope the String value of the sub scope directory where the policy is located - * @param policyName the String format of the Policy Name being pushed. - * @param policyType the String format of the Policy Type which is being pushed. - * @param pdpGroup the String format of the PDP Group name to which the policy needs to be pushed to. - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - * @return String format of the response related to the push Policy Request. - * @throws PolicyException PolicyException related to the operation. - * @deprecated use {@link #pushPolicy(PushPolicyParameters)} instead. - */ - @Deprecated - public String pushPolicy(String policyScope, String policyName, String policyType, String pdpGroup, UUID requestID) throws PolicyException { - return stdPolicyEngine.pushPolicy(policyScope, policyName, policyType, pdpGroup, requestID); - } - - /** - * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used. - * - * @param pushPolicyParameters {@link org.openecomp.policy.api.PushPolicyParameters} which represents the Push Policy parameters required to push a policy. - * @return {@link org.openecomp.policy.api.PolicyChangeResponse} which consists of the response related to the push Policy Request. - * @throws PolicyException PolicyException related to the operation. - */ - public PolicyChangeResponse pushPolicy(PushPolicyParameters pushPolicyParameters) throws PolicyException { - return stdPolicyEngine.pushPolicy(pushPolicyParameters); - } - - /** - * Deletes the specified policy from the PAP or PDP. - * - * @param deletePolicyParameters {@link org.openecomp.policy.api.DeletePolicyParameters} which represents the Delete Policy parameters to delete a policy. - * @return {@link org.openecomp.policy.api.PolicyChangeResponse} which consists of the response related to the Delete Policy Request. - * @throws PolicyException PolicyException related to the operation. - */ - public PolicyChangeResponse deletePolicy(DeletePolicyParameters deletePolicyParameters) throws PolicyException { - return stdPolicyEngine.deletePolicy(deletePolicyParameters); - } - - /** - * Creates a new Policy Service based on given Service Parameters. - * - * @param importParameters {@link org.openecomp.policy.api.ImportParameters} which represents the Service Parameters required to create a Policy Service. - * @return {@link org.openecomp.policy.api.PolicyChangeResponse} which consists of the response related to create import Service. - * @throws PolicyException PolicyException related to the operation. - */ - public PolicyChangeResponse policyEngineImport(ImportParameters importParameters) throws PolicyException { - return stdPolicyEngine.policyEngineImport(importParameters); - } - - /** - * setNotification allows changes to the Notification Scheme and Notification Handler - * - * @param scheme the NotificationScheme of {@link org.openecomp.policy.api.NotificationScheme} which defines the Notification Scheme - * @param handler the NotificationHandler of {@link org.openecomp.policy.api.NotificationHandler} which defines what should happen when a notification is received. - */ - public void setNotification(NotificationScheme scheme, NotificationHandler handler) { - this.scheme = scheme; - this.handler = handler; - stdPolicyEngine.notification(this.scheme,this.handler); - } - - /** - * clearNotification shutsDown the Notification Service if the Auto Scehme Notification service is running. - */ - public void clearNotification(){ - stdPolicyEngine.stopNotification(); - } - - /** - * setNotification allows changes to the Notification Scheme - * - * @param scheme the NotificationScheme of {@link org.openecomp.policy.api.NotificationScheme} which defines the Notification Scheme - */ - public void setScheme(NotificationScheme scheme){ - this.scheme = scheme; - stdPolicyEngine.setScheme(this.scheme); - } - - /** - * Gets the PDPNotification if there is one exists. This is used for Polling Patterns. - * - * @return PDPNotification of {@link org.openecomp.policy.api.PDPNotification} which has the Notification. - */ - public PDPNotification getNotification() { - return stdPolicyEngine.getNotification(); - } - - /** - * setClientKey allows the client to use their own implementation logic for Password Protection - * and will be used to set the clear text password, this will be used while making Requests. - * - * @param clientKey depicts String format of Password/ Client_Key. - */ - public void setClientKey(String clientKey){ - stdPolicyEngine.setClientKey(clientKey); - } - - // Internal Setter Method to help build configRequestParameters. - private ConfigRequestParameters setConfigRequestParameters(String policyName, String eCOMPComponentName, String configName, Map configAttributes, UUID requestID){ - ConfigRequestParameters configRequestParameters = new ConfigRequestParameters(); - configRequestParameters.setPolicyName(policyName); - configRequestParameters.setEcompName(eCOMPComponentName); - configRequestParameters.setConfigName(configName); - configRequestParameters.setConfigAttributes(configAttributes); - configRequestParameters.setRequestID(requestID); - return configRequestParameters; - } -} \ No newline at end of file diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngineException.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngineException.java deleted file mode 100644 index e80513ad8..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngineException.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -/** - * PolicyEngineException extends Exception to implement exceptions thrown by {@link org.openecomp.policy.api.PolicyEngine} - * - * @version 0.1 - */ -public class PolicyEngineException extends Exception{ - private static final long serialVersionUID = 4945973094200118969L; - - public PolicyEngineException() { - } - - public PolicyEngineException(String message) { - super(message); - } - - public PolicyEngineException(Throwable cause){ - super(cause); - } - - public PolicyEngineException(String message, Throwable cause) { - super(message, cause); - } - - public PolicyEngineException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEventException.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEventException.java deleted file mode 100644 index 8e4c81990..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEventException.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -/** - * PolicyEventException extends Exception to implement exceptions thrown by {@link org.openecomp.policy.api.PolicyEngine} - * - * @version 0.1 - */ -public class PolicyEventException extends Exception { - private static final long serialVersionUID = -1477625011320634608L; - - public PolicyEventException() { - } - - public PolicyEventException(String message) { - super(message); - } - - public PolicyEventException(Throwable cause){ - super(cause); - } - - public PolicyEventException(String message, Throwable cause) { - super(message, cause); - } - - public PolicyEventException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyException.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyException.java deleted file mode 100644 index f4a99fd32..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyException.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.openecomp.policy.api; - -/** - * PolicyException extends Exception to implement exceptions thrown by {@link org.openecomp.policy.api.PolicyEngine} - * - * @version 0.1 - */ -public class PolicyException extends Exception { - private static final long serialVersionUID = -5006203722296799708L; - - public PolicyException() { - } - - public PolicyException(String message) { - super(message); - } - - public PolicyException(Throwable cause){ - super(cause); - } - - public PolicyException(String message, Throwable cause) { - super(message, cause); - } - - public PolicyException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyParameters.java deleted file mode 100644 index 0f34de0d1..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyParameters.java +++ /dev/null @@ -1,557 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -/** - * PolicyParameters defines the Policy Parameters - * which are required to Create/Update a Policy. - * - * @version 0.1 - */ -public class PolicyParameters { - private PolicyClass policyClass; - private PolicyConfigType policyConfigType; - private String policyName; - private String policyDescription; - private String ecompName; - private String configName; - private Map> attributes; - private String configBody; - private PolicyType configBodyType; - private String actionPerformer; - private String actionAttribute; - private UUID requestID; - private List dynamicRuleAlgorithmLabels; - private List dynamicRuleAlgorithmFunctions; - private List dynamicRuleAlgorithmField1; - private List dynamicRuleAlgorithmField2; - private String priority; - private RuleProvider ruleProvider; - private String controllerName; - private ArrayList dependencyNames; - private Date TTLDate; - private boolean guard = false; - private String riskLevel = "5"; - private String riskType = "default"; - private String extendedOption; - - /** - * Sets Config Policy Parameters. - * - * @param policyConfigType the {@link org.openecomp.policy.api.PolicyConfigType} Enum format of the Config Type - * @param policyName the String format of the Policy Name - * @param policyDescription the String format of the Policy Description - * @param ecompName the String format of the ECOMP Name - * @param configName the String format of the Config Name - * @param attributes the Map Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it. - * @param configBodyType the {@link org.openecomp.policy.api.PolicyType} Enum format of the config Body Type. - * @param configBody the String format of the Policy Body - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - * A different request ID should be passed for each request. - */ - public void setConfigPolicyParameters(PolicyConfigType policyConfigType, String policyName, String policyDescription, String ecompName, String configName, - Map> attributes, PolicyType configBodyType, String configBody, UUID requestID){ - this.setPolicyConfigType(policyConfigType); - this.setPolicyName(policyName); - this.setPolicyDescription(policyDescription); - this.setEcompName(ecompName); - this.setConfigName(configName); - this.setAttributes(attributes); - this.setConfigBody(configBody); - this.setConfigBodyType(configBodyType); - this.setRequestID(requestID); - } - - /** - * Sets config Firewall Policy Parameters. - * - * @param policyName the String format of the Policy Name - * @param firewallJson the String representation of the Firewall Rules List - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - * A different request ID should be passed for each request. - */ - public void setConfigFirewallPolicyParameters(String policyName, String firewallJson, UUID requestID){ - this.setPolicyConfigType(PolicyConfigType.Firewall); - this.setPolicyName(policyName); - this.setConfigBody(firewallJson); - this.setConfigBodyType(PolicyType.JSON); - this.setRequestID(requestID); - } - - /** - * Gets the PolicyName of the Policy Parameters. - * - * @return policyName the String format of the Policy Name - */ - public String getPolicyName() { - return policyName; - } - - /** - * Sets the policyName of the Policy Parameters. - * - * @param policyName the String format of the Policy Name - */ - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - - /** - * Gets the policy Description. - * - * @return the String format of the Policy Description - */ - public String getPolicyDescription() { - return policyDescription; - } - - /** - * Sets the policy Description of the Policy Description. - * - * @param policyDescription the String format of the Policy Description - */ - public void setPolicyDescription(String policyDescription) { - this.policyDescription = policyDescription; - } - - /** - * Gets the ECOMP Name value of the Policy Paramters. - * - * @return String format of the ECOMP Name - */ - public String getEcompName() { - return ecompName; - } - - /** - * Sets the ECOMP Name field of the Policy Parameters. - * - * @param ecompName the String format of the ECOMP Name - */ - public void setEcompName(String ecompName) { - this.ecompName = ecompName; - } - - /** - * Gets the Config Name value of the Policy Parameters. - * - * @return String format of the Config Name - */ - public String getConfigName() { - return configName; - } - - /** - * Sets the Config Name field of the Policy Parameters. - * - * @param configName the String format of the Config Name - */ - public void setConfigName(String configName) { - this.configName = configName; - } - - /** - * Gets the Attributes of the policy Parameters. - * - * @return List the Map Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it. - */ - public Map> getAttributes() { - return attributes; - } - - /** - * Sets the Attributes of the Policy Parameters. - * - * @param attributes the Map Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it. - */ - public void setAttributes(Map> attributes) { - this.attributes = attributes; - } - - /** - * Gets the Policy Config Type value the Policy parameters. - * - * @return {@link org.openecomp.policy.api.PolicyConfigType} Enum of the Config Type - */ - public PolicyConfigType getPolicyConfigType() { - return policyConfigType; - } - - /** - * Sets the Policy Config Type field of the policy Parameters. - * - * @param policyConfigType the {@link org.openecomp.policy.api.PolicyConfigType} Enum format of the Config Type - */ - public void setPolicyConfigType(PolicyConfigType policyConfigType) { - if(policyConfigType!=null){ - setPolicyClass(PolicyClass.Config); - } - this.policyConfigType = policyConfigType; - } - - /** - * Gets the configBody value of the Policy Parameters. - * - * @return the String format of the Policy Body - */ - public String getConfigBody() { - return configBody; - } - - /** - * Sets the configBody field of the Policy Parameters. - * - * @param configBody the String format of the Policy Body - */ - public void setConfigBody(String configBody) { - this.configBody = configBody; - } - - /** - * Gets the config Body Type value of the Policy Parameters. - * - * @return the PolicyType representation of the configBodyType - */ - public PolicyType getConfigBodyType() { - return configBodyType; - } - - /** - * Sets the configBodyType field of the Policy Parameters. - * - * @param configBodyType the PolicyType representation of the config BodyType - */ - public void setConfigBodyType(PolicyType configBodyType) { - this.configBodyType = configBodyType; - } - - /** - * Gets the requestID of the Policy Parameters. - * - * @return unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - */ - public UUID getRequestID() { - return requestID; - } - - /** - * Sets the requestID of the Policy Parameters. - * - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - */ - public void setRequestID(UUID requestID) { - this.requestID = requestID; - } - - /** - * Gets the Policy Class of the Policy Parameters. - * - * @return {@link org.openecomp.policy.api.PolicyClass} of the Policy Parameters. - */ - public PolicyClass getPolicyClass() { - return policyClass; - } - - /** - * Sets the Policy Class of the Policy Parameters. - * - * @param policyClass the Enum {@link org.openecomp.policy.api.PolicyClass} to set Policy Class Type of Policy parameters. - */ - public void setPolicyClass(PolicyClass policyClass) { - this.policyClass = policyClass; - } - - /** - * Gets the Action Performer value of the Policy Parameters for Action Policies. - * - * @return the String value of the Action Performer for Action Policies - */ - public String getActionPerformer() { - return actionPerformer; - } - - /** - * Sets the Action Performer value of the Policy Parameters for Action Policies. - * - * @param actionPerformer the String format of the Action Performer - */ - public void setActionPerformer(String actionPerformer) { - this.actionPerformer = actionPerformer; - } - - /** - * Gets the Action Attribute value of the Policy Parameters for Action Policies. - * - * @return the String value of the Action Attribute for Action Policies - */ - public String getActionAttribute() { - return actionAttribute; - } - - /** - * Sets the Action Attribute value of the Policy Parameters for Action Policies. - * - * @param actionAttribute the String format of the Action Attribute - */ - public void setActionAttribute(String actionAttribute) { - this.actionAttribute = actionAttribute; - } - - /** - * Gets the Dynamic Rule Algorithm Label of the policy Parameters. Used in conjunction with the Label, Field1, - * Function, and Field2 to complete the complex and simple Rule Algorithms - * - * @return List the Dynamic Rule Algorithm Label that must contain the Labels in order - */ - public List getDynamicRuleAlgorithmLabels() { - return dynamicRuleAlgorithmLabels; - } - - /** - * Sets the Dynamic Rule Algorithm Labels used in conjunction with the Label, Field1, - * Function, and Field2 to complete the complex and simple Rule Algorithms - * - * @param dynamicRuleAlgorithmLabels the List dynamicRuleAlgoritmLabels in order - */ - public void setDynamicRuleAlgorithmLabels( - List dynamicRuleAlgorithmLabels) { - this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels; - } - - /** - * Gets the Dynamic Rule Algorithm Function of the policy Parameters. Used in conjunction with the Label, Field1, - * FunctionDef, and Field2 to complete the complex and simple Rule Algorithms - * - * @return List the Dynamic Rule Algorithm Functions that must contain the values in order - */ - public List getDynamicRuleAlgorithmFunctions() { - return dynamicRuleAlgorithmFunctions; - } - - /** - * Sets the Dynamic Rule Algorithm Functions used in conjunction with the Label, Field1, - * Function, and Field2 to complete the complex and simple Rule Algorithms - * - * @param dynamicRuleAlgorithmFunctions the List dynamicRuleAlgorithmFunctions in order - */ - public void setDynamicRuleAlgorithmFunctions(List dynamicRuleAlgorithmFunctions) { - this.dynamicRuleAlgorithmFunctions = dynamicRuleAlgorithmFunctions; - } - - /** - * Gets the Dynamic Rule Algorithm Field1 of the policy Parameters. Used in conjunction with the Label, Field1, - * Function, and Field2 to complete the complex and simple Rule Algorithms - * - * @return List the Dynamic Rule Algorithm Field1 that must contain the Field1 values in order - */ - public List getDynamicRuleAlgorithmField1() { - return dynamicRuleAlgorithmField1; - } - - /** - * Sets the Dynamic Rule Algorithm Field1 used in conjunction with the Label, Field1, - * Function, and Field2 to complete the complex and simple Rule Algorithms - * - * @param dynamicRuleAlgorithmField1 the List dynamicRuleAlgorithmField1 in order - */ - public void setDynamicRuleAlgorithmField1( - List dynamicRuleAlgorithmField1) { - this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1; - } - - /** - * Gets the Dynamic Rule Algorithm Field2 of the policy Parameters. Used in conjunction with the Label, Field1, - * Operator, and Field2 to complete the complex and simple Rule Algorithms - * - * @return List the Dynamic Rule Algorithm Field2 that must contain the Field2 values in order - */ - public List getDynamicRuleAlgorithmField2() { - return dynamicRuleAlgorithmField2; - } - - /** - * Sets the Dynamic Rule Algorithm Field2 used in conjunction with the Label, Field1, - * Function, and Field2 to complete the complex and simple Rule Algorithms - * - * @param dynamicRuleAlgorithmField2 the List dynamicRuleAlgorithmField2 in order - */ - public void setDynamicRuleAlgorithmField2( - List dynamicRuleAlgorithmField2) { - this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2; - } - - /** - * Gets the Priority of the Policy Parameters. - * - * @return priority the String format of the Micro Services priority - */ - public String getPriority() { - return priority; - } - - /** - * Sets the Priority of the Policy Parameters. - * - * @param priority the String format of the Micro Services priority - */ - public void setPriority(String priority) { - this.priority = priority; - } - - public RuleProvider getRuleProvider() { - return ruleProvider; - } - - public void setRuleProvider(RuleProvider ruleProvider) { - this.ruleProvider = ruleProvider; - } - /** - * Sets the Guard field of the Policy Parameters. - * - * @param guard the Boolean format of the guard value - */ - public void setGuard(boolean guard){ - this.guard = guard; - } - - /** - * Gets the guard value of the Policy Parameters for Action Policies. - * - * @return the boolean value of the Guard for Config Policies - */ - public boolean getGuard(){ - return guard; - } - - /** - * Sets the riskType field of the Policy Parameters. - * - * @param riskType the String format of the riskType value - */ - public void setRiskType(String riskType){ - this.riskType = riskType; - } - - /** - * Gets the riskType value of the Policy Parameters for Config Policies. - * - * @return the String value of the riskType for Config Policies - */ - public String getRiskType(){ - return riskType; - } - - /** - * Sets the riskLevel field of the Policy Parameters. - * - * @param riskLevel the String format of the riskType value - */ - public void setRiskLevel(String riskLevel){ - this.riskLevel = riskLevel; - } - - /** - * Gets the riskLevel value of the Policy Parameters for Config Policies. - * - * @return the String value of the riskLevel for Config Policies - */ - public String getRiskLevel(){ - return riskLevel; - } - - /** - * Sets the TTLDate field of the Policy Parameters. - * - * @param TTLDate the Date format of the TTLDate value - */ - public void setTtlDate(Date TTLDate){ - this.TTLDate = TTLDate; - } - - /** - * Gets the TTLDate value of the Policy Parameters for Config Policies. - * - * @return the Date value of the TTLDate for Config Policies - */ - public Date getTtlDate(){ - return TTLDate; - } - - /** - * Gets the Controller Name for your policy. - * - * @return String format of the controller Name. - */ - public String getControllerName() { - return controllerName; - } - - /** - * Sets Controller Name for your policy. - * - * @param controllerName to identify the controller information for your policy. - */ - public void setControllerName(String controllerName) { - this.controllerName = controllerName; - } - - /** - * Gets Dependency Names for your policy. - * - * @return ArrayList of String(s) format of dependency names. - */ - public ArrayList getDependencyNames() { - return dependencyNames; - } - - /** - * Sets Dependency that your policy is dependent on. - * - * @param dependencyNames ArrayList of String(s). - */ - public void setDependencyNames(ArrayList dependencyNames) { - this.dependencyNames = dependencyNames; - } - - public String getExtendedOption() { - return extendedOption; - } - - public void setExtendedOption(String extendedOption) { - this.extendedOption = extendedOption; - } - - public String toString() { - return "PolicyParameters [ policyName=" + policyName + ", policyDescription=" + policyDescription + ", ecompName="+ ecompName - + ", configName=" + configName + ", attributes=" + attributes + ", configBody=" + configBody - + ",dynamicRuleAlgorithmLabels=" + dynamicRuleAlgorithmLabels + ",dynamicRuleAlgorithmFunctions=" + dynamicRuleAlgorithmFunctions - + ",dynamicRuleAlgorithmField1=" + dynamicRuleAlgorithmField1 + ",dynamicRuleAlgorithmField2=" + dynamicRuleAlgorithmField2 - + ", actionPerformer=" + actionPerformer + ", actionAttribute=" + actionAttribute + ", priority=" + priority - + ", ruleProvider= " + ruleProvider + ", riskLevel= " + riskLevel + ", riskType= " + riskType + ", extendedOption= " + extendedOption - + "]"; - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponse.java deleted file mode 100644 index 316f7dd83..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponse.java +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - -package org.openecomp.policy.api; - -import java.util.Map; - -/** - * Defines the objects that represent PolicyEngine Response elements. PolicyResponse communicates the PolicyResponseStatus, - * PolicyResponseMessage, ActionAdvised, ActionTaken and RequestAttributes. - * - * @version 0.3 - */ -public interface PolicyResponse { - /** - * Gets the {@link org.openecomp.policy.api.PolicyResponseStatus} associated with this PolicyResponse. - * - * @return the PolicyResponseStatus associated with this PolicyResponse - */ - public PolicyResponseStatus getPolicyResponseStatus(); - - /** - * Gets the Map of String,String which consists of ActionAdvised in this PolicyResponse. - * If there is no ActionAdvised this method must return an empty Map. - * - * @return the Map of String,String which consists of AdviceAttributes in PolicyResponse - */ - public Map getActionAdvised(); - - /** - * Gets the Map of String,String which consists of ActionTaken in this PolicyResponse. - * If there are no ActionTaken this method must return an empty Map. - * - * @return the Map of String,String which consists of ActionTaken in PolicyResponse - */ - public Map getActionTaken(); - - /** - * Gets the Map of String,String which consists of RequestAttributes in this PolicyResponse. - * - * @return the Map of String,String which consists of RequestAttributes from PolicyResponse - */ - public Map getRequestAttributes(); - - /** - * Gets the String of the PolicyResponseMessage from PolicyResponse - * - * @return the String which consists of PolicyResponseMessage from PolicyResponse - */ - public String getPolicyResponseMessage(); - - /** - * Returns the String version of the PolicyResponse object. - * - * @return String of the PolicyResponse Object. - */ - @Override - public String toString(); -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponseStatus.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponseStatus.java deleted file mode 100644 index 84fac733d..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponseStatus.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import com.fasterxml.jackson.annotation.JsonCreator; - -/** - * Enumeration of PolicyResponseStatus that can be returned as a part of - * {@link org.openecomp.policy.api.PolicyResponse}. - * - * @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 PolicyResponseStatus based on String representation of PolicyResponse - * - * @param responseStatus the String Response Status - * @return the PolicyResponseStatus with the name matching ACTION_ADVISED or ACTION_TAKEN or NO_ACTION_REQUIRED - */ - public static PolicyResponseStatus getStatus(String responseStatus) { - if(responseStatus.equalsIgnoreCase("action_advised")) { - return ACTION_ADVISED; - }else if(responseStatus.equalsIgnoreCase("action_taken")) { - return ACTION_TAKEN; - }else { - return NO_ACTION_REQUIRED; - } - } - - /** - * Returns the String name for this PolicyResponseStatus - * - * @return the String name for this PolicyResponseStatus - */ - 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))){ - return type; - } - } - throw new IllegalArgumentException(); - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyType.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyType.java deleted file mode 100644 index a0566e039..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyType.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import com.fasterxml.jackson.annotation.JsonCreator; - -/** - * Enumeration of the Policy Return Types that can be returned as part of a - * {@link org.openecomp.policy.api.PolicyConfig}. - * - * @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 String format of Type for this PolicyType - * @return the String of the Type for this PolicyType - */ - public String toString() { - return this.name; - } - @JsonCreator - public static PolicyType create (String value) { - for(PolicyType type: values()){ - if(type.toString().equalsIgnoreCase(value)){ - return type; - } - } - throw new IllegalArgumentException(); - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PushPolicyParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PushPolicyParameters.java deleted file mode 100644 index 8a822065b..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PushPolicyParameters.java +++ /dev/null @@ -1,131 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import java.util.UUID; - -/** - * PushPolicyParameters defines the Policy Parameters - * which are required to Push a Policy to PDPGroup. - * - * @version 0.1 - */ -public class PushPolicyParameters { - private String policyName; - private String policyType; - private String pdpGroup; - private UUID requestID; - - /** - * Constructor with no Parameters. - */ - public PushPolicyParameters(){ - } - - /** - * Constructor with Parameters. - * - * @param policyName the String format of the Policy Name - * @param policyType the String format of the Policy Type - * @param pdpGroup the String format of the PDPGroup - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - */ - public PushPolicyParameters(String policyName, String policyType, String pdpGroup, UUID requestID){ - this.policyName = policyName; - this.policyType = policyType; - this.pdpGroup = pdpGroup; - this.requestID = requestID; - } - - /** - * Gets the PolicyName of the Push Policy Parameters. - * - * @return policyName the String format of the Policy Name - */ - public String getPolicyName() { - return policyName; - } - - /** - * Sets the policyName of the Push Policy Parameters. - * - * @param policyName the String format of the Policy Name - */ - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - - /** - * Gets the PolicyType of the Push Policy Parameters. - * - * @return policyType the String format of the Policy Type - */ - public String getPolicyType() { - return policyType; - } - - /** - * Sets the policyType of the Push Policy Parameters. - * - * @param policyType the String format of the Policy Type - */ - public void setPolicyType(String policyType) { - this.policyType = policyType; - } - - /** - * Gets the PDPGroup of the Push Policy Parameters. - * - * @return pdpGroup the String format of the PDPGroup - */ - public String getPdpGroup() { - return pdpGroup; - } - - /** - * Sets the PDPGroup of the Push Policy Parameters. - * - * @param pdpGroup the String format of the PDPGroup - */ - public void setPdpGroup(String pdpGroup) { - this.pdpGroup = pdpGroup; - } - - /** - * Gets the requestID of the Push Policy Parameters. - * - * @return unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - */ - public UUID getRequestID() { - return requestID; - } - - /** - * Sets the requestID of the Push Policy Parameters. - * - * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages. - */ - public void setRequestID(UUID requestID) { - this.requestID = requestID; - } - - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/RuleProvider.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/RuleProvider.java deleted file mode 100644 index 99f075a30..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/RuleProvider.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.api; - -import com.fasterxml.jackson.annotation.JsonCreator; - -/** - * Enumeration of the Attribute Types that is used as a part of - * {@link org.openecomp.policy.api.PolicyParameters}. - * - * @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") - ; - - private String name; - - private RuleProvider(String typeName){ - this.name = typeName; - } - - /** - * Returns the String format of Type for this AttributeType - * @return the String of the Type for this AttributeType - */ - 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))){ - return type; - } - } - throw new IllegalArgumentException(); - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/package-info.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/package-info.java deleted file mode 100644 index 982dbb47c..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/package-info.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - -package org.openecomp.policy.api; - -/** - * org.openecomp.policy.api contains the API for the PolicyEngine ProtoType - * - * @version 0.9 - * - * Changes: - * Addition of Notifications methods to the Client API. - * Combining Multiple results. and Minor changes to retrieve all policies. - * Retrieve config policy using policyFile Name and the matching conditions of the policy in the results. - * Addition of Decision policy call - * - * - */ diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/models/APIConfigResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/models/APIConfigResponse.java deleted file mode 100644 index 664522615..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/models/APIConfigResponse.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.policy.models; - -import java.util.Map; - -import org.openecomp.policy.api.PolicyConfigStatus; -import org.openecomp.policy.api.PolicyType; - -public interface APIConfigResponse { - public String getPolicyConfigMessage(); - public PolicyConfigStatus getPolicyConfigStatus(); - public PolicyType getType(); // PolicyType - public String getConfig(); - public String getPolicyName(); - public String getPolicyVersion(); - public Map getMatchingConditions(); - public Map getResponseAttributes(); - public Map getProperty(); -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/models/APIDictionaryResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/models/APIDictionaryResponse.java deleted file mode 100644 index 4829bfac8..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/models/APIDictionaryResponse.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.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) { - this.dictionaryData = dictionaryData; - } - public Object getDictionaryJson() { - return dictionaryJson; - } - public void setDictionaryJson(Object dictionaryJson) { - this.dictionaryJson = dictionaryJson; - } - public int getResponseCode() { - return responseCode; - } - public void setResponseCode(int responseCode) { - this.responseCode = responseCode; - } - public String getResponseMessage() { - return responseMessage; - } - public void setResponseMessage(String responseMessage) { - this.responseMessage = responseMessage; - } - - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/models/APIPolicyConfigResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/models/APIPolicyConfigResponse.java deleted file mode 100644 index 7be932162..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/models/APIPolicyConfigResponse.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.policy.models; - -import java.util.Map; - -import org.openecomp.policy.api.PolicyConfigStatus; -import org.openecomp.policy.api.PolicyType; - -public class APIPolicyConfigResponse implements APIConfigResponse { - private String policyConfigMessage; - private PolicyConfigStatus policyConfigStatus; - private PolicyType type; - private String config; - private String policyName; - private String policyVersion; - private Map matchingConditions; - private Map responseAttributes; - private Map property; - public String getConfig() { - return config; - } - public void setConfig(String config) { - this.config = config; - } - public PolicyType getType() { - return type; - } - public void setType(PolicyType type) { - this.type = type; - } - public PolicyConfigStatus getPolicyConfigStatus() { - return policyConfigStatus; - } - public void setPolicyConfigStatus(PolicyConfigStatus policyConfigStatus) { - this.policyConfigStatus = policyConfigStatus; - } - public String getPolicyConfigMessage() { - return policyConfigMessage; - } - public void setPolicyConfigMessage(String policyConfigMessage) { - this.policyConfigMessage = policyConfigMessage; - } - public Map getProperty() { - return property; - } - public void setProperty(Map property) { - this.property = property; - } - public String getPolicyName(){ - return policyName; - } - public void setPolicyName(String policyName){ - this.policyName = policyName; - } - public String getPolicyVersion(){ - return policyVersion; - } - public void setPolicyVersion(String policyVersion){ - this.policyVersion = policyVersion; - } - public Map getMatchingConditions(){ - return matchingConditions; - } - public void setMatchingConditions(Map matchingConditions){ - this.matchingConditions = matchingConditions; - } - public void setResponseAttributes(Map responseAttributes){ - this.responseAttributes = responseAttributes; - } - public Map getResponseAttributes(){ - return responseAttributes; - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientDMAAP.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientDMAAP.java deleted file mode 100644 index 563cd85ca..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientDMAAP.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.openecomp.policy.std; - -import java.util.List; -import java.util.UUID; - -import org.openecomp.policy.api.NotificationHandler; -import org.openecomp.policy.api.NotificationScheme; -import org.openecomp.policy.api.NotificationType; -import org.openecomp.policy.api.PDPNotification; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; -import org.openecomp.policy.utils.BusConsumer; -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -public class AutoClientDMAAP implements Runnable { - private static StdPDPNotification notification = null; - private static NotificationScheme scheme = null; - private static NotificationHandler handler = null; - private static String topic = null; - private static boolean status = false; - private static Logger logger = FlexLogger.getLogger(AutoClientDMAAP.class.getName()); - private static String notficatioinType = null; - private static BusConsumer dmaapConsumer = null; - private static List dmaapList = null; - private static String aafLogin = null; - private static String aafPassword = null; - public volatile boolean isRunning = false; - - - public AutoClientDMAAP(List dmaapList, String topic, String aafLogin, String aafPassword) { - AutoClientDMAAP.topic = topic; - AutoClientDMAAP.dmaapList = dmaapList; - AutoClientDMAAP.aafLogin = aafLogin; - AutoClientDMAAP.aafPassword = aafPassword; - } - - public void setAuto(NotificationScheme scheme, - NotificationHandler handler) { - AutoClientDMAAP.scheme = scheme; - AutoClientDMAAP.handler = handler; - } - - public static void setScheme(NotificationScheme scheme) { - AutoClientDMAAP.scheme = scheme; - } - - public static boolean getStatus(){ - return AutoClientDMAAP.status; - } - - public static String getTopic() { - return AutoClientDMAAP.topic; - } - - public static String getNotficationType(){ - return AutoClientDMAAP.notficatioinType; - } - - public synchronized boolean isRunning() { - return this.isRunning; - } - - public synchronized void terminate() { - this.isRunning = false; - } - - @Override - public void run() { - synchronized(this) { - this.isRunning = true; - } - String group = UUID.randomUUID ().toString (); - String id = "0"; - - // Stop and Start needs to be done. - if (scheme != null && handler!=null) { - if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS) || scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) { - - // create a loop to listen for messages from DMaaP server - try { - dmaapConsumer = new BusConsumer.DmaapConsumerWrapper(dmaapList, topic, aafLogin, aafPassword, group, id, 15*1000, 1000 ); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to create DMaaP Consumer: ", e); - } - - while (this.isRunning() ) - { - try { - for ( String msg : dmaapConsumer.fetch () ) - { - logger.debug("Auto Notification Recieved Message " + msg + " from DMAAP server : " + dmaapList.toString()); - notification = NotificationUnMarshal.notificationJSON(msg); - callHandler(); - } - } catch (Exception e) { - logger.debug("Error in processing DMAAP message"); - } - - } - logger.debug("Stopping DMAAP Consumer loop will no longer fetch messages from the servers"); - } - } - } - - private static void callHandler() { - if (handler != null && scheme != null) { - if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS)) { - boolean removed = false, updated = false; - if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) { - removed = true; - } - if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) { - updated = true; - } - if (removed && updated) { - notification.setNotificationType(NotificationType.BOTH); - } else if (removed) { - notification.setNotificationType(NotificationType.REMOVE); - } else if (updated) { - notification.setNotificationType(NotificationType.UPDATE); - } - handler.notificationReceived(notification); - } else if (scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) { - PDPNotification newNotification = MatchStore.checkMatch(notification); - if (newNotification.getNotificationType() != null) { - handler.notificationReceived(newNotification); - } - } - } - } - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientEnd.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientEnd.java deleted file mode 100644 index 06a2e471e..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientEnd.java +++ /dev/null @@ -1,248 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std; - -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; - -import javax.websocket.ClientEndpoint; -import javax.websocket.DeploymentException; -import javax.websocket.OnClose; -import javax.websocket.OnError; -import javax.websocket.OnMessage; -import javax.websocket.OnOpen; -import javax.websocket.Session; - -//import org.apache.log4j.Logger; -import org.glassfish.tyrus.client.ClientManager; -import org.openecomp.policy.api.NotificationHandler; -import org.openecomp.policy.api.NotificationScheme; -import org.openecomp.policy.api.NotificationType; -import org.openecomp.policy.api.PDPNotification; -import org.openecomp.policy.std.NotificationStore; -import org.openecomp.policy.std.StdPDPNotification; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import org.openecomp.policy.common.logging.flexlogger.*; - -@ClientEndpoint -public class AutoClientEnd { - private static StdPDPNotification notification = null; - private static StdPDPNotification oldNotification = null; - private static ClientManager client = null; - private static NotificationScheme scheme = null; - private static NotificationHandler handler = null; - private static String url = null; - private static Session session = null; - private static boolean status = false; - private static boolean stop = false; - private static boolean message = false; - private static boolean error = false; - private static Logger logger = FlexLogger.getLogger(AutoClientEnd.class.getName()); - - public static void setAuto(NotificationScheme scheme, - NotificationHandler handler) { - AutoClientEnd.scheme = scheme; - AutoClientEnd.handler = handler; - } - - public static void setScheme(NotificationScheme scheme) { - AutoClientEnd.scheme = scheme; - } - - public static boolean getStatus(){ - return AutoClientEnd.status; - } - - public static String getURL() { - return AutoClientEnd.url; - } - - public static void start(String url) { - AutoClientEnd.url = url; - // Stop and Start needs to be done. - if (scheme != null && handler!=null) { - if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS) || scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) { - if (AutoClientEnd.client == null) { - client = ClientManager.createClient(); - if(url.contains("https")){ - url = url.replaceAll("https", "wss"); - }else { - url = url.replaceAll("http", "ws"); - } - try { - logger.info("Starting Auto Notification with the PDP server : " + url); - client.connectToServer(AutoClientEnd.class, new URI(url + "notifications")); - status = true; - if(error){ - // The URL's will be in Sync according to design Spec. - ManualClientEnd.start(AutoClientEnd.url); - StdPDPNotification notification = NotificationStore.getDeltaNotification((StdPDPNotification)ManualClientEnd.result(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)); - if(notification.getNotificationType()!=null){ - if(oldNotification!=notification){ - oldNotification= notification; - AutoClientEnd.notification = notification; - callHandler(); - } - } - error = false; - } - // - } catch (DeploymentException | IOException | URISyntaxException e) { - logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e); - client = null; - status = false; - changeURL(); - } - } - } - } - } - - private static void changeURL(){ - // Change the PDP if it is not Up. - StdPolicyEngine.rotatePDPList(); - start(StdPolicyEngine.getPDPURL()); - } - - public static void stop() { - if (client != null) { - client.shutdown(); - if(session!=null){ - try { - stop = true; - logger.info("\n Closing Auto Notification WebSocket Connection.. "); - session.close(); - session = null; - } catch (IOException e) { - // - } - } - client = null; - status = false; - stop = false; - } - } - - private static void callHandler() { - if (handler != null && scheme != null) { - if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS)) { - boolean removed = false, updated = false; - if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) { - removed = true; - } - if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) { - updated = true; - } - if (removed && updated) { - notification.setNotificationType(NotificationType.BOTH); - } else if (removed) { - notification.setNotificationType(NotificationType.REMOVE); - } else if (updated) { - notification.setNotificationType(NotificationType.UPDATE); - } - try{ - handler.notificationReceived(notification); - }catch (Exception e){ - logger.error("Error in Clients Handler Object : ", e); - } - } else if (scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) { - PDPNotification newNotification = MatchStore.checkMatch(notification); - if (newNotification.getNotificationType() != null) { - try{ - handler.notificationReceived(newNotification); - }catch (Exception e){ - logger.error("Error in Clients Handler Object : ", e); - } - } - } - } - } - - // WebSockets Code.. - @OnOpen - public void onOpen(Session session) throws IOException { - // session.getBasicRemote().sendText("Connected to Client with Session: " - // + session.getId()); - logger.debug("Auto Notification Session Started... " + session.getId()); - if(AutoClientEnd.session == null){ - AutoClientEnd.session = session; - } - } - - @OnError - public void onError(Session session, Throwable e) { - // trying to Restart by self. - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Session Error.. "+ session.getId() + "\n Error is : " + e ); - // logger.error("Exception Occured"+e); - stop(); - if (url != null) { - client = null; - status = false; - error= true; - start(url); - } - } - - @OnClose - public void onClose(Session session) { - logger.info("Session ended with "+ session.getId()); - if(!stop && !message){ - // This Block of code is executed if there is any Network Failure or if the Notification is Down. - logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Disconnected from Notification Server"); - client = null; - status = false; - AutoClientEnd.session=null; - // Try to connect Back to available PDP. - error = true; - start(url); - } - AutoClientEnd.message=false; - } - - @OnMessage - public void onMessage(String message, Session session) throws JsonParseException, JsonMappingException, IOException { - AutoClientEnd.message = true; - logger.debug("Auto Notification Recieved Message " + message + " Session info is : " + session.getId()); - try { - notification = NotificationUnMarshal.notificationJSON(message); - } catch (Exception e) { - logger.error("PE500 " + e); - } - if(AutoClientEnd.session == session){ - try{ - NotificationStore.recordNotification(notification); - }catch(Exception e){ - logger.error(e); - } - if(oldNotification!=notification){ - oldNotification= notification; - callHandler(); - } - }else{ - session.close(); - } - AutoClientEnd.message = false; - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java deleted file mode 100644 index 782187720..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java +++ /dev/null @@ -1,178 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.List; -import java.util.UUID; - -import org.openecomp.policy.api.NotificationHandler; -import org.openecomp.policy.api.NotificationScheme; -import org.openecomp.policy.api.NotificationType; -import org.openecomp.policy.api.PDPNotification; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -import com.att.nsa.cambria.client.CambriaClientBuilders; -import com.att.nsa.cambria.client.CambriaClientBuilders.ConsumerBuilder; -import com.att.nsa.cambria.client.CambriaConsumer; -/** - * Create a UEB Consumer to receive policy update notification. - * - * - * - */ -public class AutoClientUEB implements Runnable { - private static StdPDPNotification notification = null; - private static NotificationScheme scheme = null; - private static NotificationHandler handler = null; - private static String topic = null; - private static String url = null; - private static boolean status = false; - private static Logger logger = FlexLogger.getLogger(AutoClientUEB.class.getName()); - private static String notficatioinType = null; - private static CambriaConsumer CConsumer = null; - private static String apiKey = null; - private static String apiSecret = null; - private static List uebURLList = null; - public volatile boolean isRunning = false; - - - public AutoClientUEB(String url, List uebURLList, String apiKey, String apiSecret) { - AutoClientUEB.url = url; - AutoClientUEB.uebURLList = uebURLList; - AutoClientUEB.apiKey = apiKey; - AutoClientUEB.apiKey = apiKey; - } - - public void setAuto(NotificationScheme scheme, - NotificationHandler handler) { - AutoClientUEB.scheme = scheme; - AutoClientUEB.handler = handler; - } - - public static void setScheme(NotificationScheme scheme) { - AutoClientUEB.scheme = scheme; - } - - public static boolean getStatus(){ - return AutoClientUEB.status; - } - - public static String getURL() { - return AutoClientUEB.url; - } - - public static String getNotficationType(){ - return AutoClientUEB.notficatioinType; - } - - public synchronized boolean isRunning() { - return this.isRunning; - } - - public synchronized void terminate() { - this.isRunning = false; - } - - @Override - public void run() { - synchronized(this) { - this.isRunning = true; - } - String group = UUID.randomUUID ().toString (); - String id = "0"; - //String topic = null; - // Stop and Start needs to be done. - if (scheme != null && handler!=null) { - if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS) || scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) { - URL aURL; - try { - aURL = new URL(AutoClientUEB.topic); - topic = aURL.getHost() + aURL.getPort(); - } catch (MalformedURLException e) { - topic = AutoClientUEB.url.replace("[:/]", ""); - } - - try { - //CConsumer = CambriaClientFactory.createConsumer ( null, uebURLList, topic, group, id, 15*1000, 1000 ); - ConsumerBuilder builder = new CambriaClientBuilders.ConsumerBuilder(); - builder.knownAs(group, id) - .usingHosts(uebURLList) - .onTopic(topic) - .waitAtServer(15*1000) - .receivingAtMost(1000) - .authenticatedBy(apiKey, apiSecret); - - CConsumer = builder.build(); - - } catch (Exception e1) { - logger.error("Exception Occured" + e1); - } - while (this.isRunning() ) - { - try { - for ( String msg : CConsumer.fetch () ) - { - logger.debug("Auto Notification Recieved Message " + msg + " from UEB cluster : " + uebURLList.toString()); - notification = NotificationUnMarshal.notificationJSON(msg); - callHandler(); - } - } catch (Exception e) { - logger.debug(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Error in processing UEB message" + e.getMessage()); - } - - } - logger.debug("Stopping UEB Consumer loop will not logger fetch messages from the cluster"); - } - } - } - - private static void callHandler() { - if (handler != null && scheme != null) { - if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS)) { - boolean removed = false, updated = false; - if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) { - removed = true; - } - if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) { - updated = true; - } - if (removed && updated) { - notification.setNotificationType(NotificationType.BOTH); - } else if (removed) { - notification.setNotificationType(NotificationType.REMOVE); - } else if (updated) { - notification.setNotificationType(NotificationType.UPDATE); - } - handler.notificationReceived(notification); - } else if (scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) { - PDPNotification newNotification = MatchStore.checkMatch(notification); - if (newNotification.getNotificationType() != null) { - handler.notificationReceived(newNotification); - } - } - } - } - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEnd.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEnd.java deleted file mode 100644 index c006b057b..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEnd.java +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std; - -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.concurrent.CountDownLatch; - -import javax.websocket.ClientEndpoint; -import javax.websocket.DeploymentException; -import javax.websocket.OnClose; -import javax.websocket.OnError; -import javax.websocket.OnMessage; -import javax.websocket.OnOpen; -import javax.websocket.Session; - -//import org.apache.log4j.Logger; -import org.glassfish.tyrus.client.ClientManager; -import org.openecomp.policy.api.NotificationScheme; -import org.openecomp.policy.api.NotificationType; -import org.openecomp.policy.api.PDPNotification; -import org.openecomp.policy.std.StdPDPNotification; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -import org.openecomp.policy.common.logging.flexlogger.*; - -@ClientEndpoint -public class ManualClientEnd { - private static CountDownLatch latch; - private static StdPDPNotification notification = null; - private static String resultJson = null; - private static Logger logger = FlexLogger.getLogger(ManualClientEnd.class.getName()); - - public static void start(String url) { - latch = new CountDownLatch(1); - ClientManager client = ClientManager.createClient(); - if(url.contains("https")){ - url = url.replaceAll("https", "wss"); - }else { - url = url.replaceAll("http", "ws"); - } - try { - client.connectToServer(ManualClientEnd.class, new URI(url+"notifications")); - latch.await(); - } catch (DeploymentException | URISyntaxException | InterruptedException e) { - logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e); - } catch (IOException e) { - logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e); - } - } - - public static PDPNotification result(NotificationScheme scheme) { - if (resultJson == null || notification == null) { - logger.debug("No Result" ); - return null; - } else { - if(scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) { - boolean removed = false, updated = false; - if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){ - removed = true; - } - if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){ - updated = true; - } - if(removed && updated) { - notification.setNotificationType(NotificationType.BOTH); - }else if(removed){ - notification.setNotificationType(NotificationType.REMOVE); - }else if(updated){ - notification.setNotificationType(NotificationType.UPDATE); - } - return notification; - }else if(scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) { - return MatchStore.checkMatch(notification); - }else { - return null; - } - } - } - - // WebSockets Code.. - @OnOpen - public void onOpen(Session session) throws IOException { - logger.info("Session Started with : " + session.getId()); - session.getBasicRemote().sendText("Manual"); - } - - @OnError - public void onError(Session session, Throwable e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in: "+ session.getId()); - latch.countDown(); - } - - @OnClose - public void onClose(Session session) { - logger.info("Session ended with "+ session.getId()); - latch.countDown(); - } - - @OnMessage - public void onMessage(String message, Session session){ - logger.debug(" Manual Notification Recieved Message : " + message +" Session info is : "+ session.getId()); - resultJson = message; - try { - notification = NotificationUnMarshal.notificationJSON(message); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e); - latch.countDown(); - } - try { - session.close(); - } catch (IOException e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e); - latch.countDown(); - } // For Manual Client.. - latch.countDown(); - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndDMAAP.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndDMAAP.java deleted file mode 100644 index f4a218d66..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndDMAAP.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.openecomp.policy.std; - -import java.util.List; - -import org.json.JSONObject; -import org.openecomp.policy.api.NotificationScheme; -import org.openecomp.policy.api.NotificationType; -import org.openecomp.policy.api.PDPNotification; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; -import org.openecomp.policy.utils.BusConsumer; -import org.openecomp.policy.utils.BusPublisher; -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -public class ManualClientEndDMAAP { - private static StdPDPNotification notification = null; - private static String resultJson = null; - private static Logger logger = FlexLogger.getLogger(ManualClientEndDMAAP.class.getName()); - private static BusConsumer dmaapConsumer = null; - private static String uniquID = null; - private static String topic = null; - - - public static PDPNotification result(NotificationScheme scheme) { - if (resultJson == null || notification == null) { - logger.debug("No Result" ); - return null; - } else { - if(scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) { - boolean removed = false, updated = false; - if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){ - removed = true; - } - if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){ - updated = true; - } - if(removed && updated) { - notification.setNotificationType(NotificationType.BOTH); - }else if(removed){ - notification.setNotificationType(NotificationType.REMOVE); - }else if(updated){ - notification.setNotificationType(NotificationType.UPDATE); - } - return notification; - }else if(scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) { - return MatchStore.checkMatch(notification); - }else { - return null; - } - } - } - - private static void publishMessage(String pubTopic, String uniqueID, List dmaapList, String aafLogin, String aafPassword) { - BusPublisher pub = null; - try { - pub = new BusPublisher.DmaapPublisherWrapper(dmaapList, topic, aafLogin, aafPassword); - final JSONObject msg1 = new JSONObject (); - msg1.put ( "JSON", "DMaaP Update Request UID=" + uniqueID); - pub.send ( "MyPartitionKey", msg1.toString () ); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to create DMaaP Publisher: ", e); - } - if(pub != null){ - pub.close (); - } - } - - //NOTE: should be able to remove this for DMAAP since we will not be creating topics dynamically - public static void createTopic (String topic, String uniquID, List dmaapList, String aafLogin, String aafPassword){ - ManualClientEndDMAAP.topic = topic; - publishMessage(topic, uniquID, dmaapList, aafLogin, aafPassword); - } - - - public static void start(List dmaapList, String topic, String aafLogin, String aafPassword, String uniqueID) { - - ManualClientEndDMAAP.uniquID = uniqueID; - ManualClientEndDMAAP.topic = topic; - - String id = "0"; - - try { - dmaapConsumer = new BusConsumer.DmaapConsumerWrapper(dmaapList, topic, aafLogin, aafPassword, "clientGroup", id, 15*1000, 1000); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to create DMaaP Consumer: ", e); - } - - int count = 1; - while (count < 4) { - publishMessage(topic, uniquID, dmaapList, aafLogin, aafPassword); - try { - for ( String msg : dmaapConsumer.fetch () ) - { - logger.debug("Manual Notification Recieved Message " + msg + " from DMaaP server : " + dmaapList.toString()); - resultJson = msg; - if (!msg.contains("DMaaP Update")){ - notification = NotificationUnMarshal.notificationJSON(msg); - count = 4; - } - } - }catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to fetch messages from DMaaP servers: ", e); - } - count++; - } - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java deleted file mode 100644 index 85d5659e8..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java +++ /dev/null @@ -1,160 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.List; - -import org.json.JSONObject; -import org.openecomp.policy.api.NotificationScheme; -import org.openecomp.policy.api.NotificationType; -import org.openecomp.policy.api.PDPNotification; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; - -import com.att.nsa.cambria.client.CambriaClientFactory; -import com.att.nsa.cambria.client.CambriaConsumer; -import com.att.nsa.cambria.client.CambriaPublisher; - - -@SuppressWarnings("deprecation") -public class ManualClientEndUEB { - private static StdPDPNotification notification = null; - private static String resultJson = null; - private static Logger logger = FlexLogger.getLogger(ManualClientEndUEB.class.getName()); - private static CambriaConsumer CConsumer = null; - @SuppressWarnings("unused") - private static List uebURLList = null; - @SuppressWarnings("unused") - private static boolean messageNotReceived = false; - @SuppressWarnings("unused") - private static String url = null; - private static String uniquID = null; - private static String topic = null; - - - public static PDPNotification result(NotificationScheme scheme) { - if (resultJson == null || notification == null) { - logger.debug("No Result" ); - return null; - } else { - if(scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) { - boolean removed = false, updated = false; - if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){ - removed = true; - } - if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){ - updated = true; - } - if(removed && updated) { - notification.setNotificationType(NotificationType.BOTH); - }else if(removed){ - notification.setNotificationType(NotificationType.REMOVE); - }else if(updated){ - notification.setNotificationType(NotificationType.UPDATE); - } - return notification; - }else if(scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) { - return MatchStore.checkMatch(notification); - }else { - return null; - } - } - } - - private static void publishMessage(String pubTopic, String uniqueID , List uebURLList) { - - String UEBlist = uebURLList.toString(); - UEBlist = UEBlist.substring(1,UEBlist.length()-1); - CambriaPublisher pub = null; - try { - pub = CambriaClientFactory.createSimplePublisher(null, UEBlist, pubTopic); - } catch (Exception e1) { - logger.error("Exception Occured"+e1); - } - final JSONObject msg1 = new JSONObject (); - - msg1.put ( "JSON", "UEB Update Ruest UID=" + uniqueID); - if(pub != null){ - try { - pub.send ( "MyPartitionKey", msg1.toString () ); - pub.close (); - } catch (IOException e) { - logger.error("Exception Occured"+e); - } - } - } - - public static void createTopic (String url, String uniquID, List uebURLList){ - URL aURL; - try { - aURL = new URL(url); - topic = aURL.getHost() + aURL.getPort(); - } catch (MalformedURLException e) { - topic = url.replace("[:/]", ""); - } - - publishMessage(topic+ uniquID , uniquID, uebURLList); - - } - public static void start(String url, List uebURLList, - String uniqueID) { - ManualClientEndUEB.uebURLList = uebURLList; - ManualClientEndUEB.url = url; - ManualClientEndUEB.uniquID = uniqueID; - URL aURL; - try { - aURL = new URL(url); - ManualClientEndUEB.topic = aURL.getHost() + aURL.getPort(); - } catch (MalformedURLException e) { - ManualClientEndUEB.topic = url.replace("[:/]", ""); - } - String id = "0"; - try { - CConsumer = CambriaClientFactory.createConsumer ( null, uebURLList, topic + uniquID, "clientGroup", id, 15*1000, 1000 ); - } catch (Exception e1) { - logger.error("Exception Occured"+e1); - } - int count = 1; - while (count < 4) { - publishMessage(topic + "UpdateRequest", uniquID, uebURLList); - try { - for ( String msg : CConsumer.fetch () ) - { - - logger.debug("Manual Notification Recieved Message " + msg + " from UEB cluster : " + uebURLList.toString()); - resultJson = msg; - if (!msg.contains("UEB Update")){ -// System.out.println("Manual Notification Recieved Message " + msg + " from UEB cluster : " + uebURLList.toString()); - notification = NotificationUnMarshal.notificationJSON(msg); - count = 4; - } - } - }catch (Exception e) { - - } - count++; - } - } - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java deleted file mode 100644 index 1459dd9d9..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java +++ /dev/null @@ -1,246 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std; - -import java.util.Collection; -import java.util.HashSet; - -import org.openecomp.policy.api.LoadedPolicy; -import org.openecomp.policy.api.NotificationType; -import org.openecomp.policy.api.PDPNotification; -import org.openecomp.policy.api.RemovedPolicy; -import org.openecomp.policy.std.StdLoadedPolicy; -import org.openecomp.policy.std.StdPDPNotification; -import org.openecomp.policy.std.StdRemovedPolicy; - -import org.openecomp.policy.common.logging.flexlogger.*; - -public class MatchStore { - private static HashSet matchStore = new HashSet<>(); - private static Logger logger = FlexLogger.getLogger(MatchStore.class.getName()); - - public static HashSet 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 ECOMPName - if(oldMatch.getEcompName().equals(newMatch.getEcompName())){ - // 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==false){ - matchStore.add(newMatch); - } - } - } - } - - //Logic changes for Requested Policies notifications.. - public static PDPNotification checkMatch(PDPNotification oldNotification) { - boolean removed = false, updated = false; - if(oldNotification==null){ - return null; - } - StdPDPNotification newNotification = new StdPDPNotification(); - if(matchStore.isEmpty()) { - logger.debug("No Success Config Calls made yet.. "); - System.out.println("No success Config calls made yet. "); - return null; - } - if(oldNotification.getRemovedPolicies()!=null && !oldNotification.getRemovedPolicies().isEmpty()){ - // send all removed policies to client. - Collection 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 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 = false; - 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 ecomp 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(newKey.equals("ECOMPName")){ - if(updatedPolicy.getMatches().get(newKey).equals(match.getEcompName())){ - matchAttributes = true; - }else { - matchAttributes = false; - break; - } - }else if(newKey.equals("ConfigName")) { - 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("ECOMPName").equals(match.getEcompName())){ - if(updatedPolicy.getMatches().get("ConfigName").equals(match.getConfigName())){ - // Match.. - matched = true; - }else{ - break; - } - }else { - break; - } - }else{ - break; - } - }else { - // If non exist then assuming the ECOMP Name to be there. - if(updatedPolicy.getMatches().size()== 1){ - if(updatedPolicy.getMatches().get("ECOMPName").equals(match.getEcompName())){ - // 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; - } - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/Matches.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/Matches.java deleted file mode 100644 index 8e6a8ee97..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/Matches.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std; - -import java.util.Map; - -public class Matches { - private String ecompName = null; - private String configName = null; - private Map configAttributes = null; - public String getEcompName() { - return ecompName; - } - public void setEcompName(String ecompName) { - this.ecompName = ecompName; - } - public String getConfigName() { - return configName; - } - public void setConfigName(String configName) { - this.configName = configName; - } - public Map getConfigAttributes() { - return configAttributes; - } - public void setConfigAttributes(Map configAttributes) { - this.configAttributes = configAttributes; - } - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java deleted file mode 100644 index 196f89b3d..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std; - -import java.util.ArrayList; -import java.util.Collection; - -import org.openecomp.policy.api.LoadedPolicy; -import org.openecomp.policy.api.RemovedPolicy; -import org.openecomp.policy.api.UpdateType; -import org.openecomp.policy.std.StdLoadedPolicy; -import org.openecomp.policy.std.StdPDPNotification; - -import com.fasterxml.jackson.databind.ObjectMapper; - -public class NotificationUnMarshal { - private static StdPDPNotification notification; - - public static StdPDPNotification notificationJSON(String json) throws Exception{ - ObjectMapper mapper = new ObjectMapper(); - notification = mapper.readValue(json, StdPDPNotification.class); - if(notification!=null){ - if(notification.getLoadedPolicies()!=null){ - Collection 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; - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDecisionResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDecisionResponse.java deleted file mode 100644 index 1f4cf65d0..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDecisionResponse.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - -package org.openecomp.policy.std; - -import org.openecomp.policy.api.DecisionResponse; -import org.openecomp.policy.api.PolicyDecision; - -/** - * Decision Response Implementation Class. - * - * @version 0.1 - */ -public class StdDecisionResponse implements DecisionResponse { - - private PolicyDecision decision = PolicyDecision.DENY; - private String details; - - @Override - public PolicyDecision getDecision() { - return decision; - } - - @Override - public String getDetails() { - return details; - } - - public void setDecision(PolicyDecision decision){ - this.decision = decision; - } - - public void setDetails(String details) { - this.details = details; - } - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDictionaryResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDictionaryResponse.java deleted file mode 100644 index 74eebc354..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDictionaryResponse.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std; - -import java.util.Map; - -import javax.json.JsonObject; - -import org.openecomp.policy.api.DictionaryResponse; - -public class StdDictionaryResponse implements DictionaryResponse { - private String dictionaryMessage; - private JsonObject dictionaryJson; - private Map dictionaryData; - private int responseCode; - - @Override - public String getResponseMessage() { - return dictionaryMessage; - } - - @Override - public JsonObject getDictionaryJson() { - return dictionaryJson; - } - - @Override - public Map getDictionaryData() { - return dictionaryData; - } - - @Override - public int getResponseCode() { - return responseCode; - } - - public void setResponseMessage(String dictionaryMessage) { - this.dictionaryMessage = dictionaryMessage; - } - - public void setDictionaryJson(JsonObject dictionaryJson) { - this.dictionaryJson = dictionaryJson; - } - - public void setDictionaryData(Map dictionaryData) { - this.dictionaryData = dictionaryData; - } - - public void setResponseCode(int responseCode) { - this.responseCode = responseCode; - } - - - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdMetricsResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdMetricsResponse.java deleted file mode 100644 index 8c89e4a9d..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdMetricsResponse.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std; - -import org.openecomp.policy.api.MetricsResponse; - -public class StdMetricsResponse implements MetricsResponse { - private String responseMessage; - private int pdpMetrics; - private int papMetrics; - private int metricsTotal; - private int responseCode; - - @Override - public String getResponseMessage() { - return responseMessage; - } - - @Override - public int getResponseCode() { - return responseCode; - } - - @Override - public int getPapMetrics() { - return papMetrics; - } - - @Override - public int getPdpMetrics() { - return pdpMetrics; - } - - @Override - public int getMetricsTotal() { - metricsTotal = papMetrics + pdpMetrics; - return metricsTotal; - } - - public void setResponseMessage(String responseMessage) { - this.responseMessage = responseMessage; - } - - public void setPdpMetrics(int pdpMetrics) { - this.pdpMetrics = pdpMetrics; - } - - public void setPapMetrics(int papMetrics) { - this.papMetrics = papMetrics; - } - - public void setMetricsTotal(int metricsTotal) { - this.metricsTotal = metricsTotal; - } - - public void setResponseCode(int responseCode) { - this.responseCode = responseCode; - } - -} \ No newline at end of file diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyChangeResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyChangeResponse.java deleted file mode 100644 index 2fec8605c..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyChangeResponse.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std; - -import org.openecomp.policy.api.PolicyChangeResponse; - -public class StdPolicyChangeResponse implements PolicyChangeResponse{ - private String responseMessage = null; - private int responseCode; - - @Override - public String getResponseMessage() { - return responseMessage; - } - - @Override - public int getResponseCode() { - return responseCode; - } - - public void setResponseMessage(String responseMessage){ - this.responseMessage = responseMessage; - } - - public void setResponseCode(int responseCode){ - this.responseCode = responseCode; - } - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyConfig.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyConfig.java deleted file mode 100644 index ec205dab2..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyConfig.java +++ /dev/null @@ -1,168 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - -package org.openecomp.policy.std; - -import java.util.Map; -import java.util.Properties; - -import javax.json.JsonObject; - -import org.openecomp.policy.api.PolicyConfig; -import org.openecomp.policy.api.PolicyConfigStatus; -import org.openecomp.policy.api.PolicyType; -import org.w3c.dom.Document; - -/** - * PolicyConfig Implementation. - * - * @version 0.3 - * - */ - -public class StdPolicyConfig implements PolicyConfig{ - private PolicyType policyType; - private Properties properties; - private JsonObject jsonObject; - private Document document; - private String other; - private PolicyConfigStatus policyConfigStatus; - private String configStatus; - private String policyName; - private String policyVersion; - private Map matchingConditions; - private Map responseAttributes; - - @Override - public PolicyType getType() { - return policyType; - } - - @Override - public Properties toProperties() { - return properties; - } - - @Override - public JsonObject toJSON() { - return jsonObject; - } - - @Override - public Document toXML() { - return document; - } - - @Override - public String toOther() { - return other; - } - - @Override - public PolicyConfigStatus getPolicyConfigStatus() { - return policyConfigStatus; - } - - @Override - public String getPolicyConfigMessage() { - return configStatus; - } - - @Override - public String getPolicyName() { - if(policyName!=null && policyName.contains(".xml")){ - return (policyName.substring(0, policyName.substring(0, policyName.lastIndexOf(".")).lastIndexOf("."))); - } - return policyName; - } - - @Override - public String getPolicyVersion() { - return policyVersion; - } - - @Override - public Map getMatchingConditions(){ - return matchingConditions; - } - - @Override - public Map getResponseAttributes(){ - return responseAttributes; - } - - public void setPolicyType(PolicyType policyType) { - this.policyType = policyType; - } - - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - - public void setPolicyVersion(String policyVersion) { - this.policyVersion = policyVersion; - } - - public void setProperties(Properties properties) { - this.properties = properties; - } - - public void setJsonObject(JsonObject jsonObject) { - this.jsonObject = jsonObject; - } - - public void setDocument(Document document) { - this.document = document; - } - - public void setOther(String other) { - this.other = other; - } - - public void setConfigStatus(String configStatus) { - this.configStatus = configStatus; - } - - public void setPolicyConfigStatus(PolicyConfigStatus policyConfigStatus) { - this.policyConfigStatus = policyConfigStatus; - } - - public void setConfigStatus(String configStatus, PolicyConfigStatus policyConfigStatus) { - this.configStatus = configStatus; - this.policyConfigStatus = policyConfigStatus; - } - - public void setMatchingConditions(Map matchingConditions){ - this.matchingConditions = matchingConditions; - } - - public void setResponseAttributes(Map responseAttributes){ - this.responseAttributes = responseAttributes; - } - - @Override - public String toString() { - return "PolicyConfig [ policyConfigStatus=" + policyConfigStatus + ", policyConfigMessage=" + configStatus + ", policyName=" + policyName + - "" - + "]"; - } - -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java deleted file mode 100644 index 0732c3cf5..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java +++ /dev/null @@ -1,1254 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - -package org.openecomp.policy.std; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringReader; -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.net.URLConnection; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.UUID; - -import javax.json.Json; -import javax.json.JsonObject; -import javax.json.JsonReader; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.openecomp.policy.api.AttributeType; -import org.openecomp.policy.api.ConfigRequestParameters; -import org.openecomp.policy.api.DecisionRequestParameters; -import org.openecomp.policy.api.DecisionResponse; -import org.openecomp.policy.api.DeletePolicyParameters; -import org.openecomp.policy.api.DictionaryParameters; -import org.openecomp.policy.api.DictionaryResponse; -import org.openecomp.policy.api.EventRequestParameters; -import org.openecomp.policy.api.ImportParameters; -import org.openecomp.policy.api.MetricsRequestParameters; -import org.openecomp.policy.api.MetricsResponse; -import org.openecomp.policy.api.NotificationHandler; -import org.openecomp.policy.api.NotificationScheme; -import org.openecomp.policy.api.PDPNotification; -import org.openecomp.policy.api.PolicyChangeResponse; -import org.openecomp.policy.api.PolicyClass; -import org.openecomp.policy.api.PolicyConfig; -import org.openecomp.policy.api.PolicyConfigException; -import org.openecomp.policy.api.PolicyConfigType; -import org.openecomp.policy.api.PolicyDecisionException; -import org.openecomp.policy.api.PolicyEngineException; -import org.openecomp.policy.api.PolicyEventException; -import org.openecomp.policy.api.PolicyException; -import org.openecomp.policy.api.PolicyParameters; -import org.openecomp.policy.api.PolicyResponse; -import org.openecomp.policy.api.PolicyType; -import org.openecomp.policy.api.PushPolicyParameters; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; -import org.openecomp.policy.models.APIDictionaryResponse; -import org.openecomp.policy.models.APIPolicyConfigResponse; -import org.openecomp.policy.utils.AAFEnvironment; -import org.openecomp.policy.utils.PolicyUtils; -import org.openecomp.policy.xacml.api.XACMLErrorConstants; -import org.springframework.core.io.FileSystemResource; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.client.RestTemplate; -import org.xml.sax.InputSource; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -/** - * PolicyEngine Implementation class - * - * @version 1.0 - */ -public class StdPolicyEngine { - private static final String ERROR_AUTH_GET_PERM = "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to: "; - private static final String DEFAULT_NOTIFICATION = "websocket"; - - private String propertyFilePath = null; - private String clientEncoding = null; - private String contentType = null; - private static List pdps = null; - private static String environment= null; - private static String userName = null; - private static String pass = null; - private static List encoding = null; - private static boolean junit = false; - private List pdpDefault = null; - private List typeDefault = null; - private List notificationType = new ArrayList(); - private List notificationURLList = new ArrayList(); - private NotificationScheme scheme = null; - private NotificationHandler handler = null; - private AutoClientUEB uebClientThread = null; - private Thread registerUEBThread = null; - private boolean uebThread = false; - private AutoClientDMAAP dmaapClientThread = null; - private Thread registerDMAAPThread = null; - private boolean dmaapThread = false; - private String topic = null; - private String apiKey = null; - private String apiSecret = null; - - private static final String UNIQUEID = UUID.randomUUID ().toString (); - private static final Logger LOGGER = FlexLogger.getLogger(StdPolicyConfig.class.getName()); - - /* - * Taking the Property file even if it null. - */ - public StdPolicyEngine(String propertyFilePath, String clientKey) throws PolicyEngineException { - setProperty(propertyFilePath, clientKey); - } - - /* - * Taking the Notification Constructor. - */ - public StdPolicyEngine(String propertyFilePath, - NotificationScheme scheme, - NotificationHandler handler) throws PolicyEngineException { - setProperty(propertyFilePath, null); - this.scheme = scheme; - this.handler = handler; - if ((!"ueb".equals(notificationType.get(0)))||(!"dmaap".equals(notificationType.get(0)))){ - AutoClientEnd.setAuto(scheme, handler); - } - notification(scheme, handler); - } - - /* - * Taking the Notification Constructor. - */ - public StdPolicyEngine(String propertyFilePath, NotificationScheme scheme) throws PolicyEngineException { - setProperty(propertyFilePath, null); - this.scheme = scheme; - setScheme(scheme); - } - - /* - * sendEvent API Implementation - */ - public Collection sendEvent(Map eventAttributes, UUID requestID) throws PolicyEventException { - return sendEventImpl(eventAttributes, requestID); - } - - /* - * sendEvent API Implementation for eventRequestParameters - */ - public Collection sendEvent(EventRequestParameters eventRequestParameters) throws PolicyEventException{ - if(eventRequestParameters==null){ - String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No event Request Parameters Given. "; - LOGGER.error(message); - throw new PolicyEventException(message); - } - return sendEventImpl(eventRequestParameters.getEventAttributes(), eventRequestParameters.getRequestID()); - } - - /* - * getConfig using configRequestParameters Implementation - */ - public Collection getConfig(ConfigRequestParameters configRequestParameters) throws PolicyConfigException{ - return getConfigImpl(configRequestParameters); - } - - /* - * listPolicies using configRequestParameters Implementation - */ - public Collection listConfig(ConfigRequestParameters listPolicyRequestParameters) throws PolicyConfigException{ - return listConfigImpl(listPolicyRequestParameters); - } - - /* - * getDecision using the decision Attributes. - */ - public DecisionResponse getDecision(String eCOMPComponentName, Map decisionAttributes, UUID requestID) throws PolicyDecisionException { - return getDecisionImpl(eCOMPComponentName, decisionAttributes, requestID); - } - - /* - * getDecision Using decisionRequestParameters. - */ - public DecisionResponse getDecision(DecisionRequestParameters decisionRequestParameters) throws PolicyDecisionException{ - if(decisionRequestParameters==null){ - String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Decision Request Parameters Given. "; - LOGGER.error(message); - throw new PolicyDecisionException(message); - } - return getDecisionImpl(decisionRequestParameters.getECOMPComponentName(), decisionRequestParameters.getDecisionAttributes(), decisionRequestParameters.getRequestID()); - } - - /* - * getMetrics using metricsRequestParameters - */ - public MetricsResponse getMetrics(MetricsRequestParameters parameters) throws PolicyException{ - return getMetricsImpl(parameters); - } - - public MetricsResponse getMetricsImpl(MetricsRequestParameters parameters) throws PolicyException{ - StdMetricsResponse response = new StdMetricsResponse(); - String resource = "getMetrics"; - String body = new String(); - - // Create the Request - try { - if (parameters!=null) { - body = PolicyUtils.objectToJsonString(parameters); - } - } catch (JsonProcessingException e) { - String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; - LOGGER.error(message); - throw new PolicyException(message, e); - } - // Get Response. - try { - ResponseEntity result = callNewPDP(resource, HttpMethod.GET, body, String.class); - // Process response - response.setResponseMessage(result.getBody()); - response.setResponseCode(result.getStatusCode().value()); - } catch (PolicyException exception) { - if(exception.getCause()!=null && exception.getCause() instanceof HttpClientErrorException){ - LOGGER.error(exception); - HttpClientErrorException ex = (HttpClientErrorException) exception.getCause(); - response.setResponseCode(ex.getRawStatusCode()); - response.setResponseMessage(exception.getMessage()); - return response; - }else{ - String message = XACMLErrorConstants.ERROR_SYSTEM_ERROR+ "Error while processing results. please check logs."; - LOGGER.error(message, exception); - throw new PolicyException(message, exception); - } - } - return response; - } - - /* - * PushPolicy using pushPolicyParameters. - */ - public PolicyChangeResponse pushPolicy(PushPolicyParameters pushPolicyParameters) throws PolicyException{ - return pushPolicyImpl(pushPolicyParameters); - } - - public PolicyChangeResponse pushPolicyImpl(PushPolicyParameters pushPolicyParameters) throws PolicyException{ - StdPolicyChangeResponse response = new StdPolicyChangeResponse(); - String resource= "pushPolicy"; - String body = new String(); - // Create Request. - try { - body = PolicyUtils.objectToJsonString(pushPolicyParameters); - } catch (JsonProcessingException e) { - String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; - LOGGER.error(message); - throw new PolicyException(message, e); - } - // Get Response. - try { - ResponseEntity result = callNewPDP(resource, HttpMethod.PUT, body, String.class); - // Process response - response.setResponseMessage(result.getBody()); - response.setResponseCode(result.getStatusCode().value()); - } catch (PolicyException exception) { - return processException(exception); - } - return response; - } - - /* - * Delete a Policy using deletePolicyParameters - */ - public PolicyChangeResponse deletePolicy(DeletePolicyParameters parameters) throws PolicyException { - return deletePolicyImpl(parameters); - } - - public PolicyChangeResponse deletePolicyImpl(DeletePolicyParameters parameters) throws PolicyException { - StdPolicyChangeResponse response = new StdPolicyChangeResponse(); - String resource= "deletePolicy"; - String body = new String(); - // Create Request. - try { - body = PolicyUtils.objectToJsonString(parameters); - } catch (JsonProcessingException e) { - String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; - LOGGER.error(message); - throw new PolicyException(message, e); - } - // Get Response. - try { - ResponseEntity result = callNewPDP(resource, HttpMethod.DELETE, body, String.class); - // Process response - response.setResponseMessage(result.getBody()); - response.setResponseCode(result.getStatusCode().value()); - } catch (PolicyException exception) { - return processException(exception); - } - return response; - } - - /* - * getDictionaryItem Using dictionaryParameters - */ - public DictionaryResponse getDictionaryItem(DictionaryParameters parameters) throws PolicyException { - return getDictionaryItemImpl(parameters); - } - - public DictionaryResponse getDictionaryItemImpl(DictionaryParameters parameters) throws PolicyException{ - StdDictionaryResponse response = new StdDictionaryResponse(); - String resource="getDictionaryItems"; - String body = "{}"; - // Create Request. - try { - body = PolicyUtils.objectToJsonString(parameters); - } catch (JsonProcessingException e) { - String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; - LOGGER.error(message); - throw new PolicyException(message, e); - } - // Get Response. - try { - ResponseEntity result = callNewPDP(resource, HttpMethod.POST, body, APIDictionaryResponse.class); - // Process response - response = dictionaryResult(result.getBody()); - } catch (Exception exception) { - if(exception.getCause().getMessage().contains("401")){ - String message = XACMLErrorConstants.ERROR_PERMISSIONS + ERROR_AUTH_GET_PERM + resource; - LOGGER.error(message); - response.setResponseMessage(message); - response.setResponseCode(401); - return response; - }if(exception.getCause().getMessage().contains("400")){ - String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given."; - response.setResponseMessage(message); - response.setResponseCode(400); - return response; - } - String message = XACMLErrorConstants.ERROR_PERMISSIONS+ "Unable to get valid Response from PDP(s) " + pdps; - LOGGER.error(message, exception); - response.setResponseMessage(message); - response.setResponseCode(500); - return response; - } - return response; - } - - @SuppressWarnings("unchecked") - private StdDictionaryResponse dictionaryResult(APIDictionaryResponse body) { - StdDictionaryResponse response = new StdDictionaryResponse(); - response.setResponseCode(body.getResponseCode()); - response.setResponseMessage(body.getResponseMessage()); - response.setDictionaryData((Map) body.getDictionaryData()); - if(body.getDictionaryJson()!=null){ - Gson objGson = new GsonBuilder().create(); - String mapToJson = objGson.toJson(body.getDictionaryJson()); - JsonReader jsonReader = Json.createReader(new StringReader(mapToJson)); - JsonObject object = jsonReader.readObject(); - jsonReader.close(); - response.setDictionaryJson(object); - } - return response; - } - - /* - * createDictinaryItem Using dictionaryParameters. - */ - public PolicyChangeResponse createDictionaryItem(DictionaryParameters parameters) throws PolicyException{ - return createUpdateDictionaryItemImpl(parameters, false); - } - - /* - * updateDictinaryItem Using dictionaryParameters. - */ - public PolicyChangeResponse updateDictionaryItem(DictionaryParameters parameters) throws PolicyException{ - return createUpdateDictionaryItemImpl(parameters, true); - } - - public PolicyChangeResponse createUpdateDictionaryItemImpl(DictionaryParameters parameters, boolean updateFlag) throws PolicyException{ - StdPolicyChangeResponse response = new StdPolicyChangeResponse(); - String resource = "createDictionaryItem"; - if(updateFlag){ - resource = "updateDictionaryItem"; - } - String body = new String(); - // Create Request. - try { - body = PolicyUtils.objectToJsonString(parameters); - } catch (JsonProcessingException e) { - String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; - LOGGER.error(message); - throw new PolicyException(message, e); - } - // Get Response. - try { - ResponseEntity result = callNewPDP(resource, HttpMethod.PUT, body, String.class); - // Process response - response.setResponseMessage(result.getBody()); - response.setResponseCode(result.getStatusCode().value()); - } catch (PolicyException exception) { - return processException(exception); - } - return response; - } - - /* - * PolicyEngine Import - */ - public PolicyChangeResponse policyEngineImport(ImportParameters importParameters) throws PolicyException { - return policyEngineImportImpl(importParameters); - } - - public PolicyChangeResponse policyEngineImportImpl(ImportParameters importParameters) throws PolicyException { - StdPolicyChangeResponse response = new StdPolicyChangeResponse(); - String resource= "policyEngineImport"; - LinkedMultiValueMap parameters = new LinkedMultiValueMap(); - // Create Request. - try { - String body = PolicyUtils.objectToJsonString(importParameters); - parameters.set("importParametersJson", body); - parameters.set("file", new FileSystemResource(importParameters.getFilePath())); - } catch (Exception e) { - String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; - LOGGER.error(message); - throw new PolicyException(message, e); - } - contentType = MediaType.MULTIPART_FORM_DATA_VALUE; - // Get Response. - try { - ResponseEntity result = callNewPDP(resource, HttpMethod.POST, parameters, String.class); - // Process response - response.setResponseMessage(result.getBody()); - response.setResponseCode(result.getStatusCode().value()); - } catch (PolicyException exception) { - return processException(exception); - } finally{ - contentType = null; - } - return response; - } - - /* - * createPolicy Using policyParameters. - */ - public PolicyChangeResponse createPolicy(PolicyParameters policyParameters) throws PolicyException{ - return createUpdatePolicyImpl(policyParameters, false); - } - - /* - * updatePolicy using policyParameters. - */ - public PolicyChangeResponse updatePolicy(PolicyParameters policyParameters) throws PolicyException{ - return createUpdatePolicyImpl(policyParameters, true); - } - - public PolicyChangeResponse createUpdatePolicyImpl(PolicyParameters policyParameters, boolean updateFlag) throws PolicyException{ - StdPolicyChangeResponse response = new StdPolicyChangeResponse(); - String resource= "createPolicy"; - if(updateFlag){ - resource="updatePolicy"; - } - String body = new String(); - // Create Request. - try { - body = PolicyUtils.objectToJsonString(policyParameters); - } catch (JsonProcessingException e) { - String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; - LOGGER.error(message); - throw new PolicyException(message, e); - } - // Get Response. - try { - ResponseEntity result = callNewPDP(resource, HttpMethod.PUT, body, String.class); - // Process response - response.setResponseMessage(result.getBody()); - response.setResponseCode(result.getStatusCode().value()); - } catch (PolicyException exception) { - return processException(exception); - } - return response; - } - - private PolicyChangeResponse processException(PolicyException exception) throws PolicyException { - StdPolicyChangeResponse response = new StdPolicyChangeResponse(); - if(exception.getCause()!=null && exception.getCause() instanceof HttpClientErrorException){ - LOGGER.error(exception); - HttpClientErrorException ex = (HttpClientErrorException) exception.getCause(); - response.setResponseCode(ex.getRawStatusCode()); - response.setResponseMessage(exception.getMessage()); - return response; - }else{ - String message = XACMLErrorConstants.ERROR_SYSTEM_ERROR+ "Error while processing results. please check logs."; - LOGGER.error(message, exception); - throw new PolicyException(message, exception); - } - } - - public DecisionResponse getDecisionImpl(String eCOMPComponentName, - Map decisionAttributes, - UUID requestID) throws PolicyDecisionException { - String resource= "getDecision"; - StdDecisionResponse response = new StdDecisionResponse(); - String body = new String(); - // Create Request. - try { - DecisionRequestParameters decisionRequestParameters = new DecisionRequestParameters(); - decisionRequestParameters.setDecisionAttributes(decisionAttributes); - decisionRequestParameters.setECOMPComponentName(eCOMPComponentName); - decisionRequestParameters.setRequestID(requestID); - body = PolicyUtils.objectToJsonString(decisionRequestParameters); - } catch (JsonProcessingException e) { - String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; - LOGGER.error(message); - throw new PolicyDecisionException(message, e); - } - // Get Response. - try { - ResponseEntity result = callNewPDP(resource, HttpMethod.POST, body, StdDecisionResponse.class); - // Process response - response = result.getBody(); - } catch (Exception exception) { - if(exception.getCause().getMessage().contains("401")){ - String message = XACMLErrorConstants.ERROR_PERMISSIONS + ERROR_AUTH_GET_PERM + resource; - LOGGER.error(message); - throw new PolicyDecisionException(message, exception); - }if(exception.getCause().getMessage().contains("400")){ - String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given."; - LOGGER.error(message); - throw new PolicyDecisionException(message, exception); - } - String message = XACMLErrorConstants.ERROR_PERMISSIONS+ "Unable to get valid Response from PDP(s) " + pdps; - LOGGER.error(message, exception); - throw new PolicyDecisionException(message, exception); - } - return response; - } - - public Collection getConfigImpl(ConfigRequestParameters configRequestParameters) throws PolicyConfigException{ - String resource= "getConfig"; - ArrayList response = new ArrayList<>(); - String body = new String(); - // Create Request. - try { - body = PolicyUtils.objectToJsonString(configRequestParameters); - } catch (JsonProcessingException e) { - String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; - LOGGER.error(message); - throw new PolicyConfigException(message, e); - } - // Get Response. - try { - ResponseEntity result = callNewPDP(resource, HttpMethod.POST, body, APIPolicyConfigResponse[].class); - // Process Response - response = configResult(result.getBody()); - } catch (Exception exception) { - if(exception.getCause().getMessage().contains("401")){ - String message = XACMLErrorConstants.ERROR_PERMISSIONS + ERROR_AUTH_GET_PERM + resource; - LOGGER.error(message); - throw new PolicyConfigException(message, exception); - }if(exception.getCause().getMessage().contains("400")){ - String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given."; - LOGGER.error(message); - throw new PolicyConfigException(message, exception); - } - String message = XACMLErrorConstants.ERROR_PROCESS_FLOW+ "Unable to get valid Response from PDP(s) " + pdps; - LOGGER.error(message, exception); - throw new PolicyConfigException(message, exception); - } - return response; - } - - private ArrayList configResult(APIPolicyConfigResponse[] response) throws PolicyConfigException { - ArrayList result = new ArrayList<>(); - if(response!=null && response.length>0){ - for(APIPolicyConfigResponse policyConfigResponse: response){ - StdPolicyConfig policyConfig = new StdPolicyConfig(); - policyConfig.setConfigStatus(policyConfigResponse.getPolicyConfigMessage()); - policyConfig.setMatchingConditions(policyConfigResponse.getMatchingConditions()); - policyConfig.setPolicyConfigStatus(policyConfigResponse.getPolicyConfigStatus()); - policyConfig.setPolicyName(policyConfigResponse.getPolicyName()); - policyConfig.setPolicyType(policyConfigResponse.getType()); - policyConfig.setPolicyVersion(policyConfigResponse.getPolicyVersion()); - policyConfig.setResponseAttributes(policyConfigResponse.getResponseAttributes()); - setMatches(policyConfig.getMatchingConditions()); - if(policyConfigResponse.getType()!=null){ - try { - switch (policyConfigResponse.getType()) { - case JSON: - JsonReader jsonReader = Json.createReader(new StringReader(policyConfigResponse.getConfig())); - JsonObject object = jsonReader.readObject(); - jsonReader.close(); - policyConfig.setJsonObject(object); - break; - case OTHER: - policyConfig.setOther(policyConfigResponse.getConfig()); - break; - case PROPERTIES: - Properties props = new Properties(); - props.putAll(policyConfigResponse.getProperty()); - policyConfig.setProperties(props); - break; - case XML: - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder; - builder = factory.newDocumentBuilder(); - policyConfig.setDocument(builder.parse(new InputSource(new StringReader(policyConfigResponse.getConfig())))); - break; - } - } catch (Exception e) { - LOGGER.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID+ e); - throw new PolicyConfigException(XACMLErrorConstants.ERROR_SCHEMA_INVALID+ "Unable to parse the config", e); - } - } - result.add(policyConfig); - } - } - return result; - } - - private void setMatches(Map matchingConditions) { - Matches match = new Matches(); - HashMap configAttributes = new HashMap<>(); - try{ - for(String key: matchingConditions.keySet()){ - if(key.equalsIgnoreCase("ECOMPName")){ - match.setEcompName(matchingConditions.get(key)); - }else if(key.equalsIgnoreCase("ConfigName")){ - match.setConfigName(matchingConditions.get(key)); - }else{ - configAttributes.put(key, matchingConditions.get(key)); - } - } - if(!configAttributes.isEmpty()){ - match.setConfigAttributes(configAttributes); - } - MatchStore.storeMatch(match); - }catch(Exception e){ - LOGGER.info("StoreMatch failed for Ecomp:" - + match.getEcompName() + " Config: " - + match.getConfigName()); - } - } - - /* - * Generic Rest Client to call PDP services. - */ - private ResponseEntity callNewPDP(String resource, - HttpMethod method, Object body, Class responseType) throws PolicyException{ - RestTemplate restTemplate = new RestTemplate(); - HttpEntity requestEntity = new HttpEntity<>(body, getHeaders()); - ResponseEntity result = null; - HttpClientErrorException exception = null; - int pdpsCount = 0; - while(pdpsCount < pdps.size()){ - try{ - result = restTemplate.exchange(pdps.get(0)+"/api/" + resource, method, requestEntity, responseType); - }catch(HttpClientErrorException e){ - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while connecting to " + pdps.get(0), e); - exception = e; - }catch(Exception e){ - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while connecting to " + pdps.get(0), e); - exception = new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage()); - } - if(result == null){ - Collections.rotate(pdps, -1); - Collections.rotate(encoding, -1); - pdpsCount++; - }else{ - break; - } - } - if(exception != null && exception.getStatusCode()!=null){ - if(exception.getStatusCode().equals(HttpStatus.UNAUTHORIZED)){ - String message = XACMLErrorConstants.ERROR_PERMISSIONS +":"+exception.getStatusCode()+":" +ERROR_AUTH_GET_PERM + resource; - LOGGER.error(message); - throw new PolicyException(message, exception); - } - if(exception.getStatusCode().equals(HttpStatus.BAD_REQUEST)){ - String message = XACMLErrorConstants.ERROR_DATA_ISSUE + ":"+exception.getStatusCode()+":" + exception.getResponseBodyAsString(); - LOGGER.error(message); - throw new PolicyException(message, exception); - } - if(exception.getStatusCode().equals(HttpStatus.NOT_FOUND)){ - String message = XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while connecting to " + pdps + exception; - LOGGER.error(message); - throw new PolicyException(message, exception); - } - String message = XACMLErrorConstants.ERROR_PROCESS_FLOW + ":"+exception.getStatusCode()+":" + exception.getResponseBodyAsString(); - LOGGER.error(message); - throw new PolicyException(message, exception); - } - return result; - } - - private HttpHeaders getHeaders() { - HttpHeaders headers = new HttpHeaders(); - headers.set("ClientAuth", "Basic " + clientEncoding); - headers.set("Authorization", "Basic " + encoding.get(0)); - if(contentType!=null){ - headers.set("Content-Type", contentType.toString()); - }else{ - headers.set("Content-Type", MediaType.APPLICATION_JSON_VALUE); - } - headers.set("Environment", environment); - return headers; - } - - private void setClientEncoding() { - Base64.Encoder encoder = Base64.getEncoder(); - clientEncoding = encoder.encodeToString((userName+":"+pass).getBytes(StandardCharsets.UTF_8)); - } - - public Collection listConfigImpl(ConfigRequestParameters listRequestParameters) throws PolicyConfigException{ - Collection policyList = new ArrayList<>(); - if (junit){ - policyList.add("Policy Name: listConfigTest"); - return policyList; - } - Collection policyConfig = getConfigImpl(listRequestParameters); - for(PolicyConfig policy : policyConfig){ - if(policy.getPolicyConfigMessage()!=null && policy.getPolicyConfigMessage().contains("PE300")){ - policyList.add(policy.getPolicyConfigMessage()); - } else { - policyList.add("Policy Name: " + policy.getPolicyName()); - } - } - return policyList; - } - - public Collection sendEventImpl(Map eventAttributes, UUID requestID) throws PolicyEventException { - String resource= "sendEvent"; - ArrayList response = new ArrayList(); - String body = new String(); - // Create Request. - try { - // Long way here, can be shortened and will be done. - EventRequestParameters eventRequestParameters = new EventRequestParameters(); - eventRequestParameters.setEventAttributes(eventAttributes); - eventRequestParameters.setRequestID(requestID); - body = PolicyUtils.objectToJsonString(eventRequestParameters); - } catch (JsonProcessingException e) { - String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + e; - LOGGER.error(message); - throw new PolicyEventException(message, e); - } - // Get Response. - try { - ResponseEntity result = callNewPDP(resource, HttpMethod.POST, body, StdPolicyResponse[].class); - // Process Response - response = eventResult(result.getBody()); - } catch (Exception exception) { - if(exception.getCause().getMessage().contains("401")){ - String message = XACMLErrorConstants.ERROR_PERMISSIONS + ERROR_AUTH_GET_PERM + resource; - LOGGER.error(message); - throw new PolicyEventException(message, exception); - }if(exception.getCause().getMessage().contains("400")){ - String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given."; - LOGGER.error(message); - throw new PolicyEventException(message, exception); - } - String message = XACMLErrorConstants.ERROR_PERMISSIONS+ "Unable to get valid Response from PDP(s) " + pdps; - LOGGER.error(message, exception); - throw new PolicyEventException(message, exception); - } - return response; - } - - private ArrayList eventResult(StdPolicyResponse[] response) throws PolicyEventException{ - ArrayList eventResult = new ArrayList<>(); - if(response!=null && response.length>0){ - for(StdPolicyResponse policyConfigResponse: response){ - eventResult.add(policyConfigResponse); - } - } - return eventResult; - } - - private void setProperty(String propertyFilePath, String clientKey) - throws PolicyEngineException { - this.propertyFilePath = propertyFilePath; - if (this.propertyFilePath == null) { - throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error NO PropertyFile Path provided"); - } else { - // Adding logic for remote Properties file. - Properties prop = new Properties(); - if (propertyFilePath.startsWith("http")) { - URL configURL; - try { - configURL = new URL(propertyFilePath); - URLConnection connection = null; - connection = configURL.openConnection(); - prop.load(connection.getInputStream()); - } catch (IOException e) { - LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e); - throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Maformed property URL "+ e.getMessage()); - } - } else { - Path file = Paths.get(propertyFilePath); - if (Files.notExists(file)) { - throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "File doesn't exist in the specified Path " + file.toString()); - } - if (file.toString().endsWith(".properties")) { - InputStream in; - prop = new Properties(); - try { - in = new FileInputStream(file.toFile()); - prop.load(in); - } catch (IOException e) { - LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e); - throw new PolicyEngineException(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Cannot Load the Properties file", e); - } - } else { - LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Not a .properties file " + propertyFilePath); - throw new PolicyEngineException(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Not a .properties file"); - } - } - // UEB and DMAAP Settings - String check_type = prop.getProperty("NOTIFICATION_TYPE"); - String serverList = prop.getProperty("NOTIFICATION_SERVERS"); - topic = prop.getProperty("NOTIFICATION_TOPIC"); - apiKey = prop.getProperty("UEB_API_KEY"); - apiSecret = prop.getProperty("UEB_API_SECRET"); - - if(check_type==null) { - notificationType.add(DEFAULT_NOTIFICATION); - LOGGER.info("Properties file doesn't have the NOTIFICATION_TYPE parameter system will use defualt websockets"); - }else{ - check_type = check_type.trim(); - if(check_type.contains(",")) { - typeDefault = new ArrayList(Arrays.asList(prop.getProperty("NOTIFICATION_TYPE").split(","))); - notificationType = typeDefault; - } else { - notificationType = new ArrayList<>(); - notificationType.add(check_type); - } - } - if(serverList==null) { - notificationType.clear(); - notificationType.add(DEFAULT_NOTIFICATION); - LOGGER.info("Properties file doesn't have the NOTIFICATION_SERVERS parameter system will use defualt websockets"); - }else{ - serverList = serverList.trim(); - if(serverList.contains(",")) { - notificationURLList = new ArrayList(Arrays.asList(serverList.split(","))); - } else { - notificationURLList = new ArrayList<>(); - notificationURLList.add(serverList); - } - } - - if(topic!=null) { - topic = topic.trim(); - } else { - LOGGER.error("Properties file doesn't have the NOTIFICATION_TOPIC parameter."); - } - - // Client ID Authorization Settings. - String clientID = prop.getProperty("CLIENT_ID"); - if(clientKey==null){ - clientKey = prop.getProperty("CLIENT_KEY"); - try { - clientKey = PolicyUtils.decode(clientKey); - } catch (UnsupportedEncodingException|IllegalArgumentException e) { - LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS+" Cannot Decode the given Password Proceeding with given Password!!"); - } - } - if(clientID ==null || clientKey == null || clientID.isEmpty() || clientKey.isEmpty()){ - LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS+" Cannot proceed without the CLIENT_KEY and CLIENT_ID values !!"); - throw new PolicyEngineException(XACMLErrorConstants.ERROR_PERMISSIONS+ " Cannot proceed without the CLIENT_KEY and CLIENT_ID values !!"); - }else{ - userName = clientID.trim(); - pass = clientKey.trim(); - } - setClientEncoding(); - environment = prop.getProperty("ENVIRONMENT", AAFEnvironment.DEVL.toString()); - if(environment.equalsIgnoreCase(AAFEnvironment.TEST.toString())){ - environment = AAFEnvironment.TEST.toString(); - }else if(environment.equalsIgnoreCase(AAFEnvironment.PROD.toString())){ - environment = AAFEnvironment.PROD.toString(); - }else{ - environment = AAFEnvironment.DEVL.toString(); - } - // Initializing the values. - pdps = new ArrayList<>(); - encoding = new ArrayList<>(); - // Check the Keys for PDP_URLs - Collection unsorted = prop.keySet(); - @SuppressWarnings({ "rawtypes", "unchecked" }) - List sorted = new ArrayList(unsorted); - Collections.sort(sorted); - for (String propKey : sorted) { - if (propKey.startsWith("PDP_URL")) { - String check_val = prop.getProperty(propKey); - if (check_val == null) { - throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Properties file doesn't have the PDP_URL parameter"); - } - if (check_val.contains(";")) { - pdpDefault = new ArrayList(Arrays.asList(check_val.split("\\s*;\\s*"))); - int pdpCount = 0; - while (pdpCount < pdpDefault.size()) { - String pdpVal = pdpDefault.get(pdpCount); - readPDPParam(pdpVal); - pdpCount++; - } - } else { - readPDPParam(check_val); - } - } - } - if (pdps == null || pdps.isEmpty()) { - LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot Proceed without PDP_URLs"); - throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot Proceed without PDP_URLs"); - } - - // Get JUNIT property from properties file when running tests - String junit = prop.getProperty("JUNIT"); - if(junit == null || junit.isEmpty()){ - LOGGER.info("No JUNIT property provided, this will not be executed as a test."); - }else{ - if(junit.equalsIgnoreCase("test")){ - StdPolicyEngine.junit = true; - } else { - StdPolicyEngine.junit = false; - } - } - } - } - - /* - * Read the PDP_URL parameter - */ - private void readPDPParam(String pdpVal) throws PolicyEngineException{ - if(pdpVal.contains(",")){ - List pdpValues = new ArrayList(Arrays.asList(pdpVal.split("\\s*,\\s*"))); - if(pdpValues.size()==3){ - // 0 - PDPURL - pdps.add(pdpValues.get(0)); - // 1:2 will be UserID:Password - String userID = pdpValues.get(1); - String pass = pdpValues.get(2); - Base64.Encoder encoder = Base64.getEncoder(); - encoding.add(encoder.encodeToString((userID+":"+pass).getBytes(StandardCharsets.UTF_8))); - }else{ - LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Credentials to send Request: " + pdpValues); - throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "No enough Credentials to send Request. " + pdpValues); - } - }else{ - LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "PDP value is improper/missing required values: " + pdpVal); - throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "PDP value is improper/missing required values."); - } - } - /* - * Allowing changes to the scheme and Handler. - */ - public void notification(NotificationScheme scheme, NotificationHandler handler) { - this.scheme = scheme; - this.handler = handler; - LOGGER.debug("Scheme is : " + scheme.toString()); - LOGGER.debug("Handler is : " + handler.getClass().getName()); - - if (notificationType.get(0).equals("ueb")){ - if (this.uebThread) { - uebClientThread.setAuto(scheme, handler); - this.uebThread = registerUEBThread.isAlive(); - } - } else if (notificationType.get(0).equals("dmaap")){ - if (this.dmaapThread) { - dmaapClientThread.setAuto(scheme, handler); - this.dmaapThread = registerDMAAPThread.isAlive(); - } - } else { - AutoClientEnd.setAuto(scheme, handler); - } - - if(junit){ - return; - } - - if(pdps!=null){ - if (notificationType.get(0).equals("ueb") && !this.uebThread){ - this.uebClientThread = new AutoClientUEB(pdps.get(0), notificationURLList, apiKey, apiSecret); - this.uebClientThread.setAuto(scheme, handler); - this.registerUEBThread = new Thread(this.uebClientThread); - this.registerUEBThread.start(); - this.uebThread = true; - }else if (notificationType.get(0).equals("dmaap") && !this.dmaapThread){ - this.dmaapClientThread = new AutoClientDMAAP(notificationURLList,topic,userName,pass); - this.dmaapClientThread.setAuto(scheme, handler); - this.registerDMAAPThread = new Thread(this.dmaapClientThread); - this.registerDMAAPThread.start(); - this.dmaapThread = true; - }else{ - if(pdps.get(0)!=null){ - if(AutoClientEnd.getURL()==null){ - AutoClientEnd.start(pdps.get(0)); - }else { - AutoClientEnd.stop(); - AutoClientEnd.start(pdps.get(0)); - } - } - } - } - } - - /* - * Gets the Notification if one exists. Used only for Manual Polling - * purposes. - */ - public PDPNotification getNotification(){ - //Check if there is proper scheme.. - PDPNotification notification = null; - if(this.scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS) || this.scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) { - if (notificationType.get(0).equals("ueb")){ - ManualClientEndUEB.start(pdps.get(0), notificationURLList, UNIQUEID); - notification = ManualClientEndUEB.result(scheme); - }else if (notificationType.get(0).equals("dmaap")){ - ManualClientEndDMAAP.start(notificationURLList, topic, UNIQUEID, userName, pass); - notification = ManualClientEndDMAAP.result(scheme); - }else{ - ManualClientEnd.start(pdps.get(0)); - LOGGER.debug("manual notification requested.. : " + scheme.toString()); - notification = ManualClientEnd.result(scheme); - } - if (notification == null){ - LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Notification yet.."); - return null; - } else { - return notification; - } - }else { - return null; - } - } - - /* - * Setting the Scheme. - */ - public void setScheme(NotificationScheme scheme) { - this.scheme = scheme; - if (notificationType.get(0).equals("ueb")){ - AutoClientUEB.setScheme(this.scheme); - if (this.scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)){ - ManualClientEndUEB.createTopic(pdps.get(0), UNIQUEID, notificationURLList); - } - }else if (notificationType.get(0).equals("dmaap")){ - AutoClientDMAAP.setScheme(this.scheme); - if (this.scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)){ - ManualClientEndDMAAP.createTopic(topic, UNIQUEID, notificationURLList, userName, pass); - } - }else{ - AutoClientEnd.setScheme(this.scheme); - } - } - - /* - * Returns the Scheme - */ - public NotificationScheme getScheme() { - return this.scheme; - } - - /* - * Returns the NotificationHandler - */ - public NotificationHandler getNotificationHandler() { - return this.handler; - } - - /* - * Stop the Notification Service if its running. - */ - public void stopNotification() { - if (this.scheme != null && this.handler != null) { - if (this.scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS) - || this.scheme - .equals(NotificationScheme.AUTO_NOTIFICATIONS)) { - LOGGER.info("Clear Notification called.. "); - if (notificationType.get(0).equals("ueb")){ - this.uebClientThread.terminate(); - this.uebThread = false; - }else if (notificationType.get(0).equals("dmaap")){ - this.dmaapClientThread.terminate(); - this.dmaapThread = false; - }else{ - AutoClientEnd.stop(); - } - } - } - } - - /* - * Push a policy to the PDP API implementation - */ - public String pushPolicy(String policyScope, String policyName, String policyType, String pdpGroup, UUID requestID) throws PolicyException { - PushPolicyParameters pushPolicyParameters = new PushPolicyParameters(); - if(policyScope==null|| policyScope.trim().isEmpty()){ - String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given."; - LOGGER.error(message); - throw new PolicyException(message); - } - if(policyName==null|| policyName.trim().isEmpty()){ - String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given."; - LOGGER.error(message); - throw new PolicyException(message); - } - pushPolicyParameters.setPolicyName(policyScope+"."+policyName); - pushPolicyParameters.setPolicyType(policyType); - pushPolicyParameters.setPdpGroup(pdpGroup); - pushPolicyParameters.setRequestID(requestID); - return pushPolicyImpl(pushPolicyParameters).getResponseMessage(); - } - - public String createUpdateConfigPolicy(String policyName, String policyDescription, String ecompName, String configName, - Map configAttributes, String configType, String body, String policyScope, UUID requestID, - String riskLevel, String riskType, String guard, String ttlDate, boolean updateFlag) throws PolicyException { - return createUpdateConfigPolicyImpl(policyName, policyDescription, ecompName, configName, - configAttributes, configType, body, policyScope, requestID, - riskLevel, riskType, guard, ttlDate, updateFlag); - } - - /* - * Create Config Policy API Implementation - */ - public String createUpdateConfigPolicyImpl(String policyName, String policyDescription, String ecompName, String configName, - Map configAttributes, String configType, String body, String policyScope, UUID requestID, - String riskLevel, String riskType, String guard, String ttlDate, boolean updateFlag) throws PolicyException { - PolicyParameters policyParameters = new PolicyParameters(); - policyParameters.setPolicyClass(PolicyClass.Config); - policyParameters.setPolicyConfigType(PolicyConfigType.Base); - if(policyScope==null|| policyScope.trim().isEmpty()){ - String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given."; - LOGGER.error(message); - throw new PolicyException(message); - } - if(policyName==null|| policyName.trim().isEmpty()){ - String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given."; - LOGGER.error(message); - throw new PolicyException(message); - } - policyParameters.setPolicyName(policyScope+"."+policyName); - policyParameters.setPolicyDescription(policyDescription); - policyParameters.setEcompName(ecompName); - policyParameters.setConfigName(configName); - Map> attributes = new HashMap>(); - attributes.put(AttributeType.MATCHING, configAttributes); - policyParameters.setAttributes(attributes); - policyParameters.setConfigBodyType(PolicyType.valueOf(configType)); - policyParameters.setConfigBody(body); - policyParameters.setRequestID(requestID); - policyParameters.setRiskLevel(riskLevel); - policyParameters.setRiskType(riskType); - policyParameters.setGuard(Boolean.parseBoolean(guard)); - try { - policyParameters.setTtlDate(new SimpleDateFormat("dd-MM-yyyy").parse(ttlDate)); - } catch (ParseException e) { - LOGGER.warn("Error Parsing date given " + ttlDate); - policyParameters.setTtlDate(null); - } - return createUpdatePolicyImpl(policyParameters, updateFlag).getResponseMessage(); - } - - public String createUpdateConfigFirewallPolicy(String policyName, JsonObject firewallJson, String policyScope, UUID requestID, - String riskLevel, String riskType, String guard, String ttlDate, boolean updateFlag) throws PolicyException { - return createUpdateConfigFirewallPolicyImpl(policyName, firewallJson, policyScope, requestID, - riskLevel, riskType, guard, ttlDate, updateFlag); - } - - /* - * Create Update Config Firewall Policy API implementation - */ - public String createUpdateConfigFirewallPolicyImpl(String policyName, JsonObject firewallJson, String policyScope, UUID requestID, - String riskLevel, String riskType, String guard, String ttlDate, boolean updateFlag) throws PolicyException { - PolicyParameters policyParameters = new PolicyParameters(); - policyParameters.setPolicyClass(PolicyClass.Config); - policyParameters.setPolicyConfigType(PolicyConfigType.Firewall); - if(policyScope==null|| policyScope.trim().isEmpty()){ - String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given."; - LOGGER.error(message); - throw new PolicyException(message); - } - if(policyName==null|| policyName.trim().isEmpty()){ - String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given."; - LOGGER.error(message); - throw new PolicyException(message); - } - policyParameters.setPolicyName(policyScope+"."+policyName); - policyParameters.setConfigBody(firewallJson.toString()); - policyParameters.setRequestID(requestID); - policyParameters.setRiskLevel(riskLevel); - policyParameters.setRiskType(riskType); - policyParameters.setGuard(Boolean.parseBoolean(guard)); - try { - policyParameters.setTtlDate(new SimpleDateFormat("dd-MM-yyyy").parse(ttlDate)); - } catch (NullPointerException | ParseException e) { - LOGGER.warn("Error Parsing date given " + ttlDate); - policyParameters.setTtlDate(null); - } - return createUpdatePolicyImpl(policyParameters, updateFlag).getResponseMessage(); - } - - public void setClientKey(String clientKey){ - if(clientKey!=null && !clientKey.isEmpty()){ - StdPolicyEngine.pass = clientKey; - setClientEncoding(); - } - } - /* - * Get the Environment. - */ - public static String getEnvironment() { - return environment; - } - /* - * Rotate the PDP list upon WEBsocket Failures - */ - public static void rotatePDPList() { - Collections.rotate(pdps, -1); - Collections.rotate(encoding, -1); - } - /* - * Get the latest PDP - */ - public static String getPDPURL() { - return pdps.get(0); - } -} \ No newline at end of file diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyResponse.java deleted file mode 100644 index eed40ba2e..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyResponse.java +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - -package org.openecomp.policy.std; - -import java.util.Map; - -import org.openecomp.policy.api.PolicyResponse; -import org.openecomp.policy.api.PolicyResponseStatus; - -/** - * PolicyResponse Implementation class. - * - * @version 0.1 - * - */ -public class StdPolicyResponse implements PolicyResponse{ - private PolicyResponseStatus policyResponseStatus; - private Map actionAdvised; - private Map actionTaken; - private Map requestAttributes; - private String policyResponseMessage; - - @Override - public PolicyResponseStatus getPolicyResponseStatus() { - return policyResponseStatus; - } - - @Override - public Map getActionAdvised() { - return actionAdvised; - } - - @Override - public Map getActionTaken() { - return actionTaken; - } - - @Override - public Map getRequestAttributes() { - return requestAttributes; - } - - @Override - public String getPolicyResponseMessage() { - return policyResponseMessage; - } - - public void setPolicyResponseStatus(PolicyResponseStatus policyResponseStatus) { - this.policyResponseStatus = policyResponseStatus; - } - - public void setActionAdvised(Map actionAdvised) { - this.actionAdvised = actionAdvised; - } - - public void setActionTaken(Map actionTaken) { - this.actionTaken = actionTaken; - } - - public void setRequestAttributes(Map requestAttributes) { - this.requestAttributes = requestAttributes; - } - - public void setPolicyResponseMessage(String policyResponseMessage) { - this.policyResponseMessage = policyResponseMessage; - } - - public void setPolicyResponseStatus(String policyResponseMessage, PolicyResponseStatus policyResponseStatus) { - this.policyResponseMessage = policyResponseMessage; - this.policyResponseStatus = policyResponseStatus; - } - - @Override - public String toString() { - return "PolicyResponse [ policyResponseStatus=" + policyResponseStatus + ", policyResponseMessage=" + policyResponseMessage + ", " + - "" - + "]"; - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdStatus.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdStatus.java deleted file mode 100644 index a7d22b7cb..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdStatus.java +++ /dev/null @@ -1,235 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - -package org.openecomp.policy.std; - -import java.util.Map; -import java.util.Properties; - -import javax.json.JsonObject; - -import org.openecomp.policy.api.DecisionResponse; -import org.openecomp.policy.api.PolicyConfig; -import org.openecomp.policy.api.PolicyConfigStatus; -import org.openecomp.policy.api.PolicyDecision; -import org.openecomp.policy.api.PolicyResponse; -import org.openecomp.policy.api.PolicyResponseStatus; -import org.openecomp.policy.api.PolicyType; -import org.w3c.dom.Document; - -public class StdStatus extends StdPolicyResponse implements PolicyConfig, PolicyResponse, DecisionResponse{ - private PolicyType policyType; - private Properties properties; - private JsonObject jsonObject; - private Document document; - private String other; - private PolicyConfigStatus policyConfigStatus; - private String configStatus; - private PolicyResponseStatus policyResponseStatus; - private Map actionAdvised; - private Map actionTaken; - private Map requestAttributes; - private String policyResponseMessage; - private String policyName; - private String policyVersion; - private Map matchingConditions; - private Map responseAttributes; - private PolicyDecision policyDecision; - private String details; - - public void setStatus(String message, PolicyResponseStatus policyResponseStatus, PolicyConfigStatus policyConfigStatus) { - this.configStatus = message; - this.policyResponseMessage = message; - this.policyResponseStatus = policyResponseStatus; - this.policyConfigStatus = policyConfigStatus; - } - @Override - public PolicyResponseStatus getPolicyResponseStatus() { - return policyResponseStatus; - } - - @Override - public Map getActionAdvised() { - return actionAdvised; - } - - @Override - public Map getActionTaken() { - return actionTaken; - } - - @Override - public Map getRequestAttributes() { - return requestAttributes; - } - - @Override - public String getPolicyResponseMessage() { - return policyResponseMessage; - } - - public void setPolicyResponseStatus(PolicyResponseStatus policyResponseStatus) { - this.policyResponseStatus = policyResponseStatus; - } - - public void setActionAdvised(Map actionAdvised) { - this.actionAdvised = actionAdvised; - } - - public void setActionTaken(Map actionTaken) { - this.actionTaken = actionTaken; - } - - public void setRequestAttributes(Map requestAttributes) { - this.requestAttributes = requestAttributes; - } - - public void setPolicyResponseMessage(String policyResponseMessage) { - this.policyResponseMessage = policyResponseMessage; - } - - public void setPolicyResponseStatus(String policyResponseMessage, PolicyResponseStatus policyResponseStatus) { - this.policyResponseMessage = policyResponseMessage; - this.policyResponseStatus = policyResponseStatus; - } - - @Override - public PolicyType getType() { - return policyType; - } - - @Override - public Properties toProperties() { - return properties; - } - - @Override - public JsonObject toJSON() { - return jsonObject; - } - - @Override - public Document toXML() { - return document; - } - - @Override - public PolicyConfigStatus getPolicyConfigStatus() { - return policyConfigStatus; - } - - @Override - public String getPolicyConfigMessage() { - return configStatus; - } - - @Override - public String getPolicyName() { - if(policyName!=null && policyName.contains(".xml")){ - return (policyName.substring(0, policyName.substring(0, policyName.lastIndexOf(".")).lastIndexOf("."))); - } - return policyName; - } - - @Override - public String getPolicyVersion() { - return policyVersion; - } - - @Override - public Map getMatchingConditions(){ - return matchingConditions; - } - - @Override - public Map getResponseAttributes(){ - return responseAttributes; - } - - public void setPolicyType(PolicyType policyType) { - this.policyType = policyType; - } - - public void setProperties(Properties properties) { - this.properties = properties; - } - - public void setJsonObject(JsonObject jsonObject) { - this.jsonObject = jsonObject; - } - - public void setDocument(Document document) { - this.document = document; - } - - public void setConfigStatus(String configStatus) { - this.configStatus = configStatus; - } - - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - - public void setPolicyVersion(String policyVersion) { - this.policyVersion = policyVersion; - } - - public void setMatchingConditions(Map matchingConditions){ - this.matchingConditions = matchingConditions; - } - - public void setResposneAttributes(Map responseAttributes){ - this.responseAttributes = responseAttributes; - } - - public void setPolicyConfigStatus(PolicyConfigStatus policyConfigStatus) { - this.policyConfigStatus = policyConfigStatus; - } - - public void setPolicyConfigStatus(String configStatus, PolicyConfigStatus policyConfigStatus) { - this.policyConfigStatus = policyConfigStatus; - this.configStatus = configStatus; - } - - @Override - public String toOther() { - return other; - } - - public void setOther(String other) { - this.other = other; - } - - public PolicyDecision getDecision() { - return policyDecision; - } - public void setDecision(PolicyDecision policyDecision) { - this.policyDecision = policyDecision; - } - - public void setDetails(String details){ - this.details = details; - } - - public String getDetails(){ - return details; - } -} diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/package-info.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/package-info.java deleted file mode 100644 index a10f347e9..000000000 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std; -/** - * Provides standard implementations of the interfaces from the {@link org.openecomp.policy.api} package. - * - * @version 0.3 - * - */ diff --git a/PolicyEngineAPI/src/main/resources/logback.xml b/PolicyEngineAPI/src/main/resources/logback.xml index 098db5a54..9f725493e 100644 --- a/PolicyEngineAPI/src/main/resources/logback.xml +++ b/PolicyEngineAPI/src/main/resources/logback.xml @@ -27,7 +27,7 @@ + ::= "MSO" | "DCAE" | "ASDC " | "AAI" |"Policy" | "SDNC" | "AC" --> diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/AutoClientEndTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/AutoClientEndTest.java new file mode 100644 index 000000000..203b9f54f --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/AutoClientEndTest.java @@ -0,0 +1,228 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import static org.junit.Assert.assertNotNull; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.api.NotificationHandler; +import org.onap.policy.api.NotificationScheme; +import org.onap.policy.std.AutoClientEnd; +import org.onap.policy.std.StdPolicyEngine; + +/** + * The class AutoClientEndTest contains tests for the class {@link AutoClientEnd}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class AutoClientEndTest { + /** + * Run the AutoClientEnd() constructor test. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testAutoClientEnd_1() + throws Exception { + AutoClientEnd result = new AutoClientEnd(); + assertNotNull(result); + // add additional test code here + } + + /** + * Run the boolean getStatus() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetStatus_1() + throws Exception { + + boolean result = AutoClientEnd.getStatus(); + + assertNotNull(result); + } + + /** + * Run the String getURL() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetURL_1() + throws Exception { + + String result = AutoClientEnd.getURL(); + + // 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.AutoClientEnd + assertNotNull(result); + } + + + /** + * Run the void setAuto(NotificationScheme,NotificationHandler) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetAuto() + throws Exception { + NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS; + NotificationHandler handler = null; + + AutoClientEnd.setAuto(scheme, handler); + + // 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.AutoClientEnd.(AutoClientEnd.java:39) + } + + /** + * Run the void setScheme(NotificationScheme) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetScheme() + throws Exception { + + NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS; + AutoClientEnd.setScheme(scheme); + + } + + /** + * Run the void start(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testStart() + throws Exception { + String url = "http://test.com"; + + AutoClientEnd.start(url); + + // 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.AutoClientEnd + } + + + /** + * Run the void start(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testStart_2() + throws Exception { + String url = null; + + AutoClientEnd.start(url); + + // 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.AutoClientEnd + } + + /** + * Run the void stop() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testStop_1() + throws Exception { + + AutoClientEnd.stop(); + + // 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.AutoClientEnd + } + + /** + * 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 set up code here + StdPolicyEngine policyEngine = new StdPolicyEngine("Test/config_pass.properties", (String) null); + + NotificationHandler handler = policyEngine.getNotificationHandler(); + AutoClientEnd.setAuto(NotificationScheme.AUTO_ALL_NOTIFICATIONS, handler); + AutoClientEnd.start("http://testurl.com"); + + } + + /** + * 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(AutoClientEndTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/AutoClientUEBTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/AutoClientUEBTest.java new file mode 100644 index 000000000..94c2ac781 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/AutoClientUEBTest.java @@ -0,0 +1,567 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import java.util.LinkedList; +import java.util.List; + +import org.junit.*; +import org.onap.policy.api.NotificationHandler; +import org.onap.policy.api.NotificationScheme; +import org.onap.policy.std.AutoClientUEB; + +import static org.junit.Assert.*; + +/** + * The class AutoClientUEBTest contains tests for the class {@link AutoClientUEB}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class AutoClientUEBTest { + /** + * Run the AutoClientUEB(String,List) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testAutoClientUEB_1() + throws Exception { + String url = ""; + String apiKey = ""; + String apiSecret = ""; + List uebURLList = new LinkedList(); + + AutoClientUEB result = new AutoClientUEB(url, uebURLList, apiKey, apiSecret); + + // 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.AutoClientUEB.(AutoClientUEB.java:39) + assertNotNull(result); + } + + /** + * Run the String getNotficationType() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetNotficationType_1() + throws Exception { + + String result = AutoClientUEB.getNotficationType(); + + // 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.AutoClientUEB + assertNull(result); + } + + /** + * Run the boolean getStatus() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetStatus_1() + throws Exception { + + boolean result = AutoClientUEB.getStatus(); + + // 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.AutoClientUEB + assertFalse(result); + } + + /** + * Run the String getURL() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetURL_1() + throws Exception { + + String result = AutoClientUEB.getURL(); + + // 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.AutoClientUEB + assertNotNull(result); + } + + /** + * Run the boolean isRunning() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testIsRunning_1() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(), "", ""); + fixture.isRunning = true; + + boolean result = fixture.isRunning(); + + // 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.AutoClientUEB + assertTrue(result); + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_1() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(), "", ""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_2() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(), "", ""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_3() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(), "", ""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_4() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(), "", ""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_5() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_6() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_7() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_8() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_9() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_10() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_11() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_12() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_13() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_14() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_15() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void run() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRun_16() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); + fixture.isRunning = true; + + fixture.run(); + + // 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.AutoClientUEB + } + + /** + * Run the void setAuto(NotificationScheme,NotificationHandler) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetAuto_1() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); + fixture.isRunning = true; + NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS; + NotificationHandler handler = null; + + fixture.setAuto(scheme, handler); + + // 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.AutoClientUEB + } + + /** + * Run the void setScheme(NotificationScheme) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetScheme_1() + throws Exception { + NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS; + + AutoClientUEB.setScheme(scheme); + + // 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.AutoClientUEB + } + + /** + * Run the void terminate() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testTerminate_1() + throws Exception { + AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); + fixture.isRunning = true; + + fixture.terminate(); + + // 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.AutoClientUEB + } + + /** + * 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 set up code here + List urlList = new LinkedList(); + urlList.add("test2.com"); + AutoClientUEB client = new AutoClientUEB("test.com", urlList, "testKey", "testSecret"); + NotificationHandler handler = null; + client.setAuto(NotificationScheme.AUTO_ALL_NOTIFICATIONS, handler); + } + + /** + * 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(AutoClientUEBTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/Handler.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/Handler.java new file mode 100644 index 000000000..388ca078d --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/Handler.java @@ -0,0 +1,126 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import java.util.Collection; + +import org.onap.policy.api.LoadedPolicy; +import org.onap.policy.api.NotificationHandler; +import org.onap.policy.api.NotificationType; +import org.onap.policy.api.PDPNotification; +import org.onap.policy.api.PolicyConfig; +import org.onap.policy.api.PolicyConfigException; +import org.onap.policy.api.PolicyConfigStatus; +import org.onap.policy.api.PolicyEngine; +import org.onap.policy.api.PolicyEngineException; +import org.onap.policy.api.RemovedPolicy; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; + +public class Handler implements NotificationHandler{ + + private static final Logger LOGGER = FlexLogger.getLogger(Handler.class); + + @Override + public void notificationReceived(PDPNotification notification) { + System.out.println("Notification Received..."); + System.out.println(notification.getNotificationType()); + if(notification.getNotificationType().equals(NotificationType.REMOVE)){ + System.out.println("Removed Policies: \n"); + for(RemovedPolicy removedPolicy: notification.getRemovedPolicies()){ + System.out.println(removedPolicy.getPolicyName()); + System.out.println(removedPolicy.getVersionNo()); + } + }else if(notification.getNotificationType().equals(NotificationType.UPDATE)){ + System.out.println("Updated Policies: \n"); + for(LoadedPolicy updatedPolicy: notification.getLoadedPolicies()){ + System.out.println("policyName : " + updatedPolicy.getPolicyName()); + System.out.println("policyVersion :" + updatedPolicy.getVersionNo()); + if(updatedPolicy.getPolicyName().contains(".Config_")){ + System.out.println("Matches: " + updatedPolicy.getMatches()); + System.out.println("UpdateType: "+ updatedPolicy.getUpdateType()); + // Checking the Name is correct or not. + try { + PolicyEngine policyEngine = new PolicyEngine("config.properties"); + @SuppressWarnings("deprecation") + Collection policyConfigs = policyEngine.getConfigByPolicyName(updatedPolicy.getPolicyName()); + for(PolicyConfig policyConfig: policyConfigs){ + if(policyConfig.getPolicyConfigStatus().equals(PolicyConfigStatus.CONFIG_RETRIEVED)){ + System.out.println("Policy Retrieved with this Name notified. "); + }else{ + System.err.println("\n\n Fail to retrieve policy !!!!\n\n"); + } + // Also Test this case. + if(policyConfig.getPolicyName().equals(updatedPolicy.getPolicyName())){ + System.out.println("Policy Name is good. "); + }else{ + System.err.println("\n\n Fail to check Name \n\n"); + } + } + } catch (PolicyEngineException e) { + LOGGER.error("Exception Occured"+e); + } catch (PolicyConfigException e) { + LOGGER.error("Exception Occured"+e); + } + } + } + }else if(notification.getNotificationType().equals(NotificationType.BOTH)){ + System.out.println("Both updated and Removed Notification: \n"); + System.out.println("Removed Policies: \n"); + for(RemovedPolicy removedPolicy: notification.getRemovedPolicies()){ + System.out.println(removedPolicy.getPolicyName()); + System.out.println(removedPolicy.getVersionNo()); + } + System.out.println("Updated Policies: \n"); + for(LoadedPolicy updatedPolicy: notification.getLoadedPolicies()){ + System.out.println("policyName : " + updatedPolicy.getPolicyName()); + System.out.println("policyVersion :" + updatedPolicy.getVersionNo()); + System.out.println("Matches: " + updatedPolicy.getMatches()); + System.out.println("UpdateType: "+ updatedPolicy.getUpdateType()); + // Checking the Name is correct or not. + try { + PolicyEngine policyEngine = new PolicyEngine("config.properties"); + @SuppressWarnings("deprecation") + Collection policyConfigs = policyEngine.getConfigByPolicyName(updatedPolicy.getPolicyName()); + for(PolicyConfig policyConfig: policyConfigs){ + if(policyConfig.getPolicyConfigStatus().equals(PolicyConfigStatus.CONFIG_RETRIEVED)){ + System.out.println("Policy Retrieved with this Name notified. "); + }else{ + System.err.println("\n\n Fail to retrieve policy !!!!\n\n"); + } + // Also Test this case. + if(policyConfig.getPolicyName().equals(updatedPolicy.getPolicyName())){ + System.out.println("Policy Name is good. "); + }else{ + System.err.println("\n\n Fail to check Name \n\n"); + } + } + } catch (PolicyEngineException e) { + LOGGER.error("Exception Occured"+e); + } catch (PolicyConfigException e) { + LOGGER.error("Exception Occured"+e); + } + } + } + } + + +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndTest.java new file mode 100644 index 000000000..2ae522c1d --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndTest.java @@ -0,0 +1,126 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.api.NotificationScheme; +import org.onap.policy.api.PDPNotification; +import org.onap.policy.std.ManualClientEnd; + +/** + * The class ManualClientEndTest contains tests for the class {@link ManualClientEnd}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class ManualClientEndTest { + /** + * Run the ManualClientEnd() constructor test. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testManualClientEnd_1() + throws Exception { + ManualClientEnd result = new ManualClientEnd(); + assertNotNull(result); + // add additional test code here + } + + + /** + * Run the PDPNotification result(NotificationScheme) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testResult_1() + throws Exception { + NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS; + + PDPNotification result = ManualClientEnd.result(scheme); + + assertNull(result); + } + + + /** + * Run the void start(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testStart_1() + throws Exception { + String url = ""; + + ManualClientEnd.start(url); + + } + + /** + * 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(ManualClientEndTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndUEBTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndUEBTest.java new file mode 100644 index 000000000..77b0c6f49 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndUEBTest.java @@ -0,0 +1,119 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.util.LinkedList; +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.api.NotificationScheme; +import org.onap.policy.api.PDPNotification; +import org.onap.policy.std.ManualClientEndUEB; +import org.onap.policy.std.StdPDPNotification; + +/** + * The class ManualClientEndUEBTest contains tests for the class {@link ManualClientEndUEB}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class ManualClientEndUEBTest { + + String resultJson = "{'test':'testing'}"; + String json = "{\"test\":\"testing\"}"; + StdPDPNotification notification = new StdPDPNotification(); + ManualClientEndUEB mockManualClient = null; + /** + * 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 { + String url = "http://test.com"; + List uebURLList = new LinkedList(); + uebURLList.add(url); + + } + /** + * Run the ManualClientEndUEB() constructor test. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testManualClientEndUEB_1() + throws Exception { + ManualClientEndUEB result = new ManualClientEndUEB(); + assertNotNull(result); + // add additional test code here + } + + /** + * Run the PDPNotification result(NotificationScheme) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testResult_1() + throws Exception { + NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS; + + PDPNotification result = ManualClientEndUEB.result(scheme); + + assertNull(result); + } + + /** + * 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(ManualClientEndUEBTest.class); + } +} 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 new file mode 100644 index 000000000..856474dd8 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchStoreTest.java @@ -0,0 +1,776 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.util.HashSet; +import java.util.Hashtable; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.api.PDPNotification; +import org.onap.policy.std.MatchStore; +import org.onap.policy.std.Matches; +import org.onap.policy.std.StdPDPNotification; + +/** + * The class MatchStoreTest contains tests for the class {@link MatchStore}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class MatchStoreTest { + /** + * Run the MatchStore() constructor test. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testMatchStore_1() + throws Exception { + MatchStore result = new MatchStore(); + assertNotNull(result); + // add additional test code here + } + + /** + * 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 getMatchStore() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetMatchStore_1() + throws Exception { + + HashSet 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.(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()); + 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()); + 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()); + 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()); + 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()); + 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()); + 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()); + 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()); + 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()); + 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); + } +} 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 new file mode 100644 index 000000000..f71d93cb8 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchesTest.java @@ -0,0 +1,216 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import java.util.Hashtable; +import java.util.Map; + +import org.junit.*; +import org.onap.policy.std.Matches; + +import static org.junit.Assert.*; + +/** + * The class MatchesTest contains tests for the class {@link Matches}. + * + * @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 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()); + fixture.setConfigName(""); + + Map 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()); + 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()); + fixture.setConfigName(""); + + String result = fixture.getOnapName(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the void setConfigAttributes(Map) 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()); + fixture.setConfigName(""); + Map configAttributes = new Hashtable(); + + 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()); + 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()); + 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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationStoreTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationStoreTest.java new file mode 100644 index 000000000..ed7383e1a --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationStoreTest.java @@ -0,0 +1,359 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import org.junit.*; +import org.onap.policy.std.NotificationStore; +import org.onap.policy.std.StdPDPNotification; + +import static org.junit.Assert.*; + +/** + * The class NotificationStoreTest contains tests for the class {@link NotificationStore}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class NotificationStoreTest { + /** + * Run the NotificationStore() constructor test. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testNotificationStore_1() + throws Exception { + NotificationStore result = new NotificationStore(); + assertNotNull(result); + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_1() + throws Exception { + StdPDPNotification notification = new StdPDPNotification(); + + NotificationStore.recordNotification(notification); + + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_2() + throws Exception { + StdPDPNotification notification = new StdPDPNotification(); + + NotificationStore.recordNotification(notification); + + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_3() + throws Exception { + StdPDPNotification notification = new StdPDPNotification(); + + NotificationStore.recordNotification(notification); + + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_4() + throws Exception { + StdPDPNotification notification = new StdPDPNotification(); + + NotificationStore.recordNotification(notification); + + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_5() + throws Exception { + StdPDPNotification notification = new StdPDPNotification(); + + NotificationStore.recordNotification(notification); + + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_6() + throws Exception { + StdPDPNotification notification = new StdPDPNotification(); + + NotificationStore.recordNotification(notification); + + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_7() + throws Exception { + StdPDPNotification notification = new StdPDPNotification(); + + NotificationStore.recordNotification(notification); + + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_8() + throws Exception { + StdPDPNotification notification = new StdPDPNotification(); + + NotificationStore.recordNotification(notification); + + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_9() + throws Exception { + StdPDPNotification notification = new StdPDPNotification(); + + NotificationStore.recordNotification(notification); + + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_10() + throws Exception { + StdPDPNotification notification = new StdPDPNotification(); + + NotificationStore.recordNotification(notification); + + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_11() + throws Exception { + StdPDPNotification notification = new StdPDPNotification(); + + NotificationStore.recordNotification(notification); + + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_12() + throws Exception { + StdPDPNotification notification = new StdPDPNotification(); + + NotificationStore.recordNotification(notification); + + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_13() + throws Exception { + StdPDPNotification notification = new StdPDPNotification(); + + NotificationStore.recordNotification(notification); + + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_14() + throws Exception { + StdPDPNotification notification = new StdPDPNotification(); + + NotificationStore.recordNotification(notification); + + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_15() + throws Exception { + StdPDPNotification notification = new StdPDPNotification(); + + NotificationStore.recordNotification(notification); + + // add additional test code here + } + + /** + * Run the void recordNotification(StdPDPNotification) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testRecordNotification_16() + throws Exception { + StdPDPNotification notification = null; + + NotificationStore.recordNotification(notification); + + // 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(NotificationStoreTest.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 new file mode 100644 index 000000000..fb42f98aa --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationUnMarshalTest.java @@ -0,0 +1,256 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import static org.junit.Assert.assertNotNull; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.std.NotificationUnMarshal; +import org.onap.policy.std.StdPDPNotification; + +/** + * The class NotificationUnMarshalTest contains tests for the class {@link NotificationUnMarshal}. + * + * @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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdLoadedPolicyTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdLoadedPolicyTest.java new file mode 100644 index 000000000..c45a5aca7 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdLoadedPolicyTest.java @@ -0,0 +1,314 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import java.util.Hashtable; +import java.util.Map; + +import org.junit.*; +import org.onap.policy.api.UpdateType; +import org.onap.policy.std.StdLoadedPolicy; + +import static org.junit.Assert.*; + +/** + * The class StdLoadedPolicyTest contains tests for the class {@link StdLoadedPolicy}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class StdLoadedPolicyTest { + /** + * Run the StdLoadedPolicy() constructor test. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testStdLoadedPolicy_1() + throws Exception { + StdLoadedPolicy result = new StdLoadedPolicy(); + assertNotNull(result); + // add additional test code here + } + + /** + * Run the Map getMatches() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetMatches_1() + throws Exception { + StdLoadedPolicy fixture = new StdLoadedPolicy(); + fixture.setPolicyName(""); + fixture.setVersionNo(""); + fixture.setUpdateType(UpdateType.NEW); + fixture.setMatches(new Hashtable()); + + Map result = fixture.getMatches(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the String getPolicyName() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetPolicyName_1() + throws Exception { + StdLoadedPolicy fixture = new StdLoadedPolicy(); + fixture.setPolicyName(""); + fixture.setVersionNo(""); + fixture.setUpdateType(UpdateType.NEW); + fixture.setMatches(new Hashtable()); + + 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:40 PM + */ + @Test + public void testGetPolicyName_2() + throws Exception { + StdLoadedPolicy fixture = new StdLoadedPolicy(); + fixture.setPolicyName((String) null); + fixture.setVersionNo(""); + fixture.setUpdateType(UpdateType.NEW); + fixture.setMatches(new Hashtable()); + + 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:40 PM + */ + @Test + public void testGetPolicyName_3() + throws Exception { + StdLoadedPolicy fixture = new StdLoadedPolicy(); + fixture.setPolicyName(""); + fixture.setVersionNo(""); + fixture.setUpdateType(UpdateType.NEW); + fixture.setMatches(new Hashtable()); + + String result = fixture.getPolicyName(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the UpdateType getUpdateType() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetUpdateType_1() + throws Exception { + StdLoadedPolicy fixture = new StdLoadedPolicy(); + fixture.setPolicyName(""); + fixture.setVersionNo(""); + fixture.setUpdateType(UpdateType.NEW); + fixture.setMatches(new Hashtable()); + + UpdateType result = fixture.getUpdateType(); + + // add additional test code here + assertNotNull(result); + assertEquals("new", result.toString()); + assertEquals("NEW", result.name()); + assertEquals(1, result.ordinal()); + } + + /** + * Run the String getVersionNo() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetVersionNo_1() + throws Exception { + StdLoadedPolicy fixture = new StdLoadedPolicy(); + fixture.setPolicyName(""); + fixture.setVersionNo(""); + fixture.setUpdateType(UpdateType.NEW); + fixture.setMatches(new Hashtable()); + + String result = fixture.getVersionNo(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the void setMatches(Map) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetMatches_1() + throws Exception { + StdLoadedPolicy fixture = new StdLoadedPolicy(); + fixture.setPolicyName(""); + fixture.setVersionNo(""); + fixture.setUpdateType(UpdateType.NEW); + fixture.setMatches(new Hashtable()); + Map matches = new Hashtable(); + + fixture.setMatches(matches); + + // 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 { + StdLoadedPolicy fixture = new StdLoadedPolicy(); + fixture.setPolicyName(""); + fixture.setVersionNo(""); + fixture.setUpdateType(UpdateType.NEW); + fixture.setMatches(new Hashtable()); + String policyName = ""; + + fixture.setPolicyName(policyName); + + // add additional test code here + } + + /** + * Run the void setUpdateType(UpdateType) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetUpdateType_1() + throws Exception { + StdLoadedPolicy fixture = new StdLoadedPolicy(); + fixture.setPolicyName(""); + fixture.setVersionNo(""); + fixture.setUpdateType(UpdateType.NEW); + fixture.setMatches(new Hashtable()); + UpdateType updateType = UpdateType.NEW; + + fixture.setUpdateType(updateType); + + // add additional test code here + } + + /** + * Run the void setVersionNo(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetVersionNo_1() + throws Exception { + StdLoadedPolicy fixture = new StdLoadedPolicy(); + fixture.setPolicyName(""); + fixture.setVersionNo(""); + fixture.setUpdateType(UpdateType.NEW); + fixture.setMatches(new Hashtable()); + String versionNo = ""; + + fixture.setVersionNo(versionNo); + + // 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(StdLoadedPolicyTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPDPNotificationTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPDPNotificationTest.java new file mode 100644 index 000000000..6a558006d --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPDPNotificationTest.java @@ -0,0 +1,311 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import java.util.Collection; +import java.util.LinkedList; + +import org.junit.*; +import org.onap.policy.api.LoadedPolicy; +import org.onap.policy.api.NotificationType; +import org.onap.policy.api.RemovedPolicy; +import org.onap.policy.std.StdLoadedPolicy; +import org.onap.policy.std.StdPDPNotification; +import org.onap.policy.std.StdRemovedPolicy; + +import static org.junit.Assert.*; + +/** + * The class StdPDPNotificationTest contains tests for the class {@link StdPDPNotification}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class StdPDPNotificationTest { + /** + * Run the StdPDPNotification() constructor test. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testStdPDPNotification_1() + throws Exception { + StdPDPNotification result = new StdPDPNotification(); + assertNotNull(result); + // add additional test code here + } + + /** + * Run the Collection getLoadedPolicies() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetLoadedPolicies_1() + throws Exception { + StdPDPNotification fixture = new StdPDPNotification(); + fixture.setRemovedPolicies(new LinkedList()); + fixture.setNotificationType(NotificationType.BOTH); + fixture.setLoadedPolicies(new LinkedList()); + + Collection result = fixture.getLoadedPolicies(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the Collection getLoadedPolicies() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetLoadedPolicies_2() + throws Exception { + StdPDPNotification fixture = new StdPDPNotification(); + fixture.setRemovedPolicies(new LinkedList()); + fixture.setNotificationType(NotificationType.BOTH); + fixture.setLoadedPolicies(new LinkedList()); + + Collection result = fixture.getLoadedPolicies(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the Collection getLoadedPolicies() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetLoadedPolicies_3() + throws Exception { + StdPDPNotification fixture = new StdPDPNotification(); + fixture.setRemovedPolicies(new LinkedList()); + fixture.setNotificationType(NotificationType.BOTH); + fixture.setLoadedPolicies(null); + + Collection result = fixture.getLoadedPolicies(); + + // add additional test code here + assertEquals(null, result); + } + + /** + * Run the NotificationType getNotificationType() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetNotificationType_1() + throws Exception { + StdPDPNotification fixture = new StdPDPNotification(); + fixture.setRemovedPolicies(new LinkedList()); + fixture.setNotificationType(NotificationType.BOTH); + fixture.setLoadedPolicies(new LinkedList()); + + NotificationType result = fixture.getNotificationType(); + + // add additional test code here + assertNotNull(result); + assertEquals("both", result.toString()); + assertEquals("BOTH", result.name()); + assertEquals(2, result.ordinal()); + } + + /** + * Run the Collection getRemovedPolicies() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetRemovedPolicies_1() + throws Exception { + StdPDPNotification fixture = new StdPDPNotification(); + fixture.setRemovedPolicies(new LinkedList()); + fixture.setNotificationType(NotificationType.BOTH); + fixture.setLoadedPolicies(new LinkedList()); + + Collection result = fixture.getRemovedPolicies(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the Collection getRemovedPolicies() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetRemovedPolicies_2() + throws Exception { + StdPDPNotification fixture = new StdPDPNotification(); + fixture.setRemovedPolicies(new LinkedList()); + fixture.setNotificationType(NotificationType.BOTH); + fixture.setLoadedPolicies(new LinkedList()); + + Collection result = fixture.getRemovedPolicies(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the Collection getRemovedPolicies() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetRemovedPolicies_3() + throws Exception { + StdPDPNotification fixture = new StdPDPNotification(); + fixture.setRemovedPolicies(null); + fixture.setNotificationType(NotificationType.BOTH); + fixture.setLoadedPolicies(new LinkedList()); + + Collection result = fixture.getRemovedPolicies(); + + // add additional test code here + assertEquals(null, result); + } + + /** + * Run the void setNotificationType(NotificationType) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetNotificationType_1() + throws Exception { + StdPDPNotification fixture = new StdPDPNotification(); + fixture.setRemovedPolicies(new LinkedList()); + fixture.setNotificationType(NotificationType.BOTH); + fixture.setLoadedPolicies(new LinkedList()); + NotificationType notificationType = NotificationType.BOTH; + + fixture.setNotificationType(notificationType); + + // add additional test code here + } + + /** + * Run the void setRemovedPolicies(Collection) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetRemovedPolicies_1() + throws Exception { + StdPDPNotification fixture = new StdPDPNotification(); + fixture.setRemovedPolicies(new LinkedList()); + fixture.setNotificationType(NotificationType.BOTH); + fixture.setLoadedPolicies(new LinkedList()); + Collection removedPolicies = new LinkedList(); + + fixture.setRemovedPolicies(removedPolicies); + + // add additional test code here + } + + /** + * Run the void setUpdatedPolicies(Collection) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetUpdatedPolicies_1() + throws Exception { + StdPDPNotification fixture = new StdPDPNotification(); + fixture.setRemovedPolicies(new LinkedList()); + fixture.setNotificationType(NotificationType.BOTH); + fixture.setLoadedPolicies(new LinkedList()); + Collection updatedPolicies = new LinkedList(); + + fixture.setLoadedPolicies(updatedPolicies); + + // 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(StdPDPNotificationTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyChangeResponseTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyChangeResponseTest.java new file mode 100644 index 000000000..5ce53d133 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyChangeResponseTest.java @@ -0,0 +1,166 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import org.junit.*; +import org.onap.policy.std.StdPolicyChangeResponse; + +import static org.junit.Assert.*; + +/** + * The class StdPolicyChangeResponseTest contains tests for the class {@link StdPolicyChangeResponse}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class StdPolicyChangeResponseTest { + /** + * Run the StdPolicyChangeResponse() constructor test. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testStdPolicyChangeResponse_1() + throws Exception { + StdPolicyChangeResponse result = new StdPolicyChangeResponse(); + assertNotNull(result); + // add additional test code here + } + + /** + * Run the int getResponseCode() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetResponseCode_1() + throws Exception { + StdPolicyChangeResponse fixture = new StdPolicyChangeResponse(); + fixture.setResponseMessage(""); + fixture.setResponseCode(1); + + int result = fixture.getResponseCode(); + + // add additional test code here + assertEquals(1, result); + } + + /** + * Run the String getResponseMessage() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetResponseMessage_1() + throws Exception { + StdPolicyChangeResponse fixture = new StdPolicyChangeResponse(); + fixture.setResponseMessage(""); + fixture.setResponseCode(1); + + String result = fixture.getResponseMessage(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the void setResponseCode(int) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetResponseCode_1() + throws Exception { + StdPolicyChangeResponse fixture = new StdPolicyChangeResponse(); + fixture.setResponseMessage(""); + fixture.setResponseCode(1); + int responseCode = 1; + + fixture.setResponseCode(responseCode); + + // add additional test code here + } + + /** + * Run the void setResponseMessage(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetResponseMessage_1() + throws Exception { + StdPolicyChangeResponse fixture = new StdPolicyChangeResponse(); + fixture.setResponseMessage(""); + fixture.setResponseCode(1); + String responseMessage = ""; + + fixture.setResponseMessage(responseMessage); + + // 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(StdPolicyChangeResponseTest.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 new file mode 100644 index 000000000..736f51b57 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyConfigTest.java @@ -0,0 +1,821 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import java.util.Hashtable; +import java.util.Map; +import java.util.Properties; + +import javax.json.JsonObject; + +import org.junit.*; +import org.onap.policy.api.PolicyConfigStatus; +import org.onap.policy.api.PolicyType; +import org.onap.policy.std.StdPolicyConfig; + +import static org.junit.Assert.*; + +import org.w3c.dom.Document; + +/** + * The class StdPolicyConfigTest contains tests for the class {@link StdPolicyConfig}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class StdPolicyConfigTest { + /** + * Run the Map 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + + Map 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + + 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()); + 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 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + + String result = fixture.getPolicyVersion(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the Map 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + + Map 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + JsonObject jsonObject = null; + + fixture.setJsonObject(jsonObject); + + // add additional test code here + } + + /** + * Run the void setMatchingConditions(Map) 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + Map matchingConditions = new Hashtable(); + + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + Properties properties = new Properties(); + + fixture.setProperties(properties); + + // add additional test code here + } + + /** + * Run the void setResponseAttributes(Map) 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + Map responseAttributes = new Hashtable(); + + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName("test"); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + + 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()); + fixture.setPolicyVersion(""); + fixture.setOther(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setPolicyName(""); + fixture.setProperties(new Properties()); + fixture.setJsonObject((JsonObject) null); + fixture.setMatchingConditions(new Hashtable()); + + 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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyResponseTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyResponseTest.java new file mode 100644 index 000000000..11179aece --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyResponseTest.java @@ -0,0 +1,348 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import java.util.Hashtable; +import java.util.Map; + +import org.junit.*; +import org.onap.policy.api.PolicyResponseStatus; +import org.onap.policy.std.StdPolicyResponse; + +import static org.junit.Assert.*; + +/** + * The class StdPolicyResponseTest contains tests for the class {@link StdPolicyResponse}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class StdPolicyResponseTest { + /** + * Run the Map getActionAdvised() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetActionAdvised_1() + throws Exception { + StdPolicyResponse fixture = new StdPolicyResponse(); + fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); + fixture.setRequestAttributes(new Hashtable()); + fixture.setActionAdvised(new Hashtable()); + fixture.setActionTaken(new Hashtable()); + + Map result = fixture.getActionAdvised(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the Map getActionTaken() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetActionTaken_1() + throws Exception { + StdPolicyResponse fixture = new StdPolicyResponse(); + fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); + fixture.setRequestAttributes(new Hashtable()); + fixture.setActionAdvised(new Hashtable()); + fixture.setActionTaken(new Hashtable()); + + Map result = fixture.getActionTaken(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the String getPolicyResponseMessage() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetPolicyResponseMessage_1() + throws Exception { + StdPolicyResponse fixture = new StdPolicyResponse(); + fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); + fixture.setRequestAttributes(new Hashtable()); + fixture.setActionAdvised(new Hashtable()); + fixture.setActionTaken(new Hashtable()); + + String result = fixture.getPolicyResponseMessage(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the PolicyResponseStatus getPolicyResponseStatus() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetPolicyResponseStatus_1() + throws Exception { + StdPolicyResponse fixture = new StdPolicyResponse(); + fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); + fixture.setRequestAttributes(new Hashtable()); + fixture.setActionAdvised(new Hashtable()); + fixture.setActionTaken(new Hashtable()); + + PolicyResponseStatus result = fixture.getPolicyResponseStatus(); + + // add additional test code here + assertNotNull(result); + assertEquals("action_advised", result.toString()); + assertEquals("ACTION_ADVISED", result.name()); + assertEquals(1, result.ordinal()); + } + + /** + * Run the Map getRequestAttributes() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetRequestAttributes_1() + throws Exception { + StdPolicyResponse fixture = new StdPolicyResponse(); + fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); + fixture.setRequestAttributes(new Hashtable()); + fixture.setActionAdvised(new Hashtable()); + fixture.setActionTaken(new Hashtable()); + + Map result = fixture.getRequestAttributes(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the void setActionAdvised(Map) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetActionAdvised_1() + throws Exception { + StdPolicyResponse fixture = new StdPolicyResponse(); + fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); + fixture.setRequestAttributes(new Hashtable()); + fixture.setActionAdvised(new Hashtable()); + fixture.setActionTaken(new Hashtable()); + Map actionAdvised = new Hashtable(); + + fixture.setActionAdvised(actionAdvised); + + // add additional test code here + } + + /** + * Run the void setActionTaken(Map) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetActionTaken_1() + throws Exception { + StdPolicyResponse fixture = new StdPolicyResponse(); + fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); + fixture.setRequestAttributes(new Hashtable()); + fixture.setActionAdvised(new Hashtable()); + fixture.setActionTaken(new Hashtable()); + Map actionTaken = new Hashtable(); + + fixture.setActionTaken(actionTaken); + + // add additional test code here + } + + /** + * Run the void setPolicyResponseMessage(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetPolicyResponseMessage_1() + throws Exception { + StdPolicyResponse fixture = new StdPolicyResponse(); + fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); + fixture.setRequestAttributes(new Hashtable()); + fixture.setActionAdvised(new Hashtable()); + fixture.setActionTaken(new Hashtable()); + String policyResponseMessage = ""; + + fixture.setPolicyResponseMessage(policyResponseMessage); + + // add additional test code here + } + + /** + * Run the void setPolicyResponseStatus(PolicyResponseStatus) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetPolicyResponseStatus_1() + throws Exception { + StdPolicyResponse fixture = new StdPolicyResponse(); + fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); + fixture.setRequestAttributes(new Hashtable()); + fixture.setActionAdvised(new Hashtable()); + fixture.setActionTaken(new Hashtable()); + PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED; + + fixture.setPolicyResponseStatus(policyResponseStatus); + + // add additional test code here + } + + /** + * Run the void setPolicyResponseStatus(String,PolicyResponseStatus) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetPolicyResponseStatus_2() + throws Exception { + StdPolicyResponse fixture = new StdPolicyResponse(); + fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); + fixture.setRequestAttributes(new Hashtable()); + fixture.setActionAdvised(new Hashtable()); + fixture.setActionTaken(new Hashtable()); + String policyResponseMessage = ""; + PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED; + + fixture.setPolicyResponseStatus(policyResponseMessage, policyResponseStatus); + + // add additional test code here + } + + /** + * Run the void setRequestAttributes(Map) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetRequestAttributes_1() + throws Exception { + StdPolicyResponse fixture = new StdPolicyResponse(); + fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); + fixture.setRequestAttributes(new Hashtable()); + fixture.setActionAdvised(new Hashtable()); + fixture.setActionTaken(new Hashtable()); + Map requestAttributes = new Hashtable(); + + fixture.setRequestAttributes(requestAttributes); + + // add additional test code here + } + + /** + * Run the String toString() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testToString_1() + throws Exception { + StdPolicyResponse fixture = new StdPolicyResponse(); + fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); + fixture.setRequestAttributes(new Hashtable()); + fixture.setActionAdvised(new Hashtable()); + fixture.setActionTaken(new Hashtable()); + + String result = fixture.toString(); + + // add additional test code here + assertEquals("PolicyResponse [ policyResponseStatus=action_advised, policyResponseMessage=, ]", 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(StdPolicyResponseTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdRemovedPolicyTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdRemovedPolicyTest.java new file mode 100644 index 000000000..2482c3015 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdRemovedPolicyTest.java @@ -0,0 +1,206 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import org.junit.*; +import org.onap.policy.std.StdRemovedPolicy; + +import static org.junit.Assert.*; + +/** + * The class StdRemovedPolicyTest contains tests for the class {@link StdRemovedPolicy}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class StdRemovedPolicyTest { + /** + * Run the StdRemovedPolicy() constructor test. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testStdRemovedPolicy_1() + throws Exception { + StdRemovedPolicy result = new StdRemovedPolicy(); + assertNotNull(result); + // add additional test code here + } + + /** + * Run the String getPolicyName() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetPolicyName_1() + throws Exception { + StdRemovedPolicy fixture = new StdRemovedPolicy(); + fixture.setVersionNo(""); + fixture.setPolicyName(""); + + 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:40 PM + */ + @Test + public void testGetPolicyName_2() + throws Exception { + StdRemovedPolicy fixture = new StdRemovedPolicy(); + fixture.setVersionNo(""); + fixture.setPolicyName((String) null); + + 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:40 PM + */ + @Test + public void testGetPolicyName_3() + throws Exception { + StdRemovedPolicy fixture = new StdRemovedPolicy(); + fixture.setVersionNo(""); + fixture.setPolicyName(""); + + String result = fixture.getPolicyName(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the String getVersionNo() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetVersionNo_1() + throws Exception { + StdRemovedPolicy fixture = new StdRemovedPolicy(); + fixture.setVersionNo(""); + fixture.setPolicyName(""); + + String result = fixture.getVersionNo(); + + // add additional test code here + assertEquals("", result); + } + + /** + * 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 { + StdRemovedPolicy fixture = new StdRemovedPolicy(); + fixture.setVersionNo(""); + fixture.setPolicyName(""); + String policyName = ""; + + fixture.setPolicyName(policyName); + + // add additional test code here + } + + /** + * Run the void setVersionNo(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetVersionNo_1() + throws Exception { + StdRemovedPolicy fixture = new StdRemovedPolicy(); + fixture.setVersionNo(""); + fixture.setPolicyName(""); + String versionNo = ""; + + fixture.setVersionNo(versionNo); + + // 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(StdRemovedPolicyTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdStatusTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdStatusTest.java new file mode 100644 index 000000000..b72d2568d --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdStatusTest.java @@ -0,0 +1,1433 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.std.test; + +import java.util.Hashtable; +import java.util.Map; +import java.util.Properties; + +import javax.json.JsonObject; + +import org.junit.*; +import org.onap.policy.api.PolicyConfigStatus; +import org.onap.policy.api.PolicyDecision; +import org.onap.policy.api.PolicyResponseStatus; +import org.onap.policy.api.PolicyType; +import org.onap.policy.std.StdStatus; + +import static org.junit.Assert.*; + +import org.w3c.dom.Document; + +/** + * The class StdStatusTest contains tests for the class {@link StdStatus}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class StdStatusTest { + /** + * Run the Map getActionAdvised() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetActionAdvised_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + Map result = fixture.getActionAdvised(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the Map getActionTaken() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetActionTaken_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + Map result = fixture.getActionTaken(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the Map getMatchingConditions() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetMatchingConditions_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + Map 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:40 PM + */ + @Test + public void testGetPolicyConfigMessage_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + 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:40 PM + */ + @Test + public void testGetPolicyConfigStatus_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + 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 PolicyDecision getPolicyDecision() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetPolicyDecision_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + PolicyDecision result = fixture.getDecision(); + + // add additional test code here + assertNotNull(result); + assertEquals("deny", result.toString()); + assertEquals("DENY", result.name()); + assertEquals(1, result.ordinal()); + } + + /** + * Run the String getPolicyName() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetPolicyName_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + 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:40 PM + */ + @Test + public void testGetPolicyName_2() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName((String) null); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + 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:40 PM + */ + @Test + public void testGetPolicyName_3() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + String result = fixture.getPolicyName(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the String getPolicyResponseMessage() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetPolicyResponseMessage_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + String result = fixture.getPolicyResponseMessage(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the PolicyResponseStatus getPolicyResponseStatus() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetPolicyResponseStatus_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + PolicyResponseStatus result = fixture.getPolicyResponseStatus(); + + // add additional test code here + assertNotNull(result); + assertEquals("action_advised", result.toString()); + assertEquals("ACTION_ADVISED", result.name()); + assertEquals(1, result.ordinal()); + } + + /** + * Run the String getPolicyVersion() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetPolicyVersion_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + String result = fixture.getPolicyVersion(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the Map getRequestAttributes() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetRequestAttributes_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + Map result = fixture.getRequestAttributes(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the Map getResponseAttributes() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetResponseAttributes_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + Map 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:40 PM + */ + @Test + public void testGetType_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + 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 setActionAdvised(Map) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetActionAdvised_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + Map actionAdvised = new Hashtable(); + + fixture.setActionAdvised(actionAdvised); + + // add additional test code here + } + + /** + * Run the void setActionTaken(Map) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetActionTaken_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + Map actionTaken = new Hashtable(); + + fixture.setActionTaken(actionTaken); + + // add additional test code here + } + + /** + * Run the void setConfigStatus(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetConfigStatus_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + String configStatus = ""; + + fixture.setConfigStatus(configStatus); + + // add additional test code here + } + + /** + * Run the void setDocument(Document) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetDocument_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + 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:40 PM + */ + @Test + public void testSetJsonObject_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + JsonObject jsonObject = null; + + fixture.setJsonObject(jsonObject); + + // add additional test code here + } + + /** + * Run the void setMatchingConditions(Map) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetMatchingConditions_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + Map matchingConditions = new Hashtable(); + + fixture.setMatchingConditions(matchingConditions); + + // add additional test code here + } + + /** + * Run the void setOther(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetOther_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + 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:40 PM + */ + @Test + public void testSetPolicyConfigStatus_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND; + + fixture.setPolicyConfigStatus(policyConfigStatus); + + // add additional test code here + } + + /** + * Run the void setPolicyConfigStatus(String,PolicyConfigStatus) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetPolicyConfigStatus_2() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + String configStatus = ""; + PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND; + + fixture.setPolicyConfigStatus(configStatus, policyConfigStatus); + + // add additional test code here + } + + /** + * Run the void setPolicyDecision(PolicyDecision) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetPolicyDecision_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + PolicyDecision policyDecision = PolicyDecision.DENY; + + fixture.setDecision(policyDecision); + + // 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 { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + String policyName = ""; + + fixture.setPolicyName(policyName); + + // add additional test code here + } + + /** + * Run the void setPolicyResponseMessage(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetPolicyResponseMessage_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + String policyResponseMessage = ""; + + fixture.setPolicyResponseMessage(policyResponseMessage); + + // add additional test code here + } + + /** + * Run the void setPolicyResponseStatus(PolicyResponseStatus) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetPolicyResponseStatus_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED; + + fixture.setPolicyResponseStatus(policyResponseStatus); + + // add additional test code here + } + + /** + * Run the void setPolicyResponseStatus(String,PolicyResponseStatus) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetPolicyResponseStatus_2() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + String policyResponseMessage = ""; + PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED; + + fixture.setPolicyResponseStatus(policyResponseMessage, policyResponseStatus); + + // add additional test code here + } + + /** + * Run the void setPolicyType(PolicyType) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetPolicyType_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + 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:40 PM + */ + @Test + public void testSetPolicyVersion_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + 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:40 PM + */ + @Test + public void testSetProperties_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + Properties properties = new Properties(); + + fixture.setProperties(properties); + + // add additional test code here + } + + /** + * Run the void setRequestAttributes(Map) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetRequestAttributes_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + Map requestAttributes = new Hashtable(); + + fixture.setRequestAttributes(requestAttributes); + + // add additional test code here + } + + /** + * Run the void setResposneAttributes(Map) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetResposneAttributes_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + Map responseAttributes = new Hashtable(); + + fixture.setResposneAttributes(responseAttributes); + + // add additional test code here + } + + /** + * Run the void setStatus(String,PolicyResponseStatus,PolicyConfigStatus) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetStatus_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + String message = ""; + PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED; + PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND; + + fixture.setStatus(message, policyResponseStatus, policyConfigStatus); + + // add additional test code here + } + + /** + * Run the JsonObject toJSON() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testToJSON_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + 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:40 PM + */ + @Test + public void testToOther_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + 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:40 PM + */ + @Test + public void testToProperties_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + Properties result = fixture.toProperties(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the Document toXML() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testToXML_1() + throws Exception { + StdStatus fixture = new StdStatus(); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setPolicyName(""); + fixture.setPolicyType(PolicyType.JSON); + fixture.setResposneAttributes(new Hashtable()); + fixture.setMatchingConditions(new Hashtable()); + fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); + fixture.setJsonObject((JsonObject) null); + fixture.setDocument((Document) null); + fixture.setProperties(new Properties()); + fixture.setRequestAttributes(new Hashtable()); + fixture.setPolicyVersion(""); + fixture.setActionAdvised(new Hashtable()); + fixture.setOther(""); + fixture.setDecision(PolicyDecision.DENY); + fixture.setDetails(""); + fixture.setActionTaken(new Hashtable()); + + 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: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(StdStatusTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/package-info.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/package-info.java new file mode 100644 index 000000000..4c98f98a9 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/package-info.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +/** + * + */ +/** + * + */ +package org.onap.policy.std.test; diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/ActionPolicyApiTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ActionPolicyApiTest.java new file mode 100644 index 000000000..a66256432 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ActionPolicyApiTest.java @@ -0,0 +1,239 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.policy.api.AttributeType; +import org.onap.policy.api.PolicyChangeResponse; +import org.onap.policy.api.PolicyClass; +import org.onap.policy.api.PolicyEngine; +import org.onap.policy.api.PolicyEngineException; +import org.onap.policy.api.PolicyParameters; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; +import org.onap.policy.std.StdPolicyChangeResponse; + +import junit.framework.TestCase; + +public class ActionPolicyApiTest extends TestCase { + + private static final Logger logger = FlexLogger.getLogger(ActionPolicyApiTest.class); + + private PolicyEngine policyEngine = null; + private PolicyEngine mockPolicyEngine = null; + + PolicyChangeResponse result = null; + StdPolicyChangeResponse response = new StdPolicyChangeResponse(); + PolicyParameters policyParameters = new PolicyParameters(); + + @Before + protected void setUp() throws Exception { + try { + policyEngine = new PolicyEngine("Test/config_pass.properties"); + } catch (PolicyEngineException e) { + logger.error(e.getMessage()); + fail("PolicyEngine Instantiation Error" + e); + } + logger.info("Loaded.. PolicyEngine"); + + mockPolicyEngine = Mockito.mock(PolicyEngine.class); + + policyParameters.setPolicyClass(PolicyClass.Action); //required + policyParameters.setPolicyName("test.junitTest"); //required + policyParameters.setPolicyDescription("testing"); //optional + //policyParameters.setPolicyScope("test"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI + + //Set the Component Attributes... These are Optional + Map configAttributes = new HashMap(); + configAttributes.put("test", "testing"); + + Map> attributes = new HashMap>(); + attributes.put(AttributeType.MATCHING, configAttributes); + policyParameters.setAttributes(attributes); + + policyParameters.setActionPerformer("PEP"); + policyParameters.setActionAttribute("testing"); + policyParameters.setRequestID(UUID.randomUUID()); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public final void testCreatePolicy() { + response.setResponseMessage("success"); + PolicyChangeResponse result = null; + try { + + Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response); + result = mockPolicyEngine.createPolicy(policyParameters); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + @Test + public final void testUpdatePolicy() { + response.setResponseMessage("success"); + PolicyChangeResponse result = null; + try { + + Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response); + result = mockPolicyEngine.updatePolicy(policyParameters); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + + } + + @Test + public final void testCreatePolicyNullPolicyName() { + response.setResponseMessage("PE300 - Data Issue: No Policy Name given."); + policyParameters.setPolicyName(null); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testCreatePolicyNullPolicyScope() { + response.setResponseMessage("PE300 - Data Issue: No Policy Scope given."); + policyParameters.setPolicyName("test"); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testCreatePolicyNullActionAttributes() { + response.setResponseMessage("PE300 - Data Issue: No Action Attribute given."); + policyParameters.setActionAttribute(null); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testCreatePolicyNullActionPerformer() { + response.setResponseMessage("PE300 - Data Issue: No Action Performer given."); + policyParameters.setActionPerformer(null); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testCreatePolicyInvalidActionPerformer() { + response.setResponseMessage("PE300 - Data Issue: Invalid Action Performer given."); + policyParameters.setActionPerformer("testfail"); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullPolicyName() { + response.setResponseMessage("PE300 - Data Issue: No Policy Name given."); + policyParameters.setPolicyName(null); + try{ + result = policyEngine.updatePolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullPolicyScope() { + response.setResponseMessage("PE300 - Data Issue: No Policy Scope given."); + policyParameters.setPolicyName("test"); + try{ + result = policyEngine.updatePolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullActionAttributes() { + response.setResponseMessage("PE300 - Data Issue: No Action Attribute given."); + policyParameters.setActionAttribute(null); + try{ + result = policyEngine.updatePolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullActionPerformer() { + response.setResponseMessage("PE300 - Data Issue: No Action Performer given."); + policyParameters.setActionPerformer(null); + try{ + result = policyEngine.updatePolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyInvalidActionPerformer() { + response.setResponseMessage("PE300 - Data Issue: Invalid Action Performer given."); + policyParameters.setActionPerformer("testfail"); + try{ + result = policyEngine.updatePolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/AttributeTypeTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/AttributeTypeTest.java new file mode 100644 index 000000000..62c447fae --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/AttributeTypeTest.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.*; +import org.onap.policy.api.AttributeType; + +import static org.junit.Assert.*; + +/** + * The class AttributeTypeTest contains tests for the class {@link AttributeType}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class AttributeTypeTest { + /** + * Run the String toString() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testToString_1() + throws Exception { + AttributeType fixture = AttributeType.MATCHING; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("matching", 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 + } + +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigBasePolicyTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigBasePolicyTest.java new file mode 100644 index 000000000..5d5a076ae --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigBasePolicyTest.java @@ -0,0 +1,325 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.policy.api.AttributeType; +import org.onap.policy.api.PolicyChangeResponse; +import org.onap.policy.api.PolicyConfigType; +import org.onap.policy.api.PolicyEngine; +import org.onap.policy.api.PolicyEngineException; +import org.onap.policy.api.PolicyParameters; +import org.onap.policy.api.PolicyType; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; +import org.onap.policy.std.StdPolicyChangeResponse; + +import junit.framework.TestCase; + +/** + * The class ConfigBasePolicyTest contains tests for the class + * {@link PolicyEngine} + * + * @pattern JUnit Test Case + * * + */ +public class ConfigBasePolicyTest extends TestCase { + + private static final Logger logger = FlexLogger.getLogger(DecisionPolicyApiTest.class); + + private PolicyEngine policyEngine = null; + private PolicyEngine mockPolicyEngine = null; + + PolicyChangeResponse result = null; + StdPolicyChangeResponse response = new StdPolicyChangeResponse(); + PolicyParameters policyParameters = new PolicyParameters(); + + /** + * Perform pre-test initialization + * + * @throws Exception + * + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + try { + policyEngine = new PolicyEngine("Test/config_pass.properties"); + } catch (PolicyEngineException e) { + logger.error(e.getMessage()); + fail("PolicyEngine Instantiation Error" + e); + } + logger.info("Loaded.. PolicyEngine"); + + mockPolicyEngine = Mockito.mock(PolicyEngine.class); + + policyParameters.setPolicyConfigType(PolicyConfigType.Base); //required + policyParameters.setPolicyName("test.junitTest"); //required + policyParameters.setOnapName("test"); + policyParameters.setConfigName("testBase"); + policyParameters.setConfigBodyType(PolicyType.OTHER); + policyParameters.setConfigBody("testing"); + policyParameters.setPolicyDescription("testing"); //optional + //policyParameters.setPolicyScope("test"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI + + //Set the Component Attributes... These are Optional + Map configAttributes = new HashMap(); + configAttributes.put("test", "testing"); + + Map> attributes = new HashMap>(); + attributes.put(AttributeType.MATCHING, configAttributes); + policyParameters.setAttributes(attributes); + + policyParameters.setRequestID(UUID.randomUUID()); + } + + /** + * Perform post-test clean up + * + * @throws Exception + * + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + super.tearDown(); + // Add additional tear down code here + } + + /** + * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test + */ + public void testCreatePolicy() { + response.setResponseMessage("success"); + PolicyChangeResponse result = null; + try { + + Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response); + result = mockPolicyEngine.createPolicy(policyParameters); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + /** + * Run the String createConfigPolicy() method test + */ + @SuppressWarnings("deprecation") + @Test + public void testCreateConfigPolicy() { + String response = "success"; + String result = null; + try { + + Mockito.when(mockPolicyEngine.createConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null)).thenReturn(response); + result = mockPolicyEngine.createConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + /** + * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test + */ + public void testUpdatePolicy() { + response.setResponseMessage("success"); + PolicyChangeResponse result = null; + try { + + Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response); + result = mockPolicyEngine.updatePolicy(policyParameters); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + /** + * Run the String updateConfigPolicy() method test + */ + @SuppressWarnings("deprecation") + @Test + public void testUpdateConfigPolicy() { + String response = "success"; + String result = null; + try { + + Mockito.when(mockPolicyEngine.updateConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null)).thenReturn(response); + result = mockPolicyEngine.updateConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + @Test + public final void testCreatePolicyNullPolicyName() { + response.setResponseMessage("PE300 - Data Issue: No Policy Name given."); + policyParameters.setPolicyName(null); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testCreatePolicyNullPolicyScope() { + response.setResponseMessage("PE300 - Data Issue: No Policy Scope given."); + policyParameters.setPolicyName("test"); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testCreatePolicyNullOnapName() { + response.setResponseMessage("PE300 - Data Issue: No ONAP Name given."); + policyParameters.setOnapName(null); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testCreatePolicyNullPolicyConfigName() { + response.setResponseMessage("PE300 - Data Issue: No Config Name given."); + policyParameters.setConfigName(null);; + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testCreatePolicyNullPolicyConfigBodyType() { + response.setResponseMessage("PE300 - Data Issue: No Config Body Type given."); + policyParameters.setConfigBodyType(null); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testCreatePolicyNullPolicyConfigBody() { + response.setResponseMessage("PE300 - Data Issue: No Config Body given."); + policyParameters.setConfigBody(null); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullPolicyName() { + response.setResponseMessage("PE300 - Data Issue: No Policy Name given."); + policyParameters.setPolicyName(null); + try{ + result = policyEngine.updatePolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullPolicyScope() { + response.setResponseMessage("PE300 - Data Issue: No Policy Scope given."); + policyParameters.setPolicyName("test"); + try{ + result = policyEngine.updatePolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullOnapName() { + response.setResponseMessage("PE300 - Data Issue: No ONAP Name given."); + policyParameters.setOnapName(null); + try{ + result = policyEngine.updatePolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullPolicyConfigName() { + response.setResponseMessage("PE300 - Data Issue: No Config Name given."); + policyParameters.setConfigName(null);; + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullPolicyConfigBodyType() { + response.setResponseMessage("PE300 - Data Issue: No Config Body Type given."); + policyParameters.setConfigBodyType(null); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullPolicyConfigBody() { + response.setResponseMessage("PE300 - Data Issue: No Config Body given."); + policyParameters.setConfigBody(null); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + //assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } +} \ No newline at end of file diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigFirewallPolicyTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigFirewallPolicyTest.java new file mode 100644 index 000000000..78ae2493b --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigFirewallPolicyTest.java @@ -0,0 +1,254 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import java.io.StringReader; +import java.util.UUID; + +import javax.json.Json; +import javax.json.JsonObject; +import javax.json.JsonReader; + +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.policy.api.PolicyChangeResponse; +import org.onap.policy.api.PolicyConfigType; +import org.onap.policy.api.PolicyEngine; +import org.onap.policy.api.PolicyEngineException; +import org.onap.policy.api.PolicyParameters; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; +import org.onap.policy.std.StdPolicyChangeResponse; + +import junit.framework.TestCase; + +public class ConfigFirewallPolicyTest extends TestCase { + + private static final Logger logger = FlexLogger.getLogger(DecisionPolicyApiTest.class); + + private PolicyEngine policyEngine = null; + private PolicyEngine mockPolicyEngine = null; + + PolicyChangeResponse result = null; + StdPolicyChangeResponse response = new StdPolicyChangeResponse(); + PolicyParameters policyParameters = new PolicyParameters(); + String json = null; + + /** + * Perform pre-test initialization + * + * @throws Exception + * + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + try { + policyEngine = new PolicyEngine("Test/config_pass.properties"); + } catch (PolicyEngineException e) { + logger.error(e.getMessage()); + fail("PolicyEngine Instantiation Error" + e); + } + logger.info("Loaded.. PolicyEngine"); + + mockPolicyEngine = Mockito.mock(PolicyEngine.class); + + policyParameters.setPolicyConfigType(PolicyConfigType.Firewall); //required + policyParameters.setPolicyName("test.junitTest"); //required + + json = "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"rule1607\",\"deploymentOption\":{\"deployNow\":false},\"securityZoneId\":\"/v0/firewall/pan\",\"serviceGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"REFERENCE\",\"name\":\"SList\"},{\"type\":\"REFERENCE\",\"name\":\"Syslog\"}]},{\"name\":\"Syslog\",\"description\":\"NA\",\"type\":\"SERVICE\",\"transportProtocol\":\"udp\",\"appProtocol\":null,\"ports\":\"514\"},{\"name\":\"SList\",\"description\":\"Service List\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\",\"appProtocol\":null,\"ports\":\"8080\"}],\"addressGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"},{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]},{\"name\":\"PL_CCE3\",\"description\":\"CCE Routers\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]}],\"firewallRuleList\":[{\"position\":\"1\",\"ruleName\":\"1607Rule\",\"fromZones\":[\"Trusted\"],\"toZones\":[\"Untrusted\"],\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\",\"value\":\"PL_CCE3\"},{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"destinationList\":[{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"1607Group\"}],\"action\":\"accept\",\"description\":\"Rule for 1607 templates\",\"enabled\":true,\"log\":true}]}"; + + policyParameters.setConfigBody(buildJSON(json).toString()); + + //policyParameters.setPolicyScope("test"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI + policyParameters.setRequestID(UUID.randomUUID()); + } + + private static JsonObject buildJSON(String jsonString) { + JsonObject json = null;; + if (jsonString != null) { + StringReader in = null; + + in = new StringReader(jsonString); + + JsonReader jsonReader = Json.createReader(in); + json = jsonReader.readObject(); + } + + return json; + } + /** + * Perform post-test clean up + * + * @throws Exception + * + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + super.tearDown(); + // Add additional tear down code here + } + + /** + * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test + */ + public void testCreatePolicy() { + response.setResponseMessage("success"); + PolicyChangeResponse result = null; + try { + + Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response); + result = mockPolicyEngine.createPolicy(policyParameters); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + /** + * Run the String createConfigFirewallPolicy() method test + */ + @SuppressWarnings("deprecation") + @Test + public void testCreateConfigFirewallPolicy() { + String response = "success"; + String result = null; + JsonObject jsonObj = buildJSON(json); + try { + + Mockito.when(mockPolicyEngine.createConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null)).thenReturn(response); + result = mockPolicyEngine.createConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + /** + * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test + */ + public void testUpdatePolicy() { + response.setResponseMessage("success"); + PolicyChangeResponse result = null; + try { + + Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response); + result = mockPolicyEngine.updatePolicy(policyParameters); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + /** + * Run the String updateConfigFirewallPolicy() method test + */ + @SuppressWarnings("deprecation") + @Test + public void testUpdateConfigFirewallPolicy() { + String response = "success"; + String result = null; + JsonObject jsonObj = buildJSON(json); + try { + + Mockito.when(mockPolicyEngine.updateConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null)).thenReturn(response); + result = mockPolicyEngine.updateConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + @Test + public final void testCreatePolicyNullPolicyName() { + response.setResponseMessage("PE500 - Process Flow Issue: :500:"); + policyParameters.setPolicyName(null); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testCreatePolicyNullPolicyScope() { + response.setResponseMessage("PE500 - Process Flow Issue: :500:"); + policyParameters.setPolicyName("test"); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testCreatePolicyNullPolicyConfigBody() { + response.setResponseMessage("PE500 - Process Flow Issue: :500:"); + policyParameters.setConfigBody(null); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullPolicyName() { + response.setResponseMessage("PE500 - Process Flow Issue: :500:"); + policyParameters.setPolicyName(null); + try{ + result = policyEngine.updatePolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullPolicyScope() { + response.setResponseMessage("PE500 - Process Flow Issue: :500:"); + policyParameters.setPolicyName("test"); + try{ + result = policyEngine.updatePolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullPolicyConfigBody() { + response.setResponseMessage("PE500 - Process Flow Issue: :500:"); + policyParameters.setConfigBody(null); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigRequestParametersTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigRequestParametersTest.java new file mode 100644 index 000000000..91025f5c0 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigRequestParametersTest.java @@ -0,0 +1,362 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import java.util.Hashtable; +import java.util.Map; +import java.util.UUID; + +import org.junit.*; +import org.onap.policy.api.ConfigRequestParameters; + +import static org.junit.Assert.*; + +/** + * The class ConfigRequestParametersTest contains tests for the class {@link ConfigRequestParameters}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class ConfigRequestParametersTest { + /** + * Run the ConfigRequestParameters() constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testConfigRequestParameters_1() + throws Exception { + + ConfigRequestParameters result = new ConfigRequestParameters(); + + // add additional test code here + assertNotNull(result); + assertEquals(null, result.getPolicyName()); + assertEquals(null, result.getConfigName()); + assertEquals(null, result.getConfigAttributes()); + assertEquals(null, result.getRequestID()); + assertEquals(null, result.getOnapName()); + assertEquals(Boolean.FALSE, result.getUnique()); + } + + /** + * Run the ConfigRequestParameters(String,String,String,Map,Boolean,UUID) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testConfigRequestParameters_2() + throws Exception { + String policyName = ""; + String onapComponentName = ""; + String configName = ""; + Map configAttributes = new Hashtable(); + Boolean unique = new Boolean(true); + UUID requestID = UUID.randomUUID(); + + ConfigRequestParameters result = createConfigRequest(policyName, onapComponentName, configName, configAttributes, unique, requestID); + + // add additional test code here + assertNotNull(result); + assertEquals("", result.getPolicyName()); + assertEquals("", result.getConfigName()); + assertEquals("", result.getOnapName()); + assertEquals(Boolean.TRUE, result.getUnique()); + } + + /** + * Run the Map getConfigAttributes() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetConfigAttributes_1() + throws Exception { + ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); + + Map 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:40 PM + */ + @Test + public void testGetConfigName_1() + throws Exception { + ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); + + 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:40 PM + */ + @Test + public void testGetOnapName_1() + throws Exception { + ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); + + String result = fixture.getOnapName(); + + // 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 { + ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); + + 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 { + ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.fromString("6b5aa070-90bc-46a6-9a59-e1fe526df7ae")); + + UUID result = fixture.getRequestID(); + + // add additional test code here + assertNotNull(result); + assertEquals("6b5aa070-90bc-46a6-9a59-e1fe526df7ae", result.toString()); + assertEquals(4, result.version()); + assertEquals(2, result.variant()); + assertEquals(-7324574836520519762L, result.getLeastSignificantBits()); + assertEquals(7735671715287287462L, result.getMostSignificantBits()); + } + + /** + * Run the Boolean getUnique() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetUnique_1() + throws Exception { + ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); + + Boolean result = fixture.getUnique(); + + // add additional test code here + assertNotNull(result); + assertEquals("true", result.toString()); + assertEquals(true, result.booleanValue()); + } + + /** + * Run the void makeUnique(Boolean) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testMakeUnique_1() + throws Exception { + ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); + Boolean unique = new Boolean(true); + + fixture.makeUnique(unique); + + // add additional test code here + } + + /** + * Run the void setConfigAttributes(Map) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetConfigAttributes_1() + throws Exception { + ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); + Map configAttributes = new Hashtable(); + + fixture.setConfigAttributes(configAttributes); + + // add additional test code here + } + + /** + * Run the void setConfigName(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetConfigName_1() + throws Exception { + ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); + 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:40 PM + */ + @Test + public void testSetOnapName_1() + throws Exception { + ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); + String onapComponentName = ""; + + fixture.setOnapName(onapComponentName); + + // 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 { + ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); + 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 { + ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); + 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(ConfigRequestParametersTest.class); + } + + private ConfigRequestParameters createConfigRequest(String policyName, String onapComponentName, String configName, Map configAttributes, Boolean unique, UUID requestID){ + ConfigRequestParameters configRequestParameters = new ConfigRequestParameters(); + configRequestParameters.setRequestID(requestID); + configRequestParameters.setPolicyName(policyName); + configRequestParameters.setOnapName(onapComponentName); + configRequestParameters.setConfigName(configName); + configRequestParameters.setConfigAttributes(configAttributes); + configRequestParameters.makeUnique(unique); + return configRequestParameters; + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionPolicyApiTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionPolicyApiTest.java new file mode 100644 index 000000000..a80093470 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionPolicyApiTest.java @@ -0,0 +1,219 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.policy.api.AttributeType; +import org.onap.policy.api.PolicyChangeResponse; +import org.onap.policy.api.PolicyClass; +import org.onap.policy.api.PolicyEngine; +import org.onap.policy.api.PolicyEngineException; +import org.onap.policy.api.PolicyParameters; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; +import org.onap.policy.std.StdPolicyChangeResponse; + +import junit.framework.TestCase; + +/** + * The class DecisionPolicyApiTest contains tests for the class + * {@link PolicyEngine} + * + * @pattern JUnit Test Case + * * + */ +public class DecisionPolicyApiTest extends TestCase { + + private static final Logger logger = FlexLogger.getLogger(DecisionPolicyApiTest.class); + + private PolicyEngine policyEngine = null; + private PolicyEngine mockPolicyEngine = null; + + PolicyChangeResponse result = null; + StdPolicyChangeResponse response = new StdPolicyChangeResponse(); + PolicyParameters policyParameters = new PolicyParameters(); + + /** + * Perform pre-test initialization + * + * @throws Exception + * + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + try { + policyEngine = new PolicyEngine("Test/config_pass.properties"); + } catch (PolicyEngineException e) { + logger.error(e.getMessage()); + fail("PolicyEngine Instantiation Error" + e); + } + logger.info("Loaded.. PolicyEngine"); + + mockPolicyEngine = Mockito.mock(PolicyEngine.class); + + policyParameters.setPolicyClass(PolicyClass.Decision); //required + policyParameters.setPolicyName("test.junitTest"); //required + policyParameters.setOnapName("test"); + policyParameters.setPolicyDescription("testing"); //optional + //policyParameters.setPolicyScope("test"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI + + //Set the Component Attributes... These are Optional + Map configAttributes = new HashMap(); + configAttributes.put("test", "testing"); + + Map> attributes = new HashMap>(); + attributes.put(AttributeType.MATCHING, configAttributes); + policyParameters.setAttributes(attributes); + + //Set the settings... These are Optional +/* Map settingsMap = new HashMap(); + settingsMap.put("server", "5"); + + Map> settings = new HashMap>(); + settings.put(AttributeType.SETTINGS, settingsMap); + policyParameters.setSettings(settings);*/ + + policyParameters.setRequestID(UUID.randomUUID()); + } + + /** + * Perform post-test clean up + * + * @throws Exception + * + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + super.tearDown(); + // Add additional tear down code here + } + + /** + * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test + */ + public void testCreatePolicy() { + response.setResponseMessage("success"); + PolicyChangeResponse result = null; + try { + + Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response); + result = mockPolicyEngine.createPolicy(policyParameters); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + /** + * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test + */ + public void testUpdatePolicy() { + response.setResponseMessage("success"); + PolicyChangeResponse result = null; + try { + + Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response); + result = mockPolicyEngine.updatePolicy(policyParameters); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + @Test + public final void testCreatePolicyNullPolicyName() { + response.setResponseMessage("PE500 - Process Flow Issue: :500:"); + policyParameters.setPolicyName(null); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testCreatePolicyNullPolicyScope() { + response.setResponseMessage("PE500 - Process Flow Issue: :500:"); + policyParameters.setPolicyName("test"); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testCreatePolicyNullOnapName() { + response.setResponseMessage("PE500 - Process Flow Issue: :500:"); + policyParameters.setOnapName(null); + try{ + result = policyEngine.createPolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullPolicyName() { + response.setResponseMessage("PE500 - Process Flow Issue: :500:"); + policyParameters.setPolicyName(null); + try{ + result = policyEngine.updatePolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullPolicyScope() { + response.setResponseMessage("PE500 - Process Flow Issue: :500:"); + policyParameters.setPolicyName("test"); + try{ + result = policyEngine.updatePolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } + + @Test + public final void testUpdatePolicyNullOnapName() { + response.setResponseMessage("PE500 - Process Flow Issue: :500:"); + policyParameters.setOnapName(null); + try{ + result = policyEngine.updatePolicy(policyParameters); + } catch (Exception e){ + logger.warn(e.getMessage()); + } + assertEquals(result.getResponseMessage(), response.getResponseMessage()); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionRequestParametersTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionRequestParametersTest.java new file mode 100644 index 000000000..746822f94 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionRequestParametersTest.java @@ -0,0 +1,232 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import java.util.Hashtable; +import java.util.Map; +import java.util.UUID; + +import org.junit.*; +import org.onap.policy.api.DecisionRequestParameters; + +import static org.junit.Assert.*; + +/** + * The class DecisionRequestParametersTest contains tests for the class {@link DecisionRequestParameters}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class DecisionRequestParametersTest { + /** + * Run the DecisionRequestParameters() constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testDecisionRequestParameters_1() + throws Exception { + + DecisionRequestParameters result = new DecisionRequestParameters(); + + // add additional test code here + assertNotNull(result); + assertEquals(null, result.getONAPComponentName()); + assertEquals(null, result.getDecisionAttributes()); + assertEquals(null, result.getRequestID()); + } + + /** + * Run the DecisionRequestParameters(String,Map,UUID) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testDecisionRequestParameters_2() + throws Exception { + String onapComponentName = ""; + Map decisionAttributes = new Hashtable(); + UUID requestID = UUID.randomUUID(); + + DecisionRequestParameters result = new DecisionRequestParameters(onapComponentName, decisionAttributes, requestID); + + // add additional test code here + assertNotNull(result); + assertEquals("", result.getONAPComponentName()); + } + + /** + * Run the Map getDecisionAttributes() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetDecisionAttributes_1() + throws Exception { + DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable(), UUID.randomUUID()); + + Map result = fixture.getDecisionAttributes(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the String getONAPComponentName() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetONAPComponentName_1() + throws Exception { + DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable(), UUID.randomUUID()); + + String result = fixture.getONAPComponentName(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the UUID getRequestID() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetRequestID_1() + throws Exception { + DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable(), UUID.fromString("d1db6a6d-7140-4864-8200-6b541261fdd2")); + + UUID result = fixture.getRequestID(); + + // add additional test code here + assertNotNull(result); + assertEquals("d1db6a6d-7140-4864-8200-6b541261fdd2", result.toString()); + assertEquals(4, result.version()); + assertEquals(2, result.variant()); + assertEquals(-9079138839949083182L, result.getLeastSignificantBits()); + assertEquals(-3324946881598961564L, result.getMostSignificantBits()); + } + + /** + * Run the void setDecisionAttributes(Map) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetDecisionAttributes_1() + throws Exception { + DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable(), UUID.randomUUID()); + Map decisionAttributes = new Hashtable(); + + fixture.setDecisionAttributes(decisionAttributes); + + // add additional test code here + } + + /** + * Run the void setONAPComponentName(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetONAPComponentName_1() + throws Exception { + DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable(), UUID.randomUUID()); + String onapComponentName = ""; + + fixture.setONAPComponentName(onapComponentName); + + // add additional test code here + } + + /** + * Run the void setRequestID(UUID) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetRequestID_1() + throws Exception { + DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable(), UUID.randomUUID()); + 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: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(DecisionRequestParametersTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyConditionTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyConditionTest.java new file mode 100644 index 000000000..2513816bb --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyConditionTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.*; +import org.onap.policy.api.DeletePolicyCondition; + +import static org.junit.Assert.*; + +/** + * The class DeletePolicyConditionTest contains tests for the class {@link DeletePolicyCondition}. + * + * @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(); + + // add additional test code here + assertEquals("All Versions", 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(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 new file mode 100644 index 000000000..423b839f6 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DeletePolicyParametersTest.java @@ -0,0 +1,314 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import java.util.UUID; + +import org.junit.*; +import org.onap.policy.api.DeletePolicyCondition; +import org.onap.policy.api.DeletePolicyParameters; + +import static org.junit.Assert.*; + +/** + * The class DeletePolicyParametersTest contains tests for the class {@link DeletePolicyParameters}. + * + * @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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/EventRequestParametersTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/EventRequestParametersTest.java new file mode 100644 index 000000000..4fecea8c2 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/EventRequestParametersTest.java @@ -0,0 +1,193 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import java.util.Hashtable; +import java.util.Map; +import java.util.UUID; + +import org.junit.*; +import org.onap.policy.api.EventRequestParameters; + +import static org.junit.Assert.*; + +/** + * The class EventRequestParametersTest contains tests for the class {@link EventRequestParameters}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class EventRequestParametersTest { + /** + * Run the EventRequestParameters() constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testEventRequestParameters_1() + throws Exception { + + EventRequestParameters result = new EventRequestParameters(); + + // add additional test code here + assertNotNull(result); + assertEquals(null, result.getEventAttributes()); + assertEquals(null, result.getRequestID()); + } + + /** + * Run the EventRequestParameters(Map,UUID) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testEventRequestParameters_2() + throws Exception { + Map eventAttributes = new Hashtable(); + UUID requestID = UUID.randomUUID(); + + EventRequestParameters result = new EventRequestParameters(eventAttributes, requestID); + + // add additional test code here + assertNotNull(result); + } + + /** + * Run the Map getEventAttributes() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetEventAttributes_1() + throws Exception { + EventRequestParameters fixture = new EventRequestParameters(new Hashtable(), UUID.randomUUID()); + + Map result = fixture.getEventAttributes(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the UUID getRequestID() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetRequestID_1() + throws Exception { + EventRequestParameters fixture = new EventRequestParameters(new Hashtable(), UUID.fromString("5b15376d-569b-4772-ac75-9362043f6a6c")); + + UUID result = fixture.getRequestID(); + + // add additional test code here + assertNotNull(result); + assertEquals("5b15376d-569b-4772-ac75-9362043f6a6c", result.toString()); + assertEquals(4, result.version()); + assertEquals(2, result.variant()); + assertEquals(-6019743277723456916L, result.getLeastSignificantBits()); + assertEquals(6563212974706345842L, result.getMostSignificantBits()); + } + + /** + * Run the void setEventAttributes(Map) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetEventAttributes_1() + throws Exception { + EventRequestParameters fixture = new EventRequestParameters(new Hashtable(), UUID.randomUUID()); + Map eventAttributes = new Hashtable(); + + fixture.setEventAttributes(eventAttributes); + + // add additional test code here + } + + /** + * Run the void setRequestID(UUID) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetRequestID_1() + throws Exception { + EventRequestParameters fixture = new EventRequestParameters(new Hashtable(), UUID.randomUUID()); + 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: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(EventRequestParametersTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigByPolicyNameTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigByPolicyNameTest.java new file mode 100644 index 000000000..07af71eaf --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigByPolicyNameTest.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import java.util.Collection; + +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.api.PolicyConfig; +import org.onap.policy.api.PolicyConfigException; +import org.onap.policy.api.PolicyEngine; +import org.onap.policy.api.PolicyEngineException; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; + +import junit.framework.TestCase; + +public class GetConfigByPolicyNameTest extends TestCase { + private PolicyEngine policyEngine = null; + private String policyName = null; + private Collection policyConfig = null; + private static final Logger logger = FlexLogger.getLogger(GetConfigByPolicyNameTest.class); + @Before + public void setUp() { + try { + policyEngine = new PolicyEngine("Test/config_pass.properties"); + } catch (PolicyEngineException e) { + logger.error(e.getMessage()); + fail("PolicyEngine Instantiation Error" + e); + } + logger.info("Loaded.. PolicyEngine"); + } + + @SuppressWarnings("deprecation") + @Test + public void testGetConfigPolicyNameNotValid(){ + policyName = null; + try{ + policyConfig = policyEngine.getConfigByPolicyName(policyName); + } catch (PolicyConfigException e){ + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringMapTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringMapTest.java new file mode 100644 index 000000000..f70a16a98 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringMapTest.java @@ -0,0 +1,259 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.api.PolicyConfig; +import org.onap.policy.api.PolicyConfigException; +import org.onap.policy.api.PolicyConfigStatus; +import org.onap.policy.api.PolicyEngine; +import org.onap.policy.api.PolicyEngineException; +import org.onap.policy.api.PolicyType; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; + +public class GetConfigStringStringMapTest { + + private PolicyEngine policyEngine = null; + private String onapComponentName = null; + private String configName = null; + private Map configAttributes = new HashMap(); + private Collection policyConfig = null; + private static final Logger logger = FlexLogger.getLogger(GetConfigStringStringMapTest.class); + @Before + public void setUp() { + try { + policyEngine = new PolicyEngine("Test/config_pass.properties"); + } catch (PolicyEngineException e) { + logger.error(e.getMessage()); + fail("PolicyEngine Instantiation Error" + e); + } + logger.info("Loaded.. PolicyEngine"); + } + + @SuppressWarnings("deprecation") + @Test + public void testGetConfigStringStringMapFail() { + onapComponentName = null; + configName = null; + configAttributes = null; + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @SuppressWarnings("deprecation") + @Test + public void testGetConfigStringStringMapFail1() { + onapComponentName = null; + configName = "testFail"; + configAttributes.put("TestValue", "Fail"); + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @SuppressWarnings("deprecation") + @Test + public void testGetConfigStringStringMapFail2() { + onapComponentName = "TestFail"; + configName = null; + configAttributes.put("TestValue", "Fail"); + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @SuppressWarnings("deprecation") + @Test + public void testGetConfigStringStringMapFail3() { + onapComponentName = "TestFail"; + configName = "configFail"; + configAttributes= null; + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @SuppressWarnings("deprecation") + @Test + public void testGetConfigStringStringMapfail4() { + onapComponentName = "TestFail"; + configName = "configFail"; + configAttributes.put("", ""); + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + //@Test + @SuppressWarnings("deprecation") + public void testGetConfigStringStringMapNotValid() { + onapComponentName = "TestFail"; + configName = "configFail"; + configAttributes.put("Action:com.test.fail", "Value"); + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + for(PolicyConfig policyConfig : this.policyConfig){ + logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig); + assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND,policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig.getPolicyConfigMessage()); + assertNull(policyConfig.getType()); + assertNull(policyConfig.toJSON()); + assertNull(policyConfig.toProperties()); + assertNull(policyConfig.toXML()); + assertNull(policyConfig.toOther()); + } + } + + //@Test + @SuppressWarnings("deprecation") + public void testGetConfigStringStringMapValidJSON() { + onapComponentName = "JSON"; + configName = "JSONconfig"; + configAttributes.put("Resource.com:test:resource:json", "Test"); + configAttributes.put("Action.com:test:action:json", "TestJSON"); + configAttributes.put("Subject.com:test:subject:json", "TestSubject"); + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + for(PolicyConfig policyConfig : this.policyConfig){ + logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig); + assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig.getPolicyConfigMessage()); + assertEquals(PolicyType.JSON,policyConfig.getType()); + assertNotNull(policyConfig.toJSON()); + assertNull(policyConfig.toProperties()); + assertNull(policyConfig.toXML()); + assertNull(policyConfig.toOther()); + } + } + + //@Test + @SuppressWarnings("deprecation") + public void testGetConfigStringStringMapValidXML() { + onapComponentName = "XML"; + configName = "XMLconfig"; + configAttributes.put("Resource.com:test:resource:json", "Test"); + configAttributes.put("Action.com:test:action:json", "TestJSON"); + configAttributes.put("Subject.com:test:subject:json", "TestSubject"); + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + for(PolicyConfig policyConfig : this.policyConfig){ + logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig); + assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig.getPolicyConfigMessage()); + assertEquals(PolicyType.XML,policyConfig.getType()); + assertNull(policyConfig.toJSON()); + assertNull(policyConfig.toProperties()); + assertNotNull(policyConfig.toXML()); + assertNull(policyConfig.toOther()); + } + } + + //@Test + @SuppressWarnings("deprecation") + public void testGetConfigStringStringMapValidProperties() { + onapComponentName = "Properties"; + configName = "PropConfig" ; + configAttributes.put("Resource.com:test:resource:json", "Test"); + configAttributes.put("Action.com:test:action:json", "TestJSON"); + configAttributes.put("Subject.com:test:subject:json", "TestSubject"); + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + for(PolicyConfig policyConfig : this.policyConfig){ + logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig); + assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig.getPolicyConfigMessage()); + assertEquals(PolicyType.PROPERTIES,policyConfig.getType()); + assertNull(policyConfig.toJSON()); + assertNotNull(policyConfig.toProperties()); + assertNull(policyConfig.toXML()); + assertNull(policyConfig.toOther()); + } + } + + //@Test + @SuppressWarnings("deprecation") + public void testGetConfigStringStringMapValidOther() { + onapComponentName = "Other"; + configName = "OtherConfig" ; + configAttributes.put("Resource.com:test:resource:json", "Test"); + configAttributes.put("Action.com:test:action:json", "TestJSON"); + configAttributes.put("Subject.com:test:subject:json", "TestSubject"); + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + for(PolicyConfig policyConfig : this.policyConfig){ + logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig); + assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig.getPolicyConfigMessage()); + assertEquals(PolicyType.OTHER,policyConfig.getType()); + assertNull(policyConfig.toJSON()); + assertNull(policyConfig.toProperties()); + assertNull(policyConfig.toXML()); + assertNotNull(policyConfig.toOther()); + } + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringTest.java new file mode 100644 index 000000000..0a6db2dd4 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringTest.java @@ -0,0 +1,213 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.util.Collection; + +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.api.PolicyConfig; +import org.onap.policy.api.PolicyConfigException; +import org.onap.policy.api.PolicyConfigStatus; +import org.onap.policy.api.PolicyEngine; +import org.onap.policy.api.PolicyEngineException; +import org.onap.policy.api.PolicyType; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; + +public class GetConfigStringStringTest { + + private PolicyEngine policyEngine = null; + private String onapComponentName = null; + private String configName = null; + private Collection policyConfig = null; + private static final Logger logger = FlexLogger.getLogger(GetConfigStringStringTest.class); + @Before + public void setUp() { + try { + policyEngine = new PolicyEngine("Test/config_pass.properties"); + } catch (PolicyEngineException e) { + logger.error(e.getMessage()); + fail("PolicyEngine Instantiation Error" + e); + } + logger.info("Loaded.. PolicyEngine"); + } + + @SuppressWarnings("deprecation") + @Test + public void testGetConfigStringStringFail() { + onapComponentName = null; + configName = null; + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @SuppressWarnings("deprecation") + @Test + public void testGetConfigStringStringFail1() { + onapComponentName = null; + configName = ""; + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @SuppressWarnings("deprecation") + @Test + public void testGetConfigStringStringFail2() { + onapComponentName = ""; + configName = null; + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + //@Test + @SuppressWarnings("deprecation") + public void testGetConfigStringStringNotvalid() { + onapComponentName = "fail"; + configName = "fail"; + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + for(PolicyConfig policyConfig : this.policyConfig){ + logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig); + assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND,policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig.getPolicyConfigMessage()); + assertNull(policyConfig.getType()); + assertNull(policyConfig.toJSON()); + assertNull(policyConfig.toProperties()); + assertNull(policyConfig.toXML()); + assertNull(policyConfig.toOther()); + } + } + + //@Test + @SuppressWarnings("deprecation") + public void testGetConfigStringStringValidJSON() { + onapComponentName = "JSON"; + configName = "JSONconfig"; + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + for(PolicyConfig policyConfig : this.policyConfig){ + logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig); + assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig.getPolicyConfigMessage()); + assertEquals(PolicyType.JSON,policyConfig.getType()); + assertNotNull(policyConfig.toJSON()); + assertNull(policyConfig.toProperties()); + assertNull(policyConfig.toXML()); + assertNull(policyConfig.toOther()); + } + } + + //@Test + @SuppressWarnings("deprecation") + public void testGetConfigStringStringValidXML() { + onapComponentName = "XML"; + configName = "XMLconfig"; + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + for(PolicyConfig policyConfig : this.policyConfig){ + logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig); + assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig.getPolicyConfigMessage()); + assertEquals(PolicyType.XML,policyConfig.getType()); + assertNull(policyConfig.toJSON()); + assertNull(policyConfig.toProperties()); + assertNotNull(policyConfig.toXML()); + assertNull(policyConfig.toOther()); + } + } + + //@Test + @SuppressWarnings("deprecation") + public void testGetConfigStringStringValidProperties() { + onapComponentName = "Properties"; + configName = "PropConfig" ; + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + for(PolicyConfig policyConfig : this.policyConfig){ + logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig); + assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig.getPolicyConfigMessage()); + assertEquals(PolicyType.PROPERTIES,policyConfig.getType()); + assertNull(policyConfig.toJSON()); + assertNotNull(policyConfig.toProperties()); + assertNull(policyConfig.toXML()); + assertNull(policyConfig.toOther()); + } + } + + //@Test + @SuppressWarnings("deprecation") + public void testGetConfigStringStringValidOther() { + onapComponentName = "Other"; + configName = "OtherConfig" ; + try { + policyConfig = policyEngine.getConfig(onapComponentName, configName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + for(PolicyConfig policyConfig : this.policyConfig){ + logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig); + assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig.getPolicyConfigMessage()); + assertEquals(PolicyType.OTHER,policyConfig.getType()); + assertNull(policyConfig.toJSON()); + assertNull(policyConfig.toProperties()); + assertNull(policyConfig.toXML()); + assertNotNull(policyConfig.toOther()); + } + } + +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringTest.java new file mode 100644 index 000000000..f87a59c09 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringTest.java @@ -0,0 +1,170 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import java.util.Collection; + +import org.junit.Before; +import org.onap.policy.api.PolicyConfig; +import org.onap.policy.api.PolicyConfigException; +import org.onap.policy.api.PolicyEngine; +import org.onap.policy.api.PolicyEngineException; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; + +import junit.framework.TestCase; + +public class GetConfigStringTest extends TestCase{ + + private PolicyEngine policyEngine = null; + private String onapComponentName = null; + private Collection policyConfig = null; + private static final Logger logger = FlexLogger.getLogger(GetConfigStringTest.class); + @Before + public void setUp() { + try { + policyEngine = new PolicyEngine("Test/config_pass.properties"); + } catch (PolicyEngineException e) { + logger.error(e.getMessage()); + fail("PolicyEngine Instantiation Error" + e); + } + logger.info("Loaded.. PolicyEngine"); + } + + //@Test + @SuppressWarnings("deprecation") + public void testGetConfigStringFail() { + onapComponentName = null; + try { + policyConfig = policyEngine.getConfig(onapComponentName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + /*@Test + public void testGetConfigStringNotvalid() { + onapComponentName = "fail"; + try { + policyConfig = policyEngine.getConfig(onapComponentName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + for(PolicyConfig policyConfig : this.policyConfig){ + logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig); + assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND,policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig.getPolicyConfigMessage()); + assertNull(policyConfig.getType()); + assertNull(policyConfig.toJSON()); + assertNull(policyConfig.toProperties()); + assertNull(policyConfig.toXML()); + assertNull(policyConfig.toOther()); + } + } + */ + + /*@Test + public void testGetConfigStringValidJSON() { + onapComponentName = "JSON"; + try { + policyConfig = policyEngine.getConfig(onapComponentName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + for(PolicyConfig policyConfig : this.policyConfig){ + logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig); + assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig.getPolicyConfigMessage()); + assertEquals(PolicyType.JSON,policyConfig.getType()); + assertNotNull(policyConfig.toJSON()); + assertNull(policyConfig.toProperties()); + assertNull(policyConfig.toXML()); + assertNull(policyConfig.toOther()); + } + } + */ + /*@Test + public void testGetConfigStringValidXML() { + onapComponentName = "XML"; + try { + policyConfig = policyEngine.getConfig(onapComponentName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + for(PolicyConfig policyConfig : this.policyConfig){ + logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig); + assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig.getPolicyConfigMessage()); + assertEquals(PolicyType.XML,policyConfig.getType()); + assertNull(policyConfig.toJSON()); + assertNull(policyConfig.toProperties()); + assertNotNull(policyConfig.toXML()); + assertNull(policyConfig.toOther()); + } + } + */ + /*@Test + public void testGetConfigStringValidProperties() { + onapComponentName = "Properties"; + try { + policyConfig = policyEngine.getConfig(onapComponentName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + for(PolicyConfig policyConfig : this.policyConfig){ + logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig); + assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig.getPolicyConfigMessage()); + assertEquals(PolicyType.PROPERTIES,policyConfig.getType()); + assertNull(policyConfig.toJSON()); + assertNotNull(policyConfig.toProperties()); + assertNull(policyConfig.toXML()); + assertNull(policyConfig.toOther()); + } + } + */ + /*@Test + public void testGetConfigStringValidOther() { + onapComponentName = "Other"; + try { + policyConfig = policyEngine.getConfig(onapComponentName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + for(PolicyConfig policyConfig : this.policyConfig){ + logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig); + assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); + assertNotNull(policyConfig.getPolicyConfigMessage()); + assertEquals(PolicyType.OTHER,policyConfig.getType()); + assertNull(policyConfig.toJSON()); + assertNull(policyConfig.toProperties()); + assertNull(policyConfig.toXML()); + assertNotNull(policyConfig.toOther()); + } + } + */ +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/ImportParametersTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ImportParametersTest.java new file mode 100644 index 000000000..be3e9c39b --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ImportParametersTest.java @@ -0,0 +1,403 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.UUID; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.api.ImportParameters; + +/** + * The class ImportParametersTest contains tests for the class {@link ImportParameters}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class ImportParametersTest { + /** + * Run the String getDescription() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetDescription_1() + throws Exception { + ImportParameters fixture = new ImportParameters(); + fixture.setFilePath(""); + fixture.setVersion(""); + fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); + fixture.setRequestID(UUID.randomUUID()); + fixture.setDescription(""); + fixture.setServiceName(""); + + String result = fixture.getDescription(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the String getFilePath() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetFilePath_1() + throws Exception { + ImportParameters fixture = new ImportParameters(); + fixture.setFilePath(""); + fixture.setVersion(""); + fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); + fixture.setRequestID(UUID.randomUUID()); + fixture.setDescription(""); + fixture.setServiceName(""); + + String result = fixture.getFilePath(); + + // 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 { + ImportParameters fixture = new ImportParameters(); + fixture.setFilePath(""); + fixture.setVersion(""); + fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); + fixture.setRequestID(UUID.fromString("731dca0a-fe99-456c-8ad2-87cff8437b2f")); + fixture.setDescription(""); + fixture.setServiceName(""); + + UUID result = fixture.getRequestID(); + + // add additional test code here + assertNotNull(result); + assertEquals("731dca0a-fe99-456c-8ad2-87cff8437b2f", result.toString()); + assertEquals(4, result.version()); + assertEquals(2, result.variant()); + assertEquals(-8443537024073106641L, result.getLeastSignificantBits()); + assertEquals(8295008237256263020L, result.getMostSignificantBits()); + } + + /** + * Run the String getServiceName() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetServiceName_1() + throws Exception { + ImportParameters fixture = new ImportParameters(); + fixture.setFilePath(""); + fixture.setVersion(""); + fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); + fixture.setRequestID(UUID.randomUUID()); + fixture.setDescription(""); + fixture.setServiceName(""); + + String result = fixture.getServiceName(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the ImportParameters.IMPORT_TYPE getServiceType() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetServiceType_1() + throws Exception { + ImportParameters fixture = new ImportParameters(); + fixture.setFilePath(""); + fixture.setVersion(""); + fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); + fixture.setRequestID(UUID.randomUUID()); + fixture.setDescription(""); + fixture.setServiceName(""); + + ImportParameters.IMPORT_TYPE result = fixture.getServiceType(); + + // add additional test code here + assertNotNull(result); + assertEquals("MICROSERVICE", result.name()); + assertEquals("MICROSERVICE", result.toString()); + assertEquals(0, result.ordinal()); + } + + /** + * Run the String getVersion() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetVersion_1() + throws Exception { + ImportParameters fixture = new ImportParameters(); + fixture.setFilePath(""); + fixture.setVersion(""); + fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); + fixture.setRequestID(UUID.randomUUID()); + fixture.setDescription(""); + fixture.setServiceName(""); + + String result = fixture.getVersion(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the void setDescription(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetDescription_1() + throws Exception { + ImportParameters fixture = new ImportParameters(); + fixture.setFilePath(""); + fixture.setVersion(""); + fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); + fixture.setRequestID(UUID.randomUUID()); + fixture.setDescription(""); + fixture.setServiceName(""); + String description = ""; + + fixture.setDescription(description); + + // add additional test code here + } + + /** + * Run the void setFilePath(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetFilePath_1() + throws Exception { + ImportParameters fixture = new ImportParameters(); + fixture.setFilePath(""); + fixture.setVersion(""); + fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); + fixture.setRequestID(UUID.randomUUID()); + fixture.setDescription(""); + fixture.setServiceName(""); + String filePath = ""; + + fixture.setFilePath(filePath); + + // add additional test code here + } + + /** + * Run the void setImportParameters(String,String,UUID,String,IMPORT_TYPE,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetImportParameters_1() + throws Exception { + ImportParameters fixture = new ImportParameters(); + fixture.setFilePath(""); + fixture.setVersion(""); + fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); + fixture.setRequestID(UUID.randomUUID()); + fixture.setDescription(""); + fixture.setServiceName(""); + String serviceName = ""; + String description = ""; + UUID requestID = UUID.randomUUID(); + String filePath = ""; + ImportParameters.IMPORT_TYPE importType = ImportParameters.IMPORT_TYPE.MICROSERVICE; + String version = ""; + + fixture.setImportParameters(serviceName, description, requestID, filePath, importType, version); + + // 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 { + ImportParameters fixture = new ImportParameters(); + fixture.setFilePath(""); + fixture.setVersion(""); + fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); + fixture.setRequestID(UUID.randomUUID()); + fixture.setDescription(""); + fixture.setServiceName(""); + UUID requestID = UUID.randomUUID(); + + fixture.setRequestID(requestID); + + // add additional test code here + } + + /** + * Run the void setServiceName(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetServiceName_1() + throws Exception { + ImportParameters fixture = new ImportParameters(); + fixture.setFilePath(""); + fixture.setVersion(""); + fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); + fixture.setRequestID(UUID.randomUUID()); + fixture.setDescription(""); + fixture.setServiceName(""); + String serviceName = ""; + + fixture.setServiceName(serviceName); + + // add additional test code here + } + + /** + * Run the void setServiceType(IMPORT_TYPE) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetServiceType_1() + throws Exception { + ImportParameters fixture = new ImportParameters(); + fixture.setFilePath(""); + fixture.setVersion(""); + fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); + fixture.setRequestID(UUID.randomUUID()); + fixture.setDescription(""); + fixture.setServiceName(""); + ImportParameters.IMPORT_TYPE enumImportType = ImportParameters.IMPORT_TYPE.MICROSERVICE; + + fixture.setServiceType(enumImportType); + + // add additional test code here + } + + /** + * Run the void setVersion(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetVersion_1() + throws Exception { + ImportParameters fixture = new ImportParameters(); + fixture.setFilePath(""); + fixture.setVersion(""); + fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); + fixture.setRequestID(UUID.randomUUID()); + fixture.setDescription(""); + fixture.setServiceName(""); + String version = ""; + + fixture.setVersion(version); + + // 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(ImportParametersTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/LoadedPolicyTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/LoadedPolicyTest.java new file mode 100644 index 000000000..1cc9de8df --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/LoadedPolicyTest.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.After; +import org.junit.Before; +import org.onap.policy.api.LoadedPolicy; + +/** + * The class LoadedPolicyTest contains tests for the class {@link LoadedPolicy}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class LoadedPolicyTest { + /** + * 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(LoadedPolicyTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationHandlerTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationHandlerTest.java new file mode 100644 index 000000000..4b996ce35 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationHandlerTest.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.After; +import org.junit.Before; +import org.onap.policy.api.NotificationHandler; + +/** + * The class NotificationHandlerTest contains tests for the class {@link NotificationHandler}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class NotificationHandlerTest { + /** + * 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(NotificationHandlerTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationSchemeTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationSchemeTest.java new file mode 100644 index 000000000..3274cf3ac --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationSchemeTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.*; +import org.onap.policy.api.NotificationScheme; + +import static org.junit.Assert.*; + +/** + * The class NotificationSchemeTest contains tests for the class {@link NotificationScheme}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class NotificationSchemeTest { + /** + * Run the String toString() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testToString_1() + throws Exception { + NotificationScheme fixture = NotificationScheme.AUTO_ALL_NOTIFICATIONS; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("auto_all_notifications", 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(NotificationSchemeTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationTypeTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationTypeTest.java new file mode 100644 index 000000000..53ef086e2 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationTypeTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.*; +import org.onap.policy.api.NotificationType; + +import static org.junit.Assert.*; + +/** + * The class NotificationTypeTest contains tests for the class {@link NotificationType}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class NotificationTypeTest { + /** + * Run the String toString() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testToString_1() + throws Exception { + NotificationType fixture = NotificationType.BOTH; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("both", 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(NotificationTypeTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PDPNotificationTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PDPNotificationTest.java new file mode 100644 index 000000000..50d0aa324 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PDPNotificationTest.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.After; +import org.junit.Before; +import org.onap.policy.api.PDPNotification; + +/** + * The class PDPNotificationTest contains tests for the class {@link PDPNotification}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class PDPNotificationTest { + /** + * 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(PDPNotificationTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyChangeResponseTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyChangeResponseTest.java new file mode 100644 index 000000000..e8fd6346a --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyChangeResponseTest.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.After; +import org.junit.Before; +import org.onap.policy.api.PolicyChangeResponse; + +/** + * The class PolicyChangeResponseTest contains tests for the class {@link PolicyChangeResponse}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class PolicyChangeResponseTest { + /** + * 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(PolicyChangeResponseTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyClassTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyClassTest.java new file mode 100644 index 000000000..24eafc1ad --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyClassTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.*; +import org.onap.policy.api.PolicyClass; + +import static org.junit.Assert.*; + +/** + * The class PolicyClassTest contains tests for the class {@link PolicyClass}. + * + * @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() + throws Exception { + PolicyClass fixture = PolicyClass.Action; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("Action", 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(PolicyClassTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigExceptionTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigExceptionTest.java new file mode 100644 index 000000000..60b11b5c4 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigExceptionTest.java @@ -0,0 +1,183 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.*; +import org.onap.policy.api.PolicyConfigException; + +import static org.junit.Assert.*; + +/** + * The class PolicyConfigExceptionTest contains tests for the class {@link PolicyConfigException}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class PolicyConfigExceptionTest { + /** + * Run the PolicyConfigException() constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPolicyConfigException_1() + throws Exception { + + PolicyConfigException result = new PolicyConfigException(); + + // add additional test code here + assertNotNull(result); + assertEquals(null, result.getCause()); + assertEquals("org.onap.policy.api.PolicyConfigException", result.toString()); + assertEquals(null, result.getLocalizedMessage()); + assertEquals(null, result.getMessage()); + } + + /** + * Run the PolicyConfigException(String) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPolicyConfigException_2() + throws Exception { + String message = ""; + + PolicyConfigException result = new PolicyConfigException(message); + + // add additional test code here + assertNotNull(result); + assertEquals(null, result.getCause()); + assertEquals("org.onap.policy.api.PolicyConfigException: ", result.toString()); + assertEquals("", result.getLocalizedMessage()); + assertEquals("", result.getMessage()); + } + + /** + * Run the PolicyConfigException(Throwable) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPolicyConfigException_3() + throws Exception { + Throwable cause = new Throwable(); + + PolicyConfigException result = new PolicyConfigException(cause); + + // add additional test code here + assertNotNull(result); + assertEquals("org.onap.policy.api.PolicyConfigException: java.lang.Throwable", result.toString()); + assertEquals("java.lang.Throwable", result.getLocalizedMessage()); + assertEquals("java.lang.Throwable", result.getMessage()); + } + + /** + * Run the PolicyConfigException(String,Throwable) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPolicyConfigException_4() + throws Exception { + String message = ""; + Throwable cause = new Throwable(); + + PolicyConfigException result = new PolicyConfigException(message, cause); + + // add additional test code here + assertNotNull(result); + assertEquals("org.onap.policy.api.PolicyConfigException: ", result.toString()); + assertEquals("", result.getLocalizedMessage()); + assertEquals("", result.getMessage()); + } + + /** + * Run the PolicyConfigException(String,Throwable,boolean,boolean) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPolicyConfigException_5() + throws Exception { + String message = ""; + Throwable cause = new Throwable(); + boolean enableSuppression = true; + boolean writableStackTrace = true; + + PolicyConfigException result = new PolicyConfigException(message, cause, enableSuppression, writableStackTrace); + + // add additional test code here + assertNotNull(result); + assertEquals("org.onap.policy.api.PolicyConfigException: ", result.toString()); + assertEquals("", result.getLocalizedMessage()); + assertEquals("", result.getMessage()); + } + + /** + * 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(PolicyConfigExceptionTest.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 new file mode 100644 index 000000000..7a93f0505 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigStatusTest.java @@ -0,0 +1,133 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.*; +import org.onap.policy.api.PolicyConfigStatus; + +import static org.junit.Assert.*; + +/** + * The class PolicyConfigStatusTest contains tests for the class {@link PolicyConfigStatus}. + * + * @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); + + // add additional test code here + assertNotNull(result); + assertEquals("not_found", result.toString()); + assertEquals("CONFIG_NOT_FOUND", result.name()); + assertEquals(1, 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 { + String configStatus = ""; + + PolicyConfigStatus result = PolicyConfigStatus.getStatus(configStatus); + + // 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 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; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("not_found", 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(PolicyConfigStatusTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTest.java new file mode 100644 index 000000000..0aa4fbbfa --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTest.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.After; +import org.junit.Before; +import org.onap.policy.api.PolicyConfig; + +/** + * The class PolicyConfigTest contains tests for the class {@link PolicyConfig}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class PolicyConfigTest { + /** + * 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(PolicyConfigTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTypeTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTypeTest.java new file mode 100644 index 000000000..e5e0b5494 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTypeTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.*; +import org.onap.policy.api.PolicyConfigType; + +import static org.junit.Assert.*; + +/** + * The class PolicyConfigTypeTest contains tests for the class {@link PolicyConfigType}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class PolicyConfigTypeTest { + /** + * Run the String toString() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testToString_1() + throws Exception { + PolicyConfigType fixture = PolicyConfigType.BRMS_PARAM; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("BRMS_Param", 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(PolicyConfigTypeTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionExceptionTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionExceptionTest.java new file mode 100644 index 000000000..f0ee88151 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionExceptionTest.java @@ -0,0 +1,183 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.*; +import org.onap.policy.api.PolicyDecisionException; + +import static org.junit.Assert.*; + +/** + * The class PolicyDecisionExceptionTest contains tests for the class {@link PolicyDecisionException}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class PolicyDecisionExceptionTest { + /** + * Run the PolicyDecisionException() constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPolicyDecisionException_1() + throws Exception { + + PolicyDecisionException result = new PolicyDecisionException(); + + // add additional test code here + assertNotNull(result); + assertEquals(null, result.getCause()); + assertEquals("org.onap.policy.api.PolicyDecisionException", result.toString()); + assertEquals(null, result.getLocalizedMessage()); + assertEquals(null, result.getMessage()); + } + + /** + * Run the PolicyDecisionException(String) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPolicyDecisionException_2() + throws Exception { + String message = ""; + + PolicyDecisionException result = new PolicyDecisionException(message); + + // add additional test code here + assertNotNull(result); + assertEquals(null, result.getCause()); + assertEquals("org.onap.policy.api.PolicyDecisionException: ", result.toString()); + assertEquals("", result.getLocalizedMessage()); + assertEquals("", result.getMessage()); + } + + /** + * Run the PolicyDecisionException(Throwable) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPolicyDecisionException_3() + throws Exception { + Throwable cause = new Throwable(); + + PolicyDecisionException result = new PolicyDecisionException(cause); + + // add additional test code here + assertNotNull(result); + assertEquals("org.onap.policy.api.PolicyDecisionException: java.lang.Throwable", result.toString()); + assertEquals("java.lang.Throwable", result.getLocalizedMessage()); + assertEquals("java.lang.Throwable", result.getMessage()); + } + + /** + * Run the PolicyDecisionException(String,Throwable) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPolicyDecisionException_4() + throws Exception { + String message = ""; + Throwable cause = new Throwable(); + + PolicyDecisionException result = new PolicyDecisionException(message, cause); + + // add additional test code here + assertNotNull(result); + assertEquals("org.onap.policy.api.PolicyDecisionException: ", result.toString()); + assertEquals("", result.getLocalizedMessage()); + assertEquals("", result.getMessage()); + } + + /** + * Run the PolicyDecisionException(String,Throwable,boolean,boolean) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPolicyDecisionException_5() + throws Exception { + String message = ""; + Throwable cause = new Throwable(); + boolean enableSuppression = true; + boolean writableStackTrace = true; + + PolicyDecisionException result = new PolicyDecisionException(message, cause, enableSuppression, writableStackTrace); + + // add additional test code here + assertNotNull(result); + assertEquals("org.onap.policy.api.PolicyDecisionException: ", result.toString()); + assertEquals("", result.getLocalizedMessage()); + assertEquals("", result.getMessage()); + } + + /** + * 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(PolicyDecisionExceptionTest.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 new file mode 100644 index 000000000..4d9523859 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.*; +import org.onap.policy.api.PolicyDecision; + +import static org.junit.Assert.*; + +/** + * The class PolicyDecisionTest contains tests for the class {@link PolicyDecision}. + * + * @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); + } + + /** + * 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(PolicyDecisionTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineExceptionTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineExceptionTest.java new file mode 100644 index 000000000..58c45b97c --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineExceptionTest.java @@ -0,0 +1,183 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.*; +import org.onap.policy.api.PolicyEngineException; + +import static org.junit.Assert.*; + +/** + * The class PolicyEngineExceptionTest contains tests for the class {@link PolicyEngineException}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class PolicyEngineExceptionTest { + /** + * Run the PolicyEngineException() constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testPolicyEngineException_1() + throws Exception { + + PolicyEngineException result = new PolicyEngineException(); + + // add additional test code here + assertNotNull(result); + assertEquals(null, result.getCause()); + assertEquals("org.onap.policy.api.PolicyEngineException", result.toString()); + assertEquals(null, result.getLocalizedMessage()); + assertEquals(null, result.getMessage()); + } + + /** + * Run the PolicyEngineException(String) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testPolicyEngineException_2() + throws Exception { + String message = ""; + + PolicyEngineException result = new PolicyEngineException(message); + + // add additional test code here + assertNotNull(result); + assertEquals(null, result.getCause()); + assertEquals("org.onap.policy.api.PolicyEngineException: ", result.toString()); + assertEquals("", result.getLocalizedMessage()); + assertEquals("", result.getMessage()); + } + + /** + * Run the PolicyEngineException(Throwable) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testPolicyEngineException_3() + throws Exception { + Throwable cause = new Throwable(); + + PolicyEngineException result = new PolicyEngineException(cause); + + // add additional test code here + assertNotNull(result); + assertEquals("org.onap.policy.api.PolicyEngineException: java.lang.Throwable", result.toString()); + assertEquals("java.lang.Throwable", result.getLocalizedMessage()); + assertEquals("java.lang.Throwable", result.getMessage()); + } + + /** + * Run the PolicyEngineException(String,Throwable) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testPolicyEngineException_4() + throws Exception { + String message = ""; + Throwable cause = new Throwable(); + + PolicyEngineException result = new PolicyEngineException(message, cause); + + // add additional test code here + assertNotNull(result); + assertEquals("org.onap.policy.api.PolicyEngineException: ", result.toString()); + assertEquals("", result.getLocalizedMessage()); + assertEquals("", result.getMessage()); + } + + /** + * Run the PolicyEngineException(String,Throwable,boolean,boolean) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testPolicyEngineException_5() + throws Exception { + String message = ""; + Throwable cause = new Throwable(); + boolean enableSuppression = true; + boolean writableStackTrace = true; + + PolicyEngineException result = new PolicyEngineException(message, cause, enableSuppression, writableStackTrace); + + // add additional test code here + assertNotNull(result); + assertEquals("org.onap.policy.api.PolicyEngineException: ", result.toString()); + assertEquals("", result.getLocalizedMessage()); + assertEquals("", result.getMessage()); + } + + /** + * 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(PolicyEngineExceptionTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineInterfaceTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineInterfaceTest.java new file mode 100644 index 000000000..be9e0e7e8 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineInterfaceTest.java @@ -0,0 +1,670 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import java.io.StringReader; +import java.net.HttpURLConnection; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import javax.json.Json; +import javax.json.JsonObject; +import javax.json.JsonReader; + +import org.mockito.Mockito; +import org.onap.policy.api.AttributeType; +import org.onap.policy.api.ConfigRequestParameters; +import org.onap.policy.api.DecisionRequestParameters; +import org.onap.policy.api.DecisionResponse; +import org.onap.policy.api.DeletePolicyCondition; +import org.onap.policy.api.DeletePolicyParameters; +import org.onap.policy.api.EventRequestParameters; +import org.onap.policy.api.ImportParameters; +import org.onap.policy.api.ImportParameters.IMPORT_TYPE; +import org.onap.policy.api.NotificationHandler; +import org.onap.policy.api.NotificationScheme; +import org.onap.policy.api.PDPNotification; +import org.onap.policy.api.PolicyChangeResponse; +import org.onap.policy.api.PolicyClass; +import org.onap.policy.api.PolicyConfig; +import org.onap.policy.api.PolicyConfigException; +import org.onap.policy.api.PolicyDecisionException; +import org.onap.policy.api.PolicyEngine; +import org.onap.policy.api.PolicyEngineException; +import org.onap.policy.api.PolicyEventException; +import org.onap.policy.api.PolicyParameters; +import org.onap.policy.api.PolicyResponse; +import org.onap.policy.api.PushPolicyParameters; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; +import org.onap.policy.std.StdPDPNotification; +import org.onap.policy.std.StdPolicyChangeResponse; +import org.onap.policy.std.StdPolicyResponse; + +import junit.framework.TestCase; + +/** + * The class PolicyEngineInterfaceTest contains tests for the + * class {@link PolicyEngine} + * + * @pattern JUnit Test Case + * + * @generatedBy CodePro at 5/27/16 10:33 AM + * + * + * @version $Revision$ + */ +public class PolicyEngineInterfaceTest extends TestCase { + + private static final Logger logger = FlexLogger.getLogger(PolicyEngineInterfaceTest.class); + + private PolicyEngine policyEngine = null; + private PolicyEngine mockPolicyEngine = null; + private Collection policyConfig = null; + private UUID requestID = UUID.randomUUID(); + + + PolicyChangeResponse result = null; + StdPolicyChangeResponse response = new StdPolicyChangeResponse(); + + + /** + * Construct new test instance + * + * @param name the test name + */ + public PolicyEngineInterfaceTest(String name) { + super(name); + } + + /** + * Perform pre-test initialization + * + * @throws Exception + * + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + try { + policyEngine = new PolicyEngine("Test/config_pass.properties"); + } catch (PolicyEngineException e) { + logger.error(e.getMessage()); + fail("PolicyEngine Instantiation Error" + e); + } + logger.info("Loaded.. PolicyEngine"); + + mockPolicyEngine = Mockito.mock(PolicyEngine.class); + HttpURLConnection conn = Mockito.mock(HttpURLConnection.class); + Mockito.when(conn.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK); + + } + + /** + * Perform post-test clean up + * + * @throws Exception + * + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + super.tearDown(); + // Add additional tear down code here + } + + /** + * Run the Collection getConfigByPolicyName(String) method + * test + */ + @SuppressWarnings("deprecation") + public void testGetConfigByPolicyName() { + String policyName = null; + try{ + policyConfig = policyEngine.getConfigByPolicyName(policyName); + } catch (PolicyConfigException e){ + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @SuppressWarnings("deprecation") + public void testGetConfigByPolicyName2() { + String policyName = null; + + try{ + policyConfig = policyEngine.getConfigByPolicyName(policyName, requestID); + } catch (PolicyConfigException e){ + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + /** + * Run the Collection getConfig(String) method test + */ + @SuppressWarnings("deprecation") + public void testGetConfig() { + String onapName = null; + + try{ + policyConfig = policyEngine.getConfig(onapName); + } catch (PolicyConfigException e){ + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @SuppressWarnings("deprecation") + public void testGetConfig2() { + String onapName = null; + + try{ + policyConfig = policyEngine.getConfig(onapName,requestID); + } catch (PolicyConfigException e){ + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + + @SuppressWarnings("deprecation") + public void testGetConfig3() { + String onapName = null; + String configName = null; + + try{ + policyConfig = policyEngine.getConfig(onapName,configName,requestID); + } catch (PolicyConfigException e){ + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @SuppressWarnings("deprecation") + public void testGetConfig4() { + String onapName = null; + String configName = null; + Map configAttributes = null; + + try{ + policyConfig = policyEngine.getConfig(onapName,configName,configAttributes); + } catch (PolicyConfigException e){ + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @SuppressWarnings("deprecation") + public void testGetConfig5() { + String onapName = null; + String configName = null; + Map configAttributes = null; + + try{ + policyConfig = policyEngine.getConfig(onapName,configName,configAttributes,requestID); + } catch (PolicyConfigException e){ + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + public void testGetConfig6() { + ConfigRequestParameters parameters = new ConfigRequestParameters(); + + try{ + policyConfig = policyEngine.getConfig(parameters); + } catch (PolicyConfigException e){ + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + + /** + * Run the Collection sendEvent(Map) method + * test + */ + @SuppressWarnings("deprecation") + public void testSendEvent() + { + Collection result = null; + Collection response = null; + Map eventAttributes = null; + + try { + Mockito.when(mockPolicyEngine.sendEvent(eventAttributes)).thenReturn(result); + result = mockPolicyEngine.sendEvent(eventAttributes); + } catch (PolicyEventException e) { + logger.error("Exception Occured"+e); + } + + + assertEquals(result,response); + + } + + @SuppressWarnings("deprecation") + public void testSendEvent2() + { + Collection result = null; + Collection response = null; + Map eventAttributes = null; + + try { + Mockito.when(mockPolicyEngine.sendEvent(eventAttributes,requestID)).thenReturn(result); + result = mockPolicyEngine.sendEvent(eventAttributes,requestID); + } catch (PolicyEventException e) { + logger.error("Exception Occured"+e); + } + + + assertEquals(result,response); + + } + + public void testSendEvent3() + { + Collection result = null; + Collection response = null; + EventRequestParameters parameters = new EventRequestParameters(); + + try { + Mockito.when(mockPolicyEngine.sendEvent(parameters)).thenReturn(result); + result = mockPolicyEngine.sendEvent(parameters); + } catch (PolicyEventException e) { + logger.error("Exception Occured"+e); + } + + assertEquals(result,response); + + } + + + + /** + * Run the PolicyDecision getDecision(String, Map) method + * test + */ + @SuppressWarnings("deprecation") + public void testGetDecision() + { + String onapComponentName = null; + Map decisionAttributes = null; + + DecisionResponse result = null; + + try { + Mockito.when(mockPolicyEngine.getDecision(onapComponentName,decisionAttributes)).thenReturn(null); + result = mockPolicyEngine.getDecision(onapComponentName,decisionAttributes); + } catch (PolicyDecisionException e) { + logger.error("Exception Occured"+e); + } + + assertEquals(result,null); + } + + @SuppressWarnings("deprecation") + public void testGetDecision2() + { + String onapComponentName = null; + Map decisionAttributes = null; + + DecisionResponse result = null; + + try { + Mockito.when(mockPolicyEngine.getDecision(onapComponentName,decisionAttributes,requestID)).thenReturn(null); + result = mockPolicyEngine.getDecision(onapComponentName,decisionAttributes); + } catch (PolicyDecisionException e) { + logger.error("Exception Occured"+e); + } + + assertEquals(result,null); + } + + public void testGetDecision3() + { + DecisionRequestParameters parameters = new DecisionRequestParameters(); + DecisionResponse result = null; + + try { + Mockito.when(mockPolicyEngine.getDecision(parameters)).thenReturn(null); + result = mockPolicyEngine.getDecision(parameters); + } catch (PolicyDecisionException e) { + logger.error("Exception Occured"+e); + } + + assertEquals(result,null); + } + + /** + * Run the void setNotification(NotificationScheme, NotificationHandler) + * method test + */ + public void testSetNotification() { + // add test code here + + NotificationScheme scheme = null; + NotificationHandler handler = null; + + Mockito.doNothing().when(mockPolicyEngine).setNotification(scheme, handler); + mockPolicyEngine.setNotification(scheme, handler); + //assertTrue(true); + } + + /** + * Run the void clearNotification() method test + */ + public void testClearNotification() { + // add test code here + + Mockito.doNothing().when(mockPolicyEngine).clearNotification(); + mockPolicyEngine.clearNotification(); + //assertTrue(true); + } + + /** + * Run the void setScheme(NotificationScheme) method test + */ + public void testSetScheme() { + NotificationScheme scheme = null; + + Mockito.doNothing().when(mockPolicyEngine).setScheme(scheme); + mockPolicyEngine.setScheme(scheme); + //assertTrue(true); + } + + /** + * Run the PDPNotification getNotification() method test + */ + public void testGetNotification() { + PDPNotification result = null; + StdPDPNotification response = null; + Mockito.when(mockPolicyEngine.getNotification()).thenReturn(response); + result = mockPolicyEngine.getNotification(); + + assertEquals(result,response); + } + + /** + * Run the String createConfigPolicy(String, String, String, String, + * Map, String, String, String, UUID) method test + */ + @SuppressWarnings("deprecation") + public void testCreateConfigPolicy() + { + String response = "success"; + String result = null; + try { + + Mockito.when(mockPolicyEngine.createConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null)).thenReturn(response); + result = mockPolicyEngine.createConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + /** + * Run the String updateConfigPolicy(String, String, String, String, + * Map, String, String, String, UUID) method test + */ + @SuppressWarnings("deprecation") + public void testUpdateConfigPolicy() + { + String response = "success"; + String result = null; + try { + + Mockito.when(mockPolicyEngine.updateConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null)).thenReturn(response); + result = mockPolicyEngine.updateConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + /** + * Run the String createConfigFirewallPolicy(String, JsonObject, String, + * UUID) method test + */ + @SuppressWarnings("deprecation") + public void testCreateConfigFirewallPolicy() { + String response = "success"; + String result = null; + String json = "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"rule1607\",\"deploymentOption\":{\"deployNow\":false},\"securityZoneId\":\"/v0/firewall/pan\",\"serviceGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"REFERENCE\",\"name\":\"SList\"},{\"type\":\"REFERENCE\",\"name\":\"Syslog\"}]},{\"name\":\"Syslog\",\"description\":\"NA\",\"type\":\"SERVICE\",\"transportProtocol\":\"udp\",\"appProtocol\":null,\"ports\":\"514\"},{\"name\":\"SList\",\"description\":\"Service List\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\",\"appProtocol\":null,\"ports\":\"8080\"}],\"addressGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"},{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]},{\"name\":\"PL_CCE3\",\"description\":\"CCE Routers\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]}],\"firewallRuleList\":[{\"position\":\"1\",\"ruleName\":\"1607Rule\",\"fromZones\":[\"Trusted\"],\"toZones\":[\"Untrusted\"],\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\",\"value\":\"PL_CCE3\"},{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"destinationList\":[{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"1607Group\"}],\"action\":\"accept\",\"description\":\"Rule for 1607 templates\",\"enabled\":true,\"log\":true}]}"; + JsonObject jsonObj = buildJSON(json); + try { + + Mockito.when(mockPolicyEngine.createConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null)).thenReturn(response); + result = mockPolicyEngine.createConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + /** + * Run the String updateConfigFirewallPolicy(String, JsonObject, String, + * UUID) method test + */ + @SuppressWarnings("deprecation") + public void testUpdateConfigFirewallPolicy() { + String response = "success"; + String result = null; + String json = "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"rule1607\",\"deploymentOption\":{\"deployNow\":false},\"securityZoneId\":\"/v0/firewall/pan\",\"serviceGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"REFERENCE\",\"name\":\"SList\"},{\"type\":\"REFERENCE\",\"name\":\"Syslog\"}]},{\"name\":\"Syslog\",\"description\":\"NA\",\"type\":\"SERVICE\",\"transportProtocol\":\"udp\",\"appProtocol\":null,\"ports\":\"514\"},{\"name\":\"SList\",\"description\":\"Service List\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\",\"appProtocol\":null,\"ports\":\"8080\"}],\"addressGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"},{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]},{\"name\":\"PL_CCE3\",\"description\":\"CCE Routers\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]}],\"firewallRuleList\":[{\"position\":\"1\",\"ruleName\":\"1607Rule\",\"fromZones\":[\"Trusted\"],\"toZones\":[\"Untrusted\"],\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\",\"value\":\"PL_CCE3\"},{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"destinationList\":[{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"1607Group\"}],\"action\":\"accept\",\"description\":\"Rule for 1607 templates\",\"enabled\":true,\"log\":true}]}"; + JsonObject jsonObj = buildJSON(json); + try { + + Mockito.when(mockPolicyEngine.updateConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null)).thenReturn(response); + result = mockPolicyEngine.updateConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + /** + * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test + */ + public void testCreatePolicy() { + response.setResponseMessage("success"); + PolicyChangeResponse result = null; + PolicyParameters policyParameters = new PolicyParameters(); + + policyParameters.setPolicyClass(PolicyClass.Action); //required + policyParameters.setPolicyName("test.junitTest"); //required + policyParameters.setPolicyDescription("testing"); //optional + + //Set the Component Attributes... These are Optional + Map configAttributes = new HashMap(); + configAttributes.put("test", "testing"); + + Map> attributes = new HashMap>(); + attributes.put(AttributeType.MATCHING, configAttributes); + policyParameters.setAttributes(attributes); + + policyParameters.setActionPerformer("PEP"); + policyParameters.setActionAttribute("testing"); + policyParameters.setRequestID(UUID.randomUUID()); + + try { + + //stdPolicyEngine = Mockito.mock(StdPolicyEngine.class); + //Mockito.when(stdPolicyEngine.callPAP(newPAPPolicy, new String[] {"operation=create", "apiflag=api", "policyType=Action"}, null, "Action")).thenReturn(callPapResponse); + Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response); + result = mockPolicyEngine.createPolicy(policyParameters); + + } catch (Exception e) { + logger.warn(e.getMessage()); + logger.error("Exception Occured"+e); + } + assertEquals(result, response); + } + + /** + * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test + */ + public void testUpdatePolicy() { + response.setResponseMessage("success"); + PolicyChangeResponse result = null; + PolicyParameters policyParameters = new PolicyParameters(); + + policyParameters.setPolicyClass(PolicyClass.Action); //required + policyParameters.setPolicyName("test.junitTest"); //required + policyParameters.setPolicyDescription("testing"); //optional + + //Set the Component Attributes... These are Optional + Map configAttributes = new HashMap(); + configAttributes.put("test", "testing"); + + Map> attributes = new HashMap>(); + attributes.put(AttributeType.MATCHING, configAttributes); + policyParameters.setAttributes(attributes); + + policyParameters.setActionPerformer("PEP"); + policyParameters.setActionAttribute("testing"); + policyParameters.setRequestID(UUID.randomUUID()); + + try { + + Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response); + result = mockPolicyEngine.updatePolicy(policyParameters); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + assertEquals(result, response); + } + + /** + * Run the String pushPolicy(String, String, String, String, UUID) method + * test + */ + @SuppressWarnings("deprecation") + public void testPushPolicy() { + String response = "Success"; + String result = null; + try { + + Mockito.when(mockPolicyEngine.pushPolicy("testing","test","Base","default",requestID)).thenReturn(response); + result = mockPolicyEngine.pushPolicy("testing","test","Base","default",requestID); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + + assertEquals(result, response); + } + + public void testPushPolicy2() { + PushPolicyParameters policyParameters = new PushPolicyParameters(); + PolicyChangeResponse result = null; + + //String policyScope = null; + policyParameters.setPolicyName("test.junitTest"); + policyParameters.setPolicyType("Action"); + policyParameters.setPdpGroup("Default"); + + try { + + Mockito.when(mockPolicyEngine.pushPolicy(policyParameters)).thenReturn(response); + result = mockPolicyEngine.pushPolicy(policyParameters); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + + assertEquals(result, response); + } + + /** + * Run the PolicyChangeResponse deletePolicy(DeletePolicyParameters) method + * test + */ + public void testDeletePolicy() { + DeletePolicyParameters policyParameters = new DeletePolicyParameters(); + PolicyChangeResponse result = null; + + //String policyScope = null; + policyParameters.setPolicyName("test.junitTest.1.xml"); + policyParameters.setDeleteCondition(DeletePolicyCondition.ALL); + policyParameters.setPolicyComponent("PAP"); + policyParameters.setPdpGroup("Default"); + + try { + + Mockito.when(mockPolicyEngine.deletePolicy(policyParameters)).thenReturn(response); + result = mockPolicyEngine.deletePolicy(policyParameters); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + + assertEquals(result, response); + } + + /** + * Run the PolicyChangeResponse policyEngineImport(ImportParameters) method + * test + */ + public void testPolicyEngineImport() { + ImportParameters importParameters = new ImportParameters(); + PolicyChangeResponse result = null; + + importParameters.setFilePath("C:\\Workspaces\\models\\TestingModel\\ControllerServiceSampleSdnlServiceInstance-v0.1.0-SNAPSHOT.zip"); + importParameters.setServiceName("ControllerServiceSampleSdnlServiceInstance"); + + importParameters.setRequestID(UUID.randomUUID()); + importParameters.setServiceType(IMPORT_TYPE.MICROSERVICE); + importParameters.setVersion("1607-2"); + + + try { + + Mockito.when(mockPolicyEngine.policyEngineImport(importParameters)).thenReturn(response); + result = mockPolicyEngine.policyEngineImport(importParameters); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + + assertEquals(result, response); + } + + private static JsonObject buildJSON(String jsonString) { + JsonObject json = null;; + if (jsonString != null) { + StringReader in = null; + + in = new StringReader(jsonString); + + JsonReader jsonReader = Json.createReader(in); + json = jsonReader.readObject(); + } + + return json; + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineTest.java new file mode 100644 index 000000000..abfab075b --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineTest.java @@ -0,0 +1,170 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.Test; +import org.onap.policy.api.NotificationScheme; +import org.onap.policy.api.PolicyEngine; +import org.onap.policy.api.PolicyEngineException; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; + +public class PolicyEngineTest { + + private static final Logger logger = FlexLogger.getLogger(PolicyEngineTest.class); + private PolicyEngine policyEngine = null; + private String filePath = null; + + @Test + public void testPolicyEngineForFail() { + filePath = null; + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNull(policyEngine); + // Test even for this case. + filePath = "NotNull"; + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNull(policyEngine); + } + + @Test + public void testPolicyEngineforPropertyFileError() { + filePath = "Test/config_error.property"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNull(policyEngine); + } + + @Test + public void testPolicyEngineforPDPURLError() { + String filePath = "Test/config_fail.properties"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNull(policyEngine); + } + + @Test + public void testPolicyEngineForPass() { + String filePath = "Test/config_pass.properties"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNotNull(policyEngine); + } + + @Test + public void testPolicyEngineForUEBPass() { + String filePath = "Test/config_UEB_pass.properties"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNotNull(policyEngine); + } + + + @Test + public void testPolicyEngineForUEBBadType() { + String filePath = "Test/config_UEB_bad_type.properties"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNotNull(policyEngine); + } + + @Test + public void testPolicyEngineForUEBBadServerType() { + String filePath = "Test/config_UEB_badservers.properties"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNotNull(policyEngine); + } + + @Test + public void testPolicyEngineNotficationAutoUEB() { + String filePath = "Test/config_UEB_pass.properties"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + policyEngine.setScheme(NotificationScheme.AUTO_ALL_NOTIFICATIONS); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNotNull(policyEngine); + } + + @Test + public void testPolicyEngineNotficationAuto() { + String filePath = "Test/config_pass.properties"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + policyEngine.setScheme(NotificationScheme.AUTO_ALL_NOTIFICATIONS); + //policyEngine.getNotification(); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNotNull(policyEngine); + } + + public void isFileAvailable(String filePath) { + Path file = Paths.get(filePath); + if (Files.notExists(file)) { + logger.error("File Doesn't Exist "+ file.toString()); + fail("File: " +filePath + " Not found"); + } + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEventExceptionTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEventExceptionTest.java new file mode 100644 index 000000000..6f7573352 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEventExceptionTest.java @@ -0,0 +1,183 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.*; +import org.onap.policy.api.PolicyEventException; + +import static org.junit.Assert.*; + +/** + * The class PolicyEventExceptionTest contains tests for the class {@link PolicyEventException}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class PolicyEventExceptionTest { + /** + * Run the PolicyEventException() constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPolicyEventException_1() + throws Exception { + + PolicyEventException result = new PolicyEventException(); + + // add additional test code here + assertNotNull(result); + assertEquals(null, result.getCause()); + assertEquals("org.onap.policy.api.PolicyEventException", result.toString()); + assertEquals(null, result.getLocalizedMessage()); + assertEquals(null, result.getMessage()); + } + + /** + * Run the PolicyEventException(String) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPolicyEventException_2() + throws Exception { + String message = ""; + + PolicyEventException result = new PolicyEventException(message); + + // add additional test code here + assertNotNull(result); + assertEquals(null, result.getCause()); + assertEquals("org.onap.policy.api.PolicyEventException: ", result.toString()); + assertEquals("", result.getLocalizedMessage()); + assertEquals("", result.getMessage()); + } + + /** + * Run the PolicyEventException(Throwable) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPolicyEventException_3() + throws Exception { + Throwable cause = new Throwable(); + + PolicyEventException result = new PolicyEventException(cause); + + // add additional test code here + assertNotNull(result); + assertEquals("org.onap.policy.api.PolicyEventException: java.lang.Throwable", result.toString()); + assertEquals("java.lang.Throwable", result.getLocalizedMessage()); + assertEquals("java.lang.Throwable", result.getMessage()); + } + + /** + * Run the PolicyEventException(String,Throwable) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPolicyEventException_4() + throws Exception { + String message = ""; + Throwable cause = new Throwable(); + + PolicyEventException result = new PolicyEventException(message, cause); + + // add additional test code here + assertNotNull(result); + assertEquals("org.onap.policy.api.PolicyEventException: ", result.toString()); + assertEquals("", result.getLocalizedMessage()); + assertEquals("", result.getMessage()); + } + + /** + * Run the PolicyEventException(String,Throwable,boolean,boolean) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPolicyEventException_5() + throws Exception { + String message = ""; + Throwable cause = new Throwable(); + boolean enableSuppression = true; + boolean writableStackTrace = true; + + PolicyEventException result = new PolicyEventException(message, cause, enableSuppression, writableStackTrace); + + // add additional test code here + assertNotNull(result); + assertEquals("org.onap.policy.api.PolicyEventException: ", result.toString()); + assertEquals("", result.getLocalizedMessage()); + assertEquals("", result.getMessage()); + } + + /** + * 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(PolicyEventExceptionTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyParametersTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyParametersTest.java new file mode 100644 index 000000000..ff192dcab --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyParametersTest.java @@ -0,0 +1,1409 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.Hashtable; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.api.AttributeType; +import org.onap.policy.api.PolicyClass; +import org.onap.policy.api.PolicyConfigType; +import org.onap.policy.api.PolicyParameters; +import org.onap.policy.api.PolicyType; + +/** + * The class PolicyParametersTest contains tests for the class {@link PolicyParameters}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class PolicyParametersTest { + /** + * Run the String getActionAttribute() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetActionAttribute_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getActionAttribute(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the String getActionPerformer() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetActionPerformer_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getActionPerformer(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the Map> getAttributes() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetAttributes_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + Map> result = fixture.getAttributes(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the String getConfigBody() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetConfigBody_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getConfigBody(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the PolicyType getConfigBodyType() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetConfigBodyType_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + PolicyType result = fixture.getConfigBodyType(); + + // add additional test code here + assertNotNull(result); + assertEquals("json", result.toString()); + assertEquals("JSON", result.name()); + assertEquals(1, result.ordinal()); + } + + /** + * Run the String getConfigName() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetConfigName_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getConfigName(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the List getDynamicRuleAlgorithmField1() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetDynamicRuleAlgorithmField1_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + List result = fixture.getDynamicRuleAlgorithmField1(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the List getDynamicRuleAlgorithmField2() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetDynamicRuleAlgorithmField2_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + List result = fixture.getDynamicRuleAlgorithmField2(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the List getDynamicRuleAlgorithmFunctions() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetDynamicRuleAlgorithmFunctions_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + List result = fixture.getDynamicRuleAlgorithmFunctions(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the List getDynamicRuleAlgorithmLabels() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetDynamicRuleAlgorithmLabels_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + List result = fixture.getDynamicRuleAlgorithmLabels(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the String getOnapName() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetOnapName_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getOnapName(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the PolicyClass getPolicyClass() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetPolicyClass_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + PolicyClass result = fixture.getPolicyClass(); + + // add additional test code here + assertNotNull(result); + assertEquals("Action", result.toString()); + assertEquals("Action", result.name()); + assertEquals(1, result.ordinal()); + } + + /** + * Run the PolicyConfigType getPolicyConfigType() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetPolicyConfigType_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + PolicyConfigType result = (PolicyConfigType) fixture.getPolicyConfigType(); + + // add additional test code here + assertNotNull(result); + assertEquals("BRMS_Param", result.toString()); + assertEquals("BRMS_PARAM", result.name()); + assertEquals(5, result.ordinal()); + } + + /** + * Run the String getPolicyDescription() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetPolicyDescription_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getPolicyDescription(); + + // 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_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getPolicyName(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the String getPriority() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetPriority_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getPriority(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the UUID getRequestID() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetRequestID_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.fromString("878d319c-2799-4684-b480-99f40e1042b2")); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + UUID result = fixture.getRequestID(); + + // add additional test code here + assertNotNull(result); + assertEquals("878d319c-2799-4684-b480-99f40e1042b2", result.toString()); + assertEquals(4, result.version()); + assertEquals(2, result.variant()); + assertEquals(-5440179076376542542L, result.getLeastSignificantBits()); + assertEquals(-8679226360124062076L, result.getMostSignificantBits()); + } + + /** + * Run the void setActionAttribute(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetActionAttribute_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String actionAttribute = ""; + + fixture.setActionAttribute(actionAttribute); + + // add additional test code here + } + + /** + * Run the void setActionPerformer(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetActionPerformer_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String actionPerformer = ""; + + fixture.setActionPerformer(actionPerformer); + + // add additional test code here + } + + /** + * Run the void setAttributes(Map>) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetAttributes_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + Map> attributes = new Hashtable>(); + + fixture.setAttributes(attributes); + + // add additional test code here + } + + /** + * Run the void setConfigBody(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetConfigBody_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String configBody = ""; + + fixture.setConfigBody(configBody); + + // add additional test code here + } + + /** + * Run the void setConfigBodyType(PolicyType) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetConfigBodyType_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + PolicyType configBodyType = PolicyType.JSON; + + fixture.setConfigBodyType(configBodyType); + + // add additional test code here + } + + /** + * Run the void setConfigFirewallPolicyParameters(String,String,UUID) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetConfigFirewallPolicyParameters_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String policyName = ""; + String firewallJson = ""; + UUID requestID = UUID.randomUUID(); + + fixture.setConfigFirewallPolicyParameters(policyName, firewallJson, requestID); + + // 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 { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String configName = ""; + + fixture.setConfigName(configName); + + // add additional test code here + } + + /** + * Run the void setConfigPolicyParameters(PolicyConfigType,String,String,String,String,Map>,PolicyType,String,UUID) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetConfigPolicyParameters_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + PolicyConfigType policyConfigType = PolicyConfigType.BRMS_PARAM; + String policyName = ""; + String policyDescription = ""; + String onapName = ""; + String configName = ""; + Map> attributes = new Hashtable>(); + PolicyType configBodyType = PolicyType.JSON; + String configBody = ""; + UUID requestID = UUID.randomUUID(); + + fixture.setConfigPolicyParameters(policyConfigType, policyName, policyDescription, onapName, configName, attributes, configBodyType, configBody, requestID); + + // add additional test code here + } + + /** + * Run the void setDynamicRuleAlgorithmField1(List) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetDynamicRuleAlgorithmField1_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + List dynamicRuleAlgorithmField1 = new LinkedList(); + + fixture.setDynamicRuleAlgorithmField1(dynamicRuleAlgorithmField1); + + // add additional test code here + } + + /** + * Run the void setDynamicRuleAlgorithmField2(List) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetDynamicRuleAlgorithmField2_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + List dynamicRuleAlgorithmField2 = new LinkedList(); + + fixture.setDynamicRuleAlgorithmField2(dynamicRuleAlgorithmField2); + + // add additional test code here + } + + /** + * Run the void setDynamicRuleAlgorithmFunctions(List) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetDynamicRuleAlgorithmFunctions_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + List dynamicRuleAlgorithmFunctions = new LinkedList(); + + fixture.setDynamicRuleAlgorithmFunctions(dynamicRuleAlgorithmFunctions); + + // add additional test code here + } + + /** + * Run the void setDynamicRuleAlgorithmLabels(List) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetDynamicRuleAlgorithmLabels_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + List dynamicRuleAlgorithmLabels = new LinkedList(); + + fixture.setDynamicRuleAlgorithmLabels(dynamicRuleAlgorithmLabels); + + // 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 { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String onapName = ""; + + fixture.setOnapName(onapName); + + // add additional test code here + } + + /** + * Run the void setPolicyClass(PolicyClass) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetPolicyClass_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + PolicyClass policyClass = PolicyClass.Action; + + fixture.setPolicyClass(policyClass); + + // add additional test code here + } + + /** + * Run the void setPolicyConfigType(PolicyConfigType) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetPolicyConfigType_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + PolicyConfigType policyConfigType = PolicyConfigType.BRMS_PARAM; + + fixture.setPolicyConfigType(policyConfigType); + + // add additional test code here + } + + /** + * Run the void setPolicyDescription(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetPolicyDescription_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String policyDescription = ""; + + fixture.setPolicyDescription(policyDescription); + + // 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 { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String policyName = ""; + + fixture.setPolicyName(policyName); + + // add additional test code here + } + + /** + * Run the void setPriority(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetPriority_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String priority = ""; + + fixture.setPriority(priority); + + // add additional test code here + } + + /** + * Run the void setRequestID(UUID) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetRequestID_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable>()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setOnapName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + 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: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(PolicyParametersTest.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 new file mode 100644 index 000000000..294f0929d --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseStatusTest.java @@ -0,0 +1,154 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.*; +import org.onap.policy.api.PolicyResponseStatus; + +import static org.junit.Assert.*; + +/** + * The class PolicyResponseStatusTest contains tests for the class {@link PolicyResponseStatus}. + * + * @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 = ""; + + 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_3() + 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 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); + } + + /** + * 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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseTest.java new file mode 100644 index 000000000..b0a71d375 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseTest.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.After; +import org.junit.Before; +import org.onap.policy.api.PolicyResponse; + +/** + * The class PolicyResponseTest contains tests for the class {@link PolicyResponse}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class PolicyResponseTest { + /** + * 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(PolicyResponseTest.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 new file mode 100644 index 000000000..9f1a608da --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyTypeTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.*; +import org.onap.policy.api.PolicyType; + +import static org.junit.Assert.*; + +/** + * The class PolicyTypeTest contains tests for the class {@link PolicyType}. + * + * @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; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("json", 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(PolicyTypeTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PushPolicyParametersTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PushPolicyParametersTest.java new file mode 100644 index 000000000..832589757 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PushPolicyParametersTest.java @@ -0,0 +1,269 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import java.util.UUID; + +import org.junit.*; +import org.onap.policy.api.PushPolicyParameters; + +import static org.junit.Assert.*; + +/** + * The class PushPolicyParametersTest contains tests for the class {@link PushPolicyParameters}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class PushPolicyParametersTest { + /** + * Run the PushPolicyParameters() constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPushPolicyParameters_1() + throws Exception { + + PushPolicyParameters result = new PushPolicyParameters(); + + // add additional test code here + assertNotNull(result); + assertEquals(null, result.getPolicyName()); + assertEquals(null, result.getRequestID()); + assertEquals(null, result.getPolicyType()); + assertEquals(null, result.getPdpGroup()); + } + + /** + * Run the PushPolicyParameters(String,String,String,UUID) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testPushPolicyParameters_2() + throws Exception { + String policyName = ""; + String policyType = ""; + String pdpGroup = ""; + UUID requestID = UUID.randomUUID(); + + PushPolicyParameters result = new PushPolicyParameters(policyName, policyType, pdpGroup, requestID); + + // add additional test code here + assertNotNull(result); + assertEquals("", result.getPolicyName()); + assertEquals("", result.getPolicyType()); + assertEquals("", result.getPdpGroup()); + } + + /** + * Run the String getPdpGroup() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetPdpGroup_1() + throws Exception { + PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID()); + + String result = fixture.getPdpGroup(); + + // 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 { + PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID()); + + String result = fixture.getPolicyName(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the String getPolicyType() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetPolicyType_1() + throws Exception { + PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID()); + + String result = fixture.getPolicyType(); + + // 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() + throws Exception { + PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.fromString("d1dbaac1-0944-4f07-9ce7-733c697537ea")); + + UUID result = fixture.getRequestID(); + + // add additional test code here + assertNotNull(result); + assertEquals("d1dbaac1-0944-4f07-9ce7-733c697537ea", result.toString()); + assertEquals(4, result.version()); + assertEquals(2, result.variant()); + assertEquals(-7140611980868110358L, result.getLeastSignificantBits()); + assertEquals(-3324876153822097657L, result.getMostSignificantBits()); + } + + /** + * 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 { + PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID()); + String pdpGroup = ""; + + fixture.setPdpGroup(pdpGroup); + + // 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 { + PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID()); + String policyName = ""; + + fixture.setPolicyName(policyName); + + // add additional test code here + } + + /** + * Run the void setPolicyType(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetPolicyType_1() + throws Exception { + PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID()); + String policyType = ""; + + fixture.setPolicyType(policyType); + + // 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 { + PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID()); + 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(PushPolicyParametersTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/RemovedPolicyTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/RemovedPolicyTest.java new file mode 100644 index 000000000..6a53cbfb1 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/RemovedPolicyTest.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.After; +import org.junit.Before; +import org.onap.policy.api.RemovedPolicy; + +/** + * The class RemovedPolicyTest contains tests for the class {@link RemovedPolicy}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class RemovedPolicyTest { + /** + * 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(RemovedPolicyTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/SendEventTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/SendEventTest.java new file mode 100644 index 000000000..560ca463f --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/SendEventTest.java @@ -0,0 +1,155 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.junit.Before; +import org.onap.policy.api.PolicyEngine; +import org.onap.policy.api.PolicyEngineException; +import org.onap.policy.api.PolicyEventException; +import org.onap.policy.api.PolicyResponse; +import org.onap.policy.api.PolicyResponseStatus; +import org.onap.policy.common.logging.flexlogger.FlexLogger; +import org.onap.policy.common.logging.flexlogger.Logger; + +public class SendEventTest { + + private PolicyEngine policyEngine = null; + private Map eventAttributes = new HashMap(); + private Collection policyResponse = null; + private static final Logger logger = FlexLogger.getLogger(SendEventTest.class); + @Before + public void setUp() { + try { + policyEngine = new PolicyEngine("Test/config_pass.properties"); + } catch (PolicyEngineException e) { + logger.error(e.getMessage()); + fail("PolicyEngine Instantiation Error" + e); + } + logger.info("Loaded.. PolicyEngine"); + } + + //@Test + @SuppressWarnings("deprecation") + public void testSendEventFail() { + eventAttributes = null; + try { + policyResponse = policyEngine.sendEvent(eventAttributes); + } catch (PolicyEventException e) { + logger.warn(e.getMessage()); + } + assertNull(policyResponse); + } + + //@Test + @SuppressWarnings("deprecation") + public void testSendEventFailNull() { + eventAttributes.put("", ""); + try { + policyResponse = policyEngine.sendEvent(eventAttributes); + } catch (PolicyEventException e) { + logger.warn(e.getMessage()); + } + assertNull(policyResponse); + } + + // deprecated Test. + /*@Test + public void testSendEventFailAttribute() { + eventAttributes.put("Fail.key", "Value"); + try { + policyResponse = policyEngine.sendEvent(eventAttributes); + } catch (PolicyEventException e) { + logger.warn(e.getMessage()); + } + assertNull(policyResponse.getPolicyResponseMessage()); + }*/ + + //@Test + @SuppressWarnings("deprecation") + public void testSendEventNotValid() { + eventAttributes.put("Action.fail", "Value"); + try { + policyResponse = policyEngine.sendEvent(eventAttributes); + } catch (PolicyEventException e) { + logger.warn(e.getMessage()); + } + for(PolicyResponse policyResponse: this.policyResponse){ + logger.info(policyResponse.getPolicyResponseMessage() + " , " + policyResponse.getPolicyResponseStatus()); + assertNotNull(policyResponse); + assertEquals(PolicyResponseStatus.NO_ACTION_REQUIRED, policyResponse.getPolicyResponseStatus()); + assertNotNull(policyResponse.getPolicyResponseMessage()); + assertNotNull(policyResponse.getRequestAttributes()); + assertNull(policyResponse.getActionTaken()); + assertNull(policyResponse.getActionAdvised()); + } + } + + //@Test + @SuppressWarnings("deprecation") + public void testSendEventActionAdvised() { + eventAttributes.put("Key", "Value"); + eventAttributes.put("cpu", "80"); + try { + policyResponse = policyEngine.sendEvent(eventAttributes); + } catch (PolicyEventException e) { + logger.warn(e.getMessage()); + } + for(PolicyResponse policyResponse: this.policyResponse){ + logger.info(policyResponse.getPolicyResponseMessage() + " , " + policyResponse.getPolicyResponseStatus()); + assertNotNull(policyResponse); + assertEquals(PolicyResponseStatus.ACTION_ADVISED, policyResponse.getPolicyResponseStatus()); + assertNotNull(policyResponse.getPolicyResponseMessage()); + assertNotNull(policyResponse.getRequestAttributes()); + assertNull(policyResponse.getActionTaken()); + assertNotNull(policyResponse.getActionAdvised()); + } + } + + //@Test + @SuppressWarnings("deprecation") + public void testSendEventActionTaken() { + eventAttributes.put("Key", "Value"); + eventAttributes.put("cpu", "91"); + try { + policyResponse = policyEngine.sendEvent(eventAttributes); + } catch (PolicyEventException e) { + logger.warn(e.getMessage()); + } + for(PolicyResponse policyResponse: this.policyResponse){ + logger.info(policyResponse.getPolicyResponseMessage() + " , " + policyResponse.getPolicyResponseStatus()); + assertNotNull(policyResponse); + assertEquals(PolicyResponseStatus.ACTION_TAKEN, policyResponse.getPolicyResponseStatus()); + assertNotNull(policyResponse.getPolicyResponseMessage()); + assertNotNull(policyResponse.getRequestAttributes()); + assertNotNull(policyResponse.getActionTaken()); + assertNull(policyResponse.getActionAdvised()); + } + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/TestRunner.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/TestRunner.java new file mode 100644 index 000000000..87687f0ab --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/TestRunner.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.runner.JUnitCore; +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; + +public class TestRunner { + public static void main(String[] args) { + Result result = JUnitCore.runClasses(PolicyEngineTest.class); + for(Failure failure: result.getFailures()) { + System.out.println("Failed Test: " + failure.toString()); + } + Result results = null; + if(result.wasSuccessful()) { + System.out.println("API Methods are being Tested.. "); + results = JUnitCore.runClasses(GetConfigByPolicyNameTest.class, GetConfigStringTest.class,GetConfigStringStringTest.class,GetConfigStringStringMapTest.class,SendEventTest.class); + for(Failure failure: results.getFailures()) { + System.out.println("Failed Test: " + failure.toString()); + } + System.out.println("Test Results.. "); + System.out.println("Stats: \nRun Time: " + (results.getRunTime()+result.getRunTime()) + "\nTotal Tests:" + results.getRunCount()+ result.getRunCount() + + "\nFailures: " + results.getFailureCount()+ result.getFailureCount()); + System.exit(1); + } + System.out.println("Test Failed.."); + System.out.println("Stats: \nRun Time: " + result.getRunTime() + "\nTests:" + result.getRunCount() + + "\nFailures: " + result.getFailureCount()); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/UpdateTypeTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/UpdateTypeTest.java new file mode 100644 index 000000000..500d6c1c5 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/UpdateTypeTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.test; + +import org.junit.*; +import org.onap.policy.api.UpdateType; + +import static org.junit.Assert.*; + +/** + * The class UpdateTypeTest contains tests for the class {@link UpdateType}. + * + * @generatedBy CodePro at 6/1/16 1:39 PM + * @version $Revision: 1.0 $ + */ +public class UpdateTypeTest { + /** + * Run the String toString() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:39 PM + */ + @Test + public void testToString_1() + throws Exception { + UpdateType fixture = UpdateType.NEW; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("new", result); + } + + /** + * Perform pre-test initialization. + * + * @throws Exception + * if the initialization fails for some reason + * + * @generatedBy CodePro at 6/1/16 1:39 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:39 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:39 PM + */ + public static void main(String[] args) { + new org.junit.runner.JUnitCore().run(UpdateTypeTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/package-info.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/package-info.java new file mode 100644 index 000000000..eb92f89bd --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/package-info.java @@ -0,0 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +/** + * API JUNIT TestCases. + */ +package org.onap.policy.test; diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/AutoClientEndTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/AutoClientEndTest.java deleted file mode 100644 index 86f15992a..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/AutoClientEndTest.java +++ /dev/null @@ -1,228 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import static org.junit.Assert.assertNotNull; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openecomp.policy.api.NotificationHandler; -import org.openecomp.policy.api.NotificationScheme; -import org.openecomp.policy.std.AutoClientEnd; -import org.openecomp.policy.std.StdPolicyEngine; - -/** - * The class AutoClientEndTest contains tests for the class {@link AutoClientEnd}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class AutoClientEndTest { - /** - * Run the AutoClientEnd() constructor test. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testAutoClientEnd_1() - throws Exception { - AutoClientEnd result = new AutoClientEnd(); - assertNotNull(result); - // add additional test code here - } - - /** - * Run the boolean getStatus() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetStatus_1() - throws Exception { - - boolean result = AutoClientEnd.getStatus(); - - assertNotNull(result); - } - - /** - * Run the String getURL() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetURL_1() - throws Exception { - - String result = AutoClientEnd.getURL(); - - // 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.openecomp.policy.std.AutoClientEnd - assertNotNull(result); - } - - - /** - * Run the void setAuto(NotificationScheme,NotificationHandler) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetAuto() - throws Exception { - NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS; - NotificationHandler handler = null; - - AutoClientEnd.setAuto(scheme, handler); - - // 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.openecomp.policy.std.AutoClientEnd.(AutoClientEnd.java:39) - } - - /** - * Run the void setScheme(NotificationScheme) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetScheme() - throws Exception { - - NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS; - AutoClientEnd.setScheme(scheme); - - } - - /** - * Run the void start(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testStart() - throws Exception { - String url = "http://test.com"; - - AutoClientEnd.start(url); - - // 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.openecomp.policy.std.AutoClientEnd - } - - - /** - * Run the void start(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testStart_2() - throws Exception { - String url = null; - - AutoClientEnd.start(url); - - // 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.openecomp.policy.std.AutoClientEnd - } - - /** - * Run the void stop() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testStop_1() - throws Exception { - - AutoClientEnd.stop(); - - // 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.openecomp.policy.std.AutoClientEnd - } - - /** - * 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 set up code here - StdPolicyEngine policyEngine = new StdPolicyEngine("Test/config_pass.properties", (String) null); - - NotificationHandler handler = policyEngine.getNotificationHandler(); - AutoClientEnd.setAuto(NotificationScheme.AUTO_ALL_NOTIFICATIONS, handler); - AutoClientEnd.start("http://testurl.com"); - - } - - /** - * 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(AutoClientEndTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/AutoClientUEBTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/AutoClientUEBTest.java deleted file mode 100644 index 28889677b..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/AutoClientUEBTest.java +++ /dev/null @@ -1,567 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import java.util.LinkedList; -import java.util.List; - -import org.junit.*; -import org.openecomp.policy.api.NotificationHandler; -import org.openecomp.policy.api.NotificationScheme; -import org.openecomp.policy.std.AutoClientUEB; - -import static org.junit.Assert.*; - -/** - * The class AutoClientUEBTest contains tests for the class {@link AutoClientUEB}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class AutoClientUEBTest { - /** - * Run the AutoClientUEB(String,List) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testAutoClientUEB_1() - throws Exception { - String url = ""; - String apiKey = ""; - String apiSecret = ""; - List uebURLList = new LinkedList(); - - AutoClientUEB result = new AutoClientUEB(url, uebURLList, apiKey, apiSecret); - - // 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.openecomp.policy.std.AutoClientUEB.(AutoClientUEB.java:39) - assertNotNull(result); - } - - /** - * Run the String getNotficationType() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetNotficationType_1() - throws Exception { - - String result = AutoClientUEB.getNotficationType(); - - // 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.openecomp.policy.std.AutoClientUEB - assertNull(result); - } - - /** - * Run the boolean getStatus() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetStatus_1() - throws Exception { - - boolean result = AutoClientUEB.getStatus(); - - // 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.openecomp.policy.std.AutoClientUEB - assertFalse(result); - } - - /** - * Run the String getURL() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetURL_1() - throws Exception { - - String result = AutoClientUEB.getURL(); - - // 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.openecomp.policy.std.AutoClientUEB - assertNotNull(result); - } - - /** - * Run the boolean isRunning() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testIsRunning_1() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(), "", ""); - fixture.isRunning = true; - - boolean result = fixture.isRunning(); - - // 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.openecomp.policy.std.AutoClientUEB - assertTrue(result); - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_1() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(), "", ""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_2() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(), "", ""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_3() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(), "", ""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_4() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(), "", ""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_5() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_6() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_7() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_8() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_9() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_10() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_11() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_12() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_13() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_14() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_15() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void run() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRun_16() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); - fixture.isRunning = true; - - fixture.run(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void setAuto(NotificationScheme,NotificationHandler) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetAuto_1() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); - fixture.isRunning = true; - NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS; - NotificationHandler handler = null; - - fixture.setAuto(scheme, handler); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void setScheme(NotificationScheme) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetScheme_1() - throws Exception { - NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS; - - AutoClientUEB.setScheme(scheme); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * Run the void terminate() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testTerminate_1() - throws Exception { - AutoClientUEB fixture = new AutoClientUEB("", new LinkedList(),"",""); - fixture.isRunning = true; - - fixture.terminate(); - - // 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.openecomp.policy.std.AutoClientUEB - } - - /** - * 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 set up code here - List urlList = new LinkedList(); - urlList.add("test2.com"); - AutoClientUEB client = new AutoClientUEB("test.com", urlList, "testKey", "testSecret"); - NotificationHandler handler = null; - client.setAuto(NotificationScheme.AUTO_ALL_NOTIFICATIONS, handler); - } - - /** - * 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(AutoClientUEBTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/Handler.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/Handler.java deleted file mode 100644 index 9879174cb..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/Handler.java +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import java.util.Collection; - -import org.openecomp.policy.api.LoadedPolicy; -import org.openecomp.policy.api.NotificationHandler; -import org.openecomp.policy.api.NotificationType; -import org.openecomp.policy.api.PDPNotification; -import org.openecomp.policy.api.PolicyConfig; -import org.openecomp.policy.api.PolicyConfigException; -import org.openecomp.policy.api.PolicyConfigStatus; -import org.openecomp.policy.api.PolicyEngine; -import org.openecomp.policy.api.PolicyEngineException; -import org.openecomp.policy.api.RemovedPolicy; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; - -public class Handler implements NotificationHandler{ - - private static final Logger LOGGER = FlexLogger.getLogger(Handler.class); - - @Override - public void notificationReceived(PDPNotification notification) { - System.out.println("Notification Received..."); - System.out.println(notification.getNotificationType()); - if(notification.getNotificationType().equals(NotificationType.REMOVE)){ - System.out.println("Removed Policies: \n"); - for(RemovedPolicy removedPolicy: notification.getRemovedPolicies()){ - System.out.println(removedPolicy.getPolicyName()); - System.out.println(removedPolicy.getVersionNo()); - } - }else if(notification.getNotificationType().equals(NotificationType.UPDATE)){ - System.out.println("Updated Policies: \n"); - for(LoadedPolicy updatedPolicy: notification.getLoadedPolicies()){ - System.out.println("policyName : " + updatedPolicy.getPolicyName()); - System.out.println("policyVersion :" + updatedPolicy.getVersionNo()); - if(updatedPolicy.getPolicyName().contains(".Config_")){ - System.out.println("Matches: " + updatedPolicy.getMatches()); - System.out.println("UpdateType: "+ updatedPolicy.getUpdateType()); - // Checking the Name is correct or not. - try { - PolicyEngine policyEngine = new PolicyEngine("config.properties"); - @SuppressWarnings("deprecation") - Collection policyConfigs = policyEngine.getConfigByPolicyName(updatedPolicy.getPolicyName()); - for(PolicyConfig policyConfig: policyConfigs){ - if(policyConfig.getPolicyConfigStatus().equals(PolicyConfigStatus.CONFIG_RETRIEVED)){ - System.out.println("Policy Retrieved with this Name notified. "); - }else{ - System.err.println("\n\n Fail to retrieve policy !!!!\n\n"); - } - // Also Test this case. - if(policyConfig.getPolicyName().equals(updatedPolicy.getPolicyName())){ - System.out.println("Policy Name is good. "); - }else{ - System.err.println("\n\n Fail to check Name \n\n"); - } - } - } catch (PolicyEngineException e) { - LOGGER.error("Exception Occured"+e); - } catch (PolicyConfigException e) { - LOGGER.error("Exception Occured"+e); - } - } - } - }else if(notification.getNotificationType().equals(NotificationType.BOTH)){ - System.out.println("Both updated and Removed Notification: \n"); - System.out.println("Removed Policies: \n"); - for(RemovedPolicy removedPolicy: notification.getRemovedPolicies()){ - System.out.println(removedPolicy.getPolicyName()); - System.out.println(removedPolicy.getVersionNo()); - } - System.out.println("Updated Policies: \n"); - for(LoadedPolicy updatedPolicy: notification.getLoadedPolicies()){ - System.out.println("policyName : " + updatedPolicy.getPolicyName()); - System.out.println("policyVersion :" + updatedPolicy.getVersionNo()); - System.out.println("Matches: " + updatedPolicy.getMatches()); - System.out.println("UpdateType: "+ updatedPolicy.getUpdateType()); - // Checking the Name is correct or not. - try { - PolicyEngine policyEngine = new PolicyEngine("config.properties"); - @SuppressWarnings("deprecation") - Collection policyConfigs = policyEngine.getConfigByPolicyName(updatedPolicy.getPolicyName()); - for(PolicyConfig policyConfig: policyConfigs){ - if(policyConfig.getPolicyConfigStatus().equals(PolicyConfigStatus.CONFIG_RETRIEVED)){ - System.out.println("Policy Retrieved with this Name notified. "); - }else{ - System.err.println("\n\n Fail to retrieve policy !!!!\n\n"); - } - // Also Test this case. - if(policyConfig.getPolicyName().equals(updatedPolicy.getPolicyName())){ - System.out.println("Policy Name is good. "); - }else{ - System.err.println("\n\n Fail to check Name \n\n"); - } - } - } catch (PolicyEngineException e) { - LOGGER.error("Exception Occured"+e); - } catch (PolicyConfigException e) { - LOGGER.error("Exception Occured"+e); - } - } - } - } - - -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/ManualClientEndTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/ManualClientEndTest.java deleted file mode 100644 index c44dac606..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/ManualClientEndTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openecomp.policy.api.NotificationScheme; -import org.openecomp.policy.api.PDPNotification; -import org.openecomp.policy.std.ManualClientEnd; - -/** - * The class ManualClientEndTest contains tests for the class {@link ManualClientEnd}. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - * @version $Revision: 1.0 $ - */ -public class ManualClientEndTest { - /** - * Run the ManualClientEnd() constructor test. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testManualClientEnd_1() - throws Exception { - ManualClientEnd result = new ManualClientEnd(); - assertNotNull(result); - // add additional test code here - } - - - /** - * Run the PDPNotification result(NotificationScheme) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testResult_1() - throws Exception { - NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS; - - PDPNotification result = ManualClientEnd.result(scheme); - - assertNull(result); - } - - - /** - * Run the void start(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testStart_1() - throws Exception { - String url = ""; - - ManualClientEnd.start(url); - - } - - /** - * 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(ManualClientEndTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/ManualClientEndUEBTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/ManualClientEndUEBTest.java deleted file mode 100644 index f19697597..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/ManualClientEndUEBTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.util.LinkedList; -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openecomp.policy.api.NotificationScheme; -import org.openecomp.policy.api.PDPNotification; -import org.openecomp.policy.std.ManualClientEndUEB; -import org.openecomp.policy.std.StdPDPNotification; - -/** - * The class ManualClientEndUEBTest contains tests for the class {@link ManualClientEndUEB}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class ManualClientEndUEBTest { - - String resultJson = "{'test':'testing'}"; - String json = "{\"test\":\"testing\"}"; - StdPDPNotification notification = new StdPDPNotification(); - ManualClientEndUEB mockManualClient = null; - /** - * 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 { - String url = "http://test.com"; - List uebURLList = new LinkedList(); - uebURLList.add(url); - - } - /** - * Run the ManualClientEndUEB() constructor test. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testManualClientEndUEB_1() - throws Exception { - ManualClientEndUEB result = new ManualClientEndUEB(); - assertNotNull(result); - // add additional test code here - } - - /** - * Run the PDPNotification result(NotificationScheme) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testResult_1() - throws Exception { - NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS; - - PDPNotification result = ManualClientEndUEB.result(scheme); - - assertNull(result); - } - - /** - * 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(ManualClientEndUEBTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/MatchStoreTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/MatchStoreTest.java deleted file mode 100644 index ab8946c60..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/MatchStoreTest.java +++ /dev/null @@ -1,776 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.util.HashSet; -import java.util.Hashtable; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openecomp.policy.api.PDPNotification; -import org.openecomp.policy.std.MatchStore; -import org.openecomp.policy.std.Matches; -import org.openecomp.policy.std.StdPDPNotification; - -/** - * The class MatchStoreTest contains tests for the class {@link MatchStore}. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - * @version $Revision: 1.0 $ - */ -public class MatchStoreTest { - /** - * Run the MatchStore() constructor test. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testMatchStore_1() - throws Exception { - MatchStore result = new MatchStore(); - assertNotNull(result); - // add additional test code here - } - - /** - * 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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.policy.std.MatchStore - assertNotNull(result); - } - - /** - * Run the HashSet getMatchStore() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetMatchStore_1() - throws Exception { - - HashSet 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.openecomp.policy.std.MatchStore.(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.setEcompName(""); - - 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.openecomp.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.setEcompName(""); - - 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.openecomp.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.setEcompName(""); - - 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.openecomp.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()); - newMatch.setConfigName(""); - newMatch.setEcompName(""); - - 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.openecomp.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()); - newMatch.setConfigName(""); - newMatch.setEcompName(""); - - 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.openecomp.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()); - newMatch.setConfigName(""); - newMatch.setEcompName(""); - - 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.openecomp.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()); - newMatch.setConfigName(""); - newMatch.setEcompName(""); - - 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.openecomp.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.setEcompName(""); - - 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.openecomp.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.setEcompName(""); - - 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.openecomp.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()); - newMatch.setConfigName(""); - newMatch.setEcompName(""); - - 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.openecomp.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()); - newMatch.setConfigName(""); - newMatch.setEcompName(""); - - 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.openecomp.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()); - newMatch.setConfigName(""); - newMatch.setEcompName(""); - - 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.openecomp.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()); - newMatch.setConfigName(""); - newMatch.setEcompName(""); - - 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.openecomp.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()); - newMatch.setConfigName(""); - newMatch.setEcompName(""); - - 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.openecomp.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.openecomp.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.openecomp.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); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/MatchesTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/MatchesTest.java deleted file mode 100644 index cdc9b5595..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/MatchesTest.java +++ /dev/null @@ -1,216 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import java.util.Hashtable; -import java.util.Map; - -import org.junit.*; -import org.openecomp.policy.std.Matches; - -import static org.junit.Assert.*; - -/** - * The class MatchesTest contains tests for the class {@link Matches}. - * - * @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 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.setEcompName(""); - fixture.setConfigAttributes(new Hashtable()); - fixture.setConfigName(""); - - Map 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.setEcompName(""); - fixture.setConfigAttributes(new Hashtable()); - fixture.setConfigName(""); - - String result = fixture.getConfigName(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the String getEcompName() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetEcompName_1() - throws Exception { - Matches fixture = new Matches(); - fixture.setEcompName(""); - fixture.setConfigAttributes(new Hashtable()); - fixture.setConfigName(""); - - String result = fixture.getEcompName(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the void setConfigAttributes(Map) 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.setEcompName(""); - fixture.setConfigAttributes(new Hashtable()); - fixture.setConfigName(""); - Map configAttributes = new Hashtable(); - - 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.setEcompName(""); - fixture.setConfigAttributes(new Hashtable()); - fixture.setConfigName(""); - String configName = ""; - - fixture.setConfigName(configName); - - // add additional test code here - } - - /** - * Run the void setEcompName(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetEcompName_1() - throws Exception { - Matches fixture = new Matches(); - fixture.setEcompName(""); - fixture.setConfigAttributes(new Hashtable()); - fixture.setConfigName(""); - String ecompName = ""; - - fixture.setEcompName(ecompName); - - // 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); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/NotificationStoreTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/NotificationStoreTest.java deleted file mode 100644 index d54c4f4cb..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/NotificationStoreTest.java +++ /dev/null @@ -1,359 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import org.junit.*; -import org.openecomp.policy.std.NotificationStore; -import org.openecomp.policy.std.StdPDPNotification; - -import static org.junit.Assert.*; - -/** - * The class NotificationStoreTest contains tests for the class {@link NotificationStore}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class NotificationStoreTest { - /** - * Run the NotificationStore() constructor test. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testNotificationStore_1() - throws Exception { - NotificationStore result = new NotificationStore(); - assertNotNull(result); - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_1() - throws Exception { - StdPDPNotification notification = new StdPDPNotification(); - - NotificationStore.recordNotification(notification); - - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_2() - throws Exception { - StdPDPNotification notification = new StdPDPNotification(); - - NotificationStore.recordNotification(notification); - - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_3() - throws Exception { - StdPDPNotification notification = new StdPDPNotification(); - - NotificationStore.recordNotification(notification); - - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_4() - throws Exception { - StdPDPNotification notification = new StdPDPNotification(); - - NotificationStore.recordNotification(notification); - - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_5() - throws Exception { - StdPDPNotification notification = new StdPDPNotification(); - - NotificationStore.recordNotification(notification); - - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_6() - throws Exception { - StdPDPNotification notification = new StdPDPNotification(); - - NotificationStore.recordNotification(notification); - - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_7() - throws Exception { - StdPDPNotification notification = new StdPDPNotification(); - - NotificationStore.recordNotification(notification); - - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_8() - throws Exception { - StdPDPNotification notification = new StdPDPNotification(); - - NotificationStore.recordNotification(notification); - - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_9() - throws Exception { - StdPDPNotification notification = new StdPDPNotification(); - - NotificationStore.recordNotification(notification); - - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_10() - throws Exception { - StdPDPNotification notification = new StdPDPNotification(); - - NotificationStore.recordNotification(notification); - - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_11() - throws Exception { - StdPDPNotification notification = new StdPDPNotification(); - - NotificationStore.recordNotification(notification); - - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_12() - throws Exception { - StdPDPNotification notification = new StdPDPNotification(); - - NotificationStore.recordNotification(notification); - - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_13() - throws Exception { - StdPDPNotification notification = new StdPDPNotification(); - - NotificationStore.recordNotification(notification); - - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_14() - throws Exception { - StdPDPNotification notification = new StdPDPNotification(); - - NotificationStore.recordNotification(notification); - - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_15() - throws Exception { - StdPDPNotification notification = new StdPDPNotification(); - - NotificationStore.recordNotification(notification); - - // add additional test code here - } - - /** - * Run the void recordNotification(StdPDPNotification) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testRecordNotification_16() - throws Exception { - StdPDPNotification notification = null; - - NotificationStore.recordNotification(notification); - - // 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(NotificationStoreTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/NotificationUnMarshalTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/NotificationUnMarshalTest.java deleted file mode 100644 index 674c58a00..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/NotificationUnMarshalTest.java +++ /dev/null @@ -1,256 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import static org.junit.Assert.assertNotNull; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openecomp.policy.std.NotificationUnMarshal; -import org.openecomp.policy.std.StdPDPNotification; - -/** - * The class NotificationUnMarshalTest contains tests for the class {@link NotificationUnMarshal}. - * - * @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); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdLoadedPolicyTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdLoadedPolicyTest.java deleted file mode 100644 index de8a6a7ad..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdLoadedPolicyTest.java +++ /dev/null @@ -1,314 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import java.util.Hashtable; -import java.util.Map; - -import org.junit.*; -import org.openecomp.policy.api.UpdateType; -import org.openecomp.policy.std.StdLoadedPolicy; - -import static org.junit.Assert.*; - -/** - * The class StdLoadedPolicyTest contains tests for the class {@link StdLoadedPolicy}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class StdLoadedPolicyTest { - /** - * Run the StdLoadedPolicy() constructor test. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testStdLoadedPolicy_1() - throws Exception { - StdLoadedPolicy result = new StdLoadedPolicy(); - assertNotNull(result); - // add additional test code here - } - - /** - * Run the Map getMatches() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetMatches_1() - throws Exception { - StdLoadedPolicy fixture = new StdLoadedPolicy(); - fixture.setPolicyName(""); - fixture.setVersionNo(""); - fixture.setUpdateType(UpdateType.NEW); - fixture.setMatches(new Hashtable()); - - Map result = fixture.getMatches(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the String getPolicyName() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetPolicyName_1() - throws Exception { - StdLoadedPolicy fixture = new StdLoadedPolicy(); - fixture.setPolicyName(""); - fixture.setVersionNo(""); - fixture.setUpdateType(UpdateType.NEW); - fixture.setMatches(new Hashtable()); - - 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:40 PM - */ - @Test - public void testGetPolicyName_2() - throws Exception { - StdLoadedPolicy fixture = new StdLoadedPolicy(); - fixture.setPolicyName((String) null); - fixture.setVersionNo(""); - fixture.setUpdateType(UpdateType.NEW); - fixture.setMatches(new Hashtable()); - - 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:40 PM - */ - @Test - public void testGetPolicyName_3() - throws Exception { - StdLoadedPolicy fixture = new StdLoadedPolicy(); - fixture.setPolicyName(""); - fixture.setVersionNo(""); - fixture.setUpdateType(UpdateType.NEW); - fixture.setMatches(new Hashtable()); - - String result = fixture.getPolicyName(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the UpdateType getUpdateType() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetUpdateType_1() - throws Exception { - StdLoadedPolicy fixture = new StdLoadedPolicy(); - fixture.setPolicyName(""); - fixture.setVersionNo(""); - fixture.setUpdateType(UpdateType.NEW); - fixture.setMatches(new Hashtable()); - - UpdateType result = fixture.getUpdateType(); - - // add additional test code here - assertNotNull(result); - assertEquals("new", result.toString()); - assertEquals("NEW", result.name()); - assertEquals(1, result.ordinal()); - } - - /** - * Run the String getVersionNo() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetVersionNo_1() - throws Exception { - StdLoadedPolicy fixture = new StdLoadedPolicy(); - fixture.setPolicyName(""); - fixture.setVersionNo(""); - fixture.setUpdateType(UpdateType.NEW); - fixture.setMatches(new Hashtable()); - - String result = fixture.getVersionNo(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the void setMatches(Map) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetMatches_1() - throws Exception { - StdLoadedPolicy fixture = new StdLoadedPolicy(); - fixture.setPolicyName(""); - fixture.setVersionNo(""); - fixture.setUpdateType(UpdateType.NEW); - fixture.setMatches(new Hashtable()); - Map matches = new Hashtable(); - - fixture.setMatches(matches); - - // 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 { - StdLoadedPolicy fixture = new StdLoadedPolicy(); - fixture.setPolicyName(""); - fixture.setVersionNo(""); - fixture.setUpdateType(UpdateType.NEW); - fixture.setMatches(new Hashtable()); - String policyName = ""; - - fixture.setPolicyName(policyName); - - // add additional test code here - } - - /** - * Run the void setUpdateType(UpdateType) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetUpdateType_1() - throws Exception { - StdLoadedPolicy fixture = new StdLoadedPolicy(); - fixture.setPolicyName(""); - fixture.setVersionNo(""); - fixture.setUpdateType(UpdateType.NEW); - fixture.setMatches(new Hashtable()); - UpdateType updateType = UpdateType.NEW; - - fixture.setUpdateType(updateType); - - // add additional test code here - } - - /** - * Run the void setVersionNo(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetVersionNo_1() - throws Exception { - StdLoadedPolicy fixture = new StdLoadedPolicy(); - fixture.setPolicyName(""); - fixture.setVersionNo(""); - fixture.setUpdateType(UpdateType.NEW); - fixture.setMatches(new Hashtable()); - String versionNo = ""; - - fixture.setVersionNo(versionNo); - - // 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(StdLoadedPolicyTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPDPNotificationTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPDPNotificationTest.java deleted file mode 100644 index 1bda0e59f..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPDPNotificationTest.java +++ /dev/null @@ -1,311 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import java.util.Collection; -import java.util.LinkedList; - -import org.junit.*; -import org.openecomp.policy.api.LoadedPolicy; -import org.openecomp.policy.api.NotificationType; -import org.openecomp.policy.api.RemovedPolicy; -import org.openecomp.policy.std.StdLoadedPolicy; -import org.openecomp.policy.std.StdPDPNotification; -import org.openecomp.policy.std.StdRemovedPolicy; - -import static org.junit.Assert.*; - -/** - * The class StdPDPNotificationTest contains tests for the class {@link StdPDPNotification}. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - * @version $Revision: 1.0 $ - */ -public class StdPDPNotificationTest { - /** - * Run the StdPDPNotification() constructor test. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testStdPDPNotification_1() - throws Exception { - StdPDPNotification result = new StdPDPNotification(); - assertNotNull(result); - // add additional test code here - } - - /** - * Run the Collection getLoadedPolicies() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetLoadedPolicies_1() - throws Exception { - StdPDPNotification fixture = new StdPDPNotification(); - fixture.setRemovedPolicies(new LinkedList()); - fixture.setNotificationType(NotificationType.BOTH); - fixture.setLoadedPolicies(new LinkedList()); - - Collection result = fixture.getLoadedPolicies(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the Collection getLoadedPolicies() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetLoadedPolicies_2() - throws Exception { - StdPDPNotification fixture = new StdPDPNotification(); - fixture.setRemovedPolicies(new LinkedList()); - fixture.setNotificationType(NotificationType.BOTH); - fixture.setLoadedPolicies(new LinkedList()); - - Collection result = fixture.getLoadedPolicies(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the Collection getLoadedPolicies() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetLoadedPolicies_3() - throws Exception { - StdPDPNotification fixture = new StdPDPNotification(); - fixture.setRemovedPolicies(new LinkedList()); - fixture.setNotificationType(NotificationType.BOTH); - fixture.setLoadedPolicies(null); - - Collection result = fixture.getLoadedPolicies(); - - // add additional test code here - assertEquals(null, result); - } - - /** - * Run the NotificationType getNotificationType() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetNotificationType_1() - throws Exception { - StdPDPNotification fixture = new StdPDPNotification(); - fixture.setRemovedPolicies(new LinkedList()); - fixture.setNotificationType(NotificationType.BOTH); - fixture.setLoadedPolicies(new LinkedList()); - - NotificationType result = fixture.getNotificationType(); - - // add additional test code here - assertNotNull(result); - assertEquals("both", result.toString()); - assertEquals("BOTH", result.name()); - assertEquals(2, result.ordinal()); - } - - /** - * Run the Collection getRemovedPolicies() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetRemovedPolicies_1() - throws Exception { - StdPDPNotification fixture = new StdPDPNotification(); - fixture.setRemovedPolicies(new LinkedList()); - fixture.setNotificationType(NotificationType.BOTH); - fixture.setLoadedPolicies(new LinkedList()); - - Collection result = fixture.getRemovedPolicies(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the Collection getRemovedPolicies() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetRemovedPolicies_2() - throws Exception { - StdPDPNotification fixture = new StdPDPNotification(); - fixture.setRemovedPolicies(new LinkedList()); - fixture.setNotificationType(NotificationType.BOTH); - fixture.setLoadedPolicies(new LinkedList()); - - Collection result = fixture.getRemovedPolicies(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the Collection getRemovedPolicies() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetRemovedPolicies_3() - throws Exception { - StdPDPNotification fixture = new StdPDPNotification(); - fixture.setRemovedPolicies(null); - fixture.setNotificationType(NotificationType.BOTH); - fixture.setLoadedPolicies(new LinkedList()); - - Collection result = fixture.getRemovedPolicies(); - - // add additional test code here - assertEquals(null, result); - } - - /** - * Run the void setNotificationType(NotificationType) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetNotificationType_1() - throws Exception { - StdPDPNotification fixture = new StdPDPNotification(); - fixture.setRemovedPolicies(new LinkedList()); - fixture.setNotificationType(NotificationType.BOTH); - fixture.setLoadedPolicies(new LinkedList()); - NotificationType notificationType = NotificationType.BOTH; - - fixture.setNotificationType(notificationType); - - // add additional test code here - } - - /** - * Run the void setRemovedPolicies(Collection) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetRemovedPolicies_1() - throws Exception { - StdPDPNotification fixture = new StdPDPNotification(); - fixture.setRemovedPolicies(new LinkedList()); - fixture.setNotificationType(NotificationType.BOTH); - fixture.setLoadedPolicies(new LinkedList()); - Collection removedPolicies = new LinkedList(); - - fixture.setRemovedPolicies(removedPolicies); - - // add additional test code here - } - - /** - * Run the void setUpdatedPolicies(Collection) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetUpdatedPolicies_1() - throws Exception { - StdPDPNotification fixture = new StdPDPNotification(); - fixture.setRemovedPolicies(new LinkedList()); - fixture.setNotificationType(NotificationType.BOTH); - fixture.setLoadedPolicies(new LinkedList()); - Collection updatedPolicies = new LinkedList(); - - fixture.setLoadedPolicies(updatedPolicies); - - // 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(StdPDPNotificationTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPolicyChangeResponseTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPolicyChangeResponseTest.java deleted file mode 100644 index 45c70187d..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPolicyChangeResponseTest.java +++ /dev/null @@ -1,166 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import org.junit.*; -import org.openecomp.policy.std.StdPolicyChangeResponse; - -import static org.junit.Assert.*; - -/** - * The class StdPolicyChangeResponseTest contains tests for the class {@link StdPolicyChangeResponse}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class StdPolicyChangeResponseTest { - /** - * Run the StdPolicyChangeResponse() constructor test. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testStdPolicyChangeResponse_1() - throws Exception { - StdPolicyChangeResponse result = new StdPolicyChangeResponse(); - assertNotNull(result); - // add additional test code here - } - - /** - * Run the int getResponseCode() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetResponseCode_1() - throws Exception { - StdPolicyChangeResponse fixture = new StdPolicyChangeResponse(); - fixture.setResponseMessage(""); - fixture.setResponseCode(1); - - int result = fixture.getResponseCode(); - - // add additional test code here - assertEquals(1, result); - } - - /** - * Run the String getResponseMessage() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetResponseMessage_1() - throws Exception { - StdPolicyChangeResponse fixture = new StdPolicyChangeResponse(); - fixture.setResponseMessage(""); - fixture.setResponseCode(1); - - String result = fixture.getResponseMessage(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the void setResponseCode(int) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetResponseCode_1() - throws Exception { - StdPolicyChangeResponse fixture = new StdPolicyChangeResponse(); - fixture.setResponseMessage(""); - fixture.setResponseCode(1); - int responseCode = 1; - - fixture.setResponseCode(responseCode); - - // add additional test code here - } - - /** - * Run the void setResponseMessage(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetResponseMessage_1() - throws Exception { - StdPolicyChangeResponse fixture = new StdPolicyChangeResponse(); - fixture.setResponseMessage(""); - fixture.setResponseCode(1); - String responseMessage = ""; - - fixture.setResponseMessage(responseMessage); - - // 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(StdPolicyChangeResponseTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPolicyConfigTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPolicyConfigTest.java deleted file mode 100644 index a34737477..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPolicyConfigTest.java +++ /dev/null @@ -1,821 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import java.util.Hashtable; -import java.util.Map; -import java.util.Properties; - -import javax.json.JsonObject; - -import org.junit.*; -import org.openecomp.policy.api.PolicyConfigStatus; -import org.openecomp.policy.api.PolicyType; -import org.openecomp.policy.std.StdPolicyConfig; - -import static org.junit.Assert.*; - -import org.w3c.dom.Document; - -/** - * The class StdPolicyConfigTest contains tests for the class {@link StdPolicyConfig}. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - * @version $Revision: 1.0 $ - */ -public class StdPolicyConfigTest { - /** - * Run the Map 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - - Map 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - - 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()); - 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 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - - String result = fixture.getPolicyVersion(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the Map 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - - Map 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - JsonObject jsonObject = null; - - fixture.setJsonObject(jsonObject); - - // add additional test code here - } - - /** - * Run the void setMatchingConditions(Map) 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - Map matchingConditions = new Hashtable(); - - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - Properties properties = new Properties(); - - fixture.setProperties(properties); - - // add additional test code here - } - - /** - * Run the void setResponseAttributes(Map) 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - Map responseAttributes = new Hashtable(); - - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName("test"); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - - 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()); - fixture.setPolicyVersion(""); - fixture.setOther(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setPolicyName(""); - fixture.setProperties(new Properties()); - fixture.setJsonObject((JsonObject) null); - fixture.setMatchingConditions(new Hashtable()); - - 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); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPolicyResponseTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPolicyResponseTest.java deleted file mode 100644 index a593c460b..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdPolicyResponseTest.java +++ /dev/null @@ -1,348 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import java.util.Hashtable; -import java.util.Map; - -import org.junit.*; -import org.openecomp.policy.api.PolicyResponseStatus; -import org.openecomp.policy.std.StdPolicyResponse; - -import static org.junit.Assert.*; - -/** - * The class StdPolicyResponseTest contains tests for the class {@link StdPolicyResponse}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class StdPolicyResponseTest { - /** - * Run the Map getActionAdvised() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetActionAdvised_1() - throws Exception { - StdPolicyResponse fixture = new StdPolicyResponse(); - fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); - fixture.setRequestAttributes(new Hashtable()); - fixture.setActionAdvised(new Hashtable()); - fixture.setActionTaken(new Hashtable()); - - Map result = fixture.getActionAdvised(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the Map getActionTaken() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetActionTaken_1() - throws Exception { - StdPolicyResponse fixture = new StdPolicyResponse(); - fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); - fixture.setRequestAttributes(new Hashtable()); - fixture.setActionAdvised(new Hashtable()); - fixture.setActionTaken(new Hashtable()); - - Map result = fixture.getActionTaken(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the String getPolicyResponseMessage() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetPolicyResponseMessage_1() - throws Exception { - StdPolicyResponse fixture = new StdPolicyResponse(); - fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); - fixture.setRequestAttributes(new Hashtable()); - fixture.setActionAdvised(new Hashtable()); - fixture.setActionTaken(new Hashtable()); - - String result = fixture.getPolicyResponseMessage(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the PolicyResponseStatus getPolicyResponseStatus() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetPolicyResponseStatus_1() - throws Exception { - StdPolicyResponse fixture = new StdPolicyResponse(); - fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); - fixture.setRequestAttributes(new Hashtable()); - fixture.setActionAdvised(new Hashtable()); - fixture.setActionTaken(new Hashtable()); - - PolicyResponseStatus result = fixture.getPolicyResponseStatus(); - - // add additional test code here - assertNotNull(result); - assertEquals("action_advised", result.toString()); - assertEquals("ACTION_ADVISED", result.name()); - assertEquals(1, result.ordinal()); - } - - /** - * Run the Map getRequestAttributes() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetRequestAttributes_1() - throws Exception { - StdPolicyResponse fixture = new StdPolicyResponse(); - fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); - fixture.setRequestAttributes(new Hashtable()); - fixture.setActionAdvised(new Hashtable()); - fixture.setActionTaken(new Hashtable()); - - Map result = fixture.getRequestAttributes(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the void setActionAdvised(Map) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetActionAdvised_1() - throws Exception { - StdPolicyResponse fixture = new StdPolicyResponse(); - fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); - fixture.setRequestAttributes(new Hashtable()); - fixture.setActionAdvised(new Hashtable()); - fixture.setActionTaken(new Hashtable()); - Map actionAdvised = new Hashtable(); - - fixture.setActionAdvised(actionAdvised); - - // add additional test code here - } - - /** - * Run the void setActionTaken(Map) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetActionTaken_1() - throws Exception { - StdPolicyResponse fixture = new StdPolicyResponse(); - fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); - fixture.setRequestAttributes(new Hashtable()); - fixture.setActionAdvised(new Hashtable()); - fixture.setActionTaken(new Hashtable()); - Map actionTaken = new Hashtable(); - - fixture.setActionTaken(actionTaken); - - // add additional test code here - } - - /** - * Run the void setPolicyResponseMessage(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetPolicyResponseMessage_1() - throws Exception { - StdPolicyResponse fixture = new StdPolicyResponse(); - fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); - fixture.setRequestAttributes(new Hashtable()); - fixture.setActionAdvised(new Hashtable()); - fixture.setActionTaken(new Hashtable()); - String policyResponseMessage = ""; - - fixture.setPolicyResponseMessage(policyResponseMessage); - - // add additional test code here - } - - /** - * Run the void setPolicyResponseStatus(PolicyResponseStatus) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetPolicyResponseStatus_1() - throws Exception { - StdPolicyResponse fixture = new StdPolicyResponse(); - fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); - fixture.setRequestAttributes(new Hashtable()); - fixture.setActionAdvised(new Hashtable()); - fixture.setActionTaken(new Hashtable()); - PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED; - - fixture.setPolicyResponseStatus(policyResponseStatus); - - // add additional test code here - } - - /** - * Run the void setPolicyResponseStatus(String,PolicyResponseStatus) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetPolicyResponseStatus_2() - throws Exception { - StdPolicyResponse fixture = new StdPolicyResponse(); - fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); - fixture.setRequestAttributes(new Hashtable()); - fixture.setActionAdvised(new Hashtable()); - fixture.setActionTaken(new Hashtable()); - String policyResponseMessage = ""; - PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED; - - fixture.setPolicyResponseStatus(policyResponseMessage, policyResponseStatus); - - // add additional test code here - } - - /** - * Run the void setRequestAttributes(Map) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetRequestAttributes_1() - throws Exception { - StdPolicyResponse fixture = new StdPolicyResponse(); - fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); - fixture.setRequestAttributes(new Hashtable()); - fixture.setActionAdvised(new Hashtable()); - fixture.setActionTaken(new Hashtable()); - Map requestAttributes = new Hashtable(); - - fixture.setRequestAttributes(requestAttributes); - - // add additional test code here - } - - /** - * Run the String toString() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testToString_1() - throws Exception { - StdPolicyResponse fixture = new StdPolicyResponse(); - fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED); - fixture.setRequestAttributes(new Hashtable()); - fixture.setActionAdvised(new Hashtable()); - fixture.setActionTaken(new Hashtable()); - - String result = fixture.toString(); - - // add additional test code here - assertEquals("PolicyResponse [ policyResponseStatus=action_advised, policyResponseMessage=, ]", 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(StdPolicyResponseTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdRemovedPolicyTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdRemovedPolicyTest.java deleted file mode 100644 index 0a0865c82..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdRemovedPolicyTest.java +++ /dev/null @@ -1,206 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import org.junit.*; -import org.openecomp.policy.std.StdRemovedPolicy; - -import static org.junit.Assert.*; - -/** - * The class StdRemovedPolicyTest contains tests for the class {@link StdRemovedPolicy}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class StdRemovedPolicyTest { - /** - * Run the StdRemovedPolicy() constructor test. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testStdRemovedPolicy_1() - throws Exception { - StdRemovedPolicy result = new StdRemovedPolicy(); - assertNotNull(result); - // add additional test code here - } - - /** - * Run the String getPolicyName() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetPolicyName_1() - throws Exception { - StdRemovedPolicy fixture = new StdRemovedPolicy(); - fixture.setVersionNo(""); - fixture.setPolicyName(""); - - 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:40 PM - */ - @Test - public void testGetPolicyName_2() - throws Exception { - StdRemovedPolicy fixture = new StdRemovedPolicy(); - fixture.setVersionNo(""); - fixture.setPolicyName((String) null); - - 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:40 PM - */ - @Test - public void testGetPolicyName_3() - throws Exception { - StdRemovedPolicy fixture = new StdRemovedPolicy(); - fixture.setVersionNo(""); - fixture.setPolicyName(""); - - String result = fixture.getPolicyName(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the String getVersionNo() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetVersionNo_1() - throws Exception { - StdRemovedPolicy fixture = new StdRemovedPolicy(); - fixture.setVersionNo(""); - fixture.setPolicyName(""); - - String result = fixture.getVersionNo(); - - // add additional test code here - assertEquals("", result); - } - - /** - * 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 { - StdRemovedPolicy fixture = new StdRemovedPolicy(); - fixture.setVersionNo(""); - fixture.setPolicyName(""); - String policyName = ""; - - fixture.setPolicyName(policyName); - - // add additional test code here - } - - /** - * Run the void setVersionNo(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetVersionNo_1() - throws Exception { - StdRemovedPolicy fixture = new StdRemovedPolicy(); - fixture.setVersionNo(""); - fixture.setPolicyName(""); - String versionNo = ""; - - fixture.setVersionNo(versionNo); - - // 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(StdRemovedPolicyTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdStatusTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdStatusTest.java deleted file mode 100644 index 34918c2ea..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/StdStatusTest.java +++ /dev/null @@ -1,1433 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.std.test; - -import java.util.Hashtable; -import java.util.Map; -import java.util.Properties; - -import javax.json.JsonObject; - -import org.junit.*; -import org.openecomp.policy.api.PolicyConfigStatus; -import org.openecomp.policy.api.PolicyDecision; -import org.openecomp.policy.api.PolicyResponseStatus; -import org.openecomp.policy.api.PolicyType; -import org.openecomp.policy.std.StdStatus; - -import static org.junit.Assert.*; - -import org.w3c.dom.Document; - -/** - * The class StdStatusTest contains tests for the class {@link StdStatus}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class StdStatusTest { - /** - * Run the Map getActionAdvised() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetActionAdvised_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - Map result = fixture.getActionAdvised(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the Map getActionTaken() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetActionTaken_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - Map result = fixture.getActionTaken(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the Map getMatchingConditions() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetMatchingConditions_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - Map 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:40 PM - */ - @Test - public void testGetPolicyConfigMessage_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - 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:40 PM - */ - @Test - public void testGetPolicyConfigStatus_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - 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 PolicyDecision getPolicyDecision() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetPolicyDecision_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - PolicyDecision result = fixture.getDecision(); - - // add additional test code here - assertNotNull(result); - assertEquals("deny", result.toString()); - assertEquals("DENY", result.name()); - assertEquals(1, result.ordinal()); - } - - /** - * Run the String getPolicyName() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetPolicyName_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - 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:40 PM - */ - @Test - public void testGetPolicyName_2() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName((String) null); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - 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:40 PM - */ - @Test - public void testGetPolicyName_3() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - String result = fixture.getPolicyName(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the String getPolicyResponseMessage() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetPolicyResponseMessage_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - String result = fixture.getPolicyResponseMessage(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the PolicyResponseStatus getPolicyResponseStatus() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetPolicyResponseStatus_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - PolicyResponseStatus result = fixture.getPolicyResponseStatus(); - - // add additional test code here - assertNotNull(result); - assertEquals("action_advised", result.toString()); - assertEquals("ACTION_ADVISED", result.name()); - assertEquals(1, result.ordinal()); - } - - /** - * Run the String getPolicyVersion() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetPolicyVersion_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - String result = fixture.getPolicyVersion(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the Map getRequestAttributes() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetRequestAttributes_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - Map result = fixture.getRequestAttributes(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the Map getResponseAttributes() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetResponseAttributes_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - Map 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:40 PM - */ - @Test - public void testGetType_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - 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 setActionAdvised(Map) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetActionAdvised_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - Map actionAdvised = new Hashtable(); - - fixture.setActionAdvised(actionAdvised); - - // add additional test code here - } - - /** - * Run the void setActionTaken(Map) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetActionTaken_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - Map actionTaken = new Hashtable(); - - fixture.setActionTaken(actionTaken); - - // add additional test code here - } - - /** - * Run the void setConfigStatus(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetConfigStatus_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - String configStatus = ""; - - fixture.setConfigStatus(configStatus); - - // add additional test code here - } - - /** - * Run the void setDocument(Document) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetDocument_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - 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:40 PM - */ - @Test - public void testSetJsonObject_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - JsonObject jsonObject = null; - - fixture.setJsonObject(jsonObject); - - // add additional test code here - } - - /** - * Run the void setMatchingConditions(Map) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetMatchingConditions_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - Map matchingConditions = new Hashtable(); - - fixture.setMatchingConditions(matchingConditions); - - // add additional test code here - } - - /** - * Run the void setOther(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetOther_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - 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:40 PM - */ - @Test - public void testSetPolicyConfigStatus_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND; - - fixture.setPolicyConfigStatus(policyConfigStatus); - - // add additional test code here - } - - /** - * Run the void setPolicyConfigStatus(String,PolicyConfigStatus) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetPolicyConfigStatus_2() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - String configStatus = ""; - PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND; - - fixture.setPolicyConfigStatus(configStatus, policyConfigStatus); - - // add additional test code here - } - - /** - * Run the void setPolicyDecision(PolicyDecision) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetPolicyDecision_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - PolicyDecision policyDecision = PolicyDecision.DENY; - - fixture.setDecision(policyDecision); - - // 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 { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - String policyName = ""; - - fixture.setPolicyName(policyName); - - // add additional test code here - } - - /** - * Run the void setPolicyResponseMessage(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetPolicyResponseMessage_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - String policyResponseMessage = ""; - - fixture.setPolicyResponseMessage(policyResponseMessage); - - // add additional test code here - } - - /** - * Run the void setPolicyResponseStatus(PolicyResponseStatus) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetPolicyResponseStatus_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED; - - fixture.setPolicyResponseStatus(policyResponseStatus); - - // add additional test code here - } - - /** - * Run the void setPolicyResponseStatus(String,PolicyResponseStatus) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetPolicyResponseStatus_2() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - String policyResponseMessage = ""; - PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED; - - fixture.setPolicyResponseStatus(policyResponseMessage, policyResponseStatus); - - // add additional test code here - } - - /** - * Run the void setPolicyType(PolicyType) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetPolicyType_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - 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:40 PM - */ - @Test - public void testSetPolicyVersion_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - 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:40 PM - */ - @Test - public void testSetProperties_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - Properties properties = new Properties(); - - fixture.setProperties(properties); - - // add additional test code here - } - - /** - * Run the void setRequestAttributes(Map) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetRequestAttributes_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - Map requestAttributes = new Hashtable(); - - fixture.setRequestAttributes(requestAttributes); - - // add additional test code here - } - - /** - * Run the void setResposneAttributes(Map) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetResposneAttributes_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - Map responseAttributes = new Hashtable(); - - fixture.setResposneAttributes(responseAttributes); - - // add additional test code here - } - - /** - * Run the void setStatus(String,PolicyResponseStatus,PolicyConfigStatus) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetStatus_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - String message = ""; - PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED; - PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND; - - fixture.setStatus(message, policyResponseStatus, policyConfigStatus); - - // add additional test code here - } - - /** - * Run the JsonObject toJSON() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testToJSON_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - 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:40 PM - */ - @Test - public void testToOther_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - 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:40 PM - */ - @Test - public void testToProperties_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - Properties result = fixture.toProperties(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the Document toXML() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testToXML_1() - throws Exception { - StdStatus fixture = new StdStatus(); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setPolicyName(""); - fixture.setPolicyType(PolicyType.JSON); - fixture.setResposneAttributes(new Hashtable()); - fixture.setMatchingConditions(new Hashtable()); - fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND); - fixture.setJsonObject((JsonObject) null); - fixture.setDocument((Document) null); - fixture.setProperties(new Properties()); - fixture.setRequestAttributes(new Hashtable()); - fixture.setPolicyVersion(""); - fixture.setActionAdvised(new Hashtable()); - fixture.setOther(""); - fixture.setDecision(PolicyDecision.DENY); - fixture.setDetails(""); - fixture.setActionTaken(new Hashtable()); - - 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: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(StdStatusTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/package-info.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/package-info.java deleted file mode 100644 index 75bfc39ad..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/std/test/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -/** - * - */ -/** - * - */ -package org.openecomp.policy.std.test; diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ActionPolicyApiTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ActionPolicyApiTest.java deleted file mode 100644 index 398efe0f1..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ActionPolicyApiTest.java +++ /dev/null @@ -1,239 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.openecomp.policy.api.AttributeType; -import org.openecomp.policy.api.PolicyChangeResponse; -import org.openecomp.policy.api.PolicyClass; -import org.openecomp.policy.api.PolicyEngine; -import org.openecomp.policy.api.PolicyEngineException; -import org.openecomp.policy.api.PolicyParameters; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; -import org.openecomp.policy.std.StdPolicyChangeResponse; - -import junit.framework.TestCase; - -public class ActionPolicyApiTest extends TestCase { - - private static final Logger logger = FlexLogger.getLogger(ActionPolicyApiTest.class); - - private PolicyEngine policyEngine = null; - private PolicyEngine mockPolicyEngine = null; - - PolicyChangeResponse result = null; - StdPolicyChangeResponse response = new StdPolicyChangeResponse(); - PolicyParameters policyParameters = new PolicyParameters(); - - @Before - protected void setUp() throws Exception { - try { - policyEngine = new PolicyEngine("Test/config_pass.properties"); - } catch (PolicyEngineException e) { - logger.error(e.getMessage()); - fail("PolicyEngine Instantiation Error" + e); - } - logger.info("Loaded.. PolicyEngine"); - - mockPolicyEngine = Mockito.mock(PolicyEngine.class); - - policyParameters.setPolicyClass(PolicyClass.Action); //required - policyParameters.setPolicyName("test.junitTest"); //required - policyParameters.setPolicyDescription("testing"); //optional - //policyParameters.setPolicyScope("test"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI - - //Set the Component Attributes... These are Optional - Map configAttributes = new HashMap(); - configAttributes.put("test", "testing"); - - Map> attributes = new HashMap>(); - attributes.put(AttributeType.MATCHING, configAttributes); - policyParameters.setAttributes(attributes); - - policyParameters.setActionPerformer("PEP"); - policyParameters.setActionAttribute("testing"); - policyParameters.setRequestID(UUID.randomUUID()); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - @Test - public final void testCreatePolicy() { - response.setResponseMessage("success"); - PolicyChangeResponse result = null; - try { - - Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response); - result = mockPolicyEngine.createPolicy(policyParameters); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - @Test - public final void testUpdatePolicy() { - response.setResponseMessage("success"); - PolicyChangeResponse result = null; - try { - - Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response); - result = mockPolicyEngine.updatePolicy(policyParameters); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - - } - - @Test - public final void testCreatePolicyNullPolicyName() { - response.setResponseMessage("PE300 - Data Issue: No Policy Name given."); - policyParameters.setPolicyName(null); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testCreatePolicyNullPolicyScope() { - response.setResponseMessage("PE300 - Data Issue: No Policy Scope given."); - policyParameters.setPolicyName("test"); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testCreatePolicyNullActionAttributes() { - response.setResponseMessage("PE300 - Data Issue: No Action Attribute given."); - policyParameters.setActionAttribute(null); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testCreatePolicyNullActionPerformer() { - response.setResponseMessage("PE300 - Data Issue: No Action Performer given."); - policyParameters.setActionPerformer(null); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testCreatePolicyInvalidActionPerformer() { - response.setResponseMessage("PE300 - Data Issue: Invalid Action Performer given."); - policyParameters.setActionPerformer("testfail"); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullPolicyName() { - response.setResponseMessage("PE300 - Data Issue: No Policy Name given."); - policyParameters.setPolicyName(null); - try{ - result = policyEngine.updatePolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullPolicyScope() { - response.setResponseMessage("PE300 - Data Issue: No Policy Scope given."); - policyParameters.setPolicyName("test"); - try{ - result = policyEngine.updatePolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullActionAttributes() { - response.setResponseMessage("PE300 - Data Issue: No Action Attribute given."); - policyParameters.setActionAttribute(null); - try{ - result = policyEngine.updatePolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullActionPerformer() { - response.setResponseMessage("PE300 - Data Issue: No Action Performer given."); - policyParameters.setActionPerformer(null); - try{ - result = policyEngine.updatePolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyInvalidActionPerformer() { - response.setResponseMessage("PE300 - Data Issue: Invalid Action Performer given."); - policyParameters.setActionPerformer("testfail"); - try{ - result = policyEngine.updatePolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/AttributeTypeTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/AttributeTypeTest.java deleted file mode 100644 index df8713ab8..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/AttributeTypeTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.*; -import org.openecomp.policy.api.AttributeType; - -import static org.junit.Assert.*; - -/** - * The class AttributeTypeTest contains tests for the class {@link AttributeType}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class AttributeTypeTest { - /** - * Run the String toString() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testToString_1() - throws Exception { - AttributeType fixture = AttributeType.MATCHING; - - String result = fixture.toString(); - - // add additional test code here - assertEquals("matching", 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 - } - -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigBasePolicyTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigBasePolicyTest.java deleted file mode 100644 index 69de7fe87..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigBasePolicyTest.java +++ /dev/null @@ -1,325 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.junit.Test; -import org.mockito.Mockito; -import org.openecomp.policy.api.AttributeType; -import org.openecomp.policy.api.PolicyChangeResponse; -import org.openecomp.policy.api.PolicyConfigType; -import org.openecomp.policy.api.PolicyEngine; -import org.openecomp.policy.api.PolicyEngineException; -import org.openecomp.policy.api.PolicyParameters; -import org.openecomp.policy.api.PolicyType; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; -import org.openecomp.policy.std.StdPolicyChangeResponse; - -import junit.framework.TestCase; - -/** - * The class ConfigBasePolicyTest contains tests for the class - * {@link PolicyEngine} - * - * @pattern JUnit Test Case - * * - */ -public class ConfigBasePolicyTest extends TestCase { - - private static final Logger logger = FlexLogger.getLogger(DecisionPolicyApiTest.class); - - private PolicyEngine policyEngine = null; - private PolicyEngine mockPolicyEngine = null; - - PolicyChangeResponse result = null; - StdPolicyChangeResponse response = new StdPolicyChangeResponse(); - PolicyParameters policyParameters = new PolicyParameters(); - - /** - * Perform pre-test initialization - * - * @throws Exception - * - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - try { - policyEngine = new PolicyEngine("Test/config_pass.properties"); - } catch (PolicyEngineException e) { - logger.error(e.getMessage()); - fail("PolicyEngine Instantiation Error" + e); - } - logger.info("Loaded.. PolicyEngine"); - - mockPolicyEngine = Mockito.mock(PolicyEngine.class); - - policyParameters.setPolicyConfigType(PolicyConfigType.Base); //required - policyParameters.setPolicyName("test.junitTest"); //required - policyParameters.setEcompName("test"); - policyParameters.setConfigName("testBase"); - policyParameters.setConfigBodyType(PolicyType.OTHER); - policyParameters.setConfigBody("testing"); - policyParameters.setPolicyDescription("testing"); //optional - //policyParameters.setPolicyScope("test"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI - - //Set the Component Attributes... These are Optional - Map configAttributes = new HashMap(); - configAttributes.put("test", "testing"); - - Map> attributes = new HashMap>(); - attributes.put(AttributeType.MATCHING, configAttributes); - policyParameters.setAttributes(attributes); - - policyParameters.setRequestID(UUID.randomUUID()); - } - - /** - * Perform post-test clean up - * - * @throws Exception - * - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - // Add additional tear down code here - } - - /** - * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test - */ - public void testCreatePolicy() { - response.setResponseMessage("success"); - PolicyChangeResponse result = null; - try { - - Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response); - result = mockPolicyEngine.createPolicy(policyParameters); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - /** - * Run the String createConfigPolicy() method test - */ - @SuppressWarnings("deprecation") - @Test - public void testCreateConfigPolicy() { - String response = "success"; - String result = null; - try { - - Mockito.when(mockPolicyEngine.createConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null)).thenReturn(response); - result = mockPolicyEngine.createConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - /** - * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test - */ - public void testUpdatePolicy() { - response.setResponseMessage("success"); - PolicyChangeResponse result = null; - try { - - Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response); - result = mockPolicyEngine.updatePolicy(policyParameters); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - /** - * Run the String updateConfigPolicy() method test - */ - @SuppressWarnings("deprecation") - @Test - public void testUpdateConfigPolicy() { - String response = "success"; - String result = null; - try { - - Mockito.when(mockPolicyEngine.updateConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null)).thenReturn(response); - result = mockPolicyEngine.updateConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - @Test - public final void testCreatePolicyNullPolicyName() { - response.setResponseMessage("PE300 - Data Issue: No Policy Name given."); - policyParameters.setPolicyName(null); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testCreatePolicyNullPolicyScope() { - response.setResponseMessage("PE300 - Data Issue: No Policy Scope given."); - policyParameters.setPolicyName("test"); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testCreatePolicyNullEcompName() { - response.setResponseMessage("PE300 - Data Issue: No ECOMP Name given."); - policyParameters.setEcompName(null); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testCreatePolicyNullPolicyConfigName() { - response.setResponseMessage("PE300 - Data Issue: No Config Name given."); - policyParameters.setConfigName(null);; - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testCreatePolicyNullPolicyConfigBodyType() { - response.setResponseMessage("PE300 - Data Issue: No Config Body Type given."); - policyParameters.setConfigBodyType(null); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testCreatePolicyNullPolicyConfigBody() { - response.setResponseMessage("PE300 - Data Issue: No Config Body given."); - policyParameters.setConfigBody(null); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullPolicyName() { - response.setResponseMessage("PE300 - Data Issue: No Policy Name given."); - policyParameters.setPolicyName(null); - try{ - result = policyEngine.updatePolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullPolicyScope() { - response.setResponseMessage("PE300 - Data Issue: No Policy Scope given."); - policyParameters.setPolicyName("test"); - try{ - result = policyEngine.updatePolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullEcompName() { - response.setResponseMessage("PE300 - Data Issue: No ECOMP Name given."); - policyParameters.setEcompName(null); - try{ - result = policyEngine.updatePolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullPolicyConfigName() { - response.setResponseMessage("PE300 - Data Issue: No Config Name given."); - policyParameters.setConfigName(null);; - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullPolicyConfigBodyType() { - response.setResponseMessage("PE300 - Data Issue: No Config Body Type given."); - policyParameters.setConfigBodyType(null); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullPolicyConfigBody() { - response.setResponseMessage("PE300 - Data Issue: No Config Body given."); - policyParameters.setConfigBody(null); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - //assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } -} \ No newline at end of file diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigFirewallPolicyTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigFirewallPolicyTest.java deleted file mode 100644 index 280f06e10..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigFirewallPolicyTest.java +++ /dev/null @@ -1,254 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import java.io.StringReader; -import java.util.UUID; - -import javax.json.Json; -import javax.json.JsonObject; -import javax.json.JsonReader; - -import org.junit.Test; -import org.mockito.Mockito; -import org.openecomp.policy.api.PolicyChangeResponse; -import org.openecomp.policy.api.PolicyConfigType; -import org.openecomp.policy.api.PolicyEngine; -import org.openecomp.policy.api.PolicyEngineException; -import org.openecomp.policy.api.PolicyParameters; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; -import org.openecomp.policy.std.StdPolicyChangeResponse; - -import junit.framework.TestCase; - -public class ConfigFirewallPolicyTest extends TestCase { - - private static final Logger logger = FlexLogger.getLogger(DecisionPolicyApiTest.class); - - private PolicyEngine policyEngine = null; - private PolicyEngine mockPolicyEngine = null; - - PolicyChangeResponse result = null; - StdPolicyChangeResponse response = new StdPolicyChangeResponse(); - PolicyParameters policyParameters = new PolicyParameters(); - String json = null; - - /** - * Perform pre-test initialization - * - * @throws Exception - * - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - try { - policyEngine = new PolicyEngine("Test/config_pass.properties"); - } catch (PolicyEngineException e) { - logger.error(e.getMessage()); - fail("PolicyEngine Instantiation Error" + e); - } - logger.info("Loaded.. PolicyEngine"); - - mockPolicyEngine = Mockito.mock(PolicyEngine.class); - - policyParameters.setPolicyConfigType(PolicyConfigType.Firewall); //required - policyParameters.setPolicyName("test.junitTest"); //required - - json = "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"rule1607\",\"deploymentOption\":{\"deployNow\":false},\"securityZoneId\":\"/v0/firewall/pan\",\"serviceGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"REFERENCE\",\"name\":\"SList\"},{\"type\":\"REFERENCE\",\"name\":\"Syslog\"}]},{\"name\":\"Syslog\",\"description\":\"NA\",\"type\":\"SERVICE\",\"transportProtocol\":\"udp\",\"appProtocol\":null,\"ports\":\"514\"},{\"name\":\"SList\",\"description\":\"Service List\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\",\"appProtocol\":null,\"ports\":\"8080\"}],\"addressGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"},{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]},{\"name\":\"PL_CCE3\",\"description\":\"CCE Routers\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]}],\"firewallRuleList\":[{\"position\":\"1\",\"ruleName\":\"1607Rule\",\"fromZones\":[\"Trusted\"],\"toZones\":[\"Untrusted\"],\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\",\"value\":\"PL_CCE3\"},{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"destinationList\":[{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"1607Group\"}],\"action\":\"accept\",\"description\":\"Rule for 1607 templates\",\"enabled\":true,\"log\":true}]}"; - - policyParameters.setConfigBody(buildJSON(json).toString()); - - //policyParameters.setPolicyScope("test"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI - policyParameters.setRequestID(UUID.randomUUID()); - } - - private static JsonObject buildJSON(String jsonString) { - JsonObject json = null;; - if (jsonString != null) { - StringReader in = null; - - in = new StringReader(jsonString); - - JsonReader jsonReader = Json.createReader(in); - json = jsonReader.readObject(); - } - - return json; - } - /** - * Perform post-test clean up - * - * @throws Exception - * - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - // Add additional tear down code here - } - - /** - * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test - */ - public void testCreatePolicy() { - response.setResponseMessage("success"); - PolicyChangeResponse result = null; - try { - - Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response); - result = mockPolicyEngine.createPolicy(policyParameters); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - /** - * Run the String createConfigFirewallPolicy() method test - */ - @SuppressWarnings("deprecation") - @Test - public void testCreateConfigFirewallPolicy() { - String response = "success"; - String result = null; - JsonObject jsonObj = buildJSON(json); - try { - - Mockito.when(mockPolicyEngine.createConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null)).thenReturn(response); - result = mockPolicyEngine.createConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - /** - * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test - */ - public void testUpdatePolicy() { - response.setResponseMessage("success"); - PolicyChangeResponse result = null; - try { - - Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response); - result = mockPolicyEngine.updatePolicy(policyParameters); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - /** - * Run the String updateConfigFirewallPolicy() method test - */ - @SuppressWarnings("deprecation") - @Test - public void testUpdateConfigFirewallPolicy() { - String response = "success"; - String result = null; - JsonObject jsonObj = buildJSON(json); - try { - - Mockito.when(mockPolicyEngine.updateConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null)).thenReturn(response); - result = mockPolicyEngine.updateConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - @Test - public final void testCreatePolicyNullPolicyName() { - response.setResponseMessage("PE500 - Process Flow Issue: :500:"); - policyParameters.setPolicyName(null); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testCreatePolicyNullPolicyScope() { - response.setResponseMessage("PE500 - Process Flow Issue: :500:"); - policyParameters.setPolicyName("test"); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testCreatePolicyNullPolicyConfigBody() { - response.setResponseMessage("PE500 - Process Flow Issue: :500:"); - policyParameters.setConfigBody(null); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullPolicyName() { - response.setResponseMessage("PE500 - Process Flow Issue: :500:"); - policyParameters.setPolicyName(null); - try{ - result = policyEngine.updatePolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullPolicyScope() { - response.setResponseMessage("PE500 - Process Flow Issue: :500:"); - policyParameters.setPolicyName("test"); - try{ - result = policyEngine.updatePolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullPolicyConfigBody() { - response.setResponseMessage("PE500 - Process Flow Issue: :500:"); - policyParameters.setConfigBody(null); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigRequestParametersTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigRequestParametersTest.java deleted file mode 100644 index 0e8f912c9..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigRequestParametersTest.java +++ /dev/null @@ -1,362 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import java.util.Hashtable; -import java.util.Map; -import java.util.UUID; - -import org.junit.*; -import org.openecomp.policy.api.ConfigRequestParameters; - -import static org.junit.Assert.*; - -/** - * The class ConfigRequestParametersTest contains tests for the class {@link ConfigRequestParameters}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class ConfigRequestParametersTest { - /** - * Run the ConfigRequestParameters() constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testConfigRequestParameters_1() - throws Exception { - - ConfigRequestParameters result = new ConfigRequestParameters(); - - // add additional test code here - assertNotNull(result); - assertEquals(null, result.getPolicyName()); - assertEquals(null, result.getConfigName()); - assertEquals(null, result.getConfigAttributes()); - assertEquals(null, result.getRequestID()); - assertEquals(null, result.getEcompName()); - assertEquals(Boolean.FALSE, result.getUnique()); - } - - /** - * Run the ConfigRequestParameters(String,String,String,Map,Boolean,UUID) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testConfigRequestParameters_2() - throws Exception { - String policyName = ""; - String eCOMPComponentName = ""; - String configName = ""; - Map configAttributes = new Hashtable(); - Boolean unique = new Boolean(true); - UUID requestID = UUID.randomUUID(); - - ConfigRequestParameters result = createConfigRequest(policyName, eCOMPComponentName, configName, configAttributes, unique, requestID); - - // add additional test code here - assertNotNull(result); - assertEquals("", result.getPolicyName()); - assertEquals("", result.getConfigName()); - assertEquals("", result.getEcompName()); - assertEquals(Boolean.TRUE, result.getUnique()); - } - - /** - * Run the Map getConfigAttributes() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetConfigAttributes_1() - throws Exception { - ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); - - Map 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:40 PM - */ - @Test - public void testGetConfigName_1() - throws Exception { - ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); - - String result = fixture.getConfigName(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the String getEcompName() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetEcompName_1() - throws Exception { - ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); - - String result = fixture.getEcompName(); - - // 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 { - ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); - - 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 { - ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.fromString("6b5aa070-90bc-46a6-9a59-e1fe526df7ae")); - - UUID result = fixture.getRequestID(); - - // add additional test code here - assertNotNull(result); - assertEquals("6b5aa070-90bc-46a6-9a59-e1fe526df7ae", result.toString()); - assertEquals(4, result.version()); - assertEquals(2, result.variant()); - assertEquals(-7324574836520519762L, result.getLeastSignificantBits()); - assertEquals(7735671715287287462L, result.getMostSignificantBits()); - } - - /** - * Run the Boolean getUnique() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetUnique_1() - throws Exception { - ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); - - Boolean result = fixture.getUnique(); - - // add additional test code here - assertNotNull(result); - assertEquals("true", result.toString()); - assertEquals(true, result.booleanValue()); - } - - /** - * Run the void makeUnique(Boolean) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testMakeUnique_1() - throws Exception { - ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); - Boolean unique = new Boolean(true); - - fixture.makeUnique(unique); - - // add additional test code here - } - - /** - * Run the void setConfigAttributes(Map) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetConfigAttributes_1() - throws Exception { - ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); - Map configAttributes = new Hashtable(); - - fixture.setConfigAttributes(configAttributes); - - // add additional test code here - } - - /** - * Run the void setConfigName(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetConfigName_1() - throws Exception { - ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); - String configName = ""; - - fixture.setConfigName(configName); - - // add additional test code here - } - - /** - * Run the void setEcompName(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetEcompName_1() - throws Exception { - ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); - String eCOMPComponentName = ""; - - fixture.setEcompName(eCOMPComponentName); - - // 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 { - ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); - 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 { - ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); - 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(ConfigRequestParametersTest.class); - } - - private ConfigRequestParameters createConfigRequest(String policyName, String eCOMPComponentName, String configName, Map configAttributes, Boolean unique, UUID requestID){ - ConfigRequestParameters configRequestParameters = new ConfigRequestParameters(); - configRequestParameters.setRequestID(requestID); - configRequestParameters.setPolicyName(policyName); - configRequestParameters.setEcompName(eCOMPComponentName); - configRequestParameters.setConfigName(configName); - configRequestParameters.setConfigAttributes(configAttributes); - configRequestParameters.makeUnique(unique); - return configRequestParameters; - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DecisionPolicyApiTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DecisionPolicyApiTest.java deleted file mode 100644 index 82ba1c7ca..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DecisionPolicyApiTest.java +++ /dev/null @@ -1,219 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.junit.Test; -import org.mockito.Mockito; -import org.openecomp.policy.api.AttributeType; -import org.openecomp.policy.api.PolicyChangeResponse; -import org.openecomp.policy.api.PolicyClass; -import org.openecomp.policy.api.PolicyEngine; -import org.openecomp.policy.api.PolicyEngineException; -import org.openecomp.policy.api.PolicyParameters; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; -import org.openecomp.policy.std.StdPolicyChangeResponse; - -import junit.framework.TestCase; - -/** - * The class DecisionPolicyApiTest contains tests for the class - * {@link PolicyEngine} - * - * @pattern JUnit Test Case - * * - */ -public class DecisionPolicyApiTest extends TestCase { - - private static final Logger logger = FlexLogger.getLogger(DecisionPolicyApiTest.class); - - private PolicyEngine policyEngine = null; - private PolicyEngine mockPolicyEngine = null; - - PolicyChangeResponse result = null; - StdPolicyChangeResponse response = new StdPolicyChangeResponse(); - PolicyParameters policyParameters = new PolicyParameters(); - - /** - * Perform pre-test initialization - * - * @throws Exception - * - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - try { - policyEngine = new PolicyEngine("Test/config_pass.properties"); - } catch (PolicyEngineException e) { - logger.error(e.getMessage()); - fail("PolicyEngine Instantiation Error" + e); - } - logger.info("Loaded.. PolicyEngine"); - - mockPolicyEngine = Mockito.mock(PolicyEngine.class); - - policyParameters.setPolicyClass(PolicyClass.Decision); //required - policyParameters.setPolicyName("test.junitTest"); //required - policyParameters.setEcompName("test"); - policyParameters.setPolicyDescription("testing"); //optional - //policyParameters.setPolicyScope("test"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI - - //Set the Component Attributes... These are Optional - Map configAttributes = new HashMap(); - configAttributes.put("test", "testing"); - - Map> attributes = new HashMap>(); - attributes.put(AttributeType.MATCHING, configAttributes); - policyParameters.setAttributes(attributes); - - //Set the settings... These are Optional -/* Map settingsMap = new HashMap(); - settingsMap.put("server", "5"); - - Map> settings = new HashMap>(); - settings.put(AttributeType.SETTINGS, settingsMap); - policyParameters.setSettings(settings);*/ - - policyParameters.setRequestID(UUID.randomUUID()); - } - - /** - * Perform post-test clean up - * - * @throws Exception - * - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - // Add additional tear down code here - } - - /** - * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test - */ - public void testCreatePolicy() { - response.setResponseMessage("success"); - PolicyChangeResponse result = null; - try { - - Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response); - result = mockPolicyEngine.createPolicy(policyParameters); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - /** - * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test - */ - public void testUpdatePolicy() { - response.setResponseMessage("success"); - PolicyChangeResponse result = null; - try { - - Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response); - result = mockPolicyEngine.updatePolicy(policyParameters); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - @Test - public final void testCreatePolicyNullPolicyName() { - response.setResponseMessage("PE500 - Process Flow Issue: :500:"); - policyParameters.setPolicyName(null); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testCreatePolicyNullPolicyScope() { - response.setResponseMessage("PE500 - Process Flow Issue: :500:"); - policyParameters.setPolicyName("test"); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testCreatePolicyNullEcompName() { - response.setResponseMessage("PE500 - Process Flow Issue: :500:"); - policyParameters.setEcompName(null); - try{ - result = policyEngine.createPolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullPolicyName() { - response.setResponseMessage("PE500 - Process Flow Issue: :500:"); - policyParameters.setPolicyName(null); - try{ - result = policyEngine.updatePolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullPolicyScope() { - response.setResponseMessage("PE500 - Process Flow Issue: :500:"); - policyParameters.setPolicyName("test"); - try{ - result = policyEngine.updatePolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } - - @Test - public final void testUpdatePolicyNullEcompName() { - response.setResponseMessage("PE500 - Process Flow Issue: :500:"); - policyParameters.setEcompName(null); - try{ - result = policyEngine.updatePolicy(policyParameters); - } catch (Exception e){ - logger.warn(e.getMessage()); - } - assertEquals(result.getResponseMessage(), response.getResponseMessage()); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DecisionRequestParametersTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DecisionRequestParametersTest.java deleted file mode 100644 index d8fdfbc0a..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DecisionRequestParametersTest.java +++ /dev/null @@ -1,232 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import java.util.Hashtable; -import java.util.Map; -import java.util.UUID; - -import org.junit.*; -import org.openecomp.policy.api.DecisionRequestParameters; - -import static org.junit.Assert.*; - -/** - * The class DecisionRequestParametersTest contains tests for the class {@link DecisionRequestParameters}. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - * @version $Revision: 1.0 $ - */ -public class DecisionRequestParametersTest { - /** - * Run the DecisionRequestParameters() constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testDecisionRequestParameters_1() - throws Exception { - - DecisionRequestParameters result = new DecisionRequestParameters(); - - // add additional test code here - assertNotNull(result); - assertEquals(null, result.getECOMPComponentName()); - assertEquals(null, result.getDecisionAttributes()); - assertEquals(null, result.getRequestID()); - } - - /** - * Run the DecisionRequestParameters(String,Map,UUID) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testDecisionRequestParameters_2() - throws Exception { - String eCOMPComponentName = ""; - Map decisionAttributes = new Hashtable(); - UUID requestID = UUID.randomUUID(); - - DecisionRequestParameters result = new DecisionRequestParameters(eCOMPComponentName, decisionAttributes, requestID); - - // add additional test code here - assertNotNull(result); - assertEquals("", result.getECOMPComponentName()); - } - - /** - * Run the Map getDecisionAttributes() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetDecisionAttributes_1() - throws Exception { - DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable(), UUID.randomUUID()); - - Map result = fixture.getDecisionAttributes(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the String getECOMPComponentName() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetECOMPComponentName_1() - throws Exception { - DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable(), UUID.randomUUID()); - - String result = fixture.getECOMPComponentName(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the UUID getRequestID() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetRequestID_1() - throws Exception { - DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable(), UUID.fromString("d1db6a6d-7140-4864-8200-6b541261fdd2")); - - UUID result = fixture.getRequestID(); - - // add additional test code here - assertNotNull(result); - assertEquals("d1db6a6d-7140-4864-8200-6b541261fdd2", result.toString()); - assertEquals(4, result.version()); - assertEquals(2, result.variant()); - assertEquals(-9079138839949083182L, result.getLeastSignificantBits()); - assertEquals(-3324946881598961564L, result.getMostSignificantBits()); - } - - /** - * Run the void setDecisionAttributes(Map) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetDecisionAttributes_1() - throws Exception { - DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable(), UUID.randomUUID()); - Map decisionAttributes = new Hashtable(); - - fixture.setDecisionAttributes(decisionAttributes); - - // add additional test code here - } - - /** - * Run the void setECOMPComponentName(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetECOMPComponentName_1() - throws Exception { - DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable(), UUID.randomUUID()); - String eCOMPComponentName = ""; - - fixture.setECOMPComponentName(eCOMPComponentName); - - // add additional test code here - } - - /** - * Run the void setRequestID(UUID) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetRequestID_1() - throws Exception { - DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable(), UUID.randomUUID()); - 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: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(DecisionRequestParametersTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DeletePolicyConditionTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DeletePolicyConditionTest.java deleted file mode 100644 index c2941202b..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DeletePolicyConditionTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.*; -import org.openecomp.policy.api.DeletePolicyCondition; - -import static org.junit.Assert.*; - -/** - * The class DeletePolicyConditionTest contains tests for the class {@link DeletePolicyCondition}. - * - * @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(); - - // add additional test code here - assertEquals("All Versions", 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(DeletePolicyConditionTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DeletePolicyParametersTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DeletePolicyParametersTest.java deleted file mode 100644 index 7723f9819..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DeletePolicyParametersTest.java +++ /dev/null @@ -1,314 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import java.util.UUID; - -import org.junit.*; -import org.openecomp.policy.api.DeletePolicyCondition; -import org.openecomp.policy.api.DeletePolicyParameters; - -import static org.junit.Assert.*; - -/** - * The class DeletePolicyParametersTest contains tests for the class {@link DeletePolicyParameters}. - * - * @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); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/EventRequestParametersTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/EventRequestParametersTest.java deleted file mode 100644 index abfc31f8b..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/EventRequestParametersTest.java +++ /dev/null @@ -1,193 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import java.util.Hashtable; -import java.util.Map; -import java.util.UUID; - -import org.junit.*; -import org.openecomp.policy.api.EventRequestParameters; - -import static org.junit.Assert.*; - -/** - * The class EventRequestParametersTest contains tests for the class {@link EventRequestParameters}. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - * @version $Revision: 1.0 $ - */ -public class EventRequestParametersTest { - /** - * Run the EventRequestParameters() constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testEventRequestParameters_1() - throws Exception { - - EventRequestParameters result = new EventRequestParameters(); - - // add additional test code here - assertNotNull(result); - assertEquals(null, result.getEventAttributes()); - assertEquals(null, result.getRequestID()); - } - - /** - * Run the EventRequestParameters(Map,UUID) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testEventRequestParameters_2() - throws Exception { - Map eventAttributes = new Hashtable(); - UUID requestID = UUID.randomUUID(); - - EventRequestParameters result = new EventRequestParameters(eventAttributes, requestID); - - // add additional test code here - assertNotNull(result); - } - - /** - * Run the Map getEventAttributes() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetEventAttributes_1() - throws Exception { - EventRequestParameters fixture = new EventRequestParameters(new Hashtable(), UUID.randomUUID()); - - Map result = fixture.getEventAttributes(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the UUID getRequestID() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetRequestID_1() - throws Exception { - EventRequestParameters fixture = new EventRequestParameters(new Hashtable(), UUID.fromString("5b15376d-569b-4772-ac75-9362043f6a6c")); - - UUID result = fixture.getRequestID(); - - // add additional test code here - assertNotNull(result); - assertEquals("5b15376d-569b-4772-ac75-9362043f6a6c", result.toString()); - assertEquals(4, result.version()); - assertEquals(2, result.variant()); - assertEquals(-6019743277723456916L, result.getLeastSignificantBits()); - assertEquals(6563212974706345842L, result.getMostSignificantBits()); - } - - /** - * Run the void setEventAttributes(Map) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetEventAttributes_1() - throws Exception { - EventRequestParameters fixture = new EventRequestParameters(new Hashtable(), UUID.randomUUID()); - Map eventAttributes = new Hashtable(); - - fixture.setEventAttributes(eventAttributes); - - // add additional test code here - } - - /** - * Run the void setRequestID(UUID) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetRequestID_1() - throws Exception { - EventRequestParameters fixture = new EventRequestParameters(new Hashtable(), UUID.randomUUID()); - 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: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(EventRequestParametersTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigByPolicyNameTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigByPolicyNameTest.java deleted file mode 100644 index 7bfa27c6e..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigByPolicyNameTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import java.util.Collection; - -import org.junit.Before; -import org.junit.Test; -import org.openecomp.policy.api.PolicyConfig; -import org.openecomp.policy.api.PolicyConfigException; -import org.openecomp.policy.api.PolicyEngine; -import org.openecomp.policy.api.PolicyEngineException; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; - -import junit.framework.TestCase; - -public class GetConfigByPolicyNameTest extends TestCase { - private PolicyEngine policyEngine = null; - private String policyName = null; - private Collection policyConfig = null; - private static final Logger logger = FlexLogger.getLogger(GetConfigByPolicyNameTest.class); - @Before - public void setUp() { - try { - policyEngine = new PolicyEngine("Test/config_pass.properties"); - } catch (PolicyEngineException e) { - logger.error(e.getMessage()); - fail("PolicyEngine Instantiation Error" + e); - } - logger.info("Loaded.. PolicyEngine"); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetConfigPolicyNameNotValid(){ - policyName = null; - try{ - policyConfig = policyEngine.getConfigByPolicyName(policyName); - } catch (PolicyConfigException e){ - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringStringMapTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringStringMapTest.java deleted file mode 100644 index c5b7f8f6d..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringStringMapTest.java +++ /dev/null @@ -1,259 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; -import org.openecomp.policy.api.PolicyConfig; -import org.openecomp.policy.api.PolicyConfigException; -import org.openecomp.policy.api.PolicyConfigStatus; -import org.openecomp.policy.api.PolicyEngine; -import org.openecomp.policy.api.PolicyEngineException; -import org.openecomp.policy.api.PolicyType; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; - -public class GetConfigStringStringMapTest { - - private PolicyEngine policyEngine = null; - private String eCOMPComponentName = null; - private String configName = null; - private Map configAttributes = new HashMap(); - private Collection policyConfig = null; - private static final Logger logger = FlexLogger.getLogger(GetConfigStringStringMapTest.class); - @Before - public void setUp() { - try { - policyEngine = new PolicyEngine("Test/config_pass.properties"); - } catch (PolicyEngineException e) { - logger.error(e.getMessage()); - fail("PolicyEngine Instantiation Error" + e); - } - logger.info("Loaded.. PolicyEngine"); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetConfigStringStringMapFail() { - eCOMPComponentName = null; - configName = null; - configAttributes = null; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName, configAttributes); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetConfigStringStringMapFail1() { - eCOMPComponentName = null; - configName = "testFail"; - configAttributes.put("TestValue", "Fail"); - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName, configAttributes); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetConfigStringStringMapFail2() { - eCOMPComponentName = "TestFail"; - configName = null; - configAttributes.put("TestValue", "Fail"); - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName, configAttributes); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetConfigStringStringMapFail3() { - eCOMPComponentName = "TestFail"; - configName = "configFail"; - configAttributes= null; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName, configAttributes); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetConfigStringStringMapfail4() { - eCOMPComponentName = "TestFail"; - configName = "configFail"; - configAttributes.put("", ""); - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName, configAttributes); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - //@Test - @SuppressWarnings("deprecation") - public void testGetConfigStringStringMapNotValid() { - eCOMPComponentName = "TestFail"; - configName = "configFail"; - configAttributes.put("Action:com.test.fail", "Value"); - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName, configAttributes); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - for(PolicyConfig policyConfig : this.policyConfig){ - logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig); - assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND,policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig.getPolicyConfigMessage()); - assertNull(policyConfig.getType()); - assertNull(policyConfig.toJSON()); - assertNull(policyConfig.toProperties()); - assertNull(policyConfig.toXML()); - assertNull(policyConfig.toOther()); - } - } - - //@Test - @SuppressWarnings("deprecation") - public void testGetConfigStringStringMapValidJSON() { - eCOMPComponentName = "JSON"; - configName = "JSONconfig"; - configAttributes.put("Resource.com:test:resource:json", "Test"); - configAttributes.put("Action.com:test:action:json", "TestJSON"); - configAttributes.put("Subject.com:test:subject:json", "TestSubject"); - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName, configAttributes); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - for(PolicyConfig policyConfig : this.policyConfig){ - logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig); - assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig.getPolicyConfigMessage()); - assertEquals(PolicyType.JSON,policyConfig.getType()); - assertNotNull(policyConfig.toJSON()); - assertNull(policyConfig.toProperties()); - assertNull(policyConfig.toXML()); - assertNull(policyConfig.toOther()); - } - } - - //@Test - @SuppressWarnings("deprecation") - public void testGetConfigStringStringMapValidXML() { - eCOMPComponentName = "XML"; - configName = "XMLconfig"; - configAttributes.put("Resource.com:test:resource:json", "Test"); - configAttributes.put("Action.com:test:action:json", "TestJSON"); - configAttributes.put("Subject.com:test:subject:json", "TestSubject"); - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName, configAttributes); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - for(PolicyConfig policyConfig : this.policyConfig){ - logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig); - assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig.getPolicyConfigMessage()); - assertEquals(PolicyType.XML,policyConfig.getType()); - assertNull(policyConfig.toJSON()); - assertNull(policyConfig.toProperties()); - assertNotNull(policyConfig.toXML()); - assertNull(policyConfig.toOther()); - } - } - - //@Test - @SuppressWarnings("deprecation") - public void testGetConfigStringStringMapValidProperties() { - eCOMPComponentName = "Properties"; - configName = "PropConfig" ; - configAttributes.put("Resource.com:test:resource:json", "Test"); - configAttributes.put("Action.com:test:action:json", "TestJSON"); - configAttributes.put("Subject.com:test:subject:json", "TestSubject"); - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName, configAttributes); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - for(PolicyConfig policyConfig : this.policyConfig){ - logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig); - assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig.getPolicyConfigMessage()); - assertEquals(PolicyType.PROPERTIES,policyConfig.getType()); - assertNull(policyConfig.toJSON()); - assertNotNull(policyConfig.toProperties()); - assertNull(policyConfig.toXML()); - assertNull(policyConfig.toOther()); - } - } - - //@Test - @SuppressWarnings("deprecation") - public void testGetConfigStringStringMapValidOther() { - eCOMPComponentName = "Other"; - configName = "OtherConfig" ; - configAttributes.put("Resource.com:test:resource:json", "Test"); - configAttributes.put("Action.com:test:action:json", "TestJSON"); - configAttributes.put("Subject.com:test:subject:json", "TestSubject"); - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName, configAttributes); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - for(PolicyConfig policyConfig : this.policyConfig){ - logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig); - assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig.getPolicyConfigMessage()); - assertEquals(PolicyType.OTHER,policyConfig.getType()); - assertNull(policyConfig.toJSON()); - assertNull(policyConfig.toProperties()); - assertNull(policyConfig.toXML()); - assertNotNull(policyConfig.toOther()); - } - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringStringTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringStringTest.java deleted file mode 100644 index b55abd734..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringStringTest.java +++ /dev/null @@ -1,213 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - -import java.util.Collection; - -import org.junit.Before; -import org.junit.Test; -import org.openecomp.policy.api.PolicyConfig; -import org.openecomp.policy.api.PolicyConfigException; -import org.openecomp.policy.api.PolicyConfigStatus; -import org.openecomp.policy.api.PolicyEngine; -import org.openecomp.policy.api.PolicyEngineException; -import org.openecomp.policy.api.PolicyType; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; - -public class GetConfigStringStringTest { - - private PolicyEngine policyEngine = null; - private String eCOMPComponentName = null; - private String configName = null; - private Collection policyConfig = null; - private static final Logger logger = FlexLogger.getLogger(GetConfigStringStringTest.class); - @Before - public void setUp() { - try { - policyEngine = new PolicyEngine("Test/config_pass.properties"); - } catch (PolicyEngineException e) { - logger.error(e.getMessage()); - fail("PolicyEngine Instantiation Error" + e); - } - logger.info("Loaded.. PolicyEngine"); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetConfigStringStringFail() { - eCOMPComponentName = null; - configName = null; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetConfigStringStringFail1() { - eCOMPComponentName = null; - configName = ""; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetConfigStringStringFail2() { - eCOMPComponentName = ""; - configName = null; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - //@Test - @SuppressWarnings("deprecation") - public void testGetConfigStringStringNotvalid() { - eCOMPComponentName = "fail"; - configName = "fail"; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - for(PolicyConfig policyConfig : this.policyConfig){ - logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig); - assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND,policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig.getPolicyConfigMessage()); - assertNull(policyConfig.getType()); - assertNull(policyConfig.toJSON()); - assertNull(policyConfig.toProperties()); - assertNull(policyConfig.toXML()); - assertNull(policyConfig.toOther()); - } - } - - //@Test - @SuppressWarnings("deprecation") - public void testGetConfigStringStringValidJSON() { - eCOMPComponentName = "JSON"; - configName = "JSONconfig"; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - for(PolicyConfig policyConfig : this.policyConfig){ - logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig); - assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig.getPolicyConfigMessage()); - assertEquals(PolicyType.JSON,policyConfig.getType()); - assertNotNull(policyConfig.toJSON()); - assertNull(policyConfig.toProperties()); - assertNull(policyConfig.toXML()); - assertNull(policyConfig.toOther()); - } - } - - //@Test - @SuppressWarnings("deprecation") - public void testGetConfigStringStringValidXML() { - eCOMPComponentName = "XML"; - configName = "XMLconfig"; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - for(PolicyConfig policyConfig : this.policyConfig){ - logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig); - assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig.getPolicyConfigMessage()); - assertEquals(PolicyType.XML,policyConfig.getType()); - assertNull(policyConfig.toJSON()); - assertNull(policyConfig.toProperties()); - assertNotNull(policyConfig.toXML()); - assertNull(policyConfig.toOther()); - } - } - - //@Test - @SuppressWarnings("deprecation") - public void testGetConfigStringStringValidProperties() { - eCOMPComponentName = "Properties"; - configName = "PropConfig" ; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - for(PolicyConfig policyConfig : this.policyConfig){ - logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig); - assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig.getPolicyConfigMessage()); - assertEquals(PolicyType.PROPERTIES,policyConfig.getType()); - assertNull(policyConfig.toJSON()); - assertNotNull(policyConfig.toProperties()); - assertNull(policyConfig.toXML()); - assertNull(policyConfig.toOther()); - } - } - - //@Test - @SuppressWarnings("deprecation") - public void testGetConfigStringStringValidOther() { - eCOMPComponentName = "Other"; - configName = "OtherConfig" ; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName, configName); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - for(PolicyConfig policyConfig : this.policyConfig){ - logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig); - assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig.getPolicyConfigMessage()); - assertEquals(PolicyType.OTHER,policyConfig.getType()); - assertNull(policyConfig.toJSON()); - assertNull(policyConfig.toProperties()); - assertNull(policyConfig.toXML()); - assertNotNull(policyConfig.toOther()); - } - } - -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringTest.java deleted file mode 100644 index ffa1913aa..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringTest.java +++ /dev/null @@ -1,170 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import java.util.Collection; - -import org.junit.Before; -import org.openecomp.policy.api.PolicyConfig; -import org.openecomp.policy.api.PolicyConfigException; -import org.openecomp.policy.api.PolicyEngine; -import org.openecomp.policy.api.PolicyEngineException; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; - -import junit.framework.TestCase; - -public class GetConfigStringTest extends TestCase{ - - private PolicyEngine policyEngine = null; - private String eCOMPComponentName = null; - private Collection policyConfig = null; - private static final Logger logger = FlexLogger.getLogger(GetConfigStringTest.class); - @Before - public void setUp() { - try { - policyEngine = new PolicyEngine("Test/config_pass.properties"); - } catch (PolicyEngineException e) { - logger.error(e.getMessage()); - fail("PolicyEngine Instantiation Error" + e); - } - logger.info("Loaded.. PolicyEngine"); - } - - //@Test - @SuppressWarnings("deprecation") - public void testGetConfigStringFail() { - eCOMPComponentName = null; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - /*@Test - public void testGetConfigStringNotvalid() { - eCOMPComponentName = "fail"; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - for(PolicyConfig policyConfig : this.policyConfig){ - logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig); - assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND,policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig.getPolicyConfigMessage()); - assertNull(policyConfig.getType()); - assertNull(policyConfig.toJSON()); - assertNull(policyConfig.toProperties()); - assertNull(policyConfig.toXML()); - assertNull(policyConfig.toOther()); - } - } - */ - - /*@Test - public void testGetConfigStringValidJSON() { - eCOMPComponentName = "JSON"; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - for(PolicyConfig policyConfig : this.policyConfig){ - logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig); - assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig.getPolicyConfigMessage()); - assertEquals(PolicyType.JSON,policyConfig.getType()); - assertNotNull(policyConfig.toJSON()); - assertNull(policyConfig.toProperties()); - assertNull(policyConfig.toXML()); - assertNull(policyConfig.toOther()); - } - } - */ - /*@Test - public void testGetConfigStringValidXML() { - eCOMPComponentName = "XML"; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - for(PolicyConfig policyConfig : this.policyConfig){ - logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig); - assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig.getPolicyConfigMessage()); - assertEquals(PolicyType.XML,policyConfig.getType()); - assertNull(policyConfig.toJSON()); - assertNull(policyConfig.toProperties()); - assertNotNull(policyConfig.toXML()); - assertNull(policyConfig.toOther()); - } - } - */ - /*@Test - public void testGetConfigStringValidProperties() { - eCOMPComponentName = "Properties"; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - for(PolicyConfig policyConfig : this.policyConfig){ - logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig); - assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig.getPolicyConfigMessage()); - assertEquals(PolicyType.PROPERTIES,policyConfig.getType()); - assertNull(policyConfig.toJSON()); - assertNotNull(policyConfig.toProperties()); - assertNull(policyConfig.toXML()); - assertNull(policyConfig.toOther()); - } - } - */ - /*@Test - public void testGetConfigStringValidOther() { - eCOMPComponentName = "Other"; - try { - policyConfig = policyEngine.getConfig(eCOMPComponentName); - } catch (PolicyConfigException e) { - logger.warn(e.getMessage()); - } - for(PolicyConfig policyConfig : this.policyConfig){ - logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig); - assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus()); - assertNotNull(policyConfig.getPolicyConfigMessage()); - assertEquals(PolicyType.OTHER,policyConfig.getType()); - assertNull(policyConfig.toJSON()); - assertNull(policyConfig.toProperties()); - assertNull(policyConfig.toXML()); - assertNotNull(policyConfig.toOther()); - } - } - */ -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ImportParametersTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ImportParametersTest.java deleted file mode 100644 index 3719b5d2f..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ImportParametersTest.java +++ /dev/null @@ -1,403 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openecomp.policy.api.ImportParameters; - -/** - * The class ImportParametersTest contains tests for the class {@link ImportParameters}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class ImportParametersTest { - /** - * Run the String getDescription() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetDescription_1() - throws Exception { - ImportParameters fixture = new ImportParameters(); - fixture.setFilePath(""); - fixture.setVersion(""); - fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); - fixture.setRequestID(UUID.randomUUID()); - fixture.setDescription(""); - fixture.setServiceName(""); - - String result = fixture.getDescription(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the String getFilePath() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetFilePath_1() - throws Exception { - ImportParameters fixture = new ImportParameters(); - fixture.setFilePath(""); - fixture.setVersion(""); - fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); - fixture.setRequestID(UUID.randomUUID()); - fixture.setDescription(""); - fixture.setServiceName(""); - - String result = fixture.getFilePath(); - - // 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 { - ImportParameters fixture = new ImportParameters(); - fixture.setFilePath(""); - fixture.setVersion(""); - fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); - fixture.setRequestID(UUID.fromString("731dca0a-fe99-456c-8ad2-87cff8437b2f")); - fixture.setDescription(""); - fixture.setServiceName(""); - - UUID result = fixture.getRequestID(); - - // add additional test code here - assertNotNull(result); - assertEquals("731dca0a-fe99-456c-8ad2-87cff8437b2f", result.toString()); - assertEquals(4, result.version()); - assertEquals(2, result.variant()); - assertEquals(-8443537024073106641L, result.getLeastSignificantBits()); - assertEquals(8295008237256263020L, result.getMostSignificantBits()); - } - - /** - * Run the String getServiceName() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetServiceName_1() - throws Exception { - ImportParameters fixture = new ImportParameters(); - fixture.setFilePath(""); - fixture.setVersion(""); - fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); - fixture.setRequestID(UUID.randomUUID()); - fixture.setDescription(""); - fixture.setServiceName(""); - - String result = fixture.getServiceName(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the ImportParameters.IMPORT_TYPE getServiceType() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetServiceType_1() - throws Exception { - ImportParameters fixture = new ImportParameters(); - fixture.setFilePath(""); - fixture.setVersion(""); - fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); - fixture.setRequestID(UUID.randomUUID()); - fixture.setDescription(""); - fixture.setServiceName(""); - - ImportParameters.IMPORT_TYPE result = fixture.getServiceType(); - - // add additional test code here - assertNotNull(result); - assertEquals("MICROSERVICE", result.name()); - assertEquals("MICROSERVICE", result.toString()); - assertEquals(0, result.ordinal()); - } - - /** - * Run the String getVersion() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetVersion_1() - throws Exception { - ImportParameters fixture = new ImportParameters(); - fixture.setFilePath(""); - fixture.setVersion(""); - fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); - fixture.setRequestID(UUID.randomUUID()); - fixture.setDescription(""); - fixture.setServiceName(""); - - String result = fixture.getVersion(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the void setDescription(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetDescription_1() - throws Exception { - ImportParameters fixture = new ImportParameters(); - fixture.setFilePath(""); - fixture.setVersion(""); - fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); - fixture.setRequestID(UUID.randomUUID()); - fixture.setDescription(""); - fixture.setServiceName(""); - String description = ""; - - fixture.setDescription(description); - - // add additional test code here - } - - /** - * Run the void setFilePath(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetFilePath_1() - throws Exception { - ImportParameters fixture = new ImportParameters(); - fixture.setFilePath(""); - fixture.setVersion(""); - fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); - fixture.setRequestID(UUID.randomUUID()); - fixture.setDescription(""); - fixture.setServiceName(""); - String filePath = ""; - - fixture.setFilePath(filePath); - - // add additional test code here - } - - /** - * Run the void setImportParameters(String,String,UUID,String,IMPORT_TYPE,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetImportParameters_1() - throws Exception { - ImportParameters fixture = new ImportParameters(); - fixture.setFilePath(""); - fixture.setVersion(""); - fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); - fixture.setRequestID(UUID.randomUUID()); - fixture.setDescription(""); - fixture.setServiceName(""); - String serviceName = ""; - String description = ""; - UUID requestID = UUID.randomUUID(); - String filePath = ""; - ImportParameters.IMPORT_TYPE importType = ImportParameters.IMPORT_TYPE.MICROSERVICE; - String version = ""; - - fixture.setImportParameters(serviceName, description, requestID, filePath, importType, version); - - // 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 { - ImportParameters fixture = new ImportParameters(); - fixture.setFilePath(""); - fixture.setVersion(""); - fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); - fixture.setRequestID(UUID.randomUUID()); - fixture.setDescription(""); - fixture.setServiceName(""); - UUID requestID = UUID.randomUUID(); - - fixture.setRequestID(requestID); - - // add additional test code here - } - - /** - * Run the void setServiceName(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetServiceName_1() - throws Exception { - ImportParameters fixture = new ImportParameters(); - fixture.setFilePath(""); - fixture.setVersion(""); - fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); - fixture.setRequestID(UUID.randomUUID()); - fixture.setDescription(""); - fixture.setServiceName(""); - String serviceName = ""; - - fixture.setServiceName(serviceName); - - // add additional test code here - } - - /** - * Run the void setServiceType(IMPORT_TYPE) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetServiceType_1() - throws Exception { - ImportParameters fixture = new ImportParameters(); - fixture.setFilePath(""); - fixture.setVersion(""); - fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); - fixture.setRequestID(UUID.randomUUID()); - fixture.setDescription(""); - fixture.setServiceName(""); - ImportParameters.IMPORT_TYPE enumImportType = ImportParameters.IMPORT_TYPE.MICROSERVICE; - - fixture.setServiceType(enumImportType); - - // add additional test code here - } - - /** - * Run the void setVersion(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetVersion_1() - throws Exception { - ImportParameters fixture = new ImportParameters(); - fixture.setFilePath(""); - fixture.setVersion(""); - fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); - fixture.setRequestID(UUID.randomUUID()); - fixture.setDescription(""); - fixture.setServiceName(""); - String version = ""; - - fixture.setVersion(version); - - // 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(ImportParametersTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/LoadedPolicyTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/LoadedPolicyTest.java deleted file mode 100644 index 0748d0ad9..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/LoadedPolicyTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.After; -import org.junit.Before; -import org.openecomp.policy.api.LoadedPolicy; - -/** - * The class LoadedPolicyTest contains tests for the class {@link LoadedPolicy}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class LoadedPolicyTest { - /** - * 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(LoadedPolicyTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationHandlerTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationHandlerTest.java deleted file mode 100644 index 68ba3a773..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationHandlerTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.After; -import org.junit.Before; -import org.openecomp.policy.api.NotificationHandler; - -/** - * The class NotificationHandlerTest contains tests for the class {@link NotificationHandler}. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - * @version $Revision: 1.0 $ - */ -public class NotificationHandlerTest { - /** - * 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(NotificationHandlerTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationSchemeTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationSchemeTest.java deleted file mode 100644 index 1cb105c2f..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationSchemeTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.*; -import org.openecomp.policy.api.NotificationScheme; - -import static org.junit.Assert.*; - -/** - * The class NotificationSchemeTest contains tests for the class {@link NotificationScheme}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class NotificationSchemeTest { - /** - * Run the String toString() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testToString_1() - throws Exception { - NotificationScheme fixture = NotificationScheme.AUTO_ALL_NOTIFICATIONS; - - String result = fixture.toString(); - - // add additional test code here - assertEquals("auto_all_notifications", 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(NotificationSchemeTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationTypeTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationTypeTest.java deleted file mode 100644 index 95dce6a60..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationTypeTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.*; -import org.openecomp.policy.api.NotificationType; - -import static org.junit.Assert.*; - -/** - * The class NotificationTypeTest contains tests for the class {@link NotificationType}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class NotificationTypeTest { - /** - * Run the String toString() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testToString_1() - throws Exception { - NotificationType fixture = NotificationType.BOTH; - - String result = fixture.toString(); - - // add additional test code here - assertEquals("both", 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(NotificationTypeTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PDPNotificationTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PDPNotificationTest.java deleted file mode 100644 index 43754f8df..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PDPNotificationTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.After; -import org.junit.Before; -import org.openecomp.policy.api.PDPNotification; - -/** - * The class PDPNotificationTest contains tests for the class {@link PDPNotification}. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - * @version $Revision: 1.0 $ - */ -public class PDPNotificationTest { - /** - * 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(PDPNotificationTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyChangeResponseTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyChangeResponseTest.java deleted file mode 100644 index d36ae44c2..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyChangeResponseTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.After; -import org.junit.Before; -import org.openecomp.policy.api.PolicyChangeResponse; - -/** - * The class PolicyChangeResponseTest contains tests for the class {@link PolicyChangeResponse}. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - * @version $Revision: 1.0 $ - */ -public class PolicyChangeResponseTest { - /** - * 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(PolicyChangeResponseTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyClassTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyClassTest.java deleted file mode 100644 index 28e5beefd..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyClassTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.*; -import org.openecomp.policy.api.PolicyClass; - -import static org.junit.Assert.*; - -/** - * The class PolicyClassTest contains tests for the class {@link PolicyClass}. - * - * @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() - throws Exception { - PolicyClass fixture = PolicyClass.Action; - - String result = fixture.toString(); - - // add additional test code here - assertEquals("Action", 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(PolicyClassTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigExceptionTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigExceptionTest.java deleted file mode 100644 index 4134eacc2..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigExceptionTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.*; -import org.openecomp.policy.api.PolicyConfigException; - -import static org.junit.Assert.*; - -/** - * The class PolicyConfigExceptionTest contains tests for the class {@link PolicyConfigException}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class PolicyConfigExceptionTest { - /** - * Run the PolicyConfigException() constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPolicyConfigException_1() - throws Exception { - - PolicyConfigException result = new PolicyConfigException(); - - // add additional test code here - assertNotNull(result); - assertEquals(null, result.getCause()); - assertEquals("org.openecomp.policy.api.PolicyConfigException", result.toString()); - assertEquals(null, result.getLocalizedMessage()); - assertEquals(null, result.getMessage()); - } - - /** - * Run the PolicyConfigException(String) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPolicyConfigException_2() - throws Exception { - String message = ""; - - PolicyConfigException result = new PolicyConfigException(message); - - // add additional test code here - assertNotNull(result); - assertEquals(null, result.getCause()); - assertEquals("org.openecomp.policy.api.PolicyConfigException: ", result.toString()); - assertEquals("", result.getLocalizedMessage()); - assertEquals("", result.getMessage()); - } - - /** - * Run the PolicyConfigException(Throwable) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPolicyConfigException_3() - throws Exception { - Throwable cause = new Throwable(); - - PolicyConfigException result = new PolicyConfigException(cause); - - // add additional test code here - assertNotNull(result); - assertEquals("org.openecomp.policy.api.PolicyConfigException: java.lang.Throwable", result.toString()); - assertEquals("java.lang.Throwable", result.getLocalizedMessage()); - assertEquals("java.lang.Throwable", result.getMessage()); - } - - /** - * Run the PolicyConfigException(String,Throwable) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPolicyConfigException_4() - throws Exception { - String message = ""; - Throwable cause = new Throwable(); - - PolicyConfigException result = new PolicyConfigException(message, cause); - - // add additional test code here - assertNotNull(result); - assertEquals("org.openecomp.policy.api.PolicyConfigException: ", result.toString()); - assertEquals("", result.getLocalizedMessage()); - assertEquals("", result.getMessage()); - } - - /** - * Run the PolicyConfigException(String,Throwable,boolean,boolean) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPolicyConfigException_5() - throws Exception { - String message = ""; - Throwable cause = new Throwable(); - boolean enableSuppression = true; - boolean writableStackTrace = true; - - PolicyConfigException result = new PolicyConfigException(message, cause, enableSuppression, writableStackTrace); - - // add additional test code here - assertNotNull(result); - assertEquals("org.openecomp.policy.api.PolicyConfigException: ", result.toString()); - assertEquals("", result.getLocalizedMessage()); - assertEquals("", result.getMessage()); - } - - /** - * 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(PolicyConfigExceptionTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigStatusTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigStatusTest.java deleted file mode 100644 index c40253890..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigStatusTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.*; -import org.openecomp.policy.api.PolicyConfigStatus; - -import static org.junit.Assert.*; - -/** - * The class PolicyConfigStatusTest contains tests for the class {@link PolicyConfigStatus}. - * - * @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); - - // add additional test code here - assertNotNull(result); - assertEquals("not_found", result.toString()); - assertEquals("CONFIG_NOT_FOUND", result.name()); - assertEquals(1, 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 { - String configStatus = ""; - - PolicyConfigStatus result = PolicyConfigStatus.getStatus(configStatus); - - // 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 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; - - String result = fixture.toString(); - - // add additional test code here - assertEquals("not_found", 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(PolicyConfigStatusTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTest.java deleted file mode 100644 index c6247fcdf..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.After; -import org.junit.Before; -import org.openecomp.policy.api.PolicyConfig; - -/** - * The class PolicyConfigTest contains tests for the class {@link PolicyConfig}. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - * @version $Revision: 1.0 $ - */ -public class PolicyConfigTest { - /** - * 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(PolicyConfigTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTypeTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTypeTest.java deleted file mode 100644 index cd6c6a977..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTypeTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.*; -import org.openecomp.policy.api.PolicyConfigType; - -import static org.junit.Assert.*; - -/** - * The class PolicyConfigTypeTest contains tests for the class {@link PolicyConfigType}. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - * @version $Revision: 1.0 $ - */ -public class PolicyConfigTypeTest { - /** - * Run the String toString() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testToString_1() - throws Exception { - PolicyConfigType fixture = PolicyConfigType.BRMS_PARAM; - - String result = fixture.toString(); - - // add additional test code here - assertEquals("BRMS_Param", 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(PolicyConfigTypeTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyDecisionExceptionTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyDecisionExceptionTest.java deleted file mode 100644 index 95dfd7acd..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyDecisionExceptionTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.*; -import org.openecomp.policy.api.PolicyDecisionException; - -import static org.junit.Assert.*; - -/** - * The class PolicyDecisionExceptionTest contains tests for the class {@link PolicyDecisionException}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class PolicyDecisionExceptionTest { - /** - * Run the PolicyDecisionException() constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPolicyDecisionException_1() - throws Exception { - - PolicyDecisionException result = new PolicyDecisionException(); - - // add additional test code here - assertNotNull(result); - assertEquals(null, result.getCause()); - assertEquals("org.openecomp.policy.api.PolicyDecisionException", result.toString()); - assertEquals(null, result.getLocalizedMessage()); - assertEquals(null, result.getMessage()); - } - - /** - * Run the PolicyDecisionException(String) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPolicyDecisionException_2() - throws Exception { - String message = ""; - - PolicyDecisionException result = new PolicyDecisionException(message); - - // add additional test code here - assertNotNull(result); - assertEquals(null, result.getCause()); - assertEquals("org.openecomp.policy.api.PolicyDecisionException: ", result.toString()); - assertEquals("", result.getLocalizedMessage()); - assertEquals("", result.getMessage()); - } - - /** - * Run the PolicyDecisionException(Throwable) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPolicyDecisionException_3() - throws Exception { - Throwable cause = new Throwable(); - - PolicyDecisionException result = new PolicyDecisionException(cause); - - // add additional test code here - assertNotNull(result); - assertEquals("org.openecomp.policy.api.PolicyDecisionException: java.lang.Throwable", result.toString()); - assertEquals("java.lang.Throwable", result.getLocalizedMessage()); - assertEquals("java.lang.Throwable", result.getMessage()); - } - - /** - * Run the PolicyDecisionException(String,Throwable) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPolicyDecisionException_4() - throws Exception { - String message = ""; - Throwable cause = new Throwable(); - - PolicyDecisionException result = new PolicyDecisionException(message, cause); - - // add additional test code here - assertNotNull(result); - assertEquals("org.openecomp.policy.api.PolicyDecisionException: ", result.toString()); - assertEquals("", result.getLocalizedMessage()); - assertEquals("", result.getMessage()); - } - - /** - * Run the PolicyDecisionException(String,Throwable,boolean,boolean) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPolicyDecisionException_5() - throws Exception { - String message = ""; - Throwable cause = new Throwable(); - boolean enableSuppression = true; - boolean writableStackTrace = true; - - PolicyDecisionException result = new PolicyDecisionException(message, cause, enableSuppression, writableStackTrace); - - // add additional test code here - assertNotNull(result); - assertEquals("org.openecomp.policy.api.PolicyDecisionException: ", result.toString()); - assertEquals("", result.getLocalizedMessage()); - assertEquals("", result.getMessage()); - } - - /** - * 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(PolicyDecisionExceptionTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyDecisionTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyDecisionTest.java deleted file mode 100644 index 12069abeb..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyDecisionTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.*; -import org.openecomp.policy.api.PolicyDecision; - -import static org.junit.Assert.*; - -/** - * The class PolicyDecisionTest contains tests for the class {@link PolicyDecision}. - * - * @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); - } - - /** - * 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(PolicyDecisionTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineExceptionTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineExceptionTest.java deleted file mode 100644 index d21fb12e2..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineExceptionTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.*; -import org.openecomp.policy.api.PolicyEngineException; - -import static org.junit.Assert.*; - -/** - * The class PolicyEngineExceptionTest contains tests for the class {@link PolicyEngineException}. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - * @version $Revision: 1.0 $ - */ -public class PolicyEngineExceptionTest { - /** - * Run the PolicyEngineException() constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testPolicyEngineException_1() - throws Exception { - - PolicyEngineException result = new PolicyEngineException(); - - // add additional test code here - assertNotNull(result); - assertEquals(null, result.getCause()); - assertEquals("org.openecomp.policy.api.PolicyEngineException", result.toString()); - assertEquals(null, result.getLocalizedMessage()); - assertEquals(null, result.getMessage()); - } - - /** - * Run the PolicyEngineException(String) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testPolicyEngineException_2() - throws Exception { - String message = ""; - - PolicyEngineException result = new PolicyEngineException(message); - - // add additional test code here - assertNotNull(result); - assertEquals(null, result.getCause()); - assertEquals("org.openecomp.policy.api.PolicyEngineException: ", result.toString()); - assertEquals("", result.getLocalizedMessage()); - assertEquals("", result.getMessage()); - } - - /** - * Run the PolicyEngineException(Throwable) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testPolicyEngineException_3() - throws Exception { - Throwable cause = new Throwable(); - - PolicyEngineException result = new PolicyEngineException(cause); - - // add additional test code here - assertNotNull(result); - assertEquals("org.openecomp.policy.api.PolicyEngineException: java.lang.Throwable", result.toString()); - assertEquals("java.lang.Throwable", result.getLocalizedMessage()); - assertEquals("java.lang.Throwable", result.getMessage()); - } - - /** - * Run the PolicyEngineException(String,Throwable) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testPolicyEngineException_4() - throws Exception { - String message = ""; - Throwable cause = new Throwable(); - - PolicyEngineException result = new PolicyEngineException(message, cause); - - // add additional test code here - assertNotNull(result); - assertEquals("org.openecomp.policy.api.PolicyEngineException: ", result.toString()); - assertEquals("", result.getLocalizedMessage()); - assertEquals("", result.getMessage()); - } - - /** - * Run the PolicyEngineException(String,Throwable,boolean,boolean) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testPolicyEngineException_5() - throws Exception { - String message = ""; - Throwable cause = new Throwable(); - boolean enableSuppression = true; - boolean writableStackTrace = true; - - PolicyEngineException result = new PolicyEngineException(message, cause, enableSuppression, writableStackTrace); - - // add additional test code here - assertNotNull(result); - assertEquals("org.openecomp.policy.api.PolicyEngineException: ", result.toString()); - assertEquals("", result.getLocalizedMessage()); - assertEquals("", result.getMessage()); - } - - /** - * 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(PolicyEngineExceptionTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineInterfaceTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineInterfaceTest.java deleted file mode 100644 index fd5f65fa3..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineInterfaceTest.java +++ /dev/null @@ -1,670 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import java.io.StringReader; -import java.net.HttpURLConnection; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import javax.json.Json; -import javax.json.JsonObject; -import javax.json.JsonReader; - -import org.mockito.Mockito; -import org.openecomp.policy.api.AttributeType; -import org.openecomp.policy.api.ConfigRequestParameters; -import org.openecomp.policy.api.DecisionRequestParameters; -import org.openecomp.policy.api.DecisionResponse; -import org.openecomp.policy.api.DeletePolicyCondition; -import org.openecomp.policy.api.DeletePolicyParameters; -import org.openecomp.policy.api.EventRequestParameters; -import org.openecomp.policy.api.ImportParameters; -import org.openecomp.policy.api.ImportParameters.IMPORT_TYPE; -import org.openecomp.policy.api.NotificationHandler; -import org.openecomp.policy.api.NotificationScheme; -import org.openecomp.policy.api.PDPNotification; -import org.openecomp.policy.api.PolicyChangeResponse; -import org.openecomp.policy.api.PolicyClass; -import org.openecomp.policy.api.PolicyConfig; -import org.openecomp.policy.api.PolicyConfigException; -import org.openecomp.policy.api.PolicyDecisionException; -import org.openecomp.policy.api.PolicyEngine; -import org.openecomp.policy.api.PolicyEngineException; -import org.openecomp.policy.api.PolicyEventException; -import org.openecomp.policy.api.PolicyParameters; -import org.openecomp.policy.api.PolicyResponse; -import org.openecomp.policy.api.PushPolicyParameters; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; -import org.openecomp.policy.std.StdPDPNotification; -import org.openecomp.policy.std.StdPolicyChangeResponse; -import org.openecomp.policy.std.StdPolicyResponse; - -import junit.framework.TestCase; - -/** - * The class PolicyEngineInterfaceTest contains tests for the - * class {@link PolicyEngine} - * - * @pattern JUnit Test Case - * - * @generatedBy CodePro at 5/27/16 10:33 AM - * - * - * @version $Revision$ - */ -public class PolicyEngineInterfaceTest extends TestCase { - - private static final Logger logger = FlexLogger.getLogger(PolicyEngineInterfaceTest.class); - - private PolicyEngine policyEngine = null; - private PolicyEngine mockPolicyEngine = null; - private Collection policyConfig = null; - private UUID requestID = UUID.randomUUID(); - - - PolicyChangeResponse result = null; - StdPolicyChangeResponse response = new StdPolicyChangeResponse(); - - - /** - * Construct new test instance - * - * @param name the test name - */ - public PolicyEngineInterfaceTest(String name) { - super(name); - } - - /** - * Perform pre-test initialization - * - * @throws Exception - * - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - try { - policyEngine = new PolicyEngine("Test/config_pass.properties"); - } catch (PolicyEngineException e) { - logger.error(e.getMessage()); - fail("PolicyEngine Instantiation Error" + e); - } - logger.info("Loaded.. PolicyEngine"); - - mockPolicyEngine = Mockito.mock(PolicyEngine.class); - HttpURLConnection conn = Mockito.mock(HttpURLConnection.class); - Mockito.when(conn.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK); - - } - - /** - * Perform post-test clean up - * - * @throws Exception - * - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - // Add additional tear down code here - } - - /** - * Run the Collection getConfigByPolicyName(String) method - * test - */ - @SuppressWarnings("deprecation") - public void testGetConfigByPolicyName() { - String policyName = null; - try{ - policyConfig = policyEngine.getConfigByPolicyName(policyName); - } catch (PolicyConfigException e){ - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - @SuppressWarnings("deprecation") - public void testGetConfigByPolicyName2() { - String policyName = null; - - try{ - policyConfig = policyEngine.getConfigByPolicyName(policyName, requestID); - } catch (PolicyConfigException e){ - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - /** - * Run the Collection getConfig(String) method test - */ - @SuppressWarnings("deprecation") - public void testGetConfig() { - String ecompName = null; - - try{ - policyConfig = policyEngine.getConfig(ecompName); - } catch (PolicyConfigException e){ - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - @SuppressWarnings("deprecation") - public void testGetConfig2() { - String ecompName = null; - - try{ - policyConfig = policyEngine.getConfig(ecompName,requestID); - } catch (PolicyConfigException e){ - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - - @SuppressWarnings("deprecation") - public void testGetConfig3() { - String ecompName = null; - String configName = null; - - try{ - policyConfig = policyEngine.getConfig(ecompName,configName,requestID); - } catch (PolicyConfigException e){ - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - @SuppressWarnings("deprecation") - public void testGetConfig4() { - String ecompName = null; - String configName = null; - Map configAttributes = null; - - try{ - policyConfig = policyEngine.getConfig(ecompName,configName,configAttributes); - } catch (PolicyConfigException e){ - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - @SuppressWarnings("deprecation") - public void testGetConfig5() { - String ecompName = null; - String configName = null; - Map configAttributes = null; - - try{ - policyConfig = policyEngine.getConfig(ecompName,configName,configAttributes,requestID); - } catch (PolicyConfigException e){ - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - public void testGetConfig6() { - ConfigRequestParameters parameters = new ConfigRequestParameters(); - - try{ - policyConfig = policyEngine.getConfig(parameters); - } catch (PolicyConfigException e){ - logger.warn(e.getMessage()); - } - assertNull(policyConfig); - } - - - /** - * Run the Collection sendEvent(Map) method - * test - */ - @SuppressWarnings("deprecation") - public void testSendEvent() - { - Collection result = null; - Collection response = null; - Map eventAttributes = null; - - try { - Mockito.when(mockPolicyEngine.sendEvent(eventAttributes)).thenReturn(result); - result = mockPolicyEngine.sendEvent(eventAttributes); - } catch (PolicyEventException e) { - logger.error("Exception Occured"+e); - } - - - assertEquals(result,response); - - } - - @SuppressWarnings("deprecation") - public void testSendEvent2() - { - Collection result = null; - Collection response = null; - Map eventAttributes = null; - - try { - Mockito.when(mockPolicyEngine.sendEvent(eventAttributes,requestID)).thenReturn(result); - result = mockPolicyEngine.sendEvent(eventAttributes,requestID); - } catch (PolicyEventException e) { - logger.error("Exception Occured"+e); - } - - - assertEquals(result,response); - - } - - public void testSendEvent3() - { - Collection result = null; - Collection response = null; - EventRequestParameters parameters = new EventRequestParameters(); - - try { - Mockito.when(mockPolicyEngine.sendEvent(parameters)).thenReturn(result); - result = mockPolicyEngine.sendEvent(parameters); - } catch (PolicyEventException e) { - logger.error("Exception Occured"+e); - } - - assertEquals(result,response); - - } - - - - /** - * Run the PolicyDecision getDecision(String, Map) method - * test - */ - @SuppressWarnings("deprecation") - public void testGetDecision() - { - String eCOMPComponentName = null; - Map decisionAttributes = null; - - DecisionResponse result = null; - - try { - Mockito.when(mockPolicyEngine.getDecision(eCOMPComponentName,decisionAttributes)).thenReturn(null); - result = mockPolicyEngine.getDecision(eCOMPComponentName,decisionAttributes); - } catch (PolicyDecisionException e) { - logger.error("Exception Occured"+e); - } - - assertEquals(result,null); - } - - @SuppressWarnings("deprecation") - public void testGetDecision2() - { - String eCOMPComponentName = null; - Map decisionAttributes = null; - - DecisionResponse result = null; - - try { - Mockito.when(mockPolicyEngine.getDecision(eCOMPComponentName,decisionAttributes,requestID)).thenReturn(null); - result = mockPolicyEngine.getDecision(eCOMPComponentName,decisionAttributes); - } catch (PolicyDecisionException e) { - logger.error("Exception Occured"+e); - } - - assertEquals(result,null); - } - - public void testGetDecision3() - { - DecisionRequestParameters parameters = new DecisionRequestParameters(); - DecisionResponse result = null; - - try { - Mockito.when(mockPolicyEngine.getDecision(parameters)).thenReturn(null); - result = mockPolicyEngine.getDecision(parameters); - } catch (PolicyDecisionException e) { - logger.error("Exception Occured"+e); - } - - assertEquals(result,null); - } - - /** - * Run the void setNotification(NotificationScheme, NotificationHandler) - * method test - */ - public void testSetNotification() { - // add test code here - - NotificationScheme scheme = null; - NotificationHandler handler = null; - - Mockito.doNothing().when(mockPolicyEngine).setNotification(scheme, handler); - mockPolicyEngine.setNotification(scheme, handler); - //assertTrue(true); - } - - /** - * Run the void clearNotification() method test - */ - public void testClearNotification() { - // add test code here - - Mockito.doNothing().when(mockPolicyEngine).clearNotification(); - mockPolicyEngine.clearNotification(); - //assertTrue(true); - } - - /** - * Run the void setScheme(NotificationScheme) method test - */ - public void testSetScheme() { - NotificationScheme scheme = null; - - Mockito.doNothing().when(mockPolicyEngine).setScheme(scheme); - mockPolicyEngine.setScheme(scheme); - //assertTrue(true); - } - - /** - * Run the PDPNotification getNotification() method test - */ - public void testGetNotification() { - PDPNotification result = null; - StdPDPNotification response = null; - Mockito.when(mockPolicyEngine.getNotification()).thenReturn(response); - result = mockPolicyEngine.getNotification(); - - assertEquals(result,response); - } - - /** - * Run the String createConfigPolicy(String, String, String, String, - * Map, String, String, String, UUID) method test - */ - @SuppressWarnings("deprecation") - public void testCreateConfigPolicy() - { - String response = "success"; - String result = null; - try { - - Mockito.when(mockPolicyEngine.createConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null)).thenReturn(response); - result = mockPolicyEngine.createConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - /** - * Run the String updateConfigPolicy(String, String, String, String, - * Map, String, String, String, UUID) method test - */ - @SuppressWarnings("deprecation") - public void testUpdateConfigPolicy() - { - String response = "success"; - String result = null; - try { - - Mockito.when(mockPolicyEngine.updateConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null)).thenReturn(response); - result = mockPolicyEngine.updateConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - /** - * Run the String createConfigFirewallPolicy(String, JsonObject, String, - * UUID) method test - */ - @SuppressWarnings("deprecation") - public void testCreateConfigFirewallPolicy() { - String response = "success"; - String result = null; - String json = "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"rule1607\",\"deploymentOption\":{\"deployNow\":false},\"securityZoneId\":\"/v0/firewall/pan\",\"serviceGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"REFERENCE\",\"name\":\"SList\"},{\"type\":\"REFERENCE\",\"name\":\"Syslog\"}]},{\"name\":\"Syslog\",\"description\":\"NA\",\"type\":\"SERVICE\",\"transportProtocol\":\"udp\",\"appProtocol\":null,\"ports\":\"514\"},{\"name\":\"SList\",\"description\":\"Service List\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\",\"appProtocol\":null,\"ports\":\"8080\"}],\"addressGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"},{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]},{\"name\":\"PL_CCE3\",\"description\":\"CCE Routers\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]}],\"firewallRuleList\":[{\"position\":\"1\",\"ruleName\":\"1607Rule\",\"fromZones\":[\"Trusted\"],\"toZones\":[\"Untrusted\"],\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\",\"value\":\"PL_CCE3\"},{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"destinationList\":[{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"1607Group\"}],\"action\":\"accept\",\"description\":\"Rule for 1607 templates\",\"enabled\":true,\"log\":true}]}"; - JsonObject jsonObj = buildJSON(json); - try { - - Mockito.when(mockPolicyEngine.createConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null)).thenReturn(response); - result = mockPolicyEngine.createConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - /** - * Run the String updateConfigFirewallPolicy(String, JsonObject, String, - * UUID) method test - */ - @SuppressWarnings("deprecation") - public void testUpdateConfigFirewallPolicy() { - String response = "success"; - String result = null; - String json = "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"rule1607\",\"deploymentOption\":{\"deployNow\":false},\"securityZoneId\":\"/v0/firewall/pan\",\"serviceGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"REFERENCE\",\"name\":\"SList\"},{\"type\":\"REFERENCE\",\"name\":\"Syslog\"}]},{\"name\":\"Syslog\",\"description\":\"NA\",\"type\":\"SERVICE\",\"transportProtocol\":\"udp\",\"appProtocol\":null,\"ports\":\"514\"},{\"name\":\"SList\",\"description\":\"Service List\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\",\"appProtocol\":null,\"ports\":\"8080\"}],\"addressGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"},{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]},{\"name\":\"PL_CCE3\",\"description\":\"CCE Routers\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]}],\"firewallRuleList\":[{\"position\":\"1\",\"ruleName\":\"1607Rule\",\"fromZones\":[\"Trusted\"],\"toZones\":[\"Untrusted\"],\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\",\"value\":\"PL_CCE3\"},{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"destinationList\":[{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"1607Group\"}],\"action\":\"accept\",\"description\":\"Rule for 1607 templates\",\"enabled\":true,\"log\":true}]}"; - JsonObject jsonObj = buildJSON(json); - try { - - Mockito.when(mockPolicyEngine.updateConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null)).thenReturn(response); - result = mockPolicyEngine.updateConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - /** - * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test - */ - public void testCreatePolicy() { - response.setResponseMessage("success"); - PolicyChangeResponse result = null; - PolicyParameters policyParameters = new PolicyParameters(); - - policyParameters.setPolicyClass(PolicyClass.Action); //required - policyParameters.setPolicyName("test.junitTest"); //required - policyParameters.setPolicyDescription("testing"); //optional - - //Set the Component Attributes... These are Optional - Map configAttributes = new HashMap(); - configAttributes.put("test", "testing"); - - Map> attributes = new HashMap>(); - attributes.put(AttributeType.MATCHING, configAttributes); - policyParameters.setAttributes(attributes); - - policyParameters.setActionPerformer("PEP"); - policyParameters.setActionAttribute("testing"); - policyParameters.setRequestID(UUID.randomUUID()); - - try { - - //stdPolicyEngine = Mockito.mock(StdPolicyEngine.class); - //Mockito.when(stdPolicyEngine.callPAP(newPAPPolicy, new String[] {"operation=create", "apiflag=api", "policyType=Action"}, null, "Action")).thenReturn(callPapResponse); - Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response); - result = mockPolicyEngine.createPolicy(policyParameters); - - } catch (Exception e) { - logger.warn(e.getMessage()); - logger.error("Exception Occured"+e); - } - assertEquals(result, response); - } - - /** - * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test - */ - public void testUpdatePolicy() { - response.setResponseMessage("success"); - PolicyChangeResponse result = null; - PolicyParameters policyParameters = new PolicyParameters(); - - policyParameters.setPolicyClass(PolicyClass.Action); //required - policyParameters.setPolicyName("test.junitTest"); //required - policyParameters.setPolicyDescription("testing"); //optional - - //Set the Component Attributes... These are Optional - Map configAttributes = new HashMap(); - configAttributes.put("test", "testing"); - - Map> attributes = new HashMap>(); - attributes.put(AttributeType.MATCHING, configAttributes); - policyParameters.setAttributes(attributes); - - policyParameters.setActionPerformer("PEP"); - policyParameters.setActionAttribute("testing"); - policyParameters.setRequestID(UUID.randomUUID()); - - try { - - Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response); - result = mockPolicyEngine.updatePolicy(policyParameters); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - assertEquals(result, response); - } - - /** - * Run the String pushPolicy(String, String, String, String, UUID) method - * test - */ - @SuppressWarnings("deprecation") - public void testPushPolicy() { - String response = "Success"; - String result = null; - try { - - Mockito.when(mockPolicyEngine.pushPolicy("testing","test","Base","default",requestID)).thenReturn(response); - result = mockPolicyEngine.pushPolicy("testing","test","Base","default",requestID); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - - assertEquals(result, response); - } - - public void testPushPolicy2() { - PushPolicyParameters policyParameters = new PushPolicyParameters(); - PolicyChangeResponse result = null; - - //String policyScope = null; - policyParameters.setPolicyName("test.junitTest"); - policyParameters.setPolicyType("Action"); - policyParameters.setPdpGroup("Default"); - - try { - - Mockito.when(mockPolicyEngine.pushPolicy(policyParameters)).thenReturn(response); - result = mockPolicyEngine.pushPolicy(policyParameters); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - - assertEquals(result, response); - } - - /** - * Run the PolicyChangeResponse deletePolicy(DeletePolicyParameters) method - * test - */ - public void testDeletePolicy() { - DeletePolicyParameters policyParameters = new DeletePolicyParameters(); - PolicyChangeResponse result = null; - - //String policyScope = null; - policyParameters.setPolicyName("test.junitTest.1.xml"); - policyParameters.setDeleteCondition(DeletePolicyCondition.ALL); - policyParameters.setPolicyComponent("PAP"); - policyParameters.setPdpGroup("Default"); - - try { - - Mockito.when(mockPolicyEngine.deletePolicy(policyParameters)).thenReturn(response); - result = mockPolicyEngine.deletePolicy(policyParameters); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - - assertEquals(result, response); - } - - /** - * Run the PolicyChangeResponse policyEngineImport(ImportParameters) method - * test - */ - public void testPolicyEngineImport() { - ImportParameters importParameters = new ImportParameters(); - PolicyChangeResponse result = null; - - importParameters.setFilePath("C:\\Workspaces\\models\\TestingModel\\ControllerServiceSampleSdnlServiceInstance-v0.1.0-SNAPSHOT.zip"); - importParameters.setServiceName("ControllerServiceSampleSdnlServiceInstance"); - - importParameters.setRequestID(UUID.randomUUID()); - importParameters.setServiceType(IMPORT_TYPE.MICROSERVICE); - importParameters.setVersion("1607-2"); - - - try { - - Mockito.when(mockPolicyEngine.policyEngineImport(importParameters)).thenReturn(response); - result = mockPolicyEngine.policyEngineImport(importParameters); - - } catch (Exception e) { - logger.warn(e.getMessage()); - } - - assertEquals(result, response); - } - - private static JsonObject buildJSON(String jsonString) { - JsonObject json = null;; - if (jsonString != null) { - StringReader in = null; - - in = new StringReader(jsonString); - - JsonReader jsonReader = Json.createReader(in); - json = jsonReader.readObject(); - } - - return json; - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineTest.java deleted file mode 100644 index c36a921d4..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineTest.java +++ /dev/null @@ -1,170 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.junit.Test; -import org.openecomp.policy.api.NotificationScheme; -import org.openecomp.policy.api.PolicyEngine; -import org.openecomp.policy.api.PolicyEngineException; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; - -public class PolicyEngineTest { - - private static final Logger logger = FlexLogger.getLogger(PolicyEngineTest.class); - private PolicyEngine policyEngine = null; - private String filePath = null; - - @Test - public void testPolicyEngineForFail() { - filePath = null; - try { - policyEngine = new PolicyEngine(filePath); - } catch (PolicyEngineException e) { - logger.warn(e.getMessage()); - } - assertNull(policyEngine); - // Test even for this case. - filePath = "NotNull"; - try { - policyEngine = new PolicyEngine(filePath); - } catch (PolicyEngineException e) { - logger.warn(e.getMessage()); - } - assertNull(policyEngine); - } - - @Test - public void testPolicyEngineforPropertyFileError() { - filePath = "Test/config_error.property"; - isFileAvailable(filePath); - try { - policyEngine = new PolicyEngine(filePath); - } catch (PolicyEngineException e) { - logger.warn(e.getMessage()); - } - assertNull(policyEngine); - } - - @Test - public void testPolicyEngineforPDPURLError() { - String filePath = "Test/config_fail.properties"; - isFileAvailable(filePath); - try { - policyEngine = new PolicyEngine(filePath); - } catch (PolicyEngineException e) { - logger.warn(e.getMessage()); - } - assertNull(policyEngine); - } - - @Test - public void testPolicyEngineForPass() { - String filePath = "Test/config_pass.properties"; - isFileAvailable(filePath); - try { - policyEngine = new PolicyEngine(filePath); - } catch (PolicyEngineException e) { - logger.warn(e.getMessage()); - } - assertNotNull(policyEngine); - } - - @Test - public void testPolicyEngineForUEBPass() { - String filePath = "Test/config_UEB_pass.properties"; - isFileAvailable(filePath); - try { - policyEngine = new PolicyEngine(filePath); - } catch (PolicyEngineException e) { - logger.warn(e.getMessage()); - } - assertNotNull(policyEngine); - } - - - @Test - public void testPolicyEngineForUEBBadType() { - String filePath = "Test/config_UEB_bad_type.properties"; - isFileAvailable(filePath); - try { - policyEngine = new PolicyEngine(filePath); - } catch (PolicyEngineException e) { - logger.warn(e.getMessage()); - } - assertNotNull(policyEngine); - } - - @Test - public void testPolicyEngineForUEBBadServerType() { - String filePath = "Test/config_UEB_badservers.properties"; - isFileAvailable(filePath); - try { - policyEngine = new PolicyEngine(filePath); - } catch (PolicyEngineException e) { - logger.warn(e.getMessage()); - } - assertNotNull(policyEngine); - } - - @Test - public void testPolicyEngineNotficationAutoUEB() { - String filePath = "Test/config_UEB_pass.properties"; - isFileAvailable(filePath); - try { - policyEngine = new PolicyEngine(filePath); - policyEngine.setScheme(NotificationScheme.AUTO_ALL_NOTIFICATIONS); - } catch (PolicyEngineException e) { - logger.warn(e.getMessage()); - } - assertNotNull(policyEngine); - } - - @Test - public void testPolicyEngineNotficationAuto() { - String filePath = "Test/config_pass.properties"; - isFileAvailable(filePath); - try { - policyEngine = new PolicyEngine(filePath); - policyEngine.setScheme(NotificationScheme.AUTO_ALL_NOTIFICATIONS); - //policyEngine.getNotification(); - } catch (PolicyEngineException e) { - logger.warn(e.getMessage()); - } - assertNotNull(policyEngine); - } - - public void isFileAvailable(String filePath) { - Path file = Paths.get(filePath); - if (Files.notExists(file)) { - logger.error("File Doesn't Exist "+ file.toString()); - fail("File: " +filePath + " Not found"); - } - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEventExceptionTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEventExceptionTest.java deleted file mode 100644 index fa8d5d1d8..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEventExceptionTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.*; -import org.openecomp.policy.api.PolicyEventException; - -import static org.junit.Assert.*; - -/** - * The class PolicyEventExceptionTest contains tests for the class {@link PolicyEventException}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class PolicyEventExceptionTest { - /** - * Run the PolicyEventException() constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPolicyEventException_1() - throws Exception { - - PolicyEventException result = new PolicyEventException(); - - // add additional test code here - assertNotNull(result); - assertEquals(null, result.getCause()); - assertEquals("org.openecomp.policy.api.PolicyEventException", result.toString()); - assertEquals(null, result.getLocalizedMessage()); - assertEquals(null, result.getMessage()); - } - - /** - * Run the PolicyEventException(String) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPolicyEventException_2() - throws Exception { - String message = ""; - - PolicyEventException result = new PolicyEventException(message); - - // add additional test code here - assertNotNull(result); - assertEquals(null, result.getCause()); - assertEquals("org.openecomp.policy.api.PolicyEventException: ", result.toString()); - assertEquals("", result.getLocalizedMessage()); - assertEquals("", result.getMessage()); - } - - /** - * Run the PolicyEventException(Throwable) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPolicyEventException_3() - throws Exception { - Throwable cause = new Throwable(); - - PolicyEventException result = new PolicyEventException(cause); - - // add additional test code here - assertNotNull(result); - assertEquals("org.openecomp.policy.api.PolicyEventException: java.lang.Throwable", result.toString()); - assertEquals("java.lang.Throwable", result.getLocalizedMessage()); - assertEquals("java.lang.Throwable", result.getMessage()); - } - - /** - * Run the PolicyEventException(String,Throwable) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPolicyEventException_4() - throws Exception { - String message = ""; - Throwable cause = new Throwable(); - - PolicyEventException result = new PolicyEventException(message, cause); - - // add additional test code here - assertNotNull(result); - assertEquals("org.openecomp.policy.api.PolicyEventException: ", result.toString()); - assertEquals("", result.getLocalizedMessage()); - assertEquals("", result.getMessage()); - } - - /** - * Run the PolicyEventException(String,Throwable,boolean,boolean) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPolicyEventException_5() - throws Exception { - String message = ""; - Throwable cause = new Throwable(); - boolean enableSuppression = true; - boolean writableStackTrace = true; - - PolicyEventException result = new PolicyEventException(message, cause, enableSuppression, writableStackTrace); - - // add additional test code here - assertNotNull(result); - assertEquals("org.openecomp.policy.api.PolicyEventException: ", result.toString()); - assertEquals("", result.getLocalizedMessage()); - assertEquals("", result.getMessage()); - } - - /** - * 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(PolicyEventExceptionTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyParametersTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyParametersTest.java deleted file mode 100644 index eeb973b90..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyParametersTest.java +++ /dev/null @@ -1,1409 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.Hashtable; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openecomp.policy.api.AttributeType; -import org.openecomp.policy.api.PolicyClass; -import org.openecomp.policy.api.PolicyConfigType; -import org.openecomp.policy.api.PolicyParameters; -import org.openecomp.policy.api.PolicyType; - -/** - * The class PolicyParametersTest contains tests for the class {@link PolicyParameters}. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - * @version $Revision: 1.0 $ - */ -public class PolicyParametersTest { - /** - * Run the String getActionAttribute() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetActionAttribute_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - String result = fixture.getActionAttribute(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the String getActionPerformer() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetActionPerformer_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - String result = fixture.getActionPerformer(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the Map> getAttributes() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetAttributes_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - Map> result = fixture.getAttributes(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the String getConfigBody() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetConfigBody_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - String result = fixture.getConfigBody(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the PolicyType getConfigBodyType() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetConfigBodyType_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - PolicyType result = fixture.getConfigBodyType(); - - // add additional test code here - assertNotNull(result); - assertEquals("json", result.toString()); - assertEquals("JSON", result.name()); - assertEquals(1, result.ordinal()); - } - - /** - * Run the String getConfigName() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetConfigName_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - String result = fixture.getConfigName(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the List getDynamicRuleAlgorithmField1() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetDynamicRuleAlgorithmField1_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - List result = fixture.getDynamicRuleAlgorithmField1(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the List getDynamicRuleAlgorithmField2() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetDynamicRuleAlgorithmField2_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - List result = fixture.getDynamicRuleAlgorithmField2(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the List getDynamicRuleAlgorithmFunctions() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetDynamicRuleAlgorithmFunctions_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - List result = fixture.getDynamicRuleAlgorithmFunctions(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the List getDynamicRuleAlgorithmLabels() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetDynamicRuleAlgorithmLabels_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - List result = fixture.getDynamicRuleAlgorithmLabels(); - - // add additional test code here - assertNotNull(result); - assertEquals(0, result.size()); - } - - /** - * Run the String getEcompName() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetEcompName_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - String result = fixture.getEcompName(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the PolicyClass getPolicyClass() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetPolicyClass_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - PolicyClass result = fixture.getPolicyClass(); - - // add additional test code here - assertNotNull(result); - assertEquals("Action", result.toString()); - assertEquals("Action", result.name()); - assertEquals(1, result.ordinal()); - } - - /** - * Run the PolicyConfigType getPolicyConfigType() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetPolicyConfigType_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - PolicyConfigType result = (PolicyConfigType) fixture.getPolicyConfigType(); - - // add additional test code here - assertNotNull(result); - assertEquals("BRMS_Param", result.toString()); - assertEquals("BRMS_PARAM", result.name()); - assertEquals(5, result.ordinal()); - } - - /** - * Run the String getPolicyDescription() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetPolicyDescription_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - String result = fixture.getPolicyDescription(); - - // 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_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - String result = fixture.getPolicyName(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the String getPriority() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetPriority_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - String result = fixture.getPriority(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the UUID getRequestID() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testGetRequestID_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.fromString("878d319c-2799-4684-b480-99f40e1042b2")); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - - UUID result = fixture.getRequestID(); - - // add additional test code here - assertNotNull(result); - assertEquals("878d319c-2799-4684-b480-99f40e1042b2", result.toString()); - assertEquals(4, result.version()); - assertEquals(2, result.variant()); - assertEquals(-5440179076376542542L, result.getLeastSignificantBits()); - assertEquals(-8679226360124062076L, result.getMostSignificantBits()); - } - - /** - * Run the void setActionAttribute(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetActionAttribute_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - String actionAttribute = ""; - - fixture.setActionAttribute(actionAttribute); - - // add additional test code here - } - - /** - * Run the void setActionPerformer(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetActionPerformer_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - String actionPerformer = ""; - - fixture.setActionPerformer(actionPerformer); - - // add additional test code here - } - - /** - * Run the void setAttributes(Map>) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetAttributes_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - Map> attributes = new Hashtable>(); - - fixture.setAttributes(attributes); - - // add additional test code here - } - - /** - * Run the void setConfigBody(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetConfigBody_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - String configBody = ""; - - fixture.setConfigBody(configBody); - - // add additional test code here - } - - /** - * Run the void setConfigBodyType(PolicyType) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetConfigBodyType_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - PolicyType configBodyType = PolicyType.JSON; - - fixture.setConfigBodyType(configBodyType); - - // add additional test code here - } - - /** - * Run the void setConfigFirewallPolicyParameters(String,String,UUID) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetConfigFirewallPolicyParameters_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - String policyName = ""; - String firewallJson = ""; - UUID requestID = UUID.randomUUID(); - - fixture.setConfigFirewallPolicyParameters(policyName, firewallJson, requestID); - - // 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 { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - String configName = ""; - - fixture.setConfigName(configName); - - // add additional test code here - } - - /** - * Run the void setConfigPolicyParameters(PolicyConfigType,String,String,String,String,Map>,PolicyType,String,UUID) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetConfigPolicyParameters_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - PolicyConfigType policyConfigType = PolicyConfigType.BRMS_PARAM; - String policyName = ""; - String policyDescription = ""; - String ecompName = ""; - String configName = ""; - Map> attributes = new Hashtable>(); - PolicyType configBodyType = PolicyType.JSON; - String configBody = ""; - UUID requestID = UUID.randomUUID(); - - fixture.setConfigPolicyParameters(policyConfigType, policyName, policyDescription, ecompName, configName, attributes, configBodyType, configBody, requestID); - - // add additional test code here - } - - /** - * Run the void setDynamicRuleAlgorithmField1(List) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetDynamicRuleAlgorithmField1_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - List dynamicRuleAlgorithmField1 = new LinkedList(); - - fixture.setDynamicRuleAlgorithmField1(dynamicRuleAlgorithmField1); - - // add additional test code here - } - - /** - * Run the void setDynamicRuleAlgorithmField2(List) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetDynamicRuleAlgorithmField2_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - List dynamicRuleAlgorithmField2 = new LinkedList(); - - fixture.setDynamicRuleAlgorithmField2(dynamicRuleAlgorithmField2); - - // add additional test code here - } - - /** - * Run the void setDynamicRuleAlgorithmFunctions(List) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetDynamicRuleAlgorithmFunctions_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - List dynamicRuleAlgorithmFunctions = new LinkedList(); - - fixture.setDynamicRuleAlgorithmFunctions(dynamicRuleAlgorithmFunctions); - - // add additional test code here - } - - /** - * Run the void setDynamicRuleAlgorithmLabels(List) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetDynamicRuleAlgorithmLabels_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - List dynamicRuleAlgorithmLabels = new LinkedList(); - - fixture.setDynamicRuleAlgorithmLabels(dynamicRuleAlgorithmLabels); - - // add additional test code here - } - - /** - * Run the void setEcompName(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetEcompName_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - String ecompName = ""; - - fixture.setEcompName(ecompName); - - // add additional test code here - } - - /** - * Run the void setPolicyClass(PolicyClass) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetPolicyClass_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - PolicyClass policyClass = PolicyClass.Action; - - fixture.setPolicyClass(policyClass); - - // add additional test code here - } - - /** - * Run the void setPolicyConfigType(PolicyConfigType) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetPolicyConfigType_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - PolicyConfigType policyConfigType = PolicyConfigType.BRMS_PARAM; - - fixture.setPolicyConfigType(policyConfigType); - - // add additional test code here - } - - /** - * Run the void setPolicyDescription(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetPolicyDescription_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - String policyDescription = ""; - - fixture.setPolicyDescription(policyDescription); - - // 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 { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - String policyName = ""; - - fixture.setPolicyName(policyName); - - // add additional test code here - } - - /** - * Run the void setPriority(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetPriority_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - String priority = ""; - - fixture.setPriority(priority); - - // add additional test code here - } - - /** - * Run the void setRequestID(UUID) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:41 PM - */ - @Test - public void testSetRequestID_1() - throws Exception { - PolicyParameters fixture = new PolicyParameters(); - fixture.setRequestID(UUID.randomUUID()); - fixture.setActionAttribute(""); - fixture.setAttributes(new Hashtable>()); - fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); - fixture.setPolicyDescription(""); - - fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); - fixture.setDynamicRuleAlgorithmField2(new LinkedList()); - fixture.setPolicyName(""); - fixture.setConfigName(""); - fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); - fixture.setPolicyClass(PolicyClass.Action); - fixture.setEcompName(""); - fixture.setConfigBodyType(PolicyType.JSON); - fixture.setDynamicRuleAlgorithmField1(new LinkedList()); - fixture.setPriority(""); - fixture.setActionPerformer(""); - fixture.setConfigBody(""); - 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: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(PolicyParametersTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseStatusTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseStatusTest.java deleted file mode 100644 index 5841571bd..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseStatusTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.*; -import org.openecomp.policy.api.PolicyResponseStatus; - -import static org.junit.Assert.*; - -/** - * The class PolicyResponseStatusTest contains tests for the class {@link PolicyResponseStatus}. - * - * @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 = ""; - - 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_3() - 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 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); - } - - /** - * 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); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseTest.java deleted file mode 100644 index ec6ac09f0..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.After; -import org.junit.Before; -import org.openecomp.policy.api.PolicyResponse; - -/** - * The class PolicyResponseTest contains tests for the class {@link PolicyResponse}. - * - * @generatedBy CodePro at 6/1/16 1:41 PM - * @version $Revision: 1.0 $ - */ -public class PolicyResponseTest { - /** - * 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(PolicyResponseTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyTypeTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyTypeTest.java deleted file mode 100644 index 5b31e857b..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyTypeTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.*; -import org.openecomp.policy.api.PolicyType; - -import static org.junit.Assert.*; - -/** - * The class PolicyTypeTest contains tests for the class {@link PolicyType}. - * - * @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; - - String result = fixture.toString(); - - // add additional test code here - assertEquals("json", 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(PolicyTypeTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PushPolicyParametersTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PushPolicyParametersTest.java deleted file mode 100644 index ef005f1f4..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PushPolicyParametersTest.java +++ /dev/null @@ -1,269 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import java.util.UUID; - -import org.junit.*; -import org.openecomp.policy.api.PushPolicyParameters; - -import static org.junit.Assert.*; - -/** - * The class PushPolicyParametersTest contains tests for the class {@link PushPolicyParameters}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class PushPolicyParametersTest { - /** - * Run the PushPolicyParameters() constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPushPolicyParameters_1() - throws Exception { - - PushPolicyParameters result = new PushPolicyParameters(); - - // add additional test code here - assertNotNull(result); - assertEquals(null, result.getPolicyName()); - assertEquals(null, result.getRequestID()); - assertEquals(null, result.getPolicyType()); - assertEquals(null, result.getPdpGroup()); - } - - /** - * Run the PushPolicyParameters(String,String,String,UUID) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testPushPolicyParameters_2() - throws Exception { - String policyName = ""; - String policyType = ""; - String pdpGroup = ""; - UUID requestID = UUID.randomUUID(); - - PushPolicyParameters result = new PushPolicyParameters(policyName, policyType, pdpGroup, requestID); - - // add additional test code here - assertNotNull(result); - assertEquals("", result.getPolicyName()); - assertEquals("", result.getPolicyType()); - assertEquals("", result.getPdpGroup()); - } - - /** - * Run the String getPdpGroup() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetPdpGroup_1() - throws Exception { - PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID()); - - String result = fixture.getPdpGroup(); - - // 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 { - PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID()); - - String result = fixture.getPolicyName(); - - // add additional test code here - assertEquals("", result); - } - - /** - * Run the String getPolicyType() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testGetPolicyType_1() - throws Exception { - PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID()); - - String result = fixture.getPolicyType(); - - // 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() - throws Exception { - PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.fromString("d1dbaac1-0944-4f07-9ce7-733c697537ea")); - - UUID result = fixture.getRequestID(); - - // add additional test code here - assertNotNull(result); - assertEquals("d1dbaac1-0944-4f07-9ce7-733c697537ea", result.toString()); - assertEquals(4, result.version()); - assertEquals(2, result.variant()); - assertEquals(-7140611980868110358L, result.getLeastSignificantBits()); - assertEquals(-3324876153822097657L, result.getMostSignificantBits()); - } - - /** - * 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 { - PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID()); - String pdpGroup = ""; - - fixture.setPdpGroup(pdpGroup); - - // 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 { - PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID()); - String policyName = ""; - - fixture.setPolicyName(policyName); - - // add additional test code here - } - - /** - * Run the void setPolicyType(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:40 PM - */ - @Test - public void testSetPolicyType_1() - throws Exception { - PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID()); - String policyType = ""; - - fixture.setPolicyType(policyType); - - // 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 { - PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID()); - 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(PushPolicyParametersTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/RemovedPolicyTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/RemovedPolicyTest.java deleted file mode 100644 index ef77e6d5f..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/RemovedPolicyTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.After; -import org.junit.Before; -import org.openecomp.policy.api.RemovedPolicy; - -/** - * The class RemovedPolicyTest contains tests for the class {@link RemovedPolicy}. - * - * @generatedBy CodePro at 6/1/16 1:40 PM - * @version $Revision: 1.0 $ - */ -public class RemovedPolicyTest { - /** - * 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(RemovedPolicyTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/SendEventTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/SendEventTest.java deleted file mode 100644 index 5757f8915..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/SendEventTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.junit.Before; -import org.openecomp.policy.api.PolicyEngine; -import org.openecomp.policy.api.PolicyEngineException; -import org.openecomp.policy.api.PolicyEventException; -import org.openecomp.policy.api.PolicyResponse; -import org.openecomp.policy.api.PolicyResponseStatus; -import org.openecomp.policy.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; - -public class SendEventTest { - - private PolicyEngine policyEngine = null; - private Map eventAttributes = new HashMap(); - private Collection policyResponse = null; - private static final Logger logger = FlexLogger.getLogger(SendEventTest.class); - @Before - public void setUp() { - try { - policyEngine = new PolicyEngine("Test/config_pass.properties"); - } catch (PolicyEngineException e) { - logger.error(e.getMessage()); - fail("PolicyEngine Instantiation Error" + e); - } - logger.info("Loaded.. PolicyEngine"); - } - - //@Test - @SuppressWarnings("deprecation") - public void testSendEventFail() { - eventAttributes = null; - try { - policyResponse = policyEngine.sendEvent(eventAttributes); - } catch (PolicyEventException e) { - logger.warn(e.getMessage()); - } - assertNull(policyResponse); - } - - //@Test - @SuppressWarnings("deprecation") - public void testSendEventFailNull() { - eventAttributes.put("", ""); - try { - policyResponse = policyEngine.sendEvent(eventAttributes); - } catch (PolicyEventException e) { - logger.warn(e.getMessage()); - } - assertNull(policyResponse); - } - - // deprecated Test. - /*@Test - public void testSendEventFailAttribute() { - eventAttributes.put("Fail.key", "Value"); - try { - policyResponse = policyEngine.sendEvent(eventAttributes); - } catch (PolicyEventException e) { - logger.warn(e.getMessage()); - } - assertNull(policyResponse.getPolicyResponseMessage()); - }*/ - - //@Test - @SuppressWarnings("deprecation") - public void testSendEventNotValid() { - eventAttributes.put("Action.fail", "Value"); - try { - policyResponse = policyEngine.sendEvent(eventAttributes); - } catch (PolicyEventException e) { - logger.warn(e.getMessage()); - } - for(PolicyResponse policyResponse: this.policyResponse){ - logger.info(policyResponse.getPolicyResponseMessage() + " , " + policyResponse.getPolicyResponseStatus()); - assertNotNull(policyResponse); - assertEquals(PolicyResponseStatus.NO_ACTION_REQUIRED, policyResponse.getPolicyResponseStatus()); - assertNotNull(policyResponse.getPolicyResponseMessage()); - assertNotNull(policyResponse.getRequestAttributes()); - assertNull(policyResponse.getActionTaken()); - assertNull(policyResponse.getActionAdvised()); - } - } - - //@Test - @SuppressWarnings("deprecation") - public void testSendEventActionAdvised() { - eventAttributes.put("Key", "Value"); - eventAttributes.put("cpu", "80"); - try { - policyResponse = policyEngine.sendEvent(eventAttributes); - } catch (PolicyEventException e) { - logger.warn(e.getMessage()); - } - for(PolicyResponse policyResponse: this.policyResponse){ - logger.info(policyResponse.getPolicyResponseMessage() + " , " + policyResponse.getPolicyResponseStatus()); - assertNotNull(policyResponse); - assertEquals(PolicyResponseStatus.ACTION_ADVISED, policyResponse.getPolicyResponseStatus()); - assertNotNull(policyResponse.getPolicyResponseMessage()); - assertNotNull(policyResponse.getRequestAttributes()); - assertNull(policyResponse.getActionTaken()); - assertNotNull(policyResponse.getActionAdvised()); - } - } - - //@Test - @SuppressWarnings("deprecation") - public void testSendEventActionTaken() { - eventAttributes.put("Key", "Value"); - eventAttributes.put("cpu", "91"); - try { - policyResponse = policyEngine.sendEvent(eventAttributes); - } catch (PolicyEventException e) { - logger.warn(e.getMessage()); - } - for(PolicyResponse policyResponse: this.policyResponse){ - logger.info(policyResponse.getPolicyResponseMessage() + " , " + policyResponse.getPolicyResponseStatus()); - assertNotNull(policyResponse); - assertEquals(PolicyResponseStatus.ACTION_TAKEN, policyResponse.getPolicyResponseStatus()); - assertNotNull(policyResponse.getPolicyResponseMessage()); - assertNotNull(policyResponse.getRequestAttributes()); - assertNotNull(policyResponse.getActionTaken()); - assertNull(policyResponse.getActionAdvised()); - } - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/TestRunner.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/TestRunner.java deleted file mode 100644 index 69cbd834e..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/TestRunner.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.runner.JUnitCore; -import org.junit.runner.Result; -import org.junit.runner.notification.Failure; - -public class TestRunner { - public static void main(String[] args) { - Result result = JUnitCore.runClasses(PolicyEngineTest.class); - for(Failure failure: result.getFailures()) { - System.out.println("Failed Test: " + failure.toString()); - } - Result results = null; - if(result.wasSuccessful()) { - System.out.println("API Methods are being Tested.. "); - results = JUnitCore.runClasses(GetConfigByPolicyNameTest.class, GetConfigStringTest.class,GetConfigStringStringTest.class,GetConfigStringStringMapTest.class,SendEventTest.class); - for(Failure failure: results.getFailures()) { - System.out.println("Failed Test: " + failure.toString()); - } - System.out.println("Test Results.. "); - System.out.println("Stats: \nRun Time: " + (results.getRunTime()+result.getRunTime()) + "\nTotal Tests:" + results.getRunCount()+ result.getRunCount() - + "\nFailures: " + results.getFailureCount()+ result.getFailureCount()); - System.exit(1); - } - System.out.println("Test Failed.."); - System.out.println("Stats: \nRun Time: " + result.getRunTime() + "\nTests:" + result.getRunCount() - + "\nFailures: " + result.getFailureCount()); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/UpdateTypeTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/UpdateTypeTest.java deleted file mode 100644 index 909a05f0e..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/UpdateTypeTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.test; - -import org.junit.*; -import org.openecomp.policy.api.UpdateType; - -import static org.junit.Assert.*; - -/** - * The class UpdateTypeTest contains tests for the class {@link UpdateType}. - * - * @generatedBy CodePro at 6/1/16 1:39 PM - * @version $Revision: 1.0 $ - */ -public class UpdateTypeTest { - /** - * Run the String toString() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 6/1/16 1:39 PM - */ - @Test - public void testToString_1() - throws Exception { - UpdateType fixture = UpdateType.NEW; - - String result = fixture.toString(); - - // add additional test code here - assertEquals("new", result); - } - - /** - * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - * @generatedBy CodePro at 6/1/16 1:39 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:39 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:39 PM - */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(UpdateTypeTest.class); - } -} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/package-info.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/package-info.java deleted file mode 100644 index e678c4be2..000000000 --- a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PolicyEngineAPI - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -/** - * API JUNIT TestCases. - */ -package org.openecomp.policy.test; -- cgit 1.2.3-korg