aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-REST/src
diff options
context:
space:
mode:
Diffstat (limited to 'ONAP-REST/src')
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/XacmlAdminAuthorization.java10
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/XacmlRest.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRest.java)96
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/XacmlRestProperties.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRestProperties.java)209
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java53
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/dao/CommonClassDao.java36
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/dao/PolicyDbException.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/dao/PolicyDBException.java)25
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImpl.java176
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionBodyEntity.java188
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionList.java49
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionPolicyDict.java137
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AddressGroup.java75
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Attribute.java255
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AttributeAssignment.java56
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsController.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSController.java)124
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsDependency.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSDependency.java)123
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsParamTemplate.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSParamTemplate.java)87
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java171
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java100
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopSite.java100
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoops.java75
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConfigurationDataEntity.java214
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java83
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintValue.java63
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DatabaseLockEntity.java28
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Datatype.java200
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DcaeUsers.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VMType.java)47
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DcaeUuid.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEuuid.java)49
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DecisionSettings.java143
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DescriptiveScope.java102
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DictionaryData.java41
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTagPicker.java163
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FirewallDictionaryList.java63
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionArgument.java102
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionDefinition.java212
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FwTag.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTag.java)103
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FwTagPicker.java104
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GlobalRoleSettings.java58
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupEntity.java209
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupPolicyScopeList.java46
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupServiceList.java40
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceAttribute.java55
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceConfigName.java49
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceLocation.java48
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceModels.java134
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaults.java95
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Obadvice.java148
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ObadviceExpression.java58
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OnapName.java99
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OptimizationModels.java140
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfigParam.java148
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolverParam.java148
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PdpEntity.java190
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PepOptions.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VNFType.java)113
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipConfigParam.java135
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipConfiguration.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfiguration.java)466
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipResolver.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolver.java)286
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipResolverParam.java132
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipType.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPType.java)114
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAlgorithms.java84
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAuditlog.java48
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyDBDaoEntity.java150
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyDbDaoEntity.java107
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEditorScopes.java88
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java283
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyGroupEntity.java37
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyRoles.java64
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeClosedLoop.java48
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeResource.java47
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeService.java48
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeType.java47
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScore.java75
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java176
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PortList.java47
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PrefixList.java58
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ProtocolList.java50
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RainyDayTreatments.java87
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RemoteCatalogValues.java47
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RiskType.java97
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RuleAlgorithms.java76
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SafePolicyWarning.java58
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SecurityZone.java47
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ServiceList.java94
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SystemLogDb.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SystemLogDB.java)113
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/TermList.java190
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/UserInfo.java38
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VarbindDictionary.java104
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VmType.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEUsers.java)50
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VnfType.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PEPOptions.java)121
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VsclAction.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VSCLAction.java)100
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/WatchPolicyNotificationTable.java75
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Zone.java47
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/LockdownListener.java12
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/MSAttributeValue.java60
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/MsAttributeObject.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/util/MSAttributeObject.java)88
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/MsAttributeValue.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/package-info.java)20
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/MsModelUtils.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java)897
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/ParserException.java22
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/PdpPolicyContainer.java (renamed from ONAP-REST/src/main/java/org/onap/policy/rest/util/PDPPolicyContainer.java)263
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyContainer.java41
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifier.java33
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java578
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java691
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/XACMLRestTest.java111
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/XacmlAdminAuthorizationTest.java38
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/XacmlRestTest.java303
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/adapter/PolicyRestAdapterTest.java104
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/dao/PolicyDbExceptionTest.java (renamed from ONAP-REST/src/test/java/org/onap/policy/rest/dao/PolicyDBExceptionTest.java)53
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImplTest.java912
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionBodyEntityTest.java70
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java (renamed from ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJPATest.java)181
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BrmsDictionaryJpaTest.java (renamed from ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BRMSDictionaryJPATest.java)59
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJpaTest.java (renamed from ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJPATest.java)114
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJpaTest.java (renamed from ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJPATest.java)117
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ConfigurationDataEntityTest.java83
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DecisionDictionaryJpaTest.java (renamed from ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DecisionDictionaryJPATest.java)38
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DictionaryDataTest.java4
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DummyIdentifier.java46
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FwDictionaryJpaTest.java (renamed from ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FWDictionaryJPATest.java)129
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/GetterSetterToStringTest.java57
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJpaTest.java (renamed from ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJPATest.java)125
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaultsTest.java54
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/OptimizationModelsJpaTest.java (renamed from ONAP-REST/src/test/java/org/onap/policy/rest/jpa/OptimizationModelsJPATest.java)26
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PIPConfigurationTest.java121
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PipConfigurationTest.java196
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PipJpaTest.java (renamed from ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PIPJPATest.java)131
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyAuditlogTest.java3
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJPATest.java206
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJpaTest.java528
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyUtilsJPATest.java190
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyUtilsJpaTest.java320
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/util/DummyPolicyContainer.java77
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/util/MsAttributeObjectTest.java (renamed from ONAP-REST/src/test/java/org/onap/policy/rest/util/MSAttributeObjectTest.java)13
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/util/MsModelUtilsTest.java (renamed from ONAP-REST/src/test/java/org/onap/policy/rest/util/MSModelUtilsTest.java)47
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/util/PDPPolicyContainerTest.java138
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/util/ParserExceptionTest.java34
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/util/PdpPolicyContainerTest.java267
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifierTest.java69
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationRequestWrapperTest.java422
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationTest.java1234
-rw-r--r--ONAP-REST/src/test/resources/policies/DecisionPolicy.json1556
-rw-r--r--ONAP-REST/src/test/resources/policies/MicroServicePolicy.json38
-rw-r--r--ONAP-REST/src/test/resources/policies/MicroServicePolicyContent0.json23
-rw-r--r--ONAP-REST/src/test/resources/policies/MicroServicePolicyContent1.json27
-rw-r--r--ONAP-REST/src/test/resources/policies/PolicyJsonTrapFault.json9
144 files changed, 11532 insertions, 9020 deletions
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlAdminAuthorization.java b/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlAdminAuthorization.java
index 184d1ff60..10b3cbfb4 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlAdminAuthorization.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlAdminAuthorization.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -32,9 +33,10 @@ public class XacmlAdminAuthorization {
String userRole;
- Role(String a) {
- this.userRole = a;
+ Role(String userRole) {
+ this.userRole = userRole;
}
+
@Override
public String toString() {
return this.userRole;
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRest.java b/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlRest.java
index 7cced5667..011fb8868 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRest.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlRest.java
@@ -4,13 +4,14 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,6 +22,8 @@
package org.onap.policy.rest;
+import com.att.research.xacml.util.XACMLProperties;
+
import java.io.IOException;
import java.util.Enumeration;
import java.util.Map;
@@ -35,37 +38,31 @@ import org.apache.commons.logging.LogFactory;
import org.onap.policy.common.logging.eelf.MessageCodes;
import org.onap.policy.common.logging.eelf.PolicyLogger;
-import com.att.research.xacml.util.XACMLProperties;
-
-
/**
- * This static class is used by both the PDP and PAP servlet's. It contains some common
- * static functions and objects used by both the servlet's.
- *
+ * This static class is used by both the PDP and PAP servlet's. It contains some common static functions and objects
+ * used by both the servlet's.
+ *
*
*/
-public class XACMLRest {
- private static final Log logger = LogFactory.getLog(XACMLRest.class);
+public class XacmlRest {
+ private static final Log logger = LogFactory.getLog(XacmlRest.class);
private static Properties restProperties = new Properties();
- private XACMLRest(){
+ private XacmlRest() {
// Empty constructor
}
+
/**
- * This must be called during servlet initialization. It sets up the xacml.?.properties
- * file as a system property. If the System property is already set, then it does not
- * do anything. This allows the developer to specify their own xacml.properties file to be
- * used. They can 1) modify the default properties that comes with the project, or 2) change
- * the WebInitParam annotation, or 3) specify an alternative path in the web.xml, or 4) set
- * the Java System property to point to their xacml.properties file.
- *
- * The recommended way of overriding the default xacml.properties file is using a Java System
- * property:
+ * This must be called during servlet initialization. It sets up the xacml.?.properties file as a system property.
+ * If the System property is already set, then it does not do anything. This allows the developer to specify their
+ * own xacml.properties file to be used. They can 1) modify the default properties that comes with the project, or
+ * 2) change the WebInitParam annotation, or 3) specify an alternative path in the web.xml, or 4) set the Java
+ * System property to point to their xacml.properties file.
*
+ * <p>The recommended way of overriding the default xacml.properties file is using a Java System property:
* -Dxacml.properties=/opt/app/xacml/etc/xacml.admin.properties
*
- * This way one does not change any actual code or files in the project and can leave the
- * defaults alone.
+ * <p>This way one does not change any actual code or files in the project and can leave the defaults alone.
*
* @param config - The servlet config file passed from the javax servlet init() function
*/
@@ -100,7 +97,7 @@ public class XACMLRest {
Enumeration<String> params = config.getInitParameterNames();
while (params.hasMoreElements()) {
String param = params.nextElement();
- if (! "XACML_PROPERTIES_NAME".equals(param)) {
+ if (!"XACML_PROPERTIES_NAME".equals(param)) {
String value = config.getInitParameter(param);
PolicyLogger.info(param + "=" + config.getInitParameter(param));
restProperties.setProperty(param, value);
@@ -109,15 +106,14 @@ public class XACMLRest {
}
/**
- * Reset's the XACMLProperties internal properties object so we start
- * in a fresh environment. Then adds back in our Servlet init properties that were
- * passed in the javax Servlet init() call.
+ * Reset's the XACMLProperties internal properties object so we start in a fresh environment. Then adds back in our
+ * Servlet init properties that were passed in the javax Servlet init() call.
*
- * This function is primarily used when a new configuration is passed in and the
- * PDP servlet needs to load a new PDP engine instance.
+ * <p>This function is primarily used when a new configuration is passed in and the PDP servlet needs to load a new
+ * PDP engine instance.
*
* @param pipProperties - PIP configuration properties
- * @param policyProperties - Policy configuration properties
+ * @param policyProperties - Policy configuration properties
*/
public static void loadXacmlProperties(Properties policyProperties, Properties pipProperties) {
try {
@@ -128,7 +124,7 @@ public class XACMLRest {
//
// Now load our init properties
//
- XACMLProperties.getProperties().putAll(XACMLRest.restProperties);
+ XACMLProperties.getProperties().putAll(XacmlRest.restProperties);
//
// Load our policy properties
//
@@ -142,7 +138,8 @@ public class XACMLRest {
XACMLProperties.getProperties().putAll(pipProperties);
}
} catch (IOException e) {
- PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Failed to put init properties into Xacml properties");
+ PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e,
+ "Failed to put init properties into Xacml properties");
}
//
// Dump them
@@ -166,12 +163,26 @@ public class XACMLRest {
return;
}
- // special-case for receiving heartbeat - don't need to repeatedly output all of the information in multiple lines
- if ("GET".equals(request.getMethod()) && "hb".equals(request.getParameter("type")) ) {
+ // special-case for receiving heartbeat - don't need to repeatedly output all of the information in multiple
+ // lines
+ if ("GET".equals(request.getMethod()) && "hb".equals(request.getParameter("type"))) {
PolicyLogger.debug("GET type=hb : heartbeat received");
return;
}
- logger.debug(request.getMethod() + ":" + request.getRemoteAddr() + " " + request.getRemoteHost() + " " + request.getRemotePort());
+
+ dumpRequestHeadersAttributesContextPath(request);
+
+ dumpRequestBody(request);
+ }
+
+ /**
+ * Dump the headers, attributes, and context path of the request.
+ *
+ * @param request the request to dump
+ */
+ private static void dumpRequestHeadersAttributesContextPath(HttpServletRequest request) {
+ logger.debug(request.getMethod() + ":" + request.getRemoteAddr() + " " + request.getRemoteHost() + " "
+ + request.getRemotePort());
logger.debug(request.getLocalAddr() + " " + request.getLocalName() + " " + request.getLocalPort());
Enumeration<String> en = request.getHeaderNames();
logger.debug("Headers:");
@@ -190,9 +201,20 @@ public class XACMLRest {
logger.debug(element + ":" + request.getAttribute(element));
}
logger.debug("ContextPath: " + request.getContextPath());
+ }
+
+
+ /**
+ * Dump the body of the request.
+ *
+ * @param request the request to act on
+ */
+ private static void dumpRequestBody(HttpServletRequest request) {
if ("PUT".equals(request.getMethod()) || "POST".equals(request.getMethod())) {
- // POST and PUT are allowed to have parameters in the content, but in our usage the parameters are always in the Query string.
- // More importantly, there are cases where the POST and PUT content is NOT parameters (e.g. it might contain a Policy file).
+ // POST and PUT are allowed to have parameters in the content, but in our usage the parameters are always in
+ // the Query string.
+ // More importantly, there are cases where the POST and PUT content is NOT parameters (e.g. it might contain
+ // a Policy file).
// Unfortunately the request.getParameterMap method reads the content to see if there are any parameters,
// and once the content is read it cannot be read again.
// Thus for PUT and POST we must avoid reading the content here so that the main code can read it.
@@ -204,7 +226,7 @@ public class XACMLRest {
logger.debug("Content available: " + request.getInputStream().available());
}
} catch (Exception e) {
- logger.debug("Content: inputStream exception: " + e.getMessage() + "; (May not be relevant)" +e);
+ logger.debug("Content: inputStream exception: " + e.getMessage() + "; (May not be relevant)" + e);
}
} else {
logger.debug("Parameters:");
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRestProperties.java b/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlRestProperties.java
index f7f887cef..f75f80c7c 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRestProperties.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlRestProperties.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,52 +24,48 @@ package org.onap.policy.rest;
import com.att.research.xacml.util.XACMLProperties;
/**
- * These are XACML Properties that are relevant to the RESTful API interface for
- * the PDP, PAP and AC interfaces.
+ * These are XACML Properties that are relevant to the RESTful API interface for the PDP, PAP and AC interfaces.
*
*
*/
-public class XACMLRestProperties extends XACMLProperties {
+public class XacmlRestProperties extends XACMLProperties {
/**
- * A unique identifier for the PDP servlet instance. Usually set to the URL
- * it is running as in the J2EE container.
+ * A unique identifier for the PDP servlet instance. Usually set to the URL it is running as in the J2EE container.
*
- * Eg. http://localhost:8080/pdp/
+ * <p>Eg. http://localhost:8080/pdp/
*/
public static final String PROP_PDP_ID = "xacml.rest.pdp.id";
/**
- * A PDP servlet's configuration directory. Holds the pip and policy
- * configuration data as well as the local policy cache.
+ * A PDP servlet's configuration directory. Holds the pip and policy configuration data as well as the local policy
+ * cache.
*
- * Eg: /opt/app/xacml/config
+ * <p>Eg: /opt/app/xacml/config
*/
public static final String PROP_PDP_CONFIG = "xacml.rest.pdp.config";
// Resilience feature-
public static final String PROP_PDP_WEBAPPS = "xacml.rest.pdp.webapps";
- //Closed Loop JSON table
+ // Closed Loop JSON table
public static final String PROP_ADMIN_CLOSEDLOOP = "xacml.rest.admin.closedLoopJSON";
/**
- * Set this property to true or false if the PDP servlet should register
- * itself upon startup with the PAP servlet.
+ * Set this property to true or false if the PDP servlet should register itself upon startup with the PAP servlet.
*/
public static final String PROP_PDP_REGISTER = "xacml.rest.pdp.register";
/**
- * Number of seconds the PDP will sleep while retrying registration with the
- * PAP. This value must be greater or equal to 5.
+ * Number of seconds the PDP will sleep while retrying registration with the PAP. This value must be greater or
+ * equal to 5.
*/
public static final String PROP_PDP_REGISTER_SLEEP = "xacml.rest.pdp.register.sleep";
/**
- * Number of retry attempts at registration with the PAP. A value of -1
- * indicates infinite retries.
+ * Number of retry attempts at registration with the PAP. A value of -1 indicates infinite retries.
*/
public static final String PROP_PDP_REGISTER_RETRIES = "xacml.rest.pdp.register.retries";
/**
- * Max content length accepted for an incoming POST XML/JSON request.
- * Default is 32767 bytes.
+ * Max content length accepted for an incoming POST XML/JSON request. Default is 32767 bytes.
*/
public static final String PROP_PDP_MAX_CONTENT = "xacml.rest.pdp.maxcontent";
+
/**
- * Custom HTTP header used by PDP to send the value of the PROP_PDP_ID
+ * Custom HTTP header used by PDP to send the value of the PROP_PDP_ID.
*/
public static final String PROP_PDP_HTTP_HEADER_ID = "X-XACML-PDP-ID";
/**
@@ -76,55 +73,48 @@ public class XACMLRestProperties extends XACMLProperties {
*/
public static final String PROP_PDP_HTTP_HEADER_HB = "X-XACML-PDP-HB";
/*
- * Custom HTTP header used by PDP to send the value of the
- * X-XACML-PDP-JMX-PORT
+ * Custom HTTP header used by PDP to send the value of the X-XACML-PDP-JMX-PORT
*/
public static final String PROP_PDP_HTTP_HEADER_JMX_PORT = "X-XACML-PDP-JMX-PORT";
/**
- * The URL of the PAP servlet. Used by PDP servlet's to communicate. Because
- * administrators can set whatever context they want to run the PAP servlet,
- * it isn't easy to determine a return URL for the PAP servlet. This is
- * especially true upon initialization.
+ * The URL of the PAP servlet. Used by PDP servlet's to communicate. Because administrators can set whatever context
+ * they want to run the PAP servlet, it isn't easy to determine a return URL for the PAP servlet. This is especially
+ * true upon initialization.
*/
public static final String PROP_PAP_URL = "xacml.rest.pap.url";
/**
- * A comma divided list of urls pointing to avaiable PAP urls.
- * If one or more fail, the other servers in the list can
- * handle the requests.
+ * A comma divided list of urls pointing to avaiable PAP urls. If one or more fail, the other servers in the list
+ * can handle the requests.
*/
public static final String PROP_PAP_URLS = "xacml.rest.pap.urls";
public static final String PROP_PAP_FAILED_URLS = "xacml.rest.pap.failedUrls";
public static final String PROP_PAP_SUCCEEDED_URLS = "xacml.rest.pap.succeededUrls";
/**
- * Upon startup, have the PAP servlet send latest configuration information
- * to all the PDP nodes it knows about.
+ * Upon startup, have the PAP servlet send latest configuration information to all the PDP nodes it knows about.
*/
public static final String PROP_PAP_INITIATE_PDP_CONFIG = "xacml.rest.pap.initiate.pdp";
/**
- * The interval the PAP servlet uses to send heartbeat requests to the PDP
- * nodes.
+ * The interval the PAP servlet uses to send heartbeat requests to the PDP nodes.
*/
public static final String PROP_PAP_HEARTBEAT_INTERVAL = "xacml.rest.pap.heartbeat.interval";
/**
- * Timeout value used by the PAP servlet when trying to check the heartbeat
- * of a PDP node.
+ * Timeout value used by the PAP servlet when trying to check the heartbeat of a PDP node.
*/
public static final String PROP_PAP_HEARTBEAT_TIMEOUT = "xacml.rest.pap.heartbeat.timeout";
/*
- * This is the domain you can setup for your organization, it should be a URI.
- * Eg. com:sample:foo
+ * This is the domain you can setup for your organization, it should be a URI. Eg. com:sample:foo
*/
public static final String PROP_PAP_DOMAIN = "xacml.rest.pap.domain";
/*
- * Local path to where user workspaces exist. The user workspace contains temporary files, the
- * user's clone of the GIT repository, anything specific to the user, etc.
+ * Local path to where user workspaces exist. The user workspace contains temporary files, the user's clone of the
+ * GIT repository, anything specific to the user, etc.
*/
public static final String PROP_PAP_WORKSPACE = "xacml.rest.pap.workspace";
/*
- * Local path to where the GIT repository exists.
+ * Local path to where the GIT repository exists.
*
* Eg. /opt/app/xacml/repository
*/
@@ -166,8 +156,8 @@ public class XACMLRestProperties extends XACMLProperties {
public static final String PROP_PAP_AUDIT_TIMEOUT = "xacml.rest.pap.audit.timeoutms";
/*
- * Value determines direction of audit. Value=true will synch the file system to contents of the DB.
- * Value=false will synch the DB to the contents of the file system.
+ * Value determines direction of audit. Value=true will synch the file system to contents of the DB. Value=false
+ * will synch the DB to the contents of the file system.
*/
public static final String PROP_PAP_AUDIT_FLAG = "xacml.rest.pap.filesystem.audit";
@@ -181,12 +171,12 @@ public class XACMLRestProperties extends XACMLProperties {
*/
public static final String PROP_PAP_NOTIFY_TIMEOUT = "xacml.rest.pap.notify.timeoutms";
/*
- * Value for Enable/Disable of AutoPush Flag.
+ * Value for Enable/Disable of AutoPush Flag.
*/
public static final String PROP_PAP_PUSH_FLAG = "xacml.rest.pap.autopush.flag";
/*
- * Properties file for the AutoPush Functionality.
+ * Properties file for the AutoPush Functionality.
*/
public static final String PROP_PAP_PUSH_FILE = "xacml.rest.pap.autopush.file";
@@ -197,14 +187,12 @@ public class XACMLRestProperties extends XACMLProperties {
*/
public static final String PROP_ADMIN_REPOSITORY = "xacml.rest.admin.repository";
/*
- * Local path to where user workspaces exist. The user workspace contains
- * temporary files, the user's clone of the GIT repository, anything
- * specific to the user, etc.
+ * Local path to where user workspaces exist. The user workspace contains temporary files, the user's clone of the
+ * GIT repository, anything specific to the user, etc.
*/
public static final String PROP_ADMIN_WORKSPACE = "xacml.rest.admin.workspace";
/*
- * This is the domain you can setup for your organization, it should be a
- * URI.
+ * This is the domain you can setup for your organization, it should be a URI.
*
* Eg. com:sample:foo
*/
@@ -212,38 +200,33 @@ public class XACMLRestProperties extends XACMLProperties {
/**
* PROP_ADMIN_USER_NAME is simply a name for the logged in user.
*
- * AC authentication is out the scope of the web application itself. It is
- * up to the developer to setup authentication as they please in the J2EE
- * container used to run the web application. Whatever authentication
- * mechanism they use, they should then set the attribute into the
- * HttpSession object. The Admin Console will be able to read that value
- * (default to "guest") in.
+ * <p>AC authentication is out the scope of the web application itself. It is up to the developer to setup
+ * authentication as they please in the J2EE container used to run the web application. Whatever authentication
+ * mechanism they use, they should then set the attribute into the HttpSession object. The Admin Console will be
+ * able to read that value (default to "guest") in.
*
- * ((HttpServletRequest)
- * request).getSession().setAttribute("xacml.rest.admin.user.name",
- * "Homer");
+ * <p>((HttpServletRequest) request).getSession().setAttribute("xacml.rest.admin.user.name", "Homer");
*
*/
public static final String PROP_ADMIN_USER_NAME = "xacml.rest.admin.user.name";
+
/**
- *
* PROP_ADMIN_USER_ID is an id for the logged in user.
*
- * Eg. hs1234
+ * <p>Eg. hs1234
*
- * @see #PROP_ADMIN_USER_NAME for more information.
+ * <p>@see #PROP_ADMIN_USER_NAME for more information.
*/
+
public static final String PROP_ADMIN_USER_ID = "xacml.rest.admin.user.id";
/**
- *
* PROP_ADMIN_USER_EMAIL is a user's email address.
*
* @see #PROP_ADMIN_USER_NAME for more information.
*/
public static final String PROP_ADMIN_USER_EMAIL = "xacml.rest.admin.user.email";
/**
- * Directory path containing sub-directories where the Subscriber servlet
- * puts files sent through data feeds.
+ * Directory path containing sub-directories where the Subscriber servlet puts files sent through data feeds.
*/
public static final String PROP_SUBSCRIBER_INCOMING = "xacml.subscriber.incoming";
/**
@@ -251,8 +234,7 @@ public class XACMLRestProperties extends XACMLProperties {
*/
public static final String PROP_SUBSCRIBER_FEED = "xacml.subscriber.feed";
/**
- * Value for the log time frame that is to be stored in the database any
- * logs after this time frame will be removed.
+ * Value for the log time frame that is to be stored in the database any logs after this time frame will be removed.
*/
public static final String PROP_LOG_TIMEFRAME = "xacml.log.timeframe";
/**
@@ -305,7 +287,7 @@ public class XACMLRestProperties extends XACMLProperties {
/*
* webapps Location of the PAP-REST server
*/
- public static final String PROP_PAP_WEBAPPS= "xacml.rest.config.webapps";
+ public static final String PROP_PAP_WEBAPPS = "xacml.rest.config.webapps";
/*
* Value for Notification Option
*/
@@ -317,27 +299,27 @@ public class XACMLRestProperties extends XACMLProperties {
/*
* Value for Notification Delay
*/
- public static final String PROP_NOTIFICATION_DELAY= "NOTIFICATION_DELAY";
+ public static final String PROP_NOTIFICATION_DELAY = "NOTIFICATION_DELAY";
/*
* Value for Notification Topic
*/
- public static final String PROP_NOTIFICATION_TOPIC= "NOTIFICATION_TOPIC";
+ public static final String PROP_NOTIFICATION_TOPIC = "NOTIFICATION_TOPIC";
/*
* Value for Notification Topic
*/
- public static final String PROP_UEB_API_KEY= "UEB_API_KEY";
+ public static final String PROP_UEB_API_KEY = "UEB_API_KEY";
/*
* Value for Notification Topic
*/
- public static final String PROP_UEB_API_SECRET= "UEB_API_SECRET";
+ public static final String PROP_UEB_API_SECRET = "UEB_API_SECRET";
/*
* Closedloop Fault Policy Template Version
*/
- public static final String TemplateVersion_Fault= "xacml.rest.closedLoopFault";
+ public static final String TEMPLATE_VERSION_FAULT = "xacml.rest.closedLoopFault";
/*
* Closedloop PM Policy Template Version
*/
- public static final String TemplateVersion_PM= "xacml.rest.closedLoopPM";
+ public static final String TEMPLATE_VERSION_PM = "xacml.rest.closedLoopPM";
/*
* Value for model properties file
*/
@@ -345,89 +327,88 @@ public class XACMLRestProperties extends XACMLProperties {
/*
* MicroService Policy Template Version
*/
- public static final String TemplateVersion_MS= "xacml.rest.microServices";
+ public static final String TEMPLATE_VERSION_MS = "xacml.rest.microServices";
/*
* Optimization Policy Template Version
*/
- public static final String TemplateVersion_OOF= "xacml.rest.optimization";
+ public static final String TEMPLATE_VERSION_OOF = "xacml.rest.optimization";
/*
* Firewall Policy Template Version
*/
- public static final String TemplateVersion_FW= "xacml.rest.firewallPolicy";
+ public static final String TEMPLATE_VERSION_FW = "xacml.rest.firewallPolicy";
/*
- * Size of SelectList for Users in MS
+ * Size of SelectList for Users in MS
*
- */
- public static final String PROP_USER_SELECTLIST_WINDOW_SIZE= "xacml.user.column.count";
+ */
+ public static final String PROP_USER_SELECTLIST_WINDOW_SIZE = "xacml.user.column.count";
/*
* Audit function in pap admin to Update userinfo table to syncronize with Roles table
*/
- public static final String PROP_ROLES_USERINFO_AUDIT= "xacml.audit.userInfo";
+ public static final String PROP_ROLES_USERINFO_AUDIT = "xacml.audit.userInfo";
/*
* test Environment LoginId
*/
- public static final String PROP_TEST_ENVIRONMENT_LOGINID= "xacml.testEnvironment.loginId";
+ public static final String PROP_TEST_ENVIRONMENT_LOGINID = "xacml.testEnvironment.loginId";
/*
- * Size of of the page length for sqlcontainer
+ * Size of of the page length for sqlcontainer
*
- */
- public static final String PROP_SQLCONTAINER_PAGE_LENGTH= "xacml.sqlcontainer.page.length";
+ */
+ public static final String PROP_SQLCONTAINER_PAGE_LENGTH = "xacml.sqlcontainer.page.length";
/*
- * add values used to connect to restful api
+ * add values used to connect to restful api
*
- */
- public static final String PROP_RESTFUL_INTERFACE= "xacm.restful.interface.file";
+ */
+ public static final String PROP_RESTFUL_INTERFACE = "xacm.restful.interface.file";
/*
- * add pattern to identify what values are designed as required
+ * add pattern to identify what values are designed as required
*
- */
- public static final String PROP_XCORE_REQUIRED_PATTERN= "xacm.xcor.required.pattern";
+ */
+ public static final String PROP_XCORE_REQUIRED_PATTERN = "xacm.xcor.required.pattern";
/*
- * Time before a cache value is evicted
+ * Time before a cache value is evicted
*
- */
- public static final String PROP_CACHE_LIVE_TIME= "xacm.cache.live.time";
+ */
+ public static final String PROP_CACHE_LIVE_TIME = "xacm.cache.live.time";
/*
- * Highest value allowed in priority
+ * Highest value allowed in priority
*
- */
- public static final String PROP_PRIORITY_COUNT= "xacml.max.priority.count";
+ */
+ public static final String PROP_PRIORITY_COUNT = "xacml.max.priority.count";
/*
- * The name of the PAP. Must be unique across the system
+ * The name of the PAP. Must be unique across the system
*/
- public static final String PAP_RESOURCE_NAME="xacml.rest.pap.resource.name";
+ public static final String PAP_RESOURCE_NAME = "xacml.rest.pap.resource.name";
/*
* The name of the site in which the PAP resides
*/
- public static final String PAP_SITE_NAME="site_name";
+ public static final String PAP_SITE_NAME = "site_name";
/*
* The node type of the PAP - really a no-op since it's value is pap
*/
- public static final String PAP_NODE_TYPE="node_type";
+ public static final String PAP_NODE_TYPE = "node_type";
/*
- * A list of the groups of resources/nodes on which the PAP is dependent. The members of a
- * group are comma-separated and the groups are separated with semicolons.
+ * A list of the groups of resources/nodes on which the PAP is dependent. The members of a group are comma-separated
+ * and the groups are separated with semicolons.
*/
- public static final String PAP_DEPENDENCY_GROUPS="dependency_groups";
+ public static final String PAP_DEPENDENCY_GROUPS = "dependency_groups";
/*
- * The (optional) period of time in seconds between executions of the integrity audit.
- * Value < 0 : Audit does not run (default value if property is not present = -1)
- * Value = 0 : Audit runs continuously
- * Value > 0 : The period of time in seconds between execution of the audit on a particular node
+ * The (optional) period of time in seconds between executions of the integrity audit. Value < 0 : Audit does not
+ * run (default value if property is not present = -1) Value = 0 : Audit runs continuously Value > 0 : The period of
+ * time in seconds between execution of the audit on a particular node
*/
public static final String PAP_INTEGRITY_AUDIT_PERIOD_SECONDS = "integrity_audit_period_seconds";
/*
- * The name of the Admin. Must be unique across the system
+ * The name of the Admin. Must be unique across the system
*/
- public static final String ADMIN_RESOURCE_NAME="xacml.rest.admin.resource.name";
+ public static final String ADMIN_RESOURCE_NAME = "xacml.rest.admin.resource.name";
/*
- * The name of the PDP. Must be unique across the system
+ * The name of the PDP. Must be unique across the system
*/
- public static final String PDP_RESOURCE_NAME="xacml.rest.pdp.resource.name";
+ public static final String PDP_RESOURCE_NAME = "xacml.rest.pdp.resource.name";
/*
* Audit function in pap admin to Update userinfo table to syncronize with Roles table
*/
- public static final String PROP_AUTOMATIC_POLICYPUSH= "xacml.automatic.push";
+ public static final String PROP_AUTOMATIC_POLICYPUSH = "xacml.automatic.push";
/*
* Add Limit for Onap Portal Dashboard tab data
*/
@@ -444,7 +425,7 @@ public class XACMLRestProperties extends XACMLProperties {
/*
* The number of Risk Levels allowed
*/
- public static final String ADMIN_RISK_LEVEL_COUNT="xacml.risk.level.count";
+ public static final String ADMIN_RISK_LEVEL_COUNT = "xacml.risk.level.count";
/*
* The maxium Level displayed on the UI for Micro Services
*/
@@ -453,7 +434,7 @@ public class XACMLRestProperties extends XACMLProperties {
/*
* Value for Incoming Notification tries
*
- * */
+ */
public static final String PROP_PAP_INCOMINGNOTIFICATION_TRIES = "xacml.rest.pap.incomingnotification.tries";
/*
@@ -463,7 +444,7 @@ public class XACMLRestProperties extends XACMLProperties {
// Static class, hide constructor
- private XACMLRestProperties() {
+ private XacmlRestProperties() {
super();
}
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java
index 0a3f46c78..e7879a855 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java
@@ -23,7 +23,9 @@ package org.onap.policy.rest.adapter;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+
import javax.persistence.EntityManagerFactory;
+
import org.onap.policy.rest.jpa.OnapName;
public class PolicyRestAdapter {
@@ -1154,4 +1156,55 @@ public class PolicyRestAdapter {
public void setUiJsonBody(String uiJsonBody) {
this.uiJsonBody = uiJsonBody;
}
+
+ public boolean setupUsingAttribute(String attributeId, String value) {
+ switch (attributeId) {
+ case "ONAPName":
+ this.setOnapName(value);
+ OnapName tempOnapName = new OnapName();
+ tempOnapName.setName(value);
+ this.setOnapNameField(tempOnapName);
+ return true;
+ case "RiskType":
+ this.setRiskType(value);
+ return true;
+ case "RiskLevel":
+ this.setRiskLevel(value);
+ return true;
+ case "guard":
+ this.setGuard(value);
+ return true;
+ case "ConfigName":
+ this.setConfigName(value);
+ return true;
+ case "uuid":
+ this.setUuid(value);
+ return true;
+ case "location":
+ this.setLocation(value);
+ return true;
+ case "TTLDate":
+ if (!value.contains("NA")) {
+ this.setTtlDate(PolicyRestAdapter.convertDate(value));
+ return true;
+ }
+ return false;
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * Function to convert date.
+ *
+ * @param dateTimeToLive input date value.
+ * @return
+ */
+ private static String convertDate(String dateTimeToLive) {
+ String formatDate = null;
+ if (dateTimeToLive.contains("-")) {
+ formatDate = dateTimeToLive.replace("-", "/");
+ }
+ return formatDate;
+ }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/dao/CommonClassDao.java b/ONAP-REST/src/main/java/org/onap/policy/rest/dao/CommonClassDao.java
index 0056a2bf5..6bc9a646e 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/dao/CommonClassDao.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/dao/CommonClassDao.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,37 +23,46 @@ package org.onap.policy.rest.dao;
import java.util.List;
-import org.onap.policy.rest.jpa.PolicyRoles;
import javax.script.SimpleBindings;
+import org.onap.policy.rest.jpa.PolicyRoles;
+
public interface CommonClassDao {
- //Common methods
+ // Common methods
List<Object> getData(@SuppressWarnings("rawtypes") Class className);
+
List<Object> getDataById(@SuppressWarnings("rawtypes") Class className, String columnName, String key);
+
List<String> getDataByColumn(@SuppressWarnings("rawtypes") Class className, String columnName);
- List<Object> checkDuplicateEntry(String value, String columnName, @SuppressWarnings("rawtypes") Class className);
+
+ List<Object> checkDuplicateEntry(String value, String columnName, @SuppressWarnings("rawtypes") Class className);
+
Object getEntityItem(@SuppressWarnings("rawtypes") Class className, String columnName, String key);
- List<Object> getDataByQuery(String query, SimpleBindings params);
- List<Object> getMultipleDataOnAddingConjunction(@SuppressWarnings("rawtypes") Class className, String columnName, List<String> data);
+
+ List<Object> getDataByQuery(String query, SimpleBindings params);
+
+ List<Object> getMultipleDataOnAddingConjunction(@SuppressWarnings("rawtypes") Class className, String columnName,
+ List<String> data);
+
void save(Object entity);
+
void delete(Object entity);
+
void update(Object entity);
+
void updateQuery(String query);
- //Group Policy Scope
+ // Group Policy Scope
List<Object> checkExistingGroupListforUpdate(String groupListValue, String groupNameValue);
-
- //Roles
+ // Roles
List<PolicyRoles> getUserRoles();
-
- //ClosedLoops
+ // ClosedLoops
void updateClAlarms(String clName, String alarms);
- void updateClYaml(String clName, String yaml);
- void deleteAll();
-
+ void updateClYaml(String clName, String yaml);
+ void deleteAll();
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/dao/PolicyDBException.java b/ONAP-REST/src/main/java/org/onap/policy/rest/dao/PolicyDbException.java
index df6bf12b2..4a982ccc0 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/dao/PolicyDBException.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/dao/PolicyDbException.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,30 +22,30 @@
package org.onap.policy.rest.dao;
/**
- * PolicyDBException extends <code>Exception</code> to implement exceptions thrown by Policy Database transactions.
- *
+ * PolicyDBException extends <code>Exception</code> to implement exceptions thrown by Policy Database transactions.
+ *
* @version 0.1
*/
-public class PolicyDBException extends Exception {
+public class PolicyDbException extends Exception {
private static final long serialVersionUID = -6162444281003852781L;
- public PolicyDBException() {
+ public PolicyDbException() {
// Empty constructor
}
-
- public PolicyDBException(String message) {
+
+ public PolicyDbException(String message) {
super(message);
}
-
- public PolicyDBException(Throwable cause){
+
+ public PolicyDbException(Throwable cause) {
super(cause);
}
-
- public PolicyDBException(String message, Throwable cause) {
+
+ public PolicyDbException(String message, Throwable cause) {
super(message, cause);
}
-
- public PolicyDBException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+
+ public PolicyDbException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImpl.java b/ONAP-REST/src/main/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImpl.java
index 66401ccb3..f64b9ce19 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImpl.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImpl.java
@@ -3,13 +3,14 @@
* ONAP Policy Engine
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.daoimpl;
import java.util.ArrayList;
@@ -45,28 +47,28 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
-public class PolicyValidationDaoImpl implements CommonClassDao{
+public class PolicyValidationDaoImpl implements CommonClassDao {
private static final Logger LOGGER = FlexLogger.getLogger(PolicyValidationDaoImpl.class);
private static final String DB_CONNECTION_CLOSING_ERROR = "Error While Closing Connection/Statement";
private static final String DBTABLE_QUERY_ERROR = "Error While Querying Table";
private static SessionFactory sessionfactory;
-
- public static SessionFactory getSessionfactory() {
- return sessionfactory;
+
+ @Autowired
+ private PolicyValidationDaoImpl(SessionFactory sessionfactory) {
+ PolicyValidationDaoImpl.sessionfactory = sessionfactory;
}
- public static void setSessionfactory(SessionFactory sessionfactory) {
- PolicyValidationDaoImpl.sessionfactory = sessionfactory;
+ public PolicyValidationDaoImpl() {
+ // Default Constructor
}
- @Autowired
- private PolicyValidationDaoImpl(SessionFactory sessionfactory){
- PolicyValidationDaoImpl.sessionfactory = sessionfactory;
+ public static SessionFactory getSessionfactory() {
+ return sessionfactory;
}
-
- public PolicyValidationDaoImpl(){
- //Default Constructor
+
+ public static void setSessionfactory(SessionFactory sessionfactory) {
+ PolicyValidationDaoImpl.sessionfactory = sessionfactory;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -74,16 +76,16 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
public List<Object> getData(Class className) {
Session session = sessionfactory.openSession();
List<Object> data = null;
- try{
+ try {
Criteria cr = session.createCriteria(className);
data = cr.list();
- }catch(Exception e){
+ } catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + e);
- }finally{
- try{
+ } finally {
+ try {
session.close();
- }catch(Exception e){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR+e);
+ } catch (Exception e) {
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e);
}
}
return data;
@@ -97,22 +99,22 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
List<Object> data = null;
try {
Criteria cr = session.createCriteria(className);
- if(columnName.contains(":") && key.contains(":")){
+ if (columnName.contains(":") && key.contains(":")) {
String[] columns = columnName.split(":");
String[] keys = key.split(":");
- for(int i=0; i < columns.length; i++){
+ for (int i = 0; i < columns.length; i++) {
cr.add(Restrictions.eq(columns[i], keys[i]));
}
- }else{
+ } else {
cr.add(Restrictions.eq(columnName, key));
}
data = cr.list();
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + e);
- }finally{
- try{
+ } finally {
+ try {
session.close();
- }catch(Exception e1){
+ } catch (Exception e1) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
@@ -126,12 +128,12 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
try {
session.persist(entity);
tx.commit();
- }catch(Exception e){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving data to Table"+e);
- }finally{
- try{
+ } catch (Exception e) {
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving data to Table" + e);
+ } finally {
+ try {
session.close();
- }catch(Exception e1){
+ } catch (Exception e1) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
@@ -145,12 +147,12 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
try {
session.delete(entity);
tx.commit();
- }catch(Exception e){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting data from Table"+e);
- }finally{
- try{
+ } catch (Exception e) {
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting data from Table" + e);
+ } finally {
+ try {
session.close();
- }catch(Exception e1){
+ } catch (Exception e1) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
@@ -165,12 +167,12 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
try {
session.update(entity);
tx.commit();
- }catch(Exception e){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating data to Table"+e);
- }finally{
- try{
+ } catch (Exception e) {
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating data to Table" + e);
+ } finally {
+ try {
session.close();
- }catch(Exception e1){
+ } catch (Exception e1) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
@@ -185,30 +187,31 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
Transaction tx = session.beginTransaction();
List<Object> data = null;
String[] columnNames = null;
- if(columnName != null && columnName.contains(":")){
+ if (columnName != null && columnName.contains(":")) {
columnNames = columnName.split(":");
}
String[] values = null;
- if(value != null && value.contains(":")){
+ if (value != null && value.contains(":")) {
values = value.split(":");
}
try {
Criteria cr = session.createCriteria(className);
- if(columnNames != null && values != null && columnNames.length == values.length){
- for (int i = 0; i < columnNames.length; i++){
- cr.add(Restrictions.eq(columnNames[i],values[i]));
+ if (columnNames != null && values != null && columnNames.length == values.length) {
+ for (int i = 0; i < columnNames.length; i++) {
+ cr.add(Restrictions.eq(columnNames[i], values[i]));
}
- }else{
- cr.add(Restrictions.eq(columnName,value));
+ } else {
+ cr.add(Restrictions.eq(columnName, value));
}
data = cr.list();
tx.commit();
} catch (Exception e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying for Duplicate Entries for Table"+e + className);
- }finally{
- try{
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying for Duplicate Entries for Table"
+ + e + className);
+ } finally {
+ try {
session.close();
- }catch(Exception e1){
+ } catch (Exception e1) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
@@ -223,13 +226,13 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
Transaction tx = session.beginTransaction();
List<PolicyRoles> rolesData = null;
try {
- Criteria cr = session.createCriteria(PolicyRoles.class);
- Disjunction disjunction = Restrictions.disjunction();
- Conjunction conjunction1 = Restrictions.conjunction();
+ final Criteria cr = session.createCriteria(PolicyRoles.class);
+ final Disjunction disjunction = Restrictions.disjunction();
+ Conjunction conjunction1 = Restrictions.conjunction();
conjunction1.add(Restrictions.eq("role", "admin"));
- Conjunction conjunction2 = Restrictions.conjunction();
+ Conjunction conjunction2 = Restrictions.conjunction();
conjunction2.add(Restrictions.eq("role", "editor"));
- Conjunction conjunction3 = Restrictions.conjunction();
+ Conjunction conjunction3 = Restrictions.conjunction();
conjunction3.add(Restrictions.eq("role", "guest"));
disjunction.add(conjunction1);
disjunction.add(conjunction2);
@@ -237,11 +240,11 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
rolesData = cr.add(disjunction).list();
tx.commit();
} catch (Exception e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyRoles Table"+e);
- }finally{
- try{
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyRoles Table" + e);
+ } finally {
+ try {
session.close();
- }catch(Exception e1){
+ } catch (Exception e1) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
@@ -270,10 +273,9 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
try {
Query hbquery = session.createQuery(query);
for (Map.Entry<String, Object> paramPair : params.entrySet()) {
- if(paramPair.getValue() instanceof java.lang.Long){
+ if (paramPair.getValue() instanceof java.lang.Long) {
hbquery.setLong(paramPair.getKey(), (long) paramPair.getValue());
- }
- else{
+ } else {
hbquery.setParameter(paramPair.getKey(), paramPair.getValue());
}
}
@@ -282,10 +284,10 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + e);
throw e;
- }finally{
- try{
+ } finally {
+ try {
session.close();
- }catch(HibernateException e1){
+ } catch (HibernateException e1) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
@@ -301,23 +303,23 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
Object data = null;
try {
Criteria cr = session.createCriteria(className);
- if(columnName.contains(":") && key.contains(":")){
+ if (columnName.contains(":") && key.contains(":")) {
String[] columns = columnName.split(":");
String[] keys = key.split(":");
- for(int i=0; i < columns.length; i++){
+ for (int i = 0; i < columns.length; i++) {
cr.add(Restrictions.eq(columns[i], keys[i]));
}
- }else{
+ } else {
cr.add(Restrictions.eq(columnName, key));
}
data = cr.list().get(0);
tx.commit();
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + e);
- }finally{
- try{
+ } finally {
+ try {
session.close();
- }catch(Exception e1){
+ } catch (Exception e1) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
@@ -346,11 +348,11 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
hbquery.executeUpdate();
tx.commit();
} catch (Exception e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating Database Table"+e);
- }finally{
- try{
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating Database Table" + e);
+ } finally {
+ try {
session.close();
- }catch(Exception e1){
+ } catch (Exception e1) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
@@ -363,16 +365,16 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
public List<String> getDataByColumn(Class className, String columnName) {
Session session = sessionfactory.openSession();
List<String> data = null;
- try{
+ try {
Criteria cr = session.createCriteria(className);
cr.setProjection(Projections.property(columnName));
data = cr.list();
- }catch(Exception e){
+ } catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + e);
- }finally{
- try{
+ } finally {
+ try {
session.close();
- }catch(Exception e){
+ } catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e);
}
}
@@ -391,24 +393,24 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
Disjunction disjunction = Restrictions.disjunction();
List<Conjunction> conjunctionList = new ArrayList<>();
String[] columNames = columnName.split(":");
- for(int i =0; i < data.size(); i++){
+ for (int i = 0; i < data.size(); i++) {
String[] entiySplit = data.get(i).split(":");
Conjunction conjunction = Restrictions.conjunction();
conjunction.add(Restrictions.eq(columNames[0], entiySplit[0]));
conjunction.add(Restrictions.eq(columNames[1], entiySplit[1]));
conjunctionList.add(conjunction);
}
- for(int j =0 ; j < conjunctionList.size(); j++){
+ for (int j = 0; j < conjunctionList.size(); j++) {
disjunction.add(conjunctionList.get(j));
}
entityData = cr.add(disjunction).list();
tx.commit();
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + className + e);
- }finally{
- try{
+ } finally {
+ try {
session.close();
- }catch(Exception e1){
+ } catch (Exception e1) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionBodyEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionBodyEntity.java
index 16f6e7347..c0c009fb9 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionBodyEntity.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionBodyEntity.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,12 +18,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
-/*
- */
+
+import com.fasterxml.jackson.annotation.JsonBackReference;
+
import java.io.Serializable;
import java.util.Date;
-import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -38,190 +40,80 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
/*
* The Entity class to persist a policy object Action Body
*/
-
-
-import com.fasterxml.jackson.annotation.JsonBackReference;
-
+// @formatter:off
@Entity
-@Table(name="ActionBodyEntity")
-@NamedQueries({
- @NamedQuery(name=" ActionBodyEntity.findAll", query="SELECT e FROM ActionBodyEntity e "),
- @NamedQuery(name="ActionBodyEntity.deleteAll", query="DELETE FROM ActionBodyEntity WHERE 1=1")
-})
+@Table(name = "ActionBodyEntity")
+@NamedQueries(
+ {
+ @NamedQuery(name = " ActionBodyEntity.findAll", query = "SELECT e FROM ActionBodyEntity e "),
+ @NamedQuery(name = "ActionBodyEntity.deleteAll", query = "DELETE FROM ActionBodyEntity WHERE 1=1")
+ }
+)
+@Getter
+@Setter
+@NoArgsConstructor
+// @foramtter:on
public class ActionBodyEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="actionBodyId")
+ @Column(name = "actionBodyId")
@JsonBackReference
private long actionBodyId;
- @Column(name="actionBodyName", nullable=false, length=255)
+ @Column(name = "actionBodyName", nullable = false, length = 255)
private String actionBodyName = "";
@Version
- @Column(name="version")
+ @Column(name = "version")
private int version;
@Lob
- @Column(name="actionBody", nullable=false, columnDefinition="TEXT")
+ @Column(name = "actionBody", nullable = false, columnDefinition = "TEXT")
private String actionBody = "NoBody";
- @Column(name="created_by", nullable=false, length=255)
+ @Column(name = "created_by", nullable = false, length = 255)
private String createdBy = "guest";
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
- @Column(name="modified_by", nullable=false, length=255)
+ @Column(name = "modified_by", nullable = false, length = 255)
private String modifiedBy = "guest";
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
- @Column(name="deleted", nullable=false)
+ @Column(name = "deleted", nullable = false)
private boolean deleted = false;
- public ActionBodyEntity() {
- //An empty constructor
- }
-
+ /**
+ * Called before an instance is persisted.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Called before an instance is updated.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
- /**
- * @return the configurationDataId
- */
- public long getActionBodyId() {
- return actionBodyId;
- }
- /**
- * @param name the configuration body name to set
- */
- public void setActionBodyName(String name) {
- this.actionBodyName = name;
- }
- public String getActionBodyName(){
- return this.actionBodyName;
- }
-
- /**
- * @return the actionBody
- */
- public String getActionBody() {
- return actionBody;
- }
- /**
- * @param body the configBody to set
- */
- public void setActionBody(String body) {
- this.actionBody = body;
- }
- /**
- * @return the createdBy
- */
- public String getCreatedBy() {
- return createdBy;
- }
- /**
- * @param createdBy the createdBy to set
- */
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- /**
- * @return the modifiedBy
- */
- public String getModifiedBy() {
- return modifiedBy;
- }
- /**
- * @param modifiedBy the modifiedBy to set
- */
- public void setModifiedBy(String modifiedBy) {
- this.modifiedBy = modifiedBy;
- }
- /**
- * @return the modifiedDate
- */
- public Date getModifiedDate() {
- return modifiedDate;
- }
- /**
- * @param modifiedDate the modifiedDate to set
- */
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
- /**
- * @return the version
- */
- public int getVersion() {
- return version;
- }
- /**
- * @return the createdDate
- */
- public Date getCreatedDate() {
- return createdDate;
- }
-
- /**
- * @return the deleted
- */
- public boolean isDeleted() {
- return deleted;
- }
-
- /**
- * @param deleted the deleted to set
- */
- public void setDeleted(boolean deleted) {
- this.deleted = deleted;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(actionBodyId, actionBodyName, version, actionBody,
- createdBy, createdDate, modifiedBy, modifiedDate, deleted);
- }
-
- @Override
- public boolean equals(Object obj) {
- if(obj == null){
- return false;
- }
- if(obj == this){
- return true;
- }
- if(!(obj instanceof ActionBodyEntity)){
- return false;
- }
-
- return actionBodyId == ((ActionBodyEntity) obj).actionBodyId &&
- actionBodyName.equals(((ActionBodyEntity) obj).actionBodyName) &&
- version == ((ActionBodyEntity) obj).version &&
- actionBody.equals(((ActionBodyEntity) obj).actionBody) &&
- createdBy.equals(((ActionBodyEntity) obj).createdBy) &&
- createdDate.equals(((ActionBodyEntity) obj).createdDate) &&
- modifiedBy.equals(((ActionBodyEntity) obj).modifiedBy) &&
- modifiedDate.equals(((ActionBodyEntity) obj).modifiedDate) &&
- deleted == ((ActionBodyEntity) obj).deleted;
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionList.java
index d3e870bff..e72c4022d 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionList.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionList.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,47 +32,26 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
+
@Entity
-@Table(name="actionlist")
-@NamedQuery(name="ActionList.findAll", query="SELECT e FROM ActionList e ")
+@Table(name = "actionlist")
+@NamedQuery(name = "ActionList.findAll", query = "SELECT e FROM ActionList e ")
+@Getter
+@Setter
public class ActionList implements Serializable {
private static final long serialVersionUID = 1L;
-
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="actionname", nullable=false)
+ @Column(name = "actionname", nullable = false)
@OrderBy("asc")
private String actionName;
- @Column(name="description")
+ @Column(name = "description")
private String description;
-
- public String getActionName() {
- return this.actionName;
- }
-
- public void setActionName(String actionName) {
- this.actionName = actionName;
-
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionPolicyDict.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionPolicyDict.java
index e9a29446d..7847585c3 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionPolicyDict.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionPolicyDict.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,9 +19,8 @@
* ============LICENSE_END=========================================================
*/
-/*
- */
package org.onap.policy.rest.jpa;
+
import java.io.Serializable;
import java.util.Date;
@@ -40,150 +40,85 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
+// @formatter:off
@Entity
-@Table(name="ActionPolicyDict")
-@NamedQueries({
- @NamedQuery(name="ActionPolicyDict.findAll", query="SELECT e FROM ActionPolicyDict e")
-})
+@Table(name = "ActionPolicyDict")
+@NamedQueries(
+ {
+ @NamedQuery(name = "ActionPolicyDict.findAll", query = "SELECT e FROM ActionPolicyDict e")
+ }
+)
+@Getter
+@Setter
+//@formatter:on
public class ActionPolicyDict implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="ATTRIBUTE_NAME", nullable=false)
+ @Column(name = "ATTRIBUTE_NAME", nullable = false)
@OrderBy("asc")
private String attributeName;
- @Column(name="Type", nullable=false)
+ @Column(name = "Type", nullable = false)
@OrderBy("asc")
private String type;
- @Column(name="URL", nullable=false)
+ @Column(name = "URL", nullable = false)
@OrderBy("asc")
private String url;
- @Column(name="Method", nullable=false)
+ @Column(name = "Method", nullable = false)
@OrderBy("asc")
private String method;
- @Column(name="Headers", nullable=true)
+ @Column(name = "Headers", nullable = true)
@OrderBy("asc")
private String header;
- @Column(name="Body", nullable=true)
+ @Column(name = "Body", nullable = true)
@OrderBy("asc")
private String body;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
- @Column(name="description", nullable=true, length=2048)
+ @Column(name = "description", nullable = true, length = 2048)
private String description;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
+ /**
+ * Called before an instance is persisted.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+
+ /**
+ * Called before an instance is updated.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
- public int getId() {
- return this.id;
- }
- public void setId(int id) {
- this.id = id;
- }
-
- public Date getCreatedDate() {
- return this.createdDate;
- }
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
- public String getDescription() {
- return this.description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getModifiedDate() {
- return this.modifiedDate;
- }
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
- public String getType() {
- return type;
- }
- public void setType(String type) {
- this.type = type;
- }
-
- public String getUrl() {
- return url;
- }
- public void setUrl(String url) {
- this.url = url;
- }
- public String getMethod() {
- return method;
- }
- public void setMethod(String method) {
- this.method = method;
- }
- public String getHeader() {
- return header;
- }
- public void setHeader(String header) {
- this.header = header;
- }
-
- public String getBody() {
- return body;
- }
- public void setBody(String body) {
- this.body = body;
- }
- public String getAttributeName() {
- return attributeName;
- }
- public void setAttributeName(String attributeName) {
- this.attributeName = attributeName;
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AddressGroup.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AddressGroup.java
index c71969a8b..3d2c69aa0 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AddressGroup.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AddressGroup.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,59 +32,62 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * The Class AddressGroup is a JPA class for address groups.
+ */
@Entity
-@Table(name="AddressGroup")
-@NamedQuery(name="AddressGroup.findAll", query="SELECT e FROM AddressGroup e ")
+@Table(name = "AddressGroup")
+@NamedQuery(name = "AddressGroup.findAll", query = "SELECT e FROM AddressGroup e ")
+
+@Getter
+@Setter
+@ToString
public class AddressGroup implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String name;
- @Column(name="prefixlist")
+ @Column(name = "prefixlist")
private String prefixList;
-
- @Column(name="description")
+ @Column(name = "description")
private String description;
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
+ /**
+ * Get the group name.
+ *
+ * @return the group name
+ */
public String getGroupName() {
- return this.name;
+ return name;
}
- public void setGroupName(String serviceName) {
- this.name = serviceName;
-
- }
-
- public String getPrefixList() {
- return this.prefixList;
+ /**
+ * Set the group name.
+ *
+ * @param groupName the group name
+ */
+ public void setGroupName(final String groupName) {
+ this.name = groupName;
}
+ /**
+ * Sets the service list.
+ *
+ * @param prefixList the new service list
+ */
public void setServiceList(String prefixList) {
this.prefixList = prefixList;
-
- }
- public String getDescription() {
- return this.description;
}
-
- public void setDescription(String description) {
- this.description = description;
-
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Attribute.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Attribute.java
index 3389d391e..4b8059e9c 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Attribute.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Attribute.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +21,8 @@
package org.onap.policy.rest.jpa;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
@@ -43,77 +46,81 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
-import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
/**
* The persistent class for the Attribute database table.
- *
+ *
*/
@Entity
-@Table(name="Attribute")
-@NamedQuery(name="Attribute.findAll", query="SELECT a FROM Attribute a order by a.priority asc, a.xacmlId asc")
+@Table(name = "Attribute")
+@NamedQuery(name = "Attribute.findAll", query = "SELECT a FROM Attribute a order by a.priority asc, a.xacmlId asc")
+
+@Getter
+@Setter
+@NoArgsConstructor
public class Attribute implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- //bi-directional many-to-one association to Category
+ // bi-directional many-to-one association to Category
@ManyToOne
- @JoinColumn(name="constraint_type", nullable=true)
+ @JoinColumn(name = "constraint_type", nullable = true)
@JsonIgnore
private ConstraintType constraintType;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
- @Column(name="description", nullable=true, length=2048)
+ @Column(name = "description", nullable = true, length = 2048)
private String description;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
- @Column(name="PRIORITY", nullable=true)
+ @Column(name = "PRIORITY", nullable = true)
@OrderBy("asc")
private String priority;
- @Column(name="ATTRIBUTE_VALUE", nullable=true)
+ @Column(name = "ATTRIBUTE_VALUE", nullable = true)
@OrderBy("asc")
private String attributeValue;
- @Column(name="xacml_id", unique = true, nullable=false)
+ @Column(name = "xacml_id", unique = true, nullable = false)
@OrderBy("asc")
private String xacmlId = "urn";
- //bi-directional many-to-one association to ConstraintValue
- @OneToMany(mappedBy="attribute", orphanRemoval=true, cascade=CascadeType.REMOVE)
+ // bi-directional many-to-one association to ConstraintValue
+ @OneToMany(mappedBy = "attribute", orphanRemoval = true, cascade = CascadeType.REMOVE)
@JsonIgnore
private Set<ConstraintValue> constraintValues = new HashSet<>();
- //bi-directional many-to-one association to Category
+ // bi-directional many-to-one association to Category
@ManyToOne
- @JoinColumn(name="category")
+ @JoinColumn(name = "category")
@JsonIgnore
private Category categoryBean;
- //bi-directional many-to-one association to Datatype
+ // bi-directional many-to-one association to Datatype
@ManyToOne
- @JoinColumn(name="datatype")
+ @JoinColumn(name = "datatype")
private Datatype datatypeBean;
- @Column(name="is_designator", nullable=false)
+ @Column(name = "is_designator", nullable = false)
@JsonIgnore
private char isDesignator = '1';
- @Column(name="selector_path", nullable=true, length=2048)
+ @Column(name = "selector_path", nullable = true, length = 2048)
private String selectorPath;
-
-
@Transient
private String issuer = null;
@@ -121,38 +128,27 @@ public class Attribute implements Serializable {
private boolean mustBePresent = false;
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
-
- public Attribute() {
- //An empty constructor
- }
-
+ /**
+ * Constructor with domain.
+ *
+ * @param domain the domain to use to construct the object
+ */
public Attribute(String domain) {
this.xacmlId = domain;
}
+ /**
+ * Copy constructor.
+ *
+ * @param copy the copy to copy from
+ */
public Attribute(Attribute copy) {
this(copy.getXacmlId() + ":(0)");
this.constraintType = copy.getConstraintType();
@@ -166,78 +162,45 @@ public class Attribute implements Serializable {
}
}
+ /**
+ * Called before an instance is persisted.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Called before an instance is updated.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public ConstraintType getConstraintType() {
- return this.constraintType;
- }
-
- public void setConstraintType(ConstraintType constraintType) {
- this.constraintType = constraintType;
- }
-
- public Date getCreatedDate() {
- return this.createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getModifiedDate() {
- return this.modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
- public String getXacmlId() {
- return this.xacmlId;
- }
-
-
- public void setXacmlId(String xacmlId) {
- this.xacmlId = xacmlId;
- }
-
- public Set<ConstraintValue> getConstraintValues() {
- return this.constraintValues;
- }
-
+ /**
+ * Sets the constraint values.
+ *
+ * @param constraintValues the new constraint values
+ */
public void setConstraintValues(Set<ConstraintValue> constraintValues) {
+ if (this.constraintValues == null) {
+ this.constraintValues = new HashSet<>();
+ }
for (ConstraintValue value : this.constraintValues) {
value.setAttribute(this);
}
this.constraintValues = constraintValues;
}
+ /**
+ * Adds the constraint value.
+ *
+ * @param constraintValue the constraint value
+ * @return the constraint value
+ */
public ConstraintValue addConstraintValue(ConstraintValue constraintValue) {
if (this.constraintValues == null) {
this.constraintValues = new HashSet<>();
@@ -248,6 +211,12 @@ public class Attribute implements Serializable {
return constraintValue;
}
+ /**
+ * Removes the constraint value.
+ *
+ * @param constraintValue the constraint value
+ * @return the constraint value
+ */
public ConstraintValue removeConstraintValue(ConstraintValue constraintValue) {
this.constraintValues.remove(constraintValue);
constraintValue.setAttribute(null);
@@ -255,6 +224,9 @@ public class Attribute implements Serializable {
return constraintValue;
}
+ /**
+ * Removes the all constraint values.
+ */
public void removeAllConstraintValues() {
if (this.constraintValues == null) {
return;
@@ -265,63 +237,61 @@ public class Attribute implements Serializable {
this.constraintValues.clear();
}
- public Category getCategoryBean() {
- return this.categoryBean;
- }
-
- public void setCategoryBean(Category categoryBean) {
- this.categoryBean = categoryBean;
- }
-
- public Datatype getDatatypeBean() {
- return this.datatypeBean;
- }
-
- public void setDatatypeBean(Datatype datatypeBean) {
- this.datatypeBean = datatypeBean;
- }
-
- public char getIsDesignator() {
- return this.isDesignator;
- }
-
- public void setIsDesignator(char is) {
- this.isDesignator = is;
- }
-
- public String getSelectorPath() {
- return this.selectorPath;
- }
-
- public void setSelectorPath(String path) {
- this.selectorPath = path;
- }
-
+ /**
+ * Gets the issuer.
+ *
+ * @return the issuer
+ */
@Transient
public String getIssuer() {
return issuer;
}
+ /**
+ * Sets the issuer.
+ *
+ * @param issuer the new issuer
+ */
@Transient
public void setIssuer(String issuer) {
this.issuer = issuer;
}
+ /**
+ * Checks if is must be present.
+ *
+ * @return true, if is must be present
+ */
@Transient
public boolean isMustBePresent() {
return mustBePresent;
}
+ /**
+ * Sets the must be present.
+ *
+ * @param mustBePresent the new must be present
+ */
@Transient
public void setMustBePresent(boolean mustBePresent) {
this.mustBePresent = mustBePresent;
}
+ /**
+ * Checks if is designator.
+ *
+ * @return true, if is designator
+ */
@Transient
public boolean isDesignator() {
return this.isDesignator == '1';
}
+ /**
+ * Sets the checks if is designator.
+ *
+ * @param is the new checks if is designator
+ */
@Transient
public void setIsDesignator(boolean is) {
if (is) {
@@ -330,21 +300,4 @@ public class Attribute implements Serializable {
this.isDesignator = '0';
}
}
-
- public String getPriority() {
- return priority;
- }
-
- public void setPriority(String priority) {
- this.priority = priority;
- }
-
- public String getAttributeValue() {
- return attributeValue;
- }
-
- public void setAttributeValue(String attributeValue) {
- this.attributeValue = attributeValue;
- }
}
-
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AttributeAssignment.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AttributeAssignment.java
index d05b2d4af..8a40f4cf3 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AttributeAssignment.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AttributeAssignment.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
import java.io.Serializable;
@@ -30,14 +32,20 @@ import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
/**
* The persistent class for the ObadviceExpressions database table.
- *
+ *
*/
@Entity
-@Table(name="AttributeAssignment")
-@NamedQuery(name="AttributeAssignment.findAll", query="SELECT a FROM AttributeAssignment a")
+@Table(name = "AttributeAssignment")
+@NamedQuery(name = "AttributeAssignment.findAll", query = "SELECT a FROM AttributeAssignment a")
+@Getter
+@Setter
+@NoArgsConstructor
public class AttributeAssignment implements Serializable {
private static final long serialVersionUID = 1L;
@@ -50,45 +58,17 @@ public class AttributeAssignment implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="attribute_id")
+ @Column(name = "attribute_id")
private int attributeId;
- //bi-directional many-to-one association to Obadvice
- @Column(name="expression", nullable=false)
+ // bi-directional many-to-one association to Obadvice
+ @Column(name = "expression", nullable = false)
private String expression;
- //bi-directional many-to-one association to Obadvice
+ // bi-directional many-to-one association to Obadvice
@ManyToOne
private Obadvice obadvice;
-
- public AttributeAssignment() {
- //An empty constructor
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public int getAttributeId() {
- return this.attributeId;
- }
-
- public void setAttributeId(int attributeId) {
- this.attributeId = attributeId;
- }
-
- public String getExpression() {
- return expression;
- }
-
- public void setExpression(String expression) {
- this.expression = expression;
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSController.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsController.java
index af2b11a20..7eaf075fb 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSController.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsController.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,117 +39,66 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * The Class BRMSController.
+ */
@Entity
-@Table(name="BRMSController")
-@NamedQuery(name="BRMSController.findAll", query="SELECT b from BRMSController b ")
-public class BRMSController implements Serializable{
+@Table(name = "BrmsController")
+@NamedQuery(name = "BrmsController.findAll", query = "SELECT b from BrmsController b ")
+@Getter
+@Setter
+public class BrmsController implements Serializable {
private static final long serialVersionUID = -8666947569754164177L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
-
- @Column(name="controller_name", nullable=false, length=1024, unique=true)
+
+ @Column(name = "controller_name", nullable = false, length = 1024, unique = true)
@OrderBy("asc")
private String controllerName;
-
- @Column(name="description", nullable=true, length=1024)
+
+ @Column(name = "description", nullable = true, length = 1024)
private String description;
-
+
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
-
+
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
-
+
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
-
+
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
-
- @Column(name="controller", nullable=false)
+
+ @Column(name = "controller", nullable = false)
private String controller;
-
+
+ /**
+ * Called before persisting an instance.
+ */
@PrePersist
public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
-
+
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public Date getModifiedDate() {
- return modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
- public String getController() {
- return controller;
- }
-
- public void setController(String controller) {
- this.controller = controller;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getControllerName() {
- return controllerName;
- }
-
- public void setControllerName(String controllerName) {
- this.controllerName = controllerName;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSDependency.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsDependency.java
index d06ec5d92..1b6c89f89 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSDependency.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsDependency.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,116 +39,66 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * The Class BrmsDependency.
+ */
@Entity
-@Table(name="BRMSDependency")
-@NamedQuery(name="BRMSDependency.findAll", query="SELECT b from BRMSDependency b ")
-public class BRMSDependency implements Serializable{
+@Table(name = "BrmsDependency")
+@NamedQuery(name = "BrmsDependency.findAll", query = "SELECT b from BrmsDependency b ")
+@Getter
+@Setter
+public class BrmsDependency implements Serializable {
private static final long serialVersionUID = -7005622785653160761L;
-
+
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
-
- @Column(name="dependency_name", nullable=false, length=1024, unique=true)
+
+ @Column(name = "dependency_name", nullable = false, length = 1024, unique = true)
@OrderBy("asc")
private String dependencyName;
- @Column(name="description", nullable=true, length=1024)
+ @Column(name = "description", nullable = true, length = 1024)
private String description;
-
+
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
-
+
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
-
+
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
-
+
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
-
- @Column(name="dependency", nullable=false)
+
+ @Column(name = "dependency", nullable = false)
private String dependency;
-
+
+ /**
+ * Pre persist.
+ */
@PrePersist
public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
-
+
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public Date getModifiedDate() {
- return modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
- public String getDependency() {
- return dependency;
- }
-
- public void setDependency(String dependency) {
- this.dependency = dependency;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getDependencyName() {
- return dependencyName;
- }
-
- public void setDependencyName(String dependencyName) {
- this.dependencyName = dependencyName;
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSParamTemplate.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsParamTemplate.java
index 7e47c0fb3..e3531fedd 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSParamTemplate.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsParamTemplate.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,98 +39,48 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
-import org.onap.policy.rest.jpa.UserInfo;
+import lombok.Getter;
+import lombok.Setter;
-/*
- * JPA for the BRMS Param Template.
- *
- * @version: 0.1
+/**
+ * JPA for the BRMS Param Template.
*/
-
@Entity
-@Table(name="BRMSParamTemplate")
-@NamedQuery(name="BRMSParamTemplate.findAll", query="SELECT b FROM BRMSParamTemplate b ")
-public class BRMSParamTemplate implements Serializable{
+@Table(name = "BrmsParamTemplate")
+@NamedQuery(name = "BrmsParamTemplate.findAll", query = "SELECT b FROM BrmsParamTemplate b ")
+@Getter
+@Setter
+public class BrmsParamTemplate implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="param_template_name", nullable=false, unique=true)
+ @Column(name = "param_template_name", nullable = false, unique = true)
@OrderBy("asc")
private String ruleName;
@Lob
- @Column(name="rule",nullable=false)
+ @Column(name = "rule", nullable = false)
private String rule;
- @Column(name="description", nullable=true, length=2048)
+ @Column(name = "description", nullable = true, length = 2048)
private String description;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
-
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
}
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
-
- public Date getCreatedDate() {
- return this.createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getRule(){
- return this.rule;
- }
-
- public void setRule(String rule){
- this.rule = rule;
- }
-
- public String getRuleName(){
- return this.ruleName;
- }
-
- public void setRuleName(String ruleName){
- this.ruleName = ruleName;
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java
index f3874a480..d417b37db 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java
@@ -4,13 +4,14 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,6 +22,11 @@
package org.onap.policy.rest.jpa;
+import com.att.research.xacml.api.Identifier;
+import com.att.research.xacml.api.XACML3;
+import com.att.research.xacml.std.IdentifierImpl;
+import com.fasterxml.jackson.annotation.JsonBackReference;
+
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@@ -35,19 +41,20 @@ import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
-import com.att.research.xacml.api.Identifier;
-import com.att.research.xacml.api.XACML3;
-import com.att.research.xacml.std.IdentifierImpl;
-import com.fasterxml.jackson.annotation.JsonBackReference;
-
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
/**
* The persistent class for the Categories database table.
- *
+ *
*/
@Entity
-@Table(name="Category")
-@NamedQuery(name="Category.findAll", query="SELECT c FROM Category c")
+@Table(name = "Category")
+@NamedQuery(name = "Category.findAll", query = "SELECT c FROM Category c")
+@Getter
+@Setter
+@ToString
public class Category implements Serializable {
private static final long serialVersionUID = 1L;
@@ -56,26 +63,29 @@ public class Category implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="grouping", nullable=false, length=64)
+ @Column(name = "grouping", nullable = false, length = 64)
private String grouping;
- @Column(name="is_standard", nullable=false)
+ @Column(name = "is_standard", nullable = false)
private char isStandard;
- @Column(name="xacml_id", nullable=false, unique=true, length=255)
+ @Column(name = "xacml_id", nullable = false, unique = true, length = 255)
private String xacmlId;
- @Column(name="short_name", nullable=false, length=64)
+ @Column(name = "short_name", nullable = false, length = 64)
private String shortName;
- //bi-directional many-to-one association to Attribute
- @OneToMany(mappedBy="categoryBean")
+ // bi-directional many-to-one association to Attribute
+ @OneToMany(mappedBy = "categoryBean")
@JsonBackReference
private Set<Attribute> attributes = new HashSet<>();
+ /**
+ * Instantiates a new category.
+ */
public Category() {
this.xacmlId = XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT.stringValue();
this.grouping = "subject";
@@ -83,6 +93,13 @@ public class Category implements Serializable {
this.shortName = "subject";
}
+ /**
+ * Instantiates a new category.
+ *
+ * @param cat the cat
+ * @param grouping the grouping
+ * @param isStandard the is standard
+ */
public Category(Identifier cat, String grouping, char isStandard) {
if (cat != null) {
this.xacmlId = cat.stringValue();
@@ -95,66 +112,41 @@ public class Category implements Serializable {
}
}
+ /**
+ * Instantiates a new category.
+ *
+ * @param cat the cat
+ * @param grouping the grouping
+ */
public Category(Identifier cat, String grouping) {
this(cat, grouping, Category.STANDARD);
}
+ /**
+ * Instantiates a new category.
+ *
+ * @param cat the cat
+ * @param standard the standard
+ */
public Category(Identifier cat, char standard) {
this(cat, null, standard);
}
+ /**
+ * Instantiates a new category.
+ *
+ * @param cat the cat
+ */
public Category(Identifier cat) {
this(cat, Category.STANDARD);
}
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getGrouping() {
- return this.grouping;
- }
-
- public void setGrouping(String grouping) {
- this.grouping = grouping;
- }
-
- public char getIsStandard() {
- return this.isStandard;
- }
-
- public void setIsStandard(char isStandard) {
- this.isStandard = isStandard;
- }
-
- public String getXacmlId() {
- return this.xacmlId;
- }
-
- public void setXacmlId(String xacmlId) {
- this.xacmlId = xacmlId;
- }
-
- public String getShortName() {
- return this.shortName;
- }
-
- public void setShortName(String shortName) {
- this.shortName = shortName;
- }
-
- public Set<Attribute> getAttributes() {
- return this.attributes;
- }
-
- public void setAttributes(Set<Attribute> attributes) {
- this.attributes = attributes;
- }
-
+ /**
+ * Adds the attribute.
+ *
+ * @param attribute the attribute
+ * @return the attribute
+ */
public Attribute addAttribute(Attribute attribute) {
getAttributes().add(attribute);
attribute.setCategoryBean(this);
@@ -162,6 +154,12 @@ public class Category implements Serializable {
return attribute;
}
+ /**
+ * Removes the attribute.
+ *
+ * @param attribute the attribute
+ * @return the attribute
+ */
public Attribute removeAttribute(Attribute attribute) {
getAttributes().remove(attribute);
attribute.setCategoryBean(null);
@@ -169,30 +167,41 @@ public class Category implements Serializable {
return attribute;
}
+ /**
+ * Checks if is standard.
+ *
+ * @return true, if is standard
+ */
@Transient
public boolean isStandard() {
return this.isStandard == Category.STANDARD;
}
+ /**
+ * Checks if is custom.
+ *
+ * @return true, if is custom
+ */
@Transient
public boolean isCustom() {
return this.isStandard == Category.CUSTOM;
}
+ /**
+ * Extract grouping.
+ *
+ * @param xacmlId the xacml id
+ * @return the string
+ */
@Transient
- public static String extractGrouping(String xacmlId) {
+ public static String extractGrouping(String xacmlId) {
if (xacmlId == null) {
return null;
}
String[] parts = xacmlId.split("[:]");
- if (xacmlId.matches(".*:attribute\\-category:.*")) {
- if (parts.length > 0) {
- return parts[parts.length - 1];
- }
- } else if (xacmlId.matches(".*:[a-zA-Z]+[\\-]category:.*")) {
- if (parts.length <= 0) {
- return null;
- }
+ if (xacmlId.matches(".*:attribute\\-category:.*")) {
+ return parts[parts.length - 1];
+ } else if (xacmlId.matches(".*:[a-zA-Z]+[\\-]category:.*")) {
for (String part : parts) {
int index = part.indexOf("-category");
if (index > 0) {
@@ -203,17 +212,13 @@ public class Category implements Serializable {
return null;
}
+ /**
+ * Gets the identifer.
+ *
+ * @return the identifer
+ */
@Transient
public Identifier getIdentifer() {
return new IdentifierImpl(this.xacmlId);
}
-
- @Transient
- @Override
- public String toString() {
- return "Category [id=" + id + ", grouping=" + grouping
- + ", isStandard=" + isStandard + ", xacmlId=" + xacmlId
- + ", attributes=" + attributes + "]";
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java
index cd2ea591d..41a2b2a56 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,11 +20,10 @@
*/
package org.onap.policy.rest.jpa;
-/*
- *
- */
+
import java.io.Serializable;
import java.util.Date;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -39,112 +39,70 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
+/**
+ * The Class ClosedLoopD2Services.
+ */
@Entity
@Table(name = "ClosedLoopD2Services")
-@NamedQuery(name="ClosedLoopD2Services.findAll", query="SELECT c FROM ClosedLoopD2Services c ")
-public class ClosedLoopD2Services implements Serializable{
+@NamedQuery(name = "ClosedLoopD2Services.findAll", query = "SELECT c FROM ClosedLoopD2Services c ")
+@Getter
+@Setter
+public class ClosedLoopD2Services implements Serializable {
private static final long serialVersionUID = 1L;
@Id
- @Column(name ="id")
+ @Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
- @Column(name="service_Name", nullable=false, unique=true)
+ @Column(name = "service_Name", nullable = false, unique = true)
@OrderBy("asc")
private String serviceName;
- @Column(name="description", nullable=true, length=2048)
+ @Column(name = "description", nullable = true, length = 2048)
private String description;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
+ /**
+ * Instantiates a new closed loop D 2 services.
+ */
public ClosedLoopD2Services() {
this.setModifiedDate(new Date());
}
-
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getServiceName() {
- return serviceName;
- }
-
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public Date getModifiedDate() {
- return modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopSite.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopSite.java
index 52b5a2a4a..fb220d7c0 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopSite.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopSite.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,11 +21,9 @@
package org.onap.policy.rest.jpa;
-/*
- *
- */
import java.io.Serializable;
import java.util.Date;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -40,113 +39,70 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
+/**
+ * The Class ClosedLoopSite.
+ */
@Entity
@Table(name = "ClosedLoopSite")
-@NamedQuery(name="ClosedLoopSite.findAll", query="SELECT c FROM ClosedLoopSite c ")
-public class ClosedLoopSite implements Serializable{
+@NamedQuery(name = "ClosedLoopSite.findAll", query = "SELECT c FROM ClosedLoopSite c ")
+@Getter
+@Setter
+public class ClosedLoopSite implements Serializable {
private static final long serialVersionUID = 1L;
-
@Id
- @Column(name ="id")
+ @Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
- @Column(name="site_Name", nullable=false, unique=true)
+ @Column(name = "site_Name", nullable = false, unique = true)
@OrderBy("asc")
private String siteName;
- @Column(name="description", nullable=true, length=2048)
+ @Column(name = "description", nullable = true, length = 2048)
private String description;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
+ /**
+ * Instantiates a new closed loop site.
+ */
public ClosedLoopSite() {
this.setModifiedDate(new Date());
}
-
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getSiteName() {
- return siteName;
- }
-
- public void setSiteName(String siteName) {
- this.siteName = siteName;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public Date getModifiedDate() {
- return modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoops.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoops.java
index 721a2c5f4..3b1be82cf 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoops.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoops.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -32,68 +33,38 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+// @formatter:off
@Entity
-@Table(name="ClosedLoops")
-@NamedQueries({
- @NamedQuery(name="ClosedLoops.findAll", query="SELECT e FROM ClosedLoops e"),
- @NamedQuery(name="ClosedLoops.deleteAll", query="DELETE FROM ClosedLoops WHERE 1=1")
-})
+@Table(name = "ClosedLoops")
+@NamedQueries(
+ {
+ @NamedQuery(name = "ClosedLoops.findAll", query = "SELECT e FROM ClosedLoops e"),
+ @NamedQuery(name = "ClosedLoops.deleteAll", query = "DELETE FROM ClosedLoops WHERE 1=1")
+ }
+)
+@Getter
+@Setter
+@NoArgsConstructor
+//@formatter:on
public class ClosedLoops implements Serializable {
-
- /**
- *
- */
private static final long serialVersionUID = -7796845092457926842L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="closedLoopControlName", nullable=false, length=255)
+ @Column(name = "closedLoopControlName", nullable = false, length = 255)
@OrderBy("asc")
private String closedLoopControlName;
- @Column(name="alarmConditions", nullable=true, length=255)
+ @Column(name = "alarmConditions", nullable = true, length = 255)
private String alarmConditions;
- @Column(name="yaml", nullable=true, length=1028)
+ @Column(name = "yaml", nullable = true, length = 1028)
private String yaml;
-
- public ClosedLoops() {
- //An empty constructor
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getClosedLoopControlName() {
- return closedLoopControlName;
- }
-
- public void setClosedLoopControlName(String closedLoopControlName) {
- this.closedLoopControlName = closedLoopControlName;
- }
-
- public String getAlarmConditions() {
- return alarmConditions;
- }
-
- public void setAlarmConditions(String alarmConditions) {
- this.alarmConditions = alarmConditions;
- }
-
- public String getYaml() {
- return yaml;
- }
-
- public void setYaml(String yaml) {
- this.yaml = yaml;
- }
-
} \ No newline at end of file
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConfigurationDataEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConfigurationDataEntity.java
index 7bb73f36a..f5ae1817b 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConfigurationDataEntity.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConfigurationDataEntity.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,11 +20,13 @@
*/
package org.onap.policy.rest.jpa;
+
+import com.fasterxml.jackson.annotation.JsonBackReference;
+
/*
*/
import java.io.Serializable;
import java.util.Date;
-import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -43,216 +46,87 @@ import javax.persistence.Version;
* The Entity class to persist a policy object configuration data
*/
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
-import com.fasterxml.jackson.annotation.JsonBackReference;
-
+/**
+ * The Class ConfigurationDataEntity.
+ */
+// @formatter:off
@Entity
-@Table(name="ConfigurationDataEntity")
-@NamedQueries({
- @NamedQuery(name="ConfigurationDataEntity.findAll", query="SELECT e FROM ConfigurationDataEntity e "),
- @NamedQuery(name="ConfigurationDataEntity.deleteAll", query="DELETE FROM ConfigurationDataEntity WHERE 1=1")
-})
+@Table(name = "ConfigurationDataEntity")
+@NamedQueries(
+ {
+ @NamedQuery(name = "ConfigurationDataEntity.findAll", query = "SELECT e FROM ConfigurationDataEntity e "),
+ @NamedQuery(name = "ConfigurationDataEntity.deleteAll", query = "DELETE FROM ConfigurationDataEntity WHERE 1=1")
+ }
+)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+//@formatter:on
public class ConfigurationDataEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="configurationDataId")
+ @Column(name = "configurationDataId")
@JsonBackReference
private long configurationDataId;
- @Column(name="configurationName", nullable=false, length=255)
+ @Column(name = "configurationName", nullable = false, length = 255)
private String configurationName = "";
@Version
- @Column(name="version")
+ @Column(name = "version")
private int version;
- @Column(name="configType", nullable=false, length=255)
+ @Column(name = "configType", nullable = false, length = 255)
private String configType = "NoType";
@Lob
- @Column(name="configBody", nullable=false, columnDefinition="TEXT")
+ @Column(name = "configBody", nullable = false, columnDefinition = "TEXT")
private String configBody = "NoBody";
- @Column(name="created_by", nullable=false, length=255)
+ @Column(name = "created_by", nullable = false, length = 255)
private String createdBy = "guest";
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
- @Column(name="description", nullable=false, length=2048)
+ @Column(name = "description", nullable = false, length = 2048)
private String description = "NoDescription";
- @Column(name="modified_by", nullable=false, length=255)
+ @Column(name = "modified_by", nullable = false, length = 255)
private String modifiedBy = "guest";
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
- @Column(name="deleted", nullable=false)
+ @Column(name = "deleted", nullable = false)
private boolean deleted = false;
- public ConfigurationDataEntity() {
- //An empty constructor
- }
-
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
- /**
- * @return the configurationDataId
- */
- public long getConfigurationDataId() {
- return configurationDataId;
- }
- /**
- * @param configurationDataId the configurationDataId to set
- */
- public void setConfigurationName(String configurationName) {
- this.configurationName = configurationName;
- }
- public String getConfigurationName(){
- return this.configurationName;
- }
- /**
- * @return the configType
- */
- public String getConfigType() {
- return configType;
- }
- /**
- * @param configType the configType to set
- */
- public void setConfigType(String configType) {
- this.configType = configType;
- }
- /**
- * @return the configBody
- */
- public String getConfigBody() {
- return configBody;
- }
- /**
- * @param configBody the configBody to set
- */
- public void setConfigBody(String configBody) {
- this.configBody = configBody;
- }
- /**
- * @return the createdBy
- */
- public String getCreatedBy() {
- return createdBy;
- }
- /**
- * @param createdBy the createdBy to set
- */
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
- /**
- * @return the description
- */
- public String getDescription() {
- return description;
- }
- /**
- * @param description the description to set
- */
- public void setDescription(String description) {
- this.description = description;
- }
- /**
- * @return the modifiedBy
- */
- public String getModifiedBy() {
- return modifiedBy;
- }
- /**
- * @param modifiedBy the modifiedBy to set
- */
- public void setModifiedBy(String modifiedBy) {
- this.modifiedBy = modifiedBy;
- }
- /**
- * @return the modifiedDate
- */
- public Date getModifiedDate() {
- return modifiedDate;
- }
- /**
- * @param modifiedDate the modifiedDate to set
- */
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
- /**
- * @return the version
- */
- public int getVersion() {
- return version;
- }
- /**
- * @return the createdDate
- */
- public Date getCreatedDate() {
- return createdDate;
- }
-
- /**
- * @return the deleted
- */
- public boolean isDeleted() {
- return deleted;
- }
-
- /**
- * @param deleted the deleted to set
- */
- public void setDeleted(boolean deleted) {
- this.deleted = deleted;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(configurationDataId, configurationName, version, configType,
- configBody, createdBy, createdDate, description, modifiedBy, modifiedDate, deleted);
- }
-
- @Override
- public boolean equals(Object obj) {
- if(obj == null){
- return false;
- }
- if(obj == this){
- return true;
- }
- if(!(obj instanceof ConfigurationDataEntity)){
- return false;
- }
-
- return configurationDataId == ((ConfigurationDataEntity) obj).configurationDataId &&
- configurationName.equals(((ConfigurationDataEntity) obj).configurationName) &&
- version == ((ConfigurationDataEntity) obj).version &&
- configType.equals(((ConfigurationDataEntity) obj).configType) &&
- configBody.equals(((ConfigurationDataEntity) obj).configBody) &&
- createdBy.equals(((ConfigurationDataEntity) obj).createdBy) &&
- createdDate.equals(((ConfigurationDataEntity) obj).createdDate) &&
- description.equals(((ConfigurationDataEntity) obj).description) &&
- modifiedBy.equals(((ConfigurationDataEntity) obj).modifiedBy) &&
- modifiedDate.equals(((ConfigurationDataEntity) obj).modifiedDate) &&
- deleted == ((ConfigurationDataEntity) obj).deleted;
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java
index 606403318..10394ae6f 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,9 +36,16 @@ import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
@Entity
-@Table(name="ConstraintType")
-@NamedQuery(name="ConstraintType.findAll", query="SELECT a FROM ConstraintType a")
+@Table(name = "ConstraintType")
+@NamedQuery(name = "ConstraintType.findAll", query = "SELECT a FROM ConstraintType a")
+@Getter
+@Setter
+@NoArgsConstructor
public class ConstraintType implements Serializable {
private static final long serialVersionUID = 1L;
@@ -46,35 +54,37 @@ public class ConstraintType implements Serializable {
public static final String REGEXP_TYPE = "Regular Expression";
protected static final Map<String, String> defaults = new HashMap<>();
+
static {
- defaults.put(ENUMERATION_TYPE, "Enumerate a set of values that the attribute may be set to during policy creation.");
- defaults.put(RANGE_TYPE, "Set a range of min and/or max integer/double values the attribute can be set to during policy creation.");
- defaults.put(REGEXP_TYPE, "Define a regular expression the attribute must match against during policy creation.");
+ defaults.put(ENUMERATION_TYPE,
+ "Enumerate a set of values that the attribute may be set to during policy creation.");
+ defaults.put(RANGE_TYPE, "Set a range of min and/or max integer/double values "
+ + "the attribute can be set to during policy creation.");
+ defaults.put(REGEXP_TYPE,
+ "Define a regular expression the attribute must match against during policy creation.");
}
- private static final String[] RANGE_TYPES = {"minExclusive", "minInclusive", "maxExclusive", "maxInclusive"};
+
+ private static final String[] RANGE_TYPES =
+ { "minExclusive", "minInclusive", "maxExclusive", "maxInclusive" };
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="constraint_type", nullable=false, length=64)
- private String constraintType;
+ @Column(name = "constraint_type", nullable = false, length = 64)
+ private String theConstraintType;
- @Column(name="description", nullable=false, length=255)
+ @Column(name = "description", nullable = false, length = 255)
private String description;
- //bi-directional many-to-one association to Attribute
- @OneToMany(mappedBy="constraintType")
+ // bi-directional many-to-one association to Attribute
+ @OneToMany(mappedBy = "constraintType")
private Set<Attribute> attributes = new HashSet<>();
- public ConstraintType() {
- //An empty constructor
- }
-
public ConstraintType(String constraintType) {
this();
- this.constraintType = constraintType;
+ this.theConstraintType = constraintType;
}
public ConstraintType(String constraintType, String description) {
@@ -82,40 +92,15 @@ public class ConstraintType implements Serializable {
this.description = description;
}
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
+ public static String[] getRangeTypes() {
+ return RANGE_TYPES;
}
public String getConstraintType() {
- return constraintType;
+ return theConstraintType;
}
- public void setConstraintType(String constraintType) {
- this.constraintType = constraintType;
+ public void setConstraintType(final String theConstraintType) {
+ this.theConstraintType = theConstraintType;
}
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Set<Attribute> getAttributes() {
- return attributes;
- }
-
- public void setAttributes(Set<Attribute> attributes) {
- this.attributes = attributes;
- }
-
- public static String[] getRangeTypes() {
- return RANGE_TYPES;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintValue.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintValue.java
index 4c3bf6609..d4043962f 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintValue.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintValue.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -32,37 +33,39 @@ import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
/**
* The persistent class for the ConstraintValues database table.
- *
+ *
*/
@Entity
-@Table(name="ConstraintValues")
-@NamedQuery(name="ConstraintValue.findAll", query="SELECT c FROM ConstraintValue c")
+@Table(name = "ConstraintValues")
+@NamedQuery(name = "ConstraintValue.findAll", query = "SELECT c FROM ConstraintValue c")
+@Getter
+@Setter
+@NoArgsConstructor
public class ConstraintValue implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="property")
+ @Column(name = "property")
private String property;
- @Column(name="value")
+ @Column(name = "value")
private String value;
- //bi-directional many-to-one association to Attribute
+ // bi-directional many-to-one association to Attribute
@ManyToOne
- @JoinColumn(name="attribute_id")
+ @JoinColumn(name = "attribute_id")
private Attribute attribute;
- public ConstraintValue() {
- //An empty constructor
- }
-
public ConstraintValue(String property, String value) {
this.property = property;
this.value = value;
@@ -73,38 +76,6 @@ public class ConstraintValue implements Serializable {
this.value = value.getValue();
}
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getProperty() {
- return this.property;
- }
-
- public void setProperty(String property) {
- this.property = property;
- }
-
- public String getValue() {
- return this.value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public Attribute getAttribute() {
- return this.attribute;
- }
-
- public void setAttribute(Attribute attribute) {
- this.attribute = attribute;
- }
-
@Override
public ConstraintValue clone() {
ConstraintValue constraint = new ConstraintValue();
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DatabaseLockEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DatabaseLockEntity.java
index b82ec4882..0ea3b71c4 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DatabaseLockEntity.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DatabaseLockEntity.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -27,21 +28,18 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
@Entity
-@Table(name="DatabaseLockEntity")
+@Table(name = "DatabaseLockEntity")
+@Getter
+@Setter
+@NoArgsConstructor
public class DatabaseLockEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
- @Column(name="lock_key")
- private int lock_key = 1;
- public DatabaseLockEntity(){
- //An empty constructor
- }
- public int getKey(){
- return lock_key;
- }
- public void setKey(int key){
- this.lock_key = key;
- }
-
+ @Column(name = "lock_key")
+ private int key = 1;
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Datatype.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Datatype.java
index 4ab577976..9bb2340c7 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Datatype.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Datatype.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +21,12 @@
package org.onap.policy.rest.jpa;
+import com.att.research.xacml.api.Identifier;
+import com.att.research.xacml.api.XACML3;
+import com.att.research.xacml.std.IdentifierImpl;
+import com.fasterxml.jackson.annotation.JsonBackReference;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@@ -34,20 +41,20 @@ import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
-import com.att.research.xacml.api.Identifier;
-import com.att.research.xacml.api.XACML3;
-import com.att.research.xacml.std.IdentifierImpl;
-import com.fasterxml.jackson.annotation.JsonBackReference;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
/**
* The persistent class for the Datatype database table.
- *
+ *
*/
@Entity
-@Table(name="Datatype")
-@NamedQuery(name="Datatype.findAll", query="SELECT d FROM Datatype d")
+@Table(name = "Datatype")
+@NamedQuery(name = "Datatype.findAll", query = "SELECT d FROM Datatype d")
+@Getter
+@Setter
+@ToString
public class Datatype implements Serializable {
private static final long serialVersionUID = 1L;
@@ -56,39 +63,47 @@ public class Datatype implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="is_standard", nullable=false)
+ @Column(name = "is_standard", nullable = false)
private char isStandard;
- @Column(name="xacml_id", nullable=false, unique=true, length=255)
+ @Column(name = "xacml_id", nullable = false, unique = true, length = 255)
private String xacmlId;
- @Column(name="short_name", nullable=false, length=64)
+ @Column(name = "short_name", nullable = false, length = 64)
private String shortName;
- //bi-directional many-to-one association to Attribute
- @OneToMany(mappedBy="datatypeBean")
+ // bi-directional many-to-one association to Attribute
+ @OneToMany(mappedBy = "datatypeBean")
@JsonBackReference
private Set<Attribute> attributes = new HashSet<>();
- //bi-directional many-to-one association to Attribute
- @OneToMany(mappedBy="datatypeBean")
+ // bi-directional many-to-one association to Attribute
+ @OneToMany(mappedBy = "datatypeBean")
@JsonIgnore
private Set<FunctionDefinition> functions = new HashSet<>();
- //bi-directional many-to-one association to Attribute
- @OneToMany(mappedBy="datatypeBean")
+ // bi-directional many-to-one association to Attribute
+ @OneToMany(mappedBy = "datatypeBean")
@JsonIgnore
private Set<FunctionArgument> arguments = new HashSet<>();
+ /**
+ * Instantiates a new datatype.
+ */
public Datatype() {
this.xacmlId = XACML3.ID_DATATYPE_STRING.stringValue();
this.isStandard = Datatype.STANDARD;
}
-
+ /**
+ * Instantiates a new datatype.
+ *
+ * @param id the id
+ * @param dt the dt
+ */
public Datatype(int id, Datatype dt) {
this.id = id;
this.isStandard = dt.isStandard;
@@ -100,6 +115,12 @@ public class Datatype implements Serializable {
this.attributes = new HashSet<>();
}
+ /**
+ * Instantiates a new datatype.
+ *
+ * @param identifier the identifier
+ * @param standard the standard
+ */
public Datatype(Identifier identifier, char standard) {
if (identifier != null) {
this.xacmlId = identifier.stringValue();
@@ -108,50 +129,21 @@ public class Datatype implements Serializable {
this.isStandard = standard;
}
+ /**
+ * Instantiates a new datatype.
+ *
+ * @param identifier the identifier
+ */
public Datatype(Identifier identifier) {
this(identifier, Datatype.STANDARD);
}
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public char getIsStandard() {
- return this.isStandard;
- }
-
- public void setIsStandard(char isStandard) {
- this.isStandard = isStandard;
- }
-
- public String getXacmlId() {
- return this.xacmlId;
- }
-
- public void setXacmlId(String xacmlId) {
- this.xacmlId = xacmlId;
- }
-
- public String getShortName() {
- return shortName;
- }
-
- public void setShortName(String shortName) {
- this.shortName = shortName;
- }
-
- public Set<Attribute> getAttributes() {
- return this.attributes;
- }
-
- public void setAttributes(Set<Attribute> attributes) {
- this.attributes = attributes;
- }
-
+ /**
+ * Adds the attribute.
+ *
+ * @param attribute the attribute
+ * @return the attribute
+ */
public Attribute addAttribute(Attribute attribute) {
getAttributes().add(attribute);
attribute.setDatatypeBean(this);
@@ -159,6 +151,12 @@ public class Datatype implements Serializable {
return attribute;
}
+ /**
+ * Removes the attribute.
+ *
+ * @param attribute the attribute
+ * @return the attribute
+ */
public Attribute removeAttribute(Attribute attribute) {
getAttributes().remove(attribute);
attribute.setDatatypeBean(null);
@@ -166,21 +164,12 @@ public class Datatype implements Serializable {
return attribute;
}
- public Set<FunctionDefinition> getFunctions() {
- return this.functions;
- }
-
- public void setFunctions(Set<FunctionDefinition> functions) {
- this.functions = functions;
- }
-
- public FunctionDefinition addFunction(FunctionDefinition function) {
- getFunctions().add(function);
- function.setDatatypeBean(this);
-
- return function;
- }
-
+ /**
+ * Removes the attribute.
+ *
+ * @param function the function
+ * @return the function definition
+ */
public FunctionDefinition removeAttribute(FunctionDefinition function) {
getFunctions().remove(function);
function.setDatatypeBean(null);
@@ -188,14 +177,25 @@ public class Datatype implements Serializable {
return function;
}
- public Set<FunctionArgument> getArguments() {
- return this.arguments;
- }
+ /**
+ * Adds the function.
+ *
+ * @param function the function
+ * @return the function definition
+ */
+ public FunctionDefinition addFunction(FunctionDefinition function) {
+ getFunctions().add(function);
+ function.setDatatypeBean(this);
- public void setArguments(Set<FunctionArgument> argument) {
- this.arguments = argument;
+ return function;
}
+ /**
+ * Adds the argument.
+ *
+ * @param argument the argument
+ * @return the function argument
+ */
public FunctionArgument addArgument(FunctionArgument argument) {
getArguments().add(argument);
argument.setDatatypeBean(this);
@@ -203,6 +203,12 @@ public class Datatype implements Serializable {
return argument;
}
+ /**
+ * Removes the argument.
+ *
+ * @param argument the argument
+ * @return the function argument
+ */
public FunctionArgument removeArgument(FunctionArgument argument) {
getArguments().remove(argument);
argument.setDatatypeBean(null);
@@ -210,33 +216,43 @@ public class Datatype implements Serializable {
return argument;
}
+ /**
+ * Gets the identifer.
+ *
+ * @return the identifer
+ */
@Transient
public Identifier getIdentifer() {
return new IdentifierImpl(this.xacmlId);
}
+ /**
+ * Gets the identifer by short name.
+ *
+ * @return the identifer by short name
+ */
@Transient
public Identifier getIdentiferByShortName() {
return new IdentifierImpl(this.shortName);
}
+ /**
+ * Checks if is standard.
+ *
+ * @return true, if is standard
+ */
@Transient
public boolean isStandard() {
return this.isStandard == Datatype.STANDARD;
}
+ /**
+ * Checks if is custom.
+ *
+ * @return true, if is custom
+ */
@Transient
public boolean isCustom() {
return this.isStandard == Datatype.CUSTOM;
}
-
- @Transient
- @Override
- public String toString() {
- return "Datatype [id=" + id + ", isStandard=" + isStandard
- + ", xacmlId=" + xacmlId + ", shortName=" + shortName
- + ", attributes=" + attributes + ", functions=" + functions
- + ", arguments=" + arguments + "]";
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VMType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DcaeUsers.java
index 463e51709..3313d0310 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VMType.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DcaeUsers.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,47 +32,34 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
@Entity
-@Table(name="VMType")
-@NamedQuery(name="VMType.findAll", query="SELECT e FROM VMType e ")
-public class VMType implements Serializable {
+@Table(name = "DcaeUsers")
+@NamedQuery(name = "DcaeUsers.findAll", query = "SELECT e FROM DcaeUsers e ")
+@Getter
+@Setter
+public class DcaeUsers implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String name;
- @Column(name="description")
+ @Column(name = "description ")
private String description;
- public String getDescription() {
- return description;
+ public String getDescriptionValue() {
+ return this.description;
}
- public void setDescription(String description) {
+ public void setDescriptionValue(String description) {
this.description = description;
}
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
-
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEuuid.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DcaeUuid.java
index 5194093d1..990f396eb 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEuuid.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DcaeUuid.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,47 +32,26 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
@Entity
-@Table(name="DCAEuuid")
-@NamedQuery(name="DCAEuuid.findAll", query="SELECT e FROM DCAEuuid e ")
-public class DCAEuuid implements Serializable {
+@Table(name = "DcaeUuid")
+@NamedQuery(name = "DcaeUuid.findAll", query = "SELECT e FROM DcaeUuid e ")
+@Getter
+@Setter
+public class DcaeUuid implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String name;
- @Column(name="description")
+ @Column(name = "description")
private String description;
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
-
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DecisionSettings.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DecisionSettings.java
index e469c0b4f..bfa217674 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DecisionSettings.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DecisionSettings.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -39,40 +40,52 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
+import lombok.Getter;
+import lombok.Setter;
+/**
+ * The Class DecisionSettings.
+ */
+// @formatter:off
@Entity
-@Table(name="DecisionSettings")
-@NamedQuery(name="DecisionSettings.findAll", query="SELECT a FROM DecisionSettings a order by a.priority asc, a.xacmlId asc")
+@Table(name = "DecisionSettings")
+@NamedQuery(
+ name = "DecisionSettings.findAll",
+ query = "SELECT a FROM DecisionSettings a order by a.priority asc, a.xacmlId asc"
+)
+@Getter
+@Setter
+//@formatter:on
public class DecisionSettings implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
- @Column(name="description", nullable=true, length=2048)
+ @Column(name = "description", nullable = true, length = 2048)
private String description;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
- @Column(name="PRIORITY", nullable=true)
+ @Column(name = "PRIORITY", nullable = true)
@OrderBy("asc")
private String priority;
- @Column(name="xacml_id", unique = true, nullable=false)
+ @Column(name = "xacml_id", unique = true, nullable = false)
@OrderBy("asc")
private String xacmlId = "urn";
- //bi-directional many-to-one association to Datatype
+ // bi-directional many-to-one association to Datatype
@ManyToOne
- @JoinColumn(name="datatype")
+ @JoinColumn(name = "datatype")
private Datatype datatypeBean;
@Transient
@@ -82,116 +95,28 @@ public class DecisionSettings implements Serializable {
private boolean mustBePresent = false;
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
-
- public Date getCreatedDate() {
- return this.createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getModifiedDate() {
- return this.modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
- public String getXacmlId() {
- return this.xacmlId;
- }
-
- public void setXacmlId(String xacmlId) {
- this.xacmlId = xacmlId;
- }
-
- public Datatype getDatatypeBean() {
- return this.datatypeBean;
- }
-
- public void setDatatypeBean(Datatype datatypeBean) {
- this.datatypeBean = datatypeBean;
- }
-
- @Transient
- public String getIssuer() {
- return issuer;
- }
-
- @Transient
- public void setIssuer(String issuer) {
- this.issuer = issuer;
- }
-
- @Transient
- public boolean isMustBePresent() {
- return mustBePresent;
- }
-
- @Transient
- public void setMustBePresent(boolean mustBePresent) {
- this.mustBePresent = mustBePresent;
- }
-
- public String getPriority() {
- return priority;
- }
-
- public void setPriority(String priority) {
- this.priority = priority;
- }
}
-
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DescriptiveScope.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DescriptiveScope.java
index aab9126e2..4360131a4 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DescriptiveScope.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DescriptiveScope.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,10 +39,17 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
+/**
+ * The Class DescriptiveScope.
+ */
@Entity
@Table(name = "DescriptiveScope")
-@NamedQuery(name = "DescriptiveScope.findAll", query= "Select p from DescriptiveScope p")
+@NamedQuery(name = "DescriptiveScope.findAll", query = "Select p from DescriptiveScope p")
+@Getter
+@Setter
public class DescriptiveScope implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@@ -49,106 +57,66 @@ public class DescriptiveScope implements Serializable {
@Column(name = "Id")
private int id;
- @Column(name="scopename", nullable=false)
+ @Column(name = "scopename", nullable = false)
@OrderBy("asc")
private String descriptiveScopeName;
- @Column(name="description", nullable=true, length=2048)
+ @Column(name = "description", nullable = true, length = 2048)
private String description;
- @Column(name="search", nullable=true)
+ @Column(name = "search", nullable = true)
@OrderBy("asc")
private String search;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
- public int getId() {
- return this.id;
- }
- public void setId(int id) {
- this.id = id;
- }
-
+ /**
+ * Gets the scope name.
+ *
+ * @return the scope name
+ */
public String getScopeName() {
return descriptiveScopeName;
}
+ /**
+ * Sets the scope name.
+ *
+ * @param descriptiveScopeName the new scope name
+ */
public void setScopeName(String descriptiveScopeName) {
this.descriptiveScopeName = descriptiveScopeName;
}
-
- public String getSearch() {
- return search;
- }
-
- public void setSearch(String search) {
- this.search = search;
- }
-
- public Date getCreatedDate() {
- return this.createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getModifiedDate() {
- return this.modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DictionaryData.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DictionaryData.java
index 85a5091e8..a3db91b75 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DictionaryData.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DictionaryData.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,12 +29,15 @@ import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
+
@Entity
@Table(name = "DictionaryData")
@NamedQuery(name = "DictionaryData.findAll", query = "SELECT v FROM DictionaryData v ")
+@Getter
+@Setter
public class DictionaryData {
- private static final long serialVersionUID = 1L;
-
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
@@ -47,37 +51,4 @@ public class DictionaryData {
@Column(name = "dictionaryDataByName", nullable = false, length = 1024)
private String dictionaryDataByName;
-
- public String getDictionaryUrl() {
- return dictionaryUrl;
- }
-
- public void setDictionaryUrl(String dictionaryUrl) {
- this.dictionaryUrl = dictionaryUrl;
- }
-
- public String getDictionaryDataByName() {
- return dictionaryDataByName;
- }
-
- public void setDictionaryDataByName(String dictionaryDataByName) {
- this.dictionaryDataByName = dictionaryDataByName;
- }
-
- public String getDictionaryName() {
- return dictionaryName;
- }
-
- public void setDictionaryName(String dictionaryName) {
- this.dictionaryName = dictionaryName;
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTagPicker.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTagPicker.java
deleted file mode 100644
index 0910d60d7..000000000
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTagPicker.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-REST
- * ================================================================================
- * Copyright (C) 2017-2018 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.rest.jpa;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQuery;
-import javax.persistence.OrderBy;
-import javax.persistence.PrePersist;
-import javax.persistence.PreUpdate;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-@Entity
-@Table(name = "FWTagPicker")
-@NamedQuery(name = "FWTagPicker.findAll", query= "Select p from FWTagPicker p")
-public class FWTagPicker implements Serializable {
- private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name = "Id")
- private int id;
-
- @Column(name="tagPickerName", nullable=false)
- @OrderBy("asc")
- private String tagPickerName;
-
- @Column(name="description", nullable=true, length=2048)
- private String description;
-
- @Column(name="networkRole", nullable=true)
- private String networkRole;
-
- @Column(name="tags", nullable=true)
- @OrderBy("asc")
- private String tagValues;
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
- private Date createdDate;
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
- private Date modifiedDate;
-
- @ManyToOne(optional = false)
- @JoinColumn(name="created_by")
- private UserInfo userCreatedBy;
-
- @ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
- private UserInfo userModifiedBy;
-
- @PrePersist
- public void prePersist() {
- Date date = new Date();
- this.createdDate = date;
- this.modifiedDate = date;
- }
-
- @PreUpdate
- public void preUpdate() {
- this.modifiedDate = new Date();
- }
-
- public int getId() {
- return this.id;
- }
- public void setId(int id) {
- this.id = id;
- }
-
- public String getTagPickerName() {
- return tagPickerName;
- }
-
- public void setTagPickerName(String tagPickerName) {
- this.tagPickerName = tagPickerName;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getNetworkRole() {
- return networkRole;
- }
-
- public void setNetworkRole(String networkRole) {
- this.networkRole = networkRole;
- }
-
- public String getTagValues() {
- return tagValues;
- }
-
- public void setTagValues(String tagValues) {
- this.tagValues = tagValues;
- }
-
- public Date getCreatedDate() {
- return this.createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public Date getModifiedDate() {
- return this.modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
-}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FirewallDictionaryList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FirewallDictionaryList.java
index 6ef5f60e0..8581cdf51 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FirewallDictionaryList.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FirewallDictionaryList.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -31,68 +32,32 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
@Entity
-@Table(name="parentdictionaryitems")
-@NamedQuery(name="FirewallDictionaryList.findAll", query="SELECT e FROM FirewallDictionaryList e")
+@Table(name = "parentdictionaryitems")
+@NamedQuery(name = "FirewallDictionaryList.findAll", query = "SELECT e FROM FirewallDictionaryList e")
+@Getter
+@Setter
public class FirewallDictionaryList implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="parentItemName", nullable=false)
+ @Column(name = "parentItemName", nullable = false)
@OrderBy("asc")
private String parentItemName;
- @Column(name="description")
+ @Column(name = "description")
private String description;
- @Column(name="addressList")
+ @Column(name = "addressList")
private String addressList;
- @Column(name="serviceList")
+ @Column(name = "serviceList")
private String serviceList;
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getParentItemName() {
- return parentItemName;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getAddressList() {
- return addressList;
- }
-
- public String getServiceList() {
- return serviceList;
- }
-
- public void setParentItemName(String parentItemName) {
- this.parentItemName = parentItemName;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public void setAddressList(String addressList) {
- this.addressList = addressList;
- }
-
- public void setServiceList(String serviceList) {
- this.serviceList = serviceList;
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionArgument.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionArgument.java
index a0d14e66b..f978cf089 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionArgument.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionArgument.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,44 +23,62 @@ package org.onap.policy.rest.jpa;
import java.io.Serializable;
-import javax.persistence.*;
-
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
/**
* The persistent class for the FunctionArguments database table.
- *
+ *
*/
@Entity
-@Table(name="FunctionArguments")
-@NamedQuery(name="FunctionArgument.findAll", query="SELECT f FROM FunctionArgument f")
+@Table(name = "FunctionArguments")
+@NamedQuery(name = "FunctionArgument.findAll", query = "SELECT f FROM FunctionArgument f")
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
public class FunctionArgument implements Serializable {
private static final long serialVersionUID = 1L;
@Id
- @GeneratedValue(strategy=GenerationType.AUTO)
- @Column(name="id")
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
private int id;
- @Column(name="is_bag", nullable=false)
+ @Column(name = "is_bag", nullable = false)
private int isBag;
- //bi-directional many-to-one association to FunctionDefinition
+ // bi-directional many-to-one association to FunctionDefinition
@ManyToOne
- @JoinColumn(name="function_id")
+ @JoinColumn(name = "function_id")
private FunctionDefinition functionDefinition;
- @Column(name="arg_index", nullable=false)
+ @Column(name = "arg_index", nullable = false)
private int argIndex;
- //bi-directional many-to-one association to Datatype
+ // bi-directional many-to-one association to Datatype
@ManyToOne
- @JoinColumn(name="datatype_id")
+ @JoinColumn(name = "datatype_id")
private Datatype datatypeBean;
- public FunctionArgument() {
- //An empty constructor
- }
-
+ /**
+ * Copy constructor.
+ *
+ * @param argument the object to copy from
+ */
public FunctionArgument(final FunctionArgument argument) {
this.argIndex = argument.argIndex;
this.datatypeBean = argument.datatypeBean;
@@ -67,57 +86,12 @@ public class FunctionArgument implements Serializable {
this.functionDefinition = argument.functionDefinition;
}
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public int getArgIndex() {
- return this.argIndex;
- }
-
- public void setArgIndex(int argIndex) {
- this.argIndex = argIndex;
- }
-
- public Datatype getDatatypeBean() {
- return this.datatypeBean;
- }
-
- public void setDatatypeBean(Datatype datatypeBean) {
- this.datatypeBean = datatypeBean;
- }
-
- public FunctionDefinition getFunctionDefinition() {
- return this.functionDefinition;
- }
-
public int getIsBag() {
return isBag;
}
- public void setIsBag(int isBag) {
- this.isBag = isBag;
- }
-
- public void setFunctionDefinition(FunctionDefinition functionDefinition) {
- this.functionDefinition = functionDefinition;
- }
-
- @Transient
- @Override
- public String toString() {
- return "FunctionArgument [id=" + id + ", argIndex=" + argIndex
- + ", datatypeBean=" + datatypeBean + ", isBag=" + isBag
- + ", functionDefinition=" + functionDefinition + "]";
- }
-
@Transient
public boolean isBag() {
return this.isBag == 1;
}
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionDefinition.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionDefinition.java
index 80c9beb2c..9201eec32 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionDefinition.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionDefinition.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,165 +22,93 @@
package org.onap.policy.rest.jpa;
import java.io.Serializable;
-
-import javax.persistence.*;
-
import java.util.List;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
/**
* The persistent class for the FunctionDefinition database table.
- *
+ *
*/
+// @formatter:off
@Entity
-@Table(name="FunctionDefinition")
-@NamedQueries({
- @NamedQuery(name="FunctionDefinition.findAll", query="SELECT f FROM FunctionDefinition f")
-})
+@Table(name = "FunctionDefinition")
+@NamedQueries(
+ {
+ @NamedQuery(name = "FunctionDefinition.findAll", query = "SELECT f FROM FunctionDefinition f")
+ }
+)
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+// @formatter:on
public class FunctionDefinition implements Serializable {
private static final long serialVersionUID = 1L;
@Id
- @GeneratedValue(strategy=GenerationType.AUTO)
- @Column(name="id")
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
private int id;
- @Column(name="short_name", nullable=false, length=64)
+ @Column(name = "short_name", nullable = false, length = 64)
private String shortname;
- @Column(name="xacml_id", nullable=false, length=255)
+ @Column(name = "xacml_id", nullable = false, length = 255)
private String xacmlid;
- //bi-directional many-to-one association to Datatype
+ // bi-directional many-to-one association to Datatype
@ManyToOne
- @JoinColumn(name="return_datatype", nullable=true)
+ @JoinColumn(name = "return_datatype", nullable = true)
private Datatype datatypeBean;
- @Column(name="is_bag_return", nullable=false)
+ @Column(name = "is_bag_return", nullable = false)
private Integer isBagReturn;
- @Column(name="is_higher_order", nullable=false)
+ @Column(name = "is_higher_order", nullable = false)
private Integer isHigherOrder;
- @Column(name="arg_lb", nullable=false)
+ @Column(name = "arg_lb", nullable = false)
private Integer argLb;
- @Column(name="arg_ub", nullable=false)
+ @Column(name = "arg_ub", nullable = false)
private Integer argUb;
- @Column(name="ho_arg_lb", nullable=true)
- private Integer higherOrderArg_LB;
+ @Column(name = "ho_arg_lb", nullable = true)
+ private Integer higherOrderArgLb;
- @Column(name="ho_arg_ub", nullable=true)
- private Integer higherOrderArg_UB;
+ @Column(name = "ho_arg_ub", nullable = true)
+ private Integer higherOrderArgUb;
- @Column(name="ho_primitive", nullable=true)
+ @Column(name = "ho_primitive", nullable = true)
private Character higherOrderIsPrimitive;
- //bi-directional many-to-one association to FunctionArgument
- @OneToMany(mappedBy="functionDefinition")
+ // bi-directional many-to-one association to FunctionArgument
+ @OneToMany(mappedBy = "functionDefinition")
private List<FunctionArgument> functionArguments;
- public FunctionDefinition() {
- //An empty constructor
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public int getArgLb() {
- return this.argLb;
- }
-
- public void setArgLb(Integer argLb) {
- this.argLb = argLb;
- }
-
- public int getArgUb() {
- return this.argUb;
- }
-
- public void setArgUb(Integer argUb) {
- this.argUb = argUb;
- }
-
- public int getIsBagReturn() {
- return isBagReturn;
- }
-
- public void setIsBagReturn(Integer isBagReturn) {
- this.isBagReturn = isBagReturn;
- }
-
- public int getIsHigherOrder() {
- return isHigherOrder;
- }
-
- public void setIsHigherOrder(Integer isHigherOrder) {
- this.isHigherOrder = isHigherOrder;
- }
-
- public Datatype getDatatypeBean() {
- return this.datatypeBean;
- }
-
- public void setDatatypeBean(Datatype datatypeBean) {
- this.datatypeBean = datatypeBean;
- }
-
- public String getShortname() {
- return this.shortname;
- }
-
- public void setShortname(String shortname) {
- this.shortname = shortname;
- }
-
- public String getXacmlid() {
- return this.xacmlid;
- }
-
- public void setXacmlid(String xacmlid) {
- this.xacmlid = xacmlid;
- }
-
- public int getHigherOrderArg_LB() {
- return higherOrderArg_LB;
- }
-
- public void setHigherOrderArg_LB(Integer higherOrderArg_LB) {
- this.higherOrderArg_LB = higherOrderArg_LB;
- }
-
- public int getHigherOrderArg_UB() {
- return higherOrderArg_UB;
- }
-
- public void setHigherOrderArg_UB(Integer higherOrderArg_UB) {
- this.higherOrderArg_UB = higherOrderArg_UB;
- }
-
- public Character getHigherOrderIsPrimitive() {
- return higherOrderIsPrimitive;
- }
-
- public void setHigherOrderIsPrimitive(Character higherOrderIsPrimitive) {
- this.higherOrderIsPrimitive = higherOrderIsPrimitive;
- }
-
- public List<FunctionArgument> getFunctionArguments() {
- return this.functionArguments;
- }
-
- public void setFunctionArguments(List<FunctionArgument> functionArguments) {
- this.functionArguments = functionArguments;
- }
-
+ /**
+ * Adds the function argument.
+ *
+ * @param functionArgument the function argument
+ * @return the function argument
+ */
public FunctionArgument addFunctionArgument(FunctionArgument functionArgument) {
getFunctionArguments().add(functionArgument);
functionArgument.setFunctionDefinition(this);
@@ -187,6 +116,12 @@ public class FunctionDefinition implements Serializable {
return functionArgument;
}
+ /**
+ * Removes the function argument.
+ *
+ * @param functionArgument the function argument
+ * @return the function argument
+ */
public FunctionArgument removeFunctionArgument(FunctionArgument functionArgument) {
getFunctionArguments().remove(functionArgument);
functionArgument.setFunctionDefinition(null);
@@ -194,24 +129,21 @@ public class FunctionDefinition implements Serializable {
return functionArgument;
}
- @Transient
- @Override
- public String toString() {
- return "FunctionDefinition [id=" + id + ", argLb=" + argLb + ", argUb="
- + argUb + ", isBagReturn=" + isBagReturn + ", isHigherOrder="
- + isHigherOrder + ", datatypeBean=" + datatypeBean
- + ", shortname=" + shortname + ", xacmlid=" + xacmlid
- + ", higherOrderArg_LB=" + higherOrderArg_LB
- + ", higherOrderArg_UB=" + higherOrderArg_UB
- + ", higherOrderIsPrimitive=" + higherOrderIsPrimitive
- + ", functionArguments=" + functionArguments + "]";
- }
-
+ /**
+ * Checks if is bag return.
+ *
+ * @return true, if is bag return
+ */
@Transient
public boolean isBagReturn() {
return this.isBagReturn == 1;
}
+ /**
+ * Checks if is higher order.
+ *
+ * @return true, if is higher order
+ */
@Transient
public boolean isHigherOrder() {
return this.isHigherOrder == 1;
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTag.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FwTag.java
index 75710d5b6..d19615d6c 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTag.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FwTag.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,117 +39,63 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
+
@Entity
-@Table(name = "FWTag")
-@NamedQuery(name = "FWTag.findAll", query= "Select p from FWTag p")
-public class FWTag implements Serializable {
+@Table(name = "FwTag")
+@NamedQuery(name = "FwTag.findAll", query = "Select p from FwTag p")
+@Getter
+@Setter
+public class FwTag implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "Id")
private int id;
- @Column(name="tagName", nullable=false)
+ @Column(name = "tagName", nullable = false)
@OrderBy("asc")
private String fwTagName;
- @Column(name="description", nullable=true, length=2048)
+ @Column(name = "description", nullable = true, length = 2048)
private String description;
- @Column(name="tagValues", nullable=true)
+ @Column(name = "tagValues", nullable = true)
@OrderBy("asc")
private String tagValues;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
+ /**
+ * Called before an instance is persisted.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Called before an instance is updated.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
-
- public int getId() {
- return this.id;
- }
- public void setId(int id) {
- this.id = id;
- }
-
- public String getFwTagName() {
- return fwTagName;
- }
-
- public void setFwTagName(String fwTagName) {
- this.fwTagName = fwTagName;
- }
-
- public String getTagValues() {
- return tagValues;
- }
-
- public void setTagValues(String tagValues) {
- this.tagValues = tagValues;
- }
-
-
- public Date getCreatedDate() {
- return this.createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getModifiedDate() {
- return this.modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FwTagPicker.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FwTagPicker.java
new file mode 100644
index 000000000..aa01433ff
--- /dev/null
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FwTagPicker.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-REST
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.rest.jpa;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.OrderBy;
+import javax.persistence.PrePersist;
+import javax.persistence.PreUpdate;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Entity
+@Table(name = "FWTagPicker")
+@NamedQuery(name = "FwTagPicker.findAll", query = "Select p from FwTagPicker p")
+@Getter
+@Setter
+public class FwTagPicker implements Serializable {
+ private static final long serialVersionUID = 1L;
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "Id")
+ private int id;
+
+ @Column(name = "tagPickerName", nullable = false)
+ @OrderBy("asc")
+ private String tagPickerName;
+
+ @Column(name = "description", nullable = true, length = 2048)
+ private String description;
+
+ @Column(name = "networkRole", nullable = true)
+ private String networkRole;
+
+ @Column(name = "tags", nullable = true)
+ @OrderBy("asc")
+ private String tagValues;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "created_date", updatable = false)
+ private Date createdDate;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "modified_date", nullable = false)
+ private Date modifiedDate;
+
+ @ManyToOne(optional = false)
+ @JoinColumn(name = "created_by")
+ private UserInfo userCreatedBy;
+
+ @ManyToOne(optional = false)
+ @JoinColumn(name = "modified_by")
+ private UserInfo userModifiedBy;
+
+ /**
+ * Called before an instance is persisted.
+ */
+ @PrePersist
+ public void prePersist() {
+ Date date = new Date();
+ this.createdDate = date;
+ this.modifiedDate = date;
+ }
+
+ /**
+ * Called before an instance is updated.
+ */
+ @PreUpdate
+ public void preUpdate() {
+ this.modifiedDate = new Date();
+ }
+}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GlobalRoleSettings.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GlobalRoleSettings.java
index 1b871d183..b89547927 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GlobalRoleSettings.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GlobalRoleSettings.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,22 +29,25 @@ import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
/**
- * Entity implementation class for Entity: Administration
- *
+ * Entity implementation class for Entity: Administration.
*/
@Entity
-@Table(name="GlobalRoleSettings")
-@NamedQuery(name="GlobalRoleSettings.findAll", query="SELECT g FROM GlobalRoleSettings g")
-public class GlobalRoleSettings implements Serializable {
+@Table(name = "GlobalRoleSettings")
+@NamedQuery(name = "GlobalRoleSettings.findAll", query = "SELECT g FROM GlobalRoleSettings g")
+@Getter
+@Setter
+public class GlobalRoleSettings implements Serializable {
private static final long serialVersionUID = 1L;
@Id
- @Column(name="role", length=45)
+ @Column(name = "role", length = 45)
private String role;
- @Column(name="lockdown")
+ @Column(name = "lockdown")
private boolean lockdown;
public GlobalRoleSettings() {
@@ -54,40 +58,4 @@ public class GlobalRoleSettings implements Serializable {
this.role = org.onap.policy.rest.XacmlAdminAuthorization.Role.ROLE_SUPERADMIN.toString();
this.lockdown = lockdown;
}
-
- /**
- * return the role
- *
- * @return the role
- */
- public String getRole() {
- return role;
- }
-
- /**
- * set role
- *
- * @param role the role to set
- */
- public void setRole(String role) {
- this.role = role;
- }
-
- /**
- * is the system locked down
- *
- * @return
- */
- public boolean isLockdown() {
- return lockdown;
- }
-
- /**
- * sets lockdown configuration
- *
- * @param lockdown
- */
- public void setLockdown(boolean lockdown) {
- this.lockdown = lockdown;
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupEntity.java
index 9b0ea0d7f..71e0bc4a2 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupEntity.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupEntity.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,13 +18,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
+
import com.fasterxml.jackson.annotation.JsonManagedReference;
+
/*
*/
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -43,216 +49,125 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
-/*
- * The Entity class to persist a policy object and its configuration data
- */
+import lombok.Getter;
+import lombok.Setter;
/**
- *
+ * The Entity class to persist a policy object and its configuration data.
*/
+// @formatter:off
@Entity
-//Add a non-unique index and a constraint that says the combo of policyName and scopeId must be unique
-@Table(name="GroupEntity")
+// Add a non-unique index and a constraint that says the combo of policyName and scopeId must be unique
+@Table(name = "GroupEntity")
+
+@NamedQueries(
+ {
+ @NamedQuery(name = "GroupEntity.findAll", query = "SELECT e FROM GroupEntity e "),
+ @NamedQuery(name = "GroupEntity.deleteAll", query = "DELETE FROM GroupEntity WHERE 1=1")
+ }
+)
-@NamedQueries({
- @NamedQuery(name="GroupEntity.findAll", query="SELECT e FROM GroupEntity e "),
- @NamedQuery(name="GroupEntity.deleteAll", query="DELETE FROM GroupEntity WHERE 1=1")
-})
+@Getter
+@Setter
+//@formatter:on
public class GroupEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
- @Column (name="groupKey", nullable=false)
+ @Column(name = "groupKey", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private long groupKey;
- @Column (name="groupId", nullable=false)
+ @Column(name = "groupId", nullable = false)
private String groupId;
- @Column(name="groupName", nullable=false, unique=false, length=255)
+ @Column(name = "groupName", nullable = false, unique = false, length = 255)
private String groupName;
@Version
- @Column(name="version")
+ @Column(name = "version")
private int version;
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
- @JoinTable(name="PolicyGroupEntity",joinColumns={@JoinColumn(name="groupKey")}, inverseJoinColumns={@JoinColumn(name="policyId")})
+ @JoinTable(name = "PolicyGroupEntity", joinColumns =
+ { @JoinColumn(name = "groupKey") }, inverseJoinColumns =
+ { @JoinColumn(name = "policyId") })
@JsonManagedReference
private List<PolicyEntity> policies;
- @Column(name="created_by", nullable=false, length=255)
+ @Column(name = "created_by", nullable = false, length = 255)
private String createdBy = "guest";
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
- @Column(name="description", nullable=false, length=2048)
+ @Column(name = "description", nullable = false, length = 2048)
private String description = "NoDescription";
- @Column(name="modified_by", nullable=false, length=255)
+ @Column(name = "modified_by", nullable = false, length = 255)
private String modifiedBy = "guest";
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
- @Column(name="defaultGroup", nullable=false)
+ @Column(name = "defaultGroup", nullable = false)
private boolean defaultGroup = false;
- @Column(name="deleted", nullable=false)
+ @Column(name = "deleted", nullable = false)
private boolean deleted = false;
+ /**
+ * Instantiates a new group entity.
+ */
public GroupEntity() {
super();
}
+ /**
+ * Called before an instance is persisted.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Called before an instance is updated.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
/**
- * @return the policyId
- */
- public String getGroupId() {
- return groupId;
- }
- public long getGroupKey(){
- return groupKey;
- }
-
- public void setGroupId(String groupId){
- this.groupId = groupId;
- }
-
- /**
- * @param policyId cannot be set
- */
-
- public String getgroupName() {
- return groupName;
- }
-
- public void setGroupName(String groupName) {
- this.groupName = groupName;
- }
-
- public boolean isDefaultGroup(){
- return defaultGroup;
- }
-
- public void setDefaultGroup(boolean isDefaultGroup){
- this.defaultGroup = isDefaultGroup;
- }
-
-
-
- /**
- * @return the configurationDataEntity
- */
- public List<PolicyEntity> getPolicies() {
- return policies;
- }
-
- /**
- * @param configurationDataEntity the configurationDataEntity to set
+ * Adds the policy to group.
+ *
+ * @param policy the policy
*/
public void addPolicyToGroup(PolicyEntity policy) {
- if(!this.policies.contains(policy)){
- this.policies.add(policy);
+ if (policies == null) {
+ policies = new ArrayList<>();
}
- }
- public void removePolicyFromGroup(PolicyEntity policy){
- this.policies.remove(policy);
- }
-
-
- /**
- * @return the createdBy
- */
- public String getCreatedBy() {
- return createdBy;
- }
-
- /**
- * @param createdBy the createdBy to set
- */
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- /**
- * @return the description
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * @param description the description to set
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * @return the modifiedBy
- */
- public String getModifiedBy() {
- return modifiedBy;
- }
-
- /**
- * @param modifiedBy the modifiedBy to set
- */
- public void setModifiedBy(String modifiedBy) {
- this.modifiedBy = modifiedBy;
- }
-
- /**
- * @return the version
- */
- public int getVersion() {
- return version;
- }
-
- /**
- * @return the createdDate
- */
- public Date getCreatedDate() {
- return createdDate;
- }
-
- /**
- * @return the modifiedDate
- */
- public Date getModifiedDate() {
- return modifiedDate;
+ if (!this.policies.contains(policy)) {
+ this.policies.add(policy);
+ }
}
/**
- * @return the deleted
+ * Removes the policy from group.
+ *
+ * @param policy the policy
*/
- public boolean isDeleted() {
- return deleted;
- }
+ public void removePolicyFromGroup(PolicyEntity policy) {
+ this.policies.remove(policy);
- /**
- * @param deleted the deleted to set
- */
- public void setDeleted(boolean deleted) {
- this.deleted = deleted;
+ if (policies.isEmpty()) {
+ policies = null;
+ }
}
-
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupPolicyScopeList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupPolicyScopeList.java
index 8b10083d8..71eb19ec5 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupPolicyScopeList.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupPolicyScopeList.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,35 +32,32 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
@Entity
-@Table(name="GroupPolicyScopeList")
-@NamedQuery(name="GroupPolicyScopeList.findAll", query="SELECT e FROM GroupPolicyScopeList e ")
+@Table(name = "GroupPolicyScopeList")
+@NamedQuery(name = "GroupPolicyScopeList.findAll", query = "SELECT e FROM GroupPolicyScopeList e ")
+@Getter
+@Setter
public class GroupPolicyScopeList implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String name;
- @Column(name="groupList")
+ @Column(name = "groupList")
private String groupList;
- @Column(name="description")
+ @Column(name = "description")
private String description;
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
public String getGroupName() {
return this.name;
}
@@ -69,19 +66,4 @@ public class GroupPolicyScopeList implements Serializable {
this.name = serviceName;
}
-
- public String getGroupList() {
- return this.groupList;
- }
-
- public void setGroupList(String groupList) {
- this.groupList = groupList;
-
- }
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupServiceList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupServiceList.java
index 63f673f59..6d1120307 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupServiceList.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupServiceList.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,48 +32,34 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
@Entity
-@Table(name="GroupServiceList")
-@NamedQuery(name="GroupServiceList.findAll", query="SELECT e FROM GroupServiceList e ")
+@Table(name = "GroupServiceList")
+@NamedQuery(name = "GroupServiceList.findAll", query = "SELECT e FROM GroupServiceList e ")
+@Getter
+@Setter
public class GroupServiceList implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String name;
- @Column(name="serviceList ")
+ @Column(name = "serviceList ")
private String serviceList;
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
public String getGroupName() {
return this.name;
}
public void setGroupName(String serviceName) {
this.name = serviceName;
-
}
-
- public String getServiceList() {
- return this.serviceList;
- }
-
- public void setServiceList(String serviceList) {
- this.serviceList = serviceList;
-
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceAttribute.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceAttribute.java
index 574212097..8ae81b9c0 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceAttribute.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceAttribute.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -31,54 +32,30 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
+
@Entity
-@Table(name="MicroServiceAttribute")
-@NamedQuery(name="MicroServiceAttribute.findAll", query="SELECT e FROM MicroServiceAttribute e ")
+@Table(name = "MicroServiceAttribute")
+@NamedQuery(name = "MicroServiceAttribute.findAll", query = "SELECT e FROM MicroServiceAttribute e ")
+@Getter
+@Setter
+
public class MicroServiceAttribute implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String name;
- @Column(name="value")
- private String value ;
+ @Column(name = "value")
+ private String value;
- @Column(name="modelName")
+ @Column(name = "modelName")
private String modelName;
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
-
- }
- public String getValue() {
- return this.value ;
- }
-
- public void setValue(String value ) {
- this.value = value ;
- }
- public String getModelName() {
- return modelName;
- }
- public void setModelName(String modelName) {
- this.modelName = modelName;
- }
-
} \ No newline at end of file
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceConfigName.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceConfigName.java
index 9719abbed..ab80c582b 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceConfigName.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceConfigName.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,46 +32,27 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
@Entity
-@Table(name="MicroServiceConfigName")
-@NamedQuery(name="MicroServiceConfigName.findAll", query="SELECT e FROM MicroServiceConfigName e ")
+@Table(name = "MicroServiceConfigName")
+@NamedQuery(name = "MicroServiceConfigName.findAll", query = "SELECT e FROM MicroServiceConfigName e ")
+@Getter
+@Setter
+
public class MicroServiceConfigName implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String name;
- @Column(name="description ")
- private String description ;
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
-
- }
- public String getDescriptionValue() {
- return this.description ;
- }
-
- public void setDescriptionValue(String description ) {
- this.description = description ;
- }
-
+ @Column(name = "description ")
+ private String description;
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceLocation.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceLocation.java
index 669b191e7..84962d551 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceLocation.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceLocation.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,46 +32,26 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
@Entity
-@Table(name="MicroServiceLocation")
-@NamedQuery(name="MicroServiceLocation.findAll", query="SELECT e FROM MicroServiceLocation e ")
+@Table(name = "MicroServiceLocation")
+@NamedQuery(name = "MicroServiceLocation.findAll", query = "SELECT e FROM MicroServiceLocation e ")
+@Getter
+@Setter
public class MicroServiceLocation implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String name;
- @Column(name="description ")
- private String description ;
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
-
- }
- public String getDescriptionValue() {
- return this.description ;
- }
-
- public void setDescriptionValue(String description ) {
- this.description = description ;
- }
-
+ @Column(name = "description ")
+ private String description;
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceModels.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceModels.java
index 1c6d811e1..ccedd6b8b 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceModels.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceModels.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
package org.onap.policy.rest.jpa;
import java.io.Serializable;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -38,12 +40,23 @@ import javax.persistence.Table;
* @version: 0.1
*/
+import lombok.Getter;
+import lombok.Setter;
+// @formatter:off
@Entity
@Table(name = "MicroServiceModels")
-@NamedQueries({@NamedQuery(name = "MicroServiceModels.findAll", query = "SELECT b FROM MicroServiceModels b "),
- @NamedQuery(name = "MicroServiceModels.findAllDecision",
- query = "SELECT b FROM MicroServiceModels b WHERE b.decisionModel=1")})
+@NamedQueries(
+ {
+ @NamedQuery(name = "MicroServiceModels.findAll", query = "SELECT b FROM MicroServiceModels b "),
+ @NamedQuery(
+ name = "MicroServiceModels.findAllDecision",
+ query = "SELECT b FROM MicroServiceModels b WHERE b.decisionModel=1")
+ }
+)
+@Getter
+@Setter
+// @formatter:on
public class MicroServiceModels implements Serializable {
private static final long serialVersionUID = 1L;
@@ -66,10 +79,10 @@ public class MicroServiceModels implements Serializable {
private String attributes;
@Column(name = "ref_attributes", nullable = false, length = 255)
- private String ref_attributes;
+ private String refAttributes;
@Column(name = "sub_attributes", nullable = false, length = 2000)
- private String sub_attributes;
+ private String subAttributes;
@Column(name = "dataOrderInfo", nullable = true, length = 2000)
private String dataOrderInfo;
@@ -89,120 +102,11 @@ public class MicroServiceModels implements Serializable {
@Column(name = "ruleFormation", nullable = true)
private String ruleFormation;
- public String getRuleFormation() {
- return ruleFormation;
- }
-
- public void setRuleFormation(String ruleFormation) {
- this.ruleFormation = ruleFormation;
- }
-
- public String getSub_attributes() {
- return sub_attributes;
- }
-
- public void setSub_attributes(String sub_attributes) {
- this.sub_attributes = sub_attributes;
- }
-
- public String getDataOrderInfo() {
- return dataOrderInfo;
- }
-
- public void setDataOrderInfo(String dataOrderInfo) {
- this.dataOrderInfo = dataOrderInfo;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
@ManyToOne
@JoinColumn(name = "imported_by")
private UserInfo userCreatedBy;
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public String getAttributes() {
- return attributes;
- }
-
- public void setAttributes(String attributes) {
- this.attributes = attributes;
- }
-
- public String getRef_attributes() {
- return ref_attributes;
- }
-
- public void setRef_attributes(String ref_attributes) {
- this.ref_attributes = ref_attributes;
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getDependency() {
- return dependency;
- }
-
- public void setDependency(String dependency) {
- this.dependency = dependency;
- }
-
- public String getModelName() {
- return this.modelName;
- }
-
- public void setModelName(String modelName) {
- this.modelName = modelName;
- }
-
- public String getEnumValues() {
- return enumValues;
- }
-
- public void setEnumValues(String enumValues) {
- this.enumValues = enumValues;
- }
-
- public String getAnnotation() {
- return annotation;
- }
-
- public void setAnnotation(String annotation) {
- this.annotation = annotation;
- }
-
- public Boolean isDecisionModel() {
+ public boolean isDecisionModel() {
return decisionModel;
}
-
- public void setDecisionModel(boolean decisionModel) {
- this.decisionModel = decisionModel;
- }
}
-
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaults.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaults.java
index 905555120..c7708abb3 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaults.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaults.java
@@ -2,14 +2,15 @@
* ============LICENSE_START=======================================================
* ONAP-REST
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -33,91 +34,55 @@ import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
+
@Entity
-@Table(name="MicroserviceHeaderdeFaults")
-@NamedQuery(name="MicroserviceHeaderdeFaults.findAll", query="SELECT e FROM MicroserviceHeaderdeFaults e ")
+@Table(name = "MicroserviceHeaderdeFaults")
+@NamedQuery(name = "MicroserviceHeaderdeFaults.findAll", query = "SELECT e FROM MicroserviceHeaderdeFaults e ")
+@Getter
+@Setter
public class MicroserviceHeaderdeFaults implements Serializable {
private static final long serialVersionUID = 1L;
- private static String domain;
-
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="onapName")
+ @Column(name = "onapName")
private String onapName;
- @Column(name="guard")
- private String guard ;
+ @Column(name = "guard")
+ private String guard;
- @Column(name="priority")
+ @Column(name = "priority")
private String priority;
- @Column(name="riskType")
- private String riskType ;
+ @Column(name = "riskType")
+ private String riskType;
- @Column(name="riskLevel")
+ @Column(name = "riskLevel")
private String riskLevel;
- @Column(name="modelName", nullable=false)
+ @Column(name = "modelName", nullable = false)
@OrderBy("asc")
private String modelName;
+ /**
+ * Called before persisting the object.
+ */
@PrePersist
- public void prePersist() {
-
+ public void prePersist() {
+ // Required for testing
}
+
+ /**
+ * Called before updating the object.
+ */
@PreUpdate
public void preUpdate() {
+ // Required for testing
}
-
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getModelName() {
- return modelName;
- }
- public void setModelName(String modelName) {
- this.modelName = modelName;
- }
- public String getOnapName() {
- return onapName;
- }
- public void setOnapName(String onapName) {
- this.onapName = onapName;
- }
- public String getGuard() {
- return guard;
- }
- public void setGuard(String guard) {
- this.guard = guard;
- }
- public String getPriority() {
- return priority;
- }
- public void setPriority(String priority) {
- this.priority = priority;
- }
- public String getRiskType() {
- return riskType;
- }
- public void setRiskType(String riskType) {
- this.riskType = riskType;
- }
- public String getRiskLevel() {
- return riskLevel;
- }
- public void setRiskLevel(String riskLevel) {
- this.riskLevel = riskLevel;
- }
-
} \ No newline at end of file
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Obadvice.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Obadvice.java
index 1c6b75d25..0734203e4 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Obadvice.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Obadvice.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +21,8 @@
package org.onap.policy.rest.jpa;
+import com.att.research.xacml.api.Identifier;
+
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
@@ -40,15 +43,17 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
-import com.att.research.xacml.api.Identifier;
+import lombok.Getter;
+import lombok.Setter;
/**
* The persistent class for the Obadvice database table.
- *
*/
@Entity
-@Table(name="Obadvice")
-@NamedQuery(name="Obadvice.findAll", query="SELECT o FROM Obadvice o")
+@Table(name = "Obadvice")
+@NamedQuery(name = "Obadvice.findAll", query = "SELECT o FROM Obadvice o")
+@Getter
+@Setter
public class Obadvice implements Serializable {
private static final long serialVersionUID = 1L;
@@ -58,44 +63,53 @@ public class Obadvice implements Serializable {
public static final String EFFECT_DENY = "Deny";
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="type", nullable=false)
+ @Column(name = "type", nullable = false)
private String type;
- @Column(name="xacml_id", nullable=false, length=255)
+ @Column(name = "xacml_id", nullable = false, length = 255)
private String xacmlId;
- @Column(name="fulfill_on", nullable=true, length=32)
+ @Column(name = "fulfill_on", nullable = true, length = 32)
private String fulfillOn;
- @Column(name="description", nullable=true, length=2048)
+ @Column(name = "description", nullable = true, length = 2048)
private String description;
- //bi-directional one-to-many association to Attribute Assignment
- @OneToMany(mappedBy="obadvice", orphanRemoval=true, cascade=CascadeType.REMOVE)
+ // bi-directional one-to-many association to Attribute Assignment
+ @OneToMany(mappedBy = "obadvice", orphanRemoval = true, cascade = CascadeType.REMOVE)
private Set<ObadviceExpression> obadviceExpressions = new HashSet<>(2);
- @Column(name="created_by", nullable=false, length=255)
+ @Column(name = "created_by", nullable = false, length = 255)
private String createdBy;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", nullable=false, updatable=false)
+ @Column(name = "created_date", nullable = false, updatable = false)
private Date createdDate;
- @Column(name="modified_by", nullable=false, length=255)
+ @Column(name = "modified_by", nullable = false, length = 255)
private String modifiedBy;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
+ /**
+ * Instantiates a new obadvice.
+ */
public Obadvice() {
this.type = Obadvice.OBLIGATION;
this.fulfillOn = Obadvice.EFFECT_PERMIT;
}
+ /**
+ * Instantiates a new obadvice.
+ *
+ * @param domain the domain
+ * @param userid the userid
+ */
public Obadvice(String domain, String userid) {
this.xacmlId = domain;
this.type = Obadvice.OBLIGATION;
@@ -104,86 +118,40 @@ public class Obadvice implements Serializable {
this.modifiedBy = userid;
}
+ /**
+ * Instantiates a new obadvice.
+ *
+ * @param id the id
+ * @param userid the userid
+ */
public Obadvice(Identifier id, String userid) {
this(id.stringValue(), userid);
}
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getCreatedBy() {
- return this.createdBy;
- }
-
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getFulfillOn() {
- return this.fulfillOn;
- }
-
- public void setFulfillOn(String fulfillOn) {
- this.fulfillOn = fulfillOn;
- }
-
- public String getModifiedBy() {
- return this.modifiedBy;
- }
-
- public void setModifiedBy(String modifiedBy) {
- this.modifiedBy = modifiedBy;
- }
-
- public String getType() {
- return this.type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getXacmlId() {
- return this.xacmlId;
- }
-
- public void setXacmlId(String xacmlId) {
- this.xacmlId = xacmlId;
- }
-
- public Set<ObadviceExpression> getObadviceExpressions() {
- return this.obadviceExpressions;
- }
-
- public void setObadviceExpressions(Set<ObadviceExpression> obadviceExpressions) {
- this.obadviceExpressions = obadviceExpressions;
- }
-
+ /**
+ * Adds the obadvice expression.
+ *
+ * @param obadviceExpression the obadvice expression
+ * @return the obadvice expression
+ */
public ObadviceExpression addObadviceExpression(ObadviceExpression obadviceExpression) {
this.obadviceExpressions.add(obadviceExpression);
obadviceExpression.setObadvice(this);
@@ -191,6 +159,12 @@ public class Obadvice implements Serializable {
return obadviceExpression;
}
+ /**
+ * Removes the obadvice expression.
+ *
+ * @param obadviceExpression the obadvice expression
+ * @return the obadvice expression
+ */
public ObadviceExpression removeObadviceExpression(ObadviceExpression obadviceExpression) {
this.obadviceExpressions.remove(obadviceExpression);
obadviceExpression.setObadvice(null);
@@ -198,6 +172,9 @@ public class Obadvice implements Serializable {
return obadviceExpression;
}
+ /**
+ * Removes the all expressions.
+ */
public void removeAllExpressions() {
if (this.obadviceExpressions == null) {
return;
@@ -208,6 +185,11 @@ public class Obadvice implements Serializable {
this.obadviceExpressions.clear();
}
+ /**
+ * Clone.
+ *
+ * @return the obadvice
+ */
@Transient
@Override
public Obadvice clone() {
@@ -219,7 +201,7 @@ public class Obadvice implements Serializable {
obadvice.description = this.description;
obadvice.createdBy = this.createdBy;
obadvice.modifiedBy = this.modifiedBy;
- for (ObadviceExpression exp: this.obadviceExpressions) {
+ for (ObadviceExpression exp : this.obadviceExpressions) {
obadvice.addObadviceExpression(exp.clone());
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ObadviceExpression.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ObadviceExpression.java
index 9d82b7325..db437095c 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ObadviceExpression.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ObadviceExpression.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -33,14 +34,17 @@ import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
/**
* The persistent class for the ObadviceExpressions database table.
- *
*/
@Entity
-@Table(name="ObadviceExpressions")
-@NamedQuery(name="ObadviceExpression.findAll", query="SELECT o FROM ObadviceExpression o")
+@Table(name = "ObadviceExpressions")
+@NamedQuery(name = "ObadviceExpression.findAll", query = "SELECT o FROM ObadviceExpression o")
+@Getter
+@Setter
public class ObadviceExpression implements Serializable {
private static final long serialVersionUID = 1L;
@@ -53,58 +57,26 @@ public class ObadviceExpression implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- //unidirectional one-to-one association to Attribute
+ // unidirectional one-to-one association to Attribute
@OneToOne
- @JoinColumn(name="attribute_id")
+ @JoinColumn(name = "attribute_id")
private Attribute attribute;
- @Column(name="type", nullable=false)
+ @Column(name = "type", nullable = false)
private String type;
- //bi-directional many-to-one association to Obadvice
+ // bi-directional many-to-one association to Obadvice
@ManyToOne
- @JoinColumn(name="obadvice_id")
+ @JoinColumn(name = "obadvice_id")
private Obadvice obadvice;
public ObadviceExpression() {
type = EXPRESSION_VALUE;
}
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public Attribute getAttribute() {
- return this.attribute;
- }
-
- public void setAttribute(Attribute attribute) {
- this.attribute = attribute;
- }
-
- public String getType() {
- return this.type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public Obadvice getObadvice() {
- return this.obadvice;
- }
-
- public void setObadvice(Obadvice obadvice) {
- this.obadvice = obadvice;
- }
-
@Override
public ObadviceExpression clone() {
ObadviceExpression expression = new ObadviceExpression();
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OnapName.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OnapName.java
index 0b39129a8..e128241ec 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OnapName.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OnapName.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import java.util.Date;
@@ -39,106 +39,63 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
+/**
+ * The Class OnapName.
+ */
@Entity
-@Table(name="OnapName")
-@NamedQuery(name="OnapName.findAll", query="SELECT e FROM OnapName e ")
+@Table(name = "OnapName")
+@NamedQuery(name = "OnapName.findAll", query = "SELECT e FROM OnapName e ")
+@Getter
+@Setter
public class OnapName implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="onap_Name", nullable=false, unique=true)
+ @Column(name = "onap_Name", nullable = false, unique = true)
@OrderBy("asc")
- private String onapName;
+ private String name;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
- @Column(name="description", nullable=true, length=2048)
+ @Column(name = "description", nullable = true, length = 2048)
private String description;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
- public String getOnapName() {
- return this.onapName;
- }
-
- public void setOnapName(String onapName) {
- this.onapName = onapName;
-
- }
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public Date getCreatedDate() {
- return this.createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getModifiedDate() {
- return this.modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OptimizationModels.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OptimizationModels.java
index 60b360029..457ca7382 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OptimizationModels.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OptimizationModels.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
import java.io.Serializable;
@@ -32,151 +34,59 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
/*
- * JPA for the OOF Models.
- *
+ * JPA for the OOF Models.
+ *
* @version: 0.1
*/
+import lombok.Getter;
+import lombok.Setter;
@Entity
-@Table(name="OptimizationModels")
-@NamedQuery(name="OptimizationModels.findAll", query="SELECT b FROM OptimizationModels b ")
-public class OptimizationModels implements Serializable{
+@Table(name = "OptimizationModels")
+@NamedQuery(name = "OptimizationModels.findAll", query = "SELECT b FROM OptimizationModels b ")
+@Getter
+@Setter
+public class OptimizationModels implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="modelName", nullable=false, unique=true)
+ @Column(name = "modelName", nullable = false, unique = true)
@OrderBy("asc")
private String modelName;
- @Column(name="description", nullable=true, length=2048)
+ @Column(name = "description", nullable = true, length = 2048)
private String description;
- @Column(name="dependency", nullable=true, length=2048)
+ @Column(name = "dependency", nullable = true, length = 2048)
private String dependency;
- @Column(name="attributes", nullable=false, length=255)
+ @Column(name = "attributes", nullable = false, length = 255)
private String attributes;
- @Column(name="ref_attributes", nullable=false, length=255)
+ @Column(name = "ref_attributes", nullable = false, length = 255)
private String refattributes;
- @Column (name="sub_attributes", nullable=false, length=2000)
+ @Column(name = "sub_attributes", nullable = false, length = 2000)
private String subattributes;
- @Column (name="dataOrderInfo", nullable=true, length=2000)
+ @Column(name = "dataOrderInfo", nullable = true, length = 2000)
private String dataOrderInfo;
- @Column (name="version", nullable=false, length=2000)
+ @Column(name = "version", nullable = false, length = 2000)
private String version;
- @Column (name="enumValues", nullable=false, length=2000)
+ @Column(name = "enumValues", nullable = false, length = 2000)
private String enumValues;
- @Column (name="annotation", nullable=false, length=2000)
+ @Column(name = "annotation", nullable = false, length = 2000)
private String annotation;
- public String getSubattributes() {
- return subattributes;
- }
-
- public void setSubattributes(String subattributes) {
- this.subattributes = subattributes;
- }
-
- public String getDataOrderInfo() {
- return dataOrderInfo;
- }
-
- public void setDataOrderInfo(String dataOrderInfo) {
- this.dataOrderInfo = dataOrderInfo;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
@ManyToOne
- @JoinColumn(name="imported_by")
+ @JoinColumn(name = "imported_by")
private UserInfo userCreatedBy;
-
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public String getAttributes() {
- return attributes;
- }
-
- public void setAttributes(String attributes) {
- this.attributes = attributes;
- }
-
- public String getRefattributes() {
- return refattributes;
- }
-
- public void setRefattributes(String refattributes) {
- this.refattributes = refattributes;
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getDependency() {
- return dependency;
- }
-
- public void setDependency(String dependency) {
- this.dependency = dependency;
- }
-
- public String getModelName(){
- return this.modelName;
- }
-
- public void setModelName(String modelName){
- this.modelName = modelName;
- }
-
- public String getEnumValues() {
- return enumValues;
- }
-
- public void setEnumValues(String enumValues) {
- this.enumValues = enumValues;
- }
-
- public String getAnnotation() {
- return annotation;
- }
-
- public void setAnnotation(String annotation) {
- this.annotation = annotation;
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfigParam.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfigParam.java
deleted file mode 100644
index 0f32de6d3..000000000
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfigParam.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-REST
- * ================================================================================
- * 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.rest.jpa;
-
-import java.io.Serializable;
-
-import javax.persistence.*;
-
-
-/**
- * The persistent class for the PIPConfigParams database table.
- *
- */
-@Entity
-@Table(name="PIPConfigParams")
-@NamedQuery(name="PIPConfigParam.findAll", query="SELECT p FROM PIPConfigParam p")
-public class PIPConfigParam implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Id
- @GeneratedValue(strategy=GenerationType.AUTO)
- @Column(name="id")
- private int id;
-
- @Column(name="PARAM_NAME", nullable=false, length=1024)
- private String paramName;
-
- @Column(name="PARAM_VALUE", nullable=false, length=2048)
- private String paramValue;
-
- @Column(name="PARAM_DEFAULT", nullable=true, length=2048)
- private String paramDefault = null;
-
- @Column(name="REQUIRED", nullable=false)
- private char required = '0';
-
- //bi-directional many-to-one association to PIPConfiguration
- @ManyToOne
- @JoinColumn(name="PIP_ID")
- private PIPConfiguration pipconfiguration;
-
- public PIPConfigParam() {
- //An empty constructor
- }
-
- public PIPConfigParam(String param) {
- this.paramName = param;
- }
-
- public PIPConfigParam(String param, String value) {
- this(param);
- this.paramValue = value;
- }
-
- public PIPConfigParam(PIPConfigParam param) {
- this(param.getParamName(), param.getParamValue());
- this.paramDefault = param.getParamDefault();
- this.required = param.required;
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getParamName() {
- return this.paramName;
- }
-
- public void setParamName(String paramName) {
- this.paramName = paramName;
- }
-
- public String getParamValue() {
- return this.paramValue;
- }
-
- public void setParamValue(String paramValue) {
- this.paramValue = paramValue;
- }
-
- public String getParamDefault() {
- return paramDefault;
- }
-
- public void setParamDefault(String paramDefault) {
- this.paramDefault = paramDefault;
- }
-
- public char getRequired() {
- return required;
- }
-
- public void setRequired(char required) {
- this.required = required;
- }
-
- public PIPConfiguration getPipconfiguration() {
- return this.pipconfiguration;
- }
-
- public void setPipconfiguration(PIPConfiguration pipconfiguration) {
- this.pipconfiguration = pipconfiguration;
- }
-
- @Transient
- public boolean isRequired() {
- return this.required == '1';
- }
-
- @Transient
- public void setRequired(boolean required) {
- if (required) {
- this.setRequired('1');
- } else {
- this.setRequired('0');
- }
- }
-
- @Transient
- @Override
- public String toString() {
- return "PIPConfigParam [id=" + id + ", paramName=" + paramName
- + ", paramValue=" + paramValue + ", required=" + required + "]";
- }
-
-}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolverParam.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolverParam.java
deleted file mode 100644
index 7356eebf8..000000000
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolverParam.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-REST
- * ================================================================================
- * 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.rest.jpa;
-
-import java.io.Serializable;
-
-import javax.persistence.*;
-
-
-/**
- * The persistent class for the PIPResolverParams database table.
- *
- */
-@Entity
-@Table(name="PIPResolverParams")
-@NamedQuery(name="PIPResolverParam.findAll", query="SELECT p FROM PIPResolverParam p")
-public class PIPResolverParam implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Id
- @GeneratedValue(strategy=GenerationType.AUTO)
- @Column(name="id")
- private int id;
-
- @Column(name="PARAM_NAME", nullable=false, length=1024)
- private String paramName;
-
- @Column(name="PARAM_VALUE", nullable=false, length=2048)
- private String paramValue;
-
- @Column(name="PARAM_DEFAULT", nullable=true, length=2048)
- private String paramDefault;
-
- @Column(name="REQUIRED", nullable=false)
- private char required = '0';
-
- //bi-directional many-to-one association to PIPResolver
- @ManyToOne
- @JoinColumn(name="ID_RESOLVER")
- private PIPResolver pipresolver;
-
- public PIPResolverParam() {
- // Empty constructor
- }
-
- public PIPResolverParam(String name) {
- this.paramName = name;
- }
-
- public PIPResolverParam(String name, String value) {
- this(name);
- this.paramValue = value;
- }
-
- public PIPResolverParam(PIPResolverParam param) {
- this(param.getParamName(), param.getParamValue());
- this.paramDefault = param.getParamDefault();
- this.required = param.required;
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getParamName() {
- return this.paramName;
- }
-
- public void setParamName(String paramName) {
- this.paramName = paramName;
- }
-
- public String getParamValue() {
- return this.paramValue;
- }
-
- public void setParamValue(String paramValue) {
- this.paramValue = paramValue;
- }
-
- public String getParamDefault() {
- return paramDefault;
- }
-
- public void setParamDefault(String paramDefault) {
- this.paramDefault = paramDefault;
- }
-
- public char getRequired() {
- return required;
- }
-
- public void setRequired(char required) {
- this.required = required;
- }
-
- public PIPResolver getPipresolver() {
- return this.pipresolver;
- }
-
- public void setPipresolver(PIPResolver pipresolver) {
- this.pipresolver = pipresolver;
- }
-
- @Transient
- public boolean isRequired() {
- return this.required == '1';
- }
-
- @Transient
- public void setRequired(boolean required) {
- if (required) {
- this.required = '1';
- } else {
- this.required = '0';
- }
- }
-
- @Transient
- @Override
- public String toString() {
- return "PIPResolverParam [id=" + id + ", paramName=" + paramName
- + ", paramValue=" + paramValue + ", required=" + required + "]";
- }
-
-}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PdpEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PdpEntity.java
index 92c0c9dbe..69ad3f572 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PdpEntity.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PdpEntity.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import java.util.Date;
@@ -39,108 +39,95 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
-/*
- * The Entity class to persist a policy object and its configuration data
- */
+import lombok.Getter;
+import lombok.Setter;
/**
- *
+ * The Entity class to persist a policy object and its configuration data.
*/
+// @formatter:off
@Entity
-//Add a non-unique index and a constraint that says the combo of policyName and scopeId must be unique
-@Table(name="PdpEntity")
-@NamedQueries({
- @NamedQuery(name="PdpEntity.findAll", query="SELECT e FROM PdpEntity e "),
- @NamedQuery(name="PdpEntity.deleteAll", query="DELETE FROM PdpEntity WHERE 1=1")
-})
-
+// Add a non-unique index and a constraint that says the combo of policyName and scopeId must be unique
+@Table(name = "PdpEntity")
+@NamedQueries(
+ {
+ @NamedQuery(name = "PdpEntity.findAll", query = "SELECT e FROM PdpEntity e "),
+ @NamedQuery(name = "PdpEntity.deleteAll", query = "DELETE FROM PdpEntity WHERE 1=1")
+ }
+)
+@Getter
+@Setter
+// @formatter:on
public class PdpEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
- //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqPdp")
+ // @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqPdp")
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column (name="pdpKey")
+ @Column(name = "pdpKey")
private long pdpKey;
- @Column (name="pdpId", nullable=false, unique=false, length=255)
+ @Column(name = "pdpId", nullable = false, unique = false, length = 255)
private String pdpId;
- @Column(name="pdpName", nullable=false, unique=false, length=255)
+ @Column(name = "pdpName", nullable = false, unique = false, length = 255)
private String pdpName;
- @Column(name="jmxPort", nullable=false, unique=false)
+ @Column(name = "jmxPort", nullable = false, unique = false)
private int jmxPort;
-
- @ManyToOne(optional=false)
- @JoinColumn(name="groupKey", referencedColumnName="groupKey")
+ @ManyToOne(optional = false)
+ @JoinColumn(name = "groupKey", referencedColumnName = "groupKey")
private GroupEntity groupEntity;
- @Column(name="created_by", nullable=false, length=255)
+ @Column(name = "created_by", nullable = false, length = 255)
private String createdBy = "guest";
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
- @Column(name="description", nullable=false, length=2048)
+ @Column(name = "description", nullable = false, length = 2048)
private String description = "NoDescription";
- @Column(name="modified_by", nullable=false, length=255)
+ @Column(name = "modified_by", nullable = false, length = 255)
private String modifiedBy = "guest";
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
- @Column(name="deleted", nullable=false)
+ @Column(name = "deleted", nullable = false)
private boolean deleted = false;
+ /**
+ * Instantiates a new pdp entity.
+ */
public PdpEntity() {
super();
}
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
- public long getPdpKey(){
- return pdpKey;
- }
- /**
- * @return the policyId
- */
- public String getPdpId() {
- return pdpId;
- }
-
- public void setPdpId(String id){
- pdpId = id;
- }
- /**
- * @param policyId cannot be set
- */
-
- public String getPdpName() {
- return pdpName;
- }
-
- public void setPdpName(String groupName) {
- this.pdpName = groupName;
- }
-
-
-
/**
+ * Gets the group.
+ *
* @return the configurationDataEntity
*/
public GroupEntity getGroup() {
@@ -148,94 +135,11 @@ public class PdpEntity implements Serializable {
}
/**
- * @param configurationDataEntity the configurationDataEntity to set
+ * Sets the group.
+ *
+ * @param group the new group
*/
public void setGroup(GroupEntity group) {
this.groupEntity = group;
}
-
-
-
- /**
- * @return the createdBy
- */
- public String getCreatedBy() {
- return createdBy;
- }
-
- /**
- * @param createdBy the createdBy to set
- */
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- /**
- * @return the description
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * @param description the description to set
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * @return the modifiedBy
- */
- public String getModifiedBy() {
- return modifiedBy;
- }
-
- /**
- * @param modifiedBy the modifiedBy to set
- */
- public void setModifiedBy(String modifiedBy) {
- this.modifiedBy = modifiedBy;
- }
-
- /**
- * @return the version
- */
- public int getJmxPort() {
- return jmxPort;
- }
-
- public void setJmxPort(int jmxPort){
- this.jmxPort = jmxPort;
- }
-
- /**
- * @return the createdDate
- */
- public Date getCreatedDate() {
- return createdDate;
- }
-
- /**
- * @return the modifiedDate
- */
- public Date getModifiedDate() {
- return modifiedDate;
- }
-
- /**
- * @return the deleted
- */
- public boolean isDeleted() {
- return deleted;
- }
-
- /**
- * @param deleted the deleted to set
- */
- public void setDeleted(boolean deleted) {
- this.deleted = deleted;
- }
-
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VNFType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PepOptions.java
index 3d7c7f67b..3a5f791de 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VNFType.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PepOptions.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +21,12 @@
package org.onap.policy.rest.jpa;
+/*
+ *
+ * */
import java.io.Serializable;
import java.util.Date;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -37,111 +42,73 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
-
+/**
+ * The Class PepOptions.
+ */
@Entity
-@Table(name="VNFType")
-@NamedQuery(name="VNFType.findAll", query="SELECT v FROM VNFType v ")
-public class VNFType implements Serializable {
+@Table(name = "PepOptions")
+@NamedQuery(name = "PepOptions.findAll", query = "Select p from PepOptions p")
+@Getter
+@Setter
+public class PepOptions implements Serializable {
private static final long serialVersionUID = 1L;
-
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "Id")
private int id;
- @Column(name="vnf_type", nullable=false, unique=true)
+ @Column(name = "PEP_NAME", nullable = false)
@OrderBy("asc")
- private String vnftype;
+ private String pepName;
+
+ @Column(name = "description", nullable = true, length = 2048)
+ private String description;
+
+ @Column(name = "Actions", nullable = true)
+ @OrderBy("asc")
+ private String actions;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
- @Column(name="description", nullable=true, length=2048)
- private String description;
-
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
- public VNFType() {
+ /**
+ * Instantiates a new PEP options.
+ */
+ public PepOptions() {
this.modifiedDate = new Date();
}
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
- public String getVnftype() {
- return vnftype;
- }
-
- public void setVnftype(String vnftype) {
- this.vnftype = vnftype;
- }
-
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public Date getCreatedDate() {
- return this.createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getModifiedDate() {
- return this.modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipConfigParam.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipConfigParam.java
new file mode 100644
index 000000000..06f6bef61
--- /dev/null
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipConfigParam.java
@@ -0,0 +1,135 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-REST
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.rest.jpa;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * The persistent class for the PipConfigParams database table.
+ *
+ */
+@Entity
+@Table(name = "PipConfigParams")
+@NamedQuery(name = "PipConfigParam.findAll", query = "SELECT p FROM PipConfigParam p")
+@Getter
+@Setter
+@ToString
+/**
+ * Instantiates a new PIP config param.
+ */
+@NoArgsConstructor
+public class PipConfigParam implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
+ private int id;
+
+ @Column(name = "PARAM_NAME", nullable = false, length = 1024)
+ private String paramName;
+
+ @Column(name = "PARAM_VALUE", nullable = false, length = 2048)
+ private String paramValue;
+
+ @Column(name = "PARAM_DEFAULT", nullable = true, length = 2048)
+ private String paramDefault = null;
+
+ @Column(name = "REQUIRED", nullable = false)
+ private char required = '0';
+
+ // bi-directional many-to-one association to PipConfiguration
+ @ManyToOne
+ @JoinColumn(name = "PIP_ID")
+ private PipConfiguration pipconfiguration;
+
+ /**
+ * Instantiates a new PIP config param.
+ *
+ * @param param the param
+ */
+ public PipConfigParam(String param) {
+ this.paramName = param;
+ }
+
+ /**
+ * Instantiates a new PIP config param.
+ *
+ * @param param the param
+ * @param value the value
+ */
+ public PipConfigParam(String param, String value) {
+ this(param);
+ this.paramValue = value;
+ }
+
+ /**
+ * Instantiates a new PIP config param.
+ *
+ * @param param the param
+ */
+ public PipConfigParam(PipConfigParam param) {
+ this(param.getParamName(), param.getParamValue());
+ this.paramDefault = param.getParamDefault();
+ this.required = param.required;
+ }
+
+ /**
+ * Checks if is required.
+ *
+ * @return true, if is required
+ */
+ @Transient
+ public boolean isRequired() {
+ return this.required == '1';
+ }
+
+ /**
+ * Sets the required flag.
+ *
+ * @param required the new required flag
+ */
+ @Transient
+ public void setRequiredFlag(boolean required) {
+ if (required) {
+ this.setRequired('1');
+ } else {
+ this.setRequired('0');
+ }
+ }
+}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfiguration.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipConfiguration.java
index d34c4bd0b..99bd613e8 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfiguration.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipConfiguration.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +21,12 @@
package org.onap.policy.rest.jpa;
+import com.att.research.xacml.api.pip.PIPException;
+import com.att.research.xacml.std.pip.engines.StdConfigurableEngine;
+import com.att.research.xacml.util.XACMLProperties;
+import com.google.common.base.Joiner;
+import com.google.common.base.Splitter;
+
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
@@ -49,85 +56,89 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.onap.policy.common.logging.eelf.MessageCodes;
import org.onap.policy.common.logging.eelf.PolicyLogger;
import org.onap.policy.xacml.api.XACMLErrorConstants;
-import com.att.research.xacml.api.pip.PIPException;
-import com.att.research.xacml.std.pip.engines.StdConfigurableEngine;
-import com.att.research.xacml.util.XACMLProperties;
-import com.google.common.base.Joiner;
-import com.google.common.base.Splitter;
-
-
/**
- * The persistent class for the PIPConfiguration database table.
- *
+ * The persistent class for the PipConfiguration database table.
+ *
*/
@Entity
-@Table(name="PIPConfiguration")
-@NamedQuery(name="PIPConfiguration.findAll", query="SELECT p FROM PIPConfiguration p")
-public class PIPConfiguration implements Serializable {
+@Table(name = "PipConfiguration")
+@NamedQuery(name = "PipConfiguration.findAll", query = "SELECT p FROM PipConfiguration p")
+@Getter
+@Setter
+@NoArgsConstructor
+@ToString
+public class PipConfiguration implements Serializable {
private static final long serialVersionUID = 1L;
- private static final Log logger = LogFactory.getLog(PIPConfiguration.class);
+ private static final Log logger = LogFactory.getLog(PipConfiguration.class);
@Id
- @GeneratedValue(strategy=GenerationType.AUTO)
- @Column(name="id")
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
private int id;
- @Column(name="DESCRIPTION", nullable=true, length=2048)
+ @Column(name = "DESCRIPTION", nullable = true, length = 2048)
private String description;
- @Column(name="NAME", nullable=false, length=255)
+ @Column(name = "NAME", nullable = false, length = 255)
private String name;
- @Column(name="CLASSNAME", nullable=false, length=2048)
+ @Column(name = "CLASSNAME", nullable = false, length = 2048)
private String classname;
- @Column(name="ISSUER", nullable=true, length=1024)
+ @Column(name = "ISSUER", nullable = true, length = 1024)
private String issuer;
- @Column(name="READ_ONLY", nullable=false)
+ @Column(name = "READ_ONLY", nullable = false)
private char readOnly = '0';
- @Column(name="REQUIRES_RESOLVER", nullable=false)
+ @Column(name = "REQUIRES_RESOLVER", nullable = false)
private char requiresResolvers;
- @Column(name="CREATED_BY", nullable=false, length=255)
+ @Column(name = "CREATED_BY", nullable = false, length = 255)
private String createdBy = "guest";
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="CREATED_DATE", nullable=false, updatable=false)
+ @Column(name = "CREATED_DATE", nullable = false, updatable = false)
private Date createdDate;
- @Column(name="MODIFIED_BY", nullable=false, length=255)
+ @Column(name = "MODIFIED_BY", nullable = false, length = 255)
private String modifiedBy = "guest";
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="MODIFIED_DATE", nullable=false)
+ @Column(name = "MODIFIED_DATE", nullable = false)
private Date modifiedDate;
- //bi-directional many-to-one association to PIPConfigParam
- @OneToMany(mappedBy="pipconfiguration", orphanRemoval=true, cascade=CascadeType.REMOVE)
- private Set<PIPConfigParam> pipconfigParams = new HashSet<>();
+ // bi-directional many-to-one association to PipConfigParam
+ @OneToMany(mappedBy = "pipconfiguration", orphanRemoval = true, cascade = CascadeType.REMOVE)
+ private Set<PipConfigParam> pipconfigParams = new HashSet<>();
- //bi-directional many-to-one association to PIPType
+ // bi-directional many-to-one association to PipType
@ManyToOne
- @JoinColumn(name="TYPE")
- private PIPType piptype;
-
- //bi-directional many-to-one association to PIPResolver
- @OneToMany(mappedBy="pipconfiguration", orphanRemoval=true, cascade=CascadeType.REMOVE)
- private Set<PIPResolver> pipresolvers = new HashSet<>();
-
- public PIPConfiguration() {
- //An empty constructor
- }
-
- public PIPConfiguration(PIPConfiguration config, String user) {
+ @JoinColumn(name = "TYPE")
+ private PipType piptype;
+
+ // bi-directional many-to-one association to PipResolver
+ @OneToMany(mappedBy = "pipconfiguration", orphanRemoval = true, cascade = CascadeType.REMOVE)
+ private Set<PipResolver> pipresolvers = new HashSet<>();
+
+ /**
+ * Instantiates a new PIP configuration.
+ *
+ * @param config the config
+ * @param user the user
+ */
+ public PipConfiguration(PipConfiguration config, String user) {
this.description = config.description;
this.name = config.name;
this.classname = config.classname;
@@ -135,108 +146,77 @@ public class PIPConfiguration implements Serializable {
this.requiresResolvers = config.requiresResolvers;
this.readOnly = config.readOnly;
this.piptype = config.piptype;
- for (PIPConfigParam param : config.pipconfigParams) {
- this.addPipconfigParam(new PIPConfigParam(param));
+ for (PipConfigParam param : config.pipconfigParams) {
+ this.addPipconfigParam(new PipConfigParam(param));
}
- for (PIPResolver resolver : config.pipresolvers) {
- this.addPipresolver(new PIPResolver(resolver));
+ for (PipResolver resolver : config.pipresolvers) {
+ this.addPipresolver(new PipResolver(resolver));
}
}
- public PIPConfiguration(String id, Properties properties) throws PIPException {
+ /**
+ * Instantiates a new PIP configuration.
+ *
+ * @param id the id
+ * @param properties the properties
+ * @throws PIPException the PIP exception
+ */
+ public PipConfiguration(String id, Properties properties) throws PIPException {
this.readProperties(id, properties);
}
- public PIPConfiguration(String id, Properties properties, String user) throws PIPException {
+ /**
+ * Instantiates a new PIP configuration.
+ *
+ * @param id the id
+ * @param properties the properties
+ * @param user the user
+ * @throws PIPException the PIP exception
+ */
+ public PipConfiguration(String id, Properties properties, String user) throws PIPException {
this.createdBy = user;
this.modifiedBy = user;
this.readProperties(id, properties);
}
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getClassname() {
- return classname;
- }
-
- public void setClassname(String classname) {
- this.classname = classname;
- }
-
- public String getIssuer() {
- return issuer;
- }
-
- public void setIssuer(String issuer) {
- this.issuer = issuer;
- }
-
- public char getReadOnly() {
- return readOnly;
- }
-
- public void setReadOnly(char readOnly) {
- this.readOnly = readOnly;
- }
-
- public char getRequiresResolvers() {
- return requiresResolvers;
- }
-
- public void setRequiresResolvers(char requireResolvers) {
- this.requiresResolvers = requireResolvers;
- }
-
- public Set<PIPConfigParam> getPipconfigParams() {
- return this.pipconfigParams;
- }
-
- public void setPipconfigParams(Set<PIPConfigParam> pipconfigParams) {
- this.pipconfigParams = pipconfigParams;
- }
-
- public PIPConfigParam addPipconfigParam(PIPConfigParam pipconfigParam) {
+ /**
+ * Adds the pipconfig param.
+ *
+ * @param pipconfigParam the pipconfig param
+ * @return the PIP config param
+ */
+ public PipConfigParam addPipconfigParam(PipConfigParam pipconfigParam) {
getPipconfigParams().add(pipconfigParam);
pipconfigParam.setPipconfiguration(this);
return pipconfigParam;
}
- public PIPConfigParam removePipconfigParam(PIPConfigParam pipconfigParam) {
+ /**
+ * Removes the pipconfig param.
+ *
+ * @param pipconfigParam the pipconfig param
+ * @return the PIP config param
+ */
+ public PipConfigParam removePipconfigParam(PipConfigParam pipconfigParam) {
if (pipconfigParam == null) {
return pipconfigParam;
}
@@ -246,6 +226,9 @@ public class PIPConfiguration implements Serializable {
return pipconfigParam;
}
+ /**
+ * Clear config params.
+ */
@Transient
public void clearConfigParams() {
while (!this.pipconfigParams.isEmpty()) {
@@ -253,75 +236,49 @@ public class PIPConfiguration implements Serializable {
}
}
- public PIPType getPiptype() {
- return this.piptype;
- }
-
- public void setPiptype(PIPType piptype) {
- this.piptype = piptype;
- }
-
- public Set<PIPResolver> getPipresolvers() {
- return this.pipresolvers;
- }
-
- public void setPipresolvers(Set<PIPResolver> pipresolvers) {
- this.pipresolvers = pipresolvers;
- }
-
- public PIPResolver addPipresolver(PIPResolver pipresolver) {
+ /**
+ * Adds the pipresolver.
+ *
+ * @param pipresolver the pipresolver
+ * @return the PIP resolver
+ */
+ public PipResolver addPipresolver(PipResolver pipresolver) {
getPipresolvers().add(pipresolver);
pipresolver.setPipconfiguration(this);
return pipresolver;
}
- public PIPResolver removePipresolver(PIPResolver pipresolver) {
+ /**
+ * Removes the pipresolver.
+ *
+ * @param pipresolver the pipresolver
+ * @return the PIP resolver
+ */
+ public PipResolver removePipresolver(PipResolver pipresolver) {
getPipresolvers().remove(pipresolver);
pipresolver.setPipconfiguration(null);
return pipresolver;
}
- public String getCreatedBy() {
- return createdBy;
- }
-
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- public Date getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getModifiedBy() {
- return modifiedBy;
- }
-
- public void setModifiedBy(String modifiedBy) {
- this.modifiedBy = modifiedBy;
- }
-
- public Date getModifiedDate() {
- return modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
+ /**
+ * Checks if is read only.
+ *
+ * @return true, if is read only
+ */
@Transient
public boolean isReadOnly() {
return this.readOnly == '1';
}
+ /**
+ * Sets the read only flag.
+ *
+ * @param readOnly the new read only flag
+ */
@Transient
- public void setReadOnly(boolean readOnly) {
+ public void setReadOnlyFlag(boolean readOnly) {
if (readOnly) {
this.readOnly = '1';
} else {
@@ -329,13 +286,23 @@ public class PIPConfiguration implements Serializable {
}
}
+ /**
+ * Requires resolvers.
+ *
+ * @return true, if successful
+ */
@Transient
public boolean requiresResolvers() {
return this.requiresResolvers == '1';
}
+ /**
+ * Sets the requires resolvers flag.
+ *
+ * @param requires the new requires resolvers flag
+ */
@Transient
- public void setRequiresResolvers(boolean requires) {
+ public void setRequiresResolversFlag(boolean requires) {
if (requires) {
this.requiresResolvers = '1';
} else {
@@ -343,32 +310,45 @@ public class PIPConfiguration implements Serializable {
}
}
+ /**
+ * Import PIP configurations.
+ *
+ * @param properties the properties
+ * @return the collection
+ */
@Transient
- public static Collection<PIPConfiguration> importPIPConfigurations(Properties properties) {
- Collection<PIPConfiguration> configurations = new ArrayList<>();
+ public static Collection<PipConfiguration> importPipConfigurations(Properties properties) {
+ Collection<PipConfiguration> configurations = new ArrayList<>();
String engines = properties.getProperty(XACMLProperties.PROP_PIP_ENGINES);
if (engines == null || engines.isEmpty()) {
return configurations;
}
for (String id : Splitter.on(',').trimResults().omitEmptyStrings().split(engines)) {
- PIPConfiguration configuration;
+ PipConfiguration configuration;
try {
String user = "super-admin";
- configuration = new PIPConfiguration(id, properties, user);
+ configuration = new PipConfiguration(id, properties, user);
configuration.setCreatedBy(user);
configuration.setModifiedBy(user);
configurations.add(configuration);
} catch (PIPException e) {
logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Import failed: " + e.getLocalizedMessage());
- PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PIPConfiguration", "Import failed");
+ PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PipConfiguration", "Import failed");
}
}
return configurations;
}
+ /**
+ * Read properties.
+ *
+ * @param id the id
+ * @param properties the properties
+ * @throws PIPException the PIP exception
+ */
@Transient
- protected void readProperties(String id, Properties properties) throws PIPException {
+ protected void readProperties(String id, Properties properties) throws PIPException {
//
// Save the id if we don't have one already
//
@@ -378,7 +358,7 @@ public class PIPConfiguration implements Serializable {
this.id = Integer.parseInt(id);
} catch (NumberFormatException e) {
logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Convert id to integer failed: " + id);
- PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PIPConfiguration", "Convert id to integer failed");
+ PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PipConfiguration", "Convert id to integer failed");
}
}
//
@@ -391,47 +371,8 @@ public class PIPConfiguration implements Serializable {
//
// Go through each property
//
- for (Object nme : properties.keySet()) {
- if (!nme.toString().startsWith(id)) {
- continue;
- }
- if (nme.equals(id + ".classname")) {
- //
- // We already saved this
- //
- } else if (nme.equals(id + "." + StdConfigurableEngine.PROP_NAME)) {
- this.name = properties.getProperty(nme.toString());
- } else if (nme.equals(id + "." + StdConfigurableEngine.PROP_DESCRIPTION)) {
- this.description = properties.getProperty(nme.toString());
- } else if (nme.equals(id + "." + StdConfigurableEngine.PROP_ISSUER)) {
- this.issuer = properties.getProperty(nme.toString());
- } else if (nme.equals(id + ".resolvers")) {
- //
- // It has resolvers, make sure this is set to true if
- // it has been already.
- //
- this.setRequiresResolvers(true);
- //
- // Parse the resolvers
- //
- Collection<PIPResolver> resolvers = PIPResolver.importResolvers(id + ".resolver",
- properties.getProperty(nme.toString()),
- properties,"super-admin"
- );
- for (PIPResolver resolver : resolvers) {
- this.addPipresolver(resolver);
- }
- } else if (nme.toString().startsWith(id + ".resolver")) {
- //
- // Ignore, the PIPResolver will parse these values
- //
- } else {
- //
- // Config Parameter
- //
- this.addPipconfigParam(new PIPConfigParam(nme.toString().substring(id.length() + 1),
- properties.getProperty(nme.toString())));
- }
+ for (Object propertyKey : properties.keySet()) {
+ readProperty(id, properties, propertyKey);
}
//
// Make sure we have a name at least
@@ -441,7 +382,61 @@ public class PIPConfiguration implements Serializable {
}
}
+ /**
+ * Read a property into the PIP configuration.
+ *
+ * @param id the ID of the property
+ * @param properties the properties object to read from
+ * @param key the key of the property being checked
+ * @throws PIPException on exceptions thrown on reading the property
+ */
+ private void readProperty(String id, Properties properties, Object key) throws PIPException {
+ if (!key.toString().startsWith(id)) {
+ return;
+ }
+ if (key.equals(id + ".classname")) {
+ //
+ // We already saved this
+ //
+ } else if (key.equals(id + "." + StdConfigurableEngine.PROP_NAME)) {
+ this.name = properties.getProperty(key.toString());
+ } else if (key.equals(id + "." + StdConfigurableEngine.PROP_DESCRIPTION)) {
+ this.description = properties.getProperty(key.toString());
+ } else if (key.equals(id + "." + StdConfigurableEngine.PROP_ISSUER)) {
+ this.issuer = properties.getProperty(key.toString());
+ } else if (key.equals(id + ".resolvers")) {
+ //
+ // It has resolvers, make sure this is set to true if
+ // it has been already.
+ //
+ this.setRequiresResolversFlag(true);
+ //
+ // Parse the resolvers
+ //
+ Collection<PipResolver> resolvers = PipResolver.importResolvers(id + ".resolver",
+ properties.getProperty(key.toString()), properties, "super-admin");
+ for (PipResolver resolver : resolvers) {
+ this.addPipresolver(resolver);
+ }
+ } else if (key.toString().startsWith(id + ".resolver")) {
+ //
+ // Ignore, the PipResolver will parse these values
+ //
+ } else {
+ //
+ // Config Parameter
+ //
+ this.addPipconfigParam(new PipConfigParam(key.toString().substring(id.length() + 1),
+ properties.getProperty(key.toString())));
+ }
+ }
+ /**
+ * Gets the configuration.
+ *
+ * @param name the name
+ * @return the configuration
+ */
@Transient
public Map<String, String> getConfiguration(String name) {
String prefix;
@@ -463,14 +458,14 @@ public class PIPConfiguration implements Serializable {
map.put(prefix + "issuer", this.issuer);
}
- for (PIPConfigParam param : this.pipconfigParams) {
+ for (PipConfigParam param : this.pipconfigParams) {
map.put(prefix + param.getParamName(), param.getParamValue());
}
List<String> ids = new ArrayList<>();
- Iterator<PIPResolver> iter = this.pipresolvers.iterator();
+ Iterator<PipResolver> iter = this.pipresolvers.iterator();
while (iter.hasNext()) {
- PIPResolver resolver = iter.next();
+ PipResolver resolver = iter.next();
String idd = Integer.toString(resolver.getId());
Map<String, String> resolverMap = resolver.getConfiguration(prefix + "resolver." + idd);
map.putAll(resolverMap);
@@ -482,8 +477,14 @@ public class PIPConfiguration implements Serializable {
return map;
}
+ /**
+ * Generate properties.
+ *
+ * @param name the name
+ * @return the properties
+ */
@Transient
- public Properties generateProperties(String name) {
+ public Properties generateProperties(String name) {
String prefix;
if (name == null) {
prefix = Integer.toString(this.id);
@@ -492,10 +493,14 @@ public class PIPConfiguration implements Serializable {
prefix = name;
} else {
prefix = name + ".";
+ /**
+ * Instantiates a new PIP configuration.
+ */
+
}
}
Properties props = new Properties();
- props.setProperty("xacml.pip.engines", name);
+ props.setProperty("xacml.pip.engines", prefix);
props.setProperty(prefix + "classname", this.classname);
props.setProperty(prefix + "name", this.name);
if (this.description != null) {
@@ -505,14 +510,14 @@ public class PIPConfiguration implements Serializable {
props.setProperty(prefix + "issuer", this.issuer);
}
- for (PIPConfigParam param : this.pipconfigParams) {
+ for (PipConfigParam param : this.pipconfigParams) {
props.setProperty(prefix + param.getParamName(), param.getParamValue());
}
List<String> ids = new ArrayList<>();
- Iterator<PIPResolver> iter = this.pipresolvers.iterator();
+ Iterator<PipResolver> iter = this.pipresolvers.iterator();
while (iter.hasNext()) {
- PIPResolver resolver = iter.next();
+ PipResolver resolver = iter.next();
String idd = Integer.toString(resolver.getId());
resolver.generateProperties(props, prefix + "resolver." + idd);
ids.add(idd);
@@ -522,17 +527,4 @@ public class PIPConfiguration implements Serializable {
}
return props;
}
-
- @Transient
- @Override
- public String toString() {
- return "PIPConfiguration [id=" + id + ", piptype=" + piptype
- + ", classname=" + classname + ", name=" + name
- + ", description=" + description + ", issuer=" + issuer
- + ", readOnly=" + readOnly + ", requiresResolvers="
- + requiresResolvers + ", createdBy=" + createdBy
- + ", createdDate=" + createdDate + ", modifiedBy=" + modifiedBy
- + ", modifiedDate=" + modifiedDate + ", pipconfigParams="
- + pipconfigParams + ", pipresolvers=" + pipresolvers + "]";
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolver.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipResolver.java
index a8b02580d..74e24b3db 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolver.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipResolver.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +21,10 @@
package org.onap.policy.rest.jpa;
+import com.att.research.xacml.api.pip.PIPException;
+import com.att.research.xacml.std.pip.engines.StdConfigurableEngine;
+import com.google.common.base.Splitter;
+
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
@@ -47,202 +52,135 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
-import com.att.research.xacml.api.pip.PIPException;
-import com.att.research.xacml.std.pip.engines.StdConfigurableEngine;
-import com.google.common.base.Splitter;
-
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
/**
- * The persistent class for the PIPResolver database table.
- *
+ * The persistent class for the PipResolver database table.
+ *
*/
@Entity
-@Table(name="PIPResolver")
-@NamedQuery(name="PIPResolver.findAll", query="SELECT p FROM PIPResolver p")
-public class PIPResolver implements Serializable {
+@Table(name = "PipResolver")
+@NamedQuery(name = "PipResolver.findAll", query = "SELECT p FROM PipResolver p")
+@Getter
+@Setter
+@NoArgsConstructor
+public class PipResolver implements Serializable {
private static final long serialVersionUID = 1L;
@Id
- @GeneratedValue(strategy=GenerationType.AUTO)
- @Column(name="id")
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
private int id;
- @Column(name="DESCRIPTION", nullable=true, length=2048)
+ @Column(name = "DESCRIPTION", nullable = true, length = 2048)
private String description;
- @Column(name="NAME", nullable=false, length=255)
+ @Column(name = "NAME", nullable = false, length = 255)
private String name;
- @Column(name="ISSUER", nullable=true, length=1024)
+ @Column(name = "ISSUER", nullable = true, length = 1024)
private String issuer;
- @Column(name="CLASSNAME", nullable=false, length=2048)
+ @Column(name = "CLASSNAME", nullable = false, length = 2048)
private String classname;
- @Column(name="READ_ONLY", nullable=false)
+ @Column(name = "READ_ONLY", nullable = false)
private char readOnly = '0';
- @Column(name="CREATED_BY", nullable=false, length=255)
+ @Column(name = "CREATED_BY", nullable = false, length = 255)
private String createdBy = "guest";
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="CREATED_DATE", nullable=false, updatable=false)
+ @Column(name = "CREATED_DATE", nullable = false, updatable = false)
private Date createdDate;
- @Column(name="MODIFIED_BY", nullable=false, length=255)
+ @Column(name = "MODIFIED_BY", nullable = false, length = 255)
private String modifiedBy = "guest";
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="MODIFIED_DATE", nullable=false)
+ @Column(name = "MODIFIED_DATE", nullable = false)
private Date modifiedDate;
- //bi-directional many-to-one association to PIPConfiguration
+ // bi-directional many-to-one association to PipConfiguration
@ManyToOne
- @JoinColumn(name="PIP_ID")
- private PIPConfiguration pipconfiguration;
-
- //bi-directional many-to-one association to PIPResolverParam
- @OneToMany(mappedBy="pipresolver", orphanRemoval=true, cascade=CascadeType.REMOVE)
- private Set<PIPResolverParam> pipresolverParams = new HashSet<>();
-
- public PIPResolver() {
- //An empty constructor
- }
-
- public PIPResolver(String prefix, Properties properties, String user) throws PIPException {
+ @JoinColumn(name = "PIP_ID")
+ private PipConfiguration pipconfiguration;
+
+ // bi-directional many-to-one association to PipResolverParam
+ @OneToMany(mappedBy = "pipresolver", orphanRemoval = true, cascade = CascadeType.REMOVE)
+ private Set<PipResolverParam> pipresolverParams = new HashSet<>();
+
+ /**
+ * Instantiates a new PIP resolver.
+ *
+ * @param prefix the prefix
+ * @param properties the properties
+ * @param user the user
+ * @throws PIPException the PIP exception
+ */
+ public PipResolver(String prefix, Properties properties, String user) throws PIPException {
this.createdBy = user;
this.modifiedBy = user;
this.readOnly = '0';
this.readProperties(prefix, properties);
}
- public PIPResolver(PIPResolver resolver) {
+ /**
+ * Instantiates a new PIP resolver.
+ *
+ * @param resolver the resolver
+ */
+ public PipResolver(PipResolver resolver) {
this.name = resolver.name;
this.description = resolver.description;
this.issuer = resolver.issuer;
this.classname = resolver.classname;
this.readOnly = resolver.readOnly;
- for (PIPResolverParam param : this.pipresolverParams) {
- this.addPipresolverParam(new PIPResolverParam(param));
+ for (PipResolverParam param : resolver.pipresolverParams) {
+ this.addPipresolverParam(new PipResolverParam(param));
}
}
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getIssuer() {
- return issuer;
- }
-
- public void setIssuer(String issuer) {
- this.issuer = issuer;
- }
-
- public String getClassname() {
- return classname;
- }
-
- public void setClassname(String classname) {
- this.classname = classname;
- }
-
- public char getReadOnly() {
- return readOnly;
- }
-
- public void setReadOnly(char readOnly) {
- this.readOnly = readOnly;
- }
-
- public String getCreatedBy() {
- return createdBy;
- }
-
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- public Date getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getModifiedBy() {
- return modifiedBy;
- }
-
- public void setModifiedBy(String modifiedBy) {
- this.modifiedBy = modifiedBy;
- }
-
- public Date getModifiedDate() {
- return modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
- public PIPConfiguration getPipconfiguration() {
- return this.pipconfiguration;
- }
-
- public void setPipconfiguration(PIPConfiguration pipconfiguration) {
- this.pipconfiguration = pipconfiguration;
- }
-
- public Set<PIPResolverParam> getPipresolverParams() {
- return this.pipresolverParams;
- }
-
- public void setPipresolverParams(Set<PIPResolverParam> pipresolverParams) {
- this.pipresolverParams = pipresolverParams;
- }
-
- public PIPResolverParam addPipresolverParam(PIPResolverParam pipresolverParam) {
+ /**
+ * Adds the pipresolver param.
+ *
+ * @param pipresolverParam the pipresolver param
+ * @return the PIP resolver param
+ */
+ public PipResolverParam addPipresolverParam(PipResolverParam pipresolverParam) {
getPipresolverParams().add(pipresolverParam);
pipresolverParam.setPipresolver(this);
return pipresolverParam;
}
- public PIPResolverParam removePipresolverParam(PIPResolverParam pipresolverParam) {
+ /**
+ * Removes the pipresolver param.
+ *
+ * @param pipresolverParam the pipresolver param
+ * @return the PIP resolver param
+ */
+ public PipResolverParam removePipresolverParam(PipResolverParam pipresolverParam) {
if (pipresolverParam == null) {
return pipresolverParam;
}
@@ -252,6 +190,9 @@ public class PIPResolver implements Serializable {
return pipresolverParam;
}
+ /**
+ * Clear params.
+ */
@Transient
public void clearParams() {
while (!this.pipresolverParams.isEmpty()) {
@@ -259,11 +200,21 @@ public class PIPResolver implements Serializable {
}
}
+ /**
+ * Checks if is read only.
+ *
+ * @return true, if is read only
+ */
@Transient
public boolean isReadOnly() {
return this.readOnly == '1';
}
+ /**
+ * Sets the read only.
+ *
+ * @param readOnly the new read only
+ */
@Transient
public void setReadOnly(boolean readOnly) {
if (readOnly) {
@@ -273,15 +224,33 @@ public class PIPResolver implements Serializable {
}
}
+ /**
+ * Import resolvers.
+ *
+ * @param prefix the prefix
+ * @param list the list
+ * @param properties the properties
+ * @param user the user
+ * @return the collection
+ * @throws PIPException the PIP exception
+ */
@Transient
- public static Collection<PIPResolver> importResolvers(String prefix, String list, Properties properties, String user) throws PIPException {
- Collection<PIPResolver> resolvers = new ArrayList<>();
+ public static Collection<PipResolver> importResolvers(String prefix, String list, Properties properties,
+ String user) throws PIPException {
+ Collection<PipResolver> resolvers = new ArrayList<>();
for (String id : Splitter.on(',').trimResults().omitEmptyStrings().split(list)) {
- resolvers.add(new PIPResolver(prefix + "." + id, properties, user));
+ resolvers.add(new PipResolver(prefix + "." + id, properties, user));
}
return resolvers;
}
+ /**
+ * Read properties.
+ *
+ * @param prefix the prefix
+ * @param properties the properties
+ * @throws PIPException the PIP exception
+ */
@Transient
protected void readProperties(String prefix, Properties properties) throws PIPException {
//
@@ -309,12 +278,18 @@ public class PIPResolver implements Serializable {
} else if (nme.equals(prefix + "." + StdConfigurableEngine.PROP_ISSUER)) {
this.issuer = properties.getProperty(nme.toString());
} else {
- this.addPipresolverParam(new PIPResolverParam(nme.toString().substring(prefix.length() + 1),
- properties.getProperty(nme.toString())));
+ this.addPipresolverParam(new PipResolverParam(nme.toString().substring(prefix.length() + 1),
+ properties.getProperty(nme.toString())));
}
}
}
+ /**
+ * Gets the configuration.
+ *
+ * @param prefix the prefix
+ * @return the configuration
+ */
@Transient
public Map<String, String> getConfiguration(String prefix) {
String pref = prefix;
@@ -330,14 +305,20 @@ public class PIPResolver implements Serializable {
if (this.issuer != null && this.issuer.isEmpty()) {
map.put(pref + "issuer", this.issuer);
}
- for (PIPResolverParam param : this.pipresolverParams) {
+ for (PipResolverParam param : this.pipresolverParams) {
map.put(pref + param.getParamName(), param.getParamValue());
}
return map;
}
+ /**
+ * Generate properties.
+ *
+ * @param props the props
+ * @param prefix the prefix
+ */
@Transient
- public void generateProperties(Properties props, String prefix) {
+ public void generateProperties(Properties props, String prefix) {
String pref = prefix;
if (!prefix.endsWith(".")) {
pref = prefix + ".";
@@ -350,19 +331,22 @@ public class PIPResolver implements Serializable {
if (this.issuer != null && this.issuer.isEmpty()) {
props.setProperty(pref + "issuer", this.issuer);
}
- for (PIPResolverParam param : this.pipresolverParams) {
+ for (PipResolverParam param : this.pipresolverParams) {
props.setProperty(pref + param.getParamName(), param.getParamValue());
}
}
+ /**
+ * To string.
+ *
+ * @return the string
+ */
@Transient
@Override
public String toString() {
- return "PIPResolver [id=" + id + ", classname=" + classname + ", name="
- + name + ", description=" + description + ", issuer=" + issuer
- + ", readOnly=" + readOnly + ", createdBy=" + createdBy
- + ", createdDate=" + createdDate + ", modifiedBy=" + modifiedBy
- + ", modifiedDate=" + modifiedDate + ", pipresolverParams="
- + pipresolverParams + "]";
+ return "PipResolver [id=" + id + ", classname=" + classname + ", name=" + name + ", description=" + description
+ + ", issuer=" + issuer + ", readOnly=" + readOnly + ", createdBy=" + createdBy
+ + ", createdDate=" + createdDate + ", modifiedBy=" + modifiedBy + ", modifiedDate="
+ + modifiedDate + ", pipresolverParams=" + pipresolverParams + "]";
}
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipResolverParam.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipResolverParam.java
new file mode 100644
index 000000000..3dd096862
--- /dev/null
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipResolverParam.java
@@ -0,0 +1,132 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-REST
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.rest.jpa;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * The persistent class for the PipResolverParam database table.
+ *
+ */
+@Entity
+@Table(name = "PipResolverParams")
+@NamedQuery(name = "PipResolverParam.findAll", query = "SELECT p FROM PipResolverParam p")
+@Getter
+@Setter
+@NoArgsConstructor
+@ToString
+public class PipResolverParam implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
+ private int id;
+
+ @Column(name = "PARAM_NAME", nullable = false, length = 1024)
+ private String paramName;
+
+ @Column(name = "PARAM_VALUE", nullable = false, length = 2048)
+ private String paramValue;
+
+ @Column(name = "PARAM_DEFAULT", nullable = true, length = 2048)
+ private String paramDefault;
+
+ @Column(name = "REQUIRED", nullable = false)
+ private char required = '0';
+
+ // bi-directional many-to-one association to PipResolver
+ @ManyToOne
+ @JoinColumn(name = "ID_RESOLVER")
+ private PipResolver pipresolver;
+
+ /**
+ * Instantiates a new PIP resolver param.
+ *
+ * @param name the name
+ */
+ public PipResolverParam(String name) {
+ this.paramName = name;
+ }
+
+ /**
+ * Instantiates a new PIP resolver param.
+ *
+ * @param name the name
+ * @param value the value
+ */
+ public PipResolverParam(String name, String value) {
+ this(name);
+ this.paramValue = value;
+ }
+
+ /**
+ * Instantiates a new PIP resolver param.
+ *
+ * @param param the param
+ */
+ public PipResolverParam(PipResolverParam param) {
+ this(param.getParamName(), param.getParamValue());
+ this.paramDefault = param.getParamDefault();
+ this.required = param.required;
+ }
+
+ /**
+ * Checks if is required.
+ *
+ * @return true, if is required
+ */
+ @Transient
+ public boolean isRequired() {
+ return this.required == '1';
+ }
+
+ /**
+ * Sets the required.
+ *
+ * @param required the new required
+ */
+ @Transient
+ public void setRequired(boolean required) {
+ if (required) {
+ this.required = '1';
+ } else {
+ this.required = '0';
+ }
+ }
+}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipType.java
index aa8c45ef2..0179d0d33 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPType.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PipType.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -33,15 +34,21 @@ import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
/**
- * The persistent class for the PIPType database table.
- *
+ * The persistent class for the PipType database table.
+ *
*/
@Entity
-@Table(name="PIPType")
-@NamedQuery(name="PIPType.findAll", query="SELECT p FROM PIPType p")
-public class PIPType implements Serializable {
+@Table(name = "PipType")
+@NamedQuery(name = "PipType.findAll", query = "SELECT p FROM PipType p")
+@Getter
+@Setter
+@NoArgsConstructor
+public class PipType implements Serializable {
private static final long serialVersionUID = 1L;
public static final String TYPE_SQL = "SQL";
@@ -51,81 +58,90 @@ public class PIPType implements Serializable {
public static final String TYPE_CUSTOM = "Custom";
@Id
- @GeneratedValue(strategy=GenerationType.AUTO)
- @Column(name="id")
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
private int id;
- @Column(name="type", nullable=false, length=45)
+ @Column(name = "type", nullable = false, length = 45)
private String type;
- //bi-directional many-to-one association to PIPConfiguration
- @OneToMany(mappedBy="piptype")
- private Set<PIPConfiguration> pipconfigurations;
-
- public PIPType() {
- // Empty constructor
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getType() {
- return this.type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public Set<PIPConfiguration> getPipconfigurations() {
- return this.pipconfigurations;
- }
-
- public void setPipconfigurations(Set<PIPConfiguration> pipconfigurations) {
- this.pipconfigurations = pipconfigurations;
- }
-
- public PIPConfiguration addPipconfiguration(PIPConfiguration pipconfiguration) {
+ // bi-directional many-to-one association to PipConfiguration
+ @OneToMany(mappedBy = "piptype")
+ private Set<PipConfiguration> pipconfigurations;
+
+ /**
+ * Adds the pipconfiguration.
+ *
+ * @param pipconfiguration the pipconfiguration
+ * @return the PIP configuration
+ */
+ public PipConfiguration addPipconfiguration(PipConfiguration pipconfiguration) {
getPipconfigurations().add(pipconfiguration);
pipconfiguration.setPiptype(this);
return pipconfiguration;
}
- public PIPConfiguration removePipconfiguration(PIPConfiguration pipconfiguration) {
+ /**
+ * Removes the pipconfiguration.
+ *
+ * @param pipconfiguration the pipconfiguration
+ * @return the PIP configuration
+ */
+ public PipConfiguration removePipconfiguration(PipConfiguration pipconfiguration) {
getPipconfigurations().remove(pipconfiguration);
pipconfiguration.setPiptype(null);
return pipconfiguration;
}
+ /**
+ * Checks if is sql.
+ *
+ * @return true, if is sql
+ */
@Transient
- public boolean isSQL() {
+ public boolean isSql() {
return this.type.equals(TYPE_SQL);
}
+ /**
+ * Checks if is ldap.
+ *
+ * @return true, if is ldap
+ */
@Transient
- public boolean isLDAP() {
+ public boolean isLdap() {
return this.type.equals(TYPE_LDAP);
}
+ /**
+ * Checks if is csv.
+ *
+ * @return true, if is csv
+ */
@Transient
- public boolean isCSV() {
+ public boolean isCsv() {
return this.type.equals(TYPE_CSV);
}
+ /**
+ * Checks if is hyper CSV.
+ *
+ * @return true, if is hyper CSV
+ */
@Transient
- public boolean isHyperCSV() {
+ public boolean isHyperCsv() {
return this.type.equals(TYPE_HYPERCSV);
}
+ /**
+ * Checks if is custom.
+ *
+ * @return true, if is custom
+ */
@Transient
- public boolean isCustom() {
+ public boolean isCustom() {
return this.type.equals(TYPE_CUSTOM);
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAlgorithms.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAlgorithms.java
index ba1097500..0f23f55da 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAlgorithms.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAlgorithms.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +21,8 @@
package org.onap.policy.rest.jpa;
+import com.att.research.xacml.api.Identifier;
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -31,11 +34,17 @@ import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
-import com.att.research.xacml.api.Identifier;
+import lombok.Getter;
+import lombok.Setter;
+/**
+ * The Class PolicyAlgorithms.
+ */
@Entity
-@Table(name="PolicyAlgorithms")
-@NamedQuery(name="PolicyAlgorithms.findAll", query="SELECT d FROM PolicyAlgorithms d")
+@Table(name = "PolicyAlgorithms")
+@NamedQuery(name = "PolicyAlgorithms.findAll", query = "SELECT d FROM PolicyAlgorithms d")
+@Getter
+@Setter
public class PolicyAlgorithms implements Serializable {
private static final long serialVersionUID = 1L;
@@ -44,18 +53,24 @@ public class PolicyAlgorithms implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="is_standard", nullable=false)
+ @Column(name = "is_standard", nullable = false)
private char isStandard;
- @Column(name="xacml_id", nullable=false, unique=true, length=255)
+ @Column(name = "xacml_id", nullable = false, unique = true, length = 255)
private String xacmlId;
- @Column(name="short_name", nullable=false, length=64)
+ @Column(name = "short_name", nullable = false, length = 64)
private String shortName;
+ /**
+ * Instantiates a new policy algorithms.
+ *
+ * @param identifier the identifier
+ * @param standard the standard
+ */
public PolicyAlgorithms(Identifier identifier, char standard) {
this.isStandard = standard;
if (identifier != null) {
@@ -63,54 +78,39 @@ public class PolicyAlgorithms implements Serializable {
}
}
+ /**
+ * Instantiates a new policy algorithms.
+ *
+ * @param identifier the identifier
+ */
public PolicyAlgorithms(Identifier identifier) {
this(identifier, PolicyAlgorithms.STANDARD);
}
+ /**
+ * Instantiates a new policy algorithms.
+ */
public PolicyAlgorithms() {
this(null, PolicyAlgorithms.STANDARD);
}
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public char getIsStandard() {
- return this.isStandard;
- }
-
- public void setIsStandard(char isStandard) {
- this.isStandard = isStandard;
- }
-
+ /**
+ * Checks if is standard.
+ *
+ * @return true, if is standard
+ */
@Transient
public boolean isStandard() {
return this.isStandard == PolicyAlgorithms.STANDARD;
}
+ /**
+ * Checks if is custom.
+ *
+ * @return true, if is custom
+ */
@Transient
public boolean isCustom() {
return this.isStandard == PolicyAlgorithms.CUSTOM;
}
-
- public String getXacmlId() {
- return this.xacmlId;
- }
-
- public void setXacmlId(String xacmlId) {
- this.xacmlId = xacmlId;
- }
-
- public String getShortName() {
- return shortName;
- }
-
- public void setShortName(String shortName) {
- this.shortName = shortName;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAuditlog.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAuditlog.java
index bfd7769b4..75924e867 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAuditlog.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAuditlog.java
@@ -3,6 +3,7 @@
* ONAP-PAP-REST
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
package org.onap.policy.rest.jpa;
import java.util.Date;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -29,11 +31,15 @@ import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
+
@Entity
@Table(name = "policyAuditlog")
@NamedQuery(name = "policyAuditlog.findAll", query = "SELECT v FROM PolicyAuditlog v ")
+@Getter
+@Setter
public class PolicyAuditlog {
- private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false, unique = true)
@@ -50,44 +56,4 @@ public class PolicyAuditlog {
@Column(name = "dateAndTime", nullable = false)
private Date dateAndTime;
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public String getPolicyName() {
- return policyName;
- }
-
- public void setPolicyName(String policyName) {
- this.policyName = policyName;
- }
-
- public String getActions() {
- return actions;
- }
-
- public void setActions(String actions) {
- this.actions = actions;
- }
-
- public Date getDateAndTime() {
- return dateAndTime;
- }
-
- public void setDateAndTime(Date dateAndTime) {
- this.dateAndTime = dateAndTime;
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyDBDaoEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyDBDaoEntity.java
deleted file mode 100644
index 7a0c2fe2f..000000000
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyDBDaoEntity.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-REST
- * ================================================================================
- * 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.rest.jpa;
-/*
- */
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.PrePersist;
-import javax.persistence.PreUpdate;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-/*
- * The Entity class to persist a PolicyDBDaoEntity object for registration of PolicyDBDao
- */
-
-/**
- *
- */
-@Entity
-@Table(name="PolicyDBDaoEntity")
-
-@NamedQueries({
- @NamedQuery(name="PolicyDBDaoEntity.findAll", query="SELECT e FROM PolicyDBDaoEntity e "),
- @NamedQuery(name="PolicyDBDaoEntity.deleteAll", query="DELETE FROM PolicyDBDaoEntity WHERE 1=1")
-})
-
-public class PolicyDBDaoEntity implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Id
- @Column(name="policyDBDaoUrl", nullable=false, unique=true)
- private String policyDBDaoUrl;
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
- private Date createdDate;
-
- //username for the pap server that registered this PolicyDBDaoEntity
- @Column(name="username")
- private String username;
-
- //AES encrypted password for the pap server that registered this PolicyDBDaoEntity
- @Column(name="password")
- private String password;
-
- //A column to allow some descriptive text. For example: Atlanta data center
- @Column(name="description", nullable=false, length=2048)
- private String description = "NoDescription";
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
- private Date modifiedDate;
-
- public PolicyDBDaoEntity() {
- super();
- }
-
- @PrePersist
- public void prePersist() {
- Date date = new Date();
- this.createdDate = date;
- this.modifiedDate = date;
- }
-
- @PreUpdate
- public void preUpdate() {
- this.modifiedDate = new Date();
- }
-
- /**
- * @return the policyDBDaoUrl
- */
- public String getPolicyDBDaoUrl() {
- return policyDBDaoUrl;
- }
-
- /**
- * @param url the policyDBDaoUrl to set
- */
- public void setPolicyDBDaoUrl(String url) {
- this.policyDBDaoUrl = url;
- }
-
- /**
- * @return the description
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * @param description the description to set
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * @return the createdDate
- */
- public Date getCreatedDate() {
- return createdDate;
- }
-
- /**
- * @return the modifiedDate
- */
- public Date getModifiedDate() {
- return modifiedDate;
- }
-
- public String getUsername(){
- return this.username;
- }
- public void setUsername(String username){
- this.username = username;
- }
- public String getPassword(){
- return this.password;
- }
- public void setPassword(String password){
- this.password = password;
- }
-}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyDbDaoEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyDbDaoEntity.java
new file mode 100644
index 000000000..fbad21763
--- /dev/null
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyDbDaoEntity.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-REST
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.rest.jpa;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.PrePersist;
+import javax.persistence.PreUpdate;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * The Entity class to persist a PolicyDbDaoEntity object for registration of PolicyDBDao.
+ */
+// @formatter:off
+@Entity
+@Table(name = "PolicyDbDaoEntity")
+@NamedQueries(
+ {
+ @NamedQuery(name = "PolicyDbDaoEntity.findAll", query = "SELECT e FROM PolicyDbDaoEntity e "),
+ @NamedQuery(name = "PolicyDbDaoEntity.deleteAll", query = "DELETE FROM PolicyDbDaoEntity WHERE 1=1")
+ }
+)
+@Getter
+@Setter
+//@formatter:on
+public class PolicyDbDaoEntity implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @Column(name = "policyDbDaoUrl", nullable = false, unique = true)
+ private String policyDbDaoUrl;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "created_date", updatable = false)
+ private Date createdDate;
+
+ // username for the pap server that registered this PolicyDbDaoEntity
+ @Column(name = "username")
+ private String username;
+
+ // AES encrypted password for the pap server that registered this PolicyDbDaoEntity
+ @Column(name = "password")
+ private String password;
+
+ // A column to allow some descriptive text. For example: Atlanta data center
+ @Column(name = "description", nullable = false, length = 2048)
+ private String description = "NoDescription";
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "modified_date", nullable = false)
+ private Date modifiedDate;
+
+ /**
+ * Instantiates a new policy DB dao entity.
+ */
+ public PolicyDbDaoEntity() {
+ super();
+ }
+
+ /**
+ * Pre persist.
+ */
+ @PrePersist
+ public void prePersist() {
+ Date date = new Date();
+ this.createdDate = date;
+ this.modifiedDate = date;
+ }
+
+ /**
+ * Pre update.
+ */
+ @PreUpdate
+ public void preUpdate() {
+ this.modifiedDate = new Date();
+ }
+}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEditorScopes.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEditorScopes.java
index 62fd0266e..7642a1417 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEditorScopes.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEditorScopes.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +23,7 @@ package org.onap.policy.rest.jpa;
import java.io.Serializable;
import java.util.Date;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -37,99 +39,67 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * The Class PolicyEditorScopes.
+ */
@Entity
-@Table(name="PolicyEditorScopes")
-@NamedQuery(name="PolicyEditorScopes.findAll", query="SELECT p FROM PolicyEditorScopes p ")
-public class PolicyEditorScopes implements Serializable{
+@Table(name = "PolicyEditorScopes")
+@NamedQuery(name = "PolicyEditorScopes.findAll", query = "SELECT p FROM PolicyEditorScopes p ")
+@Getter
+@Setter
+public class PolicyEditorScopes implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="scopeName", nullable=false, unique=true)
+ @Column(name = "scopeName", nullable = false, unique = true)
@OrderBy("asc")
private String scopeName;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
+ /**
+ * Instantiates a new policy editor scopes.
+ */
public PolicyEditorScopes() {
this.modifiedDate = new Date();
}
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getScopeName() {
- return scopeName;
- }
-
- public void setScopeName(String scopeName) {
- this.scopeName = scopeName;
- }
-
- public Date getCreatedDate() {
- return this.createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public Date getModifiedDate() {
- return this.modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java
index 40ddb4308..8fa80e635 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,9 +25,10 @@ package org.onap.policy.rest.jpa;
*/
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
+
import java.io.Serializable;
import java.util.Date;
-import java.util.Objects;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -44,23 +46,45 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
-/*
- * The Entity class to persist a policy object and its configuration data
+/**
+ * The Entity class to persist a policy object and its configuration data.
*/
-
+// @formatter:off
@Entity
// Add a non-unique index and a constraint that says the combo of policyName and scopeId must be unique
@Table(name = "PolicyEntity")
-@NamedQueries({
- @NamedQuery(name = "PolicyEntity.findAll", query = "SELECT e FROM PolicyEntity e "),
- @NamedQuery(name = "PolicyEntity.findAllByDeletedFlag",
- query = "SELECT e FROM PolicyEntity e WHERE e.deleted = :deleted"),
- @NamedQuery(name = "PolicyEntity.FindById", query = "SELECT e FROM PolicyEntity e WHERE e.policyId = :id"),
- @NamedQuery(name = "PolicyEntity.deleteAll", query = "DELETE FROM PolicyEntity WHERE 1=1"),
- @NamedQuery(name = "PolicyEntity.findByNameAndScope",
- query = "SELECT e FROM PolicyEntity e WHERE e.policyName = :name AND e.scope = :scope")
-})
+@NamedQueries(
+ {
+ @NamedQuery(
+ name = "PolicyEntity.findAll",
+ query = "SELECT e FROM PolicyEntity e "
+ ),
+ @NamedQuery(
+ name = "PolicyEntity.findAllByDeletedFlag",
+ query = "SELECT e FROM PolicyEntity e WHERE e.deleted = :deleted"
+ ),
+ @NamedQuery(
+ name = "PolicyEntity.FindById",
+ query = "SELECT e FROM PolicyEntity e WHERE e.policyId = :id"
+ ),
+ @NamedQuery(
+ name = "PolicyEntity.deleteAll",
+ query = "DELETE FROM PolicyEntity WHERE 1=1"
+ ),
+ @NamedQuery(
+ name = "PolicyEntity.findByNameAndScope",
+ query = "SELECT e FROM PolicyEntity e WHERE e.policyName = :name AND e.scope = :scope"
+ )
+ }
+)
+@Getter
+@Setter
+@EqualsAndHashCode
+// @formatter:on
public class PolicyEntity implements Serializable {
private static final long serialVersionUID = 1L;
@@ -145,43 +169,8 @@ public class PolicyEntity implements Serializable {
}
/**
- * Returns Policy Id.
- * @return the policyId
- */
- public long getPolicyId() {
- return policyId;
- }
-
- /**
- * Returns policy name.
- * @return the policy name
- */
- public String getPolicyName() {
- return policyName;
- }
-
- public void setPolicyName(String policyName) {
- this.policyName = policyName;
- }
-
- /**
- * Returns policy data.
- * @return the policyData
- */
- public String getPolicyData() {
- return policyData;
- }
-
- /**
- * Set policy data.
- * @param policyData the policyData to set
- */
- public void setPolicyData(String policyData) {
- this.policyData = policyData;
- }
-
- /**
* Returns configurationDataEntity.
+ *
* @return the configurationDataEntity
*/
public ConfigurationDataEntity getConfigurationData() {
@@ -190,200 +179,10 @@ public class PolicyEntity implements Serializable {
/**
* Set configurationDataEntity.
+ *
* @param configurationDataEntity the configurationDataEntity to set
*/
public void setConfigurationData(ConfigurationDataEntity configurationDataEntity) {
this.configurationDataEntity = configurationDataEntity;
}
-
- /**
- * Returns actionBodyEntity.
- * @return the actionBodyEntity
- */
- public ActionBodyEntity getActionBodyEntity() {
- return actionBodyEntity;
- }
-
- /**
- * Set actionBodyEntity.
- * @param actionBodyEntity the actionBodyEntity to set
- */
- public void setActionBodyEntity(ActionBodyEntity actionBodyEntity) {
- this.actionBodyEntity = actionBodyEntity;
- }
-
- /**
- * Returns scope.
- * @return the scope
- */
- public String getScope() {
- return scope;
- }
-
- /**
- * Set scope.
- * @param scope the scope to set
- */
- public void setScope(String scope) {
- this.scope = scope;
- }
-
- /**
- * Returns createdBy.
- * @return the createdBy
- */
- public String getCreatedBy() {
- return createdBy;
- }
-
- /**
- * Set createdBy.
- * @param createdBy the createdBy to set
- */
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- /**
- * Returns description.
- * @return the description
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * Set description.
- * @param description the description to set
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * Returns modifiedBy.
- * @return the modifiedBy
- */
- public String getModifiedBy() {
- return modifiedBy;
- }
-
- /**
- * Set modifiedBy.
- * @param modifiedBy the modifiedBy to set
- */
- public void setModifiedBy(String modifiedBy) {
- this.modifiedBy = modifiedBy;
- }
-
- /**
- * Returns version.
- * @return version
- */
- public int getVersion() {
- return version;
- }
-
- /**
- * Returns createdDate.
- * @return the createdDate
- */
- public Date getCreatedDate() {
- return createdDate;
- }
-
- /**
- * Returns modifiedDate.
- * @return the modifiedDate
- */
- public Date getModifiedDate() {
- return modifiedDate;
- }
-
- /**
- * Return deleted.
- * @return the deleted
- */
- public boolean isDeleted() {
- return deleted;
- }
-
- /**
- * Set deleted.
- * @param deleted the deleted to set
- */
- public void setDeleted(boolean deleted) {
- this.deleted = deleted;
- }
-
- /**
- * Return the reason code.
- * @return deleted reason code
- */
- public String getDeleteReasonCode() {
- return deleteReasonCode;
- }
-
- /**
- * Set the reason of deletion.
- * @param deleteReasonCode String object
- */
- public void setDeleteReasonCode(String deleteReasonCode) {
- this.deleteReasonCode = deleteReasonCode;
- }
-
- /**
- * Return deleted By.
- * @return deletedBy
- */
- public String getDeletedBy() {
- return deletedBy;
- }
-
- /**
- * Set deleted By.
- * @param deletedBy String object
- */
- public void setDeletedBy(String deletedBy) {
- this.deletedBy = deletedBy;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(policyId, policyName, scope, version, policyVersion, policyData, configurationDataEntity,
- actionBodyEntity, createdBy, createdDate, description, modifiedBy, modifiedDate, deleted);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof PolicyEntity)) {
- return false;
- }
-
- PolicyEntity p = (PolicyEntity) obj;
-
- return policyId == p.policyId
- && policyName.equals(p.policyName)
- && scope.equals(p.scope)
- && version == p.version
- && policyVersion == p.policyVersion
- && policyData.equals(p.policyData)
- && ((configurationDataEntity == null && p.configurationDataEntity == null)
- || (configurationDataEntity != null
- && configurationDataEntity
- .equals(p.configurationDataEntity)))
- && ((actionBodyEntity == null && p.actionBodyEntity == null) || (actionBodyEntity != null
- && actionBodyEntity
- .equals(p.actionBodyEntity))) && createdBy.equals(p.createdBy)
- && createdDate.equals(p.createdDate) && description.equals(p.description)
- && modifiedBy.equals(p.modifiedBy) && modifiedDate.equals(p.modifiedDate) && deleted == p.deleted;
- }
-
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyGroupEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyGroupEntity.java
index 52f8177f3..175db577c 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyGroupEntity.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyGroupEntity.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
import java.io.Serializable;
@@ -27,34 +29,23 @@ import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
+
@Entity
-@Table(name="PolicyGroupEntity")
-@NamedQuery(name="PolicyGroupEntity.findAll", query="SELECT p FROM PolicyGroupEntity p ")
-public class PolicyGroupEntity implements Serializable{
+@Table(name = "PolicyGroupEntity")
+@NamedQuery(name = "PolicyGroupEntity.findAll", query = "SELECT p FROM PolicyGroupEntity p ")
+@Getter
+@Setter
+public class PolicyGroupEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
- @Column(name="groupKey")
+ @Column(name = "groupKey")
private int groupKey;
@Id
- @Column(name="policyid")
+ @Column(name = "policyid")
private int policyid;
-
- public int getGroupKey() {
- return groupKey;
- }
-
- public void setGroupKey(int groupKey) {
- this.groupKey = groupKey;
- }
-
- public int getPolicyid() {
- return policyid;
- }
-
- public void setPolicyid(int policyid) {
- this.policyid = policyid;
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyRoles.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyRoles.java
index f220570bd..10680313b 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyRoles.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyRoles.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,6 +20,7 @@
*/
package org.onap.policy.rest.jpa;
+
/*
*/
import java.io.Serializable;
@@ -34,70 +36,44 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
-import org.onap.policy.rest.jpa.UserInfo;
-
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
/**
* The persistent class for the roles database table.
- *
*/
@Entity
-@Table(name="roles")
-@NamedQuery(name="PolicyRoles.findAll", query="SELECT r FROM PolicyRoles r ")
+@Table(name = "roles")
+@NamedQuery(name = "PolicyRoles.findAll", query = "SELECT r FROM PolicyRoles r ")
+@Getter
+@Setter
+@NoArgsConstructor
public class PolicyRoles implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
@ManyToOne
- @JoinColumn(name="loginid")
+ @JoinColumn(name = "loginid")
@OrderBy("asc")
private UserInfo loginId;
- public UserInfo getLoginId() {
- return loginId;
- }
-
- public void setLoginId(UserInfo loginId) {
- this.loginId = loginId;
- }
-
- @Column(name="scope", nullable=true, length=45)
+ @Column(name = "scope", nullable = true, length = 45)
private String scope;
- @Column(name="role", nullable=false, length=45)
+ @Column(name = "role", nullable = false, length = 45)
private String role;
- public PolicyRoles() {
- // Empty constructor
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getScope() {
- return this.scope;
- }
-
- public void setScope(String scope) {
- this.scope = scope;
-
- }
- public String getRole() {
- return this.role;
+ public UserInfo getLoginId() {
+ return loginId;
}
- public void setRole(String role) {
- this.role = role;
+ public void setLoginId(UserInfo loginId) {
+ this.loginId = loginId;
}
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeClosedLoop.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeClosedLoop.java
index c1597741e..7e0bba3be 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeClosedLoop.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeClosedLoop.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,46 +32,26 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
@Entity
-@Table(name="PolicyScopeClosedLoop")
-@NamedQuery(name="PolicyScopeClosedLoop.findAll", query="SELECT e FROM PolicyScopeClosedLoop e ")
+@Table(name = "PolicyScopeClosedLoop")
+@NamedQuery(name = "PolicyScopeClosedLoop.findAll", query = "SELECT e FROM PolicyScopeClosedLoop e ")
+@Getter
+@Setter
public class PolicyScopeClosedLoop implements Serializable {
private static final long serialVersionUID = 1L;
-
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String name;
- @Column(name="description ")
- private String description ;
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
-
- }
- public String getDescriptionValue() {
- return this.description ;
- }
-
- public void setDescriptionValue(String description ) {
- this.description = description ;
- }
+ @Column(name = "description ")
+ private String description;
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeResource.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeResource.java
index 323275624..ebc570fa8 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeResource.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeResource.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,45 +32,26 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
@Entity
-@Table(name="PolicyScopeResource")
-@NamedQuery(name="PolicyScopeResource.findAll", query="SELECT e FROM PolicyScopeResource e ")
+@Table(name = "PolicyScopeResource")
+@NamedQuery(name = "PolicyScopeResource.findAll", query = "SELECT e FROM PolicyScopeResource e ")
+@Getter
+@Setter
public class PolicyScopeResource implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String name;
- @Column(name="description ")
- private String description ;
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
-
- }
- public String getDescriptionValue() {
- return this.description ;
- }
-
- public void setDescriptionValue(String description ) {
- this.description = description ;
- }
+ @Column(name = "description ")
+ private String description;
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeService.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeService.java
index 8238110f0..7af22e338 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeService.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeService.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,46 +32,26 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
@Entity
-@Table(name="PolicyScopeService")
-@NamedQuery(name="PolicyScopeService.findAll", query="SELECT e FROM PolicyScopeService e ")
+@Table(name = "PolicyScopeService")
+@NamedQuery(name = "PolicyScopeService.findAll", query = "SELECT e FROM PolicyScopeService e ")
+@Getter
+@Setter
public class PolicyScopeService implements Serializable {
private static final long serialVersionUID = 1L;
-
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String name;
- @Column(name="description ")
- private String description ;
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
-
- }
- public String getDescriptionValue() {
- return this.description ;
- }
-
- public void setDescriptionValue(String description ) {
- this.description = description ;
- }
+ @Column(name = "description ")
+ private String description;
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeType.java
index 04f20c330..e53a1acbf 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeType.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeType.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,45 +32,26 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
@Entity
-@Table(name="PolicyScopeType")
-@NamedQuery(name="PolicyScopeType.findAll", query="SELECT e FROM PolicyScopeType e ")
+@Table(name = "PolicyScopeType")
+@NamedQuery(name = "PolicyScopeType.findAll", query = "SELECT e FROM PolicyScopeType e ")
+@Getter
+@Setter
public class PolicyScopeType implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String name;
- @Column(name="description ")
- private String description ;
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
-
- }
- public String getDescriptionValue() {
- return this.description ;
- }
-
- public void setDescriptionValue(String description ) {
- this.description = description ;
- }
+ @Column(name = "description ")
+ private String description;
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScore.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScore.java
index 3bb0919b7..74b53babb 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScore.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScore.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,6 +20,7 @@
*/
package org.onap.policy.rest.jpa;
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -31,60 +33,45 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
+// @formatter:off
@Entity
-@Table(name="POLICYSCORE")
-@NamedQueries({
- @NamedQuery(name="POLICYSCORE.findAll", query="SELECT p FROM PolicyScore p"),
- @NamedQuery(name="POLICYSCORE.deleteAll", query="DELETE FROM PolicyScore WHERE 1=1"),
- @NamedQuery(name="POLICYSCORE.findByPolicyName", query="Select p from PolicyScore p where p.PolicyName=:pname")
-})
+@Table(name = "POLICYSCORE")
+@NamedQueries(
+ {
+ @NamedQuery(
+ name = "POLICYSCORE.findAll", query = "SELECT p FROM PolicyScore p"
+ ),
+ @NamedQuery(
+ name = "POLICYSCORE.deleteAll", query = "DELETE FROM PolicyScore WHERE 1=1"
+ ),
+ @NamedQuery(
+ name = "POLICYSCORE.findByPolicyName", query = "Select p from PolicyScore p where p.policyName=:pname"
+ )
+ }
+)
+@Getter
+@Setter
+// @formatter:on
public class PolicyScore implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="POLICY_NAME", nullable=false)
+ @Column(name = "POLICY_NAME", nullable = false)
@OrderBy("asc")
- private String PolicyName;
+ private String policyName;
- @Column(name="VERSIONEXTENSION", nullable=false)
+ @Column(name = "VERSIONEXTENSION", nullable = false)
@OrderBy("asc")
- private String VersionExtension;
-
- @Column(name="POLICY_SCORE", nullable=true)
- private String PolicyScore;
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getPolicyName() {
- return PolicyName;
- }
- public void setPolicyName(String policyName) {
- PolicyName = policyName;
- }
- public String getVersionExtension() {
- return VersionExtension;
- }
-
- public void setVersionExtension(String versionExtension) {
- VersionExtension = versionExtension;
- }
- public String getPolicyScore() {
- return PolicyScore;
- }
- public void setPolicyScore(String policyScore) {
- PolicyScore = policyScore;
- }
-
+ private String versionExtension;
+ @Column(name = "POLICY_SCORE", nullable = true)
+ private String score;
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java
index f6512af88..0332dcbfd 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +23,7 @@ package org.onap.policy.rest.jpa;
import java.io.Serializable;
import java.util.Date;
-import java.util.Objects;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -36,169 +37,112 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+/**
+ * The Class PolicyVersion.
+ */
+// @formatter:off
@Entity
-@Table(name="PolicyVersion")
-@NamedQueries({
- @NamedQuery(name="PolicyVersion.findAll", query="SELECT p FROM PolicyVersion p"),
- @NamedQuery(name="PolicyVersion.deleteAll", query="DELETE FROM PolicyVersion WHERE 1=1"),
- @NamedQuery(name="PolicyVersion.findByPolicyName", query="Select p from PolicyVersion p where p.policyName=:pname"),
- @NamedQuery(name="PolicyVersion.findAllCount", query="SELECT COUNT(p) FROM PolicyVersion p")
-})
+@Table(name = "PolicyVersion")
+@NamedQueries(
+ {
+ @NamedQuery(
+ name = "PolicyVersion.findAll", query = "SELECT p FROM PolicyVersion p"
+ ),
+ @NamedQuery(
+ name = "PolicyVersion.deleteAll", query = "DELETE FROM PolicyVersion WHERE 1=1"
+ ),
+ @NamedQuery(
+ name = "PolicyVersion.findByPolicyName", query = "Select p from PolicyVersion p where p.policyName=:pname"
+ ),
+ @NamedQuery(
+ name = "PolicyVersion.findAllCount", query = "SELECT COUNT(p) FROM PolicyVersion p"
+ )
+ }
+)
+@Getter
+@Setter
+@EqualsAndHashCode
+// @formatter:on
public class PolicyVersion implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="POLICY_NAME", nullable=false, length=255)
+ @Column(name = "POLICY_NAME", nullable = false, length = 255)
private String policyName;
- @Column(name="ACTIVE_VERSION")
+ @Column(name = "ACTIVE_VERSION")
private int activeVersion;
- @Column(name="HIGHEST_VERSION")
+ @Column(name = "HIGHEST_VERSION")
private int higherVersion;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", nullable=false)
+ @Column(name = "created_date", nullable = false)
private Date createdDate;
- @Column(name="CREATED_BY", nullable=false, length=45)
+ @Column(name = "CREATED_BY", nullable = false, length = 45)
private String createdBy;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
-
- @Column(name="modified_by", nullable=false, length=45)
+ @Column(name = "modified_by", nullable = false, length = 45)
private String modifiedBy;
+ /**
+ * Instantiates a new policy version.
+ */
public PolicyVersion() {
this.modifiedDate = new Date();
this.createdDate = new Date();
}
+ /**
+ * Instantiates a new policy version.
+ *
+ * @param domain the domain
+ * @param loginUserId the login user id
+ */
public PolicyVersion(String domain, String loginUserId) {
this(domain);
this.createdBy = loginUserId;
this.modifiedBy = loginUserId;
}
+ /**
+ * Instantiates a new policy version.
+ *
+ * @param domain the domain
+ */
public PolicyVersion(String domain) {
this.policyName = domain;
}
- public int getActiveVersion() {
- return activeVersion;
- }
-
- public void setActiveVersion(int activeVersion) {
- this.activeVersion = activeVersion;
- }
-
- public int getHigherVersion() {
- return higherVersion;
- }
-
- public void setHigherVersion(int higherVersion) {
- this.higherVersion = higherVersion;
- }
-
-
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
- this.modifiedDate = new Date();
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getPolicyName() {
- return policyName;
- }
-
- public void setPolicyName(String policyName) {
- this.policyName = policyName;
- }
-
- public Date getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getCreatedBy() {
- return createdBy;
- }
-
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- public Date getModifiedDate() {
- return modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
- public String getModifiedBy() {
- return modifiedBy;
- }
-
- public void setModifiedBy(String modifiedBy) {
- this.modifiedBy = modifiedBy;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, policyName, activeVersion, higherVersion, createdDate,
- createdBy, modifiedDate, modifiedBy);
- }
-
- @Override
- public boolean equals(Object obj) {
- if(obj == null){
- return false;
- }
- if(obj == this){
- return true;
- }
- if(!(obj instanceof PolicyVersion)){
- return false;
- }
-
- PolicyVersion p = (PolicyVersion) obj;
-
- return id == p.id &&
- policyName.equals(p.policyName) &&
- activeVersion == p.activeVersion &&
- higherVersion == p.higherVersion &&
- createdDate.equals(p.createdDate) &&
- createdBy.equals(p.createdBy) &&
- modifiedDate.equals(p.modifiedDate) &&
- modifiedBy.equals(p.modifiedBy);
+ this.modifiedDate = new Date();
}
-
}
-
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PortList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PortList.java
index 93732ffcd..6e26ed93f 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PortList.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PortList.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,45 +32,26 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
+
@Entity
-@Table(name="portlist")
-@NamedQuery(name="PortList.findAll", query="SELECT e FROM PortList e ")
+@Table(name = "portlist")
+@NamedQuery(name = "PortList.findAll", query = "SELECT e FROM PortList e ")
+@Getter
+@Setter
public class PortList implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="portname", nullable=false)
+ @Column(name = "portname", nullable = false)
@OrderBy("asc")
private String portName;
- @Column(name="description")
+ @Column(name = "description")
private String description;
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getPortName() {
- return this.portName;
- }
-
- public void setPortName(String portName) {
- this.portName = portName;
-
- }
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PrefixList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PrefixList.java
index 9a0e8aec0..c723ebe39 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PrefixList.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PrefixList.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,57 +32,29 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
+
@Entity
-@Table(name="PrefixList")
-@NamedQuery(name="PrefixList.findAll", query="SELECT e FROM PrefixList e ")
+@Table(name = "PrefixList")
+@NamedQuery(name = "PrefixList.findAll", query = "SELECT e FROM PrefixList e ")
+@Getter
+@Setter
public class PrefixList implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="pl_name", nullable=false)
+ @Column(name = "pl_name", nullable = false)
@OrderBy("asc")
private String prefixListName;
- @Column(name="description", nullable=false)
+ @Column(name = "description", nullable = false)
private String description;
- @Column(name="pl_value", nullable=false)
+ @Column(name = "pl_value", nullable = false)
private String prefixListValue;
-
- public String getPrefixListName() {
- return this.prefixListName;
- }
-
- public void setPrefixListName(String prefixListName) {
- this.prefixListName = prefixListName;
-
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
-
- }
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getPrefixListValue() {
- return this.prefixListValue;
- }
-
- public void setPrefixListValue(String prefixListValue) {
- this.prefixListValue = prefixListValue;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ProtocolList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ProtocolList.java
index 5e79e6785..edb514b3f 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ProtocolList.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ProtocolList.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,48 +32,26 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
+
@Entity
-@Table(name="protocollist")
-@NamedQuery(name="ProtocolList.findAll", query="SELECT e FROM ProtocolList e ")
+@Table(name = "protocollist")
+@NamedQuery(name = "ProtocolList.findAll", query = "SELECT e FROM ProtocolList e ")
+@Getter
+@Setter
public class ProtocolList implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="protocolname", nullable=false)
+ @Column(name = "protocolname", nullable = false)
@OrderBy("asc")
private String protocolName;
- @Column(name="description")
+ @Column(name = "description")
private String description;
-
- public String getProtocolName() {
- return this.protocolName;
- }
-
- public void setProtocolName(String protocolName) {
- this.protocolName = protocolName;
-
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
-
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RainyDayTreatments.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RainyDayTreatments.java
index fd1a6b73b..4b1c810af 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RainyDayTreatments.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RainyDayTreatments.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,99 +21,45 @@
package org.onap.policy.rest.jpa;
+import java.io.Serializable;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
-
import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
-import java.io.Serializable;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
/**
* The persistent class for the RainyDayTreatment database table.
- *
*/
@Entity
-@Table(name="RainyDayTreatments")
-@NamedQuery(name="RainyDayTreatments.findAll", query="SELECT e FROM RainyDayTreatments e")
+@Table(name = "RainyDayTreatments")
+@NamedQuery(name = "RainyDayTreatments.findAll", query = "SELECT e FROM RainyDayTreatments e")
+@Getter
+@Setter
+@NoArgsConstructor
public class RainyDayTreatments implements Serializable {
- /**
- *
- */
private static final long serialVersionUID = -2491410352490381323L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="bbid", nullable=false, length=255)
+ @Column(name = "bbid", nullable = false, length = 255)
@OrderBy("asc")
private String bbid;
- @Column(name="workstep", nullable=true, length=255)
+ @Column(name = "workstep", nullable = true, length = 255)
private String workstep;
- @Column(name="treatments", nullable=true, length=1028)
+ @Column(name = "treatments", nullable = true, length = 1028)
private String treatments;
-
- public RainyDayTreatments() {
- // Empty constructor
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- /**
- * @return the bbid
- */
- public String getBbid() {
- return bbid;
- }
-
- /**
- * @param bbid the bbid to set
- */
- public void setBbid(String bbid) {
- this.bbid = bbid;
- }
-
- /**
- * @return the workstep
- */
- public String getWorkstep() {
- return workstep;
- }
-
- /**
- * @param workstep the workstep to set
- */
- public void setWorkstep(String workstep) {
- this.workstep = workstep;
- }
-
- /**
- * @return the treatments
- */
- public String getTreatments() {
- return treatments;
- }
-
- /**
- * @param treatments the treatments to set
- */
- public void setTreatments(String treatments) {
- this.treatments = treatments;
- }
-
-
} \ No newline at end of file
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RemoteCatalogValues.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RemoteCatalogValues.java
index 0cb339adf..b7662539c 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RemoteCatalogValues.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RemoteCatalogValues.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,47 +32,26 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
@Entity
-@Table(name="RemoteCatalogValues")
-@NamedQuery(name="RemoteCatalogValues.findAll", query="SELECT e FROM RemoteCatalogValues e ")
+@Table(name = "RemoteCatalogValues")
+@NamedQuery(name = "RemoteCatalogValues.findAll", query = "SELECT e FROM RemoteCatalogValues e ")
+@Getter
+@Setter
public class RemoteCatalogValues implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String name;
- @Column(name="value")
+ @Column(name = "value")
private String value;
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
-
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RiskType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RiskType.java
index 8239d4ef8..3f7c89ec0 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RiskType.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RiskType.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import java.util.Date;
@@ -39,106 +39,63 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
+/**
+ * The Class RiskType.
+ */
@Entity
-@Table(name="RiskType")
-@NamedQuery(name="RiskType.findAll", query="SELECT e FROM RiskType e ")
+@Table(name = "RiskType")
+@NamedQuery(name = "RiskType.findAll", query = "SELECT e FROM RiskType e ")
+@Getter
+@Setter
public class RiskType implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false, unique=true)
+ @Column(name = "name", nullable = false, unique = true)
@OrderBy("asc")
private String name;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
- @Column(name="description", nullable=true, length=2048)
+ @Column(name = "description", nullable = true, length = 2048)
private String description;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
- public String getRiskName() {
- return this.name;
- }
-
- public void setRiskName(String riskName) {
- this.name = riskName;
-
- }
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public Date getCreatedDate() {
- return this.createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getModifiedDate() {
- return this.modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RuleAlgorithms.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RuleAlgorithms.java
index 905648d5c..aa2ae75bc 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RuleAlgorithms.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RuleAlgorithms.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,8 +18,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
+import com.att.research.xacml.api.Identifier;
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -30,11 +34,17 @@ import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
-import com.att.research.xacml.api.Identifier;
+import lombok.Getter;
+import lombok.Setter;
+/**
+ * The Class RuleAlgorithms.
+ */
@Entity
-@Table(name="RuleAlgorithms")
-@NamedQuery(name="RuleAlgorithms.findAll", query="SELECT d FROM RuleAlgorithms d")
+@Table(name = "RuleAlgorithms")
+@NamedQuery(name = "RuleAlgorithms.findAll", query = "SELECT d FROM RuleAlgorithms d")
+@Getter
+@Setter
public class RuleAlgorithms implements Serializable {
private static final long serialVersionUID = 1L;
@@ -43,48 +53,47 @@ public class RuleAlgorithms implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="is_standard", nullable=false)
+ @Column(name = "is_standard", nullable = false)
private char isStandard;
- @Column(name="xacml_id", nullable=false, unique=true, length=255)
+ @Column(name = "xacml_id", nullable = false, unique = true, length = 255)
private String xacmlId;
- @Column(name="short_name", nullable=false, length=64)
+ @Column(name = "short_name", nullable = false, length = 64)
private String shortName;
+ /**
+ * Instantiates a new rule algorithms.
+ *
+ * @param id the id
+ * @param standard the standard
+ */
public RuleAlgorithms(Identifier id, char standard) {
if (id != null) {
this.xacmlId = id.stringValue();
}
this.isStandard = standard;
}
+
+ /**
+ * Instantiates a new rule algorithms.
+ *
+ * @param id the id
+ */
public RuleAlgorithms(Identifier id) {
this(id, RuleAlgorithms.STANDARD);
}
+ /**
+ * Instantiates a new rule algorithms.
+ */
public RuleAlgorithms() {
this(null, RuleAlgorithms.STANDARD);
}
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public char getIsStandard() {
- return this.isStandard;
- }
-
- public void setIsStandard(char isStandard) {
- this.isStandard = isStandard;
- }
-
@Transient
public boolean isStandard() {
return this.isStandard == RuleAlgorithms.STANDARD;
@@ -94,21 +103,4 @@ public class RuleAlgorithms implements Serializable {
public boolean isCustom() {
return this.isStandard == RuleAlgorithms.CUSTOM;
}
-
- public String getXacmlId() {
- return this.xacmlId;
- }
-
- public void setXacmlId(String xacmlId) {
- this.xacmlId = xacmlId;
- }
-
- public String getShortName() {
- return shortName;
- }
-
- public void setShortName(String shortName) {
- this.shortName = shortName;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SafePolicyWarning.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SafePolicyWarning.java
index adc61506b..9663fd954 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SafePolicyWarning.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SafePolicyWarning.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,55 +32,29 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
@Entity
-@Table(name="SafePolicyWarning")
-@NamedQuery(name="SafePolicyWarning.findAll", query="SELECT e FROM SafePolicyWarning e ")
+@Table(name = "SafePolicyWarning")
+@NamedQuery(name = "SafePolicyWarning.findAll", query = "SELECT e FROM SafePolicyWarning e ")
+@Getter
+@Setter
public class SafePolicyWarning implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String name;
- @Column(name="message")
- private String message ;
-
- @Column(name="riskType")
- private String riskType ;
-
- public String getRiskType() {
- return riskType;
- }
- public void setRiskType(String riskType) {
- this.riskType = riskType;
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return this.name;
- }
-
- public String getMessage() {
- return message;
- }
- public void setMessage(String message) {
- this.message = message;
- }
- public void setName(String name) {
- this.name = name;
-
- }
+ @Column(name = "message")
+ private String message;
+ @Column(name = "riskType")
+ private String riskType;
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SecurityZone.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SecurityZone.java
index c1d6c0174..fe1c6ac4c 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SecurityZone.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SecurityZone.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,45 +32,26 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
+
@Entity
-@Table(name="securityzone")
-@NamedQuery(name="SecurityZone.findAll", query="SELECT e FROM SecurityZone e ")
+@Table(name = "securityzone")
+@NamedQuery(name = "SecurityZone.findAll", query = "SELECT e FROM SecurityZone e ")
+@Getter
+@Setter
public class SecurityZone implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String zoneName;
- @Column(name="value")
+ @Column(name = "value")
private String zoneValue;
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getZoneName() {
- return this.zoneName;
- }
-
- public void setZoneName(String zoneName) {
- this.zoneName = zoneName;
-
- }
- public String getZoneValue() {
- return this.zoneValue;
- }
-
- public void setZoneValue(String zoneValue) {
- this.zoneValue = zoneValue;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ServiceList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ServiceList.java
index 33243b0a5..9be6b2ebf 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ServiceList.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ServiceList.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,92 +32,38 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
+
@Entity
-@Table(name="servicegroup")
-@NamedQuery(name="ServiceList.findAll", query="SELECT e FROM ServiceList e ")
+@Table(name = "servicegroup")
+@NamedQuery(name = "ServiceList.findAll", query = "SELECT e FROM ServiceList e ")
+@Getter
+@Setter
public class ServiceList implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String serviceName;
- @Column(name="description")
- private String serviceDesc;
+ @Column(name = "description")
+ private String serviceDescription;
- @Column(name="type")
+ @Column(name = "type")
private String serviceType;
- @Column(name="transportprotocol")
- private String serviceTrasProtocol;
+ @Column(name = "transportprotocol")
+ private String serviceTransportProtocol;
- @Column(name="appprotocol ")
+ @Column(name = "appprotocol ")
private String serviceAppProtocol;
- @Column(name="ports")
+ @Column(name = "ports")
private String servicePorts;
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getServiceName() {
- return this.serviceName;
- }
-
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
-
- }
-
- public String getServiceDescription() {
- return this.serviceDesc;
- }
-
- public void setServiceDescription(String serviceDesc) {
- this.serviceDesc = serviceDesc;
-
- }
-
- public String getServiceType() {
- return this.serviceType;
- }
-
- public void setServiceType(String serviceType) {
- this.serviceType = serviceType;
- }
-
- public String getServiceTransProtocol() {
- return this.serviceTrasProtocol;
- }
-
- public void setServiceTransProtocol(String serviceTrasProtocol) {
- this.serviceTrasProtocol = serviceTrasProtocol;
-
- }
-
- public String getServiceAppProtocol() {
- return this.serviceAppProtocol;
- }
-
- public void setServiceAppProtocol(String serviceAppProtocol) {
- this.serviceAppProtocol = serviceAppProtocol;
-
- }
- public String getServicePorts() {
- return this.servicePorts;
- }
-
- public void setServicePorts(String servicePorts) {
- this.servicePorts = servicePorts;
-
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SystemLogDB.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SystemLogDb.java
index 9dbfc52ee..9b8845fea 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SystemLogDB.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SystemLogDb.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
import java.io.Serializable;
@@ -32,47 +34,62 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
+
/**
- * The persistent class for the system log database table.
- *
-*/
+ * The persistent class for the system log database table.
+ */
@Entity
-@Table(name="SystemLogDB")
-@NamedQuery(name="SystemLogDB.findAll", query="SELECT o FROM SystemLogDB o")
-public class SystemLogDB implements Serializable {
+@Table(name = "SystemLogDb")
+@NamedQuery(name = "SystemLogDb.findAll", query = "SELECT o FROM SystemLogDb o")
+@Getter
+@Setter
+public class SystemLogDb implements Serializable {
private static final long serialVersionUID = 1L;
-
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="type", nullable=false)
+ @Column(name = "type", nullable = false)
private String type;
- @Column(name="system", nullable=false, length=255)
+ @Column(name = "system", nullable = false, length = 255)
private String system;
- @Column(name="description", nullable=true, length=2048)
+ @Column(name = "description", nullable = true, length = 2048)
private String description;
- @Column(name="remote", nullable=false, length=255)
+ @Column(name = "remote", nullable = false, length = 255)
private String remote;
- @Column(name="logtype", nullable=false, length=255)
+ @Column(name = "logtype", nullable = false, length = 255)
private String logtype;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="date", nullable=false, updatable=false)
+ @Column(name = "date", nullable = false, updatable = false)
private Date date;
- public SystemLogDB() {
+ /**
+ * Instantiates a new system log db.
+ */
+ public SystemLogDb() {
super();
}
- public SystemLogDB(int id, String system, String description, String remote,
- String type, String logtype) {
+ /**
+ * Instantiates a new system log db.
+ *
+ * @param id the id
+ * @param system the system
+ * @param description the description
+ * @param remote the remote
+ * @param type the type
+ * @param logtype the logtype
+ */
+ public SystemLogDb(int id, String system, String description, String remote, String type, String logtype) {
this.id = id;
this.system = system;
this.description = description;
@@ -80,62 +97,4 @@ public class SystemLogDB implements Serializable {
this.type = type;
this.logtype = logtype;
}
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public Date getDate(){
- return this.date;
- }
-
- public void setDate(Date date){
- this.date = date;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getType() {
- return this.type;
- }
-
- public void setType(String type) {
- this.type = type;
-
- }
-
- public String getSystem() {
- return this.system;
- }
-
- public void setSystem(String system) {
- this.system = system;
- }
-
- public String getRemote() {
- return this.remote;
- }
-
- public void setRemote(String remote) {
- this.remote = remote;
-
- }
- public String getLogtype() {
- return this.logtype;
- }
-
- public void setLogtype(String logtype) {
- this.logtype = logtype;
-
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/TermList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/TermList.java
index a87cf2a6b..63dce9390 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/TermList.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/TermList.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +23,7 @@ package org.onap.policy.rest.jpa;
import java.io.Serializable;
import java.util.Date;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -37,209 +39,97 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
+/**
+ * The Class TermList.
+ */
@Entity
-@Table(name="TERM")
-@NamedQuery(name="TermList.findAll", query="SELECT e FROM TermList e")
+@Table(name = "TERM")
+@NamedQuery(name = "TermList.findAll", query = "SELECT e FROM TermList e")
+@Getter
+@Setter
public class TermList implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="termName", nullable=false)
+ @Column(name = "termName", nullable = false)
@OrderBy("asc")
private String termName;
- @Column(name="description")
- private String termDescription;
+ @Column(name = "description")
+ private String description;
- @Column(name="fromzone")
+ @Column(name = "fromzone")
private String fromZone;
- @Column(name="tozone")
+ @Column(name = "tozone")
private String toZone;
- @Column(name="srcIPList")
- private String srcIPList;
+ @Column(name = "srcIPList")
+ private String srcIpList;
- @Column(name="destIPList")
- private String destIPList;
+ @Column(name = "destIPList")
+ private String destIpList;
- @Column(name="protocolList")
+ @Column(name = "protocolList")
private String protocolList;
- @Column(name="portList")
+ @Column(name = "portList")
private String portList;
- @Column(name="srcPortList")
+ @Column(name = "srcPortList")
private String srcPortList;
- @Column(name="destPortList")
+ @Column(name = "destPortList")
private String destPortList;
- @Column(name="action")
+ @Column(name = "action")
private String action;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
+ /**
+ * Instantiates a new term list.
+ */
public TermList() {
this.modifiedDate = new Date();
}
- public Date getCreatedDate() {
- return this.createdDate;
- }
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public Date getModifiedDate() {
- return this.modifiedDate;
- }
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getTermName() {
- return this.termName;
- }
-
- public void setTermName(String termName) {
- this.termName = termName;
- }
-
- public String getTermDescription() {
- return this.termDescription;
- }
-
- public void setDescription(String termDescription) {
- this.termDescription = termDescription;
- }
-
- public String getFromZone() {
- return this.fromZone;
- }
-
- public void setFromZones(String fromZone) {
- this.fromZone = fromZone;
- }
-
- public String getToZone() {
- return this.toZone;
- }
-
- public void setToZones(String toZone) {
- this.toZone = toZone;
- }
-
- public String getSrcIPList() {
- return this.srcIPList;
- }
-
- public void setSrcIPList(String srcIPList) {
- this.srcIPList = srcIPList;
- }
-
- public String getDestIPList() {
- return this.destIPList;
- }
-
- public void setDestIPList(String destIPList) {
- this.destIPList = destIPList;
- }
-
- public String getProtocolList() {
- return this.protocolList;
- }
-
- public void setProtocolList(String protocolList) {
- this.protocolList = protocolList;
- }
-
- public String getPortList() {
- return this.portList;
- }
-
- public void setPortList(String portList) {
- this.portList = portList;
- }
-
- public String getSrcPortList() {
- return this.srcPortList;
- }
-
- public void setSrcPortList(String srcPortList) {
- this.srcPortList = srcPortList;
- }
-
- public String getDestPortList() {
- return this.destPortList;
- }
-
- public void setDestPortList(String destPortList) {
- this.destPortList = destPortList;
- }
-
-
- public String getAction() {
- return this.action;
- }
-
- public void setAction(String action) {
- this.action = action;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/UserInfo.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/UserInfo.java
index da1438010..38d14f848 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/UserInfo.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/UserInfo.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +21,10 @@
package org.onap.policy.rest.jpa;
+import com.att.research.xacml.api.Identifier;
+import com.att.research.xacml.std.IdentifierImpl;
+import com.fasterxml.jackson.annotation.JsonBackReference;
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -29,44 +34,29 @@ import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
-import com.att.research.xacml.api.Identifier;
-import com.att.research.xacml.std.IdentifierImpl;
-import com.fasterxml.jackson.annotation.JsonBackReference;
+import lombok.Getter;
+import lombok.Setter;
@Entity
@Table(name = "UserInfo")
-@NamedQuery(name="UserInfo.findAll", query="SELECT u FROM UserInfo u ")
+@NamedQuery(name = "UserInfo.findAll", query = "SELECT u FROM UserInfo u ")
+@Getter
+@Setter
public class UserInfo implements Serializable {
private static final long serialVersionUID = 1L;
@Id
- @Column(name="loginid", nullable=false, length=45)
+ @Column(name = "loginid", nullable = false, length = 45)
private String userLoginId;
@Column(name = "name", nullable = false, unique = true)
private String userName;
- public UserInfo(){
+ public UserInfo() {
this.userLoginId = userName;
}
- public String getUserLoginId() {
- return userLoginId;
- }
-
- public void setUserLoginId(String loginid) {
- this.userLoginId = loginid;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
@Transient
@JsonBackReference
public Identifier getIdentiferByUserId() {
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VarbindDictionary.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VarbindDictionary.java
index aee187e6f..070cf7a56 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VarbindDictionary.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VarbindDictionary.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +23,7 @@ package org.onap.policy.rest.jpa;
import java.io.Serializable;
import java.util.Date;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -37,10 +39,18 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * The Class VarbindDictionary.
+ */
@Entity
-@Table(name="VarbindDictionary")
+@Table(name = "VarbindDictionary")
@NamedQuery(name = "VarbindDictionary.findAll", query = "Select v FROM VarbindDictionary v")
-public class VarbindDictionary implements Serializable{
+@Getter
+@Setter
+public class VarbindDictionary implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@@ -48,7 +58,7 @@ public class VarbindDictionary implements Serializable{
@Column(name = "Id")
private int id;
- @Column(name ="varbind_Name", nullable = false, unique = true)
+ @Column(name = "varbind_Name", nullable = false, unique = true)
@OrderBy("asc")
private String varbindName;
@@ -56,104 +66,46 @@ public class VarbindDictionary implements Serializable{
private String varbindDescription;
@Column(name = "varbind_oid", nullable = false)
- private String varbindOID;
+ private String varbindOid;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
+ /**
+ * Instantiates a new varbind dictionary.
+ */
public VarbindDictionary() {
this.setModifiedDate(new Date());
}
-
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getVarbindName() {
- return varbindName;
- }
-
- public void setVarbindName(String varbindName) {
- this.varbindName = varbindName;
- }
-
- public String getVarbindDescription() {
- return varbindDescription;
- }
-
- public void setVarbindDescription(String varbindDescription) {
- this.varbindDescription = varbindDescription;
- }
-
- public String getVarbindOID() {
- return varbindOID;
- }
-
- public void setVarbindOID(String varbindOID) {
- this.varbindOID = varbindOID;
- }
-
- public Date getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public Date getModifiedDate() {
- return modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEUsers.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VmType.java
index 31dd66056..51c3f657d 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEUsers.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VmType.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,46 +32,26 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
@Entity
-@Table(name="DCAEUsers")
-@NamedQuery(name="DCAEUsers.findAll", query="SELECT e FROM DCAEUsers e ")
-public class DCAEUsers implements Serializable {
+@Table(name = "VmType")
+@NamedQuery(name = "VmType.findAll", query = "SELECT e FROM VmType e ")
+@Getter
+@Setter
+public class VmType implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="name", nullable=false)
+ @Column(name = "name", nullable = false)
@OrderBy("asc")
private String name;
- @Column(name="description ")
- private String description ;
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
-
- }
- public String getDescriptionValue() {
- return this.description ;
- }
-
- public void setDescriptionValue(String description ) {
- this.description = description ;
- }
-
+ @Column(name = "description")
+ private String description;
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PEPOptions.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VnfType.java
index f9413b860..1a5c679af 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PEPOptions.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VnfType.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,11 +20,10 @@
*/
package org.onap.policy.rest.jpa;
-/*
- *
- * */
+
import java.io.Serializable;
import java.util.Date;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -39,121 +39,70 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
+/**
+ * The Class VnfType.
+ */
@Entity
-@Table(name = "PEPOptions")
-@NamedQuery(name = "PEPOptions.findAll", query= "Select p from PEPOptions p")
-public class PEPOptions implements Serializable {
+@Table(name = "VnfType")
+@NamedQuery(name = "VnfType.findAll", query = "SELECT v FROM VnfType v ")
+@Getter
+@Setter
+public class VnfType implements Serializable {
private static final long serialVersionUID = 1L;
+
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name = "Id")
+ @Column(name = "id")
private int id;
- @Column(name="PEP_NAME", nullable=false)
+ @Column(name = "vnf_type", nullable = false, unique = true)
@OrderBy("asc")
- private String pepName;
-
- @Column(name="description", nullable=true, length=2048)
- private String description;
-
- @Column(name="Actions", nullable=true)
- @OrderBy("asc")
- private String actions;
+ private String type;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
+ @Column(name = "description", nullable = true, length = 2048)
+ private String description;
+
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
- public PEPOptions() {
+ /**
+ * Instantiates a new VNF type.
+ */
+ public VnfType() {
this.modifiedDate = new Date();
}
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
-
- public int getId() {
- return this.id;
- }
- public void setId(int id) {
- this.id = id;
- }
-
- public String getPepName() {
- return pepName;
- }
-
- public void setPepName(String pepName) {
- this.pepName = pepName;
- }
-
- public String getActions() {
- return actions;
- }
-
- public void setActions(String actions) {
- this.actions = actions;
- }
-
- public Date getCreatedDate() {
- return this.createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getModifiedDate() {
- return this.modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VSCLAction.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VsclAction.java
index e5aac971d..5506bc5b3 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VSCLAction.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VsclAction.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +23,7 @@ package org.onap.policy.rest.jpa;
import java.io.Serializable;
import java.util.Date;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -37,111 +39,71 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import lombok.Getter;
+import lombok.Setter;
+/**
+ * The Class VsclAction.
+ */
@Entity
-@Table(name="VSCLAction")
-@NamedQuery(name="VSCLAction.findAll", query="SELECT v FROM VSCLAction v ")
-public class VSCLAction implements Serializable {
+@Table(name = "VsclAction")
+@NamedQuery(name = "VsclAction.findAll", query = "SELECT v FROM VsclAction v ")
+@Getter
+@Setter
+public class VsclAction implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="vscl_action", nullable=false, unique=true)
+ @Column(name = "vscl_action", nullable = false, unique = true)
@OrderBy("asc")
- private String vsclaction;
+ private String action;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="created_date", updatable=false)
+ @Column(name = "created_date", updatable = false)
private Date createdDate;
- @Column(name="description", nullable=true, length=2048)
+ @Column(name = "description", nullable = true, length = 2048)
private String description;
@Temporal(TemporalType.TIMESTAMP)
- @Column(name="modified_date", nullable=false)
+ @Column(name = "modified_date", nullable = false)
private Date modifiedDate;
@ManyToOne(optional = false)
- @JoinColumn(name="created_by")
+ @JoinColumn(name = "created_by")
private UserInfo userCreatedBy;
@ManyToOne(optional = false)
- @JoinColumn(name="modified_by")
+ @JoinColumn(name = "modified_by")
private UserInfo userModifiedBy;
- public VSCLAction() {
+ /**
+ * Instantiates a new vscl action.
+ */
+ public VsclAction() {
this.setModifiedDate(new Date());
}
- public UserInfo getUserCreatedBy() {
- return userCreatedBy;
- }
-
- public void setUserCreatedBy(UserInfo userCreatedBy) {
- this.userCreatedBy = userCreatedBy;
- }
-
- public UserInfo getUserModifiedBy() {
- return userModifiedBy;
- }
-
- public void setUserModifiedBy(UserInfo userModifiedBy) {
- this.userModifiedBy = userModifiedBy;
- }
-
+ /**
+ * Pre persist.
+ */
@PrePersist
- public void prePersist() {
+ public void prePersist() {
Date date = new Date();
this.createdDate = date;
this.modifiedDate = date;
}
+ /**
+ * Pre update.
+ */
@PreUpdate
public void preUpdate() {
this.modifiedDate = new Date();
}
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getVsclaction() {
- return vsclaction;
- }
-
- public void setVsclaction(String vsclaction) {
- this.vsclaction = vsclaction;
- }
-
-
- public Date getCreatedDate() {
- return this.createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getModifiedDate() {
- return this.modifiedDate;
- }
-
- public void setModifiedDate(Date modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/WatchPolicyNotificationTable.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/WatchPolicyNotificationTable.java
index 9f2cbfdf1..5c288a8a6 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/WatchPolicyNotificationTable.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/WatchPolicyNotificationTable.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,13 +20,8 @@
*/
package org.onap.policy.rest.jpa;
-/*
- *
- *
- * */
import java.io.Serializable;
-import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -36,70 +32,29 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+
@Entity
@Table(name = "WatchPolicyNotificationTable")
-@NamedQuery(name="WatchPolicyNotificationTable.findAll", query="SELECT e FROM WatchPolicyNotificationTable e ")
-public class WatchPolicyNotificationTable implements Serializable{
+@NamedQuery(name = "WatchPolicyNotificationTable.findAll", query = "SELECT e FROM WatchPolicyNotificationTable e ")
+@Getter
+@Setter
+@EqualsAndHashCode
+public class WatchPolicyNotificationTable implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="policyName", nullable=false, unique=true)
+ @Column(name = "policyName", nullable = false, unique = true)
@OrderBy("asc")
private String policyName;
- @Column(name="loginIds", nullable=false, unique=true)
+ @Column(name = "loginIds", nullable = false, unique = true)
@OrderBy("asc")
private String loginIds;
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getPolicyName() {
- return policyName;
- }
-
- public void setPolicyName(String policyName) {
- this.policyName = policyName;
- }
-
- public String getLoginIds() {
- return loginIds;
- }
-
- public void setLoginIds(String loginIds) {
- this.loginIds = loginIds;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, policyName, loginIds);
- }
-
- @Override
- public boolean equals(Object obj) {
- if(obj == null){
- return false;
- }
- if(obj == this){
- return true;
- }
- if(!(obj instanceof WatchPolicyNotificationTable)){
- return false;
- }
-
- return id == ((WatchPolicyNotificationTable)obj).id &&
- policyName.equals(((WatchPolicyNotificationTable)obj).policyName) &&
- loginIds.equals(((WatchPolicyNotificationTable)obj).loginIds);
- }
-
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Zone.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Zone.java
index 58c1a275a..71252ed05 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Zone.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Zone.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -19,8 +20,7 @@
*/
package org.onap.policy.rest.jpa;
-/*
- */
+
import java.io.Serializable;
import javax.persistence.Column;
@@ -32,45 +32,26 @@ import javax.persistence.NamedQuery;
import javax.persistence.OrderBy;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.Setter;
+
@Entity
-@Table(name="zone")
-@NamedQuery(name="Zone.findAll", query="SELECT e FROM Zone e ")
+@Table(name = "zone")
+@NamedQuery(name = "Zone.findAll", query = "SELECT e FROM Zone e ")
+@Getter
+@Setter
public class Zone implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name="id")
+ @Column(name = "id")
private int id;
- @Column(name="zonename", nullable=false)
+ @Column(name = "zonename", nullable = false)
@OrderBy("asc")
private String zoneName;
- @Column(name="zonevalue")
+ @Column(name = "zonevalue")
private String zoneValue;
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- public String getZoneName() {
- return this.zoneName;
- }
-
- public void setZoneName(String zoneName) {
- this.zoneName = zoneName;
-
- }
- public String getZoneValue() {
- return this.zoneValue;
- }
-
- public void setZoneValue(String zoneValue) {
- this.zoneValue = zoneValue;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/LockdownListener.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/LockdownListener.java
index 1111609d8..019e15db7 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/LockdownListener.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/LockdownListener.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,19 +19,16 @@
* ============LICENSE_END=========================================================
*/
-/**
- *
- */
package org.onap.policy.rest.util;
public interface LockdownListener {
/**
- * lockdown has been set in database
+ * lockdown has been set in database.
*/
public void lockdownSet();
/**
- * lockdown has been unset in the database
+ * lockdown has been unset in the database.
*/
public void lockdownUnset();
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSAttributeValue.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSAttributeValue.java
deleted file mode 100644
index c8a217d9f..000000000
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSAttributeValue.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-REST
- * ================================================================================
- * 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.rest.util;
-
-public class MSAttributeValue{
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getType() {
- return type;
- }
- public void setType(String type) {
- this.type = type;
- }
- public Boolean getRequired() {
- return required;
- }
- public void setRequired(Boolean required) {
- this.required = required;
- }
- public Boolean getArrayValue() {
- return arrayValue;
- }
- public void setArrayValue(Boolean arrayValue) {
- this.arrayValue = arrayValue;
- }
- public String getDefaultValue() {
- return defaultValue;
- }
- public void setDefaultValue(String defaultValue) {
- this.defaultValue = defaultValue;
- }
- private String name;
- private String type;
- private Boolean required;
- private Boolean arrayValue;
- private String defaultValue;
-
-}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSAttributeObject.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MsAttributeObject.java
index 3d27499da..a022f58fa 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSAttributeObject.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MsAttributeObject.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017,2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +24,12 @@ package org.onap.policy.rest.util;
import java.util.HashMap;
import java.util.Map;
-public class MSAttributeObject {
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class MsAttributeObject {
private String className;
private Map<String, String> attribute = new HashMap<>();
@@ -36,38 +42,6 @@ public class MSAttributeObject {
private String ruleFormation;
private String dataOrderInfo;
- public Map<String, String> getRefAttribute() {
- return refAttribute;
- }
-
- public void setRefAttribute(Map<String, String> refAttribute) {
- this.refAttribute = refAttribute;
- }
-
- public String getClassName() {
- return className;
- }
-
- public void setClassName(String className) {
- this.className = className;
- }
-
- public Map<String, String> getAttribute() {
- return attribute;
- }
-
- public void setAttribute(Map<String, String> attribute) {
- this.attribute = attribute;
- }
-
- public Map<String, String> getEnumType() {
- return enumType;
- }
-
- public void setEnumType(Map<String, String> enumType) {
- this.enumType = enumType;
- }
-
public void addAttribute(String key, String value) {
this.attribute.put(key, value);
}
@@ -84,38 +58,14 @@ public class MSAttributeObject {
this.refAttribute.putAll(map);
}
- public Map<String, Object> getSubClass() {
- return subClass;
- }
-
- public void setSubClass(Map<String, Object> subClass) {
- this.subClass = subClass;
- }
-
public void addAllSubClass(Map<String, Object> subClass) {
this.subClass.putAll(subClass);
}
- public String getDependency() {
- return dependency;
- }
-
- public void setDependency(String dependency) {
- this.dependency = dependency;
- }
-
public void addSingleEnum(String key, String value) {
this.enumType.put(key, value);
}
- public Map<String, String> getMatchingSet() {
- return matchingSet;
- }
-
- public void setMatchingSet(Map<String, String> matchingSet) {
- this.matchingSet = matchingSet;
- }
-
public void addMatchingSet(String key, String value) {
this.matchingSet.put(key, value);
}
@@ -123,28 +73,4 @@ public class MSAttributeObject {
public void addMatchingSet(Map<String, String> matchingSet) {
this.matchingSet.putAll(matchingSet);
}
-
- public boolean isPolicyTempalate() {
- return policyTempalate;
- }
-
- public void setPolicyTempalate(boolean policyTempalate) {
- this.policyTempalate = policyTempalate;
- }
-
- public String getRuleFormation() {
- return ruleFormation;
- }
-
- public void setRuleFormation(String ruleFormation) {
- this.ruleFormation = ruleFormation;
- }
-
- public String getDataOrderInfo() {
- return dataOrderInfo;
- }
-
- public void setDataOrderInfo(String dataOrderInfo) {
- this.dataOrderInfo = dataOrderInfo;
- }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/package-info.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MsAttributeValue.java
index 72a36f4f4..0d550e45a 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/package-info.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MsAttributeValue.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,4 +19,17 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.rest.jpa;
+package org.onap.policy.rest.util;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class MsAttributeValue {
+ private String name;
+ private String type;
+ private Boolean required;
+ private Boolean arrayValue;
+ private String defaultValue;
+}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MsModelUtils.java
index 56e110019..fad26daa4 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MsModelUtils.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +24,7 @@ package org.onap.policy.rest.util;
import com.att.research.xacml.util.XACMLProperties;
import com.google.gson.Gson;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -39,7 +41,11 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.emf.common.util.EList;
@@ -63,24 +69,59 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.json.JSONObject;
-import org.onap.policy.rest.XACMLRestProperties;
+import org.onap.policy.rest.XacmlRestProperties;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.DictionaryData;
import org.yaml.snakeyaml.Yaml;
+@Getter
+@Setter
+public class MsModelUtils {
-public class MSModelUtils {
+ private static final Log logger = LogFactory.getLog(MsModelUtils.class);
- private static final Log logger = LogFactory.getLog(MSModelUtils.class);
+ // String constants
+ private static final String BOOLEAN = "boolean";
+ private static final String CONFIGURATION = "configuration";
+ private static final String DATATYPE = "data_types.policy.data.";
+ private static final String DATA_TYPE = "data_types";
+ private static final String DEFAULT = ".default";
+ private static final String DEFAULTVALUE = ":defaultValue-";
+ private static final String DESCRIPTION = ".description";
+ private static final String DESCRIPTION_KEY = "description";
+ private static final String DESCRIPTION_TOKEN = ":description-";
+ private static final String DICTIONARY = "dictionary:";
+ private static final String DICTIONARYNAME = "dictionaryName";
+ private static final String ERROR = "error";
+ private static final String E_PROXY_URI = "eProxyURI:";
+ private static final String INTEGER = "integer";
+ private static final String JSON_MODEL = "JSON_MODEL";
+ private static final String LIST = "list";
+ private static final String MANYFALSE = ":MANY-false";
+ private static final String MANYTRUE = ":MANY-true";
+ private static final String MAP = "map";
+ private static final String MATCHABLE = ".matchable";
+ private static final String MATCHABLEKEY = "matchable";
+ private static final String MATCHINGTRUE = "matching-true";
+ private static final String NODE_TYPE = "node_types";
+ private static final String PROPERTIES = ".properties.";
+ private static final String PROPERTIES_KEY = "properties";
+ private static final String REQUIRED = ".required";
+ private static final String REQUIREDFALSE = ":required-false";
+ private static final String REQUIREDTRUE = ":required-true";
+ private static final String REQUIREDVALUE = ":required-";
+ private static final String STRING = "string";
+ private static final String TOSCA_DEFINITION_VERSION = "tosca_definitions_version";
+ private static final String TOSCA_SIMPLE_YAML_1_0_0 = "tosca_simple_yaml_1_0_0";
+ private static final String TYPE = ".type";
+
+ private static CommonClassDao commonClassDao;
- private HashMap<String, MSAttributeObject> classMap = new HashMap<>();
+ private HashMap<String, MsAttributeObject> classMap = new HashMap<>();
private HashMap<String, String> enumMap = new HashMap<>();
private HashMap<String, String> matchingClass = new HashMap<>();
- private String configuration = "configuration";
- private String dictionary = "dictionary";
private String onap = "";
private String policy = "";
- private String eProxyURI = "eProxyURI:";
private List<String> orderedElements = new ArrayList<>();
private String dataOrderInfo = "";
private Set<String> uniqueDataKeys = new HashSet<>();
@@ -89,80 +130,86 @@ public class MSModelUtils {
private String referenceAttributes;
private LinkedHashMap<String, Object> retmap = new LinkedHashMap<>();
private Map<String, String> matchableValues;
- private static final String PROPERTIES = ".properties.";
- private static final String DATATYPE = "data_types.policy.data.";
- private static final String TYPE = ".type";
- private static final String REQUIRED = ".required";
- private static final String DICTIONARYNAME = "dictionaryName";
- private static final String DICTIONARY = "dictionary:";
- private static final String MATCHABLE = ".matchable";
- public static final String STRING = "string";
- public static final String INTEGER = "integer";
- private static final String BOOLEAN = "boolean";
- public static final String LIST = "list";
- public static final String MAP = "map";
- private static final String DEFAULT = ".default";
- private static final String MANYFALSE = ":MANY-false";
- private static final String DESCRIPTION = ".description";
-
- private static final String MANYTRUE = ":MANY-true";
- private static final String DEFAULTVALUE = ":defaultValue-";
- private static final String REQUIREDVALUE = ":required-";
- private static final String MATCHABLEKEY = "matchable";
- private static final String REQUIREDFALSE = ":required-false";
- private static final String REQUIREDTRUE = ":required-true";
- private static final String MATCHINGTRUE = "matching-true";
- private static final String DESCRIPTION_KEY = "description";
- private static final String DESCRIPTION_TOKEN = ":description-";
- private static final String PROPERTIES_KEY = "properties";
- private static final String DATA_TYPE = "data_types";
- private static final String ERROR = "error";
- private static final String NODE_TYPE = "node_types";
- private static final String TOSCA_DEFINITION_VERSION = "tosca_definitions_version";
- private static final String TOSCA_SIMPLE_YAML_1_0_0 = "tosca_simple_yaml_1_0_0";
- private static final String JSON_MODEL = "JSON_MODEL";
private StringBuilder dataListBuffer = new StringBuilder();
private List<String> dataConstraints = new ArrayList<>();
private String attributeString = null;
private boolean isDuplicatedAttributes = false;
private String jsonRuleFormation = null;
- private static CommonClassDao commonClassDao;
-
- public MSModelUtils() {
- // Default Constructor
+ /**
+ * The Enum AnnotationType.
+ */
+ private enum AnnotationType {
+ MATCHING,
+ VALIDATION,
+ DICTIONARY
}
- public MSModelUtils(CommonClassDao commonClassDao) {
- MSModelUtils.commonClassDao = commonClassDao;
+ /**
+ * The Enum ModelType.
+ */
+ public enum ModelType {
+ XMI
}
- public MSModelUtils(String onap, String policy) {
- this.onap = onap;
- this.policy = policy;
+ /**
+ * The Enum SearchType.
+ */
+ public enum SearchType {
+ TOSCA_DEFINITION_VERSION,
+ TOSCA_SIMPLE_YAML_1_0_0,
+ NODE_TYPE,
+ DATA_TYPE,
+ JSON_MODEL
}
- private enum ANNOTATION_TYPE {
- MATCHING, VALIDATION, DICTIONARY
- };
+ /**
+ * Instantiates a new ms model utils.
+ */
+ public MsModelUtils() {
+ // Default Constructor
+ }
- public enum MODEL_TYPE {
- XMI
- };
+ /**
+ * Instantiates a new ms model utils.
+ *
+ * @param commonClassDao the common class dao
+ */
+ public MsModelUtils(CommonClassDao commonClassDao) {
+ MsModelUtils.commonClassDao = commonClassDao;
+ }
- public enum SearchType {
- TOSCA_DEFINITION_VERSION, TOSCA_SIMPLE_YAML_1_0_0, NODE_TYPE, DATA_TYPE, JSON_MODEL
+ /**
+ * Instantiates a new ms model utils.
+ *
+ * @param onap the onap
+ * @param policy the policy
+ */
+ public MsModelUtils(String onap, String policy) {
+ this.onap = onap;
+ this.policy = policy;
}
- public Map<String, MSAttributeObject> processEpackage(String file, MODEL_TYPE model) {
- if (model == MODEL_TYPE.XMI) {
- processXMIEpackage(file);
+ /**
+ * Process epackage.
+ *
+ * @param file the file
+ * @param model the model
+ * @return the map
+ */
+ public Map<String, MsAttributeObject> processEpackage(String file, ModelType model) {
+ if (model == ModelType.XMI) {
+ processXmiEpackage(file);
}
return classMap;
-
}
- private void processXMIEpackage(String xmiFile) {
+ /**
+ * Process XMI epackage.
+ *
+ * @param xmiFile the xmi file
+ */
+ private void processXmiEpackage(String xmiFile) {
EPackage root = getEpackage(xmiFile);
TreeIterator<EObject> treeItr = root.eAllContents();
String className;
@@ -172,14 +219,16 @@ public class MSModelUtils {
while (treeItr.hasNext()) {
EObject obj = treeItr.next();
if (obj instanceof EClassifier) {
- EClassifier eClassifier = (EClassifier) obj;
- className = eClassifier.getName();
+ EClassifier eclassifier = (EClassifier) obj;
+ className = eclassifier.getName();
if (obj instanceof EEnum) {
enumMap.putAll(getEEnum(obj));
} else if (obj instanceof EClass) {
- String temp = getDependencyList(eClassifier).toString();
- returnValue = StringUtils.replaceEach(temp, new String[] {"[", "]"}, new String[] {"", ""});
+ String temp = getDependencyList(eclassifier).toString();
+ returnValue = StringUtils.replaceEach(temp, new String[]
+ { "[", "]" }, new String[]
+ { "", "" });
getAttributes(className, returnValue, root);
}
}
@@ -193,6 +242,9 @@ public class MSModelUtils {
}
}
+ /**
+ * Check for matching class.
+ */
private void checkForMatchingClass() {
HashMap<String, String> tempAttribute = new HashMap<>();
@@ -201,12 +253,12 @@ public class MSModelUtils {
if (classMap.containsKey(key)) {
Map<String, String> listAttributes = classMap.get(key).getAttribute();
Map<String, String> listRef = classMap.get(key).getRefAttribute();
- for (Entry<String, String> eSet : listAttributes.entrySet()) {
- String key2 = eSet.getKey();
+ for (Entry<String, String> eset : listAttributes.entrySet()) {
+ String key2 = eset.getKey();
tempAttribute.put(key2, MATCHINGTRUE);
}
- for (Entry<String, String> eSet : listRef.entrySet()) {
- String key3 = eSet.getKey();
+ for (Entry<String, String> eset : listRef.entrySet()) {
+ String key3 = eset.getKey();
tempAttribute.put(key3, MATCHINGTRUE);
}
@@ -216,12 +268,16 @@ public class MSModelUtils {
}
-
-
+ /**
+ * Update matching.
+ *
+ * @param tempAttribute the temp attribute
+ * @param key the key
+ */
private void updateMatching(HashMap<String, String> tempAttribute, String key) {
- Map<String, MSAttributeObject> newClass = classMap;
+ Map<String, MsAttributeObject> newClass = classMap;
- for (Entry<String, MSAttributeObject> updateClass : newClass.entrySet()) {
+ for (Entry<String, MsAttributeObject> updateClass : newClass.entrySet()) {
Map<String, String> valueMap = updateClass.getValue().getMatchingSet();
String keymap = updateClass.getKey();
if (valueMap.containsKey(key)) {
@@ -234,17 +290,26 @@ public class MSModelUtils {
}
}
+ /**
+ * Adds the enum class map.
+ */
private void addEnumClassMap() {
- for (Entry<String, MSAttributeObject> value : classMap.entrySet()) {
+ for (Entry<String, MsAttributeObject> value : classMap.entrySet()) {
value.getValue().setEnumType(enumMap);
}
}
+ /**
+ * Gets the epackage.
+ *
+ * @param xmiFile the xmi file
+ * @return the epackage
+ */
private EPackage getEpackage(String xmiFile) {
ResourceSet resSet = new ResourceSetImpl();
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
- Map<String, Object> m = reg.getExtensionToFactoryMap();
- m.put("xmi", new XMIResourceFactoryImpl());
+ Map<String, Object> objectMap = reg.getExtensionToFactoryMap();
+ objectMap.put("xmi", new XMIResourceFactoryImpl());
Resource resource = resSet.getResource(URI.createFileURI(xmiFile), true);
try {
resource.load(Collections.emptyMap());
@@ -255,14 +320,20 @@ public class MSModelUtils {
return (EPackage) resource.getContents().get(0);
}
+ /**
+ * Gets the e enum.
+ *
+ * @param obj the obj
+ * @return the e enum
+ */
private HashMap<String, String> getEEnum(EObject obj) {
List<String> valueList = new ArrayList<>();
HashMap<String, String> returnMap = new HashMap<>();
EEnum eenum = (EEnum) obj;
String name = eenum.getName();
- for (EEnumLiteral eEnumLiteral : eenum.getELiterals()) {
- Enumerator instance = eEnumLiteral.getInstance();
+ for (EEnumLiteral enumLiteral : eenum.getELiterals()) {
+ Enumerator instance = enumLiteral.getInstance();
String value = instance.getLiteral();
valueList.add(value);
}
@@ -270,12 +341,19 @@ public class MSModelUtils {
return returnMap;
}
+ /**
+ * Gets the attributes.
+ *
+ * @param className the class name
+ * @param dependency the dependency
+ * @param root the root
+ */
public void getAttributes(String className, String dependency, EPackage root) {
List<String> dpendList = new ArrayList<>();
if (dependency != null) {
dpendList = new ArrayList<>(Arrays.asList(dependency.split(",")));
}
- MSAttributeObject msAttributeObject = new MSAttributeObject();
+ MsAttributeObject msAttributeObject = new MsAttributeObject();
msAttributeObject.setClassName(className);
String extendClass = getSubTypes(root, className);
Map<String, String> returnRefList = getRefAttributeList(root, className, extendClass);
@@ -292,6 +370,14 @@ public class MSModelUtils {
this.classMap.put(className, msAttributeObject);
}
+ /**
+ * Gets the annotation.
+ *
+ * @param root the root
+ * @param className the class name
+ * @param extendClass the extend class
+ * @return the annotation
+ */
private HashMap<String, String> getAnnotation(EPackage root, String className, String extendClass) {
TreeIterator<EObject> treeItr = root.eAllContents();
boolean requiredAttribute = false;
@@ -317,43 +403,63 @@ public class MSModelUtils {
return annotationSet;
}
+ /**
+ * Find matching annotation.
+ *
+ * @param annotationSet the annotation set
+ * @param obj the obj
+ */
private void findMatchingAnnotation(HashMap<String, String> annotationSet, EObject obj) {
- EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
- if (eStrucClassifier.getEAnnotations().isEmpty()) {
+ EStructuralFeature estrucClassifier = (EStructuralFeature) obj;
+ if (estrucClassifier.getEAnnotations().isEmpty()) {
return;
}
- String matching = annotationValue(eStrucClassifier, ANNOTATION_TYPE.MATCHING, policy);
+ String matching = annotationValue(estrucClassifier, AnnotationType.MATCHING, policy);
if (matching != null) {
if (obj instanceof EReference) {
EClass refType = ((EReference) obj).getEReferenceType();
annotationSet.put(refType.getName(), matching);
matchingClass.put(refType.getName(), matching);
} else {
- annotationSet.put(eStrucClassifier.getName(), matching);
+ annotationSet.put(estrucClassifier.getName(), matching);
}
}
}
+ /**
+ * Check annotation.
+ *
+ * @param annotationSet the annotation set
+ * @param obj the obj
+ */
private void checkAnnotation(HashMap<String, String> annotationSet, EStructuralFeature obj) {
- EStructuralFeature eStrucClassifier = obj;
- if (eStrucClassifier.getEAnnotations().isEmpty()) {
+ EStructuralFeature estrucClassifier = obj;
+ if (estrucClassifier.getEAnnotations().isEmpty()) {
return;
}
- String matching = annotationValue(eStrucClassifier, ANNOTATION_TYPE.MATCHING, policy);
+ String matching = annotationValue(estrucClassifier, AnnotationType.MATCHING, policy);
if (matching != null) {
- annotationSet.put(eStrucClassifier.getName(), matching);
+ annotationSet.put(estrucClassifier.getName(), matching);
}
- String range = annotationValue(eStrucClassifier, ANNOTATION_TYPE.VALIDATION, policy);
+ String range = annotationValue(estrucClassifier, AnnotationType.VALIDATION, policy);
if (range != null) {
- annotationSet.put(eStrucClassifier.getName(), range);
+ annotationSet.put(estrucClassifier.getName(), range);
}
- String annotationDict = annotationValue(eStrucClassifier, ANNOTATION_TYPE.DICTIONARY, policy);
+ String annotationDict = annotationValue(estrucClassifier, AnnotationType.DICTIONARY, policy);
if (annotationDict != null) {
- annotationSet.put(eStrucClassifier.getName(), annotationDict);
+ annotationSet.put(estrucClassifier.getName(), annotationDict);
}
}
+ /**
+ * Gets the sub attribute list.
+ *
+ * @param root the root
+ * @param className the class name
+ * @param superClass the super class
+ * @return the sub attribute list
+ */
private Map<String, Object> getSubAttributeList(EPackage root, String className, String superClass) {
TreeIterator<EObject> treeItr = root.eAllContents();
boolean requiredAttribute = false;
@@ -374,32 +480,45 @@ public class MSModelUtils {
}
if (requiredAttribute && (obj instanceof EStructuralFeature)) {
- EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
- if (!eStrucClassifier.getEAnnotations().isEmpty()) {
- updateSubAttributes(subAttribute, obj, eStrucClassifier);
+ EStructuralFeature estrucClassifier = (EStructuralFeature) obj;
+ if (!estrucClassifier.getEAnnotations().isEmpty()) {
+ updateSubAttributes(subAttribute, obj, estrucClassifier);
}
}
}
return subAttribute;
}
+ /**
+ * Update sub attributes.
+ *
+ * @param subAttribute the sub attribute
+ * @param obj the obj
+ * @param estrucClassifier the e struc classifier
+ */
private void updateSubAttributes(Map<String, Object> subAttribute, EObject obj,
- EStructuralFeature eStrucClassifier) {
+ EStructuralFeature estrucClassifier) {
if (!(obj instanceof EReference)) {
return;
}
- if (annotationTest(eStrucClassifier, configuration, onap)) {
+ if (annotationTest(estrucClassifier, CONFIGURATION, onap)) {
EClass refType = ((EReference) obj).getEReferenceType();
- if (!refType.toString().contains(eProxyURI)) {
+ if (!refType.toString().contains(E_PROXY_URI)) {
String required = REQUIREDFALSE;
- if (eStrucClassifier.getLowerBound() == 1) {
+ if (estrucClassifier.getLowerBound() == 1) {
required = REQUIREDTRUE;
}
- subAttribute.put(eStrucClassifier.getName(), refType.getName() + required);
+ subAttribute.put(estrucClassifier.getName(), refType.getName() + required);
}
}
}
+ /**
+ * Check defult value.
+ *
+ * @param defultValue the defult value
+ * @return the string
+ */
public String checkDefultValue(String defultValue) {
if (defultValue != null) {
return DEFAULTVALUE + defultValue;
@@ -408,19 +527,40 @@ public class MSModelUtils {
}
+ /**
+ * Check required pattern.
+ *
+ * @param upper the upper
+ * @param lower the lower
+ * @return the string
+ */
public String checkRequiredPattern(int upper, int lower) {
- String pattern = XACMLProperties.getProperty(XACMLRestProperties.PROP_XCORE_REQUIRED_PATTERN);
+ String pattern = XACMLProperties.getProperty(XacmlRestProperties.PROP_XCORE_REQUIRED_PATTERN);
if (pattern != null && upper == Integer.parseInt(pattern.split(",")[1])
- && lower == Integer.parseInt(pattern.split(",")[0])) {
+ && lower == Integer.parseInt(pattern.split(",")[0])) {
return REQUIREDTRUE;
}
return REQUIREDFALSE;
}
+ /**
+ * Builds the java object.
+ *
+ * @param map the map
+ * @return the JSON object
+ */
public JSONObject buildJavaObject(Map<String, String> map) {
return new JSONObject(map);
}
+ /**
+ * Gets the ref attribute list.
+ *
+ * @param root the root
+ * @param className the class name
+ * @param superClass the super class
+ * @return the ref attribute list
+ */
public Map<String, String> getRefAttributeList(EPackage root, String className, String superClass) {
TreeIterator<EObject> treeItr = root.eAllContents();
@@ -441,13 +581,13 @@ public class MSModelUtils {
}
if (requiredAttribute && (obj instanceof EStructuralFeature)) {
- EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
- if (!eStrucClassifier.getEAnnotations().isEmpty()) {
- annotation = annotationTest(eStrucClassifier, configuration, onap);
+ EStructuralFeature estrucClassifier = (EStructuralFeature) obj;
+ if (!estrucClassifier.getEAnnotations().isEmpty()) {
+ annotation = annotationTest(estrucClassifier, CONFIGURATION, onap);
if (annotation && obj instanceof EReference) {
- updRefAttributes(refAttribute, (EStructuralFeature) obj, eStrucClassifier);
+ updRefAttributes(refAttribute, (EStructuralFeature) obj, estrucClassifier);
} else if (annotation && obj instanceof EAttributeImpl) {
- updEnumTypeRefAttrib(refAttribute, (EStructuralFeature) obj, eStrucClassifier);
+ updEnumTypeRefAttrib(refAttribute, (EStructuralFeature) obj, estrucClassifier);
}
}
}
@@ -456,8 +596,15 @@ public class MSModelUtils {
return refAttribute;
}
+ /**
+ * Upd enum type ref attrib.
+ *
+ * @param refAttribute the ref attribute
+ * @param obj the obj
+ * @param estrucClassifier the e struc classifier
+ */
private void updEnumTypeRefAttrib(HashMap<String, String> refAttribute, EStructuralFeature obj,
- EStructuralFeature eStrucClassifier) {
+ EStructuralFeature estrucClassifier) {
EClassifier refType = ((EAttributeImpl) obj).getEType();
if (!(refType instanceof EEnumImpl)) {
return;
@@ -468,40 +615,56 @@ public class MSModelUtils {
if (obj.getLowerBound() == 1) {
required = REQUIREDTRUE;
}
- refAttribute.put(eStrucClassifier.getName(), refType.getName() + array + required);
+ refAttribute.put(estrucClassifier.getName(), refType.getName() + array + required);
}
+ /**
+ * Upd ref attributes.
+ *
+ * @param refAttribute the ref attribute
+ * @param obj the obj
+ * @param estrucClassifier the e struc classifier
+ */
private void updRefAttributes(HashMap<String, String> refAttribute, EStructuralFeature obj,
- EStructuralFeature eStrucClassifier) {
+ EStructuralFeature estrucClassifier) {
EClass refType = ((EReference) obj).getEReferenceType();
- if (refType.toString().contains(eProxyURI)) {
- String one = refType.toString().split(eProxyURI)[1];
- String refValue =
- StringUtils.replaceEach(one.split("#")[1], new String[] {"//", ")"}, new String[] {"", ""});
- refAttribute.put(eStrucClassifier.getName(), refValue);
+ if (refType.toString().contains(E_PROXY_URI)) {
+ String one = refType.toString().split(E_PROXY_URI)[1];
+ String refValue = StringUtils.replaceEach(one.split("#")[1], new String[]
+ { "//", ")" }, new String[]
+ { "", "" });
+ refAttribute.put(estrucClassifier.getName(), refValue);
} else {
String required = REQUIREDFALSE;
if (obj.getLowerBound() == 1) {
required = REQUIREDTRUE;
}
- refAttribute.put(eStrucClassifier.getName(),
- refType.getName() + arrayCheck(obj.getUpperBound()) + required);
+ refAttribute.put(estrucClassifier.getName(),
+ refType.getName() + arrayCheck(obj.getUpperBound()) + required);
}
}
- private boolean annotationTest(EStructuralFeature eStrucClassifier, String annotation, String type) {
+ /**
+ * Annotation test.
+ *
+ * @param estrucClassifier the e struc classifier
+ * @param annotation the annotation
+ * @param type the type
+ * @return true, if successful
+ */
+ private boolean annotationTest(EStructuralFeature estrucClassifier, String annotation, String type) {
String annotationType;
- EAnnotation eAnnotation;
+ EAnnotation eannotation;
String onapType;
String onapValue;
- EList<EAnnotation> value = eStrucClassifier.getEAnnotations();
+ EList<EAnnotation> value = estrucClassifier.getEAnnotations();
for (int i = 0; i < value.size(); i++) {
annotationType = value.get(i).getSource();
- eAnnotation = eStrucClassifier.getEAnnotations().get(i);
- onapType = eAnnotation.getDetails().get(0).getValue();
- onapValue = eAnnotation.getDetails().get(0).getKey();
+ eannotation = estrucClassifier.getEAnnotations().get(i);
+ onapType = eannotation.getDetails().get(0).getValue();
+ onapValue = eannotation.getDetails().get(0).getKey();
if (annotationType.contains(type) && onapType.contains(annotation)) {
return true;
@@ -515,22 +678,29 @@ public class MSModelUtils {
return false;
}
-
- private String annotationValue(EStructuralFeature eStrucClassifier, ANNOTATION_TYPE annotation, String type) {
+ /**
+ * Annotation value.
+ *
+ * @param estrucClassifier the e struc classifier
+ * @param annotation the annotation
+ * @param type the type
+ * @return the string
+ */
+ private String annotationValue(EStructuralFeature estrucClassifier, AnnotationType annotation, String type) {
String annotationType;
- EAnnotation eAnnotation;
+ EAnnotation eannotation;
String onapType;
String onapValue = null;
- EList<EAnnotation> value = eStrucClassifier.getEAnnotations();
+ EList<EAnnotation> value = estrucClassifier.getEAnnotations();
for (int i = 0; i < value.size(); i++) {
annotationType = value.get(i).getSource();
- eAnnotation = eStrucClassifier.getEAnnotations().get(i);
- onapType = eAnnotation.getDetails().get(0).getKey();
+ eannotation = estrucClassifier.getEAnnotations().get(i);
+ onapType = eannotation.getDetails().get(0).getKey();
if (annotationType.contains(type) && onapType.compareToIgnoreCase(annotation.toString()) == 0) {
- onapValue = eAnnotation.getDetails().get(0).getValue();
- if (annotation == ANNOTATION_TYPE.VALIDATION) {
+ onapValue = eannotation.getDetails().get(0).getValue();
+ if (annotation == AnnotationType.VALIDATION) {
return onapValue;
} else {
return onapType + "-" + onapValue;
@@ -541,23 +711,33 @@ public class MSModelUtils {
return onapValue;
}
+ /**
+ * Checks if is required attribute.
+ *
+ * @param obj the obj
+ * @param className the class name
+ * @return true, if is required attribute
+ */
public boolean isRequiredAttribute(EObject obj, String className) {
- EClassifier eClassifier = (EClassifier) obj;
- String workingClass = eClassifier.getName().trim();
- if (workingClass.equalsIgnoreCase(className)) {
- return true;
- }
-
- return false;
+ EClassifier eclassifier = (EClassifier) obj;
+ String workingClass = eclassifier.getName().trim();
+ return workingClass.equalsIgnoreCase(className);
}
+ /**
+ * Checks if is policy template.
+ *
+ * @param root the root
+ * @param className the class name
+ * @return true, if is policy template
+ */
private boolean isPolicyTemplate(EPackage root, String className) {
boolean result = false;
for (EClassifier classifier : root.getEClassifiers()) {
if (classifier instanceof EClass) {
- EClass eClass = (EClass) classifier;
- if (eClass.getName().contentEquals(className)) {
- result = checkPolicyTemplate(eClass);
+ EClass eclass = (EClass) classifier;
+ if (eclass.getName().contentEquals(className)) {
+ result = checkPolicyTemplate(eclass);
break;
}
}
@@ -565,8 +745,14 @@ public class MSModelUtils {
return result;
}
- private boolean checkPolicyTemplate(EClass eClass) {
- EList<EAnnotation> value = eClass.getEAnnotations();
+ /**
+ * Check policy template.
+ *
+ * @param eclass the e class
+ * @return true, if successful
+ */
+ private boolean checkPolicyTemplate(EClass eclass) {
+ EList<EAnnotation> value = eclass.getEAnnotations();
for (EAnnotation workingValue : value) {
EMap<String, String> keyMap = workingValue.getDetails();
if (keyMap.containsKey("policyTemplate")) {
@@ -576,6 +762,13 @@ public class MSModelUtils {
return false;
}
+ /**
+ * Gets the sub types.
+ *
+ * @param root the root
+ * @param className the class name
+ * @return the sub types
+ */
private String getSubTypes(EPackage root, String className) {
String returnSubTypes = null;
for (EClassifier classifier : root.getEClassifiers()) {
@@ -586,17 +779,33 @@ public class MSModelUtils {
return returnSubTypes;
}
+ /**
+ * Find sub types.
+ *
+ * @param className the class name
+ * @param returnSubTypes the return sub types
+ * @param classifier the classifier
+ * @return the string
+ */
private String findSubTypes(String className, String returnSubTypes, EClass classifier) {
- EClass eClass = classifier;
+ EClass eclass = classifier;
- for (EClass eSuperType : eClass.getEAllSuperTypes()) {
- if (eClass.getName().contentEquals(className)) {
- returnSubTypes = eSuperType.getName();
+ for (EClass esuperType : eclass.getEAllSuperTypes()) {
+ if (eclass.getName().contentEquals(className)) {
+ returnSubTypes = esuperType.getName();
}
}
return returnSubTypes;
}
+ /**
+ * Gets the attribute list.
+ *
+ * @param root the root
+ * @param className the class name
+ * @param superClass the super class
+ * @return the attribute list
+ */
public Map<String, String> getAttributeList(EPackage root, String className, String superClass) {
TreeIterator<EObject> treeItr = root.eAllContents();
@@ -611,9 +820,9 @@ public class MSModelUtils {
}
if (requiredAttribute && (obj instanceof EStructuralFeature)) {
- EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
- if (!eStrucClassifier.getEAnnotations().isEmpty()) {
- checkStrucClassifier(refAttribute, obj, eStrucClassifier);
+ EStructuralFeature estrucClassifier = (EStructuralFeature) obj;
+ if (!estrucClassifier.getEAnnotations().isEmpty()) {
+ checkStrucClassifier(refAttribute, obj, estrucClassifier);
}
}
}
@@ -621,31 +830,52 @@ public class MSModelUtils {
}
+ /**
+ * Check struc classifier.
+ *
+ * @param refAttribute the ref attribute
+ * @param obj the obj
+ * @param estrucClassifier the e struc classifier
+ */
private void checkStrucClassifier(HashMap<String, String> refAttribute, EObject obj,
- EStructuralFeature eStrucClassifier) {
+ EStructuralFeature estrucClassifier) {
EClassifier refType = ((EStructuralFeature) obj).getEType();
- boolean annotation = annotationTest(eStrucClassifier, configuration, onap);
- boolean dictionaryTest = annotationTest(eStrucClassifier, dictionary, policy);
+ boolean annotation = annotationTest(estrucClassifier, CONFIGURATION, onap);
+ boolean dictionaryTest = annotationTest(estrucClassifier, DICTIONARY, policy);
if (annotation && !(obj instanceof EReference) && !(refType instanceof EEnumImpl)) {
- updEReferenceAttrib(refAttribute, dictionaryTest, (EStructuralFeature) obj, eStrucClassifier);
+ updEReferenceAttrib(refAttribute, dictionaryTest, (EStructuralFeature) obj, estrucClassifier);
}
}
+ /**
+ * Upd E reference attrib.
+ *
+ * @param refAttribute the ref attribute
+ * @param dictionaryTest the dictionary test
+ * @param obj the obj
+ * @param estrucClassifier the e struc classifier
+ */
private void updEReferenceAttrib(HashMap<String, String> refAttribute, boolean dictionaryTest,
- EStructuralFeature obj, EStructuralFeature eStrucClassifier) {
- String eType;
- String name = eStrucClassifier.getName();
+ EStructuralFeature obj, EStructuralFeature estrucClassifier) {
+ String etype;
+ String name = estrucClassifier.getName();
if (dictionaryTest) {
- eType = annotationValue(eStrucClassifier, ANNOTATION_TYPE.DICTIONARY, policy);
+ etype = annotationValue(estrucClassifier, AnnotationType.DICTIONARY, policy);
} else {
- eType = eStrucClassifier.getEType().getInstanceClassName();
+ etype = estrucClassifier.getEType().getInstanceClassName();
}
String defaultValue = checkDefultValue(obj.getDefaultValueLiteral());
String array = arrayCheck(obj.getUpperBound());
String required = checkRequiredPattern(obj.getUpperBound(), obj.getLowerBound());
- refAttribute.put(name, eType + defaultValue + required + array);
+ refAttribute.put(name, etype + defaultValue + required + array);
}
+ /**
+ * Array check.
+ *
+ * @param upperBound the upper bound
+ * @return the string
+ */
public String arrayCheck(int upperBound) {
if (upperBound == -1) {
@@ -655,17 +885,25 @@ public class MSModelUtils {
return MANYFALSE;
}
- public List<String> getDependencyList(EClassifier eClassifier) {
- List<String> returnValue = new ArrayList<>();;
- EList<EClass> somelist = ((EClass) eClassifier).getEAllSuperTypes();
+ /**
+ * Gets the dependency list.
+ *
+ * @param eclassifier the e classifier
+ * @return the dependency list
+ */
+ public List<String> getDependencyList(EClassifier eclassifier) {
+ List<String> returnValue = new ArrayList<>();
+ ;
+ EList<EClass> somelist = ((EClass) eclassifier).getEAllSuperTypes();
if (somelist.isEmpty()) {
return returnValue;
}
for (EClass depend : somelist) {
- if (depend.toString().contains(eProxyURI)) {
- String one = depend.toString().split(eProxyURI)[1];
- String value =
- StringUtils.replaceEach(one.split("#")[1], new String[] {"//", ")"}, new String[] {"", ""});
+ if (depend.toString().contains(E_PROXY_URI)) {
+ String one = depend.toString().split(E_PROXY_URI)[1];
+ String value = StringUtils.replaceEach(one.split("#")[1], new String[]
+ { "//", ")" }, new String[]
+ { "", "" });
returnValue.add(value);
}
}
@@ -673,8 +911,16 @@ public class MSModelUtils {
return returnValue;
}
+ /**
+ * Builds the sub list.
+ *
+ * @param subClassAttributes the sub class attributes
+ * @param classMap the class map
+ * @param className the class name
+ * @return the map
+ */
public Map<String, String> buildSubList(Map<String, String> subClassAttributes,
- Map<String, MSAttributeObject> classMap, String className) {
+ Map<String, MsAttributeObject> classMap, String className) {
Map<String, String> missingValues = new HashMap<>();
Map<String, String> workingMap;
boolean enumType;
@@ -700,15 +946,22 @@ public class MSModelUtils {
return missingValues;
}
- public Map<String, Map<String, String>> recursiveReference(Map<String, MSAttributeObject> classMap,
- String className) {
+ /**
+ * Recursive reference.
+ *
+ * @param classMap the class map
+ * @param className the class name
+ * @return the map
+ */
+ public Map<String, Map<String, String>> recursiveReference(Map<String, MsAttributeObject> classMap,
+ String className) {
Map<String, Map<String, String>> returnObject = new HashMap<>();
Map<String, String> returnClass = getRefclass(classMap, className);
returnObject.put(className, returnClass);
for (Entry<String, String> reAttribute : returnClass.entrySet()) {
if (reAttribute.getValue().split(":")[1].contains("MANY")
- && classMap.get(reAttribute.getValue().split(":")[0]) != null) {
+ && classMap.get(reAttribute.getValue().split(":")[0]) != null) {
returnObject.putAll(recursiveReference(classMap, reAttribute.getValue().split(":")[0]));
}
@@ -718,7 +971,14 @@ public class MSModelUtils {
}
- public String createJson(Map<String, MSAttributeObject> classMap, String className) {
+ /**
+ * Creates the json.
+ *
+ * @param classMap the class map
+ * @param className the class name
+ * @return the string
+ */
+ public String createJson(Map<String, MsAttributeObject> classMap, String className) {
boolean enumType;
Map<String, Map<String, String>> myObject = new HashMap<>();
for (Entry<String, String> map : classMap.get(className).getRefAttribute().entrySet()) {
@@ -726,8 +986,8 @@ public class MSModelUtils {
if (value != null) {
enumType = classMap.get(className).getEnumType().containsKey(value);
if (!enumType && map.getValue().split(":")[1].contains("MANY")) {
- Map<String, Map<String, String>> testRecursive =
- recursiveReference(classMap, map.getValue().split(":")[0]);
+ Map<String, Map<String, String>> testRecursive = recursiveReference(classMap,
+ map.getValue().split(":")[0]);
myObject.putAll(testRecursive);
}
}
@@ -737,7 +997,14 @@ public class MSModelUtils {
return gson.toJson(myObject);
}
- public Map<String, String> getRefclass(Map<String, MSAttributeObject> classMap, String className) {
+ /**
+ * Gets the refclass.
+ *
+ * @param classMap the class map
+ * @param className the class name
+ * @return the refclass
+ */
+ public Map<String, String> getRefclass(Map<String, MsAttributeObject> classMap, String className) {
HashMap<String, String> missingValues = new HashMap<>();
if (classMap.get(className).getAttribute() != null || !classMap.get(className).getAttribute().isEmpty()) {
@@ -751,11 +1018,19 @@ public class MSModelUtils {
return missingValues;
}
- public String createSubAttributes(List<String> dependency, Map<String, MSAttributeObject> classMap,
- String modelName) {
+ /**
+ * Creates the sub attributes.
+ *
+ * @param dependency the dependency
+ * @param classMap the class map
+ * @param modelName the model name
+ * @return the string
+ */
+ public String createSubAttributes(List<String> dependency, Map<String, MsAttributeObject> classMap,
+ String modelName) {
HashMap<String, Object> workingMap = new HashMap<>();
- MSAttributeObject tempObject;
+ MsAttributeObject tempObject;
if (dependency != null) {
if (dependency.isEmpty()) {
return "{}";
@@ -772,15 +1047,23 @@ public class MSModelUtils {
return createJson(classMap, modelName);
}
- public List<String> getFullDependencyList(List<String> dependency, Map<String, MSAttributeObject> classMap) {
+ /**
+ * Gets the full dependency list.
+ *
+ * @param dependency the dependency
+ * @param classMap the class map
+ * @return the full dependency list
+ */
+ public List<String> getFullDependencyList(List<String> dependency, Map<String, MsAttributeObject> classMap) {
ArrayList<String> returnList = new ArrayList<>();
ArrayList<String> workingList;
returnList.addAll(dependency);
for (String element : dependency) {
if (classMap.containsKey(element)) {
- MSAttributeObject value = classMap.get(element);
- String rawValue =
- StringUtils.replaceEach(value.getDependency(), new String[] {"[", "]"}, new String[] {"", ""});
+ MsAttributeObject value = classMap.get(element);
+ String rawValue = StringUtils.replaceEach(value.getDependency(), new String[]
+ { "[", "]" }, new String[]
+ { "", "" });
workingList = new ArrayList<>(Arrays.asList(rawValue.split(",")));
for (String depend : workingList) {
updDependencyList(returnList, depend);
@@ -791,14 +1074,23 @@ public class MSModelUtils {
return returnList;
}
+ /**
+ * Upd dependency list.
+ *
+ * @param returnList the return list
+ * @param depend the depend
+ */
private void updDependencyList(ArrayList<String> returnList, String depend) {
if (!returnList.contains(depend) && !depend.isEmpty()) {
returnList.add(depend.trim());
}
}
- /*
- * For TOSCA Model
+ /**
+ * Parses the TOSCA model.
+ *
+ * @param fileName the file name
+ * @return the string
*/
public String parseTosca(String fileName) {
Map<String, String> map = new LinkedHashMap<>();
@@ -823,14 +1115,21 @@ public class MSModelUtils {
return null;
}
- @SuppressWarnings("unchecked")
+ /**
+ * Load.
+ *
+ * @param fileName the file name
+ * @return the map
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws ParserException the parser exception
+ */
public Map<String, String> load(String fileName) throws IOException, ParserException {
File newConfiguration = new File(fileName);
StringBuilder orderInfo = new StringBuilder("[");
Yaml yaml = new Yaml();
LinkedHashMap<Object, Object> yamlMap = null;
try (InputStream is = new FileInputStream(newConfiguration)) {
- yamlMap = (LinkedHashMap<Object, Object>) yaml.load(is);
+ yamlMap = yaml.load(is);
} catch (FileNotFoundException e) {
logger.error(e);
} catch (Exception e) {
@@ -838,7 +1137,6 @@ public class MSModelUtils {
throw new ParserException("Invalid TOSCA Model format. Please make sure it is a valid YAML file");
}
- StringBuilder sb = new StringBuilder();
LinkedHashMap<String, String> settings = new LinkedHashMap<>();
if (yamlMap == null) {
return settings;
@@ -869,10 +1167,16 @@ public class MSModelUtils {
}
List<String> path = new ArrayList<>();
- serializeMap(settings, sb, path, yamlMap);
+ serializeMap(settings, new StringBuilder(), path, yamlMap);
return settings;
}
+ /**
+ * Validations.
+ *
+ * @param yamlMap the yaml map
+ * @return the string
+ */
@SuppressWarnings("unchecked")
private String validations(@SuppressWarnings("rawtypes") Map yamlMap) {
@@ -887,8 +1191,7 @@ public class MSModelUtils {
// Get a set of the entries
@SuppressWarnings("rawtypes")
Set<Entry> entries = yamlMap.entrySet();
- for (@SuppressWarnings("rawtypes")
- Map.Entry me : entries) {
+ for (Map.Entry<Object, Object> me : entries) {
if (TOSCA_SIMPLE_YAML_1_0_0.equals(me.getValue())) {
isToscaVersionValueFound = true;
}
@@ -944,9 +1247,18 @@ public class MSModelUtils {
return null;
}
- @SuppressWarnings({"unchecked", "rawtypes"})
+ /**
+ * Serialize map.
+ *
+ * @param settings the settings
+ * @param sb the sb
+ * @param path the path
+ * @param yamlMap the yaml map
+ */
+ @SuppressWarnings(
+ { "unchecked", "rawtypes" })
private void serializeMap(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path,
- Map<Object, Object> yamlMap) {
+ Map<Object, Object> yamlMap) {
for (Map.Entry<Object, Object> entry : yamlMap.entrySet()) {
if (entry.getValue() instanceof Map) {
@@ -963,9 +1275,17 @@ public class MSModelUtils {
}
}
+ /**
+ * Serialize list.
+ *
+ * @param settings the settings
+ * @param sb the sb
+ * @param path the path
+ * @param yamlList the yaml list
+ */
@SuppressWarnings("unchecked")
private void serializeList(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path,
- List<String> yamlList) {
+ List<String> yamlList) {
int counter = 0;
for (Object listEle : yamlList) {
if (listEle instanceof Map) {
@@ -983,8 +1303,17 @@ public class MSModelUtils {
}
}
+ /**
+ * Serialize value.
+ *
+ * @param settings the settings
+ * @param sb the sb
+ * @param path the path
+ * @param name the name
+ * @param value the value
+ */
private void serializeValue(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path,
- String name, Object value) {
+ String name, Object value) {
if (value == null) {
return;
}
@@ -996,7 +1325,11 @@ public class MSModelUtils {
settings.put(sb.toString(), value.toString());
}
-
+ /**
+ * Parses the data and policy nodes.
+ *
+ * @param map the map
+ */
void parseDataAndPolicyNodes(Map<String, String> map) {
for (String key : map.keySet()) {
if (key.contains("policy.nodes.Root")) {
@@ -1017,6 +1350,12 @@ public class MSModelUtils {
}
}
+ /**
+ * String between dots.
+ *
+ * @param str the str
+ * @return the int
+ */
// Second index of dot should be returned.
public int stringBetweenDots(String str) {
String stringToSearch = str;
@@ -1031,7 +1370,11 @@ public class MSModelUtils {
return uniqueKeys.size();
}
-
+ /**
+ * String between dots for data fields.
+ *
+ * @param str the str
+ */
public void stringBetweenDotsForDataFields(String str) {
String stringToSearch = str;
String[] ss = stringToSearch.split("\\.");
@@ -1044,6 +1387,11 @@ public class MSModelUtils {
}
}
+ /**
+ * Construct json for data fields.
+ *
+ * @param dataMapForJson the data map for json
+ */
void constructJsonForDataFields(LinkedHashMap<String, String> dataMapForJson) {
LinkedHashMap<String, LinkedHashMap<String, String>> dataMapKey = new LinkedHashMap<>();
LinkedHashMap<String, String> hmSub;
@@ -1065,14 +1413,14 @@ public class MSModelUtils {
JSONObject mainObject = new JSONObject();
JSONObject json;
for (Map.Entry<String, LinkedHashMap<String, String>> entry : dataMapKey.entrySet()) {
- String s = entry.getKey();
+ String keyString = entry.getKey();
json = new JSONObject();
- HashMap<String, String> jsonHm = dataMapKey.get(s);
+ HashMap<String, String> jsonHm = dataMapKey.get(keyString);
for (Map.Entry<String, String> entryMap : jsonHm.entrySet()) {
String key = entryMap.getKey();
json.put(key, jsonHm.get(key));
}
- mainObject.put(s, json);
+ mainObject.put(keyString, json);
}
Iterator<String> keysItr = mainObject.keys();
while (keysItr.hasNext()) {
@@ -1086,6 +1434,12 @@ public class MSModelUtils {
logger.info("###############################################################################");
}
+ /**
+ * Parses the data nodes.
+ *
+ * @param map the map
+ * @return the linked hash map
+ */
LinkedHashMap<String, String> parseDataNodes(Map<String, String> map) {
LinkedHashMap<String, String> dataMapForJson = new LinkedHashMap<>();
matchableValues = new HashMap<>();
@@ -1112,13 +1466,10 @@ public class MSModelUtils {
requiredValue = "false";
}
if (INTEGER.equalsIgnoreCase(typeValue) || STRING.equalsIgnoreCase(typeValue)
- || typeValue.equalsIgnoreCase(BOOLEAN)) {
- String findDefault =
- DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1] + DEFAULT;
- String findDescription =
- DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1] + DESCRIPTION;
+ || typeValue.equalsIgnoreCase(BOOLEAN)) {
+ String findDefault = DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1]
+ + DEFAULT;
String defaultValue = map.get(findDefault);
- String descriptionDefined = map.get(findDescription);
logger.info("defaultValue is:" + defaultValue);
logger.info("requiredValue is:" + requiredValue);
@@ -1126,16 +1477,19 @@ public class MSModelUtils {
attributeIndividualStringBuilder.append(typeValue + DEFAULTVALUE);
attributeIndividualStringBuilder.append(defaultValue + REQUIREDVALUE);
attributeIndividualStringBuilder.append(requiredValue + MANYFALSE);
- attributeIndividualStringBuilder.append(DESCRIPTION_TOKEN + descriptionDefined);
+
+ String findDescription = DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1]
+ + DESCRIPTION;
+ attributeIndividualStringBuilder.append(DESCRIPTION_TOKEN + map.get(findDescription));
dataMapForJson.put(uniqueDataKey, attributeIndividualStringBuilder.toString());
} else if (LIST.equalsIgnoreCase(typeValue) || MAP.equalsIgnoreCase(typeValue)) {
logger.info("requiredValue is:" + requiredValue);
String findList = DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1]
- + ".entry_schema.type";
+ + ".entry_schema.type";
String findDefaultValue = DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1]
- + ".entry_schema.default";
+ + ".entry_schema.default";
String findDescription = DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1]
- + ".entry_schema.description";
+ + ".entry_schema.description";
String listValue = map.get(findList);
String defaultValue = map.get(findDefaultValue);
String description = map.get(findDescription);
@@ -1153,16 +1507,19 @@ public class MSModelUtils {
StringBuilder stringListItems = new StringBuilder();
if (LIST.equalsIgnoreCase(typeValue)) {
stringListItems.append(uniqueDataKeySplit[1].toUpperCase() + DEFAULTVALUE + defaultValue
- + REQUIREDVALUE + requiredValue + MANYFALSE + DESCRIPTION_TOKEN + description);
+ + REQUIREDVALUE + requiredValue + MANYFALSE + DESCRIPTION_TOKEN
+ + description);
} else if (MAP.equalsIgnoreCase(typeValue)) {
stringListItems.append(uniqueDataKeySplit[1].toUpperCase() + DEFAULTVALUE + defaultValue
- + REQUIREDVALUE + requiredValue + MANYTRUE + DESCRIPTION_TOKEN + description);
+ + REQUIREDVALUE + requiredValue + MANYTRUE + DESCRIPTION_TOKEN
+ + description);
}
dataMapForJson.put(uniqueDataKey, stringListItems.toString());
dataListBuffer.append(uniqueDataKeySplit[1].toUpperCase() + "=[");
for (int i = 0; i < 10; i++) {
String findConstraints = DATATYPE + uniqueDataKeySplit[0] + PROPERTIES
- + uniqueDataKeySplit[1] + ".entry_schema.constraints.0.valid_values." + i;
+ + uniqueDataKeySplit[1] + ".entry_schema.constraints.0.valid_values."
+ + i;
String constraintsValue = map.get(findConstraints);
logger.info(constraintsValue);
boolean ruleCheck = false;
@@ -1177,19 +1534,19 @@ public class MSModelUtils {
ruleCheck = true;
dictionaryNameValRule = dictionaryNameVal.split("#");
dictFromDB = commonClassDao.getDataById(DictionaryData.class, DICTIONARYNAME,
- dictionaryNameValRule[0]);
+ dictionaryNameValRule[0]);
} else {
dictFromDB = commonClassDao.getDataById(DictionaryData.class, DICTIONARYNAME,
- dictionaryName[1]);
+ dictionaryName[1]);
}
if (dictFromDB != null && !dictFromDB.isEmpty()) {
DictionaryData data = (DictionaryData) dictFromDB.get(0);
if (ruleCheck) {
constraintsValue = DICTIONARY + data.getDictionaryUrl() + "@"
- + data.getDictionaryDataByName() + "&Rule";
+ + data.getDictionaryDataByName() + "&Rule";
} else {
constraintsValue = DICTIONARY + data.getDictionaryUrl() + "@"
- + data.getDictionaryDataByName();
+ + data.getDictionaryDataByName();
}
}
dataListBuffer.append(constraintsValue + ",");
@@ -1208,9 +1565,9 @@ public class MSModelUtils {
}
} else {
String findUserDefined = DATATYPE + uniqueDataKeySplit[0] + "." + PROPERTIES_KEY + "."
- + uniqueDataKeySplit[1] + TYPE;
+ + uniqueDataKeySplit[1] + TYPE;
String findDescription = DATATYPE + uniqueDataKeySplit[0] + "." + PROPERTIES_KEY + "."
- + uniqueDataKeySplit[1] + DESCRIPTION;
+ + uniqueDataKeySplit[1] + DESCRIPTION;
String userDefinedValue = map.get(findUserDefined);
String description = map.get(findDescription);
String trimValue = userDefinedValue.substring(userDefinedValue.lastIndexOf('.') + 1);
@@ -1229,8 +1586,15 @@ public class MSModelUtils {
return dataMapForJson;
}
+ /**
+ * Parses the policy nodes.
+ *
+ * @param map the map
+ * @return the linked hash map
+ * @throws ParserException the parser exception
+ */
LinkedHashMap<String, LinkedHashMap<String, String>> parsePolicyNodes(Map<String, String> map)
- throws ParserException {
+ throws ParserException {
LinkedHashMap<String, LinkedHashMap<String, String>> mapKey = new LinkedHashMap<>();
for (String uniqueKey : uniqueKeys) {
LinkedHashMap<String, String> hm;
@@ -1243,10 +1607,9 @@ public class MSModelUtils {
String keyStr = key.substring(key.lastIndexOf('.') + 1);
String valueStr = map.get(key);
if ("type".equalsIgnoreCase(keyStr) && key.contains("entry_schema.0.type")
- || key.contains("entry_schema.type") && valueStr.contains("policy.data.")) {
- throw new ParserException(
- "For user defined object type, Please make sure no space between 'type:' and object "
- + valueStr);
+ || key.contains("entry_schema.type") && valueStr.contains("policy.data.")) {
+ throw new ParserException("For user defined object type,"
+ + " Please make sure no space between 'type:' and object " + valueStr);
}
if ("type".equals(keyStr)) {
@@ -1277,6 +1640,11 @@ public class MSModelUtils {
return mapKey;
}
+ /**
+ * Creates the attributes.
+ *
+ * @param mapKey the map key
+ */
private void createAttributes(LinkedHashMap<String, LinkedHashMap<String, String>> mapKey) {
StringBuilder attributeStringBuilder = new StringBuilder();
StringBuilder referenceStringBuilder = new StringBuilder();
@@ -1286,8 +1654,8 @@ public class MSModelUtils {
String keySetString = entry.getKey();
LinkedHashMap<String, String> keyValues = mapKey.get(keySetString);
if (keyValues.get("type") != null && (STRING.equalsIgnoreCase(keyValues.get("type"))
- || INTEGER.equalsIgnoreCase(keyValues.get("type"))
- || BOOLEAN.equalsIgnoreCase(keyValues.get("type")))) {
+ || INTEGER.equalsIgnoreCase(keyValues.get("type"))
+ || BOOLEAN.equalsIgnoreCase(keyValues.get("type")))) {
StringBuilder attributeIndividualStringBuilder = new StringBuilder();
attributeIndividualStringBuilder.append(keySetString + "=");
attributeIndividualStringBuilder.append(keyValues.get("type") + DEFAULTVALUE);
@@ -1321,7 +1689,7 @@ public class MSModelUtils {
String trimValue = value.substring(value.lastIndexOf('.') + 1);
StringBuilder referenceIndividualStringBuilder = new StringBuilder();
referenceIndividualStringBuilder.append(keySetString + "=" + trimValue + MANYTRUE
- + DESCRIPTION_TOKEN + keyValues.get(DESCRIPTION_KEY));
+ + DESCRIPTION_TOKEN + keyValues.get(DESCRIPTION_KEY));
referenceStringBuilder.append(referenceIndividualStringBuilder + ",");
isDefinedType = true;
}
@@ -1330,7 +1698,7 @@ public class MSModelUtils {
}
if (!isDefinedType && LIST.equalsIgnoreCase(keyValues.get("type"))
- && (constraints == null || constraints.isEmpty())) {
+ && (constraints == null || constraints.isEmpty())) {
referenceStringBuilder.append(keySetString + "=MANY-true" + ",");
}
} else {
@@ -1343,7 +1711,7 @@ public class MSModelUtils {
String trimValue = value.substring(value.lastIndexOf('.') + 1);
StringBuilder referenceIndividualStringBuilder = new StringBuilder();
referenceIndividualStringBuilder.append(keySetString + "=" + trimValue + MANYFALSE
- + DESCRIPTION_TOKEN + keyValues.get(DESCRIPTION_KEY));
+ + DESCRIPTION_TOKEN + keyValues.get(DESCRIPTION_KEY));
referenceStringBuilder.append(referenceIndividualStringBuilder + ",");
} else {
logger.info("keyValues.get(type) is null/empty");
@@ -1356,8 +1724,8 @@ public class MSModelUtils {
for (String str : constraints) {
if (str.contains(DICTIONARY)) {
String[] dictionaryName = str.split(":");
- List<Object> dictFromDB =
- commonClassDao.getDataById(DictionaryData.class, DICTIONARYNAME, dictionaryName[1]);
+ List<Object> dictFromDB = commonClassDao.getDataById(DictionaryData.class, DICTIONARYNAME,
+ dictionaryName[1]);
if (dictFromDB != null && !dictFromDB.isEmpty()) {
DictionaryData data = (DictionaryData) dictFromDB.get(0);
str = DICTIONARY + data.getDictionaryUrl() + "@" + data.getDictionaryDataByName();
@@ -1368,7 +1736,6 @@ public class MSModelUtils {
listBuffer.append("]#");
logger.info(listBuffer);
-
StringBuilder referenceIndividualStringBuilder = new StringBuilder();
referenceIndividualStringBuilder.append(keySetString + "=" + keySetString.toUpperCase() + MANYFALSE);
referenceStringBuilder.append(referenceIndividualStringBuilder + ",");
@@ -1378,7 +1745,6 @@ public class MSModelUtils {
dataListBuffer.append(listBuffer);
-
logger.info("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
logger.info("Whole attribute String is:" + attributeStringBuilder);
logger.info("Whole reference String is:" + referenceStringBuilder);
@@ -1391,6 +1757,11 @@ public class MSModelUtils {
this.attributeString = attributeStringBuilder.toString();
}
+ /**
+ * Find node.
+ *
+ * @param map the map
+ */
@SuppressWarnings("unchecked")
private void findNode(LinkedHashMap<Object, Object> map) {
@@ -1412,6 +1783,11 @@ public class MSModelUtils {
}
+ /**
+ * Save nodes.
+ *
+ * @param map the map
+ */
private void saveNodes(LinkedHashMap<?, ?> map) {
for (Entry<?, ?> entry : map.entrySet()) {
@@ -1424,61 +1800,4 @@ public class MSModelUtils {
}
}
}
-
- public String getAttributeString() {
- return attributeString;
- }
-
- public void setAttributeString(String attributeString) {
- this.attributeString = attributeString;
- }
-
- public LinkedHashMap<String, Object> getRetmap() {
- return retmap;
- }
-
- public void setRetmap(LinkedHashMap<String, Object> retmap) {
- this.retmap = retmap;
- }
-
- public Map<String, String> getMatchableValues() {
- return matchableValues;
- }
-
- public void setMatchableValues(Map<String, String> matchableValues) {
- this.matchableValues = matchableValues;
- }
-
- public String getReferenceAttributes() {
- return referenceAttributes;
- }
-
- public void setReferenceAttributes(String referenceAttributes) {
- this.referenceAttributes = referenceAttributes;
- }
-
- public String getListConstraints() {
- return listConstraints;
- }
-
- public void setListConstraints(String listConstraints) {
- this.listConstraints = listConstraints;
- }
-
- public String getDataOrderInfo() {
- return dataOrderInfo;
- }
-
- public void setDataOrderInfo(String dataOrderInfo) {
- this.dataOrderInfo = dataOrderInfo;
- }
-
- public String getJsonRuleFormation() {
- return jsonRuleFormation;
- }
-
- public void setJsonRuleFormation(String jsonRuleFormation) {
- this.jsonRuleFormation = jsonRuleFormation;
- }
-
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/ParserException.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/ParserException.java
index 50e30f05b..5e034d29b 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/ParserException.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/ParserException.java
@@ -2,14 +2,15 @@
* ============LICENSE_START=======================================================
* ONAP-REST
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,14 +18,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.util;
-public class ParserException extends Exception{
- String message;
- ParserException(String message) {
- this.message = message;
- }
- public String getMessage(){
- return message ;
- }
+public class ParserException extends Exception {
+ private static final long serialVersionUID = -1166704711958410424L;
+
+ public ParserException(String message) {
+ super(message);
+ }
} \ No newline at end of file
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PDPPolicyContainer.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PdpPolicyContainer.java
index f5c4c3b38..d6bd3f831 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PDPPolicyContainer.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PdpPolicyContainer.java
@@ -3,13 +3,14 @@
* ONAP Policy Engine
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +21,11 @@
package org.onap.policy.rest.util;
+import com.att.research.xacml.api.pap.PDP;
+import com.att.research.xacml.api.pap.PDPGroup;
+import com.att.research.xacml.api.pap.PDPPolicy;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.Collection;
@@ -32,69 +38,56 @@ import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.std.pap.StdPDPPolicy;
-import com.att.research.xacml.api.pap.PDP;
-import com.att.research.xacml.api.pap.PDPGroup;
-import com.att.research.xacml.api.pap.PDPPolicy;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements PolicyContainer.Indexed {
+public class PdpPolicyContainer extends PolicyItemSetChangeNotifier implements PolicyContainer.Indexed {
private static final long serialVersionUID = 1L;
- private static final Logger LOGGER = FlexLogger.getLogger(PDPPolicyContainer.class);
+ private static final Logger LOGGER = FlexLogger.getLogger(PdpPolicyContainer.class);
- /**
- * String identifier of a file's "Id" property.
- */
private static final String PROPERTY_ID = "Id";
-
- /**
- * String identifier of a file's "name" property.
- */
private static final String PROPERTY_NAME = "Name";
-
- /**
- * String identifier of a file's "name" property.
- */
private static final String PROPERTY_VERSION = "Version";
-
- /**
- * String identifier of a file's "Description" property.
- */
private static final String PROPERTY_DESCRIPTION = "Description";
-
- /**
- * String identifier of a file's "IsRoot" property.
- */
private static final String PROPERTY_ISROOT = "Root";
/**
* List of the string identifiers for the available properties.
*/
private static Collection<String> pDPPolicyProperties;
-
+
private final transient Object data;
private transient List<PDPPolicy> policies;
-
+
+ /**
+ * Instantiates a new pdp policy container.
+ *
+ * @param data the data
+ */
@SuppressWarnings("unchecked")
- public PDPPolicyContainer(Object data) {
+ public PdpPolicyContainer(Object data) {
super();
this.data = data;
if (this.data instanceof PDPGroup) {
- policies = new ArrayList<> (((PDPGroup) this.data).getPolicies());
+ policies = new ArrayList<>(((PDPGroup) this.data).getPolicies());
}
if (this.data instanceof PDP) {
- policies = new ArrayList<> (((PDP) this.data).getPolicies());
+ policies = new ArrayList<>(((PDP) this.data).getPolicies());
}
if (this.data instanceof Set) {
- policies = new ArrayList<> ((Set<PDPPolicy>)data);
+ policies = new ArrayList<>((Set<PDPPolicy>) data);
}
if (this.policies == null) {
LOGGER.info("NULL policies");
- throw new NullPointerException("PDPPolicyContainer created with unexpected Object type '" + data.getClass().getName() + "'");
+ throw new NullPointerException("PDPPolicyContainer created with unexpected Object type '"
+ + data.getClass().getName() + "'");
}
this.setContainer(this);
}
+ /**
+ * Next item id.
+ *
+ * @param itemId the item id
+ * @return the object
+ */
@Override
public Object nextItemId(Object itemId) {
if (LOGGER.isTraceEnabled()) {
@@ -104,9 +97,15 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
if (index == -1 || ((index + 1) >= this.policies.size())) {
return null;
}
- return new PDPPolicyItem(this.policies.get(index + 1));
+ return new PdpPolicyItem(this.policies.get(index + 1));
}
+ /**
+ * Prev item id.
+ *
+ * @param itemId the item id
+ * @return the object
+ */
@Override
public Object prevItemId(Object itemId) {
if (LOGGER.isTraceEnabled()) {
@@ -116,9 +115,14 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
if (index <= 0) {
return null;
}
- return new PDPPolicyItem(this.policies.get(index - 1));
+ return new PdpPolicyItem(this.policies.get(index - 1));
}
+ /**
+ * First item id.
+ *
+ * @return the object
+ */
@Override
public Object firstItemId() {
if (LOGGER.isTraceEnabled()) {
@@ -127,9 +131,14 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
if (this.policies.isEmpty()) {
return null;
}
- return new PDPPolicyItem(this.policies.get(0));
+ return new PdpPolicyItem(this.policies.get(0));
}
+ /**
+ * Last item id.
+ *
+ * @return the object
+ */
@Override
public Object lastItemId() {
if (LOGGER.isTraceEnabled()) {
@@ -138,9 +147,15 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
if (this.policies.isEmpty()) {
return null;
}
- return new PDPPolicyItem(this.policies.get(this.policies.size() - 1));
+ return new PdpPolicyItem(this.policies.get(this.policies.size() - 1));
}
+ /**
+ * Checks if is first id.
+ *
+ * @param itemId the item id
+ * @return true, if is first id
+ */
@Override
public boolean isFirstId(Object itemId) {
if (LOGGER.isTraceEnabled()) {
@@ -152,6 +167,12 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
return itemId.equals(this.policies.get(0));
}
+ /**
+ * Checks if is last id.
+ *
+ * @param itemId the item id
+ * @return true, if is last id
+ */
@Override
public boolean isLastId(Object itemId) {
if (LOGGER.isTraceEnabled()) {
@@ -163,16 +184,32 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
return itemId.equals(this.policies.get(this.policies.size() - 1));
}
+ /**
+ * Adds the item after.
+ *
+ * @param previousItemId the previous item id
+ * @return the object
+ */
@Override
public Object addItemAfter(Object previousItemId) {
return null;
}
+ /**
+ * Gets the container property ids.
+ *
+ * @return the container property ids
+ */
@Override
public Collection<?> getContainerPropertyIds() {
return pDPPolicyProperties;
}
+ /**
+ * Gets the item ids.
+ *
+ * @return the item ids
+ */
@Override
public Collection<?> getItemIds() {
final Collection<Object> items = new ArrayList<>();
@@ -180,7 +217,30 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
return Collections.unmodifiableCollection(items);
}
+ /**
+ * Gets the item ids.
+ *
+ * @param startIndex the start index
+ * @param numberOfItems the number of items
+ * @return the item ids
+ */
+ @Override
+ public List<?> getItemIds(int startIndex, int numberOfItems) {
+ if (LOGGER.isTraceEnabled()) {
+ LOGGER.trace("getItemIds: " + startIndex + " " + numberOfItems);
+ }
+ if (numberOfItems < 0) {
+ throw new IllegalArgumentException();
+ }
+ return this.policies.subList(startIndex, startIndex + numberOfItems);
+ }
+ /**
+ * Gets the type.
+ *
+ * @param propertyId the property id
+ * @return the type
+ */
@Override
public Class<?> getType(Object propertyId) {
if (propertyId.equals(PROPERTY_ID)) {
@@ -201,6 +261,11 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
return null;
}
+ /**
+ * Size.
+ *
+ * @return the int
+ */
@Override
public int size() {
if (LOGGER.isTraceEnabled()) {
@@ -209,6 +274,12 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
return this.policies.size();
}
+ /**
+ * Contains id.
+ *
+ * @param itemId the item id
+ * @return true, if successful
+ */
@Override
public boolean containsId(Object itemId) {
if (LOGGER.isTraceEnabled()) {
@@ -217,11 +288,22 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
return this.policies.contains(itemId);
}
+ /**
+ * Adds the item.
+ *
+ * @return the object
+ */
@Override
public Object addItem() {
throw new UnsupportedOperationException("Cannot add an empty policy.");
}
+ /**
+ * Removes the item.
+ *
+ * @param itemId the item id
+ * @return true, if successful
+ */
@Override
public boolean removeItem(Object itemId) {
if (LOGGER.isTraceEnabled()) {
@@ -231,34 +313,59 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
StdPDPPolicy pdpPolicy = null;
try {
- pdpPolicy = mapper.readValue(itemId.toString() , StdPDPPolicy.class);
- for(int i = 0; i< policies.size(); i++){
- if(policies.get(i).getId().equalsIgnoreCase(pdpPolicy.getId())){
+ pdpPolicy = mapper.readValue(itemId.toString(), StdPDPPolicy.class);
+ for (int i = 0; i < policies.size(); i++) {
+ if (policies.get(i).getId().equalsIgnoreCase(pdpPolicy.getId())) {
return this.policies.remove(this.policies.get(i));
}
}
} catch (Exception e) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Exception Occured While Mapping the Removing Policy from PDP Group to Std Policy"+e);
+ LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE
+ + "Exception Occured While Mapping the Removing Policy from PDP Group to Std Policy" + e);
}
return this.policies.remove(itemId);
}
+ /**
+ * Adds the container property.
+ *
+ * @param propertyId the property id
+ * @param type the type
+ * @param defaultValue the default value
+ * @return true, if successful
+ */
@Override
- public boolean addContainerProperty(Object propertyId, Class<?> type,
- Object defaultValue) {
+ public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) {
return false;
}
+ /**
+ * Removes the container property.
+ *
+ * @param propertyId the property id
+ * @return true, if successful
+ */
@Override
public boolean removeContainerProperty(Object propertyId) {
return false;
}
+ /**
+ * Removes the all items.
+ *
+ * @return true, if successful
+ */
@Override
public boolean removeAllItems() {
return false;
}
+ /**
+ * Index of id.
+ *
+ * @param itemId the item id
+ * @return the int
+ */
@Override
public int indexOfId(Object itemId) {
if (LOGGER.isTraceEnabled()) {
@@ -267,6 +374,12 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
return this.policies.indexOf(itemId);
}
+ /**
+ * Gets the id by index.
+ *
+ * @param index the index
+ * @return the id by index
+ */
@Override
public Object getIdByIndex(int index) {
if (LOGGER.isTraceEnabled()) {
@@ -275,17 +388,12 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
return this.policies.get(index);
}
- @Override
- public List<?> getItemIds(int startIndex, int numberOfItems) {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("getItemIds: " + startIndex + " " + numberOfItems);
- }
- if (numberOfItems < 0) {
- throw new IllegalArgumentException();
- }
- return this.policies.subList(startIndex, startIndex + numberOfItems);
- }
-
+ /**
+ * Adds the item at.
+ *
+ * @param index the index
+ * @return the object
+ */
@Override
public Object addItemAt(int index) {
if (LOGGER.isTraceEnabled()) {
@@ -294,13 +402,23 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
return null;
}
- public class PDPPolicyItem {
+ public class PdpPolicyItem {
private final PDPPolicy policy;
- public PDPPolicyItem(PDPPolicy itemId) {
+ /**
+ * Instantiates a new PDP policy item.
+ *
+ * @param itemId the item id
+ */
+ public PdpPolicyItem(PDPPolicy itemId) {
this.policy = itemId;
}
+ /**
+ * Gets the id.
+ *
+ * @return the id
+ */
public String getId() {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("getId: " + this.policy);
@@ -308,6 +426,11 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
return this.policy.getId();
}
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
public String getName() {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("getName: " + this.policy);
@@ -315,6 +438,11 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
return this.policy.getName();
}
+ /**
+ * Gets the version.
+ *
+ * @return the version
+ */
public String getVersion() {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("getVersion: " + this.policy);
@@ -322,6 +450,11 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
return this.policy.getVersion();
}
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
public String getDescription() {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("getDescription: " + this.policy);
@@ -329,6 +462,11 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
return this.policy.getDescription();
}
+ /**
+ * Gets the root.
+ *
+ * @return the root
+ */
public boolean getRoot() {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("isRoot: " + this.policy);
@@ -336,8 +474,13 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
return this.policy.isRoot();
}
+ /**
+ * Sets the root.
+ *
+ * @param root the new root
+ */
public void setRoot(Boolean root) {
- ((StdPDPPolicy)this.policy).setRoot(root);
+ ((StdPDPPolicy) this.policy).setRoot(root);
}
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyContainer.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyContainer.java
index 80bb16d54..42bee49b5 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyContainer.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyContainer.java
@@ -3,13 +3,14 @@
* ONAP Policy Engine
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,26 +25,24 @@ import java.io.Serializable;
import java.util.Collection;
import java.util.List;
-
-public interface PolicyContainer extends Serializable{
+public interface PolicyContainer extends Serializable {
public Collection<?> getContainerPropertyIds();
-
+
public Collection<?> getItemIds();
public Class<?> getType(Object propertyId);
public int size();
-
+
public boolean containsId(Object itemId);
public Object addItem();
-
+
public boolean removeItem(Object itemId);
- public boolean addContainerProperty(Object propertyId, Class<?> type,
- Object defaultValue);
-
+ public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue);
+
public boolean removeContainerProperty(Object propertyId);
public boolean removeAllItems();
@@ -63,10 +62,9 @@ public interface PolicyContainer extends Serializable{
public boolean isLastId(Object itemId);
public Object addItemAfter(Object previousItemId);
-
+
}
-
public interface Indexed extends Ordered {
public int indexOfId(Object itemId);
@@ -74,7 +72,7 @@ public interface PolicyContainer extends Serializable{
public Object getIdByIndex(int index);
public List<?> getItemIds(int startIndex, int numberOfItems);
-
+
public Object addItemAt(int index);
public interface ItemAddEvent extends ItemSetChangeEvent {
@@ -86,9 +84,8 @@ public interface PolicyContainer extends Serializable{
public int getAddedItemsCount();
}
-
public interface ItemRemoveEvent extends ItemSetChangeEvent {
-
+
public Object getFirstItemId();
public int getFirstIndex();
@@ -96,23 +93,21 @@ public interface PolicyContainer extends Serializable{
public int getRemovedItemsCount();
}
}
-
- public interface ItemSetChangeEvent extends Serializable {
+ @FunctionalInterface
+ public interface ItemSetChangeEvent {
public PolicyContainer getContainer();
}
- public interface ItemSetChangeListener extends Serializable {
-
+ @FunctionalInterface
+ public interface ItemSetChangeListener {
public void containerItemSetChange(PolicyContainer.ItemSetChangeEvent event);
}
public interface ItemSetChangeNotifier extends Serializable {
- public void addItemSetChangeListener(
- PolicyContainer.ItemSetChangeListener listener);
+ public void addItemSetChangeListener(PolicyContainer.ItemSetChangeListener listener);
- public void removeItemSetChangeListener(
- PolicyContainer.ItemSetChangeListener listener);
+ public void removeItemSetChangeListener(PolicyContainer.ItemSetChangeListener listener);
}
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifier.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifier.java
index 16e467041..d70830118 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifier.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifier.java
@@ -3,13 +3,14 @@
* ONAP Policy Engine
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,7 +21,6 @@
package org.onap.policy.rest.util;
-
import java.io.Serializable;
import java.util.Collection;
import java.util.EventObject;
@@ -29,19 +29,18 @@ import java.util.LinkedList;
import org.onap.policy.rest.util.PolicyContainer.ItemSetChangeEvent;
import org.onap.policy.rest.util.PolicyContainer.ItemSetChangeListener;
-
-
public class PolicyItemSetChangeNotifier implements PolicyContainer.ItemSetChangeNotifier {
private static final long serialVersionUID = 1L;
+
private Collection<PolicyContainer.ItemSetChangeListener> itemSetChangeListeners = null;
private PolicyContainer container = null;
-
+
public PolicyItemSetChangeNotifier() {
// Empty constructor
}
-
- protected void setContainer(PolicyContainer c) {
- this.container = c;
+
+ protected void setContainer(PolicyContainer container) {
+ this.container = container;
}
@Override
@@ -49,7 +48,8 @@ public class PolicyItemSetChangeNotifier implements PolicyContainer.ItemSetChang
if (getItemSetChangeListeners() == null) {
setItemSetChangeListeners(new LinkedList<PolicyContainer.ItemSetChangeListener>());
}
- getItemSetChangeListeners().add(listener); }
+ getItemSetChangeListeners().add(listener);
+ }
@Override
public void removeItemSetChangeListener(ItemSetChangeListener listener) {
@@ -58,8 +58,8 @@ public class PolicyItemSetChangeNotifier implements PolicyContainer.ItemSetChang
}
}
- protected static class BaseItemSetChangeEvent extends EventObject implements
- PolicyContainer.ItemSetChangeEvent, Serializable {
+ protected static class BaseItemSetChangeEvent extends EventObject
+ implements PolicyContainer.ItemSetChangeEvent, Serializable {
private static final long serialVersionUID = 1L;
protected BaseItemSetChangeEvent(PolicyContainer source) {
@@ -72,14 +72,14 @@ public class PolicyItemSetChangeNotifier implements PolicyContainer.ItemSetChang
}
}
- protected void setItemSetChangeListeners(
- Collection<PolicyContainer.ItemSetChangeListener> itemSetChangeListeners) {
+ protected void setItemSetChangeListeners(Collection<PolicyContainer.ItemSetChangeListener> itemSetChangeListeners) {
this.itemSetChangeListeners = itemSetChangeListeners;
}
+
protected Collection<PolicyContainer.ItemSetChangeListener> getItemSetChangeListeners() {
return itemSetChangeListeners;
}
-
+
protected void fireItemSetChange() {
fireItemSetChange(new BaseItemSetChangeEvent(this.container));
}
@@ -88,8 +88,7 @@ public class PolicyItemSetChangeNotifier implements PolicyContainer.ItemSetChang
if (getItemSetChangeListeners() != null) {
final Object[] l = getItemSetChangeListeners().toArray();
for (int i = 0; i < l.length; i++) {
- ((PolicyContainer.ItemSetChangeListener) l[i])
- .containerItemSetChange(event);
+ ((PolicyContainer.ItemSetChangeListener) l[i]).containerItemSetChange(event);
}
}
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java
index de20cd3f8..70be83208 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java
@@ -3,13 +3,14 @@
* ONAP Policy Engine
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.
@@ -26,9 +27,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
-
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringReader;
@@ -42,12 +40,18 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+
import javax.json.Json;
import javax.json.JsonException;
import javax.json.JsonObject;
import javax.json.JsonReader;
import javax.json.JsonValue;
+import lombok.Getter;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
+
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
@@ -67,42 +71,56 @@ import org.onap.policy.xacml.util.XACMLPolicyScanner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-
@Service
public class PolicyValidation {
-
private static final Logger LOGGER = FlexLogger.getLogger(PolicyValidation.class);
- public static final String CONFIG_POLICY = "Config";
- public static final String ACTION_POLICY = "Action";
- public static final String DECISION_POLICY = "Decision";
- public static final String DECISION_POLICY_MS = "Decision_MS";
- public static final String CLOSEDLOOP_POLICY = "ClosedLoop_Fault";
- public static final String CLOSEDLOOP_PM = "ClosedLoop_PM";
- public static final String ENFORCER_CONFIG_POLICY = "Enforcer Config";
- public static final String MICROSERVICES = "Micro Service";
- public static final String FIREWALL = "Firewall Config";
- public static final String OPTIMIZATION="Optimization";
- public static final String BRMSPARAM = "BRMS_Param";
- public static final String BRMSRAW = "BRMS_Raw";
- public static final String HTML_ITALICS_LNBREAK = "</i><br>";
- public static final String SUCCESS = "success";
- public static final String EMPTY_COMPONENT_ATTR =
- "Component Attributes: One or more Fields in Component Attributes is Empty.";
- public static final String ISREQUIRED = " is required";
- public static final String SPACESINVALIDCHARS = " : value has spaces or invalid characters</i><br>";
- private static final String REQUIRED_ATTRIBUTE = "required-true";
+ private static final String ACTION_POLICY = "Action";
+ private static final String BOOLEAN = "boolean";
+ private static final String BRMSPARAM = "BRMS_Param";
+ private static final String BRMSRAW = "BRMS_Raw";
+ private static final String CLOSEDLOOP_PM = "ClosedLoop_PM";
+ private static final String CLOSEDLOOP_POLICY = "ClosedLoop_Fault";
+ private static final String CONFIG_POLICY = "Config";
private static final String DECISION_MS_MODEL = "MicroService_Model";
+ private static final String DECISION_POLICY = "Decision";
+ private static final String DECISION_POLICY_MS = "Decision_MS";
+ private static final String ENFORCER_CONFIG_POLICY = "Enforcer Config";
+ private static final String FIREWALL = "Firewall Config";
+ private static final String HTML_ITALICS_LNBREAK = "</i><br>";
+ private static final String INTEGER = "integer";
+ private static final String ISREQUIRED = " is required";
+ private static final String JAVA = "java";
+ private static final String LIST = "list";
+ private static final String MAP = "map";
+ private static final String MICROSERVICES = "Micro Service";
+ private static final String MISSING_COMPONENT_ATTRIBUTE_VALUE = "<b>Component Attributes</b>:"
+ + "<i> has one missing Component Attribute value</i><br>";
+ private static final String MISSING_ATTRIBUTE_VALUE = "<b>Rule Attributes</b>:"
+ + "<i> has one missing Attribute value</i><br>";
+ private static final String MISSING_COMPONENT_ATTRIBUTE_KEY = "<b>Component Attributes</b>:"
+ + "<i> has one missing Component Attribute key</i><br>";
+ private static final String OPTIMIZATION = "Optimization";
private static final String RAW = "Raw";
+ private static final String REQUIRED_ATTRIBUTE = "required-true";
+ private static final String RULE_ALGORITHMS = "<b>Rule Algorithms</b>:<i>";
+ private static final String SELECT_AT_LEAST_ONE_D2_VIRTUALIZED_SERVICES = "<b>D2/Virtualized Services</b>: "
+ + "<i>Select at least one D2/Virtualized Services";
+ private static final String SPACESINVALIDCHARS = " : value has spaces or invalid characters</i><br>";
+ private static final String STRING = "string";
+ private static final String SUCCESS = "success";
+ private static final String VALUE = "value";
private static Map<String, String> mapAttribute = new HashMap<>();
private static Map<String, String> jsonRequestMap = new HashMap<>();
private static List<String> modelRequiredFieldsList = new ArrayList<>();
- private Set<String> allReqTrueKeys = new HashSet<>();
- private Set<String> allOptReqTrueKeys = new HashSet<>();
+ @Getter
private static CommonClassDao commonClassDao;
+ private Set<String> allReqTrueKeys = new HashSet<>();
+ private Set<String> allOptReqTrueKeys = new HashSet<>();
+
@Autowired
public PolicyValidation(CommonClassDao commonClassDao) {
PolicyValidation.commonClassDao = commonClassDao;
@@ -115,7 +133,6 @@ public class PolicyValidation {
// Empty constructor
}
-
/**
* Validate policy.
*
@@ -148,68 +165,64 @@ public class PolicyValidation {
}
if (!"API".equals(policyData.getApiflag()) && policyData.getAttributes() != null
- && !policyData.getAttributes().isEmpty()) {
+ && !policyData.getAttributes().isEmpty()) {
for (Object attribute : policyData.getAttributes()) {
if (attribute instanceof LinkedHashMap<?, ?>) {
- String value = null;
+ String attValue = null;
String key = null;
if (((LinkedHashMap<?, ?>) attribute).get("key") != null) {
key = ((LinkedHashMap<?, ?>) attribute).get("key").toString();
if (!PolicyUtils.policySpecialCharWithDashValidator(key).contains(SUCCESS)) {
- responseString.append("<b>Attributes or Component Attributes</b>:<i>" + value
- + SPACESINVALIDCHARS);
+ responseString.append("<b>Attributes or Component Attributes</b>:<i>" + attValue
+ + SPACESINVALIDCHARS);
valid = false;
}
} else {
if (CONFIG_POLICY.equals(policyData.getPolicyType())) {
if ("Base".equals(policyData.getConfigPolicyType())) {
- responseString
- .append("<b>Attributes</b>:<i> has one missing Attribute key</i><br>");
+ responseString.append(
+ "<b>Attributes</b>:<i> has one missing Attribute key</i><br>");
}
if (BRMSPARAM.equals(policyData.getConfigPolicyType())
- || BRMSRAW.equals(policyData.getConfigPolicyType())) {
- responseString
- .append("<b>Rule Attributes</b>:<i> has one missing Attribute key</i><br>");
+ || BRMSRAW.equals(policyData.getConfigPolicyType())) {
+ responseString.append(
+ "<b>Rule Attributes</b>:<i> has one missing Attribute key</i><br>");
}
} else {
- responseString.append(
- "<b>Component Attributes</b>:<i> has one missing Component Attribute key</i><br>");
+ responseString.append(MISSING_COMPONENT_ATTRIBUTE_KEY);
}
valid = false;
}
- if (((LinkedHashMap<?, ?>) attribute).get("value") != null) {
- value = ((LinkedHashMap<?, ?>) attribute).get("value").toString();
- if (!PolicyUtils.policySpecialCharWithDashValidator(value).contains(SUCCESS)) {
+ if (((LinkedHashMap<?, ?>) attribute).get(VALUE) != null) {
+ attValue = ((LinkedHashMap<?, ?>) attribute).get(VALUE).toString();
+ if (!PolicyUtils.policySpecialCharWithDashValidator(attValue).contains(SUCCESS)) {
if (CONFIG_POLICY.equals(policyData.getPolicyType())) {
if ("Base".equals(policyData.getConfigPolicyType())) {
- responseString.append("<b>Attributes</b>:<i>" + value
- + SPACESINVALIDCHARS);
+ responseString.append("<b>Attributes</b>:<i>" + attValue + SPACESINVALIDCHARS);
}
if (BRMSPARAM.equals(policyData.getConfigPolicyType())
- || BRMSRAW.equals(policyData.getConfigPolicyType())) {
- responseString.append("<b>Rule Attributes</b>:<i>" + value
- + SPACESINVALIDCHARS);
+ || BRMSRAW.equals(policyData.getConfigPolicyType())) {
+ responseString.append(
+ "<b>Rule Attributes</b>:<i>" + attValue + SPACESINVALIDCHARS);
}
} else {
- responseString.append("<b>Component Attributes</b>:<i>" + value
- + SPACESINVALIDCHARS);
+ responseString.append(
+ "<b>Component Attributes</b>:<i>" + attValue + SPACESINVALIDCHARS);
}
valid = false;
}
} else {
if (CONFIG_POLICY.equals(policyData.getPolicyType())) {
if ("Base".equals(policyData.getConfigPolicyType())) {
- responseString
- .append("<b>Attributes</b>:<i> has one missing Attribute value</i><br>");
+ responseString.append(
+ "<b>Attributes</b>:<i> has one missing Attribute value</i><br>");
}
if (BRMSPARAM.equals(policyData.getConfigPolicyType())
- || BRMSRAW.equals(policyData.getConfigPolicyType())) {
- responseString.append(
- "<b>Rule Attributes</b>:<i> has one missing Attribute value</i><br>");
+ || BRMSRAW.equals(policyData.getConfigPolicyType())) {
+ responseString.append(MISSING_ATTRIBUTE_VALUE);
}
} else {
- responseString.append(
- "<b>Component Attributes</b>:<i> has one missing Component Attribute value</i><br>");
+ responseString.append(MISSING_COMPONENT_ATTRIBUTE_VALUE);
}
valid = false;
}
@@ -219,25 +232,24 @@ public class PolicyValidation {
// Decision Policy Attributes Validation
if (!"API".equals(policyData.getApiflag()) && policyData.getSettings() != null
- && !policyData.getSettings().isEmpty()) {
- for (Object attribute : policyData.getAttributes()) {
+ && !policyData.getSettings().isEmpty()) {
+ for (Object attribute : policyData.getSettings()) {
if (attribute instanceof LinkedHashMap<?, ?>) {
String value = null;
if (((LinkedHashMap<?, ?>) attribute).get("key") == null) {
- responseString
- .append("<b>Settings Attributes</b>:<i> has one missing Attribute key</i><br>");
+ responseString.append(
+ "<b>Settings Attributes</b>:<i> has one missing Attribute key</i><br>");
valid = false;
}
- if (((LinkedHashMap<?, ?>) attribute).get("value") != null) {
- value = ((LinkedHashMap<?, ?>) attribute).get("value").toString();
+ if (((LinkedHashMap<?, ?>) attribute).get(VALUE) != null) {
+ value = ((LinkedHashMap<?, ?>) attribute).get(VALUE).toString();
if (!PolicyUtils.policySpecialCharValidator(value).contains(SUCCESS)) {
- responseString.append("<b>Settings Attributes</b>:<i>" + value
- + SPACESINVALIDCHARS);
+ responseString.append("<b>Settings Attributes</b>:<i>" + value + SPACESINVALIDCHARS);
valid = false;
}
} else {
- responseString
- .append("<b>Settings Attributes</b>:<i> has one missing Attribute Value</i><br>");
+ responseString.append(
+ "<b>Settings Attributes</b>:<i> has one missing Attribute Value</i><br>");
valid = false;
}
}
@@ -245,31 +257,28 @@ public class PolicyValidation {
}
if (!"API".equals(policyData.getApiflag()) && policyData.getRuleAlgorithmschoices() != null
- && !policyData.getRuleAlgorithmschoices().isEmpty()) {
+ && !policyData.getRuleAlgorithmschoices().isEmpty()) {
for (Object attribute : policyData.getRuleAlgorithmschoices()) {
if (attribute instanceof LinkedHashMap<?, ?>) {
String label = ((LinkedHashMap<?, ?>) attribute).get("id").toString();
if (((LinkedHashMap<?, ?>) attribute).get("dynamicRuleAlgorithmField1") == null) {
- responseString.append(
- "<b>Rule Algorithms</b>:<i>" + label + " : Field 1 value is not selected</i><br>");
+ responseString.append(RULE_ALGORITHMS + label + " : Field 1 value is not selected</i><br>");
valid = false;
}
if (((LinkedHashMap<?, ?>) attribute).get("dynamicRuleAlgorithmCombo") == null) {
- responseString.append(
- "<b>Rule Algorithms</b>:<i>" + label + " : Field 2 value is not selected</i><br>");
+ responseString.append(RULE_ALGORITHMS + label + " : Field 2 value is not selected</i><br>");
valid = false;
}
if (((LinkedHashMap<?, ?>) attribute).get("dynamicRuleAlgorithmField2") != null) {
- String value =
- ((LinkedHashMap<?, ?>) attribute).get("dynamicRuleAlgorithmField2").toString();
+ String value = ((LinkedHashMap<?, ?>) attribute).get("dynamicRuleAlgorithmField2")
+ .toString();
if (!PolicyUtils.policySpecialCharValidator(value).contains(SUCCESS)) {
- responseString.append("<b>Rule Algorithms</b>:<i>" + label
- + " : Field 3 value has special characters</i><br>");
+ responseString.append(RULE_ALGORITHMS + label
+ + " : Field 3 value has special characters</i><br>");
valid = false;
}
} else {
- responseString
- .append("<b>Rule Algorithms</b>:<i>" + label + " : Field 3 value is empty</i><br>");
+ responseString.append(RULE_ALGORITHMS + label + " : Field 3 value is empty</i><br>");
valid = false;
}
}
@@ -278,14 +287,15 @@ public class PolicyValidation {
if (CONFIG_POLICY.equalsIgnoreCase(policyData.getPolicyType())) {
if ("Base".equals(policyData.getConfigPolicyType())
- || CLOSEDLOOP_POLICY.equals(policyData.getConfigPolicyType())
- || CLOSEDLOOP_PM.equals(policyData.getConfigPolicyType())
- || ENFORCER_CONFIG_POLICY.equals(policyData.getConfigPolicyType())
- || MICROSERVICES.equals(policyData.getConfigPolicyType())
- || OPTIMIZATION.equals(policyData.getConfigPolicyType())) {
+ || CLOSEDLOOP_POLICY.equals(policyData.getConfigPolicyType())
+ || CLOSEDLOOP_PM.equals(policyData.getConfigPolicyType())
+ || ENFORCER_CONFIG_POLICY.equals(policyData.getConfigPolicyType())
+ || MICROSERVICES.equals(policyData.getConfigPolicyType())
+ || OPTIMIZATION.equals(policyData.getConfigPolicyType())) {
if (!Strings.isNullOrEmpty(policyData.getOnapName())) {
- String onapNameValidate = PolicyUtils.policySpecialCharWithDashValidator(policyData.getOnapName());
+ String onapNameValidate = PolicyUtils
+ .policySpecialCharWithDashValidator(policyData.getOnapName());
if (!onapNameValidate.contains(SUCCESS)) {
responseString.append("<b>OnapName</b>:<i>" + onapNameValidate + HTML_ITALICS_LNBREAK);
valid = false;
@@ -357,26 +367,22 @@ public class PolicyValidation {
if (configType != null) {
if ("JSON".equals(configType)) {
if (!PolicyUtils.isJSONValid(configBodyData)) {
- responseString
- .append("Config Body: JSON Content is not valid" + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "Config Body: JSON Content is not valid" + HTML_ITALICS_LNBREAK);
valid = false;
}
} else if ("XML".equals(configType)) {
if (!PolicyUtils.isXMLValid(configBodyData)) {
- responseString.append(
- "Config Body: XML Content data is not valid" + HTML_ITALICS_LNBREAK);
+ responseString.append("Config Body: XML Content data is not valid"
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
} else if ("PROPERTIES".equals(configType)) {
- if (!PolicyUtils.isPropValid(configBodyData) || "".equals(configBodyData)) {
- responseString
- .append("Config Body: Property data is not valid" + HTML_ITALICS_LNBREAK);
+ if (!PolicyUtils.isPropValid(configBodyData)) {
+ responseString.append(
+ "Config Body: Property data is not valid" + HTML_ITALICS_LNBREAK);
valid = false;
}
- } else if ("OTHER".equals(configType) && ("".equals(configBodyData))) {
- responseString
- .append("Config Body: Config Body Should not be Empty" + HTML_ITALICS_LNBREAK);
- valid = false;
}
}
} else {
@@ -397,14 +403,14 @@ public class PolicyValidation {
valid = false;
}
if (policyData.getSecurityZone() == null || policyData.getSecurityZone().isEmpty()) {
- responseString
- .append("<b>Security Zone</b>:<i> Security Zone is required" + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "<b>Security Zone</b>:<i> Security Zone is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
}
// Validate BRMS_Param Policy Data
if (BRMSPARAM.equalsIgnoreCase(policyData.getConfigPolicyType())
- && Strings.isNullOrEmpty(policyData.getRuleName())) {
+ && Strings.isNullOrEmpty(policyData.getRuleName())) {
responseString.append("<b>BRMS Template</b>:<i>BRMS Template is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
@@ -415,8 +421,8 @@ public class PolicyValidation {
// If there are any error other than Annotations then this is not Valid
if (message.contains("[ERR")) {
- responseString.append(
- "<b>Raw Rule Validate</b>:<i>Raw Rule has error" + message + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Raw Rule Validate</b>:<i>Raw Rule has error" + message
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
} else {
@@ -427,17 +433,17 @@ public class PolicyValidation {
// Validate ClosedLoop_PM Policy Data
if (CLOSEDLOOP_PM.equalsIgnoreCase(policyData.getConfigPolicyType())) {
try {
- if (Strings.isNullOrEmpty(
- policyData.getServiceTypePolicyName().get("serviceTypePolicyName").toString())) {
+ if (Strings.isNullOrEmpty(policyData.getServiceTypePolicyName().get("serviceTypePolicyName")
+ .toString())) {
responseString.append("<b>ServiceType PolicyName</b>:<i>ServiceType PolicyName is required"
- + HTML_ITALICS_LNBREAK);
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
} catch (Exception e) {
LOGGER.error("ERROR in ClosedLoop_PM PolicyName", e);
responseString.append("<b>ServiceType PolicyName</b>:<i>ServiceType PolicyName is required"
- + HTML_ITALICS_LNBREAK);
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
@@ -451,11 +457,9 @@ public class PolicyValidation {
valid = false;
}
}
- if ((pmBody.isGamma() || pmBody.isMcr() || pmBody.isTrinity() || pmBody.isvDNS()
- || pmBody.isvUSP()) != true) {
- responseString
- .append("<b>D2/Virtualized Services</b>: <i>Select at least one D2/Virtualized Services"
- + HTML_ITALICS_LNBREAK);
+ if (!pmBody.isGamma() && !pmBody.isMcr() && !pmBody.isTrinity() && !pmBody.isvDNS()
+ && !pmBody.isvUSP()) {
+ responseString.append(SELECT_AT_LEAST_ONE_D2_VIRTUALIZED_SERVICES + HTML_ITALICS_LNBREAK);
valid = false;
}
if (pmBody.getGeoLink() != null && !pmBody.getGeoLink().isEmpty()) {
@@ -473,16 +477,17 @@ public class PolicyValidation {
String attributeValidate = PolicyUtils.policySpecialCharValidator(value);
if (!attributeValidate.contains(SUCCESS)) {
responseString.append("<b>Attributes</b>:<i>" + key
- + " : value has spaces or invalid characters" + HTML_ITALICS_LNBREAK);
+ + " : value has spaces or invalid characters"
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
}
}
}
} else {
- responseString
- .append("<b>D2/Virtualized Services</b>:<i>Select atleast one D2/Virtualized Services"
- + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "<b>D2/Virtualized Services</b>:<i>Select at least one D2/Virtualized Services"
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
}
@@ -497,38 +502,40 @@ public class PolicyValidation {
String apiCondition = (String) json.get("conditions");
if (Strings.isNullOrEmpty(apiCondition)) {
responseString.append("<b>Conditions</b>: <i>Select At least one Condition"
- + HTML_ITALICS_LNBREAK);
+ + HTML_ITALICS_LNBREAK);
return responseString;
}
} else {
- responseString
- .append("<b>Conditions</b>: <i>There were no conditions provided in configBody json"
- + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Conditions</b>:"
+ + " <i>There were no conditions provided in configBody json"
+ + HTML_ITALICS_LNBREAK);
return responseString;
}
} else {
if (policyData.getTrapDatas().getTrap1() != null) {
if (policyData.getClearTimeOut() == null) {
- responseString.append(
- "<b>Trigger Clear TimeOut</b>: <i>Trigger Clear TimeOut is required when atleast One Trigger Signature is enabled</i><br>");
+ responseString.append("<b>Trigger Clear TimeOut</b>: "
+ + "<i>Trigger Clear TimeOut is required when at "
+ + "least One Trigger Signature is enabled</i><br>");
valid = false;
}
if (policyData.getTrapMaxAge() == null) {
- responseString.append(
- "<b>Trap Max Age</b>: <i>Trap Max Age is required when atleast One Trigger Signature is enabled</i><br>");
+ responseString.append("<b>Trap Max Age</b>: <i>Trap Max Age is required when at "
+ + "least One Trigger Signature is enabled</i><br>");
valid = false;
}
}
if (policyData.getFaultDatas().getTrap1() != null
- && policyData.getVerificationclearTimeOut() == null) {
+ && policyData.getVerificationclearTimeOut() == null) {
responseString.append(
- "<b>Fault Clear TimeOut</b>: <i>Fault Clear TimeOut is required when atleast One Fault Signature is enabled</i><br>");
+ "<b>Fault Clear TimeOut</b>: <i>Fault Clear TimeOut is required when at"
+ + "least One Fault Signature is enabled</i><br>");
valid = false;
}
}
- ClosedLoopFaultBody faultBody =
- mapper.readValue(policyData.getJsonBody(), ClosedLoopFaultBody.class);
+ ClosedLoopFaultBody faultBody = mapper.readValue(policyData.getJsonBody(),
+ ClosedLoopFaultBody.class);
if (faultBody.getEmailAddress() != null && !faultBody.getEmailAddress().isEmpty()) {
String result = emailValidation(faultBody.getEmailAddress(), responseString.toString());
if (!SUCCESS.equals(result)) {
@@ -537,26 +544,24 @@ public class PolicyValidation {
}
}
if (!(faultBody.isGamma() || faultBody.isMcr() || faultBody.isTrinity() || faultBody.isvDNS()
- || faultBody.isvUSP())) {
- responseString
- .append("<b>D2/Virtualized Services</b>: <i>Select at least one D2/Virtualized Services"
- + HTML_ITALICS_LNBREAK);
+ || faultBody.isvUSP())) {
+ responseString.append(SELECT_AT_LEAST_ONE_D2_VIRTUALIZED_SERVICES + HTML_ITALICS_LNBREAK);
valid = false;
}
if (faultBody.getActions() == null || faultBody.getActions().isEmpty()) {
- responseString
- .append("<b>vPRO Actions</b>: <i>vPRO Actions is required" + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "<b>vPRO Actions</b>: <i>vPRO Actions is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
if (faultBody.getClosedLoopPolicyStatus() == null
- || faultBody.getClosedLoopPolicyStatus().isEmpty()) {
- responseString.append(
- "<b>Policy Status</b>: <i>Policy Status is required" + HTML_ITALICS_LNBREAK);
+ || faultBody.getClosedLoopPolicyStatus().isEmpty()) {
+ responseString.append("<b>Policy Status</b>: <i>Policy Status is required"
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
if (faultBody.getConditions() == null) {
- responseString.append(
- "<b>Conditions</b>: <i>Select At least one Condition" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Conditions</b>: <i>Select At least one Condition"
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
if (faultBody.getGeoLink() != null && !faultBody.getGeoLink().isEmpty()) {
@@ -567,28 +572,28 @@ public class PolicyValidation {
}
}
if (faultBody.getAgingWindow() == 0) {
- responseString
- .append("<b>Aging Window</b>: <i>Aging Window is required" + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "<b>Aging Window</b>: <i>Aging Window is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
if (faultBody.getTimeInterval() == 0) {
- responseString.append(
- "<b>Time Interval</b>: <i>Time Interval is required" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Time Interval</b>: <i>Time Interval is required"
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
if (faultBody.getRetrys() == 0) {
responseString.append("<b>Number of Retries</b>: <i>Number of Retries is required"
- + HTML_ITALICS_LNBREAK);
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
if (faultBody.getTimeOutvPRO() == 0) {
- responseString.append(
- "<b>APP-C Timeout</b>: <i>APP-C Timeout is required" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>APP-C Timeout</b>: <i>APP-C Timeout is required"
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
if (faultBody.getTimeOutRuby() == 0) {
- responseString
- .append("<b>TimeOutRuby</b>: <i>TimeOutRuby is required" + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "<b>TimeOutRuby</b>: <i>TimeOutRuby is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
if (faultBody.getVnfType() == null || faultBody.getVnfType().isEmpty()) {
@@ -596,31 +601,31 @@ public class PolicyValidation {
valid = false;
}
} else {
- responseString
- .append("<b>D2/Virtualized Services</b>: <i>Select atleast one D2/Virtualized Services"
- + HTML_ITALICS_LNBREAK);
- responseString
- .append("<b>vPRO Actions</b>: <i>vPRO Actions is required" + HTML_ITALICS_LNBREAK);
- responseString
- .append("<b>Aging Window</b>: <i>Aging Window is required" + HTML_ITALICS_LNBREAK);
- responseString
- .append("<b>Policy Status</b>: <i>Policy Status is required" + HTML_ITALICS_LNBREAK);
- responseString
- .append("<b>Conditions</b>: <i>Select Atleast one Condition" + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "<b>D2/Virtualized Services</b>: <i>Select at least one D2/Virtualized Services"
+ + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "<b>vPRO Actions</b>: <i>vPRO Actions is required" + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "<b>Aging Window</b>: <i>Aging Window is required" + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "<b>Policy Status</b>: <i>Policy Status is required" + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "<b>Conditions</b>: <i>Select Atleast one Condition" + HTML_ITALICS_LNBREAK);
responseString.append("<b>PEP Name</b>: <i>PEP Name is required" + HTML_ITALICS_LNBREAK);
responseString.append("<b>PEP Action</b>: <i>PEP Action is required" + HTML_ITALICS_LNBREAK);
- responseString
- .append("<b>Time Interval</b>: <i>Time Interval is required" + HTML_ITALICS_LNBREAK);
responseString.append(
- "<b>Number of Retries</b>: <i>Number of Retries is required" + HTML_ITALICS_LNBREAK);
- responseString
- .append("<b>APP-C Timeout</b>: <i>APP-C Timeout is required" + HTML_ITALICS_LNBREAK);
+ "<b>Time Interval</b>: <i>Time Interval is required" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Number of Retries</b>: <i>Number of Retries is required"
+ + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "<b>APP-C Timeout</b>: <i>APP-C Timeout is required" + HTML_ITALICS_LNBREAK);
responseString.append("<b>TimeOutRuby</b>: <i>TimeOutRuby is required" + HTML_ITALICS_LNBREAK);
responseString.append("<b>Vnf Type</b>: <i>Vnf Type is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
}
-
+
// Validate MicroService Policy Data
if (MICROSERVICES.equals(policyData.getConfigPolicyType())) {
boolean tmpValid = validateMsModel(policyData, responseString);
@@ -630,7 +635,7 @@ public class PolicyValidation {
}
// Validate Optimization Policy Data
- if (OPTIMIZATION.equals(policyData.getConfigPolicyType())){
+ if (OPTIMIZATION.equals(policyData.getConfigPolicyType())) {
boolean tmpValid = validateOptimization(policyData, responseString);
if (!tmpValid) {
valid = false;
@@ -639,7 +644,7 @@ public class PolicyValidation {
}
if ((DECISION_POLICY.equalsIgnoreCase(policyData.getPolicyType()))
- || (DECISION_POLICY_MS.equalsIgnoreCase(policyData.getPolicyType()))) {
+ || (DECISION_POLICY_MS.equalsIgnoreCase(policyData.getPolicyType()))) {
if (!RAW.equalsIgnoreCase(policyData.getRuleProvider())) {
if (!Strings.isNullOrEmpty(policyData.getOnapName())) {
String onapNameValidate = PolicyUtils.policySpecialCharValidator(policyData.getOnapName());
@@ -653,7 +658,8 @@ public class PolicyValidation {
}
}
if (RAW.equalsIgnoreCase(policyData.getRuleProvider())) {
- Object policy = XACMLPolicyScanner.readPolicy(new ByteArrayInputStream(StringEscapeUtils.unescapeXml(policyData.getRawXacmlPolicy()).getBytes(StandardCharsets.UTF_8)));
+ Object policy = XACMLPolicyScanner.readPolicy(new ByteArrayInputStream(StringEscapeUtils
+ .unescapeXml(policyData.getRawXacmlPolicy()).getBytes(StandardCharsets.UTF_8)));
if (!(policy instanceof PolicySetType || policy instanceof PolicyType)) {
responseString.append("Raw XACML: The XACML Content is not valid" + HTML_ITALICS_LNBREAK);
valid = false;
@@ -690,7 +696,7 @@ public class PolicyValidation {
valid = false;
}
if (!policyData.getRainyday().getTreatmentTableChoices().isEmpty()
- && policyData.getRainyday().getTreatmentTableChoices() != null) {
+ && policyData.getRainyday().getTreatmentTableChoices() != null) {
for (Object treatmentMap : policyData.getRainyday().getTreatmentTableChoices()) {
String errorCode = null;
@@ -706,20 +712,20 @@ public class PolicyValidation {
}
if (Strings.isNullOrEmpty(errorCode) && Strings.isNullOrEmpty(treatment)) {
- responseString.append(
- "Rainy Day <b>Error Code</b> and <b>Desired Treatment</b> cannot be empty<br>");
+ responseString.append("Rainy Day <b>Error Code</b> and "
+ + "<b>Desired Treatment</b> cannot be empty<br>");
valid = false;
break;
}
if (Strings.isNullOrEmpty(errorCode)) {
- responseString.append(
- "Rainy Day <b>Error Code</b> is Required for each Desired Treatment<br>");
+ responseString.append("Rainy Day <b>Error Code</b> is Required "
+ + "for each Desired Treatment<br>");
valid = false;
break;
}
if (Strings.isNullOrEmpty(treatment)) {
- responseString.append(
- "Rainy Day <b>Desired Treatment</b> is Required for each Error Code<br>");
+ responseString.append("Rainy Day <b>Desired Treatment"
+ + "</b> is Required for each Error Code<br>");
valid = false;
break;
}
@@ -733,8 +739,8 @@ public class PolicyValidation {
}
if ("GUARD_YAML".equals(policyData.getRuleProvider())
- || "GUARD_BL_YAML".equals(policyData.getRuleProvider())
- || "GUARD_MIN_MAX".equals(policyData.getRuleProvider())) {
+ || "GUARD_BL_YAML".equals(policyData.getRuleProvider())
+ || "GUARD_MIN_MAX".equals(policyData.getRuleProvider())) {
if (policyData.getYamlparams() == null) {
responseString.append("<b> Guard Params are Required </b>" + HTML_ITALICS_LNBREAK);
valid = false;
@@ -748,13 +754,13 @@ public class PolicyValidation {
valid = false;
}
if (Strings.isNullOrEmpty(policyData.getYamlparams().getGuardActiveStart())) {
- responseString.append(
- "Guard Params <b>Guard Active Start</b> is Required " + HTML_ITALICS_LNBREAK);
+ responseString.append("Guard Params <b>Guard Active Start</b> is Required "
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
if (Strings.isNullOrEmpty(policyData.getYamlparams().getGuardActiveEnd())) {
- responseString
- .append("Guard Params <b>Guard Active End</b> is Required " + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "Guard Params <b>Guard Active End</b> is Required " + HTML_ITALICS_LNBREAK);
valid = false;
}
if ("GUARD_YAML".equals(policyData.getRuleProvider())) {
@@ -762,22 +768,22 @@ public class PolicyValidation {
responseString.append(" Guard Params <b>Limit</b> is Required " + HTML_ITALICS_LNBREAK);
valid = false;
} else if (!PolicyUtils.isInteger(policyData.getYamlparams().getLimit())) {
- responseString
- .append(" Guard Params <b>Limit</b> Should be Integer " + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ " Guard Params <b>Limit</b> Should be Integer " + HTML_ITALICS_LNBREAK);
valid = false;
}
if (Strings.isNullOrEmpty(policyData.getYamlparams().getTimeWindow())) {
- responseString
- .append("Guard Params <b>Time Window</b> is Required" + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "Guard Params <b>Time Window</b> is Required" + HTML_ITALICS_LNBREAK);
valid = false;
} else if (!PolicyUtils.isInteger(policyData.getYamlparams().getTimeWindow())) {
- responseString.append(
- " Guard Params <b>Time Window</b> Should be Integer " + HTML_ITALICS_LNBREAK);
+ responseString.append(" Guard Params <b>Time Window</b> Should be Integer "
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
if (Strings.isNullOrEmpty(policyData.getYamlparams().getTimeUnits())) {
- responseString
- .append("Guard Params <b>Time Units</b> is Required" + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "Guard Params <b>Time Units</b> is Required" + HTML_ITALICS_LNBREAK);
valid = false;
}
} else if ("GUARD_MIN_MAX".equals(policyData.getRuleProvider())) {
@@ -785,32 +791,32 @@ public class PolicyValidation {
responseString.append(" Guard Params <b>Min</b> is Required " + HTML_ITALICS_LNBREAK);
valid = false;
} else if (!PolicyUtils.isInteger(policyData.getYamlparams().getMin())) {
- responseString
- .append(" Guard Params <b>Min</b> Should be Integer " + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ " Guard Params <b>Min</b> Should be Integer " + HTML_ITALICS_LNBREAK);
valid = false;
}
if (Strings.isNullOrEmpty(policyData.getYamlparams().getMax())) {
responseString.append(" Guard Params <b>Max</b> is Required " + HTML_ITALICS_LNBREAK);
valid = false;
} else if (!PolicyUtils.isInteger(policyData.getYamlparams().getMax())) {
- responseString
- .append(" Guard Params <b>Max</b> Should be Integer " + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ " Guard Params <b>Max</b> Should be Integer " + HTML_ITALICS_LNBREAK);
valid = false;
}
} else if ("GUARD_BL_YAML".equals(policyData.getRuleProvider())
- && "Use Manual Entry".equals(policyData.getBlackListEntryType())) {
+ && "Use Manual Entry".equals(policyData.getBlackListEntryType())) {
if (policyData.getYamlparams().getBlackList() == null
- || policyData.getYamlparams().getBlackList().isEmpty()) {
- responseString
- .append(" Guard Params <b>BlackList</b> is Required " + HTML_ITALICS_LNBREAK);
+ || policyData.getYamlparams().getBlackList().isEmpty()) {
+ responseString.append(
+ " Guard Params <b>BlackList</b> is Required " + HTML_ITALICS_LNBREAK);
valid = false;
} else {
for (String blackList : policyData.getYamlparams().getBlackList()) {
- if (blackList == null
- || !(SUCCESS.equals(PolicyUtils.policySpecialCharValidator(blackList)))) {
+ if (blackList == null || !(SUCCESS
+ .equals(PolicyUtils.policySpecialCharValidator(blackList)))) {
responseString.append(" Guard Params <b>BlackList</b> Should be valid String"
- + HTML_ITALICS_LNBREAK);
+ + HTML_ITALICS_LNBREAK);
valid = false;
break;
}
@@ -829,21 +835,21 @@ public class PolicyValidation {
valid = false;
}
} else {
- responseString.append(
- "<b>ActionPerformer</b>:<i> ActionPerformer Should not be empty" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>ActionPerformer</b>:<i> ActionPerformer Should not be empty"
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
if (!Strings.isNullOrEmpty(policyData.getActionAttributeValue())) {
- String actionAttribute =
- PolicyUtils.policySpecialCharValidator(policyData.getActionAttributeValue());
+ String actionAttribute = PolicyUtils
+ .policySpecialCharValidator(policyData.getActionAttributeValue());
if (!actionAttribute.contains(SUCCESS)) {
responseString.append("<b>ActionAttribute</b>:<i>" + actionAttribute + HTML_ITALICS_LNBREAK);
valid = false;
}
} else {
- responseString.append(
- "<b>ActionAttribute</b>:<i> ActionAttribute Should not be empty" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>ActionAttribute</b>:<i> ActionAttribute Should not be empty"
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
}
@@ -853,7 +859,7 @@ public class PolicyValidation {
if (valid) {
if (commonClassDao != null) {
List<Object> spData = commonClassDao.getDataById(SafePolicyWarning.class, "riskType",
- policyData.getRiskType());
+ policyData.getRiskType());
if (!spData.isEmpty()) {
SafePolicyWarning safePolicyWarningData = (SafePolicyWarning) spData.get(0);
value = "<b>Message</b>:<i>" + safePolicyWarningData.getMessage() + "</i>";
@@ -874,7 +880,7 @@ public class PolicyValidation {
}
}
- protected String emailValidation(String email, String response) {
+ private String emailValidation(String email, String response) {
String res = response;
if (email != null) {
String validateEmail = PolicyUtils.validateEmailAddress(email.replace("\"", ""));
@@ -890,14 +896,14 @@ public class PolicyValidation {
private MicroServiceModels getAttributeObject(String name, String version) {
MicroServiceModels workingModel = null;
try {
- List<Object> microServiceModelsData =
- commonClassDao.getDataById(MicroServiceModels.class, "modelName:version", name + ":" + version);
+ List<Object> microServiceModelsData = commonClassDao.getDataById(MicroServiceModels.class,
+ "modelName:version", name + ":" + version);
if (microServiceModelsData != null) {
workingModel = (MicroServiceModels) microServiceModelsData.get(0);
}
} catch (Exception e) {
String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Template. The template name, " + name
- + " was not found in the dictionary: ";
+ + " was not found in the dictionary: ";
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + message + e);
return null;
}
@@ -905,16 +911,17 @@ public class PolicyValidation {
return workingModel;
}
- private OptimizationModels getOptimizationModelData(String name, String version) {
+ private OptimizationModels getOptimizationModelData(String name, String version) {
OptimizationModels workingModel = null;
- try{
- List<Object> optimizationModelsData = commonClassDao.getDataById(OptimizationModels.class, "modelName:version", name+":"+version);
- if(optimizationModelsData != null){
+ try {
+ List<Object> optimizationModelsData = commonClassDao.getDataById(OptimizationModels.class,
+ "modelName:version", name + ":" + version);
+ if (optimizationModelsData != null) {
workingModel = (OptimizationModels) optimizationModelsData.get(0);
}
- }catch(Exception e){
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Template. The template name, "
- + name + " was not found in the dictionary: ";
+ } catch (Exception e) {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Template. The template name, " + name
+ + " was not found in the dictionary: ";
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + message + e);
return null;
}
@@ -933,8 +940,9 @@ public class PolicyValidation {
pullJsonKeyPairs(value); // RECURSIVE CALL
} else {
if (value.isArray()) {
- String newValue = StringUtils.replaceEach(value.toString(), new String[] {"[", "]", "\""},
- new String[] {"", "", ""});
+ String newValue = StringUtils.replaceEach(value.toString(), new String[]
+ { "[", "]", "\"" }, new String[]
+ { "", "", "" });
mapAttribute.put(key, newValue);
} else {
mapAttribute.put(key, value.toString().trim());
@@ -958,11 +966,11 @@ public class PolicyValidation {
try {
String valueStr = value.toString();
String stringValue = valueStr.substring(valueStr.indexOf('[') + 1, valueStr.lastIndexOf(']'));
-
+
if (stringValue.isEmpty()) {
stringValue = "{\"test\":\"test\"}";
}
-
+
ObjectMapper mapper = new ObjectMapper();
JsonNode newValue = mapper.readTree(stringValue);
jsonRequestMap.put(key.trim(), value.toString().trim());
@@ -981,10 +989,9 @@ public class PolicyValidation {
try (JsonReader jsonReader = Json.createReader(new StringReader(value))) {
return jsonReader.readObject();
} catch (JsonException | IllegalStateException e) {
- LOGGER.info(
- XACMLErrorConstants.ERROR_DATA_ISSUE
- + "Improper JSON format... may or may not cause issues in validating the policy: " + value,
- e);
+ LOGGER.info(XACMLErrorConstants.ERROR_DATA_ISSUE
+ + "Improper JSON format... may or may not cause issues in validating the policy: " + value,
+ e);
return null;
}
}
@@ -1044,13 +1051,13 @@ public class PolicyValidation {
if (obj instanceof String && ((String) obj).contains(REQUIRED_ATTRIBUTE)) {
LOGGER.debug("key : " + key);
LOGGER.debug("obj : " + obj);
- allReqTrueKeys.add(key); //For MicroService policies
- allOptReqTrueKeys.add(key); //For Optimization policies
-
+ allReqTrueKeys.add(key); // For MicroService policies
+ allOptReqTrueKeys.add(key); // For Optimization policies
+
// get the type from value and add that one also
String type = StringUtils.substringBefore((String) obj, ":");
- if (!StringUtils.isBlank(type) && !StringUtils.containsAny(type.toLowerCase(), MSModelUtils.STRING,
- MSModelUtils.INTEGER, MSModelUtils.LIST, MSModelUtils.MAP, "java", "boolean")) {
+ if (!StringUtils.isBlank(type) && !StringUtils.containsAny(type.toLowerCase(), STRING, INTEGER, LIST,
+ MAP, JAVA, BOOLEAN)) {
allReqTrueKeys.add(type);
}
}
@@ -1066,7 +1073,7 @@ public class PolicyValidation {
}
private boolean validateMsModel(PolicyRestAdapter policyData, StringBuilder responseString)
- throws JsonProcessingException {
+ throws JsonProcessingException {
boolean valid = true;
if (!Strings.isNullOrEmpty(policyData.getServiceType())) {
@@ -1089,8 +1096,8 @@ public class PolicyValidation {
if (returnModel != null) {
String annotation = returnModel.getAnnotation();
- String refAttributes = returnModel.getRef_attributes();
- String subAttributes = returnModel.getSub_attributes();
+ String refAttributes = returnModel.getRefAttributes();
+ String subAttributes = returnModel.getSubAttributes();
String modelAttributes = returnModel.getAttributes();
if (!Strings.isNullOrEmpty(annotation)) {
@@ -1102,7 +1109,7 @@ public class PolicyValidation {
int startNum = Integer.parseInt(tempString[0]);
int endNum = Integer.parseInt(tempString[1]);
String returnString = "InvalidreturnModel Range:" + raMap.getKey() + " must be between "
- + startNum + " - " + endNum + ",";
+ + startNum + " - " + endNum + ",";
if (value != null) {
if (PolicyUtils.isInteger(value.replace("\"", ""))) {
@@ -1117,8 +1124,8 @@ public class PolicyValidation {
}
} else {
responseString.append("<b>" + raMap.getKey() + "</b>:<i>" + raMap.getKey()
- + " is required for the MicroService model " + service
- + HTML_ITALICS_LNBREAK);
+ + " is required for the MicroService model " + service
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
@@ -1129,26 +1136,26 @@ public class PolicyValidation {
// model
if (Strings.isNullOrEmpty(policyData.getLocation())) {
responseString.append("<b>Micro Service Model</b>:<i> location is required for this model"
- + HTML_ITALICS_LNBREAK);
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
if (Strings.isNullOrEmpty(policyData.getConfigName())) {
responseString.append("<b>Micro Service Model</b>:<i> configName is required for this model"
- + HTML_ITALICS_LNBREAK);
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
if (Strings.isNullOrEmpty(policyData.getUuid())) {
responseString.append("<b>Micro Service Model</b>:<i> uuid is required for this model"
- + HTML_ITALICS_LNBREAK);
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
-
+
if (Strings.isNullOrEmpty(policyData.getPolicyScope())) {
- responseString
- .append("<b>Micro Service Model</b>:<i> policyScope is required for this model"
- + HTML_ITALICS_LNBREAK);
+ responseString.append(
+ "<b>Micro Service Model</b>:<i> policyScope is required for this model"
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
}
@@ -1157,11 +1164,12 @@ public class PolicyValidation {
// GUI request are already validated from the SDK-APP
if ("API".equals(policyData.getApiflag())) {
// first , get the complete set of required fields
- populateReqFieldSet(new String[] {refAttributes, modelAttributes}, subAttributes);
+ populateReqFieldSet(new String[]
+ { refAttributes, modelAttributes }, subAttributes);
// ignore req fields in which parent is not reqd
- populateRequiredFields(new String[] {refAttributes, modelAttributes}, subAttributes,
- modelAttributes);
+ populateRequiredFields(new String[]
+ { refAttributes, modelAttributes }, subAttributes, modelAttributes);
if (modelRequiredFieldsList != null && !modelRequiredFieldsList.isEmpty()) {
// create jsonRequestMap with all json keys and values from request
@@ -1175,12 +1183,12 @@ public class PolicyValidation {
String value = jsonRequestMap.get(requiredField);
if (StringUtils.isBlank(value) || "\"\"".equals(value)) {
responseString.append("<b>Micro Service Model</b>:<i> " + requiredField
- + ISREQUIRED + HTML_ITALICS_LNBREAK);
+ + ISREQUIRED + HTML_ITALICS_LNBREAK);
valid = false;
}
} else {
- responseString.append("<b>Micro Service Model</b>:<i> " + requiredField
- + ISREQUIRED + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Micro Service Model</b>:<i> " + requiredField + ISREQUIRED
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
}
@@ -1188,12 +1196,13 @@ public class PolicyValidation {
}
} else {
responseString.append("<b>Micro Service Model</b>:<i> Invalid Model. The model name, " + service
- + " of version, " + version + " was not found in the dictionary" + HTML_ITALICS_LNBREAK);
+ + " of version, " + version + " was not found in the dictionary"
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
} else {
- responseString.append(
- "<b>Micro Service Version</b>:<i> Micro Service Version is required" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Micro Service Version</b>:<i> Micro Service Version is required"
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
} else {
@@ -1202,28 +1211,26 @@ public class PolicyValidation {
}
if (Strings.isNullOrEmpty(policyData.getPriority())
- && !DECISION_MS_MODEL.equals(policyData.getRuleProvider())) {
+ && !DECISION_MS_MODEL.equals(policyData.getRuleProvider())) {
responseString.append("<b>Priority</b>:<i> Priority is required" + HTML_ITALICS_LNBREAK);
}
-
return valid;
}
-
+
private boolean validateOptimization(PolicyRestAdapter policyData, StringBuilder responseString) {
boolean valid = true;
-
+
// Checks for required policy data in request
if (Strings.isNullOrEmpty(policyData.getServiceType())) {
- responseString.append(
- "<b>Optimization Service</b>:<i> Optimization policy data is missing or invalid Json."
+ responseString.append("<b>Optimization Service</b>:<i> Optimization policy data is missing or invalid Json."
+ HTML_ITALICS_LNBREAK);
return false;
}
-
+
modelRequiredFieldsList.clear();
pullJsonKeyPairs((JsonNode) policyData.getPolicyJSON());
-
+
// parse the service and version from the policy data
String service;
String version;
@@ -1234,22 +1241,20 @@ public class PolicyValidation {
service = policyData.getServiceType();
version = policyData.getVersion();
}
-
+
// Checks for required version in policy data
if (Strings.isNullOrEmpty(version)) {
- responseString.append(
- "<b>Optimization Service Version</b>:<i> Optimization Service Version is required"
+ responseString.append("<b>Optimization Service Version</b>:<i> Optimization Service Version is required"
+ HTML_ITALICS_LNBREAK);
return false;
}
-
+
OptimizationModels returnModel = getOptimizationModelData(service, version);
-
+
// Checks if valid model exists in the database
if (returnModel == null) {
- responseString.append("<b>Optimization Service Model</b>:<i> Invalid Model. The model name, "
- + service + " of version, " + version
- + " was not found in the dictionary" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Optimization Service Model</b>:<i> Invalid Model. The model name, " + service
+ + " of version, " + version + " was not found in the dictionary" + HTML_ITALICS_LNBREAK);
return false;
}
@@ -1259,16 +1264,15 @@ public class PolicyValidation {
String modelAttributes = returnModel.getAttributes();
if (!Strings.isNullOrEmpty(annotation)) {
- Map<String, String> rangeMap = Splitter.on(",").withKeyValueSeparator("=")
- .split(annotation);
- for (Entry<String, String> rMap : rangeMap.entrySet()) {
- if (rMap.getValue().contains("range::")) {
- String value = mapAttribute.get(rMap.getKey().trim());
- String[] tempString = rMap.getValue().split("::")[1].split("-");
+ Map<String, String> rangeMap = Splitter.on(",").withKeyValueSeparator("=").split(annotation);
+ for (Entry<String, String> rangeMapEntry : rangeMap.entrySet()) {
+ if (rangeMapEntry.getValue().contains("range::")) {
+ String value = mapAttribute.get(rangeMapEntry.getKey().trim());
+ String[] tempString = rangeMapEntry.getValue().split("::")[1].split("-");
int startNum = Integer.parseInt(tempString[0]);
int endNum = Integer.parseInt(tempString[1]);
- String returnString = "InvalidreturnModel Range:" + rMap.getKey()
- + " must be between " + startNum + " - " + endNum + ",";
+ String returnString = "InvalidreturnModel Range:" + rangeMapEntry.getKey() + " must be between "
+ + startNum + " - " + endNum + ",";
if (value != null) {
if (PolicyUtils.isInteger(value.replace("\"", ""))) {
@@ -1282,9 +1286,8 @@ public class PolicyValidation {
valid = false;
}
} else {
- responseString.append("<b>" + rMap.getKey() + "</b>:<i>" + rMap.getKey()
- + " is required for the Optimization model " + service
- + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>" + rangeMapEntry.getKey() + "</b>:<i>" + rangeMapEntry.getKey()
+ + " is required for the Optimization model " + service + HTML_ITALICS_LNBREAK);
valid = false;
}
@@ -1296,12 +1299,13 @@ public class PolicyValidation {
// GUI request are already validated from the SDK-APP
if ("API".equals(policyData.getApiflag())) {
// first , get the complete set of required fields
- populateReqFieldSet(new String[] {refAttributes, modelAttributes}, subAttributes);
+ populateReqFieldSet(new String[]
+ { refAttributes, modelAttributes }, subAttributes);
modelRequiredFieldsList.addAll(allOptReqTrueKeys);
-
+
if (modelRequiredFieldsList != null && !modelRequiredFieldsList.isEmpty()) {
-
+
// create jsonRequestMap with all json keys and values from request
JsonNode rootNode = (JsonNode) policyData.getPolicyJSON();
jsonRequestMap.clear();
@@ -1312,13 +1316,13 @@ public class PolicyValidation {
if (jsonRequestMap.containsKey(requiredField)) {
String value = jsonRequestMap.get(requiredField);
if (StringUtils.isBlank(value) || "\"\"".equals(value)) {
- responseString.append("<b>Optimization Service Model</b>:<i> "
- + requiredField + ISREQUIRED + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Optimization Service Model</b>:<i> " + requiredField + ISREQUIRED
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
} else {
- responseString.append("<b>Optimization Service Model</b>:<i> "
- + requiredField + ISREQUIRED + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Optimization Service Model</b>:<i> " + requiredField + ISREQUIRED
+ + HTML_ITALICS_LNBREAK);
valid = false;
}
}
@@ -1334,7 +1338,7 @@ public class PolicyValidation {
}
private void populateRequiredFields(String[] attrArr, String subAttributes, String modelAttributes)
- throws JsonProcessingException {
+ throws JsonProcessingException {
// get list of required fields from the ref_Attributes of the Model
for (String attributes : attrArr) {
if (!StringUtils.isBlank(attributes)) {
@@ -1367,7 +1371,6 @@ public class PolicyValidation {
// Get all keys with "required-true" defined in their value from subAttribute
getAllKeys(jsonSub);
-
// parse refAttrbutes
for (String attr : attrArr) {
if (attr != null) {
@@ -1383,5 +1386,4 @@ public class PolicyValidation {
}
}
-
-} \ No newline at end of file
+}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java
index 779c5227a..ad60a7512 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java
@@ -3,20 +3,28 @@
* ONAP Policy Engine
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* 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.rest.util;
+ */
+
+package org.onap.policy.rest.util;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Strings;
import java.io.IOException;
import java.io.StringReader;
@@ -34,6 +42,7 @@ import javax.json.JsonReader;
import javax.servlet.http.HttpServletRequest;
import org.onap.policy.api.AttributeType;
+import org.onap.policy.api.PolicyClass;
import org.onap.policy.api.PolicyParameters;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
@@ -43,31 +52,32 @@ import org.onap.policy.rest.adapter.RainyDayParams;
import org.onap.policy.rest.adapter.YAMLParams;
import org.onap.policy.xacml.api.XACMLErrorConstants;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.base.Strings;
-
public class PolicyValidationRequestWrapper {
-
- private static final Logger LOGGER = FlexLogger.getLogger(PolicyValidationRequestWrapper.class);
- public static final String CONFIG_NAME="configName";
- public static final String INVALIDJSON = " improper JSON format: ";
- public static final String ONAPNAME = "onapname";
- public static final String CONTENT = "content";
- public static final String GUARD = "guard";
- public static final String LOCATION = "location";
- public static final String POLICYSCOPE = "policyScope";
- public static final String PRIORITY = "priority";
- public static final String RISKLEVEL = "riskLevel";
- public static final String RISKTYPE = "riskType";
- public static final String SERVICE = "service";
- public static final String VERSION = "version";
-
- public static final String SERVICETYPE_POLICY_NAME = "serviceTypePolicyName";
-
+ private static final Logger LOGGER = FlexLogger.getLogger(PolicyValidationRequestWrapper.class);
+
+ private static final String CONFIG_NAME = "configName";
+ private static final String CONTENT = "content";
+ private static final String GUARD = "guard";
+ private static final String INVALIDJSON = " improper JSON format: ";
+ private static final String LOCATION = "location";
+ private static final String ONAPNAME = "onapname";
+ private static final String POLICYSCOPE = "policyScope";
+ private static final String PRIORITY = "priority";
+ private static final String RISKLEVEL = "riskLevel";
+ private static final String RISKTYPE = "riskType";
+ private static final String SECURITY_ZONE_ID = "securityZoneId";
+ private static final String SERVICE = "service";
+ private static final String SERVICETYPE_POLICY_NAME = "serviceTypePolicyName";
+ private static final String UUID = "uuid";
+ private static final String VERSION = "version";
+
+ /**
+ * Populate request parameters.
+ *
+ * @param request the request
+ * @return the policy rest adapter
+ */
public PolicyRestAdapter populateRequestParameters(HttpServletRequest request) {
-
PolicyRestAdapter policyData = null;
ClosedLoopFaultTrapDatas trapDatas = null;
ClosedLoopFaultTrapDatas faultDatas = null;
@@ -76,402 +86,389 @@ public class PolicyValidationRequestWrapper {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
policyData = mapper.readValue(root.get("policyData").toString(), PolicyRestAdapter.class);
- if(root.get("trapData") != null){
+ if (root.get("trapData") != null) {
trapDatas = mapper.readValue(root.get("trapData").toString(), ClosedLoopFaultTrapDatas.class);
policyData.setTrapDatas(trapDatas);
}
- if(root.get("faultData") != null){
+ if (root.get("faultData") != null) {
faultDatas = mapper.readValue(root.get("faultData").toString(), ClosedLoopFaultTrapDatas.class);
policyData.setFaultDatas(faultDatas);
}
- JsonObject json;
- json = stringToJsonObject(root.toString());
-
- if(json != null){
- if(json.containsKey("policyJSON")){
- policyData.setPolicyJSON(root.get("policyJSON"));
- }else{
- String jsonBodyData = json.getJsonObject("policyData").get("jsonBodyData").toString();
- policyData.setJsonBody(jsonBodyData);
- }
+ JsonObject json = stringToJsonObject(root.toString());
+ if (json.containsKey("policyJSON")) {
+ policyData.setPolicyJSON(root.get("policyJSON"));
+ } else {
+ String jsonBodyData = json.getJsonObject("policyData").get("jsonBodyData").toString();
+ policyData.setJsonBody(jsonBodyData);
}
-
} catch (Exception e) {
- LOGGER.error("Exception Occured while populating request parameters: " +e);
+ LOGGER.error("Exception Occured while populating request parameters: " + e);
}
return policyData;
}
+ /**
+ * Populate request parameters.
+ *
+ * @param parameters the parameters
+ * @return the policy rest adapter
+ */
public PolicyRestAdapter populateRequestParameters(PolicyParameters parameters) {
-
PolicyRestAdapter policyData = new PolicyRestAdapter();
-
+
/*
* set policy adapter values for Building JSON object containing policy data
*/
- //Common Policy Fields
+ // Common Policy Fields
policyData.setPolicyName(parameters.getPolicyName());
policyData.setOnapName(parameters.getOnapName());
- policyData.setPriority(parameters.getPriority()); //Micro Service
- policyData.setConfigName(parameters.getConfigName()); //Base and Firewall
- policyData.setRiskType(parameters.getRiskType()); //Safe parameters Attributes
- policyData.setRiskLevel(parameters.getRiskLevel());//Safe parameters Attributes
- policyData.setGuard(String.valueOf(parameters.getGuard()));//Safe parameters Attributes
- policyData.setTtlDate(convertDate(parameters.getTtlDate()));//Safe parameters Attributes
+ policyData.setPriority(parameters.getPriority()); // Micro Service
+ policyData.setConfigName(parameters.getConfigName()); // Base and Firewall
+ policyData.setRiskType(parameters.getRiskType()); // Safe parameters Attributes
+ policyData.setRiskLevel(parameters.getRiskLevel());// Safe parameters Attributes
+ policyData.setGuard(String.valueOf(parameters.getGuard()));// Safe parameters Attributes
+ policyData.setTtlDate(convertDate(parameters.getTtlDate()));// Safe parameters Attributes
policyData.setApiflag("API");
- //Some policies require jsonObject conversion from String for configBody (i.e. MicroService and Firewall)
+ // Some policies require jsonObject conversion from String for configBody (i.e. MicroService and Firewall)
JsonObject json = null;
- try{
- if(parameters.getConfigBody()!= null){
+ try {
+ if (parameters.getConfigBody() != null) {
json = stringToJsonObject(parameters.getConfigBody());
}
- } catch(JsonException| IllegalStateException e){
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ INVALIDJSON + parameters.getConfigBody();
+ } catch (JsonException | IllegalStateException e) {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE + INVALIDJSON + parameters.getConfigBody();
LOGGER.error(message, e);
return null;
}
-
- if(parameters.getPolicyClass()!=null && !"Config".equals(parameters.getPolicyClass().toString())){
- policyData.setPolicyType(parameters.getPolicyClass().toString());
+ if (parameters.getPolicyClass() == null) {
+ parameters.setPolicyClass(PolicyClass.Config);
+ }
+
+ policyData.setPolicyType(parameters.getPolicyClass().toString());
+
+ switch (parameters.getPolicyClass()) {
+ case Config:
+ return populateConfigParameters(parameters, policyData, json);
+
+ case Decision:
+ return populateDecisionParameters(parameters, policyData, getMatchingAttributeValues(parameters));
+
+ case Action:
+ return populateActionParameters(parameters, policyData, getMatchingAttributeValues(parameters));
+
+ default:
+ return null;
+ }
+ }
+
+ private PolicyRestAdapter populateConfigParameters(PolicyParameters parameters, PolicyRestAdapter policyData,
+ JsonObject json) {
+ policyData.setConfigPolicyType(parameters.getPolicyConfigType().toString());
+
+ // Config Specific
+ policyData.setConfigBodyData(parameters.getConfigBody()); // Base
+ policyData.setConfigType((parameters.getConfigBodyType() != null)
+ ? parameters.getConfigBodyType().toString().toUpperCase()
+ : null); // Base
+
+ switch (parameters.getPolicyConfigType()) {
+ case Firewall:
+ return populateConfigFirewallParameters(policyData, json);
+ case MicroService:
+ return populateConfigMicroserviceParameters(parameters, policyData, json);
+ case Optimization:
+ return populateConfigOptimizationParameters(parameters, policyData, json);
+ case ClosedLoop_Fault:
+ return populateConfigClosedLoopFaultParameters(policyData, json);
+ case ClosedLoop_PM:
+ return populateConfigClosedLoopPmParameters(policyData, json);
+ case BRMS_PARAM:
+ return populateConfigBrmsParameters(parameters, policyData);
+
+ // case BRMS_RAW:, case Base:, and case Extended: handled as default cases
+ default:
+ return policyData;
+ }
+ }
+
+ private PolicyRestAdapter populateConfigFirewallParameters(PolicyRestAdapter policyData, JsonObject json) {
+ policyData.setConfigPolicyType("Firewall Config");
+
+ // get values and attributes from the JsonObject
+ if (json != null) {
+ policyData.setSecurityZone(getNewOrExistingKeyValue(json, SECURITY_ZONE_ID, policyData.getSecurityZone()));
+ policyData.setConfigName(getNewOrExistingKeyValue(json, CONFIG_NAME, policyData.getConfigName()));
+ }
+ return policyData;
+ }
+
+ private PolicyRestAdapter populateConfigMicroserviceParameters(PolicyParameters parameters,
+ PolicyRestAdapter policyData, JsonObject json) {
+ policyData.setConfigPolicyType("Micro Service");
+
+ // Get values and attributes from the JsonObject
+ if (json != null) {
+ return getJsonObjectValuesAndAttributes(parameters, policyData, json);
+ } else {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE + INVALIDJSON + parameters.getConfigBody();
+ LOGGER.error(message);
+ return null;
+ }
+ }
+
+ private PolicyRestAdapter populateConfigOptimizationParameters(PolicyParameters parameters,
+ PolicyRestAdapter policyData, JsonObject json) {
+ policyData.setConfigPolicyType("Optimization");
+
+ // get values and attributes from the JsonObject
+ if (json != null) {
+ return getJsonObjectValuesAndAttributes(parameters, policyData, json);
+ } else {
+ return policyData;
+ }
+ }
+
+ private PolicyRestAdapter populateConfigClosedLoopFaultParameters(PolicyRestAdapter policyData, JsonObject json) {
+ policyData.setConfigPolicyType("ClosedLoop_Fault");
- //Get Matching attribute values
- Map<AttributeType, Map<String, String>> attributes = parameters.getAttributes();
- Map<String, String> matching = null;
- if(attributes != null){
- matching = attributes.get(AttributeType.MATCHING);
+ if (json != null) {
+ policyData.setJsonBody(json.toString());
+ policyData.setOnapName(getNewOrExistingKeyValue(json, ONAPNAME, policyData.getOnapName()));
+ }
+ return policyData;
+ }
+
+ private PolicyRestAdapter populateConfigClosedLoopPmParameters(PolicyRestAdapter policyData, JsonObject json) {
+ policyData.setConfigPolicyType("ClosedLoop_PM");
+
+ if (json != null) {
+ policyData.setJsonBody(json.toString());
+ policyData.setOnapName(getNewOrExistingKeyValue(json, ONAPNAME, policyData.getOnapName()));
+ if (json.get(SERVICETYPE_POLICY_NAME) != null) {
+ String serviceType = json.get(SERVICETYPE_POLICY_NAME).toString().replace("\"", "");
+ LinkedHashMap<String, String> serviceTypePolicyName = new LinkedHashMap<>();
+ serviceTypePolicyName.put(SERVICETYPE_POLICY_NAME, serviceType);
+ policyData.setServiceTypePolicyName(serviceTypePolicyName);
}
+ }
+ return policyData;
+ }
- if("Decision".equals(parameters.getPolicyClass().toString())){
+ private PolicyRestAdapter populateConfigBrmsParameters(PolicyParameters parameters, PolicyRestAdapter policyData) {
+ Map<AttributeType, Map<String, String>> drlRuleAndUiParams = parameters.getAttributes();
+ Map<String, String> rule = drlRuleAndUiParams.get(AttributeType.RULE);
+ policyData.setRuleName(rule.get("templateName"));
- String ruleProvider = parameters.getRuleProvider().toString();
- policyData.setRuleProvider(ruleProvider);
+ return policyData;
+ }
+
+ private PolicyRestAdapter populateDecisionParameters(PolicyParameters parameters, PolicyRestAdapter policyData,
+ Map<String, String> matching) {
+ policyData.setRuleProvider(parameters.getRuleProvider().toString());
+
+ switch (parameters.getRuleProvider()) {
+ case RAINY_DAY:
+ return populateDecisionRainyDayParameters(parameters, policyData, matching);
- if("Rainy_Day".equals(ruleProvider)){
+ case GUARD_BL_YAML:
+ case GUARD_MIN_MAX:
+ case GUARD_YAML:
+ return populateDecisionGuardParameters(policyData, matching);
- // Set Matching attributes in RainyDayParams in adapter
- RainyDayParams rainyday = new RainyDayParams();
+ case AAF:
+ case CUSTOM:
+ case RAW:
+ default:
+ return policyData;
+ }
+ }
- if(matching != null) {
- rainyday.setServiceType(matching.get("ServiceType"));
- rainyday.setVnfType(matching.get("VNFType"));
- rainyday.setBbid(matching.get("BB_ID"));
- rainyday.setWorkstep(matching.get("WorkStep"));
- }
-
- Map<String, String> treatments = parameters.getTreatments();
- ArrayList<Object> treatmentsTableChoices = new ArrayList<>();
+ private PolicyRestAdapter populateDecisionRainyDayParameters(PolicyParameters parameters,
+ PolicyRestAdapter policyData, Map<String, String> matching) {
+ // Set Matching attributes in RainyDayParams in adapter
+ RainyDayParams rainyday = new RainyDayParams();
- for (String keyField : treatments.keySet()) {
- LinkedHashMap<String, String> treatmentMap = new LinkedHashMap<>();
- String errorcode = keyField;
- String treatment = treatments.get(errorcode);
- treatmentMap.put("errorcode", errorcode);
- treatmentMap.put("treatment", treatment);
- treatmentsTableChoices.add(treatmentMap);
- }
- rainyday.setTreatmentTableChoices(treatmentsTableChoices);
- policyData.setRainyday(rainyday);
+ if (matching != null) {
+ rainyday.setServiceType(matching.get("ServiceType"));
+ rainyday.setVnfType(matching.get("VNFType"));
+ rainyday.setBbid(matching.get("BB_ID"));
+ rainyday.setWorkstep(matching.get("WorkStep"));
+ }
- } else if ("GUARD_YAML".equals(ruleProvider) || "GUARD_BL_YAML".equals(ruleProvider)
- || "GUARD_MIN_MAX".equals(ruleProvider)) {
+ Map<String, String> treatments = parameters.getTreatments();
+ ArrayList<Object> treatmentsTableChoices = new ArrayList<>();
- // Set Matching attributes in YAMLParams in adapter
- YAMLParams yamlparams = new YAMLParams();
+ for (String keyField : treatments.keySet()) {
+ LinkedHashMap<String, String> treatmentMap = new LinkedHashMap<>();
+ String errorcode = keyField;
+ String treatment = treatments.get(errorcode);
+ treatmentMap.put("errorcode", errorcode);
+ treatmentMap.put("treatment", treatment);
+ treatmentsTableChoices.add(treatmentMap);
+ }
+ rainyday.setTreatmentTableChoices(treatmentsTableChoices);
+ policyData.setRainyday(rainyday);
- if (matching != null) {
- yamlparams.setActor(matching.get("actor"));
- yamlparams.setRecipe(matching.get("recipe"));
- yamlparams.setGuardActiveStart(matching.get("guardActiveStart"));
- yamlparams.setGuardActiveEnd(matching.get("guardActiveEnd"));
+ return policyData;
+ }
- if("GUARD_YAML".equals(ruleProvider)){
- yamlparams.setLimit(matching.get("limit"));
- yamlparams.setTimeWindow(matching.get("timeWindow"));
- yamlparams.setTimeUnits(matching.get("timeUnits"));
- } else if ("GUARD_MIN_MAX".equals(ruleProvider)) {
- yamlparams.setMin(matching.get("min"));
- yamlparams.setMax(matching.get("max"));
- }else{
+ private PolicyRestAdapter populateDecisionGuardParameters(PolicyRestAdapter policyData,
+ Map<String, String> matching) {
+ // Set Matching attributes in YAMLParams in adapter
+ YAMLParams yamlparams = new YAMLParams();
- List<String> blackList = new ArrayList<>();
+ if (matching == null) {
+ policyData.setYamlparams(yamlparams);
+ return policyData;
+ }
- if(!Strings.isNullOrEmpty(matching.get("blackList"))){
- String[] blackListArray = matching.get("blackList").split(",");
- for(String element : blackListArray){
- blackList.add(element);
- }
- }
+ yamlparams.setActor(matching.get("actor"));
+ yamlparams.setRecipe(matching.get("recipe"));
+ yamlparams.setGuardActiveStart(matching.get("guardActiveStart"));
+ yamlparams.setGuardActiveEnd(matching.get("guardActiveEnd"));
- yamlparams.setBlackList(blackList);
+ yamlparams.setLimit(matching.get("limit"));
+ yamlparams.setTimeWindow(matching.get("timeWindow"));
+ yamlparams.setTimeUnits(matching.get("timeUnits"));
- }
- }
- policyData.setYamlparams(yamlparams);
- }
+ yamlparams.setMin(matching.get("min"));
+ yamlparams.setMax(matching.get("max"));
- } else if("Action".equals(parameters.getPolicyClass().toString())){
+ List<String> blackList = new ArrayList<>();
- ArrayList<Object> ruleAlgorithmChoices = new ArrayList<>();
+ if (!Strings.isNullOrEmpty(matching.get("blackList"))) {
+ String[] blackListArray = matching.get("blackList").split(",");
+ for (String element : blackListArray) {
+ blackList.add(element);
+ }
+ }
- List<String> dynamicLabelRuleAlgorithms = parameters.getDynamicRuleAlgorithmLabels();
- List<String> dynamicFieldFunctionRuleAlgorithms = parameters.getDynamicRuleAlgorithmFunctions();
- List<String> dynamicFieldOneRuleAlgorithms = parameters.getDynamicRuleAlgorithmField1();
- List<String> dyrnamicFieldTwoRuleAlgorithms = parameters.getDynamicRuleAlgorithmField2();
+ yamlparams.setBlackList(blackList);
- if (dynamicLabelRuleAlgorithms != null && !dynamicLabelRuleAlgorithms.isEmpty()) {
- int i = dynamicLabelRuleAlgorithms.size() - 1;
+ policyData.setYamlparams(yamlparams);
+ return policyData;
+ }
- for (String labelAttr : dynamicLabelRuleAlgorithms) {
- LinkedHashMap<String, String> ruleAlgorithm = new LinkedHashMap<>();
+ private PolicyRestAdapter populateActionParameters(PolicyParameters parameters, PolicyRestAdapter policyData,
+ Map<String, String> matching) {
+ ArrayList<Object> ruleAlgorithmChoices = new ArrayList<>();
- String id = dynamicLabelRuleAlgorithms.get(i);
- String dynamicRuleAlgorithmField1 = dynamicFieldOneRuleAlgorithms.get(i);
- String dynamicRuleAlgorithmCombo = dynamicFieldFunctionRuleAlgorithms.get(i);
- String dynamicRuleAlgorithmField2 = dyrnamicFieldTwoRuleAlgorithms.get(i);
+ List<String> dynamicLabelRuleAlgorithms = parameters.getDynamicRuleAlgorithmLabels();
+ List<String> dynamicFieldFunctionRuleAlgorithms = parameters.getDynamicRuleAlgorithmFunctions();
+ List<String> dynamicFieldOneRuleAlgorithms = parameters.getDynamicRuleAlgorithmField1();
+ List<String> dynamicFieldTwoRuleAlgorithms = parameters.getDynamicRuleAlgorithmField2();
- ruleAlgorithm.put("id", id);
- ruleAlgorithm.put("dynamicRuleAlgorithmField1", dynamicRuleAlgorithmField1);
- ruleAlgorithm.put("dynamicRuleAlgorithmCombo", dynamicRuleAlgorithmCombo);
- ruleAlgorithm.put("dynamicRuleAlgorithmField2", dynamicRuleAlgorithmField2);
+ if (dynamicLabelRuleAlgorithms != null && !dynamicLabelRuleAlgorithms.isEmpty()) {
- ruleAlgorithmChoices.add(ruleAlgorithm);
+ for (int i = dynamicLabelRuleAlgorithms.size() - 1; i >= 0; i--) {
+ LinkedHashMap<String, String> ruleAlgorithm = new LinkedHashMap<>();
- i--;
+ String id = dynamicLabelRuleAlgorithms.get(i);
+ String dynamicRuleAlgorithmField1 = dynamicFieldOneRuleAlgorithms.get(i);
+ String dynamicRuleAlgorithmCombo = dynamicFieldFunctionRuleAlgorithms.get(i);
+ String dynamicRuleAlgorithmField2 = dynamicFieldTwoRuleAlgorithms.get(i);
- }
- }
+ ruleAlgorithm.put("id", id);
+ ruleAlgorithm.put("dynamicRuleAlgorithmField1", dynamicRuleAlgorithmField1);
+ ruleAlgorithm.put("dynamicRuleAlgorithmCombo", dynamicRuleAlgorithmCombo);
+ ruleAlgorithm.put("dynamicRuleAlgorithmField2", dynamicRuleAlgorithmField2);
- policyData.setRuleAlgorithmschoices(ruleAlgorithmChoices);
-
- ArrayList<Object> attributeList = new ArrayList<>();
- if (matching != null) {
- for (Map.Entry<String, String> entry : matching.entrySet()) {
- LinkedHashMap<String, String> attributeMap = new LinkedHashMap<>();
- String key = entry.getKey();
- String value = entry.getValue();
- attributeMap.put("key", key);
- attributeMap.put("value", value);
- attributeList.add(attributeMap);
- }
- }
-
- policyData.setAttributes(attributeList);
- policyData.setActionAttributeValue(parameters.getActionAttribute());
- policyData.setActionPerformer(parameters.getActionPerformer());
+ ruleAlgorithmChoices.add(ruleAlgorithm);
+ }
+ }
+ policyData.setRuleAlgorithmschoices(ruleAlgorithmChoices);
+
+ ArrayList<Object> attributeList = new ArrayList<>();
+ if (matching != null) {
+ for (Map.Entry<String, String> entry : matching.entrySet()) {
+ LinkedHashMap<String, String> attributeMap = new LinkedHashMap<>();
+ String key = entry.getKey();
+ String value = entry.getValue();
+ attributeMap.put("key", key);
+ attributeMap.put("value", value);
+ attributeList.add(attributeMap);
}
- }else {
-
- policyData.setPolicyType("Config");
- policyData.setConfigPolicyType(parameters.getPolicyConfigType().toString());
-
- //Config Specific
- policyData.setConfigBodyData(parameters.getConfigBody()); //Base
- policyData.setConfigType((parameters.getConfigBodyType()!=null) ? parameters.getConfigBodyType().toString().toUpperCase(): null); //Base
-
- if("FW".equalsIgnoreCase(parameters.getPolicyConfigType().toString())){
-
- policyData.setConfigPolicyType("Firewall Config");
-
- // get values and attributes from the JsonObject
- if(json != null){
- if (json.get("securityZoneId")!=null){
- String securityZone = json.get("securityZoneId").toString().replace("\"", "");
- policyData.setSecurityZone(securityZone);
- }
- if (json.get(CONFIG_NAME)!=null){
- String configName = json.get(CONFIG_NAME).toString().replace("\"", "");
- policyData.setConfigName(configName);
- }
- }
-
- }else if("MS".equals(parameters.getPolicyConfigType().toString())){
-
- policyData.setConfigPolicyType("Micro Service");
-
- // get values and attributes from the JsonObject
- if(json != null){
- if (json.containsKey(CONTENT)){
- String content = json.get(CONTENT).toString();
- ObjectMapper mapper = new ObjectMapper();
- JsonNode policyJSON = null;
- try {
- policyJSON = mapper.readTree(content);
- } catch (IOException e) {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ INVALIDJSON + parameters.getConfigBody();
- LOGGER.error(message, e);
- return null;
- }
- policyData.setPolicyJSON(policyJSON);
- }
- if (json.containsKey(SERVICE)){
- String serviceType = json.get(SERVICE).toString().replace("\"", "");
- policyData.setServiceType(serviceType);
- }
- if (json.containsKey("uuid")){
- String uuid = json.get("uuid").toString().replace("\"", "");
- policyData.setUuid(uuid);
- }
- if (json.containsKey(LOCATION)){
- String msLocation = json.get(LOCATION).toString().replace("\"", "");
- policyData.setLocation(msLocation);
- }
- if (json.containsKey(CONFIG_NAME)){
- String configName = json.get(CONFIG_NAME).toString().replace("\"", "");
- policyData.setConfigName(configName);
- }
- if(json.containsKey(PRIORITY)){
- String priority = json.get(PRIORITY).toString().replace("\"", "");
- policyData.setPriority(priority);
- }
- if(json.containsKey(VERSION)){
- String version = json.get(VERSION).toString().replace("\"", "");
- policyData.setVersion(version);
- }
- if(json.containsKey(POLICYSCOPE)){
- String policyScope = json.get(POLICYSCOPE).toString().replace("\"", "");
- policyData.setPolicyScope(policyScope);
- }
- if(json.containsKey(RISKTYPE)){
- String riskType = json.get(RISKTYPE).toString().replace("\"", "");
- policyData.setRiskType(riskType);
- }
- if(json.containsKey(RISKLEVEL)){
- String riskLevel = json.get(RISKLEVEL).toString().replace("\"", "");
- policyData.setRiskLevel(riskLevel);
- }
- if(json.containsKey(GUARD)){
- String guard = json.get(GUARD).toString().replace("\"", "");
- policyData.setGuard(guard);
- }
- } else {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ INVALIDJSON + parameters.getConfigBody();
- LOGGER.error(message);
- return null;
- }
-
- }else if("Optimization".equals(parameters.getPolicyConfigType().toString())){
-
- policyData.setConfigPolicyType("Optimization");
-
- // get values and attributes from the JsonObject
- if(json != null){
- if (json.containsKey(CONTENT)){
- String content = json.get(CONTENT).toString();
- ObjectMapper mapper = new ObjectMapper();
- JsonNode policyJSON = null;
- try {
- policyJSON = mapper.readTree(content);
- } catch (IOException e) {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ INVALIDJSON + parameters.getConfigBody();
- LOGGER.error(message, e);
- return null;
- }
- policyData.setPolicyJSON(policyJSON);
- }
- if (json.containsKey(SERVICE)){
- String serviceType = json.get(SERVICE).toString().replace("\"", "");
- policyData.setServiceType(serviceType);
- }
- if (json.containsKey("uuid")){
- String uuid = json.get("uuid").toString().replace("\"", "");
- policyData.setUuid(uuid);
- }
- if (json.containsKey(LOCATION)){
- String msLocation = json.get(LOCATION).toString().replace("\"", "");
- policyData.setLocation(msLocation);
- }
- if (json.containsKey(CONFIG_NAME)){
- String configName = json.get(CONFIG_NAME).toString().replace("\"", "");
- policyData.setConfigName(configName);
- }
- if(json.containsKey(PRIORITY)){
- String priority = json.get(PRIORITY).toString().replace("\"", "");
- policyData.setPriority(priority);
- }
- if(json.containsKey(VERSION)){
- String version = json.get(VERSION).toString().replace("\"", "");
- policyData.setVersion(version);
- }
- if(json.containsKey(POLICYSCOPE)){
- String policyScope = json.get(POLICYSCOPE).toString().replace("\"", "");
- policyData.setPolicyScope(policyScope);
- }
- if(json.containsKey(RISKTYPE)){
- String riskType = json.get(RISKTYPE).toString().replace("\"", "");
- policyData.setRiskType(riskType);
- }
- if(json.containsKey(RISKLEVEL)){
- String riskLevel = json.get(RISKLEVEL).toString().replace("\"", "");
- policyData.setRiskLevel(riskLevel);
- }
- if(json.containsKey(GUARD)){
- String guard = json.get(GUARD).toString().replace("\"", "");
- policyData.setGuard(guard);
- }
- }
-
- } else if("Fault".equals(parameters.getPolicyConfigType().toString())){
-
- policyData.setConfigPolicyType("ClosedLoop_Fault");
-
- if(json != null){
- policyData.setJsonBody(json.toString());
- if (json.get(ONAPNAME)!=null){
- String onapName = json.get(ONAPNAME).toString().replace("\"", "");
- policyData.setOnapName(onapName);
- }
- }
-
- } else if("PM".equals(parameters.getPolicyConfigType().toString())){
-
- policyData.setConfigPolicyType("ClosedLoop_PM");
-
- if(json != null){
- policyData.setJsonBody(json.toString());
- if (json.get(ONAPNAME)!=null){
- String onapName = json.get(ONAPNAME).toString().replace("\"", "");
- policyData.setOnapName(onapName);
- }
- if (json.get(SERVICETYPE_POLICY_NAME)!=null){
- String serviceType = json.get(SERVICETYPE_POLICY_NAME).toString().replace("\"", "");
- LinkedHashMap<String, String> serviceTypePolicyName = new LinkedHashMap<>();
- serviceTypePolicyName.put(SERVICETYPE_POLICY_NAME, serviceType);
- policyData.setServiceTypePolicyName(serviceTypePolicyName);
- }
- }
- } else if("BRMS_Param".equals(parameters.getPolicyConfigType().toString())){
- Map<AttributeType, Map<String, String>> drlRuleAndUIParams = parameters.getAttributes();
- Map<String, String> rule = drlRuleAndUIParams.get(AttributeType.RULE);
- policyData.setRuleName(rule.get("templateName"));
+ }
+
+ policyData.setAttributes(attributeList);
+ policyData.setActionAttributeValue(parameters.getActionAttribute());
+ policyData.setActionPerformer(parameters.getActionPerformer());
+
+ return policyData;
+ }
+ private PolicyRestAdapter getJsonObjectValuesAndAttributes(PolicyParameters parameters,
+ PolicyRestAdapter policyData, JsonObject json) {
+ if (json.containsKey(CONTENT)) {
+ String content = json.get(CONTENT).toString();
+ JsonNode policyJson = null;
+ try {
+ policyJson = new ObjectMapper().readTree(content);
+ } catch (IOException e) {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE + INVALIDJSON + parameters.getConfigBody();
+ LOGGER.error(message, e);
+ return null;
}
+ policyData.setPolicyJSON(policyJson);
}
+ // @formatter:off
+ policyData.setServiceType(getNewOrExistingKeyValue(json, SERVICE, policyData.getServiceType()));
+ policyData.setUuid(getNewOrExistingKeyValue( json, UUID, policyData.getUuid()));
+ policyData.setLocation(getNewOrExistingKeyValue( json, LOCATION, policyData.getLocation()));
+ policyData.setConfigName(getNewOrExistingKeyValue( json, CONFIG_NAME, policyData.getConfigName()));
+ policyData.setPriority(getNewOrExistingKeyValue( json, PRIORITY, policyData.getPriority()));
+ policyData.setVersion(getNewOrExistingKeyValue( json, VERSION, policyData.getVersion()));
+ policyData.setPolicyScope(getNewOrExistingKeyValue(json, POLICYSCOPE, policyData.getPolicyScope()));
+ policyData.setRiskType(getNewOrExistingKeyValue( json, RISKTYPE, policyData.getRiskType()));
+ policyData.setRiskLevel(getNewOrExistingKeyValue( json, RISKLEVEL, policyData.getRiskLevel()));
+ policyData.setGuard(getNewOrExistingKeyValue( json, GUARD, policyData.getGuard()));
+ // @formatter:on
+
return policyData;
+ }
+
+ private String getNewOrExistingKeyValue(final JsonObject json, final String key, final String existingValue) {
+ if (json.containsKey(key)) {
+ return json.get(key).toString().replace("\"", "");
+ } else {
+ return existingValue;
+ }
+ }
+ private Map<String, String> getMatchingAttributeValues(PolicyParameters parameters) {
+ // Get Matching attribute values
+ Map<AttributeType, Map<String, String>> attributes = parameters.getAttributes();
+
+ if (attributes != null) {
+ return attributes.get(AttributeType.MATCHING);
+ }
+ return null;
}
-
+
private JsonObject stringToJsonObject(String value) {
- try(JsonReader jsonReader = Json.createReader(new StringReader(value))){
+ try (JsonReader jsonReader = Json.createReader(new StringReader(value))) {
return jsonReader.readObject();
- } catch(JsonException| IllegalStateException e){
- LOGGER.info(XACMLErrorConstants.ERROR_DATA_ISSUE+ "Improper JSON format... may or may not cause issues in validating the policy: " + value, e);
- return null;
+ } catch (JsonException | IllegalStateException jsonHandlingException) {
+ LOGGER.info(XACMLErrorConstants.ERROR_DATA_ISSUE
+ + "Improper JSON format... may or may not cause issues in validating the policy: " + value,
+ jsonHandlingException);
+ throw jsonHandlingException;
}
}
-
+
private String convertDate(Date date) {
String strDate = null;
- if (date!=null) {
+ if (date != null) {
SimpleDateFormat dateformatJava = new SimpleDateFormat("dd-MM-yyyy");
strDate = dateformatJava.format(date);
}
- return (strDate==null) ? "NA": strDate;
+ return (strDate == null) ? "NA" : strDate;
}
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/XACMLRestTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/XACMLRestTest.java
deleted file mode 100644
index 5b8513823..000000000
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/XACMLRestTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-REST
- * ================================================================================
- * Copyright (C) 2017-2018 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.rest;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.springframework.mock.web.MockHttpServletResponse;
-import org.springframework.mock.web.MockServletConfig;
-
-public class XACMLRestTest extends Mockito{
- private static Log logger = LogFactory.getLog(XACMLRestTest.class);
-
- private List<String> headers = new ArrayList<>();
-
- private HttpServletRequest httpServletRequest;
- private HttpServletResponse httpServletResponse;
- private ServletOutputStream mockOutput;
- private ServletConfig servletConfig;
-
-
- @Before
- public void setUp(){
- httpServletRequest = Mockito.mock(HttpServletRequest.class);
- Mockito.when(httpServletRequest.getMethod()).thenReturn("POST");
- Mockito.when(httpServletRequest.getHeaderNames()).thenReturn(Collections.enumeration(headers));
- Mockito.when(httpServletRequest.getAttributeNames()).thenReturn(Collections.enumeration(headers));
-
- mockOutput = Mockito.mock(ServletOutputStream.class);
-
- httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
-
- try {
- Mockito.when(httpServletResponse.getOutputStream()).thenReturn(mockOutput);
- } catch (IOException e) {
- fail();
- }
-
- servletConfig = Mockito.mock(MockServletConfig.class);
- Mockito.when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers));
- Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.pdp.properties");
-
- System.setProperty("xacml.properties", "xacml.pdp.properties");
- System.setProperty("xacml.rest.pdp.config", "config_testing");
- System.setProperty("xacml.rest.pep.idfile", "testclient.properties");
- System.setProperty("xacml.rest.pdp.webapps", "/webapps");
- System.setProperty("xacml.rootPolicies", "test_PolicyEngine.xml");
- System.setProperty("xacml.referencedPolicies", "test_PolicyEngine.xml");
- System.setProperty("test_PolicyEngine.xml.file", "config_testing\\test_PolicyEngine.xml");
- System.setProperty("xacml.rest.pdp.register", "false");
- }
-
- @Test
- public void testXacmlInit(){
- logger.info("XACMLRestTest - testInit");
- try {
- XACMLRest.xacmlInit(servletConfig);
- Logger.getRootLogger().setLevel(Level.DEBUG);
- XACMLRest.dumpRequest(httpServletRequest);
- XACMLRest.loadXacmlProperties(null, null);
- } catch (Exception e) {
- fail();
- }
- }
-
- @Test
- public void testConstructorIsPrivate() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
- Constructor<XACMLRestProperties> constructor = XACMLRestProperties.class.getDeclaredConstructor();
- assertTrue(Modifier.isPrivate(constructor.getModifiers()));
- constructor.setAccessible(true);
- constructor.newInstance();
- }
-} \ No newline at end of file
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/XacmlAdminAuthorizationTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/XacmlAdminAuthorizationTest.java
new file mode 100644
index 000000000..75abb4f53
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/XacmlAdminAuthorizationTest.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+
+/**
+ * Test the XacmlAdminAuthorizaiton class.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class XacmlAdminAuthorizationTest {
+
+ @Test
+ public void test() {
+ assertNotNull(new XacmlAdminAuthorization());
+ }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/XacmlRestTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/XacmlRestTest.java
new file mode 100644
index 000000000..3b03bdcc8
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/XacmlRestTest.java
@@ -0,0 +1,303 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-REST
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.rest;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import com.att.research.xacml.util.XACMLProperties;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.mock.web.MockServletConfig;
+
+public class XacmlRestTest extends Mockito {
+ private static Log logger = LogFactory.getLog(XacmlRestTest.class);
+
+ private List<String> headers = new ArrayList<>();
+
+ private HttpServletRequest httpServletRequest;
+ private HttpServletResponse httpServletResponse;
+ private ServletOutputStream mockOutput;
+ private ServletConfig servletConfig;
+ private ServletInputStream servletInputStream;
+
+ /**
+ * Prepare for the test.
+ */
+ @Before
+ public void setUp() {
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("POST");
+ Mockito.when(httpServletRequest.getHeaderNames()).thenReturn(Collections.enumeration(headers));
+ Mockito.when(httpServletRequest.getAttributeNames()).thenReturn(Collections.enumeration(headers));
+
+ mockOutput = Mockito.mock(ServletOutputStream.class);
+
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+
+ try {
+ Mockito.when(httpServletResponse.getOutputStream()).thenReturn(mockOutput);
+ } catch (IOException e) {
+ fail();
+ }
+
+ servletConfig = Mockito.mock(MockServletConfig.class);
+ Mockito.when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers));
+ Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.pdp.properties");
+
+ System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "xacml.pdp.properties");
+ System.setProperty("xacml.rest.pdp.config", "config_testing");
+ System.setProperty("xacml.rest.pep.idfile", "testclient.properties");
+ System.setProperty("xacml.rest.pdp.webapps", "/webapps");
+ System.setProperty("xacml.rootPolicies", "test_PolicyEngine.xml");
+ System.setProperty("xacml.referencedPolicies", "test_PolicyEngine.xml");
+ System.setProperty("test_PolicyEngine.xml.file", "config_testing\\test_PolicyEngine.xml");
+ System.setProperty("xacml.rest.pdp.register", "false");
+
+ servletInputStream = Mockito.mock(ServletInputStream.class);
+ }
+
+ @Test
+ public void testXacmlInit() {
+ logger.info("XACMLRestTest - testInit");
+
+ try {
+ XacmlRest.xacmlInit(servletConfig);
+ Logger.getRootLogger().setLevel(Level.DEBUG);
+ XacmlRest.dumpRequest(httpServletRequest);
+ XacmlRest.loadXacmlProperties(null, null);
+ } catch (Exception e) {
+ fail("Normal case of initiation of XACML REST failed");
+ }
+
+ System.clearProperty(XACMLProperties.XACML_PROPERTIES_NAME);
+ try {
+ XacmlRest.xacmlInit(servletConfig);
+ Logger.getRootLogger().setLevel(Level.DEBUG);
+ XacmlRest.dumpRequest(httpServletRequest);
+ XacmlRest.loadXacmlProperties(null, null);
+ } catch (Exception e) {
+ fail("Normal case of initiation of XACML REST failed");
+ }
+
+ System.clearProperty(XACMLProperties.XACML_PROPERTIES_NAME);
+ try {
+ Logger.getRootLogger().setLevel(Level.INFO);
+ XacmlRest.xacmlInit(servletConfig);
+ Logger.getRootLogger().setLevel(Level.DEBUG);
+ XacmlRest.dumpRequest(httpServletRequest);
+ XacmlRest.loadXacmlProperties(null, null);
+ } catch (Exception e) {
+ fail("Normal case of initiation of XACML REST failed");
+ }
+
+ System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "xacml.pdp.properties");
+
+ try {
+ Logger.getRootLogger().setLevel(Level.DEBUG);
+ XacmlRest.xacmlInit(servletConfig);
+ XacmlRest.dumpRequest(httpServletRequest);
+ XacmlRest.loadXacmlProperties(null, null);
+ } catch (Exception e) {
+ fail("Normal case of initiation of XACML REST failed");
+ }
+
+ Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn(null);
+ try {
+ XacmlRest.xacmlInit(servletConfig);
+ Logger.getRootLogger().setLevel(Level.DEBUG);
+ XacmlRest.dumpRequest(httpServletRequest);
+ XacmlRest.loadXacmlProperties(null, null);
+ } catch (Exception e) {
+ fail("Normal case of initiation of XACML REST failed");
+ }
+
+ try {
+ Logger.getRootLogger().setLevel(Level.INFO);
+ XacmlRest.xacmlInit(servletConfig);
+ Logger.getRootLogger().setLevel(Level.DEBUG);
+ XacmlRest.dumpRequest(httpServletRequest);
+ XacmlRest.loadXacmlProperties(null, null);
+ } catch (Exception e) {
+ fail("Normal case of initiation of XACML REST failed");
+ }
+
+ Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.pdp.properties");
+
+ List<String> parNameList = new ArrayList<String>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ add("Name0");
+ add("Name1");
+ add("Name2");
+ add("XACML_PROPERTIES_NAME");
+ }
+ };
+
+ Mockito.when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(parNameList));
+ Mockito.when(servletConfig.getInitParameter("Name0")).thenReturn("Value0");
+ Mockito.when(servletConfig.getInitParameter("Name1")).thenReturn("Value1");
+ Mockito.when(servletConfig.getInitParameter("Name2")).thenReturn("Value2");
+ try {
+ XacmlRest.xacmlInit(servletConfig);
+ Logger.getRootLogger().setLevel(Level.DEBUG);
+ XacmlRest.dumpRequest(httpServletRequest);
+ XacmlRest.loadXacmlProperties(null, null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Normal case of initiation of XACML REST failed");
+ }
+
+ }
+
+ @Test
+ public void testConstructorIsPrivate() throws NoSuchMethodException, IllegalAccessException,
+ InvocationTargetException, InstantiationException {
+ Constructor<XacmlRestProperties> constructor = XacmlRestProperties.class.getDeclaredConstructor();
+ assertTrue(Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+
+ @Test
+ public void testLoadXacmlProperties() {
+ XacmlRest.xacmlInit(servletConfig);
+ XacmlRest.loadXacmlProperties(null, null);
+
+ XacmlRest.loadXacmlProperties(new Properties(), new Properties());
+
+ Logger.getRootLogger().setLevel(Level.INFO);
+ XacmlRest.loadXacmlProperties(new Properties(), new Properties());
+ }
+
+ @Test
+ public void testDumpRequest() throws IOException {
+ XacmlRest.xacmlInit(servletConfig);
+
+ Logger.getRootLogger().setLevel(Level.INFO);
+ XacmlRest.dumpRequest(httpServletRequest);
+ Logger.getRootLogger().setLevel(Level.DEBUG);
+
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("GET");
+ XacmlRest.dumpRequest(httpServletRequest);
+ Mockito.when(httpServletRequest.getParameter("type")).thenReturn("hb");
+ XacmlRest.dumpRequest(httpServletRequest);
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("POST");
+
+ List<String> headerNameList = new ArrayList<String>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ add("Name0");
+ add("Name1");
+ }
+ };
+
+ List<String> header0List = new ArrayList<String>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ add("Name0H0");
+ add("Name0H1");
+ add("Name0H2");
+ }
+ };
+
+ List<String> header1List = new ArrayList<String>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ add("Name1H0");
+ add("Name1H1");
+ add("Name1H2");
+ }
+ };
+
+ Mockito.when(httpServletRequest.getHeaderNames()).thenReturn(Collections.enumeration(headerNameList));
+ Mockito.when(httpServletRequest.getHeaders("Name0")).thenReturn(Collections.enumeration(header0List));
+ Mockito.when(httpServletRequest.getHeaders("Name1")).thenReturn(Collections.enumeration(header1List));
+ XacmlRest.dumpRequest(httpServletRequest);
+
+ List<String> attributeList = new ArrayList<String>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ add("Attribute0");
+ add("Attribute1");
+ }
+ };
+ Mockito.when(httpServletRequest.getAttributeNames()).thenReturn(Collections.enumeration(attributeList));
+ Mockito.when(httpServletRequest.getAttribute("Attribute0")).thenReturn("AttributeValue0");
+ Mockito.when(httpServletRequest.getAttribute("Attribute1")).thenReturn("AttributeValue1");
+ XacmlRest.dumpRequest(httpServletRequest);
+
+ Mockito.when(httpServletRequest.getInputStream()).thenReturn(servletInputStream);
+ XacmlRest.dumpRequest(httpServletRequest);
+
+ Mockito.when(httpServletRequest.getInputStream()).thenThrow(new IOException());
+ XacmlRest.dumpRequest(httpServletRequest);
+
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("PUT");
+ XacmlRest.dumpRequest(httpServletRequest);
+
+ Map<String, String[]> parameterMap = new LinkedHashMap<>();
+ String[] mapValue0 =
+ { "MapValue0" };
+ String[] mapValue1 =
+ { "MapValue0" };
+ String[] mapValue2 =
+ {};
+ parameterMap.put("Key0", mapValue0);
+ parameterMap.put("Key1", mapValue1);
+ parameterMap.put("Key2", mapValue2);
+
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("DELETE");
+ Mockito.when(httpServletRequest.getParameterMap()).thenReturn(parameterMap);
+ XacmlRest.dumpRequest(httpServletRequest);
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("POST");
+ }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/PolicyRestAdapterTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/PolicyRestAdapterTest.java
index 971614359..61a63ce0c 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/PolicyRestAdapterTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/PolicyRestAdapterTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,6 +19,8 @@
*/
package org.onap.policy.rest.adapter;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
@@ -31,14 +33,14 @@ import org.onap.policy.rest.jpa.OnapName;
public class PolicyRestAdapterTest {
@Test
- public void testPolicyExportAdapter(){
+ public void testPolicyExportAdapter() {
PolicyExportAdapter adapter = new PolicyExportAdapter();
adapter.setPolicyDatas(new ArrayList<>());
assertTrue(adapter.getPolicyDatas() != null);
}
@Test
- public void testPolicyRestAdapter(){
+ public void testPolicyRestAdapter() {
PolicyRestAdapter adapter = new PolicyRestAdapter();
adapter.setData(new Object());
assertTrue(adapter.getData() != null);
@@ -115,27 +117,27 @@ public class PolicyRestAdapterTest {
adapter.setExistingCLName("Test");
assertTrue("Test".equals(adapter.getExistingCLName()));
adapter.setOnapNameField(new OnapName());
- assertTrue(adapter.getOnapNameField()!=null);
+ assertTrue(adapter.getOnapNameField() != null);
adapter.setJsonBodyData(new Object());
- assertTrue(adapter.getJsonBodyData()!=null);
+ assertTrue(adapter.getJsonBodyData() != null);
adapter.setDirPath("Test");
assertTrue("Test".equals(adapter.getDirPath()));
adapter.setConfigBodyPath("Test");
assertTrue("Test".equals(adapter.getConfigBodyPath()));
adapter.setAttributes(new ArrayList<>());
- assertTrue(adapter.getAttributes()!=null);
+ assertTrue(adapter.getAttributes() != null);
adapter.setSettings(new ArrayList<>());
- assertTrue(adapter.getSettings()!=null);
+ assertTrue(adapter.getSettings() != null);
adapter.setRuleAlgorithmschoices(new ArrayList<>());
- assertTrue(adapter.getRuleAlgorithmschoices()!=null);
+ assertTrue(adapter.getRuleAlgorithmschoices() != null);
adapter.setServiceTypePolicyName(new HashMap<>());
- assertTrue(adapter.getServiceTypePolicyName()!=null);
+ assertTrue(adapter.getServiceTypePolicyName() != null);
adapter.setVerticaMetrics(new HashMap<>());
- assertTrue(adapter.getVerticaMetrics()!=null);
+ assertTrue(adapter.getVerticaMetrics() != null);
adapter.setDescription(new LinkedHashMap<>());
- assertTrue(adapter.getVerticaMetrics()!=null);
+ assertTrue(adapter.getVerticaMetrics() != null);
adapter.setAttributeFields(new LinkedHashMap<>());
- assertTrue(adapter.getAttributeFields()!=null);
+ assertTrue(adapter.getAttributeFields() != null);
adapter.setClearTimeOut("Test");
assertTrue("Test".equals(adapter.getClearTimeOut()));
adapter.setTrapMaxAge("Test");
@@ -143,15 +145,15 @@ public class PolicyRestAdapterTest {
adapter.setVerificationclearTimeOut("Test");
assertTrue("Test".equals(adapter.getVerificationclearTimeOut()));
adapter.setDynamicLayoutMap(new HashMap<>());
- assertTrue(adapter.getDynamicLayoutMap()!=null);
+ assertTrue(adapter.getDynamicLayoutMap() != null);
adapter.setTrapDatas(new ClosedLoopFaultTrapDatas());
- assertTrue(adapter.getTrapDatas()!=null);
+ assertTrue(adapter.getTrapDatas() != null);
adapter.setFaultDatas(new ClosedLoopFaultTrapDatas());
- assertTrue(adapter.getFaultDatas()!=null);
+ assertTrue(adapter.getFaultDatas() != null);
adapter.setFwPolicyType("Test");
assertTrue("Test".equals(adapter.getFwPolicyType()));
adapter.setFwattributes(new ArrayList<>());
- assertTrue(adapter.getFwattributes()!=null);
+ assertTrue(adapter.getFwattributes() != null);
adapter.setParentForChild("Test");
assertTrue("Test".equals(adapter.getParentForChild()));
adapter.setSecurityZone("Test");
@@ -159,27 +161,27 @@ public class PolicyRestAdapterTest {
adapter.setRuleCombiningAlgId("Test");
assertTrue("Test".equals(adapter.getRuleCombiningAlgId()));
adapter.setDynamicFieldConfigAttributes(new HashMap<>());
- assertTrue(adapter.getDynamicFieldConfigAttributes()!=null);
+ assertTrue(adapter.getDynamicFieldConfigAttributes() != null);
adapter.setDynamicSettingsMap(new HashMap<>());
- assertTrue(adapter.getDynamicSettingsMap()!=null);
+ assertTrue(adapter.getDynamicSettingsMap() != null);
adapter.setDropDownMap(new HashMap<>());
- assertTrue(adapter.getDropDownMap()!=null);
+ assertTrue(adapter.getDropDownMap() != null);
adapter.setActionPerformer("Test");
assertTrue("Test".equals(adapter.getActionPerformer()));
adapter.setActionAttribute("Test");
assertTrue("Test".equals(adapter.getActionAttribute()));
adapter.setDynamicRuleAlgorithmLabels(new ArrayList<>());
- assertTrue(adapter.getDynamicRuleAlgorithmLabels()!=null);
+ assertTrue(adapter.getDynamicRuleAlgorithmLabels() != null);
adapter.setDynamicRuleAlgorithmCombo(new ArrayList<>());
- assertTrue(adapter.getDynamicRuleAlgorithmCombo()!=null);
+ assertTrue(adapter.getDynamicRuleAlgorithmCombo() != null);
adapter.setDynamicRuleAlgorithmField1(new ArrayList<>());
- assertTrue(adapter.getDynamicRuleAlgorithmField1()!=null);
+ assertTrue(adapter.getDynamicRuleAlgorithmField1() != null);
adapter.setDynamicRuleAlgorithmField2(new ArrayList<>());
- assertTrue(adapter.getDynamicRuleAlgorithmField2()!=null);
+ assertTrue(adapter.getDynamicRuleAlgorithmField2() != null);
adapter.setDynamicVariableList(new ArrayList<>());
- assertTrue(adapter.getDynamicVariableList()!=null);
+ assertTrue(adapter.getDynamicVariableList() != null);
adapter.setDataTypeList(new ArrayList<>());
- assertTrue(adapter.getDataTypeList()!=null);
+ assertTrue(adapter.getDataTypeList() != null);
adapter.setActionAttributeValue("Test");
assertTrue("Test".equals(adapter.getActionAttributeValue()));
adapter.setRuleProvider("Test");
@@ -195,15 +197,15 @@ public class PolicyRestAdapterTest {
adapter.setActionDictMethod("Test");
assertTrue("Test".equals(adapter.getActionDictMethod()));
adapter.setYamlparams(new YAMLParams());
- assertTrue(adapter.getYamlparams()!=null);
+ assertTrue(adapter.getYamlparams() != null);
adapter.setRainyday(new RainyDayParams());
- assertTrue(adapter.getRainyday()!=null);
+ assertTrue(adapter.getRainyday() != null);
adapter.setRainydayMap(new HashMap<>());
- assertTrue(adapter.getRainydayMap()!=null);
+ assertTrue(adapter.getRainydayMap() != null);
adapter.setErrorCodeList(new ArrayList<>());
- assertTrue(adapter.getErrorCodeList()!=null);
+ assertTrue(adapter.getErrorCodeList() != null);
adapter.setTreatmentList(new ArrayList<>());
- assertTrue(adapter.getTreatmentList()!=null);
+ assertTrue(adapter.getTreatmentList() != null);
adapter.setServiceType("Test");
assertTrue("Test".equals(adapter.getServiceType()));
adapter.setUuid("Test");
@@ -219,17 +221,17 @@ public class PolicyRestAdapterTest {
adapter.setRuleName("Test");
assertTrue("Test".equals(adapter.getRuleName()));
adapter.setBrmsParamBody(new HashMap<>());
- assertTrue(adapter.getBrmsParamBody()!=null);
+ assertTrue(adapter.getBrmsParamBody() != null);
adapter.setBrmsController("Test");
assertTrue("Test".equals(adapter.getBrmsController()));
adapter.setBrmsDependency(new ArrayList<>());
- assertTrue(adapter.getBrmsDependency()!=null);
+ assertTrue(adapter.getBrmsDependency() != null);
adapter.setRuleData(new LinkedHashMap<>());
- assertTrue(adapter.getRuleData()!=null);
+ assertTrue(adapter.getRuleData() != null);
adapter.setRuleListData(new LinkedHashMap<>());
- assertTrue(adapter.getRuleListData()!=null);
+ assertTrue(adapter.getRuleListData() != null);
adapter.setDrlRuleAndUIParams(new LinkedHashMap<>());
- assertTrue(adapter.getDrlRuleAndUIParams()!=null);
+ assertTrue(adapter.getDrlRuleAndUIParams() != null);
adapter.setPolicyScope("Test");
assertTrue("Test".equals(adapter.getPolicyScope()));
adapter.setProviderComboBox("Test");
@@ -243,11 +245,11 @@ public class PolicyRestAdapterTest {
adapter.setTtlDate("Test");
assertTrue("Test".equals(adapter.getTtlDate()));
adapter.setMatching(new LinkedHashMap<>());
- assertTrue(adapter.getMatching()!=null);
+ assertTrue(adapter.getMatching() != null);
adapter.setTriggerSignatures(new ArrayList<>());
- assertTrue(adapter.getTriggerSignatures()!=null);
+ assertTrue(adapter.getTriggerSignatures() != null);
adapter.setSymptomSignatures(new ArrayList<>());
- assertTrue(adapter.getSymptomSignatures()!=null);
+ assertTrue(adapter.getSymptomSignatures() != null);
adapter.setLogicalConnector("Test");
assertTrue("Test".equals(adapter.getLogicalConnector()));
adapter.setPolicyStatus("Test");
@@ -257,4 +259,26 @@ public class PolicyRestAdapterTest {
adapter.setSupressionType("Test");
assertTrue("Test".equals(adapter.getSupressionType()));
}
+
+ @Test
+ public void testPublic() {
+ PolicyRestAdapter adapter = new PolicyRestAdapter();
+ adapter.setupUsingAttribute("ONAPName", "onapvalue");
+ adapter.setupUsingAttribute("RiskType", "riskvalue");
+ adapter.setupUsingAttribute("RiskLevel", "risklevel");
+ adapter.setupUsingAttribute("guard", "guardvalue");
+ adapter.setupUsingAttribute("ConfigName", "configvalue");
+ adapter.setupUsingAttribute("uuid", "uuidvalue");
+ adapter.setupUsingAttribute("location", "locationvalue");
+ assertEquals("riskvalue", adapter.getRiskType());
+ assertEquals("risklevel", adapter.getRiskLevel());
+ assertEquals("guardvalue", adapter.getGuard());
+ assertEquals("onapvalue", adapter.getOnapName());
+ assertEquals("onapvalue", adapter.getOnapNameField().getName());
+ assertEquals("uuidvalue", adapter.getUuid());
+ assertEquals("locationvalue", adapter.getLocation());
+ assertEquals("configvalue", adapter.getConfigName());
+
+ assertFalse(adapter.setupUsingAttribute("foobar", "foo"));
+ }
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/dao/PolicyDBExceptionTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/dao/PolicyDbExceptionTest.java
index 0cd89a40e..5293477e8 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/dao/PolicyDBExceptionTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/dao/PolicyDbExceptionTest.java
@@ -3,13 +3,14 @@
* PolicyEngineUtils
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,32 +24,32 @@ package org.onap.policy.rest.dao;
import java.io.IOException;
import org.junit.Test;
-public class PolicyDBExceptionTest {
- @Test(expected = PolicyDBException.class)
- public void testException1() throws PolicyDBException {
- throw new PolicyDBException();
- }
+public class PolicyDbExceptionTest {
+ @Test(expected = PolicyDbException.class)
+ public void testException1() throws PolicyDbException {
+ throw new PolicyDbException();
+ }
- @Test(expected = PolicyDBException.class)
- public void testException2() throws PolicyDBException {
- throw new PolicyDBException("test");
- }
+ @Test(expected = PolicyDbException.class)
+ public void testException2() throws PolicyDbException {
+ throw new PolicyDbException("test");
+ }
- @Test(expected = PolicyDBException.class)
- public void testException3() throws PolicyDBException {
- Throwable cause = new IOException();
- throw new PolicyDBException(cause);
- }
+ @Test(expected = PolicyDbException.class)
+ public void testException3() throws PolicyDbException {
+ Throwable cause = new IOException();
+ throw new PolicyDbException(cause);
+ }
- @Test(expected = PolicyDBException.class)
- public void testException4() throws PolicyDBException {
- Throwable cause = new IOException();
- throw new PolicyDBException("test", cause);
- }
+ @Test(expected = PolicyDbException.class)
+ public void testException4() throws PolicyDbException {
+ Throwable cause = new IOException();
+ throw new PolicyDbException("test", cause);
+ }
- @Test(expected = PolicyDBException.class)
- public void testException5() throws PolicyDBException {
- Throwable cause = new IOException();
- throw new PolicyDBException("test", cause, true, true);
- }
+ @Test(expected = PolicyDbException.class)
+ public void testException5() throws PolicyDbException {
+ Throwable cause = new IOException();
+ throw new PolicyDbException("test", cause, true, true);
+ }
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImplTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImplTest.java
index f5d968b14..3cedd2312 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImplTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImplTest.java
@@ -3,13 +3,15 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications copyright (c) 2019 Nokia
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,11 +19,19 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.daoimpl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -31,411 +41,633 @@ import javax.script.SimpleBindings;
import org.apache.tomcat.dbcp.dbcp2.BasicDataSource;
import org.h2.tools.Server;
+import org.hibernate.Query;
+import org.hibernate.Session;
import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
import org.junit.After;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-//import org.onap.policy.conf.HibernateSession;
-//import org.onap.policy.controller.PolicyController;
import org.onap.policy.rest.jpa.OnapName;
import org.onap.policy.rest.jpa.PolicyEntity;
import org.onap.policy.rest.jpa.PolicyRoles;
import org.onap.policy.rest.jpa.PolicyVersion;
-import org.onap.policy.rest.jpa.SystemLogDB;
+import org.onap.policy.rest.jpa.SystemLogDb;
import org.onap.policy.rest.jpa.UserInfo;
import org.onap.policy.rest.jpa.WatchPolicyNotificationTable;
import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder;
-import org.springframework.transaction.annotation.Transactional;
import org.springframework.test.annotation.Rollback;
-
+import org.springframework.transaction.annotation.Transactional;
public class PolicyValidationDaoImplTest {
private static Logger logger = FlexLogger.getLogger(PolicyValidationDaoImplTest.class);
- SessionFactory sessionFactory;
- Server server;
- PolicyValidationDaoImpl commonClassDao;
-
- @Before
- public void setUp() throws Exception{
- try{
- BasicDataSource dataSource = new BasicDataSource();
- dataSource.setDriverClassName("org.h2.Driver");
- // In-memory DB for testing
- dataSource.setUrl("jdbc:h2:mem:test");
- dataSource.setUsername("sa");
- dataSource.setPassword("");
- LocalSessionFactoryBuilder sessionBuilder = new LocalSessionFactoryBuilder(dataSource);
- sessionBuilder.scanPackages("org.onap.*", "com.*");
-
- Properties properties = new Properties();
- properties.put("hibernate.show_sql", "false");
- properties.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
- properties.put("hibernate.hbm2ddl.auto", "drop");
- properties.put("hibernate.hbm2ddl.auto", "create");
-
- sessionBuilder.addProperties(properties);
- sessionFactory = sessionBuilder.buildSessionFactory();
-
- // Set up dao with SessionFactory
- commonClassDao = new PolicyValidationDaoImpl();
- PolicyValidationDaoImpl.setSessionfactory(sessionFactory);
- //PolicyController.setLogTableLimit("1");
- //HibernateSession.setSession(sessionFactory);
- SystemLogDB data1 = new SystemLogDB();
- data1.setDate(new Date());
- data1.setLogtype("INFO");
- data1.setRemote("Test");
- data1.setSystem("Test");
- data1.setType("Test");
- SystemLogDB data2 = new SystemLogDB();
- data2.setDate(new Date());
- data2.setLogtype("error");
- data2.setRemote("Test");
- data2.setSystem("Test");
- data2.setType("Test");
- //HibernateSession.getSession().save(data1);
- //HibernateSession.getSession().save(data2);
-
- // Create TCP server for troubleshooting
- server = Server.createTcpServer("-tcpAllowOthers").start();
- System.out.println("URL: jdbc:h2:" + server.getURL() + "/mem:test");
-
- }catch(Exception e){
- System.err.println(e);
- fail();
- }
+ static SessionFactory sessionFactory;
+ static Server server;
+ static PolicyValidationDaoImpl commonClassDao;
+
+ /**
+ * Set up all unit tests.
+ *
+ * @throws SQLException on SQL exceptions
+ */
+ @BeforeClass
+ public static void setupAll() throws SQLException {
+ BasicDataSource dataSource = new BasicDataSource();
+ dataSource.setDriverClassName("org.h2.Driver");
+ // In-memory DB for testing
+ dataSource.setUrl("jdbc:h2:mem:test");
+ dataSource.setUsername("sa");
+ dataSource.setPassword("");
+ LocalSessionFactoryBuilder sessionBuilder = new LocalSessionFactoryBuilder(dataSource);
+ sessionBuilder.scanPackages("org.onap.*", "com.*");
+
+ Properties properties = new Properties();
+ properties.put("hibernate.show_sql", "false");
+ properties.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
+ properties.put("hibernate.hbm2ddl.auto", "drop");
+ properties.put("hibernate.hbm2ddl.auto", "create");
+
+ sessionBuilder.addProperties(properties);
+ sessionFactory = sessionBuilder.buildSessionFactory();
+
+ // Set up dao with SessionFactory
+ commonClassDao = new PolicyValidationDaoImpl();
+ PolicyValidationDaoImpl.setSessionfactory(sessionFactory);
+ // PolicyController.setLogTableLimit("1");
+ // HibernateSession.setSession(sessionFactory);
+ SystemLogDb data1 = new SystemLogDb();
+ data1.setDate(new Date());
+ data1.setLogtype("INFO");
+ data1.setRemote("Test");
+ data1.setSystem("Test");
+ data1.setType("Test");
+ SystemLogDb data2 = new SystemLogDb();
+ data2.setDate(new Date());
+ data2.setLogtype("error");
+ data2.setRemote("Test");
+ data2.setSystem("Test");
+ data2.setType("Test");
+
+ // Create TCP server for troubleshooting
+ server = Server.createTcpServer("-tcpAllowOthers").start();
+ System.out.println("URL: jdbc:h2:" + server.getURL() + "/mem:test");
+ }
+
+ @AfterClass
+ public static void deleteDB() {
+ sessionFactory.close();
+ server.stop();
+ }
+
+ @After
+ public void tearDown() {
+ truncateAllTables();
}
@Test
@Transactional
@Rollback(true)
- public void testDB(){
- try{
- // Add data
- UserInfo userinfo = new UserInfo();
- userinfo.setUserLoginId("Test");
- userinfo.setUserName("Test");
- commonClassDao.save(userinfo);
- OnapName onapName = new OnapName();
- onapName.setOnapName("Test");
- onapName.setUserCreatedBy(userinfo);
- onapName.setUserModifiedBy(userinfo);
- onapName.setModifiedDate(new Date());
- commonClassDao.save(onapName);
-
-
- List<Object> list = commonClassDao.getData(OnapName.class);
- assertTrue(list.size() == 1);
- logger.debug(list.size());
- logger.debug(list.get(0));
- }catch(Exception e){
- logger.debug("Exception Occured"+e);
- fail();
- }
+ public void testDB() {
+ // Add data
+ UserInfo userinfo = new UserInfo();
+ userinfo.setUserLoginId("Test");
+ userinfo.setUserName("Test");
+ commonClassDao.save(userinfo);
+ OnapName onapName = new OnapName();
+ onapName.setName("Test");
+ onapName.setUserCreatedBy(userinfo);
+ onapName.setUserModifiedBy(userinfo);
+ onapName.setModifiedDate(new Date());
+ commonClassDao.save(onapName);
+
+ List<Object> list = commonClassDao.getData(OnapName.class);
+ assertTrue(list.size() == 1);
+ logger.debug(list.size());
+ logger.debug(list.get(0));
}
@Test
@Transactional
@Rollback(true)
- public void testUser(){
- try{
- // Add data
- UserInfo userinfo = new UserInfo();
- String loginId_userName = "Test";
- userinfo.setUserLoginId(loginId_userName);
- userinfo.setUserName(loginId_userName);
- commonClassDao.save(userinfo);
-
-
- List<Object> dataCur = commonClassDao.getDataByQuery("from UserInfo", new SimpleBindings());
-
- assertEquals(1, dataCur.size());
- UserInfo cur = (UserInfo) dataCur.get(0);
- assertEquals(loginId_userName, cur.getUserLoginId());
- assertEquals(loginId_userName, cur.getUserName());
-
- assertFalse(dataCur.isEmpty());
-
- }catch(Exception e){
- logger.debug("Exception Occured"+e);
- fail();
- }
+ public void testUser() {
+ // Add data
+ UserInfo userinfo = new UserInfo();
+ String loginIdUserName = "Test";
+ userinfo.setUserLoginId(loginIdUserName);
+ userinfo.setUserName(loginIdUserName);
+ commonClassDao.save(userinfo);
+
+ List<Object> dataCur = commonClassDao.getDataByQuery("from UserInfo", new SimpleBindings());
+
+ assertEquals(1, dataCur.size());
+ UserInfo cur = (UserInfo) dataCur.get(0);
+ assertEquals(loginIdUserName, cur.getUserLoginId());
+ assertEquals(loginIdUserName, cur.getUserName());
+
+ assertFalse(dataCur.isEmpty());
}
@Test
@Transactional
@Rollback(true)
- public void getDataByQuery_DashboardController(){
- try{
- // Add data
- PolicyEntity pe = new PolicyEntity();
- String name = "TestPolicy";
- pe.setPolicyName(name);
- pe.setPolicyData("dummyData");
- pe.prePersist();
- pe.setScope("dummyScope");
- pe.setDescription("descr");
- pe.setDeleted(false);
- pe.setCreatedBy("Test");
- commonClassDao.save(pe);
-
- List<Object> dataCur = commonClassDao.getDataByQuery("from PolicyEntity", new SimpleBindings());
-
- assertTrue(1 == dataCur.size());
- assertTrue( dataCur.get(0) instanceof PolicyEntity);
- assertEquals( name, ((PolicyEntity)dataCur.get(0)).getPolicyName());
- assertEquals( pe, ((PolicyEntity)dataCur.get(0)));
-
-
- }catch(Exception e){
- logger.debug("Exception Occured"+e);
- fail();
- }
+ public void getDataByQuery_DashboardController() {
+ // Add data
+ PolicyEntity pe = new PolicyEntity();
+ String name = "TestPolicy";
+ pe.setPolicyName(name);
+ pe.setPolicyData("dummyData");
+ pe.prePersist();
+ pe.setScope("dummyScope");
+ pe.setDescription("descr");
+ pe.setDeleted(false);
+ pe.setCreatedBy("Test");
+ commonClassDao.save(pe);
+
+ List<Object> dataCur = commonClassDao.getDataByQuery("from PolicyEntity", new SimpleBindings());
+
+ assertTrue(1 == dataCur.size());
+ assertTrue(dataCur.get(0) instanceof PolicyEntity);
+ assertEquals(name, ((PolicyEntity) dataCur.get(0)).getPolicyName());
+ assertEquals(pe, (dataCur.get(0)));
}
@Test
@Transactional
@Rollback(true)
- public void getDataByQuery_AutoPushController(){
- try{
- // Add data
- PolicyVersion pv = new PolicyVersion();
- pv.setActiveVersion(2);
- pv.setPolicyName("myPname");
- pv.prePersist();
- pv.setCreatedBy("Test");
- pv.setModifiedBy("Test");
-
- PolicyVersion pv2 = new PolicyVersion();
- pv2.setActiveVersion(1);
- pv2.setPolicyName("test");
- pv2.prePersist();
- pv2.setCreatedBy("Test");
- pv2.setModifiedBy("Test");
-
- commonClassDao.save(pv);
- commonClassDao.save(pv2);
-
- String scope = "my";
- scope += "%";
- String query = "From PolicyVersion where policy_name like :scope and id > 0";
- SimpleBindings params = new SimpleBindings();
- params.put("scope", scope);
- List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
-
-
- assertTrue(1 == dataCur.size());
- assertEquals(pv, (PolicyVersion) dataCur.get(0));
-
- }catch(Exception e){
- logger.debug("Exception Occured"+e);
- fail();
- }
+ public void getDataByQuery_AutoPushController() {
+ // Add data
+ PolicyVersion pv = new PolicyVersion();
+ pv.setActiveVersion(2);
+ pv.setPolicyName("myPname");
+ pv.prePersist();
+ pv.setCreatedBy("Test");
+ pv.setModifiedBy("Test");
+
+ PolicyVersion pv2 = new PolicyVersion();
+ pv2.setActiveVersion(1);
+ pv2.setPolicyName("test");
+ pv2.prePersist();
+ pv2.setCreatedBy("Test");
+ pv2.setModifiedBy("Test");
+
+ commonClassDao.save(pv);
+ commonClassDao.save(pv2);
+
+ String scope = "my";
+ scope += "%";
+ String query = "From PolicyVersion where policy_name like :scope and id > 0";
+ SimpleBindings params = new SimpleBindings();
+ params.put("scope", scope);
+ List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
+
+ assertTrue(1 == dataCur.size());
+ assertEquals(pv, dataCur.get(0));
}
@Test
@Transactional
@Rollback(true)
- public void getDataByQuery_PolicyNotificationMail(){
- try{
- // Add data
- WatchPolicyNotificationTable watch = new WatchPolicyNotificationTable();
- String policyFileName = "banana";
- watch.setLoginIds("Test");
- watch.setPolicyName("bananaWatch");
- commonClassDao.save(watch);
-
- if(policyFileName.contains("/")){
- policyFileName = policyFileName.substring(0, policyFileName.indexOf("/"));
- policyFileName = policyFileName.replace("/", File.separator);
- }
- if(policyFileName.contains("\\")){
- policyFileName = policyFileName.substring(0, policyFileName.indexOf("\\"));
- policyFileName = policyFileName.replace("\\", "\\\\");
- }
-
-
- // Current Implementation
- policyFileName += "%";
- String query = "from WatchPolicyNotificationTable where policyName like:policyFileName";
- SimpleBindings params = new SimpleBindings();
- params.put("policyFileName", policyFileName);
- List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
-
- // Assertions
- assertTrue(dataCur.size() == 1);
- assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable);
- assertEquals(watch, (WatchPolicyNotificationTable) dataCur.get(0));
-
- }catch(Exception e){
- logger.debug("Exception Occured"+e);
- fail();
+ public void getDataByQuery_PolicyNotificationMail() {
+ // Add data
+ WatchPolicyNotificationTable watch = new WatchPolicyNotificationTable();
+ watch.setLoginIds("Test");
+
+ // Add data
+ UserInfo userinfo = new UserInfo();
+ String loginIdUserName = "Test";
+ userinfo.setUserLoginId(loginIdUserName);
+ userinfo.setUserName(loginIdUserName);
+ commonClassDao.save(userinfo);
+
+ List<Object> dataCur = commonClassDao.getDataByQuery("from UserInfo", new SimpleBindings());
+
+ assertEquals(1, dataCur.size());
+ UserInfo cur = (UserInfo) dataCur.get(0);
+ assertEquals(loginIdUserName, cur.getUserLoginId());
+ assertEquals(loginIdUserName, cur.getUserName());
+
+ assertFalse(dataCur.isEmpty());
+
+ watch.setPolicyName("bananaWatch");
+ commonClassDao.save(watch);
+
+ String policyFileName = "banana";
+ if (policyFileName.contains("/")) {
+ policyFileName = policyFileName.substring(0, policyFileName.indexOf("/"));
+ policyFileName = policyFileName.replace("/", File.separator);
+ }
+ if (policyFileName.contains("\\")) {
+ policyFileName = policyFileName.substring(0, policyFileName.indexOf("\\"));
+ policyFileName = policyFileName.replace("\\", "\\\\");
}
- }
+ // Current Implementation
+ policyFileName += "%";
+ String query = "from WatchPolicyNotificationTable where policyName like:policyFileName";
+ SimpleBindings params = new SimpleBindings();
+ params.put("policyFileName", policyFileName);
+ dataCur = commonClassDao.getDataByQuery(query, params);
+
+ // Assertions
+ assertTrue(dataCur.size() == 1);
+ assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable);
+ assertEquals(watch, dataCur.get(0));
+ }
@Test
@Transactional
@Rollback(true)
- public void getDataByQuery_PolicyController(){
- try{
- // Add data
- PolicyEntity pe = new PolicyEntity();
- String name = "actionDummy";
- pe.setPolicyName(name);
- pe.setPolicyData("dummyData");
- pe.prePersist();
- pe.setScope("dummyScope");
- pe.setDescription("descr");
- pe.setDeleted(false);
- pe.setCreatedBy("Test");
- commonClassDao.save(pe);
-
- String dbCheckName = "dummyScope:action";
- String[] splitDBCheckName = dbCheckName.split(":");
-
-
- // Current Implementation
- String query = "FROM PolicyEntity where policyName like :splitDBCheckName1 and scope = :splitDBCheckName0";
- SimpleBindings params = new SimpleBindings();
- params.put("splitDBCheckName1", splitDBCheckName[1] + "%");
- params.put("splitDBCheckName0", splitDBCheckName[0]);
- List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
-
- // Assertions
- assertTrue(dataCur.size() == 1);
- assertTrue(dataCur.get(0) instanceof PolicyEntity);
- assertEquals(pe, (PolicyEntity) dataCur.get(0));
-
- }catch(Exception e){
- logger.debug("Exception Occured"+e);
- fail();
- }
+ public void getDataByQuery_PolicyController() {
+ // Add data
+ PolicyEntity pe = new PolicyEntity();
+ String name = "actionDummy";
+ pe.setPolicyName(name);
+ pe.setPolicyData("dummyData");
+ pe.prePersist();
+ pe.setScope("dummyScope");
+ pe.setDescription("descr");
+ pe.setDeleted(false);
+ pe.setCreatedBy("Test");
+ commonClassDao.save(pe);
+
+ String dbCheckName = "dummyScope:action";
+ String[] splitDbCheckName = dbCheckName.split(":");
+
+ // Current Implementation
+ String query = "FROM PolicyEntity where policyName like :splitDBCheckName1 and scope = :splitDBCheckName0";
+ SimpleBindings params = new SimpleBindings();
+ params.put("splitDBCheckName1", splitDbCheckName[1] + "%");
+ params.put("splitDBCheckName0", splitDbCheckName[0]);
+ List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
+
+ // Assertions
+ assertTrue(dataCur.size() == 1);
+ assertTrue(dataCur.get(0) instanceof PolicyEntity);
+ assertEquals(pe, dataCur.get(0));
}
@Test
@Transactional
@Rollback(true)
- public void getDataByQuery_PolicyNotificationController(){
- try{
- // Add data
- WatchPolicyNotificationTable watch = new WatchPolicyNotificationTable();
- String finalName = "banana"; // Policy File Name
- String userId = "Test";
- watch.setLoginIds(userId);
- watch.setPolicyName(finalName);
- commonClassDao.save(watch);
-
-
- // Current Implementation
- String query = "from WatchPolicyNotificationTable where POLICYNAME = :finalName and LOGINIDS = :userId";
- SimpleBindings params = new SimpleBindings();
- params.put("finalName", finalName);
- params.put("userId", userId);
- List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
-
- // Assertions
- assertTrue(dataCur.size() == 1);
- assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable);
- assertEquals(watch, (WatchPolicyNotificationTable) dataCur.get(0) );
-
- }catch(Exception e){
- logger.debug("Exception Occured"+e);
- fail();
- }
+ public void getDataByQuery_PolicyNotificationController() {
+ // Add data
+ WatchPolicyNotificationTable watch = new WatchPolicyNotificationTable();
+ String finalName = "banana"; // Policy File Name
+ String userId = "Test";
+ watch.setLoginIds(userId);
+ watch.setPolicyName(finalName);
+ commonClassDao.save(watch);
+
+ // Current Implementation
+ String query = "from WatchPolicyNotificationTable where POLICYNAME = :finalName and LOGINIDS = :userId";
+ SimpleBindings params = new SimpleBindings();
+ params.put("finalName", finalName);
+ params.put("userId", userId);
+ List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
+
+ // Assertions
+ assertTrue(dataCur.size() == 1);
+ assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable);
+ assertEquals(watch, dataCur.get(0));
+
+ WatchPolicyNotificationTable table0 = new WatchPolicyNotificationTable();
+ WatchPolicyNotificationTable table1 = new WatchPolicyNotificationTable();
+ assertEquals(table0, table0);
+ assertEquals(table0, table1);
+ assertNotEquals(table0, null);
+ String helloString = "Hello";
+ Object helloObject = helloString;
+ assertNotEquals(table0, helloObject);
+
+ table0.setId(1);
+ assertNotEquals(table0, table1);
+ table1.setId(1);
+ assertEquals(table0, table1);
+
+ table0.setPolicyName("GoToOz");
+ assertNotEquals(table0, table1);
+ table1.setPolicyName("GoToOz");
+ assertEquals(table0, table1);
+ table1.setPolicyName(null);
+ assertNotEquals(table0, table1);
+ table0.setPolicyName(null);
+ assertEquals(table0, table1);
+ table1.setPolicyName("GoToOz");
+ assertNotEquals(table0, table1);
+ table0.setPolicyName("GoToOz");
+ assertEquals(table0, table1);
+ assertEquals(table0, table1);
+ table1.setPolicyName("InOz");
+ assertNotEquals(table0, table1);
+ table0.setPolicyName("InOz");
+ assertEquals(table0, table1);
+
+ table0.setLoginIds("Wizard");
+ assertNotEquals(table0, table1);
+ table1.setLoginIds("Wizard");
+ assertEquals(table0, table1);
+ table1.setLoginIds(null);
+ assertNotEquals(table0, table1);
+ table0.setLoginIds(null);
+ assertEquals(table0, table1);
+ table0.setLoginIds("Wizard");
+ assertNotEquals(table0, table1);
+ table1.setLoginIds("Wizard");
+ assertEquals(table0, table1);
+ table1.setLoginIds(null);
+ table1.setLoginIds("Witch");
+ assertNotEquals(table0, table1);
+ table0.setLoginIds("Witch");
+ assertEquals(table0, table1);
+
+ assertNotNull(table0.hashCode());
+ assertNotNull(table1.hashCode());
+ assertEquals(table0.hashCode(), table0.hashCode());
+
+ table0.setLoginIds("Witci");
+ assertNotEquals(table0, table1);
+ assertNotEquals(table0.hashCode(), table1.hashCode());
}
-
- /* Test for SQL Injection Protection
+ /*
+ * Test for SQL Injection Protection
*/
@Test
@Transactional
@Rollback(true)
- public void getDataByQuery_PolicyNotificationController_Injection(){
- try{
- // Add data
- WatchPolicyNotificationTable watch = new WatchPolicyNotificationTable();
- String userId = "Test";
- watch.setLoginIds(userId);
- watch.setPolicyName("banana");
- commonClassDao.save(watch);
-
- WatchPolicyNotificationTable watch2 = new WatchPolicyNotificationTable();
- watch2.setLoginIds(userId);
- watch2.setPolicyName("banana2");
- commonClassDao.save(watch2);
-
- // SQL Injection attempt
- String finalName = "banana' OR '1'='1";
-
-
- // Current Implementation
- String query = "from WatchPolicyNotificationTable where POLICYNAME = :finalName and LOGINIDS = :userId";
- SimpleBindings params = new SimpleBindings();
- params.put("finalName", finalName);
- params.put("userId", userId);
- List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
-
- // Assertions
- assertTrue(dataCur.size() <= 1);
-
- if(dataCur.size() >= 1){
- assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable);
- assertFalse(watch.equals((WatchPolicyNotificationTable) dataCur.get(0)));
- assertFalse(watch.equals((WatchPolicyNotificationTable) dataCur.get(0)));
- }
- }catch(Exception e){
- logger.debug("Exception Occured"+e);
- fail();
+ public void getDataByQuery_PolicyNotificationController_Injection() {
+ // Add data
+ WatchPolicyNotificationTable watch = new WatchPolicyNotificationTable();
+ String userId = "Test";
+ watch.setLoginIds(userId);
+ watch.setPolicyName("banana");
+ commonClassDao.save(watch);
+
+ WatchPolicyNotificationTable watch2 = new WatchPolicyNotificationTable();
+ watch2.setLoginIds(userId);
+ watch2.setPolicyName("banana2");
+ commonClassDao.save(watch2);
+
+ // SQL Injection attempt
+ String finalName = "banana' OR '1'='1";
+
+ // Current Implementation
+ String query = "from WatchPolicyNotificationTable where POLICYNAME = :finalName and LOGINIDS = :userId";
+ SimpleBindings params = new SimpleBindings();
+ params.put("finalName", finalName);
+ params.put("userId", userId);
+ List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
+
+ // Assertions
+ assertTrue(dataCur.size() <= 1);
+
+ if (dataCur.size() >= 1) {
+ assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable);
+ assertFalse(watch.equals(dataCur.get(0)));
+ assertFalse(watch.equals(dataCur.get(0)));
}
}
@Test
- public void testCommonClassDaoImplMethods(){
- try{
- UserInfo userInfo = new UserInfo();
- userInfo.setUserLoginId("TestID");
- userInfo.setUserName("Test");
- commonClassDao.save(userInfo);
- List<Object> data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
- assertTrue(data.size() == 1);
- UserInfo userInfoUpdate = (UserInfo) data.get(0);
- userInfoUpdate.setUserName("Test1");
- commonClassDao.update(userInfoUpdate);
- List<String> data1 = commonClassDao.getDataByColumn(UserInfo.class, "userLoginId");
- assertTrue(data1.size() == 1);
- UserInfo data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId:userName", "TestID:Test1");
- assertTrue("TestID".equals(data2.getUserLoginId()));
- List<Object> data3 = commonClassDao.checkDuplicateEntry("TestID:Test1", "userLoginId:userName", UserInfo.class);
- assertTrue(data3.size() == 1);
- PolicyRoles roles = new PolicyRoles();
- roles.setRole("admin");
- roles.setLoginId(userInfo);
- roles.setScope("test");
- commonClassDao.save(roles);
- List<PolicyRoles> roles1 = commonClassDao.getUserRoles();
- assertTrue(roles1.size() == 1);
- List<String> multipleData = new ArrayList<>();
- multipleData.add("TestID:Test1");
- List<Object> data4 = commonClassDao.getMultipleDataOnAddingConjunction(UserInfo.class, "userLoginId:userName", multipleData);
- assertTrue(data4.size() == 1);
- commonClassDao.delete(data2);
- }catch(Exception e){
- logger.debug("Exception Occured"+e);
- fail();
- }
+ public void testCommonClassDaoImplMethods() {
+ UserInfo userInfo = new UserInfo();
+ userInfo.setUserLoginId("TestID");
+ userInfo.setUserName("Test");
+ commonClassDao.save(userInfo);
+ List<Object> data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+ assertTrue(data.size() == 1);
+ UserInfo userInfoUpdate = (UserInfo) data.get(0);
+ userInfoUpdate.setUserName("Test1");
+ commonClassDao.update(userInfoUpdate);
+ List<String> data1 = commonClassDao.getDataByColumn(UserInfo.class, "userLoginId");
+ assertTrue(data1.size() == 1);
+ UserInfo data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId:userName",
+ "TestID:Test1");
+ assertTrue("TestID".equals(data2.getUserLoginId()));
+ List<Object> data3 = commonClassDao.checkDuplicateEntry("TestID:Test1", "userLoginId:userName", UserInfo.class);
+ assertTrue(data3.size() == 1);
+ PolicyRoles roles = new PolicyRoles();
+ roles.setRole("admin");
+ roles.setLoginId(userInfo);
+ roles.setScope("test");
+ commonClassDao.save(roles);
+ List<PolicyRoles> roles1 = commonClassDao.getUserRoles();
+ assertTrue(roles1.size() == 1);
+ List<String> multipleData = new ArrayList<>();
+ multipleData.add("TestID:Test1");
+ List<Object> data4 = commonClassDao.getMultipleDataOnAddingConjunction(UserInfo.class, "userLoginId:userName",
+ multipleData);
+ assertTrue(data4.size() == 1);
+ commonClassDao.delete(data2);
}
- @After
- public void deleteDB(){
- sessionFactory.close();
- server.stop();
+ @Test
+ public void testGetDataByIdparameters() {
+ UserInfo userInfo = new UserInfo();
+ userInfo.setUserLoginId("TestID");
+ userInfo.setUserName("Test");
+ commonClassDao.save(userInfo);
+ List<Object> data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+ assertTrue(data.size() == 1);
+ data = commonClassDao.getDataById(UserInfo.class, null, null);
+ assertNull(data);
+ data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", null);
+ assertNull(data);
+ data = commonClassDao.getDataById(UserInfo.class, null, "TestID:Test");
+ assertNull(data);
+ data = commonClassDao.getDataById(UserInfo.class, "userLoginIduserName", "TestID:Test");
+ assertNull(data);
+ data = commonClassDao.getDataById(UserInfo.class, "userLoginIduserName", "TestIDTest");
+ assertNull(data);
+ data = commonClassDao.getDataById(UserInfo.class, "userLoginId data2.getUserLoginId()" + ":userName",
+ "TestIDTest");
+ assertNull(data);
+ commonClassDao.delete(data);
+ }
+
+ @Test
+ public void testGetDataByColumnParameters() {
+ UserInfo userInfo = new UserInfo();
+ userInfo.setUserLoginId("TestID");
+ userInfo.setUserName("Test");
+ commonClassDao.save(userInfo);
+ List<String> data = commonClassDao.getDataByColumn(UserInfo.class, "userLoginId");
+ assertTrue(data.size() == 1);
+ data = commonClassDao.getDataByColumn(null, null);
+ assertNull(data);
+ data = commonClassDao.getDataByColumn(UserInfo.class, null);
+ assertNull(data);
+ data = commonClassDao.getDataByColumn(null, "userLoginId");
+ assertNull(data);
+ commonClassDao.delete(data);
+ }
+
+ @Test
+ public void testGetMultipleDataOnAddingConjunctionParameters() {
+ UserInfo userInfo = new UserInfo();
+ userInfo.setUserLoginId("TestID");
+ userInfo.setUserName("Test");
+ assertEquals("Test", userInfo.getIdentiferByUserId().getUri().getPath());
+ commonClassDao.save(userInfo);
+ List<String> multipleData = new ArrayList<>();
+ multipleData.add("TestID:Test1");
+ List<Object> data = commonClassDao.getMultipleDataOnAddingConjunction(UserInfo.class, "userLoginId:userName",
+ multipleData);
+ assertTrue(data.size() == 0);
+ data = commonClassDao.getMultipleDataOnAddingConjunction(null, null, null);
+ assertNull(data);
+ data = commonClassDao.getMultipleDataOnAddingConjunction(null, null, multipleData);
+ assertNull(data);
+ data = commonClassDao.getMultipleDataOnAddingConjunction(null, "userLoginId:userName", null);
+ assertNull(data);
+ data = commonClassDao.getMultipleDataOnAddingConjunction(null, "userLoginId:userName", multipleData);
+ assertNull(data);
+ data = commonClassDao.getMultipleDataOnAddingConjunction(UserInfo.class, null, null);
+ assertNull(data);
+ data = commonClassDao.getMultipleDataOnAddingConjunction(UserInfo.class, null, multipleData);
+ assertNull(data);
+ data = commonClassDao.getMultipleDataOnAddingConjunction(UserInfo.class, "userLoginId:userName", null);
+ assertNull(data);
+ commonClassDao.delete(data);
+ }
+ @Test
+ public void testCheckDuplicateEntryParameters() {
+ UserInfo userInfo = new UserInfo();
+ userInfo.setUserLoginId("TestID");
+ userInfo.setUserName("Test");
+ commonClassDao.save(userInfo);
+ List<Object> data = commonClassDao.checkDuplicateEntry("TestID:Test1", "userLoginId:userName", UserInfo.class);
+ assertTrue(data.size() == 0);
+ data = commonClassDao.checkDuplicateEntry(null, null, UserInfo.class);
+ assertNull(data);
+ data = commonClassDao.checkDuplicateEntry("userLoginId:userName", null, UserInfo.class);
+ assertNull(data);
+ data = commonClassDao.checkDuplicateEntry(null, "TestID:Test", UserInfo.class);
+ assertNull(data);
+ data = commonClassDao.checkDuplicateEntry("userLoginIduserName", "TestID:Test", UserInfo.class);
+ assertNull(data);
+ data = commonClassDao.checkDuplicateEntry("userLoginId:userName", "TestID:Test:zooby", UserInfo.class);
+ assertNull(data);
+ data = commonClassDao.checkDuplicateEntry("userLoginId:userName", "TestID", UserInfo.class);
+ assertNull(data);
+ commonClassDao.delete(data);
+ }
+
+ @Test
+ public void testGetEntityItemParameters() {
+ UserInfo userInfo = new UserInfo();
+ userInfo.setUserLoginId("TestID");
+ userInfo.setUserName("Test");
+ commonClassDao.save(userInfo);
+ List<Object> data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+ assertTrue(data.size() == 1);
+ UserInfo userInfoUpdate = (UserInfo) data.get(0);
+ userInfoUpdate.setUserName("Test1");
+ commonClassDao.update(userInfoUpdate);
+ List<String> data1 = commonClassDao.getDataByColumn(UserInfo.class, "userLoginId");
+ assertTrue(data1.size() == 1);
+ UserInfo data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId:userName",
+ "TestID:Test1");
+ assertTrue("TestID".equals(data2.getUserLoginId()));
+ data2 = (UserInfo) commonClassDao.getEntityItem(null, null, null);
+ assertNull(data2);
+ data2 = (UserInfo) commonClassDao.getEntityItem(null, null, "TestID:Test1");
+ assertNull(data2);
+ data2 = (UserInfo) commonClassDao.getEntityItem(null, "userLoginId:userName", null);
+ assertNull(data2);
+ data2 = (UserInfo) commonClassDao.getEntityItem(null, "userLoginId:userName", "TestID:Test1");
+ assertNull(data2);
+ data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, null, null);
+ assertNull(data2);
+ data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, null, "TestID:Test1");
+ assertNull(data2);
+ data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId:userName", null);
+ assertNull(data2);
+ data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginIduserName", "TestID:Test1");
+ assertNull(data2);
+ data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId:userName", "TestIDTest1");
+ assertNull(data2);
+ commonClassDao.delete(data);
+ commonClassDao.delete(data1);
+ commonClassDao.delete(data2);
}
+ @Test
+ public void testOtherMethods() {
+ UserInfo userInfo = new UserInfo();
+ userInfo.setUserLoginId("TestID");
+ userInfo.setUserName("Test");
+ commonClassDao.save(userInfo);
+ commonClassDao.deleteAll();
+ List<Object> data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+ assertTrue(data.size() == 1);
+
+ data = commonClassDao.checkExistingGroupListforUpdate(null, null);
+ assertTrue(data.size() == 0);
+
+ commonClassDao.updateClAlarms(null, null);
+ commonClassDao.updateClYaml(null, null);
+ data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+ assertTrue(data.size() == 1);
+ commonClassDao.update(null);
+ assertTrue(data.size() == 1);
+ commonClassDao.getData(null);
+ assertTrue(data.size() == 1);
+ commonClassDao.delete(data);
+ }
+
+ @Test
+ public void testUpdateQuery() {
+ UserInfo userInfo = new UserInfo();
+ userInfo.setUserLoginId("TestID");
+ userInfo.setUserName("Test");
+ commonClassDao.save(userInfo);
+ commonClassDao.updateQuery("SELECT * FROM userLoginId");
+ List<Object> data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+ assertTrue(data.size() == 1);
+
+ String query = "DELETE FROM org.onap.policy.rest.jpa.FunctionDefinition";
+ commonClassDao.updateQuery(query);
+ data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+ assertTrue(data.size() == 1);
+ commonClassDao.delete(data);
+ }
+
+ @Test
+ public void testGetDataByQueryParameters() {
+ // Add data
+ UserInfo userinfo = new UserInfo();
+ String loginIdUserName = "Test";
+ userinfo.setUserLoginId(loginIdUserName);
+ userinfo.setUserName(loginIdUserName);
+ commonClassDao.save(userinfo);
+
+ SimpleBindings bindings = new SimpleBindings();
+ bindings.put("usercode", 1L);
+
+ try {
+ commonClassDao.getDataByQuery("from UserInfo", bindings);
+ fail("test should throw an exception here");
+ } catch (Exception exc) {
+ assertTrue(exc.getMessage().contains("Parameter usercode does not exist as a named parameter"));
+ }
+ }
+
+ private void truncateAllTables() {
+ Session session = sessionFactory.openSession();
+ Transaction transaction = session.beginTransaction();
+ sessionFactory.getAllClassMetadata().forEach((tableName, x) -> {
+ Query query = session.createQuery("DELETE FROM " + tableName);
+ query.executeUpdate();
+ });
+ transaction.commit();
+ session.close();
+ }
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionBodyEntityTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionBodyEntityTest.java
index f8777d868..ab74d07f8 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionBodyEntityTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionBodyEntityTest.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,43 +26,46 @@ import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
+
import java.util.Date;
+
import org.junit.Test;
public class ActionBodyEntityTest {
- @Test
- public void testEntity() {
- // Set up test data
- String value = "testVal";
- Date date = new Date();
- ActionBodyEntity entity = new ActionBodyEntity();
- entity.prePersist();
- ActionBodyEntity entity2 = new ActionBodyEntity();
- ActionBodyEntity entity3 = new ActionBodyEntity();
+ @Test
+ public void testEntity() {
+ // Set up test data
+ String value = "testVal";
+ ActionBodyEntity entity = new ActionBodyEntity();
+ entity.prePersist();
+
+ // Test set and get
+ ActionBodyEntity entity0 = new ActionBodyEntity();
+ entity0.preUpdate();
+ entity0.setActionBody(value);
+ assertEquals(value, entity0.getActionBody());
+ entity0.setActionBodyName(value);
+ assertEquals(value, entity0.getActionBodyName());
+ entity0.setCreatedBy(value);
+ assertEquals(value, entity0.getCreatedBy());
+ entity0.setModifiedBy(value);
+ assertEquals(value, entity0.getModifiedBy());
- // Test set and get
- entity3.preUpdate();
- entity3.setActionBody(value);
- assertEquals(value, entity3.getActionBody());
- entity3.setActionBodyName(value);
- assertEquals(value, entity3.getActionBodyName());
- entity3.setCreatedBy(value);
- assertEquals(value, entity3.getCreatedBy());
- entity3.setModifiedBy(value);
- assertEquals(value, entity3.getModifiedBy());
- entity3.setModifiedDate(date);
- assertEquals(date, entity3.getModifiedDate());
- assertEquals(0, entity3.getVersion());
- assertNull(entity3.getCreatedDate());
- entity3.setDeleted(true);
- assertEquals(true, entity3.isDeleted());
- assertEquals(0, entity3.getActionBodyId());
+ Date date = new Date();
+ entity0.setModifiedDate(date);
+ assertEquals(date, entity0.getModifiedDate());
+ assertEquals(0, entity0.getVersion());
+ assertNull(entity0.getCreatedDate());
+ entity0.setDeleted(true);
+ assertEquals(true, entity0.isDeleted());
+ assertEquals(0, entity0.getActionBodyId());
- // Test equals method combinations
- assertEquals(false, entity.equals(null));
- assertEquals(true, entity.equals(entity));
- assertEquals(false, entity.equals(value));
- assertEquals(false, entity.equals(entity2));
- assertThat(entity.hashCode(), is(not(0)));
- }
+ // Test equals method combinations
+ assertEquals(false, entity.equals(null));
+ assertEquals(true, entity.equals(entity));
+ assertEquals(false, entity.equals((Object) value));
+ ActionBodyEntity entity1 = new ActionBodyEntity();
+ assertEquals(false, entity.equals(entity1));
+ assertThat(entity.hashCode(), is(not(0)));
+ }
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java
index 580b3e35d..501c7fd92 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJPATest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,10 +18,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import com.att.research.xacml.api.Identifier;
+
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
@@ -30,11 +38,16 @@ import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-public class ActionDictionaryJPATest {
+public class ActionDictionaryJpaTest {
- private static Logger logger = FlexLogger.getLogger(ActionDictionaryJPATest.class);
+ private static Logger logger = FlexLogger.getLogger(ActionDictionaryJpaTest.class);
private UserInfo userInfo;
+ /**
+ * Set up the test.
+ *
+ * @throws Exception on test errors
+ */
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
@@ -45,7 +58,7 @@ public class ActionDictionaryJPATest {
}
@Test
- public void testActionDictionary(){
+ public void testActionDictionary() {
ActionPolicyDict data = new ActionPolicyDict();
data.setId(1);
assertTrue(1 == data.getId());
@@ -66,48 +79,49 @@ public class ActionDictionaryJPATest {
data.prePersist();
data.preUpdate();
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!=null);
+ assertTrue(data.getUserModifiedBy() != null);
}
@Test
- public void testFunctionArgument(){
+ public void testFunctionArgument() {
FunctionArgument data = new FunctionArgument();
data.setArgIndex(1);
assertTrue(1 == data.getArgIndex());
data.setDatatypeBean(new Datatype());
- assertTrue(data.getDatatypeBean()!=null);
+ assertTrue(data.getDatatypeBean() != null);
data.setFunctionDefinition(new FunctionDefinition());
- assertTrue(data.getFunctionDefinition()!=null);
+ assertTrue(data.getFunctionDefinition() != null);
data.setId(1);
assertTrue(1 == data.getId());
- data.isBag();
- data.toString();
+ assertFalse(data.isBag());
+ assertEquals("FunctionArgument(id=1", data.toString().substring(0, 21));
data.setIsBag(1);
+ assertTrue(data.isBag());
assertTrue(1 == data.getIsBag());
new FunctionArgument(data);
}
@Test
- public void testFunctionDefinition(){
+ public void testFunctionDefinition() {
FunctionDefinition data = new FunctionDefinition();
data.setArgLb(1);
assertTrue(1 == data.getArgLb());
data.setArgUb(1);
assertTrue(1 == data.getArgUb());
data.setDatatypeBean(new Datatype());
- assertTrue(data.getDatatypeBean()!=null);
+ assertTrue(data.getDatatypeBean() != null);
data.setFunctionArguments(new ArrayList<>());
- assertTrue(data.getFunctionArguments()!=null);
- data.setHigherOrderArg_LB(1);
- assertTrue(1 == data.getHigherOrderArg_LB());
- data.setHigherOrderArg_UB(1);
- assertTrue(1 == data.getHigherOrderArg_UB());
+ assertTrue(data.getFunctionArguments() != null);
+ data.setHigherOrderArgLb(1);
+ assertTrue(1 == data.getHigherOrderArgLb());
+ data.setHigherOrderArgUb(1);
+ assertTrue(1 == data.getHigherOrderArgUb());
data.setId(1);
assertTrue(1 == data.getId());
data.setIsBagReturn(1);
@@ -118,15 +132,23 @@ public class ActionDictionaryJPATest {
assertTrue("Test".equals(data.getShortname()));
data.setXacmlid("Test");
assertTrue("Test".equals(data.getXacmlid()));
- data.toString();
- data.isBagReturn();
- data.isHigherOrder();
- data.addFunctionArgument(new FunctionArgument());
- data.removeFunctionArgument(new FunctionArgument());
+ assertTrue(data.toString().startsWith("FunctionDefinition(id=1"));
+ assertTrue(data.isBagReturn());
+ data.setIsBagReturn(0);
+ assertTrue(data.isHigherOrder());
+ assertFalse(data.isBagReturn());
+ data.setIsHigherOrder(0);
+ assertFalse(data.isHigherOrder());
+ FunctionArgument functionArgument = new FunctionArgument();
+ functionArgument.setId(12345);
+ data.addFunctionArgument(functionArgument);
+ assertEquals(12345, data.getFunctionArguments().iterator().next().getId());
+ data.removeFunctionArgument(functionArgument);
+ assertTrue(data.getFunctionArguments().isEmpty());
}
@Test
- public void testCategory(){
+ public void testCategory() {
Category data = new Category();
new Category(null);
data.setAttributes(new HashSet<>());
@@ -134,10 +156,9 @@ public class ActionDictionaryJPATest {
data.removeAttribute(new Attribute());
data.isStandard();
data.isCustom();
- Category.extractGrouping("urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject");
data.getIdentifer();
data.toString();
- assertTrue(data.getAttributes()!=null);
+ assertTrue(data.getAttributes() != null);
data.setGrouping("Test");
assertTrue("Test".equals(data.getGrouping()));
data.setId(1);
@@ -146,15 +167,42 @@ public class ActionDictionaryJPATest {
assertTrue("Test".equals(data.getShortName()));
data.setXacmlId("Test");
assertTrue("Test".equals(data.getXacmlId()));
+
+ data.setIsStandard(Category.STANDARD);
+ assertEquals(Category.STANDARD, data.getIsStandard());
+ assertTrue(data.isStandard());
+ assertFalse(data.isCustom());
+
+ data.setIsStandard(Category.CUSTOM);
+ assertEquals(Category.CUSTOM, data.getIsStandard());
+ assertFalse(data.isStandard());
+ assertTrue(data.isCustom());
+
+ Identifier categoryIdentifier = new DummyIdentifier();
+ Category data2 = new Category(categoryIdentifier,
+ "urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject", Category.STANDARD);
+ assertEquals(DummyIdentifier.class.getName(), data2.getIdentifer().stringValue());
+
+ Category data3 = new Category(categoryIdentifier,
+ "urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject");
+ assertEquals(DummyIdentifier.class.getName(), data3.getIdentifer().stringValue());
+
+ assertEquals("subject",
+ Category.extractGrouping("urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject"));
+ assertNull(Category.extractGrouping(null));
+ assertNull(Category.extractGrouping("some random string"));
+ assertNull(Category.extractGrouping(""));
+ assertEquals("intermediary-attribute", Category
+ .extractGrouping("urn:oasis:names:tc:xacml:1.0:attribute-category:intermediary-attribute"));
}
@Test
- public void testConstraintType(){
+ public void testConstraintType() {
ConstraintType data = new ConstraintType();
new ConstraintType("Test", "Test");
ConstraintType.getRangeTypes();
data.setAttributes(new HashSet<>());
- assertTrue(data.getAttributes()!=null);
+ assertTrue(data.getAttributes() != null);
data.setConstraintType("Test");
assertTrue("Test".equals(data.getConstraintType()));
data.setDescription("Test");
@@ -164,13 +212,13 @@ public class ActionDictionaryJPATest {
}
@Test
- public void testConstraintValue(){
+ public void testConstraintValue() {
ConstraintValue data = new ConstraintValue();
data.clone();
new ConstraintValue(new ConstraintValue());
- new ConstraintValue("Test","Test");
+ new ConstraintValue("Test", "Test");
data.setAttribute(new Attribute());
- assertTrue(data.getAttribute()!=null);
+ assertTrue(data.getAttribute() != null);
data.setId(1);
assertTrue(1 == data.getId());
data.setProperty("Test");
@@ -180,14 +228,20 @@ public class ActionDictionaryJPATest {
}
@Test
- public void testObadvice(){
- Obadvice data = new Obadvice();
+ public void testObadvice() {
new Obadvice();
new Obadvice("Test", "Test");
+ new Obadvice(new DummyIdentifier(), "Test");
+ Obadvice data = new Obadvice();
data.clone();
data.addObadviceExpression(new ObadviceExpression());
+ assertNotNull(data.clone());
data.removeObadviceExpression(new ObadviceExpression());
data.removeAllExpressions();
+ assertEquals(0, data.getObadviceExpressions().size());
+ data.setObadviceExpressions(null);
+ assertNull(data.getObadviceExpressions());
+ data.removeAllExpressions();
data.prePersist();
data.preUpdate();
data.setId(1);
@@ -201,29 +255,30 @@ public class ActionDictionaryJPATest {
data.setModifiedBy("Test");
assertTrue("Test".equals(data.getModifiedBy()));
data.setObadviceExpressions(new HashSet<>());
- assertTrue(data.getObadviceExpressions()!=null);
+ assertTrue(data.getObadviceExpressions() != null);
data.setType("Test");
assertTrue("Test".equals(data.getType()));
data.setXacmlId("Test");
assertTrue("Test".equals(data.getXacmlId()));
+
}
@Test
- public void testObadviceExpression(){
+ public void testObadviceExpression() {
ObadviceExpression data = new ObadviceExpression();
data.clone();
data.setAttribute(new Attribute());
- assertTrue(data.getAttribute()!=null);
+ assertTrue(data.getAttribute() != null);
data.setId(1);
assertTrue(1 == data.getId());
data.setObadvice(new Obadvice());
- assertTrue(data.getObadvice()!=null);
+ assertTrue(data.getObadvice() != null);
data.setType("Test");
assertTrue("Test".equals(data.getType()));
}
@Test
- public void testRuleAlgorithms(){
+ public void testRuleAlgorithms() {
RuleAlgorithms data = new RuleAlgorithms();
data.isCustom();
data.isStandard();
@@ -234,10 +289,17 @@ public class ActionDictionaryJPATest {
data.setXacmlId("Test");
assertTrue("Test".equals(data.getXacmlId()));
data.toString();
+
+ RuleAlgorithms ra0 = new RuleAlgorithms(new DummyIdentifier());
+ assertTrue(ra0.isStandard());
+ assertFalse(ra0.isCustom());
+ RuleAlgorithms ra1 = new RuleAlgorithms(new DummyIdentifier(), 'C');
+ assertFalse(ra1.isStandard());
+ assertTrue(ra1.isCustom());
}
@Test
- public void testAttributeAssignment(){
+ public void testAttributeAssignment() {
AttributeAssignment data = new AttributeAssignment();
data.setId(1);
assertTrue(1 == data.getId());
@@ -248,16 +310,16 @@ public class ActionDictionaryJPATest {
}
@Test
- public void testDatatype(){
+ public void testDatatype() {
Datatype data = new Datatype();
new Datatype(null);
new Datatype(1, new Datatype());
data.setArguments(new HashSet<>());
- assertTrue(data.getArguments()!=null);
+ assertTrue(data.getArguments() != null);
data.setAttributes(new HashSet<>());
- assertTrue(data.getAttributes()!=null);
+ assertTrue(data.getAttributes() != null);
data.setFunctions(new HashSet<>());
- assertTrue(data.getFunctions()!=null);
+ assertTrue(data.getFunctions() != null);
data.setId(1);
assertTrue(1 == data.getId());
data.setShortName("Test");
@@ -270,16 +332,29 @@ public class ActionDictionaryJPATest {
data.removeArgument(new FunctionArgument());
data.removeAttribute(new Attribute());
data.removeAttribute(new FunctionDefinition());
- assertTrue(data.getIdentifer()!=null);
- assertTrue(data.getIdentiferByShortName()!=null);
+ assertTrue(data.getIdentifer() != null);
+ assertTrue(data.getIdentiferByShortName() != null);
data.setIsStandard(Datatype.STANDARD);
assertTrue(data.isStandard());
data.setIsStandard(Datatype.CUSTOM);
assertTrue(data.isCustom());
+
+ data.setIsStandard(Category.STANDARD);
+ assertEquals(Category.STANDARD, data.getIsStandard());
+ assertTrue(data.isStandard());
+ assertFalse(data.isCustom());
+
+ data.setIsStandard(Category.CUSTOM);
+ assertEquals(Category.CUSTOM, data.getIsStandard());
+ assertFalse(data.isStandard());
+ assertTrue(data.isCustom());
+
+ Datatype data2 = new Datatype(new DummyIdentifier(), Datatype.STANDARD);
+ assertEquals(DummyIdentifier.class.getName(), data2.getIdentifer().stringValue());
}
@Test
- public void testPolicyAlgorithms(){
+ public void testPolicyAlgorithms() {
PolicyAlgorithms data = new PolicyAlgorithms();
data.setId(1);
assertTrue(1 == data.getId());
@@ -289,5 +364,13 @@ public class ActionDictionaryJPATest {
assertTrue("Test".equals(data.getXacmlId()));
data.setIsStandard(PolicyAlgorithms.STANDARD);
assertTrue(data.isStandard());
+ assertFalse(data.isCustom());
+ data.setIsStandard(PolicyAlgorithms.CUSTOM);
+ assertFalse(data.isStandard());
+ assertTrue(data.isCustom());
+
+ DummyIdentifier identifier = new DummyIdentifier();
+ assertNotNull(new PolicyAlgorithms(identifier));
+ assertNotNull(new PolicyAlgorithms(identifier, 'C'));
}
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BRMSDictionaryJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BrmsDictionaryJpaTest.java
index 9012cca28..abfef0c35 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BRMSDictionaryJPATest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BrmsDictionaryJpaTest.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
import static org.junit.Assert.assertTrue;
@@ -28,11 +30,19 @@ import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-public class BRMSDictionaryJPATest {
+/**
+ * The Class BrmsDictionaryJpaTest.
+ */
+public class BrmsDictionaryJpaTest {
- private static Logger logger = FlexLogger.getLogger(BRMSDictionaryJPATest.class);
+ private static Logger logger = FlexLogger.getLogger(BrmsDictionaryJpaTest.class);
private UserInfo userInfo;
+ /**
+ * Sets the up.
+ *
+ * @throws Exception the exception
+ */
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
@@ -42,9 +52,12 @@ public class BRMSDictionaryJPATest {
logger.info("setUp: exit");
}
+ /**
+ * Test BRMS param template.
+ */
@Test
- public void testBRMSParamTemplate(){
- BRMSParamTemplate data = new BRMSParamTemplate();
+ public void testBrmsParamTemplate() {
+ BrmsParamTemplate data = new BrmsParamTemplate();
data.prePersist();
data.setId(1);
assertTrue(1 == data.getId());
@@ -55,14 +68,17 @@ public class BRMSDictionaryJPATest {
data.setDescription("Test");
assertTrue("Test".equals(data.getDescription()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
}
+ /**
+ * Test BRMS controller.
+ */
@Test
- public void testBRMSController(){
- BRMSController data = new BRMSController();
+ public void testBrmsController() {
+ BrmsController data = new BrmsController();
data.preUpdate();
data.prePersist();
data.setId(1);
@@ -74,18 +90,21 @@ public class BRMSDictionaryJPATest {
data.setDescription("Test");
assertTrue("Test".equals(data.getDescription()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!=null);
+ assertTrue(data.getUserModifiedBy() != null);
}
+ /**
+ * Test BRMS dependency.
+ */
@Test
- public void testBRMSDependency(){
- BRMSDependency data = new BRMSDependency();
+ public void testrmsDependency() {
+ BrmsDependency data = new BrmsDependency();
data.preUpdate();
data.prePersist();
data.setId(1);
@@ -97,13 +116,13 @@ public class BRMSDictionaryJPATest {
data.setDescription("Test");
assertTrue("Test".equals(data.getDescription()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!=null);
+ assertTrue(data.getUserModifiedBy() != null);
}
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJpaTest.java
index 2274855e1..00fba8ca6 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJPATest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJpaTest.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
import static org.junit.Assert.assertTrue;
@@ -28,11 +30,19 @@ import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-public class ClosedLoopPolicyDictionaryJPATest {
+/**
+ * The Class ClosedLoopPolicyDictionaryJpaTest.
+ */
+public class ClosedLoopPolicyDictionaryJpaTest {
- private static Logger logger = FlexLogger.getLogger(ClosedLoopPolicyDictionaryJPATest.class);
+ private static Logger logger = FlexLogger.getLogger(ClosedLoopPolicyDictionaryJpaTest.class);
private UserInfo userInfo;
+ /**
+ * Sets the up.
+ *
+ * @throws Exception the exception
+ */
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
@@ -42,51 +52,60 @@ public class ClosedLoopPolicyDictionaryJPATest {
logger.info("setUp: exit");
}
+ /**
+ * Test VSCL action.
+ */
@Test
- public void testVSCLAction(){
- VSCLAction data = new VSCLAction();
+ public void testVsclAction() {
+ VsclAction data = new VsclAction();
data.preUpdate();
data.prePersist();
data.setId(1);
assertTrue(1 == data.getId());
- data.setVsclaction("Test");
- assertTrue("Test".equals(data.getVsclaction()));
+ data.setAction("Test");
+ assertTrue("Test".equals(data.getAction()));
data.setDescription("Test");
assertTrue("Test".equals(data.getDescription()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!= null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!= null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!= null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!= null);
+ assertTrue(data.getUserModifiedBy() != null);
}
+ /**
+ * Test VNF type.
+ */
@Test
- public void testVNFType(){
- VNFType data = new VNFType();
+ public void testVnfType() {
+ VnfType data = new VnfType();
data.preUpdate();
data.prePersist();
data.setId(1);
assertTrue(1 == data.getId());
- data.setVnftype("Test");
- assertTrue("Test".equals(data.getVnftype()));
+ data.setType("Test");
+ assertTrue("Test".equals(data.getType()));
data.setDescription("Test");
assertTrue("Test".equals(data.getDescription()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!= null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!= null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!= null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!= null);
+ assertTrue(data.getUserModifiedBy() != null);
}
+ /**
+ * Test PEP options.
+ */
@Test
- public void testPEPOptions(){
- PEPOptions data = new PEPOptions();
+ public void testPepOptions() {
+ PepOptions data = new PepOptions();
data.preUpdate();
data.prePersist();
data.setId(1);
@@ -96,17 +115,20 @@ public class ClosedLoopPolicyDictionaryJPATest {
data.setDescription("Test");
assertTrue("Test".equals(data.getDescription()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!= null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!= null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!= null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!= null);
+ assertTrue(data.getUserModifiedBy() != null);
}
+ /**
+ * Test varbind dictionary.
+ */
@Test
- public void testVarbindDictionary(){
+ public void testVarbindDictionary() {
VarbindDictionary data = new VarbindDictionary();
data.preUpdate();
data.prePersist();
@@ -116,20 +138,23 @@ public class ClosedLoopPolicyDictionaryJPATest {
assertTrue("Test".equals(data.getVarbindName()));
data.setVarbindDescription("Test");
assertTrue("Test".equals(data.getVarbindDescription()));
- data.setVarbindOID("Test");
- assertTrue("Test".equals(data.getVarbindOID()));
+ data.setVarbindOid("Test");
+ assertTrue("Test".equals(data.getVarbindOid()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!= null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!= null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!= null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!= null);
+ assertTrue(data.getUserModifiedBy() != null);
}
+ /**
+ * Test closed loop D 2 services.
+ */
@Test
- public void testClosedLoopD2Services(){
+ public void testClosedLoopD2Services() {
ClosedLoopD2Services data = new ClosedLoopD2Services();
data.preUpdate();
data.prePersist();
@@ -140,17 +165,20 @@ public class ClosedLoopPolicyDictionaryJPATest {
data.setDescription("Test");
assertTrue("Test".equals(data.getDescription()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!= null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!= null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!= null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!= null);
+ assertTrue(data.getUserModifiedBy() != null);
}
+ /**
+ * Test closed loop site.
+ */
@Test
- public void testClosedLoopSite(){
+ public void testClosedLoopSite() {
ClosedLoopSite data = new ClosedLoopSite();
data.preUpdate();
data.prePersist();
@@ -161,12 +189,12 @@ public class ClosedLoopPolicyDictionaryJPATest {
data.setDescription("Test");
assertTrue("Test".equals(data.getDescription()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!= null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!= null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!= null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!= null);
+ assertTrue(data.getUserModifiedBy() != null);
}
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJpaTest.java
index 230844a64..a6505a3f6 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJPATest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJpaTest.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,23 +18,34 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-public class CommonDictionaryJPATest {
+public class CommonDictionaryJpaTest {
- private static Logger logger = FlexLogger.getLogger(CommonDictionaryJPATest.class);
+ private static Logger logger = FlexLogger.getLogger(CommonDictionaryJpaTest.class);
private UserInfo userInfo;
+ /**
+ * Initiations for testing.
+ *
+ * @throws Exception on test initiation errors
+ */
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
@@ -44,16 +56,16 @@ public class CommonDictionaryJPATest {
}
@Test
- public void testAttribute(){
+ public void testAttribute() {
Attribute data = new Attribute();
data.setId(1);
assertTrue(1 == data.getId());
data.setCategoryBean(new Category());
- assertTrue(data.getCategoryBean()!=null);
+ assertTrue(data.getCategoryBean() != null);
data.setConstraintType(new ConstraintType());
- assertTrue(data.getConstraintType()!=null);
+ assertTrue(data.getConstraintType() != null);
data.setConstraintValues(new HashSet<>());
- assertTrue(data.getConstraintValues()!=null);
+ assertTrue(data.getConstraintValues() != null);
data.addConstraintValue(new ConstraintValue());
data.removeConstraintValue(new ConstraintValue());
data.removeAllConstraintValues();
@@ -68,7 +80,7 @@ public class CommonDictionaryJPATest {
data.setXacmlId("Test");
assertTrue("Test".equals(data.getXacmlId()));
data.setDatatypeBean(new Datatype());
- assertTrue(data.getDatatypeBean()!=null);
+ assertTrue(data.getDatatypeBean() != null);
data.setIsDesignator(true);
assertTrue(data.isDesignator());
data.setIssuer("Test");
@@ -80,59 +92,108 @@ public class CommonDictionaryJPATest {
data.setSelectorPath("Test");
assertTrue("Test".equals(data.getSelectorPath()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!=null);
+ assertTrue(data.getUserModifiedBy() != null);
+
+ ConstraintValue constraintValue = new ConstraintValue("Greeting", "Hello");
+ data.getConstraintValues().add(constraintValue);
+ assertEquals("Hello", data.getConstraintValues().iterator().next().getValue());
+
+ data.removeConstraintValue(constraintValue);
+ assertTrue(data.getConstraintValues().isEmpty());
+
+ data.addConstraintValue(constraintValue);
+ assertEquals("Hello", data.getConstraintValues().iterator().next().getValue());
+
+ data.setConstraintValues(null);
+ assertNull(data.getConstraintValues());
+
+ data.addConstraintValue(constraintValue);
+ assertEquals("Hello", data.getConstraintValues().iterator().next().getValue());
+
+ data.removeAllConstraintValues();
+ assertTrue(data.getConstraintValues().isEmpty());
+
+ data.setConstraintValues(null);
+ assertNull(data.getConstraintValues());
+
+ data.removeAllConstraintValues();
+ assertNull(data.getConstraintValues());
+
+ data.addConstraintValue(constraintValue);
+ assertEquals("Hello", data.getConstraintValues().iterator().next().getValue());
+
+ data.setConstraintValues(null);
+ assertNull(data.getConstraintValues());
+
+ Set<ConstraintValue> constraintValueSet = new LinkedHashSet<>();
+ constraintValueSet.add(constraintValue);
+
+ data.setConstraintValues(null);
+ assertNull(data.getConstraintValues());
+
+ data.setConstraintValues(constraintValueSet);
+ assertEquals("Hello", data.getConstraintValues().iterator().next().getValue());
+
+ Attribute data2 = new Attribute(data);
+ assertEquals("Hello", data2.getConstraintValues().iterator().next().getValue());
+
+ data.setIsDesignator(true);
+ assertTrue(data.isDesignator());
+
+ data.setIsDesignator(false);
+ assertFalse(data.isDesignator());
}
@Test
- public void testOnapName(){
+ public void testOnapName() {
OnapName data = new OnapName();
data.preUpdate();
data.prePersist();
data.setId(1);
assertTrue(1 == data.getId());
- data.setOnapName("Test");
- assertTrue("Test".equals(data.getOnapName()));
+ data.setName("Test");
+ assertTrue("Test".equals(data.getName()));
data.setDescription("Test");
assertTrue("Test".equals(data.getDescription()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!=null);
+ assertTrue(data.getUserModifiedBy() != null);
}
@Test
- public void testRiskType(){
+ public void testRiskType() {
RiskType data = new RiskType();
data.preUpdate();
data.prePersist();
data.setId(1);
assertTrue(1 == data.getId());
- data.setRiskName("Test");
- assertTrue("Test".equals(data.getRiskName()));
+ data.setName("Test");
+ assertTrue("Test".equals(data.getName()));
data.setDescription("Test");
assertTrue("Test".equals(data.getDescription()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!=null);
+ assertTrue(data.getUserModifiedBy() != null);
}
@Test
- public void testSafePolicyWarning(){
+ public void testSafePolicyWarning() {
SafePolicyWarning data = new SafePolicyWarning();
data.setId(1);
assertTrue(1 == data.getId());
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ConfigurationDataEntityTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ConfigurationDataEntityTest.java
index da5dd5005..a18fcbae3 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ConfigurationDataEntityTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ConfigurationDataEntityTest.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,47 +26,51 @@ import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
+
import java.util.Date;
+
import org.junit.Test;
public class ConfigurationDataEntityTest {
- @Test
- public void testEquals() {
- // Set up test data
- String value = "testVal";
- Date date = new Date();
- ConfigurationDataEntity entity = new ConfigurationDataEntity();
- entity.prePersist();
- ConfigurationDataEntity entity2 = new ConfigurationDataEntity();
- ConfigurationDataEntity entity3 = new ConfigurationDataEntity();
+ @Test
+ public void testEquals() {
+ // Set up test data
+ String value = "testVal";
+ ConfigurationDataEntity entity = new ConfigurationDataEntity();
+ entity.prePersist();
+ ConfigurationDataEntity entity3 = new ConfigurationDataEntity();
+
+ // Test set and get
+ entity3.preUpdate();
+ entity3.setConfigBody(value);
+ assertEquals(value, entity3.getConfigBody());
+ entity3.setCreatedBy(value);
+ assertEquals(value, entity3.getCreatedBy());
+ entity3.setModifiedBy(value);
+ assertEquals(value, entity3.getModifiedBy());
+
+ Date date = new Date();
+ entity3.setModifiedDate(date);
+ assertEquals(date, entity3.getModifiedDate());
+ assertEquals(0, entity3.getVersion());
+ assertNull(entity3.getCreatedDate());
+ entity3.setDeleted(true);
+ assertEquals(true, entity3.isDeleted());
+ entity3.setDescription(value);
+ assertEquals(value, entity3.getDescription());
+ entity3.setConfigType(value);
+ assertEquals(value, entity3.getConfigType());
+ entity3.setConfigurationName(value);
+ assertEquals(value, entity3.getConfigurationName());
+ assertEquals(0, entity3.getConfigurationDataId());
- // Test set and get
- entity3.preUpdate();
- entity3.setConfigBody(value);
- assertEquals(value, entity3.getConfigBody());
- entity3.setCreatedBy(value);
- assertEquals(value, entity3.getCreatedBy());
- entity3.setModifiedBy(value);
- assertEquals(value, entity3.getModifiedBy());
- entity3.setModifiedDate(date);
- assertEquals(date, entity3.getModifiedDate());
- assertEquals(0, entity3.getVersion());
- assertNull(entity3.getCreatedDate());
- entity3.setDeleted(true);
- assertEquals(true, entity3.isDeleted());
- entity3.setDescription(value);
- assertEquals(value, entity3.getDescription());
- entity3.setConfigType(value);
- assertEquals(value, entity3.getConfigType());
- entity3.setConfigurationName(value);
- assertEquals(value, entity3.getConfigurationName());
- assertEquals(0, entity3.getConfigurationDataId());
+ // Test method combinations
+ assertEquals(false, entity.equals(null));
+ assertEquals(true, entity.equals(entity));
+ assertEquals(false, entity.equals(value));
- // Test method combinations
- assertEquals(false, entity.equals(null));
- assertEquals(true, entity.equals(entity));
- assertEquals(false, entity.equals(value));
- assertEquals(false, entity.equals(entity2));
- assertThat(entity.hashCode(), is(not(0)));
- }
+ ConfigurationDataEntity entity2 = new ConfigurationDataEntity();
+ assertEquals(false, entity.equals(entity2));
+ assertThat(entity.hashCode(), is(not(0)));
+ }
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DecisionDictionaryJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DecisionDictionaryJpaTest.java
index b1fc69903..b664cf3ed 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DecisionDictionaryJPATest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DecisionDictionaryJpaTest.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
import static org.junit.Assert.assertTrue;
@@ -28,11 +30,19 @@ import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-public class DecisionDictionaryJPATest {
+/**
+ * The Class DecisionDictionaryJpaTest.
+ */
+public class DecisionDictionaryJpaTest {
- private static Logger logger = FlexLogger.getLogger(DecisionDictionaryJPATest.class);
+ private static Logger logger = FlexLogger.getLogger(DecisionDictionaryJpaTest.class);
private UserInfo userInfo;
+ /**
+ * Sets the up.
+ *
+ * @throws Exception the exception
+ */
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
@@ -42,8 +52,11 @@ public class DecisionDictionaryJPATest {
logger.info("setUp: exit");
}
+ /**
+ * Test decision settings.
+ */
@Test
- public void testDecisionSettings(){
+ public void testDecisionSettings() {
DecisionSettings data = new DecisionSettings();
data.setId(1);
assertTrue(1 == data.getId());
@@ -54,7 +67,7 @@ public class DecisionDictionaryJPATest {
data.setXacmlId("Test");
assertTrue("Test".equals(data.getXacmlId()));
data.setDatatypeBean(new Datatype());
- assertTrue(data.getDatatypeBean()!=null);
+ assertTrue(data.getDatatypeBean() != null);
data.setIssuer("Test");
assertTrue("Test".equals(data.getIssuer()));
data.setMustBePresent(true);
@@ -62,17 +75,20 @@ public class DecisionDictionaryJPATest {
data.setPriority("Test");
assertTrue("Test".equals(data.getPriority()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!=null);
+ assertTrue(data.getUserModifiedBy() != null);
}
+ /**
+ * Test rainy day treatments.
+ */
@Test
- public void testRainyDayTreatments(){
+ public void testRainyDayTreatments() {
RainyDayTreatments data = new RainyDayTreatments();
data.setId(1);
assertTrue(1 == data.getId());
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DictionaryDataTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DictionaryDataTest.java
index 486d36442..1b4bb7114 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DictionaryDataTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DictionaryDataTest.java
@@ -5,6 +5,7 @@
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +24,7 @@
package org.onap.policy.rest.jpa;
import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
public class DictionaryDataTest {
@@ -34,7 +36,7 @@ public class DictionaryDataTest {
String value = "testData1";
// Set Data
- dictData.setId(1);;
+ dictData.setId(1);
dictData.setDictionaryDataByName(value);
dictData.setDictionaryName(value);
dictData.setDictionaryUrl(value);
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DummyIdentifier.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DummyIdentifier.java
new file mode 100644
index 000000000..bd88db29a
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DummyIdentifier.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.jpa;
+
+import com.att.research.xacml.api.Identifier;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * Dummy category identifier class.
+ */
+public class DummyIdentifier implements Identifier {
+
+ @Override
+ public String stringValue() {
+ return this.getClass().getName();
+ }
+
+ @Override
+ public URI getUri() {
+ try {
+ return new URI(this.getClass().getName());
+ } catch (URISyntaxException e) {
+ return null;
+ }
+ }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FWDictionaryJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FwDictionaryJpaTest.java
index b3b23e429..42df1c93d 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FWDictionaryJPATest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FwDictionaryJpaTest.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
import static org.junit.Assert.assertTrue;
@@ -28,11 +30,19 @@ import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-public class FWDictionaryJPATest {
+/**
+ * The Class FWDictionaryJPATest.
+ */
+public class FwDictionaryJpaTest {
- private static Logger logger = FlexLogger.getLogger(FWDictionaryJPATest.class);
+ private static Logger logger = FlexLogger.getLogger(FwDictionaryJpaTest.class);
private UserInfo userInfo;
+ /**
+ * Sets the up.
+ *
+ * @throws Exception the exception
+ */
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
@@ -42,8 +52,11 @@ public class FWDictionaryJPATest {
logger.info("setUp: exit");
}
+ /**
+ * Test action list.
+ */
@Test
- public void testActionList(){
+ public void testActionList() {
ActionList data = new ActionList();
data.setId(1);
assertTrue(1 == data.getId());
@@ -53,8 +66,11 @@ public class FWDictionaryJPATest {
assertTrue("Test".equals(data.getDescription()));
}
+ /**
+ * Test port list.
+ */
@Test
- public void testPortList(){
+ public void testPortList() {
PortList data = new PortList();
data.setId(1);
assertTrue(1 == data.getId());
@@ -64,8 +80,11 @@ public class FWDictionaryJPATest {
assertTrue("Test".equals(data.getDescription()));
}
+ /**
+ * Test protocol list.
+ */
@Test
- public void testProtocolList(){
+ public void testProtocolList() {
ProtocolList data = new ProtocolList();
data.setId(1);
assertTrue(1 == data.getId());
@@ -75,8 +94,11 @@ public class FWDictionaryJPATest {
assertTrue("Test".equals(data.getDescription()));
}
+ /**
+ * Test security zone.
+ */
@Test
- public void testSecurityZone(){
+ public void testSecurityZone() {
SecurityZone data = new SecurityZone();
data.setId(1);
assertTrue(1 == data.getId());
@@ -86,8 +108,11 @@ public class FWDictionaryJPATest {
assertTrue("Test".equals(data.getZoneValue()));
}
+ /**
+ * Test zone.
+ */
@Test
- public void testZone(){
+ public void testZone() {
Zone data = new Zone();
data.setId(1);
assertTrue(1 == data.getId());
@@ -97,8 +122,11 @@ public class FWDictionaryJPATest {
assertTrue("Test".equals(data.getZoneValue()));
}
+ /**
+ * Test address group.
+ */
@Test
- public void testAddressGroup(){
+ public void testAddressGroup() {
AddressGroup data = new AddressGroup();
data.setId(1);
assertTrue(1 == data.getId());
@@ -110,8 +138,11 @@ public class FWDictionaryJPATest {
assertTrue("Test".equals(data.getDescription()));
}
+ /**
+ * Test prefix list.
+ */
@Test
- public void testPrefixList(){
+ public void testPrefixList() {
PrefixList data = new PrefixList();
data.setId(1);
assertTrue(1 == data.getId());
@@ -123,8 +154,11 @@ public class FWDictionaryJPATest {
assertTrue("Test".equals(data.getDescription()));
}
+ /**
+ * Test FW dictionary list.
+ */
@Test
- public void testFWDictionaryList(){
+ public void testFwDictionaryList() {
FirewallDictionaryList data = new FirewallDictionaryList();
data.setId(1);
assertTrue(1 == data.getId());
@@ -138,9 +172,12 @@ public class FWDictionaryJPATest {
assertTrue("Test".equals(data.getServiceList()));
}
+ /**
+ * Test FW tag.
+ */
@Test
- public void testFWTag(){
- FWTag data = new FWTag();
+ public void testFwTag() {
+ FwTag data = new FwTag();
data.preUpdate();
data.prePersist();
data.setId(1);
@@ -152,18 +189,21 @@ public class FWDictionaryJPATest {
data.setTagValues("Test");
assertTrue("Test".equals(data.getTagValues()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!=null);
+ assertTrue(data.getUserModifiedBy() != null);
}
+ /**
+ * Test FW tag picker.
+ */
@Test
- public void testFWTagPicker(){
- FWTagPicker data = new FWTagPicker();
+ public void testFwTagPicker() {
+ FwTagPicker data = new FwTagPicker();
data.preUpdate();
data.prePersist();
data.setId(1);
@@ -177,17 +217,20 @@ public class FWDictionaryJPATest {
data.setTagValues("Test");
assertTrue("Test".equals(data.getTagValues()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!=null);
+ assertTrue(data.getUserModifiedBy() != null);
}
+ /**
+ * Test service list.
+ */
@Test
- public void testServiceList(){
+ public void testServiceList() {
ServiceList data = new ServiceList();
data.setId(1);
assertTrue(1 == data.getId());
@@ -197,16 +240,19 @@ public class FWDictionaryJPATest {
assertTrue("Test".equals(data.getServiceDescription()));
data.setServiceType("Test");
assertTrue("Test".equals(data.getServiceType()));
- data.setServiceTransProtocol("Test");
- assertTrue("Test".equals(data.getServiceTransProtocol()));
+ data.setServiceTransportProtocol("Test");
+ assertTrue("Test".equals(data.getServiceTransportProtocol()));
data.setServiceAppProtocol("Test");
assertTrue("Test".equals(data.getServiceAppProtocol()));
data.setServicePorts("Test");
assertTrue("Test".equals(data.getServicePorts()));
}
+ /**
+ * Test term list.
+ */
@Test
- public void testTermList(){
+ public void testTermList() {
TermList data = new TermList();
data.preUpdate();
data.prePersist();
@@ -215,15 +261,15 @@ public class FWDictionaryJPATest {
data.setTermName("Test");
assertTrue("Test".equals(data.getTermName()));
data.setDescription("Test");
- assertTrue("Test".equals(data.getTermDescription()));
- data.setFromZones("Test");
+ assertTrue("Test".equals(data.getDescription()));
+ data.setFromZone("Test");
assertTrue("Test".equals(data.getFromZone()));
- data.setToZones("Test");
+ data.setToZone("Test");
assertTrue("Test".equals(data.getToZone()));
- data.setSrcIPList("Test");
- assertTrue("Test".equals(data.getSrcIPList()));
- data.setDestIPList("Test");
- assertTrue("Test".equals(data.getDestIPList()));
+ data.setSrcIpList("Test");
+ assertTrue("Test".equals(data.getSrcIpList()));
+ data.setDestIpList("Test");
+ assertTrue("Test".equals(data.getDestIpList()));
data.setProtocolList("Test");
assertTrue("Test".equals(data.getProtocolList()));
data.setPortList("Test");
@@ -235,17 +281,20 @@ public class FWDictionaryJPATest {
data.setAction("Test");
assertTrue("Test".equals(data.getAction()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
+ assertTrue(data.getModifiedDate() != null);
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!=null);
+ assertTrue(data.getUserModifiedBy() != null);
}
+ /**
+ * Test group service list.
+ */
@Test
- public void testGroupServiceList(){
+ public void testGroupServiceList() {
GroupServiceList data = new GroupServiceList();
data.setId(1);
assertTrue(1 == data.getId());
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/GetterSetterToStringTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/GetterSetterToStringTest.java
new file mode 100644
index 000000000..62d486c63
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/GetterSetterToStringTest.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.jpa;
+
+import com.openpojo.reflection.filters.FilterClassName;
+import com.openpojo.reflection.filters.FilterPackageInfo;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+
+import org.junit.Test;
+import org.onap.policy.common.utils.test.ToStringTester;
+
+/**
+ * Class to perform unit testing of POJOs.
+ */
+public class GetterSetterToStringTest {
+ private static final String POJO_PACKAGE = "org.onap.policy.rest.jpa";
+
+ @Test
+ public void testPdpModels() {
+ // @formatter:off
+ final Validator validator =
+ ValidatorBuilder.create()
+ .with(new ToStringTester())
+ .with(new SetterTester())
+ .with(new GetterTester())
+ .build();
+
+ // exclude Test classes and PdpMessage
+ validator.validate(
+ POJO_PACKAGE,
+ new FilterPackageInfo(),
+ new FilterClassName("^((?!Test$).)*$")
+ );
+ // @formatter:on
+ }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJpaTest.java
index 548e3fc84..174d63506 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJPATest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJpaTest.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,8 +18,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
@@ -26,11 +29,19 @@ import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-public class MicroServiceDictionaryJPATest {
+/**
+ * The Class MicroServiceDictionaryJpaTest.
+ */
+public class MicroServiceDictionaryJpaTest {
- private static Logger logger = FlexLogger.getLogger(MicroServiceDictionaryJPATest.class);
+ private static Logger logger = FlexLogger.getLogger(MicroServiceDictionaryJpaTest.class);
private UserInfo userInfo;
+ /**
+ * Sets the up.
+ *
+ * @throws Exception the exception
+ */
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
@@ -40,9 +51,12 @@ public class MicroServiceDictionaryJPATest {
logger.info("setUp: exit");
}
+ /**
+ * Test DCAE users.
+ */
@Test
- public void testDCAEUsers(){
- DCAEUsers data = new DCAEUsers();
+ public void testDcaeUsers() {
+ DcaeUsers data = new DcaeUsers();
data.setId(1);
assertTrue(1 == data.getId());
data.setName("Test");
@@ -51,9 +65,12 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getDescriptionValue()));
}
+ /**
+ * Test DCA euuid.
+ */
@Test
- public void testDCAEuuid(){
- DCAEuuid data = new DCAEuuid();
+ public void testDcaeUuid() {
+ DcaeUuid data = new DcaeUuid();
data.setId(1);
assertTrue(1 == data.getId());
data.setName("Test");
@@ -62,30 +79,39 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getDescription()));
}
+ /**
+ * Test MS config name.
+ */
@Test
- public void testMSConfigName(){
+ public void testMsConfigName() {
MicroServiceConfigName data = new MicroServiceConfigName();
data.setId(1);
assertTrue(1 == data.getId());
data.setName("Test");
assertTrue("Test".equals(data.getName()));
- data.setDescriptionValue("Test");
- assertTrue("Test".equals(data.getDescriptionValue()));
+ data.setDescription("Test");
+ assertTrue("Test".equals(data.getDescription()));
}
+ /**
+ * Test MS config location.
+ */
@Test
- public void testMSConfigLocation(){
+ public void testMsConfigLocation() {
MicroServiceLocation data = new MicroServiceLocation();
data.setId(1);
assertTrue(1 == data.getId());
data.setName("Test");
assertTrue("Test".equals(data.getName()));
- data.setDescriptionValue("Test");
- assertTrue("Test".equals(data.getDescriptionValue()));
+ data.setDescription("Test");
+ assertTrue("Test".equals(data.getDescription()));
}
+ /**
+ * Test MS models.
+ */
@Test
- public void testMSModels(){
+ public void testMsModels() {
MicroServiceModels data = new MicroServiceModels();
data.setId(1);
assertTrue(1 == data.getId());
@@ -101,18 +127,22 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getAnnotation()));
data.setAttributes("Test");
assertTrue("Test".equals(data.getAttributes()));
- data.setRef_attributes("Test");
- assertTrue("Test".equals(data.getRef_attributes()));
+ data.setRefAttributes("Test");
+ assertTrue("Test".equals(data.getRefAttributes()));
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
- data.setSub_attributes("Test");
- assertTrue("Test".equals(data.getSub_attributes()));
+ assertTrue(data.getUserCreatedBy() != null);
+ data.setSubAttributes("Test");
+ assertTrue("Test".equals(data.getSubAttributes()));
data.setVersion("Test");
assertTrue("Test".equals(data.getVersion()));
+ assertFalse(data.isDecisionModel());
}
+ /**
+ * Test MS attribute dictionary.
+ */
@Test
- public void testMSAttributeDictionary(){
+ public void testMsAttributeDictionary() {
MicroServiceAttribute data = new MicroServiceAttribute();
data.setId(1);
assertTrue(1 == data.getId());
@@ -124,52 +154,67 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getModelName()));
}
+ /**
+ * Test policy scope service.
+ */
@Test
- public void testPolicyScopeService(){
+ public void testPolicyScopeService() {
PolicyScopeService data = new PolicyScopeService();
data.setId(1);
assertTrue(1 == data.getId());
data.setName("Test");
assertTrue("Test".equals(data.getName()));
- data.setDescriptionValue("Test");
- assertTrue("Test".equals(data.getDescriptionValue()));
+ data.setDescription("Test");
+ assertTrue("Test".equals(data.getDescription()));
}
+ /**
+ * Test policy scope resource.
+ */
@Test
- public void testPolicyScopeResource(){
+ public void testPolicyScopeResource() {
PolicyScopeResource data = new PolicyScopeResource();
data.setId(1);
assertTrue(1 == data.getId());
data.setName("Test");
assertTrue("Test".equals(data.getName()));
- data.setDescriptionValue("Test");
- assertTrue("Test".equals(data.getDescriptionValue()));
+ data.setDescription("Test");
+ assertTrue("Test".equals(data.getDescription()));
}
+ /**
+ * Test policy scope type.
+ */
@Test
- public void testPolicyScopeType(){
+ public void testPolicyScopeType() {
PolicyScopeType data = new PolicyScopeType();
data.setId(1);
assertTrue(1 == data.getId());
data.setName("Test");
assertTrue("Test".equals(data.getName()));
- data.setDescriptionValue("Test");
- assertTrue("Test".equals(data.getDescriptionValue()));
+ data.setDescription("Test");
+ assertTrue("Test".equals(data.getDescription()));
}
+ /**
+ * Test policy scope closed loop.
+ */
@Test
- public void testPolicyScopeClosedLoop(){
+ public void testPolicyScopeClosedLoop() {
PolicyScopeClosedLoop data = new PolicyScopeClosedLoop();
data.setId(1);
assertTrue(1 == data.getId());
data.setName("Test");
assertTrue("Test".equals(data.getName()));
- data.setDescriptionValue("Test");
- assertTrue("Test".equals(data.getDescriptionValue()));
+ data.setDescription("Test");
+ assertTrue("Test".equals(data.getDescription()));
}
+ /**
+ * Test policy scope group policy scope list.
+ */
@Test
- public void testPolicyScopeGroupPolicyScopeList(){
+ public void testPolicyScopeGroupPolicyScopeList() {
GroupPolicyScopeList data = new GroupPolicyScopeList();
data.setId(1);
assertTrue(1 == data.getId());
@@ -181,8 +226,11 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getGroupList()));
}
+ /**
+ * Test closed loops.
+ */
@Test
- public void testClosedLoops(){
+ public void testClosedLoops() {
ClosedLoops data = new ClosedLoops();
data.setId(1);
assertTrue(1 == data.getId());
@@ -194,9 +242,12 @@ public class MicroServiceDictionaryJPATest {
assertTrue("Test".equals(data.getYaml()));
}
+ /**
+ * Test VM type.
+ */
@Test
- public void testVMType(){
- VMType data = new VMType();
+ public void testVmType() {
+ VmType data = new VmType();
data.setId(1);
assertTrue(1 == data.getId());
data.setName("Test");
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaultsTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaultsTest.java
index 62452dcb0..cbccc3b96 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaultsTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroserviceHeaderdeFaultsTest.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,33 +22,34 @@
package org.onap.policy.rest.jpa;
import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
public class MicroserviceHeaderdeFaultsTest {
- @Test
- public void testHeader() {
- // Set up test data
- String value = "testVal";
- MicroserviceHeaderdeFaults header = new MicroserviceHeaderdeFaults();
- header.prePersist();
- header.preUpdate();
+ @Test
+ public void testHeader() {
+ // Set up test data
+ String value = "testVal";
+ MicroserviceHeaderdeFaults header = new MicroserviceHeaderdeFaults();
+ header.prePersist();
+ header.preUpdate();
- // Set data
- header.setGuard(value);
- header.setId(1);
- header.setModelName(value);
- header.setOnapName(value);
- header.setPriority(value);
- header.setRiskLevel(value);
- header.setRiskType(value);
+ // Set data
+ header.setGuard(value);
+ header.setId(1);
+ header.setModelName(value);
+ header.setOnapName(value);
+ header.setPriority(value);
+ header.setRiskLevel(value);
+ header.setRiskType(value);
- // Test gets
- assertEquals(value, header.getGuard());
- assertEquals(1, header.getId());
- assertEquals(value, header.getModelName());
- assertEquals(value, header.getOnapName());
- assertEquals(value, header.getPriority());
- assertEquals(value, header.getRiskLevel());
- assertEquals(value, header.getRiskType());
- }
+ // Test gets
+ assertEquals(value, header.getGuard());
+ assertEquals(1, header.getId());
+ assertEquals(value, header.getModelName());
+ assertEquals(value, header.getOnapName());
+ assertEquals(value, header.getPriority());
+ assertEquals(value, header.getRiskLevel());
+ assertEquals(value, header.getRiskType());
+ }
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/OptimizationModelsJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/OptimizationModelsJpaTest.java
index 243cb5106..81481e191 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/OptimizationModelsJPATest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/OptimizationModelsJpaTest.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
import static org.junit.Assert.assertTrue;
@@ -26,11 +28,19 @@ import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-public class OptimizationModelsJPATest {
+/**
+ * The Class OptimizationModelsJpaTest.
+ */
+public class OptimizationModelsJpaTest {
- private static Logger logger = FlexLogger.getLogger(OptimizationModelsJPATest.class);
+ private static Logger logger = FlexLogger.getLogger(OptimizationModelsJpaTest.class);
private UserInfo userInfo;
+ /**
+ * Sets the up.
+ *
+ * @throws Exception the exception
+ */
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
@@ -40,8 +50,11 @@ public class OptimizationModelsJPATest {
logger.info("setUp: exit");
}
+ /**
+ * Test ms models.
+ */
@Test
- public void testMSModels(){
+ public void testMsModels() {
OptimizationModels data = new OptimizationModels();
data.setId(1);
assertTrue(1 == data.getId());
@@ -60,12 +73,11 @@ public class OptimizationModelsJPATest {
data.setRefattributes("Test");
assertTrue("Test".equals(data.getRefattributes()));
data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
+ assertTrue(data.getUserCreatedBy() != null);
data.setSubattributes("Test");
assertTrue("Test".equals(data.getSubattributes()));
data.setVersion("Test");
assertTrue("Test".equals(data.getVersion()));
}
-
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PIPConfigurationTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PIPConfigurationTest.java
deleted file mode 100644
index 1a4c2756b..000000000
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PIPConfigurationTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-REST
- * ================================================================================
- * Copyright (C) 2018 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.rest.jpa;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-import org.junit.Test;
-import com.att.research.xacml.api.pip.PIPException;
-import com.att.research.xacml.util.XACMLProperties;
-
-public class PIPConfigurationTest {
- @Test
- public void testConfig() throws PIPException {
- String value = "testVal";
- String id = "1";
- PIPConfigParam param = new PIPConfigParam();
- param.setParamName(value);
- param.setParamValue(value);
- Set<PIPConfigParam> params = new HashSet<PIPConfigParam>();
- PIPResolver resolver = new PIPResolver();
- resolver.setClassname(value);
- resolver.setName(value);
- params.add(param);
- Set<PIPResolver> resolvers = new HashSet<PIPResolver>();
- resolvers.add(resolver);
- Properties props = new Properties();
- props.setProperty(id + ".classname", value);
- props.setProperty(XACMLProperties.PROP_PIP_ENGINES, id);
- PIPType type = new PIPType();
- Date date = new Date();
-
- // Test constructors
- PIPConfiguration config = new PIPConfiguration();
- assertNotNull(config);
- config.setPipconfigParams(params);
- config.setPipresolvers(resolvers);
- PIPConfiguration config2 = new PIPConfiguration(config, value);
- assertNotNull(config2);
- config2.prePersist();
- config2.preUpdate();
- PIPConfiguration config3 = new PIPConfiguration(id, props);
- assertNotNull(config3);
- PIPConfiguration config4 = new PIPConfiguration(id, props, value);
- assertNotNull(config4);
-
- // Test set and get
- config.setId(1);
- assertEquals(1, config.getId());
- config.setDescription(value);
- assertEquals(value, config.getDescription());
- config.setName(id);
- assertEquals(id, config.getName());
- config.setClassname(value);
- assertEquals(value, config.getClassname());
- config.setIssuer(value);
- assertEquals(value, config.getIssuer());
- config.setReadOnly(true);
- assertEquals('1', config.getReadOnly());
- config.setReadOnly('0');
- assertEquals('0', config.getReadOnly());
- assertEquals(false, config.isReadOnly());
- config.setRequiresResolvers('t');
- assertEquals('t', config.getRequiresResolvers());
- config.setReadOnly(false);
- assertEquals('0', config.getReadOnly());
- config.setPiptype(type);
- assertEquals(type, config.getPiptype());
- config.setRequiresResolvers(false);
- assertEquals('0', config.getRequiresResolvers());
- config.setCreatedBy(value);
- assertEquals(value, config.getCreatedBy());
- config.setCreatedDate(date);
- assertEquals(date, config.getCreatedDate());
- config.setModifiedBy(value);
- assertEquals(value, config.getModifiedBy());
- config.setModifiedDate(date);
- assertEquals(date, config.getModifiedDate());
- config.setRequiresResolvers(true);
- assertEquals(true, config.requiresResolvers());
- assertEquals(8, config.getConfiguration(id).size());
- assertEquals(9, config.generateProperties(id).size());
-
- // Test remove and clear
- assertEquals(param, config.removePipconfigParam(param));
- config.clearConfigParams();
- assertEquals(0, config.getPipconfigParams().size());
- config.removePipresolver(resolver);
- assertEquals(0, config.getPipresolvers().size());
-
- // Test import
- assertEquals(1, PIPConfiguration.importPIPConfigurations(props).size());
- config.readProperties(id, props);
- assertEquals(id, config.getName());
-
- // Test toString
- String configString = config.toString().replaceAll("@[0-9a-f]*", "");
- assertEquals(323, configString.length());
- }
-}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PipConfigurationTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PipConfigurationTest.java
new file mode 100644
index 000000000..9bc95dc5f
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PipConfigurationTest.java
@@ -0,0 +1,196 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.rest.jpa;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import com.att.research.xacml.api.pip.PIPException;
+import com.att.research.xacml.std.pip.engines.StdConfigurableEngine;
+import com.att.research.xacml.util.XACMLProperties;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Properties;
+import java.util.Set;
+
+import org.junit.Test;
+
+public class PipConfigurationTest {
+ @Test
+ public void testConfig() throws PIPException {
+ String value = "testVal";
+ PipConfigParam param = new PipConfigParam();
+ param.setParamName(value);
+ param.setParamValue(value);
+ Set<PipConfigParam> params = new HashSet<PipConfigParam>();
+ PipResolver resolver = new PipResolver();
+ resolver.setClassname(value);
+ resolver.setName(value);
+ params.add(param);
+ Set<PipResolver> resolvers = new HashSet<PipResolver>();
+ resolvers.add(resolver);
+ Properties props = new Properties();
+
+ String id = "1";
+ props.setProperty(id + ".classname", value);
+ props.setProperty(XACMLProperties.PROP_PIP_ENGINES, id);
+
+ // Test constructors
+ PipConfiguration config = new PipConfiguration();
+ assertNotNull(config);
+ config.setPipconfigParams(params);
+ config.setPipresolvers(resolvers);
+ PipConfiguration config2 = new PipConfiguration(config, value);
+ assertNotNull(config2);
+ config2.prePersist();
+ config2.preUpdate();
+ PipConfiguration config3 = new PipConfiguration(id, props);
+ assertNotNull(config3);
+ PipConfiguration config4 = new PipConfiguration(id, props, value);
+ assertNotNull(config4);
+
+ // Test set and get
+ config.setId(1);
+ assertEquals(1, config.getId());
+ config.setDescription(value);
+ assertEquals(value, config.getDescription());
+ config.setName(id);
+ assertEquals(id, config.getName());
+ config.setClassname(value);
+ assertEquals(value, config.getClassname());
+ config.setIssuer(value);
+ assertEquals(value, config.getIssuer());
+ config.setReadOnlyFlag(true);
+ assertEquals('1', config.getReadOnly());
+ config.setReadOnly('0');
+ assertEquals('0', config.getReadOnly());
+ assertEquals(false, config.isReadOnly());
+ config.setRequiresResolvers('t');
+ assertEquals('t', config.getRequiresResolvers());
+ config.setReadOnlyFlag(false);
+ assertEquals('0', config.getReadOnly());
+
+ PipType type = new PipType();
+ config.setPiptype(type);
+ assertEquals(type, config.getPiptype());
+ config.setRequiresResolversFlag(false);
+ assertEquals('0', config.getRequiresResolvers());
+ config.setCreatedBy(value);
+ assertEquals(value, config.getCreatedBy());
+
+ Date date = new Date();
+ config.setCreatedDate(date);
+ assertEquals(date, config.getCreatedDate());
+ config.setModifiedBy(value);
+ assertEquals(value, config.getModifiedBy());
+ config.setModifiedDate(date);
+ assertEquals(date, config.getModifiedDate());
+ config.setRequiresResolversFlag(true);
+ assertTrue(config.requiresResolvers());
+ config.setRequiresResolversFlag(false);
+ assertFalse(config.requiresResolvers());
+ assertEquals(8, config.getConfiguration(id).size());
+ assertEquals(9, config.generateProperties(id).size());
+
+ // Test remove and clear
+ assertEquals(param, config.removePipconfigParam(param));
+ assertNull(config.removePipconfigParam(null));
+ config.clearConfigParams();
+ assertEquals(0, config.getPipconfigParams().size());
+ config.removePipresolver(resolver);
+ assertEquals(0, config.getPipresolvers().size());
+
+ assertEquals(param, config.addPipconfigParam(param));
+ config.clearConfigParams();
+ assertEquals(0, config.getPipconfigParams().size());
+ config.removePipresolver(resolver);
+ assertEquals(0, config.getPipresolvers().size());
+
+ // Test import
+ assertEquals(1, PipConfiguration.importPipConfigurations(props).size());
+ config.readProperties(id, props);
+ assertEquals(id, config.getName());
+
+ // Test toString
+ String configString = config.toString().replaceAll("@[0-9a-f]*", "");
+ assertEquals(322, configString.length());
+
+ assertEquals(0, PipConfiguration.importPipConfigurations(new Properties()).size());
+
+ Properties otherProperties = new Properties();
+ otherProperties.put(XACMLProperties.PROP_PIP_ENGINES, "");
+ assertEquals(0, PipConfiguration.importPipConfigurations(otherProperties).size());
+
+ otherProperties.put(XACMLProperties.PROP_PIP_ENGINES, "badvalue:evenworse");
+ assertEquals(0, PipConfiguration.importPipConfigurations(otherProperties).size());
+
+ // Test readProperties
+ props.setProperty(id + "." + StdConfigurableEngine.PROP_ISSUER, "himself");
+ props.setProperty(id + ".resolvers", "");
+ props.setProperty(id + ".resolver", "");
+ props.setProperty(id + ".anotherproperty", "");
+ config.readProperties(id, props);
+ assertEquals("himself", config.getIssuer());
+ assertEquals(49, config.getRequiresResolvers());
+
+ props.setProperty(id + ".resolvers", "aaa");
+ assertThatThrownBy(() -> config.readProperties(id, props)).hasMessage("PIP Engine defined without a classname");
+
+ props.setProperty(id + ".resolver.aaa.classname", "somewhere.over.the.Rainbow");
+ props.setProperty(id + ".resolver.aaa." + StdConfigurableEngine.PROP_NAME, "Dorothy");
+ props.setProperty(id + ".resolver.aaa." + StdConfigurableEngine.PROP_DESCRIPTION, "Oz");
+ props.setProperty(id + ".resolver.aaa." + StdConfigurableEngine.PROP_ISSUER, "Wizard");
+ props.setProperty(id + ".resolver.aaa.witch", "North");
+ config.readProperties(id, props);
+
+ PipResolver pipResolver = config.getPipresolvers().iterator().next();
+
+ assertEquals("somewhere.over.the.Rainbow", pipResolver.getClassname());
+ assertEquals("Dorothy", pipResolver.getName());
+ assertEquals("Oz", pipResolver.getDescription());
+ assertEquals("Wizard", pipResolver.getIssuer());
+
+ // Test getConfiguration
+ assertEquals(10, config.getConfiguration(null).size());
+ assertEquals(10, config.getConfiguration("kansas").size());
+ assertEquals(10, config.getConfiguration("kansas.").size());
+ config.setDescription(null);
+ assertEquals(9, config.getConfiguration(null).size());
+ config.setIssuer(null);
+ assertEquals(8, config.getConfiguration(null).size());
+ config.setPipresolvers(new LinkedHashSet<PipResolver>());
+ assertEquals(3, config.getConfiguration(null).size());
+
+ // Test generateProperties
+ assertEquals(4, config.generateProperties(null).size());
+ assertEquals(4, config.generateProperties("kansas").size());
+ assertEquals(4, config.generateProperties("kansas.").size());
+ config.setIssuer("");
+ assertEquals(4, config.generateProperties("kansas.").size());
+ }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PIPJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PipJpaTest.java
index 7421d79c9..2a5dff61f 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PIPJPATest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PipJpaTest.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,25 +18,33 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.jpa;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import com.att.research.xacml.api.pip.PIPException;
import java.util.Date;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.Properties;
+import java.util.Set;
import org.junit.Test;
-import com.att.research.xacml.api.pip.PIPException;
-
-public class PIPJPATest {
+public class PipJpaTest {
@Test
- public void testPIPConfigParam(){
- PIPConfigParam data = new PIPConfigParam();
- new PIPConfigParam("test");
- new PIPConfigParam(new PIPConfigParam());
+ public void testPipConfigParam() {
+ PipConfigParam data = new PipConfigParam();
+ new PipConfigParam("test");
+ new PipConfigParam(new PipConfigParam());
data.setId(1);
assertTrue(1 == data.getId());
data.setParamName("Test");
@@ -44,18 +53,20 @@ public class PIPJPATest {
assertTrue("Test".equals(data.getParamValue()));
data.setParamDefault("Test");
assertTrue("Test".equals(data.getParamDefault()));
- data.setPipconfiguration(new PIPConfiguration());
- assertTrue(data.getPipconfiguration()!=null);
- data.setRequired(true);
+ data.setPipconfiguration(new PipConfiguration());
+ assertTrue(data.getPipconfiguration() != null);
+ data.setRequiredFlag(true);
assertTrue(data.isRequired());
+ data.setRequiredFlag(false);
+ assertFalse(data.isRequired());
data.toString();
}
@Test
- public void testPIPResolverParam(){
- PIPResolverParam data = new PIPResolverParam();
- new PIPResolverParam("test");
- new PIPResolverParam(new PIPResolverParam());
+ public void testPipResolverParam() {
+ PipResolverParam data = new PipResolverParam();
+ new PipResolverParam("test");
+ new PipResolverParam(new PipResolverParam());
data.setId(1);
assertTrue(1 == data.getId());
data.setParamName("Test");
@@ -64,40 +75,42 @@ public class PIPJPATest {
assertTrue("Test".equals(data.getParamValue()));
data.setParamDefault("Test");
assertTrue("Test".equals(data.getParamDefault()));
- data.setPipresolver(new PIPResolver());
- assertTrue(data.getPipresolver()!=null);
+ data.setPipresolver(new PipResolver());
+ assertTrue(data.getPipresolver() != null);
data.setRequired(true);
assertTrue(data.isRequired());
+ data.setRequired(false);
+ assertFalse(data.isRequired());
data.toString();
}
@Test
- public void testPIPType(){
- PIPType data = new PIPType();
+ public void testPipType() {
+ PipType data = new PipType();
data.setId(1);
assertTrue(1 == data.getId());
data.setType("Test");
assertTrue("Test".equals(data.getType()));
data.setPipconfigurations(new HashSet<>());
- assertTrue(data.getPipconfigurations()!=null);
- data.addPipconfiguration(new PIPConfiguration());
- data.removePipconfiguration(new PIPConfiguration());
+ assertTrue(data.getPipconfigurations() != null);
+ data.addPipconfiguration(new PipConfiguration());
+ data.removePipconfiguration(new PipConfiguration());
data.setType("SQL");
- assertTrue(data.isSQL());
+ assertTrue(data.isSql());
data.setType("LDAP");
- assertTrue(data.isLDAP());
+ assertTrue(data.isLdap());
data.setType("CSV");
- assertTrue(data.isCSV());
+ assertTrue(data.isCsv());
data.setType("Hyper-CSV");
- assertTrue(data.isHyperCSV());
+ assertTrue(data.isHyperCsv());
data.setType("Custom");
assertTrue(data.isCustom());
}
@Test
- public void testPIPResolver(){
- PIPResolver data = new PIPResolver();
- new PIPResolver(new PIPResolver());
+ public void testPipResolver() {
+ PipResolver data = new PipResolver();
+ new PipResolver(new PipResolver());
data.prePersist();
data.preUpdate();
data.setId(1);
@@ -115,32 +128,50 @@ public class PIPJPATest {
data.setModifiedBy("Test");
assertTrue("Test".equals(data.getModifiedBy()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
- data.setPipconfiguration(new PIPConfiguration());
- assertTrue(data.getPipconfiguration()!=null);
+ assertTrue(data.getModifiedDate() != null);
+ data.setPipconfiguration(new PipConfiguration());
+ assertTrue(data.getPipconfiguration() != null);
data.setPipresolverParams(new HashSet<>());
- assertTrue(data.getPipresolverParams()!=null);
- data.addPipresolverParam(new PIPResolverParam());
- data.removePipresolverParam(new PIPResolverParam());
+ assertTrue(data.getPipresolverParams() != null);
+ data.addPipresolverParam(new PipResolverParam());
+ data.removePipresolverParam(new PipResolverParam());
+ assertNull(data.removePipresolverParam(null));
data.clearParams();
data.getConfiguration("test");
+ assertNotNull(data.getConfiguration("test."));
data.setReadOnly(true);
assertTrue(data.isReadOnly());
+ data.setReadOnly(false);
+ assertFalse(data.isReadOnly());
data.toString();
Properties properties = new Properties();
- data.generateProperties(properties,"test");
+ data.generateProperties(properties, "test");
try {
data.readProperties("test", properties);
} catch (PIPException e) {
fail();
}
+ data.setIssuer("");
+ assertEquals(4, data.getConfiguration("test").size());
+ data.generateProperties(properties, "test.");
+ assertEquals(4, data.getConfiguration("test").size());
+
+ Set<PipResolverParam> pipresolverParams = new LinkedHashSet<>();
+ PipResolverParam prp = new PipResolverParam();
+ prp.setParamName("Dorothy");
+ prp.setParamValue("Gale");
+ pipresolverParams.add(prp);
+ data.setPipresolverParams(pipresolverParams);
+ data.generateProperties(properties, "test");
+ assertEquals(5, data.getConfiguration("test").size());
+ assertEquals(5, new PipResolver(data).getConfiguration("test").size());
}
@Test
- public void testPIPConfiguration(){
- PIPConfiguration data = new PIPConfiguration();
+ public void testPipConfiguration() {
+ PipConfiguration data = new PipConfiguration();
data.prePersist();
data.preUpdate();
data.setId(1);
@@ -158,24 +189,24 @@ public class PIPJPATest {
data.setModifiedBy("Test");
assertTrue("Test".equals(data.getModifiedBy()));
data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
+ assertTrue(data.getCreatedDate() != null);
data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
+ assertTrue(data.getModifiedDate() != null);
try {
data.readProperties("test", data.generateProperties("test"));
} catch (PIPException e) {
fail();
}
- data.setPiptype(new PIPType());
- assertTrue(data.getPiptype()!=null);
+ data.setPiptype(new PipType());
+ assertTrue(data.getPiptype() != null);
data.setPipresolvers(new HashSet<>());
- assertTrue(data.getPipresolvers()!=null);
- data.addPipresolver(new PIPResolver());
- data.removePipresolver(new PIPResolver());
+ assertTrue(data.getPipresolvers() != null);
+ data.addPipresolver(new PipResolver());
+ data.removePipresolver(new PipResolver());
data.getConfiguration("test");
- data.setReadOnly(true);
+ data.setReadOnlyFlag(true);
assertTrue(data.isReadOnly());
- data.setRequiresResolvers(true);
+ data.setRequiresResolversFlag(true);
assertTrue(data.requiresResolvers());
data.toString();
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyAuditlogTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyAuditlogTest.java
index 15e28b142..1ae1cb3e2 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyAuditlogTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyAuditlogTest.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +22,9 @@
package org.onap.policy.rest.jpa;
import static org.junit.Assert.assertEquals;
+
import java.text.ParseException;
+
import org.junit.Test;
public class PolicyAuditlogTest {
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJPATest.java
deleted file mode 100644
index 706471281..000000000
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJPATest.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-REST
- * ================================================================================
- * Copyright (C) 2018 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.rest.jpa;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Date;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
-
-public class PolicyEntityJPATest {
-
- private static Logger logger = FlexLogger.getLogger(PolicyEntityJPATest.class);
- private UserInfo userInfo;
-
- @Before
- public void setUp() throws Exception {
- logger.info("setUp: Entering");
- userInfo = new UserInfo();
- userInfo.setUserLoginId("Test");
- userInfo.setUserName("Test");
- logger.info("setUp: exit");
- }
-
- @Test
- public void testPolicyGroupEntity(){
- PolicyGroupEntity data = new PolicyGroupEntity();
- data.setGroupKey(1);
- assertTrue(1 == data.getGroupKey());
- data.setPolicyid(1);
- assertTrue(1 == data.getPolicyid());
- }
-
- @Test
- public void testPolicyDBDaoEntity(){
- PolicyDBDaoEntity data = new PolicyDBDaoEntity();
- data.prePersist();
- data.preUpdate();
- data.setPolicyDBDaoUrl("Test");
- assertTrue("Test".equals(data.getPolicyDBDaoUrl()));
- data.setDescription("Test");
- assertTrue("Test".equals(data.getDescription()));
- assertTrue(data.getCreatedDate()!=null);
- assertTrue(data.getModifiedDate()!=null);
- data.setUsername("Test");
- assertTrue("Test".equals(data.getUsername()));
- data.setPassword("Test");
- assertTrue("Test".equals(data.getPassword()));
- }
-
- @Test
- public void testDatabaseLockEntity(){
- DatabaseLockEntity data = new DatabaseLockEntity();
- data.setKey(1);
- assertTrue(1 == data.getKey());
- }
-
- @Test
- public void testPolicyEntity(){
- PolicyEntity data = new PolicyEntity();
- data.prePersist();
- data.preUpdate();
- data.setPolicyName("Test");
- assertTrue("Test".equals(data.getPolicyName()));
- data.setDescription("Test");
- assertTrue("Test".equals(data.getDescription()));
- assertTrue(data.getCreatedDate()!=null);
- assertTrue(data.getModifiedDate()!=null);
- data.setPolicyData("Test");
- assertTrue("Test".equals(data.getPolicyData()));
- data.setConfigurationData(new ConfigurationDataEntity());
- assertTrue(data.getConfigurationData()!=null);
- data.setActionBodyEntity(new ActionBodyEntity());
- assertTrue(data.getActionBodyEntity()!=null);
- data.setScope("Test");
- assertTrue("Test".equals(data.getScope()));
- data.setCreatedBy("Test");
- assertTrue("Test".equals(data.getCreatedBy()));
- data.setModifiedBy("Test");
- assertTrue("Test".equals(data.getModifiedBy()));
- data.setDeleted(true);
- assertTrue(data.isDeleted());
- data.equals(new PolicyEntity());
- data.hashCode();
- }
-
- @Test
- public void testActionBodyEntity(){
- ActionBodyEntity data = new ActionBodyEntity();
- data.prePersist();
- data.preUpdate();
- data.setActionBodyName("Test");
- assertTrue("Test".equals(data.getActionBodyName()));
- data.setActionBody("Test");
- assertTrue("Test".equals(data.getActionBody()));
- data.setCreatedBy("Test");
- assertTrue("Test".equals(data.getCreatedBy()));
- data.setModifiedBy("Test");
- assertTrue("Test".equals(data.getModifiedBy()));
- data.setModifiedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
- assertTrue(data.getModifiedDate()!=null);
- data.setDeleted(true);
- assertTrue(data.isDeleted());
- assertTrue(data.getCreatedDate()!=null);
- assertTrue(data.getModifiedDate()!=null);
- data.equals(new ConfigurationDataEntity());
- data.hashCode();
- }
-
- @Test
- public void testConfigurationDataEntity(){
- ConfigurationDataEntity data = new ConfigurationDataEntity();
- data.prePersist();
- data.preUpdate();
- data.setConfigurationName("Test");
- assertTrue("Test".equals(data.getConfigurationName()));
- data.setConfigType("Test");
- assertTrue("Test".equals(data.getConfigType()));
- data.setConfigBody("Test");
- assertTrue("Test".equals(data.getConfigBody()));
- data.setCreatedBy("Test");
- assertTrue("Test".equals(data.getCreatedBy()));
- data.setDescription("Test");
- assertTrue("Test".equals(data.getDescription()));
- data.setModifiedBy("Test");
- assertTrue("Test".equals(data.getModifiedBy()));
- data.setModifiedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
- assertTrue(data.getModifiedDate()!=null);
- data.setDeleted(true);
- assertTrue(data.isDeleted());
- assertTrue(data.getCreatedDate()!=null);
- assertTrue(data.getModifiedDate()!=null);
- data.equals(new ConfigurationDataEntity());
- data.hashCode();
- }
-
- @Test
- public void testPdpEntity(){
- PdpEntity data = new PdpEntity();
- data.prePersist();
- data.preUpdate();
- data.setPdpId("Test");
- assertTrue("Test".equals(data.getPdpId()));
- data.setPdpName("Test");
- assertTrue("Test".equals(data.getPdpName()));
- data.setGroup(new GroupEntity());
- assertTrue(data.getGroup()!=null);
- data.setCreatedBy("Test");
- assertTrue("Test".equals(data.getCreatedBy()));
- data.setDescription("Test");
- assertTrue("Test".equals(data.getDescription()));
- data.setModifiedBy("Test");
- assertTrue("Test".equals(data.getModifiedBy()));
- data.setJmxPort(1);
- assertTrue(1 == data.getJmxPort());
- data.setDeleted(true);
- assertTrue(data.isDeleted());
- assertTrue(data.getCreatedDate()!=null);
- assertTrue(data.getModifiedDate()!=null);
- }
-
- @Test
- public void testGroupEntity(){
- GroupEntity data = new GroupEntity();
- data.prePersist();
- data.preUpdate();
- data.setGroupId("Test");
- assertTrue("Test".equals(data.getGroupId()));
- data.setGroupName("Test");
- assertTrue("Test".equals(data.getgroupName()));
- data.setCreatedBy("Test");
- assertTrue("Test".equals(data.getCreatedBy()));
- data.setDescription("Test");
- assertTrue("Test".equals(data.getDescription()));
- data.setModifiedBy("Test");
- assertTrue("Test".equals(data.getModifiedBy()));
- data.setDefaultGroup(true);
- assertTrue(data.isDefaultGroup());
- data.setDeleted(true);
- assertTrue(data.isDeleted());
- assertTrue(data.getCreatedDate()!=null);
- assertTrue(data.getModifiedDate()!=null);
- }
-}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJpaTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJpaTest.java
new file mode 100644
index 000000000..a55ff8d6e
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJpaTest.java
@@ -0,0 +1,528 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.rest.jpa;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+
+/**
+ * The Class PolicyEntityJpaTest.
+ */
+public class PolicyEntityJpaTest {
+
+ private static Logger logger = FlexLogger.getLogger(PolicyEntityJpaTest.class);
+ private UserInfo userInfo;
+
+ /**
+ * Sets the up.
+ *
+ * @throws Exception the exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ logger.info("setUp: Entering");
+ userInfo = new UserInfo();
+ userInfo.setUserLoginId("Test");
+ userInfo.setUserName("Test");
+ logger.info("setUp: exit");
+ }
+
+ /**
+ * Test policy group entity.
+ */
+ @Test
+ public void testPolicyGroupEntity() {
+ PolicyGroupEntity data = new PolicyGroupEntity();
+ data.setGroupKey(1);
+ assertTrue(1 == data.getGroupKey());
+ data.setPolicyid(1);
+ assertTrue(1 == data.getPolicyid());
+ }
+
+ /**
+ * Test policy DB dao entity.
+ */
+ @Test
+ public void testPolicyDbDaoEntity() {
+ PolicyDbDaoEntity data = new PolicyDbDaoEntity();
+ data.prePersist();
+ data.preUpdate();
+ data.setPolicyDbDaoUrl("Test");
+ assertTrue("Test".equals(data.getPolicyDbDaoUrl()));
+ data.setDescription("Test");
+ assertTrue("Test".equals(data.getDescription()));
+ assertTrue(data.getCreatedDate() != null);
+ assertTrue(data.getModifiedDate() != null);
+ data.setUsername("Test");
+ assertTrue("Test".equals(data.getUsername()));
+ data.setPassword("Test");
+ assertTrue("Test".equals(data.getPassword()));
+ }
+
+ /**
+ * Test database lock entity.
+ */
+ @Test
+ public void testDatabaseLockEntity() {
+ DatabaseLockEntity data = new DatabaseLockEntity();
+ data.setKey(1);
+ assertTrue(1 == data.getKey());
+ }
+
+ /**
+ * Test policy entity.
+ */
+ @Test
+ public void testPolicyEntity() {
+ PolicyEntity data = new PolicyEntity();
+ data.prePersist();
+ data.preUpdate();
+ data.setPolicyName("Test");
+ assertTrue("Test".equals(data.getPolicyName()));
+ data.setDescription("Test");
+ assertTrue("Test".equals(data.getDescription()));
+ assertTrue(data.getCreatedDate() != null);
+ assertTrue(data.getModifiedDate() != null);
+ data.setPolicyData("Test");
+ assertTrue("Test".equals(data.getPolicyData()));
+ data.setConfigurationData(new ConfigurationDataEntity());
+ assertTrue(data.getConfigurationData() != null);
+ data.setActionBodyEntity(new ActionBodyEntity());
+ assertTrue(data.getActionBodyEntity() != null);
+ data.setScope("Test");
+ assertTrue("Test".equals(data.getScope()));
+ data.setCreatedBy("Test");
+ assertTrue("Test".equals(data.getCreatedBy()));
+ data.setModifiedBy("Test");
+ assertTrue("Test".equals(data.getModifiedBy()));
+ data.setDeleted(true);
+ assertTrue(data.isDeleted());
+ data.equals(new PolicyEntity());
+ data.hashCode();
+
+ PolicyEntity entity0 = new PolicyEntity();
+ PolicyEntity entity1 = new PolicyEntity();
+ assertEquals(entity0, entity0);
+ assertEquals(entity0, entity1);
+ assertNotEquals(entity0, null);
+ String helloString = "Hello";
+ Object helloObject = helloString;
+ assertNotEquals(entity0, helloObject);
+
+ entity0.setPolicyId(1);
+ assertNotEquals(entity0, entity1);
+ entity1.setPolicyId(1);
+ assertEquals(entity0, entity1);
+ entity0.setPolicyId(2);
+ assertNotEquals(entity0, entity1);
+ entity1.setPolicyId(2);
+ assertEquals(entity0, entity1);
+
+ entity0.setPolicyName("GoToOz");
+ assertNotEquals(entity0, entity1);
+ entity1.setPolicyName("GoToOz");
+ assertEquals(entity0, entity1);
+ entity1.setPolicyName(null);
+ assertNotEquals(entity0, entity1);
+ entity0.setPolicyName(null);
+ assertEquals(entity0, entity1);
+ entity1.setPolicyName("GoToOz");
+ assertNotEquals(entity0, entity1);
+ entity0.setPolicyName("GoToOz");
+ assertEquals(entity0, entity1);
+ entity1.setPolicyName("GoToOzNow");
+ assertNotEquals(entity0, entity1);
+ entity0.setPolicyName("GoToOzNow");
+ assertEquals(entity0, entity1);
+
+ entity0.setScope("All");
+ assertNotEquals(entity0, entity1);
+ entity1.setScope("All");
+ assertEquals(entity0, entity1);
+ entity1.setScope(null);
+ assertNotEquals(entity0, entity1);
+ entity0.setScope(null);
+ assertEquals(entity0, entity1);
+ entity1.setScope("All");
+ assertNotEquals(entity0, entity1);
+ entity0.setScope("All");
+ assertEquals(entity0, entity1);
+ entity1.setScope("AllIn");
+ assertNotEquals(entity0, entity1);
+ entity0.setScope("AllIn");
+ assertEquals(entity0, entity1);
+
+ entity0.setVersion(1);
+ assertNotEquals(entity0, entity1);
+ entity1.setVersion(1);
+ assertEquals(entity0, entity1);
+
+ entity0.setPolicyVersion(1);
+ assertNotEquals(entity0, entity1);
+ entity1.setPolicyVersion(1);
+ assertEquals(entity0, entity1);
+ entity0.setPolicyVersion(2);
+ assertNotEquals(entity0, entity1);
+ entity1.setPolicyVersion(2);
+ assertEquals(entity0, entity1);
+
+ entity0.setPolicyData("SomeData");
+ assertNotEquals(entity0, entity1);
+ entity1.setPolicyData("SomeData");
+ assertEquals(entity0, entity1);
+ entity1.setPolicyData(null);
+ assertNotEquals(entity0, entity1);
+ entity0.setPolicyData(null);
+ assertEquals(entity0, entity1);
+ entity1.setPolicyData("SomeData");
+ assertNotEquals(entity0, entity1);
+ entity0.setPolicyData("SomeData");
+ assertEquals(entity0, entity1);
+ entity1.setPolicyData("SomeMoreData");
+ assertNotEquals(entity0, entity1);
+ entity0.setPolicyData("SomeMoreData");
+ assertEquals(entity0, entity1);
+
+ ConfigurationDataEntity cde0 = new ConfigurationDataEntity();
+ entity0.setConfigurationDataEntity(cde0);
+ assertNotEquals(entity0, entity1);
+ entity1.setConfigurationDataEntity(cde0);
+ assertEquals(entity0, entity1);
+ entity1.setConfigurationDataEntity(null);
+ assertNotEquals(entity0, entity1);
+ entity0.setConfigurationDataEntity(null);
+ assertEquals(entity0, entity1);
+ ConfigurationDataEntity cde1 = new ConfigurationDataEntity();
+ entity1.setConfigurationDataEntity(cde1);
+ assertNotEquals(entity0, entity1);
+ entity0.setConfigurationDataEntity(cde1);
+ assertEquals(entity0, entity1);
+
+ ActionBodyEntity abe0 = new ActionBodyEntity();
+ entity0.setActionBodyEntity(abe0);
+ assertNotEquals(entity0, entity1);
+ entity1.setActionBodyEntity(abe0);
+ assertEquals(entity0, entity1);
+ entity1.setActionBodyEntity(null);
+ assertNotEquals(entity0, entity1);
+ entity0.setActionBodyEntity(null);
+ assertEquals(entity0, entity1);
+ entity1.setActionBodyEntity(abe0);
+ assertNotEquals(entity0, entity1);
+ entity0.setActionBodyEntity(abe0);
+ assertEquals(entity0, entity1);
+ ActionBodyEntity abe1 = new ActionBodyEntity();
+ entity1.setActionBodyEntity(abe1);
+ assertNotEquals(entity0, entity1);
+ entity0.setActionBodyEntity(abe1);
+ assertEquals(entity0, entity1);
+
+ entity0.setDescription("Description");
+ assertNotEquals(entity0, entity1);
+ entity1.setDescription("Description");
+ assertEquals(entity0, entity1);
+ entity1.setDescription(null);
+ assertNotEquals(entity0, entity1);
+ entity0.setDescription(null);
+ assertEquals(entity0, entity1);
+ entity1.setDescription("Description");
+ assertNotEquals(entity0, entity1);
+ entity0.setDescription("Description");
+ assertEquals(entity0, entity1);
+ assertEquals(entity0, entity1);
+ entity1.setDescription("Description Extra");
+ assertNotEquals(entity0, entity1);
+ entity0.setDescription("Description Extra");
+ assertEquals(entity0, entity1);
+
+ entity0.setDeleted(true);
+ assertNotEquals(entity0, entity1);
+ entity1.setDeleted(true);
+ assertEquals(entity0, entity1);
+ entity0.setDeleted(false);
+ assertNotEquals(entity0, entity1);
+ entity1.setDeleted(false);
+ assertEquals(entity0, entity1);
+
+ entity0.setDeleteReasonCode("NoReason");
+ assertNotEquals(entity0, entity1);
+ entity1.setDeleteReasonCode("NoReason");
+ assertEquals(entity0, entity1);
+ entity1.setDeleteReasonCode(null);
+ assertNotEquals(entity0, entity1);
+ entity0.setDeleteReasonCode(null);
+ assertEquals(entity0, entity1);
+ entity1.setDeleteReasonCode("NoReason");
+ assertNotEquals(entity0, entity1);
+ entity0.setDeleteReasonCode("NoReason");
+ assertEquals(entity0, entity1);
+ assertEquals(entity0, entity1);
+ entity1.setDeleteReasonCode("NoOtherReason");
+ assertNotEquals(entity0, entity1);
+ entity0.setDeleteReasonCode("NoOtherReason");
+ assertEquals(entity0, entity1);
+
+ entity0.setCreatedBy("Dorothy");
+ assertNotEquals(entity0, entity1);
+ entity1.setCreatedBy("Dorothy");
+ assertEquals(entity0, entity1);
+ entity1.setCreatedBy(null);
+ assertNotEquals(entity0, entity1);
+ entity0.setCreatedBy(null);
+ assertEquals(entity0, entity1);
+ entity1.setCreatedBy("Dorothy");
+ assertNotEquals(entity0, entity1);
+ entity0.setCreatedBy("Dorothy");
+ assertEquals(entity0, entity1);
+ entity1.setCreatedBy("Toto");
+ assertNotEquals(entity0, entity1);
+ entity0.setCreatedBy("Toto");
+ assertEquals(entity0, entity1);
+
+ entity0.setCreatedDate(new Date(12345L));
+ assertNotEquals(entity0, entity1);
+ entity1.setCreatedDate(new Date(12345L));
+ assertEquals(entity0, entity1);
+ entity1.setCreatedDate(null);
+ assertNotEquals(entity0, entity1);
+ entity0.setCreatedDate(null);
+ assertEquals(entity0, entity1);
+ entity1.setCreatedDate(new Date(12345L));
+ assertNotEquals(entity0, entity1);
+ entity0.setCreatedDate(new Date(12345L));
+ assertEquals(entity0, entity1);
+ assertEquals(entity0, entity1);
+ entity1.setCreatedDate(new Date(123456L));
+ assertNotEquals(entity0, entity1);
+ entity0.setCreatedDate(new Date(123456L));
+ assertEquals(entity0, entity1);
+
+ entity0.setModifiedBy("Dorothy");
+ assertNotEquals(entity0, entity1);
+ entity1.setModifiedBy("Dorothy");
+ assertEquals(entity0, entity1);
+ entity1.setModifiedBy(null);
+ assertNotEquals(entity0, entity1);
+ entity0.setModifiedBy(null);
+ assertEquals(entity0, entity1);
+ entity1.setModifiedBy("Dorothy");
+ assertNotEquals(entity0, entity1);
+ entity0.setModifiedBy("Dorothy");
+ assertEquals(entity0, entity1);
+ entity1.setModifiedBy("Toto");
+ assertNotEquals(entity0, entity1);
+ entity0.setModifiedBy("Toto");
+ assertEquals(entity0, entity1);
+
+ entity0.setModifiedDate(new Date(12345L));
+ assertNotEquals(entity0, entity1);
+ entity1.setModifiedDate(new Date(12345L));
+ assertEquals(entity0, entity1);
+ entity1.setModifiedDate(null);
+ assertNotEquals(entity0, entity1);
+ entity0.setModifiedDate(null);
+ assertEquals(entity0, entity1);
+ entity1.setModifiedDate(new Date(12345L));
+ assertNotEquals(entity0, entity1);
+ entity0.setModifiedDate(new Date(12345L));
+ assertEquals(entity0, entity1);
+ assertEquals(entity0, entity1);
+ entity1.setModifiedDate(new Date(123456L));
+ assertNotEquals(entity0, entity1);
+ entity0.setModifiedDate(new Date(123456L));
+ assertEquals(entity0, entity1);
+
+ entity0.setDeletedBy("Dorothy");
+ assertNotEquals(entity0, entity1);
+ entity1.setDeletedBy("Dorothy");
+ assertEquals(entity0, entity1);
+ entity1.setDeletedBy(null);
+ assertNotEquals(entity0, entity1);
+ entity0.setDeletedBy(null);
+ assertEquals(entity0, entity1);
+ entity1.setDeletedBy("Dorothy");
+ assertNotEquals(entity0, entity1);
+ entity0.setDeletedBy("Dorothy");
+ assertEquals(entity0, entity1);
+ assertEquals(entity0, entity1);
+ entity1.setDeletedBy("Toto");
+ assertNotEquals(entity0, entity1);
+ entity0.setDeletedBy("Toto");
+ assertEquals(entity0, entity1);
+
+ assertNotNull(entity0.hashCode());
+ assertNotNull(entity1.hashCode());
+ assertEquals(entity0.hashCode(), entity0.hashCode());
+
+ entity0.setDeletedBy("Totp");
+ assertNotEquals(entity0, entity1);
+ assertNotEquals(entity0.hashCode(), entity1.hashCode());
+ }
+
+ /**
+ * Test action body entity.
+ */
+ @Test
+ public void testActionBodyEntity() {
+ ActionBodyEntity data = new ActionBodyEntity();
+ data.prePersist();
+ data.preUpdate();
+ data.setActionBodyName("Test");
+ assertTrue("Test".equals(data.getActionBodyName()));
+ data.setActionBody("Test");
+ assertTrue("Test".equals(data.getActionBody()));
+ data.setCreatedBy("Test");
+ assertTrue("Test".equals(data.getCreatedBy()));
+ data.setModifiedBy("Test");
+ assertTrue("Test".equals(data.getModifiedBy()));
+ data.setModifiedDate(new Date());
+ assertTrue(data.getCreatedDate() != null);
+ assertTrue(data.getModifiedDate() != null);
+ data.setDeleted(true);
+ assertTrue(data.isDeleted());
+ assertTrue(data.getCreatedDate() != null);
+ assertTrue(data.getModifiedDate() != null);
+ String helloString = "Hello";
+ Object helloObject = helloString;
+ assertNotEquals(data, helloObject);
+ data.hashCode();
+ }
+
+ /**
+ * Test configuration data entity.
+ */
+ @Test
+ public void testConfigurationDataEntity() {
+ ConfigurationDataEntity data = new ConfigurationDataEntity();
+ data.prePersist();
+ data.preUpdate();
+ data.setConfigurationName("Test");
+ assertTrue("Test".equals(data.getConfigurationName()));
+ data.setConfigType("Test");
+ assertTrue("Test".equals(data.getConfigType()));
+ data.setConfigBody("Test");
+ assertTrue("Test".equals(data.getConfigBody()));
+ data.setCreatedBy("Test");
+ assertTrue("Test".equals(data.getCreatedBy()));
+ data.setDescription("Test");
+ assertTrue("Test".equals(data.getDescription()));
+ data.setModifiedBy("Test");
+ assertTrue("Test".equals(data.getModifiedBy()));
+ data.setModifiedDate(new Date());
+ assertTrue(data.getCreatedDate() != null);
+ assertTrue(data.getModifiedDate() != null);
+ data.setDeleted(true);
+ assertTrue(data.isDeleted());
+ assertTrue(data.getCreatedDate() != null);
+ assertTrue(data.getModifiedDate() != null);
+ data.equals(new ConfigurationDataEntity());
+ data.hashCode();
+ }
+
+ /**
+ * Test pdp entity.
+ */
+ @Test
+ public void testPdpEntity() {
+ PdpEntity data = new PdpEntity();
+ data.prePersist();
+ data.preUpdate();
+ data.setPdpId("Test");
+ assertTrue("Test".equals(data.getPdpId()));
+ data.setPdpName("Test");
+ assertTrue("Test".equals(data.getPdpName()));
+ data.setGroup(new GroupEntity());
+ assertTrue(data.getGroup() != null);
+ data.setCreatedBy("Test");
+ assertTrue("Test".equals(data.getCreatedBy()));
+ data.setDescription("Test");
+ assertTrue("Test".equals(data.getDescription()));
+ data.setModifiedBy("Test");
+ assertTrue("Test".equals(data.getModifiedBy()));
+ data.setJmxPort(1);
+ assertTrue(1 == data.getJmxPort());
+ data.setDeleted(true);
+ assertTrue(data.isDeleted());
+ assertTrue(data.getCreatedDate() != null);
+ assertTrue(data.getModifiedDate() != null);
+ }
+
+ /**
+ * Test group entity.
+ */
+ @Test
+ public void testGroupEntity() {
+ GroupEntity data = new GroupEntity();
+ data.prePersist();
+ data.preUpdate();
+ data.setGroupId("Test");
+ assertTrue("Test".equals(data.getGroupId()));
+ data.setGroupName("Test");
+ assertTrue("Test".equals(data.getGroupName()));
+ data.setCreatedBy("Test");
+ assertTrue("Test".equals(data.getCreatedBy()));
+ data.setDescription("Test");
+ assertTrue("Test".equals(data.getDescription()));
+ data.setModifiedBy("Test");
+ assertTrue("Test".equals(data.getModifiedBy()));
+ data.setDefaultGroup(true);
+ assertTrue(data.isDefaultGroup());
+ data.setDeleted(true);
+ assertTrue(data.isDeleted());
+ assertTrue(data.getCreatedDate() != null);
+ assertTrue(data.getModifiedDate() != null);
+
+ assertNull(data.getPolicies());
+ PolicyEntity policy0 = new PolicyEntity();
+ policy0.setPolicyName("PolicyName0");
+ data.addPolicyToGroup(policy0);
+ PolicyEntity policy1 = new PolicyEntity();
+ policy1.setPolicyName("PolicyName1");
+ assertTrue(data.getPolicies().contains(policy0));
+ assertFalse(data.getPolicies().contains(policy1));
+ data.addPolicyToGroup(policy1);
+ assertTrue(data.getPolicies().contains(policy0));
+ assertTrue(data.getPolicies().contains(policy1));
+ data.addPolicyToGroup(policy1);
+ assertTrue(data.getPolicies().contains(policy0));
+ assertTrue(data.getPolicies().contains(policy1));
+ data.removePolicyFromGroup(policy0);
+ assertFalse(data.getPolicies().contains(policy0));
+ assertTrue(data.getPolicies().contains(policy1));
+ data.removePolicyFromGroup(policy0);
+ assertFalse(data.getPolicies().contains(policy0));
+ assertTrue(data.getPolicies().contains(policy1));
+ data.removePolicyFromGroup(policy1);
+ assertNull(data.getPolicies());
+ }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyUtilsJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyUtilsJPATest.java
deleted file mode 100644
index 3ada4dfca..000000000
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyUtilsJPATest.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP-REST
- * ================================================================================
- * Copyright (C) 2018 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.rest.jpa;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Date;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
-
-public class PolicyUtilsJPATest {
-
- private static Logger logger = FlexLogger.getLogger(PolicyUtilsJPATest.class);
- private UserInfo userInfo;
-
- @Before
- public void setUp() throws Exception {
- logger.info("setUp: Entering");
- userInfo = new UserInfo();
- userInfo.setUserLoginId("Test");
- userInfo.setUserName("Test");
- logger.info("setUp: exit");
- }
-
- @Test
- public void testWatchPolicyNotificationTable(){
- WatchPolicyNotificationTable data = new WatchPolicyNotificationTable();
- data.setId(1);
- assertTrue(1 == data.getId());
- data.setPolicyName("Test");
- assertTrue("Test".equals(data.getPolicyName()));
- data.setLoginIds("Test");
- assertTrue("Test".equals(data.getLoginIds()));
- data.equals(data);
- data.hashCode();
- }
-
- @Test
- public void testPolicyRoles(){
- PolicyRoles data = new PolicyRoles();
- data.setId(1);
- assertTrue(1 == data.getId());
- data.setScope("Test");
- assertTrue("Test".equals(data.getScope()));
- data.setRole("Test");
- assertTrue("Test".equals(data.getRole()));
- data.setLoginId(userInfo);
- assertTrue("Test".equals(data.getLoginId().getUserLoginId()));
- }
-
- @Test
- public void testPolicyVersion(){
- PolicyVersion data = new PolicyVersion();
- new PolicyVersion("Test", "Test");
- data.prePersist();
- data.preUpdate();
- data.setId(1);
- assertTrue(1 == data.getId());
- data.setActiveVersion(1);
- assertTrue(1 == data.getActiveVersion());
- data.setHigherVersion(1);
- assertTrue(1 == data.getHigherVersion());
- data.setPolicyName("Test");
- assertTrue("Test".equals(data.getPolicyName()));
- data.setCreatedBy("Test");
- assertTrue("Test".equals(data.getCreatedBy()));
- data.setModifiedBy("Test");
- assertTrue("Test".equals(data.getModifiedBy()));
- data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
- data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
- data.equals(data);
- data.hashCode();
- }
-
- @Test
- public void testSystemLogDB(){
- SystemLogDB data = new SystemLogDB();
- new SystemLogDB(1, "","","","","");
- data.setId(1);
- assertTrue(1 == data.getId());
- data.setDescription("Test");
- assertTrue("Test".equals(data.getDescription()));
- data.setType("Test");
- assertTrue("Test".equals(data.getType()));
- data.setSystem("Test");
- assertTrue("Test".equals(data.getSystem()));
- data.setRemote("Test");
- assertTrue("Test".equals(data.getRemote()));
- data.setLogtype("Test");
- assertTrue("Test".equals(data.getLogtype()));
- data.setDate(new Date());
- assertTrue(data.getDate()!=null);
- }
-
- @Test
- public void testRemoteCatalogValues(){
- RemoteCatalogValues data = new RemoteCatalogValues();
- data.setId(1);
- assertTrue(1 == data.getId());
- data.setName("Test");
- assertTrue("Test".equals(data.getName()));
- data.setValue("Test");
- assertTrue("Test".equals(data.getValue()));
- }
-
- @Test
- public void testPolicyScore(){
- PolicyScore data = new PolicyScore();
- data.setId(1);
- assertTrue(1 == data.getId());
- data.setPolicyName("Test");
- assertTrue("Test".equals(data.getPolicyName()));
- data.setVersionExtension("Test");
- assertTrue("Test".equals(data.getVersionExtension()));
- data.setPolicyScore("Test");
- assertTrue("Test".equals(data.getPolicyScore()));
- }
-
- @Test
- public void testPolicyEditorScopes(){
- PolicyEditorScopes data = new PolicyEditorScopes();
- data.prePersist();
- data.preUpdate();
- data.setId(1);
- assertTrue(1 == data.getId());
- data.setScopeName("Test");
- assertTrue("Test".equals(data.getScopeName()));
- data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
- data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
- data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
- data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!=null);
- }
-
- @Test
- public void testDescriptiveScope(){
- DescriptiveScope data = new DescriptiveScope();
- data.prePersist();
- data.preUpdate();
- data.setId(1);
- assertTrue(1 == data.getId());
- data.setScopeName("Test");
- assertTrue("Test".equals(data.getScopeName()));
- data.setSearch("Test");
- assertTrue("Test".equals(data.getSearch()));
- data.setCreatedDate(new Date());
- assertTrue(data.getCreatedDate()!=null);
- data.setModifiedDate(new Date());
- assertTrue(data.getModifiedDate()!=null);
- data.setUserCreatedBy(userInfo);
- assertTrue(data.getUserCreatedBy()!=null);
- data.setUserModifiedBy(userInfo);
- assertTrue(data.getUserModifiedBy()!=null);
- }
-
- @Test
- public void testGlobalRoleSettings(){
- GlobalRoleSettings data = new GlobalRoleSettings();
- new GlobalRoleSettings(true);
- data.setRole("Test");
- assertTrue("Test".equals(data.getRole()));
- data.setLockdown(true);
- assertTrue(data.isLockdown());
- }
-}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyUtilsJpaTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyUtilsJpaTest.java
new file mode 100644
index 000000000..f56e55783
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyUtilsJpaTest.java
@@ -0,0 +1,320 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.rest.jpa;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+
+/**
+ * The Class PolicyUtilsJpaTest.
+ */
+public class PolicyUtilsJpaTest {
+
+ private static Logger logger = FlexLogger.getLogger(PolicyUtilsJpaTest.class);
+ private UserInfo userInfo;
+
+ /**
+ * Sets the up.
+ *
+ * @throws Exception the exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ logger.info("setUp: Entering");
+ userInfo = new UserInfo();
+ userInfo.setUserLoginId("Test");
+ userInfo.setUserName("Test");
+ logger.info("setUp: exit");
+ }
+
+ /**
+ * Test watch policy notification table.
+ */
+ @Test
+ public void testWatchPolicyNotificationTable() {
+ WatchPolicyNotificationTable data = new WatchPolicyNotificationTable();
+ data.setId(1);
+ assertTrue(1 == data.getId());
+ data.setPolicyName("Test");
+ assertTrue("Test".equals(data.getPolicyName()));
+ data.setLoginIds("Test");
+ assertTrue("Test".equals(data.getLoginIds()));
+ data.equals(data);
+ data.hashCode();
+ }
+
+ /**
+ * Test policy roles.
+ */
+ @Test
+ public void testPolicyRoles() {
+ PolicyRoles data = new PolicyRoles();
+ data.setId(1);
+ assertTrue(1 == data.getId());
+ data.setScope("Test");
+ assertTrue("Test".equals(data.getScope()));
+ data.setRole("Test");
+ assertTrue("Test".equals(data.getRole()));
+ data.setLoginId(userInfo);
+ assertTrue("Test".equals(data.getLoginId().getUserLoginId()));
+ }
+
+ /**
+ * Test policy version.
+ */
+ @Test
+ public void testPolicyVersion() {
+ PolicyVersion data = new PolicyVersion();
+ new PolicyVersion("Test", "Test");
+ data.prePersist();
+ data.preUpdate();
+ data.setId(1);
+ assertTrue(1 == data.getId());
+ data.setActiveVersion(1);
+ assertTrue(1 == data.getActiveVersion());
+ data.setHigherVersion(1);
+ assertTrue(1 == data.getHigherVersion());
+ data.setPolicyName("Test");
+ assertTrue("Test".equals(data.getPolicyName()));
+ data.setCreatedBy("Test");
+ assertTrue("Test".equals(data.getCreatedBy()));
+ data.setModifiedBy("Test");
+ assertTrue("Test".equals(data.getModifiedBy()));
+ data.setCreatedDate(new Date());
+ assertTrue(data.getCreatedDate() != null);
+ data.setModifiedDate(new Date());
+ assertTrue(data.getModifiedDate() != null);
+
+ assertNotNull(data.hashCode());
+
+ PolicyVersion version0 = new PolicyVersion();
+ PolicyVersion version1 = new PolicyVersion();
+ assertEquals(version0, version0);
+ assertEquals(version0, version1);
+ assertNotEquals(version0, null);
+ String helloString = "Hello";
+ Object helloObject = helloString;
+ assertNotEquals(version0, helloObject);
+
+ version0.setId(1);
+ assertNotEquals(version0, version1);
+ version1.setId(1);
+ assertEquals(version0, version1);
+ version0.setActiveVersion(1);
+ assertNotEquals(version0, version1);
+ version1.setActiveVersion(1);
+ assertEquals(version0, version1);
+ version0.setCreatedBy("Dorothy");
+ assertNotEquals(version0, version1);
+ version1.setCreatedBy("Dorothy");
+ assertEquals(version0, version1);
+ version1.setCreatedBy(null);
+ assertNotEquals(version0, version1);
+ version0.setCreatedBy(null);
+ assertEquals(version0, version1);
+ version1.setCreatedBy("Dorothy");
+ assertNotEquals(version0, version1);
+ version0.setCreatedBy("Dorothy");
+ assertEquals(version0, version1);
+ version0.setCreatedDate(new Date(12345L));
+ assertNotEquals(version0, version1);
+ version1.setCreatedDate(new Date(12345L));
+ assertEquals(version0, version1);
+ version1.setCreatedDate(null);
+ assertNotEquals(version0, version1);
+ version0.setCreatedDate(null);
+ assertEquals(version0, version1);
+ version1.setCreatedDate(new Date(12345L));
+ assertNotEquals(version0, version1);
+ version0.setCreatedDate(new Date(12345L));
+ assertEquals(version0, version1);
+ version0.setHigherVersion(1);
+ assertNotEquals(version0, version1);
+ version1.setHigherVersion(1);
+ assertEquals(version0, version1);
+ version0.setModifiedBy("Dorothy");
+ assertNotEquals(version0, version1);
+ version1.setModifiedBy("Dorothy");
+ assertEquals(version0, version1);
+ version1.setModifiedBy(null);
+ assertNotEquals(version0, version1);
+ version0.setModifiedBy(null);
+ assertEquals(version0, version1);
+ version1.setModifiedBy("Dorothy");
+ assertNotEquals(version0, version1);
+ version0.setModifiedBy("Dorothy");
+ assertEquals(version0, version1);
+ version0.setModifiedDate(new Date(12345L));
+ assertNotEquals(version0, version1);
+ version1.setModifiedDate(new Date(12345L));
+ assertEquals(version0, version1);
+ version1.setModifiedDate(null);
+ assertNotEquals(version0, version1);
+ version0.setModifiedDate(null);
+ assertEquals(version0, version1);
+ version1.setModifiedDate(new Date(12345L));
+ assertNotEquals(version0, version1);
+ version0.setModifiedDate(new Date(12345L));
+ assertEquals(version0, version1);
+ version0.setPolicyName("GoToOz");
+ assertNotEquals(version0, version1);
+ version1.setPolicyName("GoToOz");
+ assertEquals(version0, version1);
+ version1.setPolicyName(null);
+ assertNotEquals(version0, version1);
+ version0.setPolicyName(null);
+ assertEquals(version0, version1);
+ version1.setPolicyName("GoToOz");
+ assertNotEquals(version0, version1);
+ version0.setPolicyName("GoToOz");
+ assertEquals(version0, version1);
+
+ assertNotNull(version0.hashCode());
+ assertNotNull(version1.hashCode());
+ assertEquals(version0.hashCode(), version0.hashCode());
+
+ version0.setPolicyName("GoToOy");
+ assertNotEquals(version0, version1);
+ assertNotEquals(version0.hashCode(), version1.hashCode());
+ }
+
+ /**
+ * Test system log DB.
+ */
+ @Test
+ public void testSystemLogDb() {
+ SystemLogDb data = new SystemLogDb();
+ new SystemLogDb(1, "", "", "", "", "");
+ data.setId(1);
+ assertTrue(1 == data.getId());
+ data.setDescription("Test");
+ assertTrue("Test".equals(data.getDescription()));
+ data.setType("Test");
+ assertTrue("Test".equals(data.getType()));
+ data.setSystem("Test");
+ assertTrue("Test".equals(data.getSystem()));
+ data.setRemote("Test");
+ assertTrue("Test".equals(data.getRemote()));
+ data.setLogtype("Test");
+ assertTrue("Test".equals(data.getLogtype()));
+ data.setDate(new Date());
+ assertTrue(data.getDate() != null);
+ }
+
+ /**
+ * Test remote catalog values.
+ */
+ @Test
+ public void testRemoteCatalogValues() {
+ RemoteCatalogValues data = new RemoteCatalogValues();
+ data.setId(1);
+ assertTrue(1 == data.getId());
+ data.setName("Test");
+ assertTrue("Test".equals(data.getName()));
+ data.setValue("Test");
+ assertTrue("Test".equals(data.getValue()));
+ }
+
+ /**
+ * Test policy score.
+ */
+ @Test
+ public void testPolicyScore() {
+ PolicyScore data = new PolicyScore();
+ data.setId(1);
+ assertTrue(1 == data.getId());
+ data.setPolicyName("Test");
+ assertTrue("Test".equals(data.getPolicyName()));
+ data.setVersionExtension("Test");
+ assertTrue("Test".equals(data.getVersionExtension()));
+ data.setScore("Test");
+ assertTrue("Test".equals(data.getScore()));
+ }
+
+ /**
+ * Test policy editor scopes.
+ */
+ @Test
+ public void testPolicyEditorScopes() {
+ PolicyEditorScopes data = new PolicyEditorScopes();
+ data.prePersist();
+ data.preUpdate();
+ data.setId(1);
+ assertTrue(1 == data.getId());
+ data.setScopeName("Test");
+ assertTrue("Test".equals(data.getScopeName()));
+ data.setCreatedDate(new Date());
+ assertTrue(data.getCreatedDate() != null);
+ data.setModifiedDate(new Date());
+ assertTrue(data.getModifiedDate() != null);
+ data.setUserCreatedBy(userInfo);
+ assertTrue(data.getUserCreatedBy() != null);
+ data.setUserModifiedBy(userInfo);
+ assertTrue(data.getUserModifiedBy() != null);
+ }
+
+ /**
+ * Test descriptive scope.
+ */
+ @Test
+ public void testDescriptiveScope() {
+ DescriptiveScope data = new DescriptiveScope();
+ data.prePersist();
+ data.preUpdate();
+ data.setId(1);
+ assertTrue(1 == data.getId());
+ data.setScopeName("Test");
+ assertTrue("Test".equals(data.getScopeName()));
+ data.setSearch("Test");
+ assertTrue("Test".equals(data.getSearch()));
+ data.setCreatedDate(new Date());
+ assertTrue(data.getCreatedDate() != null);
+ data.setModifiedDate(new Date());
+ assertTrue(data.getModifiedDate() != null);
+ data.setUserCreatedBy(userInfo);
+ assertTrue(data.getUserCreatedBy() != null);
+ data.setUserModifiedBy(userInfo);
+ assertTrue(data.getUserModifiedBy() != null);
+ }
+
+ /**
+ * Test global role settings.
+ */
+ @Test
+ public void testGlobalRoleSettings() {
+ GlobalRoleSettings data = new GlobalRoleSettings();
+ new GlobalRoleSettings(true);
+ data.setRole("Test");
+ assertTrue("Test".equals(data.getRole()));
+ data.setLockdown(true);
+ assertTrue(data.isLockdown());
+ }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/DummyPolicyContainer.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/DummyPolicyContainer.java
new file mode 100644
index 000000000..385576744
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/DummyPolicyContainer.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.util;
+
+import java.util.Collection;
+
+public class DummyPolicyContainer implements PolicyContainer {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Collection<?> getContainerPropertyIds() {
+ return null;
+ }
+
+ @Override
+ public Collection<?> getItemIds() {
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(Object propertyId) {
+ return null;
+ }
+
+ @Override
+ public int size() {
+ return 0;
+ }
+
+ @Override
+ public boolean containsId(Object itemId) {
+ return false;
+ }
+
+ @Override
+ public Object addItem() {
+ return null;
+ }
+
+ @Override
+ public boolean removeItem(Object itemId) {
+ return false;
+ }
+
+ @Override
+ public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) {
+ return false;
+ }
+
+ @Override
+ public boolean removeContainerProperty(Object propertyId) {
+ return false;
+ }
+
+ @Override
+ public boolean removeAllItems() {
+ return false;
+ }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/MSAttributeObjectTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/MsAttributeObjectTest.java
index a39eb4996..8ec47fb0b 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/util/MSAttributeObjectTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/MsAttributeObjectTest.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,14 +22,16 @@
package org.onap.policy.rest.util;
import static org.junit.Assert.assertTrue;
+
import java.util.HashMap;
+
import org.junit.Test;
-public class MSAttributeObjectTest {
+public class MsAttributeObjectTest {
@Test
- public void testMSAttributeObject() {
- MSAttributeObject data = new MSAttributeObject();
+ public void testMsAttributeObject() {
+ MsAttributeObject data = new MsAttributeObject();
data.setClassName("Test");
assertTrue("Test".equals(data.getClassName()));
data.setRefAttribute(new HashMap<>());
@@ -60,8 +63,8 @@ public class MSAttributeObjectTest {
}
@Test
- public void testMSAttributeValue() {
- MSAttributeValue data = new MSAttributeValue();
+ public void testMsAttributeValue() {
+ MsAttributeValue data = new MsAttributeValue();
data.setName("Test");
assertTrue("Test".equals(data.getName()));
data.setType("Test");
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/MSModelUtilsTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/MsModelUtilsTest.java
index 34d555062..6d12d57a3 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/util/MSModelUtilsTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/MsModelUtilsTest.java
@@ -3,6 +3,7 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +26,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -32,19 +34,25 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang.StringUtils;
+
+import org.apache.commons.lang3.StringUtils;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.DictionaryData;
-import org.onap.policy.rest.util.MSModelUtils.MODEL_TYPE;
+import org.onap.policy.rest.util.MsModelUtils.ModelType;
-public class MSModelUtilsTest {
- private static Logger logger = FlexLogger.getLogger(MSModelUtilsTest.class);
+public class MsModelUtilsTest {
+ private static Logger logger = FlexLogger.getLogger(MsModelUtilsTest.class);
private static CommonClassDao commonClassDao;
+ /**
+ * Set tests up.
+ *
+ * @throws Exception on setup failures
+ */
@Before
public void setUp() throws Exception {
List<Object> dictionaryData = new ArrayList<Object>();
@@ -55,28 +63,28 @@ public class MSModelUtilsTest {
logger.info("setUp: Entering");
commonClassDao = mock(CommonClassDao.class);
when(commonClassDao.getDataById(DictionaryData.class, "dictionaryName", "GocVNFType"))
- .thenReturn(dictionaryData);
+ .thenReturn(dictionaryData);
}
@Test
- public void testMSModelUtils() {
- HashMap<String, MSAttributeObject> classMap = new HashMap<>();
+ public void testMsModelUtils() {
+ HashMap<String, MsAttributeObject> classMap = new HashMap<>();
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource("DKaTVESPolicy-v1802.xmi").getFile());
- MSModelUtils utils = new MSModelUtils("http://org.onap", "http://org.onap.policy");
- Map<String, MSAttributeObject> tempMap =
- utils.processEpackage(file.getAbsolutePath().toString(), MODEL_TYPE.XMI);
+ MsModelUtils utils = new MsModelUtils("http://org.onap", "http://org.onap.policy");
+ Map<String, MsAttributeObject> tempMap = utils.processEpackage(file.getAbsolutePath().toString(),
+ ModelType.XMI);
classMap.putAll(tempMap);
- MSAttributeObject mainClass = classMap.get("StandardDeviationThreshold");
- String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[] {"[", "]", " "},
- new String[] {"", "", ""});
+ MsAttributeObject mainClass = classMap.get("StandardDeviationThreshold");
+ String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[]
+ { "[", "]", " " }, new String[]
+ { "", "", "" });
List<String> dependency = new ArrayList<String>(Arrays.asList(dependTemp.split(",")));
dependency = utils.getFullDependencyList(dependency, classMap);
String subAttribute = utils.createSubAttributes(dependency, classMap, "StandardDeviationThreshold");
assertTrue(subAttribute != null);
}
-
/**
* Run the void stringBetweenDots(String, String) method test.
*/
@@ -85,25 +93,24 @@ public class MSModelUtilsTest {
public void testStringBetweenDots() {
// expect: uniqueKeys should contain a string value
- MSModelUtils controllerA = new MSModelUtils();
+ MsModelUtils controllerA = new MsModelUtils();
String str = "testing\\.byCorrectWay\\.OfDATA";
assertEquals(1, controllerA.stringBetweenDots(str));
// expect: uniqueKeys should not contain a string value
str = "testing\byWrongtWay.\\OfDATA";
- MSModelUtils controllerB = new MSModelUtils();
+ MsModelUtils controllerB = new MsModelUtils();
assertEquals(0, controllerB.stringBetweenDots(str));
}
/**
- * Run the Map<String,String> load(String) method test.
+ * Run the load method test.
*/
-
@Test
public void testLoad() {
boolean isLocalTesting = true;
- MSModelUtils controller = new MSModelUtils();
+ MsModelUtils controller = new MsModelUtils();
String fileName = null;
Map<String, String> result = null;
try {
@@ -146,7 +153,7 @@ public class MSModelUtilsTest {
logger.error("Exception Occured while loading file" + e1);
}
- MSModelUtils controller = new MSModelUtils(commonClassDao);
+ MsModelUtils controller = new MsModelUtils(commonClassDao);
if (isLocalTesting) {
try {
controller.parseTosca(fileName);
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PDPPolicyContainerTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PDPPolicyContainerTest.java
deleted file mode 100644
index 9302df3b5..000000000
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PDPPolicyContainerTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Engine
- * ================================================================================
- * Copyright (C) 2018 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.rest.util;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import java.util.HashSet;
-import java.util.Set;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.rest.util.PDPPolicyContainer.PDPPolicyItem;
-import org.onap.policy.xacml.std.pap.StdPDP;
-import org.onap.policy.xacml.std.pap.StdPDPGroup;
-import org.onap.policy.xacml.std.pap.StdPDPPolicy;
-import com.att.research.xacml.api.pap.PDP;
-import com.att.research.xacml.api.pap.PDPPolicy;
-
-public class PDPPolicyContainerTest {
- StdPDPGroup group;
- PDPPolicyContainer container;
- StdPDPPolicy policy;
-
- @Before
- public void setUp() {
- group = new StdPDPGroup();
- group.setDefault(true);
- group.setDefaultGroup(true);
- group.setDescription("Test");
- group.setId("Test");
- group.setName("Test");
- group.setOnapPdps(new HashSet<>());
- group.setOperation("Test");
- group.setPipConfigs(new HashSet<>());
- HashSet<PDPPolicy> policies = new HashSet<>();
- policy = new StdPDPPolicy();
- policy.setName("Config_test.1.xml");
- policy.setId("Config_test");
- policy.setVersion("1.0");
- policy.setDescription("testDescription");
- policies.add(policy);
- group.setPolicies(policies);
- group.setSelectedPolicies(new HashSet<>());
- container = new PDPPolicyContainer(group);
- }
-
- @Test
- public void testPDPPolicyContainer() {
- container.nextItemId(policy);
- container.prevItemId(policy);
- container.firstItemId();
- container.lastItemId();
- container.isFirstId(policy);
- container.isLastId(policy);
- container.addItemAfter(policy);
- container.getContainerPropertyIds();
- container.getItemIds();
- container.getType("Id");
- assertTrue(String.class.equals(String.class));
- container.getType("Name");
- assertTrue(String.class.equals(String.class));
- container.getType("Version");
- assertTrue(String.class.equals(String.class));
- container.getType("Description");
- assertTrue(String.class.equals(String.class));
- container.getType("Root");
- assertTrue(Boolean.class.equals(Boolean.class));
- assertTrue(container.size() == 1);
- container.containsId(policy);
- container.removeItem(policy);
- container.addContainerProperty(null, null, null);
- container.removeContainerProperty(policy);
- container.removeAllItems();
- container.addItemAt(0);
- }
-
- @Test(expected = NullPointerException.class)
- public void testConstructor() {
- // Test PDP based constructor
- PDP pdp = new StdPDP();
- PDPPolicyContainer container1 = new PDPPolicyContainer(pdp);
- assertNotNull(container1);
-
- // Test set based constructor
- Set<PDPPolicy> set = new HashSet<PDPPolicy>();
- PDPPolicyContainer container2 = new PDPPolicyContainer(set);
- assertNotNull(container2);
-
- // Test object based constructor
- PDPPolicyContainer container3 = new PDPPolicyContainer("testObject");
- assertNotNull(container3);
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testAddItem() {
- container.addItem();
- }
-
- @Test
- public void testGetters() {
- assertNull(container.nextItemId("testItem"));
- assertNull(container.prevItemId("testItem"));
- assertNotNull(container.firstItemId());
- assertNotNull(container.lastItemId());
- assertEquals(container.indexOfId("testItem"), -1);
- assertNotNull(container.getIdByIndex(0));
- assertNotNull(container.getItemIds(0, 1));
- }
-
- @Test
- public void testPDPPolicyItem() {
- PDPPolicyItem item = container.new PDPPolicyItem(policy);
- assertEquals("Config_test", item.getId());
- assertEquals("Config_test.1.xml", item.getName());
- assertEquals("1.0", item.getVersion());
- assertEquals("testDescription", item.getDescription());
- item.setRoot(true);
- assertEquals(true, item.getRoot());
- }
-}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/ParserExceptionTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/ParserExceptionTest.java
new file mode 100644
index 000000000..92b56a146
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/ParserExceptionTest.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class ParserExceptionTest {
+
+ @Test
+ public void test() {
+ ParserException pe = new ParserException("A Message");
+ assertEquals("A Message", pe.getMessage());
+ }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PdpPolicyContainerTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PdpPolicyContainerTest.java
new file mode 100644
index 000000000..32d9e5255
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PdpPolicyContainerTest.java
@@ -0,0 +1,267 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.rest.util;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFLogger.Level;
+import com.att.eelf.configuration.EELFManager;
+import com.att.research.xacml.api.pap.PDP;
+import com.att.research.xacml.api.pap.PDPPolicy;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.logging.eelf.PolicyLogger;
+import org.onap.policy.rest.util.PdpPolicyContainer.PdpPolicyItem;
+import org.onap.policy.xacml.std.pap.StdPDP;
+import org.onap.policy.xacml.std.pap.StdPDPGroup;
+import org.onap.policy.xacml.std.pap.StdPDPPolicy;
+
+public class PdpPolicyContainerTest {
+ StdPDPGroup group;
+ PdpPolicyContainer container;
+ StdPDPPolicy policy;
+
+ /**
+ * Set test up.
+ */
+ @Before
+ public void setUp() {
+ group = new StdPDPGroup();
+ group.setDefault(true);
+ group.setDefaultGroup(true);
+ group.setDescription("Test");
+ group.setId("Test");
+ group.setName("Test");
+ group.setOnapPdps(new HashSet<>());
+ group.setOperation("Test");
+ group.setPipConfigs(new HashSet<>());
+ policy = new StdPDPPolicy();
+ policy.setName("Config_test.1.xml");
+ policy.setId("Config_test");
+ policy.setVersion("1.0");
+ policy.setDescription("testDescription");
+
+ HashSet<PDPPolicy> policies = new HashSet<>();
+ policies.add(policy);
+ group.setPolicies(policies);
+ group.setSelectedPolicies(new HashSet<>());
+ container = new PdpPolicyContainer(group);
+ }
+
+ @Test
+ public void testPdpPolicyContainer() {
+ container.nextItemId(policy);
+ container.prevItemId(policy);
+ container.firstItemId();
+ container.lastItemId();
+ container.isFirstId(policy);
+ container.isLastId(policy);
+ container.addItemAfter(policy);
+ container.getContainerPropertyIds();
+ container.getItemIds();
+ container.getType("Id");
+ assertNull(container.getType("NonExistant"));
+ assertTrue(String.class.equals(String.class));
+ container.getType("Name");
+ assertTrue(String.class.equals(String.class));
+ container.getType("Version");
+ assertTrue(String.class.equals(String.class));
+ container.getType("Description");
+ assertTrue(String.class.equals(String.class));
+ container.getType("Root");
+ assertTrue(Boolean.class.equals(Boolean.class));
+ assertTrue(container.size() == 1);
+ container.containsId(policy);
+ container.removeItem(policy);
+ container.addContainerProperty(null, null, null);
+ container.removeContainerProperty(policy);
+ container.removeAllItems();
+
+ assertFalse(container.isFirstId(policy));
+ assertFalse(container.isLastId(policy));
+ assertNull(container.firstItemId());
+ assertNull(container.lastItemId());
+ assertNull(container.prevItemId(policy));
+
+ assertThatThrownBy(() -> container.getItemIds(0, -1)).isInstanceOf(IllegalArgumentException.class);
+
+ container.addItemAt(0);
+ }
+
+ @Test
+ public void testPdpPolicyContainerWithTrace() {
+ EELFLogger debugLogger = EELFManager.getInstance().getDebugLogger();
+
+ final Level currentLevel = PolicyLogger.getDebugLevel();
+ debugLogger.setLevel(Level.TRACE);
+
+ testPdpPolicyContainer();
+ debugLogger.setLevel(currentLevel);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testConstructor() {
+ // Test PDP based constructor
+ PDP pdp = new StdPDP();
+ PdpPolicyContainer container1 = new PdpPolicyContainer(pdp);
+ assertNotNull(container1);
+
+ // Test set based constructor
+ Set<PDPPolicy> set = new HashSet<PDPPolicy>();
+ PdpPolicyContainer container2 = new PdpPolicyContainer(set);
+ assertNotNull(container2);
+
+ // Test object based constructor
+ PdpPolicyContainer container3 = new PdpPolicyContainer("testObject");
+ assertNotNull(container3);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testAddItem() {
+ container.addItem();
+ }
+
+ @Test
+ public void testGettersWithTrace() {
+ EELFLogger debugLogger = EELFManager.getInstance().getDebugLogger();
+
+ final Level currentLevel = PolicyLogger.getDebugLevel();
+ debugLogger.setLevel(Level.TRACE);
+
+ testGetters();
+ debugLogger.setLevel(currentLevel);
+ }
+
+ @Test
+ public void testGetters() {
+ assertNull(container.nextItemId("testItem"));
+ assertNull(container.prevItemId("testItem"));
+ assertNotNull(container.firstItemId());
+ assertNotNull(container.lastItemId());
+ assertEquals(container.indexOfId("testItem"), -1);
+ assertNotNull(container.getIdByIndex(0));
+ assertNotNull(container.getItemIds(0, 1));
+ }
+
+ @Test
+ public void testPdpPolicyItemWithTrace() {
+ EELFLogger debugLogger = EELFManager.getInstance().getDebugLogger();
+
+ final Level currentLevel = PolicyLogger.getDebugLevel();
+ debugLogger.setLevel(Level.TRACE);
+
+ testPdpPolicyItem();
+ debugLogger.setLevel(currentLevel);
+ }
+
+ @Test
+ public void testPdpPolicyItem() {
+ PdpPolicyItem item = container.new PdpPolicyItem(policy);
+ assertEquals("Config_test", item.getId());
+ assertEquals("Config_test.1.xml", item.getName());
+ assertEquals("1.0", item.getVersion());
+ assertEquals("testDescription", item.getDescription());
+ item.setRoot(true);
+ assertEquals(true, item.getRoot());
+ }
+
+ @Test
+ public void testContainerListOfPolicies() {
+ StdPDPGroup testGroup = new StdPDPGroup();
+ testGroup.setDefault(true);
+ testGroup.setDefaultGroup(true);
+ testGroup.setDescription("Test");
+ testGroup.setId("Test");
+ testGroup.setName("Test");
+ testGroup.setOnapPdps(new HashSet<>());
+ testGroup.setOperation("Test");
+ testGroup.setPipConfigs(new HashSet<>());
+
+ StdPDPPolicy testPolicy0 = new StdPDPPolicy();
+ testPolicy0.setName("Config_test.0.xml");
+ testPolicy0.setId("Config_test0");
+ testPolicy0.setVersion("1.0");
+ testPolicy0.setDescription("testDescription0");
+
+ StdPDPPolicy testPolicy1 = new StdPDPPolicy();
+ testPolicy1.setName("Config_test.1.xml");
+ testPolicy1.setId("Config_test1");
+ testPolicy1.setVersion("1.0");
+ testPolicy1.setDescription("testDescription1");
+
+ HashSet<PDPPolicy> policies = new HashSet<>();
+ policies.add(testPolicy0);
+ policies.add(testPolicy1);
+
+ testGroup.setPolicies(policies);
+ testGroup.setSelectedPolicies(new HashSet<>());
+ PdpPolicyContainer testContainer = new PdpPolicyContainer(testGroup);
+
+ assertEquals("Config_test0", ((PdpPolicyItem) testContainer.nextItemId(testPolicy1)).getId());
+ assertEquals("Config_test1", ((PdpPolicyItem) testContainer.prevItemId(testPolicy0)).getId());
+
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ mapper.writeValue(System.err, testPolicy0);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ // @formatter:off
+ assertTrue(testContainer.removeItem("{"
+ + "\"PDPPolicyType\":\"StdPDPPolicy\","
+ + "\"id\":\"Config_test0\","
+ + "\"name\":\"Config_test.0.xml\","
+ + "\"policyId\":null,"
+ + "\"description\":\"testDescription0\","
+ + "\"version\":\"1.0\","
+ + "\"location\":null,"
+ + "\"valid\":false,"
+ + "\"root\":false"
+ + "}"));
+ assertFalse(testContainer.removeItem("{"
+ + "\"PDPPolicyType\":\"StdPDPPolicy\","
+ + "\"id\":\"Config_test99\","
+ + "\"name\":\"Config_test.0.xml\","
+ + "\"policyId\":null,"
+ + "\"description\":\"testDescription0\","
+ + "\"version\":\"1.0\","
+ + "\"location\":null,"
+ + "\"valid\":false,"
+ + "\"root\":false"
+ + "}"));
+ // @formatter:on
+ }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifierTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifierTest.java
index 9e5ff5d9f..5e42ec6f6 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifierTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyItemSetChangeNotifierTest.java
@@ -3,13 +3,14 @@
* ONAP Policy Engine
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,31 +21,57 @@
package org.onap.policy.rest.util;
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.policy.rest.util.PolicyContainer.ItemSetChangeEvent;
import org.onap.policy.rest.util.PolicyContainer.ItemSetChangeListener;
public class PolicyItemSetChangeNotifierTest {
- @Test
- public void testNotifier() {
- // Setup test data
- ItemSetChangeListener listener = Mockito.mock(ItemSetChangeListener.class);
- ItemSetChangeEvent event = Mockito.mock(ItemSetChangeEvent.class);
-
- // Test constructor
- PolicyItemSetChangeNotifier notifier = new PolicyItemSetChangeNotifier();
- assertNotNull(notifier);
-
- // Test listener methods
- try {
- notifier.addItemSetChangeListener(listener);
- notifier.fireItemSetChange(event);
- notifier.removeItemSetChangeListener(listener);
- } catch (Exception ex) {
- fail("Not expecting any exceptions: " + ex);
+ @Test
+ public void testNotifier() {
+
+ // Test constructor
+ PolicyItemSetChangeNotifier notifier = new PolicyItemSetChangeNotifier();
+ assertNotNull(notifier);
+
+ assertEquals(null, notifier.getItemSetChangeListeners());
+
+ ItemSetChangeListener listener1 = Mockito.mock(ItemSetChangeListener.class);
+ notifier.addItemSetChangeListener(listener1);
+ assertEquals(1, notifier.getItemSetChangeListeners().size());
+ ItemSetChangeListener listener2 = Mockito.mock(ItemSetChangeListener.class);
+ notifier.addItemSetChangeListener(listener2);
+ assertEquals(2, notifier.getItemSetChangeListeners().size());
+
+ notifier.removeItemSetChangeListener(listener1);
+ assertEquals(1, notifier.getItemSetChangeListeners().size());
+ notifier.addItemSetChangeListener(listener1);
+ assertEquals(2, notifier.getItemSetChangeListeners().size());
+
+ ItemSetChangeEvent event = Mockito.mock(ItemSetChangeEvent.class);
+ notifier.fireItemSetChange(event);
+
+ notifier.removeItemSetChangeListener(listener1);
+ assertEquals(1, notifier.getItemSetChangeListeners().size());
+ notifier.removeItemSetChangeListener(listener2);
+ assertEquals(0, notifier.getItemSetChangeListeners().size());
+ notifier.removeItemSetChangeListener(listener2);
+ assertEquals(0, notifier.getItemSetChangeListeners().size());
+
+ notifier.setItemSetChangeListeners(null);
+ notifier.removeItemSetChangeListener(listener2);
+ assertEquals(null, notifier.getItemSetChangeListeners());
+
+ assertThatCode(() -> notifier.fireItemSetChange(event)).doesNotThrowAnyException();
+
+ notifier.setContainer(new DummyPolicyContainer());
+ assertThatCode(() -> notifier.fireItemSetChange()).doesNotThrowAnyException();
+
+ PolicyContainer dummySource = new DummyPolicyContainer();
+ assertEquals(dummySource, new PolicyItemSetChangeNotifier.BaseItemSetChangeEvent(dummySource).getContainer());
}
- }
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationRequestWrapperTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationRequestWrapperTest.java
new file mode 100644
index 000000000..517058309
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationRequestWrapperTest.java
@@ -0,0 +1,422 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.util;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedReader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+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;
+import org.onap.policy.api.RuleProvider;
+import org.onap.policy.common.utils.resources.TextFileUtils;
+import org.onap.policy.rest.adapter.PolicyRestAdapter;
+
+@RunWith(MockitoJUnitRunner.class)
+public class PolicyValidationRequestWrapperTest {
+
+ @Mock
+ HttpServletRequest request;
+
+ @Test
+ public void testHttpRequest() throws Exception {
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ assertNull(wrapper.populateRequestParameters((HttpServletRequest) null));
+
+ BufferedReader decisionPolicyReader = new BufferedReader(new StringReader(
+ TextFileUtils.getTextFileAsString("src/test/resources/policies/DecisionPolicy.json")));
+
+ Mockito.when(request.getReader()).thenReturn(decisionPolicyReader);
+
+ wrapper.populateRequestParameters(request);
+
+ BufferedReader policyJsonTrapFaultReader = new BufferedReader(new StringReader(
+ TextFileUtils.getTextFileAsString("src/test/resources/policies/PolicyJsonTrapFault.json")));
+
+ Mockito.when(request.getReader()).thenReturn(policyJsonTrapFaultReader);
+
+ wrapper.populateRequestParameters(request);
+
+ BufferedReader badJsonReader = new BufferedReader(new StringReader("{"));
+
+ Mockito.when(request.getReader()).thenReturn(badJsonReader);
+
+ wrapper.populateRequestParameters(request);
+ }
+
+ @Test
+ public void testDefaultParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ parameters.setPolicyConfigType(PolicyConfigType.Firewall);
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Firewall Config", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("");
+ assertNull(wrapper.populateRequestParameters((parameters)));
+
+ parameters.setConfigBody("{\"name");
+ assertNull(wrapper.populateRequestParameters((parameters)));
+
+ parameters.setConfigBodyType(PolicyType.OTHER);
+ parameters.setConfigBody(null);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Firewall Config", adapter.getConfigPolicyType());
+
+ parameters.setPolicyConfigType(PolicyConfigType.Extended);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("EXTENDED", adapter.getConfigPolicyType());
+
+ parameters.setTtlDate(null);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("NA", adapter.getTtlDate());
+ }
+
+ @Test
+ public void testConfigFirewallParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyConfigType(PolicyConfigType.Firewall);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Firewall Config", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("{\"someParameter\": \"someValue\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals(null, adapter.getSecurityZone());
+ assertEquals("ConfigName", adapter.getConfigName());
+
+ parameters.setConfigBody("{\"securityZoneId\": \"SecurityZone\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("SecurityZone", adapter.getSecurityZone());
+
+ parameters.setConfigBody("{\"configName\": \"AnotherConfigName\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("AnotherConfigName", adapter.getConfigName());
+ }
+
+ @Test
+ public void testConfigMicroserviceParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyConfigType(PolicyConfigType.MicroService);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ assertNull(wrapper.populateRequestParameters((parameters)));
+
+ parameters.setConfigBody("{\"someParameter\": \"someValue\"}");
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Micro Service", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("{\"service\": \"MyService\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("MyService", adapter.getServiceType());
+
+ parameters.setConfigBody("{\"content\": \"{}\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("\"{}\"", adapter.getPolicyJSON().toString());
+
+ parameters.setConfigBody("{\"content\": {hess:}}");
+ assertNull(wrapper.populateRequestParameters((parameters)));
+ }
+
+ @Test
+ public void testConfigOptimizationParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyConfigType(PolicyConfigType.Optimization);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Optimization", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("{\"someParameter\": \"someValue\"}");
+
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Optimization", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("{\"service\": \"MyService\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("MyService", adapter.getServiceType());
+ }
+
+ @Test
+ public void testConfigClosedLoopFaultParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyConfigType(PolicyConfigType.ClosedLoop_Fault);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("ClosedLoop_Fault", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("{\"someParameter\": \"someValue\"}");
+
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("ClosedLoop_Fault", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("{\"onapname\": \"MyOnapName\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("MyOnapName", adapter.getOnapName());
+ }
+
+ @Test
+ public void testConfigClosedLoopPmParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyConfigType(PolicyConfigType.ClosedLoop_PM);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("ClosedLoop_PM", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("{\"someParameter\": \"someValue\"}");
+
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("ClosedLoop_PM", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody(
+ "{\"onapname\": \"MyOnapName\",\"serviceTypePolicyName\":\"Service Type Policy Name\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("MyOnapName", adapter.getOnapName());
+ }
+
+ @Test
+ public void testConfigBrmsParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyConfigType(PolicyConfigType.BRMS_PARAM);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ Map<AttributeType, Map<String, String>> attributes = new LinkedHashMap<>();
+ parameters.setAttributes(attributes);
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ Map<String, String> templateMap = new LinkedHashMap<>();
+ templateMap.put("templateName", "Template Name");
+ attributes.put(AttributeType.RULE, templateMap);
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("BRMS_Param", adapter.getConfigPolicyType());
+ assertEquals("Template Name", adapter.getRuleName());
+
+ parameters.setConfigBody("{\"someParameter\": \"someValue\"}");
+
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("BRMS_Param", adapter.getConfigPolicyType());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testDecisionRainyDayParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyClass(PolicyClass.Decision);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ Map<AttributeType, Map<String, String>> attributes = new LinkedHashMap<>();
+ parameters.setAttributes(attributes);
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ parameters.setRuleProvider(RuleProvider.RAINY_DAY);
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ Map<String, String> treatments = new LinkedHashMap<>();
+ parameters.setTreatments(treatments);
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Rainy_Day", adapter.getRuleProvider());
+
+ treatments.put("ATreatment", "A Treatment Value");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("ATreatment", ((Map<String, String>) adapter.getRainyday().getTreatmentTableChoices().get(0))
+ .get("errorcode"));
+ assertEquals("A Treatment Value",
+ ((Map<String, String>) adapter.getRainyday().getTreatmentTableChoices().get(0))
+ .get("treatment"));
+
+ Map<String, String> matchingMap = new LinkedHashMap<>();
+ matchingMap.put("ServiceType", "AServiceType");
+ attributes.put(AttributeType.MATCHING, matchingMap);
+ parameters.setAttributes(attributes);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("AServiceType", adapter.getRainyday().getServiceType());
+ }
+
+ @Test
+ public void testDecisionGuardParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyClass(PolicyClass.Decision);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ Map<AttributeType, Map<String, String>> attributes = new LinkedHashMap<>();
+ parameters.setAttributes(attributes);
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ parameters.setRuleProvider(RuleProvider.GUARD_BL_YAML);
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("GUARD_BL_YAML", adapter.getRuleProvider());
+
+ parameters.setRuleProvider(RuleProvider.GUARD_MIN_MAX);
+
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("GUARD_MIN_MAX", adapter.getRuleProvider());
+
+ parameters.setRuleProvider(RuleProvider.GUARD_YAML);
+
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("GUARD_YAML", adapter.getRuleProvider());
+
+ Map<String, String> matchingMap = new LinkedHashMap<>();
+ matchingMap.put("actor", "Actor");
+ matchingMap.put("recipe", "Recipe");
+ matchingMap.put("guardActiveStart", "GuardActiveStart");
+ matchingMap.put("guardActiveEnd", "GuardActiveEnd");
+ matchingMap.put("limit", "Limit");
+ matchingMap.put("timeWindow", "Window");
+ matchingMap.put("timeUnits", "Units");
+
+ attributes.put(AttributeType.MATCHING, matchingMap);
+ parameters.setAttributes(attributes);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Actor", adapter.getYamlparams().getActor());
+ assertEquals("Recipe", adapter.getYamlparams().getRecipe());
+ assertEquals("GuardActiveStart", adapter.getYamlparams().getGuardActiveStart());
+ assertEquals("GuardActiveEnd", adapter.getYamlparams().getGuardActiveEnd());
+ assertEquals("Limit", adapter.getYamlparams().getLimit());
+ assertEquals("Window", adapter.getYamlparams().getTimeWindow());
+ assertEquals("Units", adapter.getYamlparams().getTimeUnits());
+
+ parameters.setRuleProvider(RuleProvider.GUARD_MIN_MAX);
+ matchingMap.put("min", "TheMin");
+ matchingMap.put("max", "TheMax");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("TheMin", adapter.getYamlparams().getMin());
+ assertEquals("TheMax", adapter.getYamlparams().getMax());
+
+ parameters.setRuleProvider(RuleProvider.GUARD_BL_YAML);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertTrue(adapter.getYamlparams().getBlackList().isEmpty());
+
+ matchingMap.put("blackList", "Bad0,Bad1");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Bad0", adapter.getYamlparams().getBlackList().get(0));
+ assertEquals("Bad1", adapter.getYamlparams().getBlackList().get(1));
+
+ parameters.setRuleProvider(RuleProvider.AAF);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertNull(adapter.getYamlparams());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testActionParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyClass(PolicyClass.Action);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertTrue(adapter.getRuleAlgorithmschoices().isEmpty());
+
+ List<String> dynamicRuleAlgorithmLabels = new ArrayList<>();
+ parameters.setDynamicRuleAlgorithmLabels(dynamicRuleAlgorithmLabels);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertTrue(adapter.getRuleAlgorithmschoices().isEmpty());
+
+ dynamicRuleAlgorithmLabels.add("Label0");
+ List<String> dynamicRuleAlgorithmFunctions = new ArrayList<>();
+ dynamicRuleAlgorithmFunctions.add("FirstAlgorithmFunction");
+ parameters.setDynamicRuleAlgorithmFunctions(dynamicRuleAlgorithmFunctions);
+ List<String> dynamicRuleAlgorithmField1 = new ArrayList<>();
+ dynamicRuleAlgorithmField1.add("FirstAlgorithmFunctionField1");
+ parameters.setDynamicRuleAlgorithmField1(dynamicRuleAlgorithmField1);
+ List<String> dynamicRuleAlgorithmField2 = new ArrayList<>();
+ dynamicRuleAlgorithmField2.add("FirstAlgorithmFunctionField2");
+ parameters.setDynamicRuleAlgorithmField2(dynamicRuleAlgorithmField2);
+ parameters.setDynamicRuleAlgorithmLabels(dynamicRuleAlgorithmLabels);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals(1, adapter.getRuleAlgorithmschoices().size());
+ assertEquals("Label0", ((LinkedHashMap<String, String>) adapter.getRuleAlgorithmschoices().get(0)).get("id"));
+
+ Map<String, String> matchingMap = new LinkedHashMap<>();
+ matchingMap.put("AKey", "AValue");
+
+ Map<AttributeType, Map<String, String>> attributes = new LinkedHashMap<>();
+ attributes.put(AttributeType.MATCHING, matchingMap);
+ parameters.setAttributes(attributes);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("AKey", ((LinkedHashMap<String, String>) adapter.getAttributes().get(0)).get("key"));
+ }
+
+ private PolicyParameters createParametersObject() {
+ PolicyParameters parameters = new PolicyParameters();
+
+ parameters.setPolicyName("PolicyName");
+ parameters.setOnapName("ONAPName");
+ parameters.setPriority("SomePriority");
+ parameters.setConfigName("ConfigName");
+ parameters.setRiskType("RiskType");
+ parameters.setRiskLevel("RiskLevel");
+ parameters.setGuard(false);
+ parameters.setTtlDate(new Date());
+
+ return parameters;
+ }
+}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationTest.java
index 6051db4c3..d019c6370 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationTest.java
@@ -3,13 +3,14 @@
* ONAP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,20 +18,44 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.rest.util;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.LinkedHashMap;
+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.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
import org.onap.policy.api.PolicyConfigType;
import org.onap.policy.api.PolicyParameters;
+import org.onap.policy.common.utils.resources.TextFileUtils;
+import org.onap.policy.rest.adapter.ClosedLoopFaultTrapDatas;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
+import org.onap.policy.rest.dao.CommonClassDao;
+import org.onap.policy.rest.jpa.MicroServiceModels;
+@RunWith(MockitoJUnitRunner.class)
public class PolicyValidationTest {
+ @Mock
+ private CommonClassDao commonClassDao;
@Before
public void setUp() throws Exception {
@@ -41,9 +66,7 @@ public class PolicyValidationTest {
}
@Test
- public void microServicePolicyTests() throws Exception{
- PolicyValidation validation = new PolicyValidation();
- PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+ public void microServicePolicyTests() throws Exception {
PolicyParameters policyParameters = new PolicyParameters();
policyParameters.setPolicyConfigType(PolicyConfigType.MicroService);
@@ -51,8 +74,8 @@ public class PolicyValidationTest {
policyParameters.setPolicyDescription("This is a sample Micro Service policy Create example");
policyParameters.setOnapName("DCAE");
policyParameters.setPriority("1");
- String MSjsonString = "{\"service\":\"TOSCA_namingJenny\",\"location\":\"Test DictMSLoc\",\"uuid\":\"testDict DCAEUIID\",\"policyName\":\"testModelValidation\",\"description\":\"test\",\"configName\":\"testDict MSConfName\",\"templateVersion\":\"1607\",\"version\":\"gw12181031\",\"priority\":\"5\",\"policyScope\":\"resource=ResourcetypeVenktest1,service=ServiceName1707,type=Name1707,closedLoopControlName=Retest_retest1\",\"riskType\":\"Test\",\"riskLevel\":\"3\",\"guard\":\"True\",\"content\":{\"police-instance-name\":\"testing\",\"naming-models\":[{\"naming-properties\":[{\"property-value\":\"test\",\"source-endpoint\":\"test\",\"property-name\":\"testPropertyname\",\"increment-sequence\":{\"scope\":\"VNF\",\"start-value\":\"1\",\"length\":\"3\",\"increment\":\"2\"},\"source-system\":\"TOSCA\"}],\"naming-type\":\"testNamingType\",\"naming-recipe\":\"testNamingRecipe\"}]}}";;
- policyParameters.setConfigBody(MSjsonString);
+ String msJsonString = TextFileUtils.getTextFileAsString("src/test/resources/policies/MicroServicePolicy.json");
+ policyParameters.setConfigBody(msJsonString);
policyParameters.setRequestID(UUID.randomUUID());
SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
Date date = dateformat3.parse("15/10/2016");
@@ -62,19 +85,1202 @@ public class PolicyValidationTest {
policyParameters.setRiskType("TEST");
policyParameters.setRequestID(UUID.randomUUID());
-
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
PolicyRestAdapter policyData = wrapper.populateRequestParameters(policyParameters);
- StringBuilder responseString = validation.validatePolicy(policyData);
+ PolicyValidation validation = new PolicyValidation();
+ String responseString = validation.validatePolicy(policyData).toString();
+
+ assertNotSame("success", responseString);
+
+ new PolicyValidation(null);
+ assertNull(PolicyValidation.getCommonClassDao());
+
+ policyData.setConfigPolicyType("ClosedLoop_Fault");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).doesNotContain("success");
+
+ policyData.setConfigPolicyType("ClosedLoop_PM");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).doesNotContain("success");
+
+ policyData.setConfigPolicyType("Enforcer Config");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).doesNotContain("success");
+
+ policyData.setConfigPolicyType("Optimization");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).doesNotContain("success");
+
+ policyData.setConfigPolicyType("Strange");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).doesNotContain("success");
+ }
+
+ @Test
+ public void testPolicyHeadingValidation() throws IOException {
+ PolicyValidation validation = new PolicyValidation();
+ PolicyRestAdapter policyData = new PolicyRestAdapter();
+
+ String responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("PolicyName Should not be empty");
+
+ policyData.setPolicyName("%%%~~~%%%");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("The Value in Required Field will allow only '{0-9}, {a-z}, {A-Z}");
+
+ policyData.setPolicyName("ALegalPolicyName");
+ policyData.setPolicyDescription("@CreatedBy:");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString)
+ .contains("The value in the description shouldn't contain @CreatedBy: or @ModifiedBy:");
+ policyData.setPolicyDescription("@CreatedBy:");
+
+ policyData.setPolicyDescription("A Legal Description");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString)
+ .doesNotContain("The value in the description shouldn't contain @CreatedBy: or @ModifiedBy:");
+ }
+
+ @Test
+ public void testPolicyAttributeValidation() throws IOException {
+ PolicyValidation validation = new PolicyValidation();
+ PolicyRestAdapter policyData = new PolicyRestAdapter();
+ policyData.setPolicyName("ALegalPolicyName");
+ policyData.setPolicyDescription("A Valid Description");
+
+ String responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ policyData.setApiflag("API");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ policyData.setApiflag("NOTAPI");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ List<Object> attributes = new ArrayList<>();
+ policyData.setAttributes(attributes);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ attributes.add(new String("hello"));
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+ attributes.clear();
+
+ Map<String, String> mapAttribute = new LinkedHashMap<>();
+ attributes.add(mapAttribute);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Component Attributes</b>:<i> has one missing Component Attribute value");
+
+ mapAttribute.put("key", "value");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("<b>Component Attributes</b>:<i> has one missing Component Attribute value</i><br>",
+ responseString);
+
+ mapAttribute.put("key", "");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("<b>Attributes or Component Attributes</b>:<i>null : value has spaces or invalid characters</i>"
+ + "<br><b>Component Attributes</b>:<i> has one missing Component Attribute value</i><br>",
+ responseString);
+ mapAttribute.clear();
+
+ responseString = validation.validatePolicy(policyData).toString();
+ mapAttribute.put("hello", "aaa");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("<b>Component Attributes</b>:<i> has one missing Component Attribute key</i><br>"
+ + "<b>Component Attributes</b>:<i> has one missing Component Attribute value</i><br>",
+ responseString);
+
+ policyData.setPolicyType("Config");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("<b>RiskType</b>: Risk Type Should not be Empty</i><br>"
+ + "<b>RiskLevel</b>: Risk Level Should not be Empty</i><br>"
+ + "<b>Guard</b>: Guard Value Should not be Empty</i><br>", responseString);
+
+ policyData.setConfigPolicyType("Base");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("has one missing Attribute key");
+
+ policyData.setConfigPolicyType("BRMS_Param");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("has one missing Attribute key");
+
+ policyData.setConfigPolicyType("BRMS_Raw");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("has one missing Attribute key");
+
+ policyData.setConfigPolicyType(null);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Risk Level Should not be Empty");
+
+ mapAttribute.clear();
+ mapAttribute.put("value", "thevalue");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Risk Level Should not be Empty");
+
+ mapAttribute.put("value", "$$$%%%%");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Risk Level Should not be Empty");
+
+ policyData.setConfigPolicyType("Base");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("value has spaces or invalid characters");
+
+ policyData.setConfigPolicyType("BRMS_Param");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("value has spaces or invalid characters");
+
+ policyData.setConfigPolicyType("BRMS_Raw");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("value has spaces or invalid characters");
+
+ policyData.setConfigPolicyType(null);
+ policyData.setPolicyType(null);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("value has spaces or invalid characters");
+ }
+
+ @Test
+ public void testPolicySettingsValidation() throws IOException {
+ PolicyValidation validation = new PolicyValidation();
+ PolicyRestAdapter policyData = new PolicyRestAdapter();
+ policyData.setPolicyName("ALegalPolicyName");
+ policyData.setPolicyDescription("A Valid Description");
+
+ String responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ policyData.setApiflag("API");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ policyData.setApiflag("NOTAPI");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ List<Object> settings = new ArrayList<>();
+ policyData.setSettings(settings);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ settings.add("hello");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+ settings.clear();
+
+ Map<String, String> mapSetting = new LinkedHashMap<>();
+ settings.add(mapSetting);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Settings Attributes</b>:<i> has one missing Attribute key");
+
+ mapSetting.put("key", "value");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("<b>Settings Attributes</b>:<i> has one missing Attribute Value</i><br>", responseString);
+
+ mapSetting.put("key", "");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("<b>Settings Attributes</b>:<i> has one missing Attribute Value</i><br>", responseString);
+ mapSetting.clear();
+
+ mapSetting.put("value", "thevalue");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("has one missing Attribute key");
+
+ mapSetting.put("value", "$$$%%%");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("value has spaces or invalid characters");
+ }
+
+ @Test
+ public void testPolicyRuleAlgorithmsValidation() throws IOException {
+ PolicyValidation validation = new PolicyValidation();
+ PolicyRestAdapter policyData = new PolicyRestAdapter();
+ policyData.setPolicyName("ALegalPolicyName");
+ policyData.setPolicyDescription("A Valid Description");
+
+ String responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ policyData.setApiflag("API");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ policyData.setApiflag("NOTAPI");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ List<Object> ruleAlgorithmschoices = new ArrayList<>();
+ policyData.setRuleAlgorithmschoices(ruleAlgorithmschoices);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ ruleAlgorithmschoices.add("hello");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+ ruleAlgorithmschoices.clear();
+
+ Map<String, String> mapChoice = new LinkedHashMap<>();
+ ruleAlgorithmschoices.add(mapChoice);
+ assertNull(validation.validatePolicy(policyData));
+
+ mapChoice.clear();
+ mapChoice.put("id", "TheID");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Field 1 value is not selected");
+
+ mapChoice.put("dynamicRuleAlgorithmField1", "Field1");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Field 2 value is not selected");
+
+ mapChoice.put("dynamicRuleAlgorithmCombo", "Combo");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Field 3 value is empty");
+
+ mapChoice.put("dynamicRuleAlgorithmField2", "Field2");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ mapChoice.put("dynamicRuleAlgorithmField2", "%%%$$$");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Field 3 value has special characters");
+ }
+
+ @Test
+ public void testPolicyConfigBaseValidation() throws IOException {
+ PolicyValidation validation = new PolicyValidation();
+ PolicyRestAdapter policyData = new PolicyRestAdapter();
+ policyData.setPolicyName("ALegalPolicyName");
+ policyData.setPolicyDescription("A Valid Description");
+
+ String responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ policyData.setApiflag("API");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ policyData.setPolicyType("Config");
+ policyData.setConfigPolicyType("Base");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Onap Name Should not be empty");
+
+ policyData.setOnapName("%%%$$$$");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>OnapName</b>:<i>The Value in Required Field");
+
+ policyData.setOnapName("AValidOnapName");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Risk Level Should not be Empty");
+
+ policyData.setRiskType("%%%$$$$");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>RiskType</b>:<i>The Value in Required Field");
+
+ policyData.setRiskType("AValidRiskType");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Risk Level Should not be Empty");
+
+ policyData.setRiskLevel("%%%$$$$");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>RiskLevel</b>:<i>The Value in Required Field");
+
+ policyData.setRiskLevel("AValidRiskLevel");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Guard Value Should not be Empty");
+
+ policyData.setGuard("%%%$$$$");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>Guard</b>:<i>The Value in Required Field");
+
+ policyData.setGuard("AValidGuard");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Config Name Should not be Empty");
+
+ policyData.setConfigName("%%%$$$$");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("ConfigName:The Value in Required Field");
+
+ policyData.setConfigName("AValidConfigName");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Config Type Should not be Empty");
+
+ policyData.setConfigType("%%%$$$$");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("ConfigType:The Value in Required Field");
+
+ policyData.setConfigType("AValidConfigType");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Config Body Should not be Empty");
+
+ policyData.setConfigBodyData("");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Config Body Should not be Empty");
+
+ policyData.setConfigBodyData("%%%$$$$");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setConfigType(null);
+ policyData.setConfigBodyData("ValidConfigBodyData");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Config Type Should not be Empty");
+
+ policyData.setConfigType("JSON");
+ policyData.setConfigBodyData("{");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Config Body: JSON Content is not valid");
+
+ policyData.setConfigBodyData("ValidConfigBodyData");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setConfigType("XML");
+ policyData.setConfigBodyData("{");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Config Body: XML Content data is not valid");
+
+ policyData.setConfigBodyData("<tag>value</tag>");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setConfigType("PROPERTIES");
+ policyData.setConfigBodyData("{");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Config Body: Property data is not valid");
+
+ policyData.setConfigBodyData("propertyName=PropertyValue");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+ }
+
+ @Test
+ public void testPolicyConfigFirewallValidation() throws IOException {
+ PolicyValidation validation = new PolicyValidation();
+ PolicyRestAdapter policyData = new PolicyRestAdapter();
+ policyData.setPolicyName("ALegalPolicyName");
+ policyData.setPolicyDescription("A Valid Description");
+
+ String responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ policyData.setApiflag("API");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ // Invalid values tested in config base test
+ policyData.setOnapName("AValidOnapName");
+ policyData.setRiskType("AValidRiskType");
+ policyData.setRiskLevel("AValidRiskLevel");
+ policyData.setGuard("AValidGuard");
+ assertEquals("success", responseString);
+
+ policyData.setPolicyType("Config");
+ policyData.setConfigPolicyType("Firewall Config");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Config Name is required");
+
+ policyData.setConfigName("");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Config Name is required");
+
+ policyData.setConfigName("%%%$$$$");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>ConfigName</b>:<i>The Value in Required Field");
+
+ policyData.setConfigName("AValidConfigName");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Security Zone is required");
+
+ policyData.setSecurityZone("");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Security Zone is required");
+
+ policyData.setSecurityZone("AValidSeurityZone");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+ }
+
+ @Test
+ public void testPolicyConfigBRMSValidation() throws IOException {
+ PolicyValidation validation = new PolicyValidation();
+ PolicyRestAdapter policyData = new PolicyRestAdapter();
+ policyData.setPolicyName("ALegalPolicyName");
+ policyData.setPolicyDescription("A Valid Description");
+
+ String responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ policyData.setApiflag("API");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ // Invalid values tested in config base test
+ policyData.setOnapName("AValidOnapName");
+ policyData.setRiskType("AValidRiskType");
+ policyData.setRiskLevel("AValidRiskLevel");
+ policyData.setGuard("AValidGuard");
+ assertEquals("success", responseString);
+
+ policyData.setPolicyType("Config");
+ policyData.setConfigPolicyType("BRMS_Param");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("BRMS Template is required");
+
+ policyData.setRuleName("");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("BRMS Template is required");
+
+ policyData.setRuleName("AValidRuleName");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+ policyData.setRuleName(null);
+
+ policyData.setConfigPolicyType("BRMS_Raw");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Raw Rule is required");
+
+ policyData.setConfigBodyData("");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Raw Rule is required");
+
+ policyData.setConfigBodyData("InvalidConfigBodyData");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("expecting one of the following tokens");
+
+ policyData.setConfigBodyData("import org.onap.policy.test.DummyTestSomething;");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+ }
+
+ @Test
+ public void testPolicyConfigCloseLoopPmValidation() throws IOException {
+ PolicyValidation validation = new PolicyValidation();
+ PolicyRestAdapter policyData = new PolicyRestAdapter();
+ policyData.setPolicyName("ALegalPolicyName");
+ policyData.setPolicyDescription("A Valid Description");
+
+ String responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
- assertNotSame("success", responseString.toString());
+ policyData.setApiflag("API");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+ // Invalid values tested in config base test
+ policyData.setOnapName("AValidOnapName");
+ policyData.setRiskType("AValidRiskType");
+ policyData.setRiskLevel("AValidRiskLevel");
+ policyData.setGuard("AValidGuard");
+ assertEquals("success", responseString);
+
+ policyData.setPolicyType("Config");
+ policyData.setConfigPolicyType("ClosedLoop_PM");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("ServiceType PolicyName is required");
+
+ Map<String, String> serviceTypePolicyName = null;
+ policyData.setServiceTypePolicyName(serviceTypePolicyName);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("ServiceType PolicyName is required");
+
+ serviceTypePolicyName = new LinkedHashMap<>();
+ policyData.setServiceTypePolicyName(serviceTypePolicyName);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("ServiceType PolicyName is required");
+
+ serviceTypePolicyName.put("AKey", "AValue");
+ policyData.setServiceTypePolicyName(serviceTypePolicyName);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("ServiceType PolicyName is required");
+ serviceTypePolicyName.clear();
+
+ serviceTypePolicyName.put("serviceTypePolicyName", "");
+ policyData.setServiceTypePolicyName(serviceTypePolicyName);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("ServiceType PolicyName is required");
+
+ serviceTypePolicyName.put("serviceTypePolicyName", "AValidserviceTypePolicyName");
+ policyData.setServiceTypePolicyName(serviceTypePolicyName);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ policyData.setJsonBody("");
+ assertNull(validation.validatePolicy(policyData));
+
+ policyData.setJsonBody("InvalidConfigBodyData");
+ assertNull(validation.validatePolicy(policyData));
+
+ policyData.setJsonBody("{}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ policyData.setJsonBody("{\"gamma\": false}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ policyData.setJsonBody("{\"gamma\": true}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setJsonBody("{\"mcr\": false}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ policyData.setJsonBody("{\"mcr\": true}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setJsonBody("{\"trinity\": false}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ policyData.setJsonBody("{\"trinity\": true}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setJsonBody("{\"vDNS\": false}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ policyData.setJsonBody("{\"vDNS\": true}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setJsonBody("{\"vUSP\": false}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ policyData.setJsonBody("{\"vUSP\": true}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setJsonBody("{\"trinity\": true, \"emailAddress\": null}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setJsonBody("{\"trinity\": true, \"emailAddress\": \"\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Email Address is not Valid");
+
+ policyData.setJsonBody("{\"trinity\": true, \"emailAddress\": \"%%%$$$\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Email Address is not Valid");
+
+ policyData.setJsonBody("{\"trinity\": true, \"emailAddress\": \"dorothy@emealdcity.oz\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setJsonBody("{\"trinity\": true, \"geoLink\": null}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setJsonBody("{\"trinity\": true, \"geoLink\": \"\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setJsonBody("{\"trinity\": true, \"geoLink\": \"$$$%%%\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("The Value in Required Field");
+
+ policyData.setJsonBody("{\"trinity\": true, \"geoLink\": \"AValidGeoLink\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setJsonBody("{\"trinity\": true, \"attributes\": null}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setJsonBody("{\"trinity\": true, \"attributes\": {}}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setJsonBody("{\"trinity\": true, \"attributes\": {\"an0\":\"av0\"}}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setJsonBody("{\"trinity\": true, \"attributes\": {\"an0\":\"$$$%%%\"}}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("value has spaces or invalid characters");
+
+ policyData.setJsonBody("{\"trinity\": true, \"attributes\": {\"Message\":\"$$$%%%\"}}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
}
@Test
- public final void testEmailValidation() {
+ public void testPolicyConfigCloseLoopFaultValidation() throws IOException {
PolicyValidation validation = new PolicyValidation();
- String result = validation.emailValidation("testemail@test.com", "SUCCESS");
- assertEquals("success", result);
+ PolicyRestAdapter policyData = new PolicyRestAdapter();
+ policyData.setPolicyName("ALegalPolicyName");
+ policyData.setPolicyDescription("A Valid Description");
+
+ String responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ policyData.setApiflag("API");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ // Invalid values tested in config base test
+ policyData.setOnapName("AValidOnapName");
+ policyData.setRiskType("AValidRiskType");
+ policyData.setRiskLevel("AValidRiskLevel");
+ policyData.setGuard("AValidGuard");
+ assertEquals("success", responseString);
+
+ policyData.setPolicyType("Config");
+ policyData.setConfigPolicyType("ClosedLoop_Fault");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ policyData.setJsonBody("");
+ assertNull(validation.validatePolicy(policyData));
+
+ policyData.setJsonBody("InvalidConfigBodyData");
+ assertNull(validation.validatePolicy(policyData));
+
+ policyData.setJsonBody("{}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("There were no conditions provided in configBody json");
+
+ policyData.setJsonBody("{\"conditions\": null}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("There were no conditions provided in configBody json");
+
+ policyData.setJsonBody("{\"conditions\": \"\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select At least one Condition");
+
+ policyData.setJsonBody("{\"conditions\": \"AValidCondition\"}");
+ assertNull(validation.validatePolicy(policyData));
+
+ policyData.setApiflag("NOAPI");
+
+ policyData.setJsonBody("");
+ assertNull(validation.validatePolicy(policyData));
+
+ policyData.setJsonBody("InvalidConfigBodyData");
+ assertNull(validation.validatePolicy(policyData));
+
+ ClosedLoopFaultTrapDatas trapDatas = new ClosedLoopFaultTrapDatas();
+ policyData.setTrapDatas(trapDatas);
+
+ ClosedLoopFaultTrapDatas faultDatas = new ClosedLoopFaultTrapDatas();
+ policyData.setFaultDatas(faultDatas);
+
+ policyData.setJsonBody("{}");
+ assertThat(responseString).contains("Select At least one Condition");
+
+ List<Object> trap1 = new ArrayList<>();
+ trapDatas.setTrap1(trap1);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Trigger Clear TimeOut is required");
+
+ policyData.setClearTimeOut("AValidClearTimeout");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Trap Max Age is required");
+
+ policyData.setTrapMaxAge("AValidTrapMaxAge");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ trapDatas.setTrap1(null);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ faultDatas.setTrap1(null);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ faultDatas.setTrap1(trap1);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Fault Clear TimeOut is required when");
+
+ policyData.setVerificationclearTimeOut("AValidVerificationClearTimeout");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ policyData.setJsonBody("{\"gamma\": false}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ policyData.setJsonBody("{\"gamma\": true}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("vPRO Actions is required");
+
+ policyData.setJsonBody("{\"mcr\": false}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ policyData.setJsonBody("{\"mcr\": true}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("vPRO Actions is required");
+
+ policyData.setJsonBody("{\"trinity\": false}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ policyData.setJsonBody("{\"trinity\": true}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("vPRO Actions is required");
+
+ policyData.setJsonBody("{\"vDNS\": false}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ policyData.setJsonBody("{\"vDNS\": true}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("vPRO Actions is required");
+
+ policyData.setJsonBody("{\"vUSP\": false}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select at least one D2");
+
+ policyData.setJsonBody("{\"vUSP\": true}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("vPRO Actions is required");
+
+ policyData.setJsonBody("{\"trinity\": true, \"emailAddress\": null}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("vPRO Actions is required");
+
+ policyData.setJsonBody("{\"trinity\": true, \"emailAddress\": \"\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("vPRO Actions is required");
+
+ policyData.setJsonBody("{\"trinity\": true, \"emailAddress\": \"%%%$$$\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Email Address is not Valid");
+
+ policyData.setJsonBody("{\"trinity\": true, \"emailAddress\": \"dorothy@emealdcity.oz\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("vPRO Actions is required");
+
+ policyData.setJsonBody("{\"trinity\": true, \"actions\": null}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("vPRO Actions is required");
+
+ policyData.setJsonBody("{\"trinity\": true, \"actions\": \"\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("vPRO Actions is required");
+
+ policyData.setJsonBody("{\"trinity\": true, \"actions\": \"$$$%%%\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Policy Status is required");
+ assertThat(responseString).contains("Vnf Type is required");
+
+ policyData.setJsonBody("{\"trinity\": true, \"actions\": \"ValidActions\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Policy Status is required");
+
+ policyData.setJsonBody("{\"trinity\": true, \"actions\": \"ValidActions\", \"closedLoopPolicyStatus\": null}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Policy Status is required");
+
+ policyData.setJsonBody("{\"trinity\": true, \"actions\": \"ValidActions\", \"closedLoopPolicyStatus\": \"\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Policy Status is required");
+
+ policyData.setJsonBody(
+ "{\"trinity\": true, \"actions\": \"ValidActions\", \"closedLoopPolicyStatus\": \"$$$%%%\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select At least one Condition");
+
+ // @formatter:off
+ policyData.setJsonBody("{"
+ + "\"trinity\": true,"
+ + "\"actions\": \"ValidActions\","
+ + "\"closedLoopPolicyStatus\": \"AValidStatus\""
+ + "}");
+ // @formatter:on
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select At least one Condition");
+
+ // @formatter:off
+ policyData.setJsonBody("{"
+ + "\"trinity\": true,"
+ + "\"actions\": \"ValidActions\","
+ + "\"closedLoopPolicyStatus\": \"AValidStatus\","
+ + "\"conditions\": null"
+ + "}");
+ // @formatter:on
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Select At least one Condition");
+
+ // @formatter:off
+ policyData.setJsonBody("{"
+ + "\"trinity\": true,"
+ + "\"actions\": \"ValidActions\","
+ + "\"closedLoopPolicyStatus\": \"AValidStatus\","
+ + "\"conditions\": \"SEND\""
+ + "}");
+ // @formatter:on
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Aging Window is required");
+
+ // @formatter:off
+ policyData.setJsonBody("{"
+ + "\"trinity\": true,"
+ + "\"actions\": \"ValidActions\","
+ + "\"closedLoopPolicyStatus\": \"AValidStatus\","
+ + "\"conditions\": \"SEND\","
+ + "\"geoLink\": null"
+ + "}");
+ // @formatter:on
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Aging Window is required");
+
+ // @formatter:off
+ policyData.setJsonBody("{"
+ + "\"trinity\": true,"
+ + "\"actions\": \"ValidActions\","
+ + "\"closedLoopPolicyStatus\": \"AValidStatus\","
+ + "\"conditions\": \"SEND\","
+ + "\"geoLink\": \"\""
+ + "}");
+ // @formatter:on
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Aging Window is required");
+
+ // @formatter:off
+ policyData.setJsonBody("{"
+ + "\"trinity\": true,"
+ + "\"actions\": \"ValidActions\","
+ + "\"closedLoopPolicyStatus\": \"AValidStatus\","
+ + "\"conditions\": \"SEND\","
+ + "\"geoLink\": \"%%%$$$\""
+ + "}");
+ // @formatter:on
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("GeoLink</b>:<i>The Value in Required Field");
+
+ // @formatter:off
+ policyData.setJsonBody("{"
+ + "\"trinity\": true,"
+ + "\"actions\": \"ValidActions\","
+ + "\"closedLoopPolicyStatus\": \"AValidStatus\","
+ + "\"conditions\": \"SEND\","
+ + "\"geoLink\": \"AValidGeoLink\""
+ + "}");
+ // @formatter:on
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Aging Window is required");
+
+ // @formatter:off
+ policyData.setJsonBody("{"
+ + "\"trinity\": true,"
+ + "\"actions\": \"ValidActions\","
+ + "\"closedLoopPolicyStatus\": \"AValidStatus\","
+ + "\"conditions\": \"SEND\","
+ + "\"agingWindow\": -1"
+ + "}");
+ // @formatter:on
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Time Interval is required");
+
+ // @formatter:off
+ policyData.setJsonBody("{"
+ + "\"trinity\": true,"
+ + "\"actions\": \"ValidActions\","
+ + "\"closedLoopPolicyStatus\": \"AValidStatus\","
+ + "\"conditions\": \"SEND\","
+ + "\"agingWindow\": -1,"
+ + "\"timeInterval\": -1"
+ + "}");
+ // @formatter:on
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Number of Retries is required");
+
+ // @formatter:off
+ policyData.setJsonBody("{"
+ + "\"trinity\": true,"
+ + "\"actions\": \"ValidActions\","
+ + "\"closedLoopPolicyStatus\": \"AValidStatus\","
+ + "\"conditions\": \"SEND\","
+ + "\"agingWindow\": -1,"
+ + "\"timeInterval\": -1,"
+ + "\"retrys\": -1"
+ + "}");
+ // @formatter:on
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("APP-C Timeout is required");
+
+ // @formatter:off
+ policyData.setJsonBody("{"
+ + "\"trinity\": true,"
+ + "\"actions\": \"ValidActions\","
+ + "\"closedLoopPolicyStatus\": \"AValidStatus\","
+ + "\"conditions\": \"SEND\","
+ + "\"agingWindow\": -1,"
+ + "\"timeInterval\": -1,"
+ + "\"retrys\": -1,"
+ + "\"timeOutvPRO\": -1"
+ + "}");
+ // @formatter:on
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("TimeOutRuby is required");
+
+ // @formatter:off
+ policyData.setJsonBody("{"
+ + "\"trinity\": true,"
+ + "\"actions\": \"ValidActions\","
+ + "\"closedLoopPolicyStatus\": \"AValidStatus\","
+ + "\"conditions\": \"SEND\","
+ + "\"agingWindow\": -1,"
+ + "\"timeInterval\": -1,"
+ + "\"retrys\": -1,"
+ + "\"timeOutvPRO\": -1,"
+ + "\"timeOutRuby\": -1"
+ + "}");
+ // @formatter:on
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Vnf Type is required");
+
+ // @formatter:off
+ policyData.setJsonBody("{"
+ + "\"trinity\": true,"
+ + "\"actions\": \"ValidActions\","
+ + "\"closedLoopPolicyStatus\": \"AValidStatus\","
+ + "\"conditions\": \"SEND\","
+ + "\"agingWindow\": -1,"
+ + "\"timeInterval\": -1,"
+ + "\"retrys\": -1,"
+ + "\"timeOutvPRO\": -1,"
+ + "\"timeOutRuby\": -1,"
+ + "\"vnfType\": null"
+ + "}");
+ // @formatter:on
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Vnf Type is required");
+
+ // @formatter:off
+ policyData.setJsonBody("{"
+ + "\"trinity\": true,"
+ + "\"actions\": \"ValidActions\","
+ + "\"closedLoopPolicyStatus\": \"AValidStatus\","
+ + "\"conditions\": \"SEND\","
+ + "\"agingWindow\": -1,"
+ + "\"timeInterval\": -1,"
+ + "\"retrys\": -1,"
+ + "\"timeOutvPRO\": -1,"
+ + "\"timeOutRuby\": -1,"
+ + "\"vnfType\": \"\""
+ + "}");
+ // @formatter:on
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Vnf Type is required");
+
+ // @formatter:off
+ policyData.setJsonBody("{"
+ + "\"trinity\": true,"
+ + "\"actions\": \"ValidActions\","
+ + "\"closedLoopPolicyStatus\": \"AValidStatus\","
+ + "\"conditions\": \"SEND\","
+ + "\"agingWindow\": -1,"
+ + "\"timeInterval\": -1,"
+ + "\"retrys\": -1,"
+ + "\"timeOutvPRO\": -1,"
+ + "\"timeOutRuby\": -1,"
+ + "\"vnfType\": \"AValid VNF Type\""
+ + "}");
+ // @formatter:on
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
}
+ @Test
+ public void testPolicyConfigMicroServiceValidation() throws IOException {
+ PolicyValidation validation = new PolicyValidation(commonClassDao);
+ PolicyRestAdapter policyData = new PolicyRestAdapter();
+ policyData.setPolicyName("ALegalPolicyName");
+ policyData.setPolicyDescription("A Valid Description");
+
+ String responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ policyData.setApiflag("NOAPI");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success", responseString);
+
+ // Invalid values tested in config base test
+ policyData.setOnapName("AValidOnapName");
+ policyData.setRiskType("AValidRiskType");
+ policyData.setRiskLevel("AValidRiskLevel");
+ policyData.setGuard("AValidGuard");
+ assertEquals("success", responseString);
+
+ policyData.setPolicyType("Config");
+ policyData.setConfigPolicyType("Micro Service");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Micro Service Model is required");
+
+ policyData.setServiceType("");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Micro Service Model is required");
+
+ policyData.setServiceType("ServiceType");
+ assertNull(validation.validatePolicy(policyData));
+
+ policyData.setPolicyJSON("");
+ assertNull(validation.validatePolicy(policyData));
+
+ String msJsonContentString0 = TextFileUtils
+ .getTextFileAsString("src/test/resources/policies/MicroServicePolicyContent0.json");
+ policyData.setPolicyJSON(new ObjectMapper().readTree(msJsonContentString0));
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Micro Service Version is required");
+
+ String msJsonContentString1 = TextFileUtils
+ .getTextFileAsString("src/test/resources/policies/MicroServicePolicyContent1.json");
+ policyData.setPolicyJSON(new ObjectMapper().readTree(msJsonContentString1));
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Micro Service Version is required");
+
+ policyData.setServiceType("ServiceType-vServiceVersion");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("The model name, ServiceType of version, ServiceVersion was not found");
+
+ policyData.setServiceType("ServiceType");
+ policyData.setRuleProvider("MicroService_Model");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).doesNotContain("Priority is required");
+
+ policyData.setVersion("ServiceVersion");
+ Mockito.when(commonClassDao.getDataById(MicroServiceModels.class, "modelName:version",
+ "ServiceType:ServiceVersion")).thenReturn(null);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("The model name, ServiceType of version, ServiceVersion was not found");
+
+ List<Object> msModelsList = new ArrayList<>();
+ MicroServiceModels msModels = new MicroServiceModels();
+ msModelsList.add(msModels);
+ Mockito.when(commonClassDao.getDataById(MicroServiceModels.class, "modelName:version",
+ "ServiceType:ServiceVersion")).thenReturn(msModelsList);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ msModels.setAnnotation("SomeAnntation");
+ assertNull(validation.validatePolicy(policyData));
+
+ msModels.setAnnotation("annotation0Key=annotation0Value");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ msModels.setAnnotation("annotation0Key=range::10-100");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("annotation0Key is required for the MicroService model");
+
+ msModels.setAnnotation("police-instance-name=range::10-100");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Model Range:police-instance-name must be between 10 - 100");
+
+ msModels.setAnnotation("police-instance-range=range::12-100");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Model Range:police-instance-range must be between 12 - 100");
+
+ msModels.setAnnotation("police-instance-range=range::0-10");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("Model Range:police-instance-range must be between 0 - 10");
+
+ msModels.setAnnotation("police-instance-range=range::10-100");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ msModels.setAnnotation(null);
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setRuleProvider("Not_MicroService_Model");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>Micro Service Model</b>:<i> location is required for this model");
+
+ policyData.setLocation("AValidLocation");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>Micro Service Model</b>:<i> configName is required for this model");
+
+ policyData.setConfigName("AValidConfigname");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>Micro Service Model</b>:<i> uuid is required for this model");
+
+ policyData.setUuid("AValidUUID");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>Micro Service Model</b>:<i> policyScope is required for this model");
+
+ policyData.setPolicyScope("AValidPolicyScope");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>Priority</b>:<i> Priority is required");
+
+ policyData.setPriority("AValidPriority");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ policyData.setApiflag("API");
+ assertNull(validation.validatePolicy(policyData));
+
+ msModels.setSubAttributes("{}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ msModels.setSubAttributes("{\"subAttrName0\": \"subAttrValue0\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ msModels.setSubAttributes("{\"subAttrName0\": 10}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ msModels.setSubAttributes("{\"subAttrName0\": {}}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ msModels.setSubAttributes("{\"subAttrName0\": []}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertEquals("success@#", responseString);
+
+ msModels.setSubAttributes("{\"subAttrName0\": \"subAttrValue0-required-true\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>Micro Service Model</b>:<i> subAttrName0 is required");
+
+ msModels.setSubAttributes("{\"subAttrName0\": \":subAttrValue0-required-true\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>Micro Service Model</b>:<i> subAttrName0 is required");
+
+ msModels.setSubAttributes("{\"subAttrName0\": \"UnknownType:subAttrValue0-required-true\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>Micro Service Model</b>:<i> subAttrName0 is required");
+
+ msModels.setSubAttributes("{\"subAttrName0\": \"string:subAttrValue0-required-true\"}");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>Micro Service Model</b>:<i> subAttrName0 is required");
+
+ msModels.setRefAttributes("refAttrName0=");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>Micro Service Model</b>:<i> subAttrName0 is required");
+
+ msModels.setRefAttributes("refAttrName0=refAttrValue0");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>Micro Service Model</b>:<i> subAttrName0 is required");
+
+ msModels.setRefAttributes("refAttrName0=refAttrValue0-required-true");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>Micro Service Model</b>:<i> subAttrName0 is required");
+
+ msModels.setAttributes("");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>Micro Service Model</b>:<i> subAttrName0 is required");
+
+ msModels.setAttributes("modelAttrName0=modelAttrValue0");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("<b>Micro Service Model</b>:<i> subAttrName0 is required");
+
+ msModels.setRefAttributes("refAttrName0=refAttrValue0-required-true,");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).contains("refAttrName0 is required");
+
+ msModels.setRefAttributes("police-instance-range=refAttrValue0-required-true,");
+ responseString = validation.validatePolicy(policyData).toString();
+ assertThat(responseString).doesNotContain("police-instance-range is required");
+ }
}
diff --git a/ONAP-REST/src/test/resources/policies/DecisionPolicy.json b/ONAP-REST/src/test/resources/policies/DecisionPolicy.json
new file mode 100644
index 000000000..a316b0e7e
--- /dev/null
+++ b/ONAP-REST/src/test/resources/policies/DecisionPolicy.json
@@ -0,0 +1,1556 @@
+{
+ "policyData": {
+ "data": {
+ "description": "SampelGuardBLOne@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:",
+ "policyIssuer": null,
+ "policyDefaults": null,
+ "target": {
+ "anyOf": [
+ {
+ "allOf": [
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "com.Decision_SampelGuardBLOne.4.xml"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject",
+ "attributeId": "PolicyName",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "org.onap.function.regex-match"
+ }
+ ]
+ },
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "Test"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject",
+ "attributeId": "ONAPName",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "org.onap.function.regex-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "(?i)testActor"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "actor",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "(?i)testRecipe"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "recipe",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "testCLName"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "clname",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "Use Manual Entry"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "blackListEntryType",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "combinerParametersOrRuleCombinerParametersOrVariableDefinition": [
+ {
+ "description": null,
+ "target": {
+ "anyOf": [
+ {
+ "allOf": [
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "DECIDE"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:action",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "condition": {
+ "expression": {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:environment",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:environment:current-time",
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:time-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "5:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "10:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:2.0:function:time-in-range"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Function",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-equal"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "target",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL2"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL3"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL4"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-bag"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:3.0:function:any-of"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:and"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:not"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ },
+ "obligationExpressions": null,
+ "adviceExpressions": null,
+ "ruleId": "urn:com:xacml:rule:id:284d9393-f861-4250-b62d-fc36640a363a",
+ "effect": "PERMIT"
+ },
+ {
+ "description": null,
+ "target": {
+ "anyOf": [
+ {
+ "allOf": [
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "DECIDE"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:action",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "condition": {
+ "expression": {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:environment",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:environment:current-time",
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:time-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "5:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "10:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:2.0:function:time-in-range"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Function",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-equal"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "target",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL2"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL3"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL4"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-bag"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:3.0:function:any-of"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:and"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:not"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:not"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ },
+ "obligationExpressions": null,
+ "adviceExpressions": {
+ "adviceExpression": [
+ {
+ "attributeAssignmentExpression": [
+ {
+ "expression": {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "Denied!"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ "attributeId": "guard.response",
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "issuer": null
+ }
+ ],
+ "adviceId": "GUARD_BL_YAML",
+ "appliesTo": "DENY"
+ }
+ ]
+ },
+ "ruleId": "urn:com:xacml:rule:id:284d9393-f861-4250-b62d-fc36640a363a",
+ "effect": "DENY"
+ }
+ ],
+ "obligationExpressions": null,
+ "adviceExpressions": null,
+ "policyId": "urn:com:xacml:policy:id:d56af069-6cf1-430c-ba07-e26602e06a52",
+ "version": "4",
+ "ruleCombiningAlgId": "urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides",
+ "maxDelegationDepth": null
+ },
+ "policyName": "SampelGuardBLOne",
+ "configBodyData": null,
+ "configType": null,
+ "policyID": null,
+ "policyType": "Decision",
+ "comboPolicyType": null,
+ "configPolicyType": null,
+ "policyDescription": "SampelGuardBLOne",
+ "onapName": "Test",
+ "configName": null,
+ "ruleID": null,
+ "parentPath": null,
+ "adminNotification": null,
+ "policyData": {
+ "description": "SampelGuardBLOne@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:",
+ "policyIssuer": null,
+ "policyDefaults": null,
+ "target": {
+ "anyOf": [
+ {
+ "allOf": [
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "com.Decision_SampelGuardBLOne.4.xml"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject",
+ "attributeId": "PolicyName",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "org.onap.function.regex-match"
+ }
+ ]
+ },
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "Test"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject",
+ "attributeId": "ONAPName",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "org.onap.function.regex-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "(?i)testActor"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "actor",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "(?i)testRecipe"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "recipe",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "testCLName"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "clname",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "Use Manual Entry"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "blackListEntryType",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "combinerParametersOrRuleCombinerParametersOrVariableDefinition": [
+ {
+ "description": null,
+ "target": {
+ "anyOf": [
+ {
+ "allOf": [
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "DECIDE"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:action",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "condition": {
+ "expression": {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:environment",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:environment:current-time",
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:time-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "5:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "10:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:2.0:function:time-in-range"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Function",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-equal"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "target",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL2"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL3"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL4"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-bag"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:3.0:function:any-of"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:and"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:not"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ },
+ "obligationExpressions": null,
+ "adviceExpressions": null,
+ "ruleId": "urn:com:xacml:rule:id:284d9393-f861-4250-b62d-fc36640a363a",
+ "effect": "PERMIT"
+ },
+ {
+ "description": null,
+ "target": {
+ "anyOf": [
+ {
+ "allOf": [
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "DECIDE"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:action",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "condition": {
+ "expression": {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:environment",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:environment:current-time",
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:time-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "5:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "10:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:2.0:function:time-in-range"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Function",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-equal"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "target",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL2"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL3"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL4"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-bag"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:3.0:function:any-of"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:and"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:not"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:not"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ },
+ "obligationExpressions": null,
+ "adviceExpressions": {
+ "adviceExpression": [
+ {
+ "attributeAssignmentExpression": [
+ {
+ "expression": {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "Denied!"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ "attributeId": "guard.response",
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "issuer": null
+ }
+ ],
+ "adviceId": "GUARD_BL_YAML",
+ "appliesTo": "DENY"
+ }
+ ]
+ },
+ "ruleId": "urn:com:xacml:rule:id:284d9393-f861-4250-b62d-fc36640a363a",
+ "effect": "DENY"
+ }
+ ],
+ "obligationExpressions": null,
+ "adviceExpressions": null,
+ "policyId": "urn:com:xacml:policy:id:d56af069-6cf1-430c-ba07-e26602e06a52",
+ "version": "4",
+ "ruleCombiningAlgId": "urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides",
+ "maxDelegationDepth": null
+ },
+ "gitPath": null,
+ "readOnly": false,
+ "configHome": null,
+ "configUrl": null,
+ "finalPolicyPath": null,
+ "version": null,
+ "jsonBody": null,
+ "apiflag": null,
+ "prevJsonBody": null,
+ "highestVersion": null,
+ "entityManagerFactory": null,
+ "policyExists": false,
+ "oldPolicyFileName": "Decision_SampelGuardBLOne",
+ "userId": null,
+ "newFileName": null,
+ "clWarning": null,
+ "newCLName": null,
+ "existingCLName": null,
+ "onapNameField": null,
+ "jsonBodyData": null,
+ "dirPath": null,
+ "configBodyPath": null,
+ "attributes": [
+ ],
+ "settings": [
+ ],
+ "ruleAlgorithmschoices": [
+ ],
+ "serviceTypePolicyName": null,
+ "verticaMetrics": null,
+ "description": null,
+ "attributeFields": null,
+ "clearTimeOut": null,
+ "trapMaxAge": null,
+ "verificationclearTimeOut": null,
+ "dynamicLayoutMap": null,
+ "trapDatas": null,
+ "faultDatas": null,
+ "fwPolicyType": null,
+ "fwattributes": null,
+ "parentForChild": null,
+ "securityZone": null,
+ "ruleCombiningAlgId": null,
+ "dynamicFieldConfigAttributes": null,
+ "dynamicSettingsMap": null,
+ "dropDownMap": null,
+ "actionPerformer": null,
+ "actionAttribute": null,
+ "dynamicRuleAlgorithmLabels": null,
+ "dynamicRuleAlgorithmCombo": null,
+ "dynamicRuleAlgorithmField1": null,
+ "dynamicRuleAlgorithmField2": null,
+ "dynamicVariableList": null,
+ "dataTypeList": null,
+ "actionAttributeValue": null,
+ "ruleProvider": "GUARD_BL_YAML",
+ "actionBody": null,
+ "actionDictHeader": null,
+ "actionDictType": null,
+ "actionDictUrl": null,
+ "actionDictMethod": null,
+ "yamlparams": {
+ "actor": "testActor",
+ "recipe": "testRecipe",
+ "clname": "testCLName",
+ "limit": null,
+ "timeWindow": null,
+ "timeUnits": null,
+ "guardActiveStart": "5:00",
+ "guardActiveEnd": "10:00",
+ "blackList": [
+ "testBL2",
+ "testBL3",
+ "testBL4"
+ ],
+ "targets": null,
+ "blackListEntryType": "Use Manual Entry"
+ },
+ "blackListEntries": [
+ ],
+ "appendBlackListEntries": [
+ ],
+ "rainyday": {
+ "serviceType": null,
+ "vnfType": null,
+ "bbid": null,
+ "workstep": null,
+ "treatmentTableChoices": [
+ ],
+ "errorcode": null,
+ "treatment": null
+ },
+ "rainydayMap": null,
+ "errorCodeList": null,
+ "treatmentList": null,
+ "serviceType": null,
+ "uuid": null,
+ "location": null,
+ "priority": null,
+ "msLocation": null,
+ "policyJSON": null,
+ "ruleName": null,
+ "brmsParamBody": null,
+ "brmsController": null,
+ "brmsDependency": null,
+ "ruleData": null,
+ "ruleListData": null,
+ "drlRuleAndUIParams": null,
+ "policyScope": null,
+ "providerComboBox": null,
+ "riskType": null,
+ "riskLevel": null,
+ "guard": null,
+ "ttlDate": null,
+ "matching": null,
+ "triggerSignatures": null,
+ "symptomSignatures": null,
+ "logicalConnector": null,
+ "policyStatus": null,
+ "gocServerScope": null,
+ "supressionType": null,
+ "editPolicy": true,
+ "domainDir": "com",
+ "validData": false,
+ "draft": false,
+ "viewPolicy": false,
+ "blackListEntryType": "Use Manual Entry"
+ },
+ "date": "2018-03-27 13:36:12.0",
+ "version": 4
+}
diff --git a/ONAP-REST/src/test/resources/policies/MicroServicePolicy.json b/ONAP-REST/src/test/resources/policies/MicroServicePolicy.json
new file mode 100644
index 000000000..b9c06e536
--- /dev/null
+++ b/ONAP-REST/src/test/resources/policies/MicroServicePolicy.json
@@ -0,0 +1,38 @@
+{
+ "service": "TOSCA_namingJenny",
+ "location": "Test DictMSLoc",
+ "uuid": "testDict DCAEUIID",
+ "policyName": "testModelValidation",
+ "description": "test",
+ "configName": "testDict MSConfName",
+ "templateVersion": "1607",
+ "version": "gw12181031",
+ "priority": "5",
+ "policyScope": "resource=ResourcetypeVenktest1,service=ServiceName1707,type=Name1707,closedLoopControlName=Retest_retest1",
+ "riskType": "Test",
+ "riskLevel": "3",
+ "guard": "True",
+ "content": {
+ "police-instance-name": "testing",
+ "naming-models": [
+ {
+ "naming-properties": [
+ {
+ "property-value": "test",
+ "source-endpoint": "test",
+ "property-name": "testPropertyname",
+ "increment-sequence": {
+ "scope": "VNF",
+ "start-value": "1",
+ "length": "3",
+ "increment": "2"
+ },
+ "source-system": "TOSCA"
+ }
+ ],
+ "naming-type": "testNamingType",
+ "naming-recipe": "testNamingRecipe"
+ }
+ ]
+ }
+}
diff --git a/ONAP-REST/src/test/resources/policies/MicroServicePolicyContent0.json b/ONAP-REST/src/test/resources/policies/MicroServicePolicyContent0.json
new file mode 100644
index 000000000..f06d2f21c
--- /dev/null
+++ b/ONAP-REST/src/test/resources/policies/MicroServicePolicyContent0.json
@@ -0,0 +1,23 @@
+{
+ "police-instance-name": "content0",
+ "naming-models": [
+ {
+ "naming-properties": [
+ {
+ "property-value": "test",
+ "source-endpoint": "test",
+ "property-name": "testPropertyname",
+ "increment-sequence": {
+ "scope": "VNF",
+ "start-value": "1",
+ "length": "3",
+ "increment": "2"
+ },
+ "source-system": "TOSCA"
+ }
+ ],
+ "naming-type": "testNamingType",
+ "naming-recipe": "testNamingRecipe"
+ }
+ ]
+}
diff --git a/ONAP-REST/src/test/resources/policies/MicroServicePolicyContent1.json b/ONAP-REST/src/test/resources/policies/MicroServicePolicyContent1.json
new file mode 100644
index 000000000..dac78c0bb
--- /dev/null
+++ b/ONAP-REST/src/test/resources/policies/MicroServicePolicyContent1.json
@@ -0,0 +1,27 @@
+{
+ "police-instance-name": "content1",
+ "police-instance-range": "11",
+ "naming-models": [
+ {
+ "naming-properties": [
+ {
+ "property-value": "test",
+ "source-endpoint": "test",
+ "property-name": "testPropertyname",
+ "increment-sequence": {
+ "scope": "VNF",
+ "start-value": "1",
+ "length": "3",
+ "increment": "2"
+ },
+ "source-system": "TOSCA"
+ }
+ ],
+ "naming-type": "testNamingType",
+ "naming-recipe": "testNamingRecipe"
+ }
+ ],
+ "some-container": {
+ "container-name": "container-value"
+ }
+}
diff --git a/ONAP-REST/src/test/resources/policies/PolicyJsonTrapFault.json b/ONAP-REST/src/test/resources/policies/PolicyJsonTrapFault.json
new file mode 100644
index 000000000..8eafe2c2b
--- /dev/null
+++ b/ONAP-REST/src/test/resources/policies/PolicyJsonTrapFault.json
@@ -0,0 +1,9 @@
+{
+ "policyData": {
+ },
+ "trapData": {
+ },
+ "faultData": {
+ },
+ "policyJSON": "Policy JSON String"
+}