From 9450c8d0102b9188933b5d26193df754a70a7157 Mon Sep 17 00:00:00 2001 From: rb7147 Date: Fri, 16 Feb 2018 13:46:06 -0500 Subject: Added Junis for Policy ONAP-REST Cleaned the unused constructors. Cleaned the unused code. Added Junits for all JPAS. Renamed the Junit class names on removing classes. Issue-ID: POLICY-603 Change-Id: I0709ccecd7a2f3ec49367ff85f5a6d273479493e Signed-off-by: rb7147 --- .../policy/pap/xacml/rest/XACMLPapServlet.java | 2 - .../controller/DictionaryImportController.java | 20 +- ONAP-PDP-REST/pom.xml | 7 +- ONAP-REST/pom.xml | 6 + .../onap/policy/rest/XacmlAdminAuthorization.java | 182 +------ .../org/onap/policy/rest/jpa/ActionPolicyDict.java | 23 +- .../java/org/onap/policy/rest/jpa/Attribute.java | 12 +- .../onap/policy/rest/jpa/ClosedLoopD2Services.java | 16 +- .../org/onap/policy/rest/jpa/ClosedLoopSite.java | 31 +- .../org/onap/policy/rest/jpa/DecisionSettings.java | 29 +- .../org/onap/policy/rest/jpa/DescriptiveScope.java | 29 +- .../main/java/org/onap/policy/rest/jpa/FWTag.java | 14 - .../java/org/onap/policy/rest/jpa/FWTagPicker.java | 16 +- .../java/org/onap/policy/rest/jpa/OnapName.java | 25 +- .../java/org/onap/policy/rest/jpa/PEPOptions.java | 30 +- .../onap/policy/rest/jpa/PolicyEditorScopes.java | 30 +- .../java/org/onap/policy/rest/jpa/PolicyScore.java | 16 +- .../org/onap/policy/rest/jpa/PolicyVersion.java | 3 +- .../onap/policy/rest/jpa/RemoteCatalogValues.java | 27 +- .../java/org/onap/policy/rest/jpa/RiskType.java | 14 - .../java/org/onap/policy/rest/jpa/SystemLogDB.java | 13 +- .../java/org/onap/policy/rest/jpa/TermList.java | 37 +- .../java/org/onap/policy/rest/jpa/VNFType.java | 31 +- .../java/org/onap/policy/rest/jpa/VSCLAction.java | 31 +- .../onap/policy/rest/jpa/VarbindDictionary.java | 31 +- .../java/org/onap/policy/rest/XACMLRestTest.java | 79 ++- .../rest/jpa/ActionDictionaryJPAClasses.java | 249 --------- .../policy/rest/jpa/ActionDictionaryJPATest.java | 293 ++++++++++ .../policy/rest/jpa/BRMSDictionaryJPAClasses.java | 109 ---- .../policy/rest/jpa/BRMSDictionaryJPATest.java | 109 ++++ .../jpa/ClosedLoopPolicyDictionaryJPAClasses.java | 177 ------- .../jpa/ClosedLoopPolicyDictionaryJPATest.java | 172 ++++++ .../rest/jpa/CommonDictionaryJPAClasses.java | 147 ------ .../policy/rest/jpa/CommonDictionaryJPATest.java | 146 +++++ .../rest/jpa/DecisionDictionaryJPAClasses.java | 89 ---- .../policy/rest/jpa/DecisionDictionaryJPATest.java | 87 +++ .../policy/rest/jpa/FWDictionaryJPAClasses.java | 258 --------- .../onap/policy/rest/jpa/FWDictionaryJPATest.java | 257 +++++++++ .../rest/jpa/MicroServiceDictionaryJPAClasses.java | 183 ------- .../rest/jpa/MicroServiceDictionaryJPATest.java | 208 ++++++++ .../java/org/onap/policy/rest/jpa/PIPJPATest.java | 183 +++++++ .../policy/rest/jpa/PolicyEntityJPAClasses.java | 206 -------- .../onap/policy/rest/jpa/PolicyEntityJPATest.java | 206 ++++++++ .../onap/policy/rest/jpa/PolicyUtilsJPATest.java | 190 +++++++ .../policy/rest/util/MSAttributeObjectTest.java | 73 +++ .../onap/policy/rest/util/MSModelUtilsTest.java | 52 ++ .../src/test/resources/DKaTVESPolicy-v1802.xmi | 587 +++++++++++++++++++++ .../onap/policy/controller/PolicyController.java | 15 +- 48 files changed, 2643 insertions(+), 2107 deletions(-) delete mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJPAClasses.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJPATest.java delete mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BRMSDictionaryJPAClasses.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BRMSDictionaryJPATest.java delete mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJPAClasses.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJPATest.java delete mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJPAClasses.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJPATest.java delete mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DecisionDictionaryJPAClasses.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DecisionDictionaryJPATest.java delete mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FWDictionaryJPAClasses.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FWDictionaryJPATest.java delete mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJPAClasses.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJPATest.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PIPJPATest.java delete mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJPAClasses.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJPATest.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyUtilsJPATest.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/util/MSAttributeObjectTest.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/util/MSModelUtilsTest.java create mode 100644 ONAP-REST/src/test/resources/DKaTVESPolicy-v1802.xmi diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java index cf1e6fc6e..392c32ac5 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java @@ -40,7 +40,6 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.Scanner; @@ -89,7 +88,6 @@ import org.onap.policy.xacml.api.pap.ONAPPapEngineFactory; import org.onap.policy.xacml.api.pap.OnapPDP; import org.onap.policy.xacml.api.pap.OnapPDPGroup; import org.onap.policy.xacml.api.pap.PAPPolicyEngine; -import org.onap.policy.xacml.std.pap.StdPAPPolicy; import org.onap.policy.xacml.std.pap.StdPDP; import org.onap.policy.xacml.std.pap.StdPDPGroup; import org.onap.policy.xacml.std.pap.StdPDPItemSetChangeNotifier.StdItemSetChangeListener; diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java index c79f203cd..e2317e416 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java @@ -161,7 +161,7 @@ public class DictionaryImportController { if(dictionaryName.startsWith("ActionPolicyDictionary")){ dictionaryImportExists = true; for(int i = 1; i< dictSheet.size(); i++){ - ActionPolicyDict attribute = new ActionPolicyDict("", userId); + ActionPolicyDict attribute = new ActionPolicyDict(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); @@ -196,7 +196,7 @@ public class DictionaryImportController { if(dictionaryName.startsWith("OnapName")){ dictionaryImportExists = true; for(int i = 1; i< dictSheet.size(); i++){ - OnapName attribute = new OnapName("", userId); + OnapName attribute = new OnapName(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); @@ -256,7 +256,7 @@ public class DictionaryImportController { if(dictionaryName.startsWith("VNFType")){ dictionaryImportExists = true; for(int i = 1; i< dictSheet.size(); i++){ - VNFType attribute = new VNFType("", userId); + VNFType attribute = new VNFType(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); @@ -276,7 +276,7 @@ public class DictionaryImportController { if(dictionaryName.startsWith("VSCLAction")){ dictionaryImportExists = true; for(int i = 1; i< dictSheet.size(); i++){ - VSCLAction attribute = new VSCLAction("", userId); + VSCLAction attribute = new VSCLAction(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); @@ -316,7 +316,7 @@ public class DictionaryImportController { if(dictionaryName.startsWith("ClosedLoopSite")){ dictionaryImportExists = true; for(int i = 1; i< dictSheet.size(); i++){ - ClosedLoopSite attribute = new ClosedLoopSite("", userId); + ClosedLoopSite attribute = new ClosedLoopSite(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); @@ -336,7 +336,7 @@ public class DictionaryImportController { if(dictionaryName.startsWith("PEPOptions")){ dictionaryImportExists = true; for(int i = 1; i< dictSheet.size(); i++){ - PEPOptions attribute = new PEPOptions("", userId); + PEPOptions attribute = new PEPOptions(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); @@ -359,7 +359,7 @@ public class DictionaryImportController { if(dictionaryName.startsWith("VarbindDictionary")){ dictionaryImportExists = true; for(int i = 1; i< dictSheet.size(); i++){ - VarbindDictionary attribute = new VarbindDictionary("", userId); + VarbindDictionary attribute = new VarbindDictionary(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); @@ -448,7 +448,7 @@ public class DictionaryImportController { if(dictionaryName.startsWith("Settings")){ dictionaryImportExists = true; for(int i = 1; i< dictSheet.size(); i++){ - DecisionSettings attribute = new DecisionSettings("", userId); + DecisionSettings attribute = new DecisionSettings(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); @@ -632,7 +632,7 @@ public class DictionaryImportController { if(dictionaryName.startsWith("TermList")){ dictionaryImportExists = true; for(int i = 1; i< dictSheet.size(); i++){ - TermList attribute = new TermList("", userId); + TermList attribute = new TermList(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); @@ -673,7 +673,7 @@ public class DictionaryImportController { if(dictionaryName.startsWith("SearchCriteria")){ dictionaryImportExists = true; for(int i = 1; i< dictSheet.size(); i++){ - DescriptiveScope attribute = new DescriptiveScope("", userId); + DescriptiveScope attribute = new DescriptiveScope(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); diff --git a/ONAP-PDP-REST/pom.xml b/ONAP-PDP-REST/pom.xml index ed9481f37..34109c663 100644 --- a/ONAP-PDP-REST/pom.xml +++ b/ONAP-PDP-REST/pom.xml @@ -182,7 +182,7 @@ io.springfox springfox-swagger2 - 2.8.0 + 2.5.0 com.fasterxml.jackson.core @@ -190,6 +190,11 @@ + + io.springfox + springfox-swagger-ui + 2.5.0 + org.onap.policy.engine PolicyEngineAPI diff --git a/ONAP-REST/pom.xml b/ONAP-REST/pom.xml index 27f3582ef..ef8c76eef 100644 --- a/ONAP-REST/pom.xml +++ b/ONAP-REST/pom.xml @@ -185,6 +185,12 @@ tomcat-dbcp 8.5.9 + + org.powermock + powermock-module-junit4-common + 1.6.4 + + 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 c29e17637..8a59ec603 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -20,77 +20,8 @@ package org.onap.policy.rest; -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.rest.jpa.UserInfo; -import org.onap.policy.xacml.api.XACMLErrorConstants; - -import com.att.research.xacml.api.DataTypeException; -import com.att.research.xacml.api.Decision; -import com.att.research.xacml.api.Request; -import com.att.research.xacml.api.Response; -import com.att.research.xacml.api.Result; -import com.att.research.xacml.api.pdp.PDPEngine; -import com.att.research.xacml.api.pdp.PDPEngineFactory; -import com.att.research.xacml.api.pdp.PDPException; -import com.att.research.xacml.std.annotations.RequestParser; -import com.att.research.xacml.std.annotations.XACMLAction; -import com.att.research.xacml.std.annotations.XACMLRequest; -import com.att.research.xacml.std.annotations.XACMLResource; -import com.att.research.xacml.std.annotations.XACMLSubject; -import com.att.research.xacml.util.FactoryException; - - - public class XacmlAdminAuthorization { - private static Log logger = LogFactory.getLog(XacmlAdminAuthorization.class); - - private static UserInfo userId; - public static UserInfo getUserId() { - return userId; - } - - public static void setUserId(UserInfo userId) { - XacmlAdminAuthorization.userId = userId; - } - public enum AdminAction { - ACTION_ACCESS("access"), - ACTION_READ("read"), - ACTION_WRITE("write"), - ACTION_ADMIN("admin"); - - String action; - AdminAction(String a) { - this.action = a; - } - @Override - public String toString() { - return this.action; - } - } - - public enum AdminResource { - RESOURCE_APPLICATION("application"), - RESOURCE_POLICY_WORKSPACE("workspace"), - RESOURCE_POLICY_EDITOR("editor"), - RESOURCE_DICTIONARIES("dictionaries"), - RESOURCE_PDP_ADMIN("pdp_admin"), - RESOURCE_PIP_ADMIN("pip_admin"), - RESOURCE_SCOPES_SUPERADMIN("manage_scopes"); - - String resource; - AdminResource(String r) { - this.resource = r; - } - @Override - public String toString() { - return this.resource; - } - } - public enum Role { ROLE_GUEST("guest"), ROLE_ADMIN("admin"), @@ -109,115 +40,4 @@ public class XacmlAdminAuthorization { return this.userRole; } } - - @XACMLRequest(ReturnPolicyIdList=true) - public class AuthorizationRequest { - - @XACMLSubject(includeInResults=true) - String userID; - - @XACMLAction() - String action; - - @XACMLResource() - String resource; - - public AuthorizationRequest(String userId, String action, String resource) { - this.userID = userId; - this.action = action; - this.resource = resource; - } - - public String getUserID() { - return userID; - } - - public void setUserID(String userID) { - this.userID = userID; - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public String getResource() { - return resource; - } - - public void setResource(String resource) { - this.resource = resource; - } - } - - // - // The PDP Engine - // - protected PDPEngine pdpEngine; - - public XacmlAdminAuthorization() { - PDPEngineFactory pdpEngineFactory = null; - try { - pdpEngineFactory = PDPEngineFactory.newInstance(); - if (pdpEngineFactory == null) { - logger.error("Failed to create PDP Engine Factory"); - PolicyLogger.error("Failed to create PDP Engine Factory"); - } - this.pdpEngine = pdpEngineFactory.newEngine(); - } catch (FactoryException e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Exception create PDP Engine: " + e.getLocalizedMessage()); - PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "XacmlAdminAuthorization", "Exception create PDP Engine"); - } - } - - public boolean isAuthorized(String userid, AdminAction action, AdminResource resource) { - logger.info("authorize: " + userid + " to " + action + " with " + resource); - if (this.pdpEngine == null) { - logger.warn("no pdp engine available to authorize"); - return false; - } - Request request; - try { - request = RequestParser.parseRequest(new AuthorizationRequest(userid, action.toString(), resource.toString())); - } catch (IllegalArgumentException | IllegalAccessException | DataTypeException e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to create request: " + e.getLocalizedMessage()); - PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "XacmlAdminAuthorization", "Failed to create request"); - return false; - } - if (request == null) { - logger.error("Failed to parse request."); - PolicyLogger.error("Failed to parse request"); - return false; - } - logger.info("Request: " + request); - // - // Ask the engine - // - try { - Response response = this.pdpEngine.decide(request); - if (response == null) { - logger.error("Null response from PDP decide"); - PolicyLogger.error("Null response from PDP decide"); - } - // - // Should only be one result - // - if(response != null){ - for (Result result : response.getResults()) { - Decision decision = result.getDecision(); - logger.info("Decision: " + decision); - if (decision.equals(Decision.PERMIT)) { - return true; - } - } - } - } catch (PDPException e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "PDP Decide failed: " + e.getLocalizedMessage()); - PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "XacmlAdminAuthorization", "PDP Decide failed"); - } - return false; - } } 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 fff1bf804..7abd9a043 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -40,10 +40,6 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.onap.policy.rest.XacmlAdminAuthorization; - @Entity @Table(name="ActionPolicyDict") @@ -115,19 +111,7 @@ public class ActionPolicyDict implements Serializable { public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } - - private static Log logger = LogFactory.getLog(ActionPolicyDict.class); - public ActionPolicyDict() { - //An empty constructor - } - - public ActionPolicyDict(String string, String userid) { - this(string); - } - public ActionPolicyDict(String domain) { - this.type = domain; - } @PrePersist public void prePersist() { Date date = new Date(); @@ -137,11 +121,6 @@ public class ActionPolicyDict implements Serializable { @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy =XacmlAdminAuthorization.getUserId(); - } catch (Exception e) { - logger.error("Exception caused While adding Modified by Role"+e); - } } public int getId() { return this.id; 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 ea89eeac9..3a4624ae1 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -43,10 +43,6 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.onap.policy.rest.XacmlAdminAuthorization; - import com.fasterxml.jackson.annotation.JsonIgnore; /** @@ -58,7 +54,6 @@ import com.fasterxml.jackson.annotation.JsonIgnore; @NamedQuery(name="Attribute.findAll", query="SELECT a FROM Attribute a order by a.priority asc, a.xacmlId asc") public class Attribute implements Serializable { private static final long serialVersionUID = 1L; - private static final Log logger = LogFactory.getLog(Attribute.class); @Id @GeneratedValue(strategy = GenerationType.AUTO) @@ -181,11 +176,6 @@ public class Attribute implements Serializable { @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy = XacmlAdminAuthorization.getUserId(); - } catch (Exception e) { - logger.error("Exception caused While adding Modified by Role"+e); - } } public int getId() { 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 576889504..5fc3067f4 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -40,12 +40,6 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -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.rest.XacmlAdminAuthorization; - @Entity @Table(name = "ClosedLoopD2Services") @@ -96,8 +90,6 @@ public class ClosedLoopD2Services implements Serializable{ public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } - - private static Log LOGGER = LogFactory.getLog(ClosedLoopD2Services.class); public ClosedLoopD2Services(){ //An empty constructor @@ -113,12 +105,6 @@ public class ClosedLoopD2Services implements Serializable{ @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy = XacmlAdminAuthorization.getUserId();; - } catch (Exception e) { - LOGGER.error("Exception caused While adding Modified by Role"+e); - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "ClosedLoopD2Services", "Exception caused While adding Modified by Role"); - } } public int getId() { 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 c3acf9a21..6db176b12 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -41,21 +41,12 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.onap.policy.rest.XacmlAdminAuthorization; - -import org.onap.policy.common.logging.eelf.MessageCodes; -import org.onap.policy.common.logging.eelf.PolicyLogger; - @Entity @Table(name = "ClosedLoopSite") @NamedQuery(name="ClosedLoopSite.findAll", query="SELECT c FROM ClosedLoopSite c ") public class ClosedLoopSite implements Serializable{ private static final long serialVersionUID = 1L; - - private static String domain; @Id @@ -102,20 +93,6 @@ public class ClosedLoopSite implements Serializable{ this.userModifiedBy = userModifiedBy; } - private static Log LOGGER = LogFactory.getLog(ClosedLoopSite.class); - - public ClosedLoopSite(){ - //An empty constructor - } - - public ClosedLoopSite(String string, String userid) { - this(domain); - } - - public ClosedLoopSite(String domain) { - this.siteName = domain; - } - @PrePersist public void prePersist() { Date date = new Date(); @@ -126,12 +103,6 @@ public class ClosedLoopSite implements Serializable{ @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy = XacmlAdminAuthorization.getUserId();; - } catch (Exception e) { - LOGGER.error("Exception caused While adding Modified by Role"+e); - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "ClosedLoopSite", "Exception caused While adding Modified by Role"); - } } public int getId() { 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 ae3620294..ccd1052f0 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 @@ -39,10 +39,6 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; -import org.onap.policy.common.logging.eelf.MessageCodes; -import org.onap.policy.common.logging.eelf.PolicyLogger; -import org.onap.policy.rest.XacmlAdminAuthorization; - @Entity @Table(name="DecisionSettings") @@ -108,25 +104,7 @@ public class DecisionSettings implements Serializable { public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } - - public DecisionSettings() { - //An empty constructor - } - - public DecisionSettings(String domain) { - this.xacmlId = domain; - } - - public DecisionSettings(String domain, String user) { - this(domain); - } - public DecisionSettings(DecisionSettings copy, String user) { - this(copy.getXacmlId() + ":(0)", user); - this.datatypeBean = copy.getDatatypeBean(); - this.description = copy.getDescription(); - - } - + @PrePersist public void prePersist() { Date date = new Date(); @@ -137,11 +115,6 @@ public class DecisionSettings implements Serializable { @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy = XacmlAdminAuthorization.getUserId(); - } catch (Exception e) { - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "DecisionSettings", "Exception caused While adding Modified by Role"); - } } public int getId() { 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 68a00db98..d67a5849b 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -38,13 +38,6 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.onap.policy.rest.XacmlAdminAuthorization; - -import org.onap.policy.common.logging.eelf.MessageCodes; -import org.onap.policy.common.logging.eelf.PolicyLogger; - @Entity @Table(name = "DescriptiveScope") @@ -98,20 +91,6 @@ public class DescriptiveScope implements Serializable { public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } - - private static Log LOGGER = LogFactory.getLog(DescriptiveScope.class); - - public DescriptiveScope(){ - //An empty constructor - } - - public DescriptiveScope(String string, String userid) { - this(string); - } - - public DescriptiveScope(String domain) { - this.descriptiveScopeName = domain; - } @PrePersist public void prePersist() { @@ -123,12 +102,6 @@ public class DescriptiveScope implements Serializable { @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy =XacmlAdminAuthorization.getUserId();; - } catch (Exception e) { - LOGGER.error("Exception caused While adding Modified by Role"+e); - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "DescriptiveScope", "Exception caused While adding Modified by Role"); - } } public int getId() { 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 31ec31d21..c606dd996 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 @@ -38,12 +38,6 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -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.rest.XacmlAdminAuthorization; - @Entity @Table(name = "FWTag") @NamedQuery(name = "FWTag.findAll", query= "Select p from FWTag p") @@ -96,8 +90,6 @@ public class FWTag implements Serializable { public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } - - private static Log LOGGER = LogFactory.getLog(FWTag.class); @PrePersist public void prePersist() { @@ -109,12 +101,6 @@ public class FWTag implements Serializable { @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy =XacmlAdminAuthorization.getUserId();; - } catch (Exception e) { - LOGGER.error("Exception caused While adding Modified by Role"+e); - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "FWTag", "Exception caused While adding Modified by Role"); - } } public int getId() { 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 index 708ebf591..314a4ee9b 100644 --- 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 @@ -37,12 +37,6 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -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.rest.XacmlAdminAuthorization; - @Entity @Table(name = "FWTagPicker") @NamedQuery(name = "FWTagPicker.findAll", query= "Select p from FWTagPicker p") @@ -81,9 +75,7 @@ public class FWTagPicker implements Serializable { @ManyToOne(optional = false) @JoinColumn(name="modified_by") - private UserInfo userModifiedBy; - - private static Log logger = LogFactory.getLog(FWTagPicker.class); + private UserInfo userModifiedBy; @PrePersist public void prePersist() { @@ -95,12 +87,6 @@ public class FWTagPicker implements Serializable { @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy =XacmlAdminAuthorization.getUserId(); - } catch (Exception e) { - logger.error("Exception caused While adding Modified by Role"+e); - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "DescriptiveScope", "Exception caused While adding Modified by Role"); - } } public int getId() { 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 66ee346e1..d817f2078 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -39,10 +39,6 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import org.onap.policy.common.logging.eelf.MessageCodes; -import org.onap.policy.common.logging.eelf.PolicyLogger; -import org.onap.policy.rest.XacmlAdminAuthorization; - @Entity @Table(name="OnapName") @@ -50,8 +46,6 @@ import org.onap.policy.rest.XacmlAdminAuthorization; public class OnapName implements Serializable { private static final long serialVersionUID = 1L; - private static String domain; - @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name="id") @@ -95,18 +89,6 @@ public class OnapName implements Serializable { public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } - - public OnapName() { - //An empty constructor - } - - public OnapName(String string, String userid) { - this(domain); - } - - public OnapName(String domain) { - this.onapName = domain; - } @PrePersist public void prePersist() { @@ -118,11 +100,6 @@ public class OnapName implements Serializable { @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy =XacmlAdminAuthorization.getUserId(); - } catch (Exception e) { - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "OnapName", "Exception caused While adding Modified by Role"); - } } public String getOnapName() { return this.onapName; 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/PEPOptions.java index 869386f69..ae01999a3 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/PEPOptions.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -40,13 +40,6 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.onap.policy.rest.XacmlAdminAuthorization; - -import org.onap.policy.common.logging.eelf.MessageCodes; -import org.onap.policy.common.logging.eelf.PolicyLogger; - @Entity @Table(name = "PEPOptions") @@ -100,20 +93,7 @@ public class PEPOptions implements Serializable { public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } - - private static Log LOGGER = LogFactory.getLog(PEPOptions.class); - - public PEPOptions(){ - //An empty constructor - } - - public PEPOptions(String string, String userid) { - this(string); - } - - public PEPOptions(String domain) { - this.pepName = domain; - } + @PrePersist public void prePersist() { @@ -125,12 +105,6 @@ public class PEPOptions implements Serializable { @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy =XacmlAdminAuthorization.getUserId();; - } catch (Exception e) { - LOGGER.error("Exception caused While adding Modified by Role"+e); - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PEPOptions", "Exception caused While adding Modified by Role"); - } } public int getId() { 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 698ec36da..923f5ec6f 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -38,21 +38,11 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.onap.policy.rest.XacmlAdminAuthorization; - -import org.onap.policy.common.logging.eelf.MessageCodes; -import org.onap.policy.common.logging.eelf.PolicyLogger; - @Entity @Table(name="PolicyEditorScopes") @NamedQuery(name="PolicyEditorScopes.findAll", query="SELECT p FROM PolicyEditorScopes p ") public class PolicyEditorScopes implements Serializable{ private static final long serialVersionUID = 1L; - private static Log logger = LogFactory.getLog(PolicyEditorScopes.class); - - private static String domain; @Id @GeneratedValue(strategy = GenerationType.AUTO) @@ -78,18 +68,6 @@ public class PolicyEditorScopes implements Serializable{ @ManyToOne(optional = false) @JoinColumn(name="modified_by") private UserInfo userModifiedBy; - - public PolicyEditorScopes() { - // Empty constructor - } - - public PolicyEditorScopes(String string, String userid) { - this(domain); - } - - public PolicyEditorScopes(String domain) { - this.scopeName = domain; - } @PrePersist public void prePersist() { @@ -101,12 +79,6 @@ public class PolicyEditorScopes implements Serializable{ @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy =XacmlAdminAuthorization.getUserId(); - } catch (Exception e) { - logger.error("Exception caused While adding Modified by Role"+e); - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEditorScopes", "Exception caused While adding Modified by Role"); - } } public int getId() { 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 a9e776580..dba7299bb 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -42,8 +42,6 @@ import javax.persistence.Table; public class PolicyScore implements Serializable { private static final long serialVersionUID = 1L; - - private static String domain; @Id @GeneratedValue(strategy = GenerationType.AUTO) @@ -61,18 +59,6 @@ public class PolicyScore implements Serializable { @Column(name="POLICY_SCORE", nullable=true) private String PolicyScore; - public PolicyScore() { - // Empty constructor - } - - public PolicyScore(String pName, String pScore) { - this(domain); - - } - public PolicyScore(String domain) { - // Empty constructor - } - public int getId() { return id; } 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 663d34a17..6af607f0c 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 @@ -21,7 +21,6 @@ package org.onap.policy.rest.jpa; import java.io.Serializable; -import java.sql.Timestamp; import java.util.Date; import java.util.Objects; @@ -143,7 +142,7 @@ public class PolicyVersion implements Serializable { return createdDate; } - public void setCreatedDate(Timestamp createdDate) { + public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } 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 7d347951c..b338b186c 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -30,8 +30,6 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.NamedQuery; import javax.persistence.OrderBy; -import javax.persistence.PrePersist; -import javax.persistence.PreUpdate; import javax.persistence.Table; @@ -41,8 +39,6 @@ import javax.persistence.Table; public class RemoteCatalogValues implements Serializable { private static final long serialVersionUID = 1L; - private static String domain; - @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name="id") @@ -55,27 +51,6 @@ public class RemoteCatalogValues implements Serializable { @Column(name="value") private String value; - - public RemoteCatalogValues() { - // Empty constructor - } - public RemoteCatalogValues(String string, String userid) { - this(domain); - - } - public RemoteCatalogValues(String domain) { - // Empty constructor - } - - @PrePersist - public void prePersist() { - // Empty function - } - @PreUpdate - public void preUpdate() { - // Empty function - } - public String getValue() { return value; } 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 a533a70c1..5e6981590 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 @@ -39,12 +39,6 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -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.rest.XacmlAdminAuthorization; - @Entity @Table(name="RiskType") @@ -96,8 +90,6 @@ public class RiskType implements Serializable { this.userModifiedBy = userModifiedBy; } - private static Log LOGGER = LogFactory.getLog(RiskType.class); - @PrePersist public void prePersist() { Date date = new Date(); @@ -108,12 +100,6 @@ public class RiskType implements Serializable { @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy =XacmlAdminAuthorization.getUserId(); - } catch (Exception e) { - LOGGER.error("Exception caused While adding Modified by Role"+e); - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "RiskType", "Exception caused While adding Modified by Role"); - } } public String getRiskName() { return this.name; 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 324e92f76..45e20d632 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -80,17 +80,6 @@ public class SystemLogDB implements Serializable { this.type = type; this.logtype = logtype; } - - public void SystemLogB (int id, String system, String description, String remote, String type, Date date, String logtype){ - this.id = id; - this.system = system; - this.description = description; - this.remote = remote; - this.type = type; - this.date = date; - this.logtype = logtype; - - } public int getId() { return this.id; 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 9c18343bf..1b7186105 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -38,13 +38,6 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.onap.policy.rest.XacmlAdminAuthorization; - -import org.onap.policy.common.logging.eelf.MessageCodes; -import org.onap.policy.common.logging.eelf.PolicyLogger; - @Entity @Table(name="TERM") @@ -52,8 +45,6 @@ import org.onap.policy.common.logging.eelf.PolicyLogger; public class TermList implements Serializable { private static final long serialVersionUID = 1L; - private static String domain; - @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name="id") @@ -139,40 +130,16 @@ public class TermList implements Serializable { this.userModifiedBy = userModifiedBy; } - private static Log LOGGER = LogFactory.getLog(TermList.class); - - public TermList() { - // Empty constructor - } - - private static final Log auditLogger = LogFactory - .getLog("auditLogger"); - - public TermList(String string, String userid) { - this(domain); - } - public TermList(String domain) { - this.termName = domain; - } - @PrePersist public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; - auditLogger.debug("Added New Term Name: "+this.termName+" by "+this.userCreatedBy); - } + @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy =XacmlAdminAuthorization.getUserId();; - } catch (Exception e) { - LOGGER.error("Exception caused While adding Modified by Role"+e); - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "TermList", "Exception caused While adding Modified by Role"); - } - auditLogger.debug("Updated Term Name: "+this.termName+" by "+this.userModifiedBy); } public int getId() { 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/VNFType.java index d44e4b5b7..bffdce094 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/VNFType.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -38,13 +38,6 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.onap.policy.rest.XacmlAdminAuthorization; - -import org.onap.policy.common.logging.eelf.MessageCodes; -import org.onap.policy.common.logging.eelf.PolicyLogger; - @Entity @@ -53,8 +46,6 @@ import org.onap.policy.common.logging.eelf.PolicyLogger; public class VNFType implements Serializable { private static final long serialVersionUID = 1L; - private static String domain; - @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name="id") @@ -98,12 +89,6 @@ public class VNFType implements Serializable { public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } - - private static Log LOGGER = LogFactory.getLog(VNFType.class); - - public VNFType() { - // Empty constructor - } public String getVnftype() { return vnftype; @@ -111,14 +96,6 @@ public class VNFType implements Serializable { public void setVnftype(String vnftype) { this.vnftype = vnftype; - } - - public VNFType(String string, String userid) { - this(domain); - } - - public VNFType(String domain) { - this.vnftype = domain; } @PrePersist @@ -131,12 +108,6 @@ public class VNFType implements Serializable { @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy =XacmlAdminAuthorization.getUserId();; - } catch (Exception e) { - LOGGER.error("Exception caused While adding Modified by Role"+e); - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "VNFType", "Exception caused While adding Modified by Role"); - } } public int getId() { 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 df605ee7d..62c36e572 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -38,13 +38,6 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.onap.policy.rest.XacmlAdminAuthorization; - -import org.onap.policy.common.logging.eelf.MessageCodes; -import org.onap.policy.common.logging.eelf.PolicyLogger; - @Entity @Table(name="VSCLAction") @@ -52,8 +45,6 @@ import org.onap.policy.common.logging.eelf.PolicyLogger; public class VSCLAction implements Serializable { private static final long serialVersionUID = 1L; - private static String domain; - @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name="id") @@ -97,21 +88,7 @@ public class VSCLAction implements Serializable { public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } - - private static Log LOGGER = LogFactory.getLog(VSCLAction.class); - public VSCLAction() { - // Empty constructor - } - - public VSCLAction(String string, String userid) { - this(domain); - } - - public VSCLAction(String domain) { - this.vsclaction = domain; - } - @PrePersist public void prePersist() { Date date = new Date(); @@ -122,12 +99,6 @@ public class VSCLAction implements Serializable { @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy =XacmlAdminAuthorization.getUserId();; - } catch (Exception e) { - LOGGER.error("Exception caused While adding Modified by Role"+e); - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "VSCLAction", "Exception caused While adding Modified by Role"); - } } public int getId() { 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 376689ee7..fba4b611a 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -38,21 +38,12 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.onap.policy.rest.XacmlAdminAuthorization; - -import org.onap.policy.common.logging.eelf.MessageCodes; -import org.onap.policy.common.logging.eelf.PolicyLogger; - @Entity @Table(name="VarbindDictionary") @NamedQuery(name = "VarbindDictionary.findAll", query = "Select v FROM VarbindDictionary v") public class VarbindDictionary implements Serializable{ private static final long serialVersionUID = 1L; - private static String domain; - @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "Id") @@ -99,21 +90,7 @@ public class VarbindDictionary implements Serializable{ public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } - - private static Log LOGGER = LogFactory.getLog(VarbindDictionary.class); - public VarbindDictionary() { - // Empty constructor - } - - public VarbindDictionary(String string, String userid) { - this(domain); - } - - public VarbindDictionary(String domain) { - this.varbindName = domain; - } - @PrePersist public void prePersist() { Date date = new Date(); @@ -124,12 +101,6 @@ public class VarbindDictionary implements Serializable{ @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - try { - this.userModifiedBy =XacmlAdminAuthorization.getUserId();; - } catch (Exception e) { - LOGGER.error("Exception caused While adding Modified by Role"+e); - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "VarbindDictionary", "Exception caused While adding Modified by Role"); - } } public int getId() { 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 index 3de436481..419b14daa 100644 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/XACMLRestTest.java +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/XACMLRestTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -20,68 +20,60 @@ package org.onap.policy.rest; -/*import java.io.IOException; -import java.io.InputStream; +import static org.junit.Assert.fail; + +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Properties; -import java.util.Random; import javax.servlet.ServletConfig; -import javax.servlet.ServletInputStream; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import junit.framework.TestCase; - 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; -import com.att.research.xacml.util.XACMLProperties; -import com.mockrunner.mock.web.MockServletInputStream; - -public class XACMLRestTest extends TestCase{ +public class XACMLRestTest extends Mockito{ private static Log logger = LogFactory.getLog(XACMLRestTest.class); - - private List headers = new ArrayList(); - + + private List headers = new ArrayList<>(); + private HttpServletRequest httpServletRequest; private HttpServletResponse httpServletResponse; private ServletOutputStream mockOutput; - private ServletInputStream mockInput; 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 { + + @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)); - //pdpServlet = new XACMLPdpServlet(); - - Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.pdp.properties"); - + 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"); @@ -90,18 +82,19 @@ public class XACMLRestTest extends TestCase{ 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 testDummy(){ + } + + @Test + public void testXacmlInit(){ logger.info("XACMLRestTest - testInit"); try { - assertTrue(true); + XACMLRest.xacmlInit(servletConfig); + Logger.getRootLogger().setLevel(Level.DEBUG); + XACMLRest.dumpRequest(httpServletRequest); + XACMLRest.loadXacmlProperties(null, null); } catch (Exception e) { fail(); - } } -} -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJPAClasses.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJPAClasses.java deleted file mode 100644 index af705967c..000000000 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJPAClasses.java +++ /dev/null @@ -1,249 +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.ArrayList; -import java.util.Date; -import java.util.HashSet; - -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 ActionDictionaryJPAClasses { - - private static Logger logger = FlexLogger.getLogger(ActionDictionaryJPAClasses.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 testActionDictionary(){ - ActionPolicyDict data = new ActionPolicyDict(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setAttributeName("Test"); - assertTrue("Test".equals(data.getAttributeName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - data.setBody("Test"); - assertTrue("Test".equals(data.getBody())); - data.setHeader("Test"); - assertTrue("Test".equals(data.getHeader())); - data.setMethod("GET"); - assertTrue("GET".equals(data.getMethod())); - data.setType("JSON"); - assertTrue("JSON".equals(data.getType())); - data.setUrl("http://test.com"); - assertTrue("http://test.com".equals(data.getUrl())); - data.prePersist(); - data.preUpdate(); - 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 testFunctionArgument(){ - FunctionArgument data = new FunctionArgument(); - data.setArgIndex(1); - assertTrue(1 == data.getArgIndex()); - data.setDatatypeBean(new Datatype()); - assertTrue(data.getDatatypeBean()!=null); - data.setFunctionDefinition(new FunctionDefinition()); - assertTrue(data.getFunctionDefinition()!=null); - data.setId(1); - assertTrue(1 == data.getId()); - data.isBag(); - data.toString(); - data.setIsBag(1); - assertTrue(1 == data.getIsBag()); - new FunctionArgument(data); - } - - @Test - 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); - 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()); - data.setId(1); - assertTrue(1 == data.getId()); - data.setIsBagReturn(1); - assertTrue(1 == data.getIsBagReturn()); - data.setIsHigherOrder(1); - assertTrue(1 == data.getIsHigherOrder()); - data.setShortname("Test"); - 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()); - } - - @Test - public void testCategory(){ - Category data = new Category(); - new Category(null); - data.setAttributes(new HashSet<>()); - data.addAttribute(new Attribute()); - 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); - data.setGrouping("Test"); - assertTrue("Test".equals(data.getGrouping())); - data.setId(1); - assertTrue(1 == data.getId()); - data.setShortName("Test"); - assertTrue("Test".equals(data.getShortName())); - data.setXacmlId("Test"); - assertTrue("Test".equals(data.getXacmlId())); - } - - @Test - public void testConstraintType(){ - ConstraintType data = new ConstraintType(); - new ConstraintType("Test", "Test"); - ConstraintType.getRangeTypes(); - data.setAttributes(new HashSet<>()); - assertTrue(data.getAttributes()!=null); - data.setConstraintType("Test"); - assertTrue("Test".equals(data.getConstraintType())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - data.setId(1); - assertTrue(1 == data.getId()); - } - - @Test - public void testConstraintValue(){ - ConstraintValue data = new ConstraintValue(); - data.clone(); - new ConstraintValue(new ConstraintValue()); - new ConstraintValue("Test","Test"); - data.setAttribute(new Attribute()); - assertTrue(data.getAttribute()!=null); - data.setId(1); - assertTrue(1 == data.getId()); - data.setProperty("Test"); - assertTrue("Test".equals(data.getProperty())); - data.setValue("Test"); - assertTrue("Test".equals(data.getValue())); - } - - @Test - public void testObadvice(){ - Obadvice data = new Obadvice(); - new Obadvice(); - new Obadvice("Test", "Test"); - data.clone(); - data.addObadviceExpression(new ObadviceExpression()); - data.removeObadviceExpression(new ObadviceExpression()); - data.removeAllExpressions(); - data.prePersist(); - data.preUpdate(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setCreatedBy("Test"); - assertTrue("Test".equals(data.getCreatedBy())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - data.setFulfillOn("Test"); - assertTrue("Test".equals(data.getFulfillOn())); - data.setModifiedBy("Test"); - assertTrue("Test".equals(data.getModifiedBy())); - data.setObadviceExpressions(new HashSet<>()); - assertTrue(data.getObadviceExpressions()!=null); - data.setType("Test"); - assertTrue("Test".equals(data.getType())); - data.setXacmlId("Test"); - assertTrue("Test".equals(data.getXacmlId())); - } - - @Test - public void testObadviceExpression(){ - ObadviceExpression data = new ObadviceExpression(); - data.clone(); - data.setAttribute(new Attribute()); - assertTrue(data.getAttribute()!=null); - data.setId(1); - assertTrue(1 == data.getId()); - data.setObadvice(new Obadvice()); - assertTrue(data.getObadvice()!=null); - data.setType("Test"); - assertTrue("Test".equals(data.getType())); - } - - @Test - public void testRuleAlgorithms(){ - RuleAlgorithms data = new RuleAlgorithms(); - data.isCustom(); - data.isStandard(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setShortName("Test"); - assertTrue("Test".equals(data.getShortName())); - data.setXacmlId("Test"); - assertTrue("Test".equals(data.getXacmlId())); - data.toString(); - } - - @Test - public void testAttributeAssignment(){ - AttributeAssignment data = new AttributeAssignment(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setAttributeId(1); - assertTrue(1 == data.getAttributeId()); - data.setExpression("Test"); - assertTrue("Test".equals(data.getExpression())); - } -} 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 new file mode 100644 index 000000000..61f44bdbf --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJPATest.java @@ -0,0 +1,293 @@ +/*- + * ============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.ArrayList; +import java.util.Date; +import java.util.HashSet; + +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 ActionDictionaryJPATest { + + private static Logger logger = FlexLogger.getLogger(ActionDictionaryJPATest.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 testActionDictionary(){ + ActionPolicyDict data = new ActionPolicyDict(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setAttributeName("Test"); + assertTrue("Test".equals(data.getAttributeName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + data.setBody("Test"); + assertTrue("Test".equals(data.getBody())); + data.setHeader("Test"); + assertTrue("Test".equals(data.getHeader())); + data.setMethod("GET"); + assertTrue("GET".equals(data.getMethod())); + data.setType("JSON"); + assertTrue("JSON".equals(data.getType())); + data.setUrl("http://test.com"); + assertTrue("http://test.com".equals(data.getUrl())); + data.prePersist(); + data.preUpdate(); + 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 testFunctionArgument(){ + FunctionArgument data = new FunctionArgument(); + data.setArgIndex(1); + assertTrue(1 == data.getArgIndex()); + data.setDatatypeBean(new Datatype()); + assertTrue(data.getDatatypeBean()!=null); + data.setFunctionDefinition(new FunctionDefinition()); + assertTrue(data.getFunctionDefinition()!=null); + data.setId(1); + assertTrue(1 == data.getId()); + data.isBag(); + data.toString(); + data.setIsBag(1); + assertTrue(1 == data.getIsBag()); + new FunctionArgument(data); + } + + @Test + 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); + 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()); + data.setId(1); + assertTrue(1 == data.getId()); + data.setIsBagReturn(1); + assertTrue(1 == data.getIsBagReturn()); + data.setIsHigherOrder(1); + assertTrue(1 == data.getIsHigherOrder()); + data.setShortname("Test"); + 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()); + } + + @Test + public void testCategory(){ + Category data = new Category(); + new Category(null); + data.setAttributes(new HashSet<>()); + data.addAttribute(new Attribute()); + 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); + data.setGrouping("Test"); + assertTrue("Test".equals(data.getGrouping())); + data.setId(1); + assertTrue(1 == data.getId()); + data.setShortName("Test"); + assertTrue("Test".equals(data.getShortName())); + data.setXacmlId("Test"); + assertTrue("Test".equals(data.getXacmlId())); + } + + @Test + public void testConstraintType(){ + ConstraintType data = new ConstraintType(); + new ConstraintType("Test", "Test"); + ConstraintType.getRangeTypes(); + data.setAttributes(new HashSet<>()); + assertTrue(data.getAttributes()!=null); + data.setConstraintType("Test"); + assertTrue("Test".equals(data.getConstraintType())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + data.setId(1); + assertTrue(1 == data.getId()); + } + + @Test + public void testConstraintValue(){ + ConstraintValue data = new ConstraintValue(); + data.clone(); + new ConstraintValue(new ConstraintValue()); + new ConstraintValue("Test","Test"); + data.setAttribute(new Attribute()); + assertTrue(data.getAttribute()!=null); + data.setId(1); + assertTrue(1 == data.getId()); + data.setProperty("Test"); + assertTrue("Test".equals(data.getProperty())); + data.setValue("Test"); + assertTrue("Test".equals(data.getValue())); + } + + @Test + public void testObadvice(){ + Obadvice data = new Obadvice(); + new Obadvice(); + new Obadvice("Test", "Test"); + data.clone(); + data.addObadviceExpression(new ObadviceExpression()); + data.removeObadviceExpression(new ObadviceExpression()); + data.removeAllExpressions(); + data.prePersist(); + data.preUpdate(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setCreatedBy("Test"); + assertTrue("Test".equals(data.getCreatedBy())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + data.setFulfillOn("Test"); + assertTrue("Test".equals(data.getFulfillOn())); + data.setModifiedBy("Test"); + assertTrue("Test".equals(data.getModifiedBy())); + data.setObadviceExpressions(new HashSet<>()); + assertTrue(data.getObadviceExpressions()!=null); + data.setType("Test"); + assertTrue("Test".equals(data.getType())); + data.setXacmlId("Test"); + assertTrue("Test".equals(data.getXacmlId())); + } + + @Test + public void testObadviceExpression(){ + ObadviceExpression data = new ObadviceExpression(); + data.clone(); + data.setAttribute(new Attribute()); + assertTrue(data.getAttribute()!=null); + data.setId(1); + assertTrue(1 == data.getId()); + data.setObadvice(new Obadvice()); + assertTrue(data.getObadvice()!=null); + data.setType("Test"); + assertTrue("Test".equals(data.getType())); + } + + @Test + public void testRuleAlgorithms(){ + RuleAlgorithms data = new RuleAlgorithms(); + data.isCustom(); + data.isStandard(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setShortName("Test"); + assertTrue("Test".equals(data.getShortName())); + data.setXacmlId("Test"); + assertTrue("Test".equals(data.getXacmlId())); + data.toString(); + } + + @Test + public void testAttributeAssignment(){ + AttributeAssignment data = new AttributeAssignment(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setAttributeId(1); + assertTrue(1 == data.getAttributeId()); + data.setExpression("Test"); + assertTrue("Test".equals(data.getExpression())); + } + + @Test + public void testDatatype(){ + Datatype data = new Datatype(); + new Datatype(null); + new Datatype(1, new Datatype()); + data.setArguments(new HashSet<>()); + assertTrue(data.getArguments()!=null); + data.setAttributes(new HashSet<>()); + assertTrue(data.getAttributes()!=null); + data.setFunctions(new HashSet<>()); + assertTrue(data.getFunctions()!=null); + data.setId(1); + assertTrue(1 == data.getId()); + data.setShortName("Test"); + assertTrue("Test".equals(data.getShortName())); + data.setXacmlId("Test"); + assertTrue("Test".equals(data.getXacmlId())); + data.addArgument(new FunctionArgument()); + data.addAttribute(new Attribute()); + data.addFunction(new FunctionDefinition()); + data.removeArgument(new FunctionArgument()); + data.removeAttribute(new Attribute()); + data.removeAttribute(new FunctionDefinition()); + assertTrue(data.getIdentifer()!=null); + assertTrue(data.getIdentiferByShortName()!=null); + data.setIsStandard(Datatype.STANDARD); + assertTrue(data.isStandard()); + data.setIsStandard(Datatype.CUSTOM); + assertTrue(data.isCustom()); + } + + @Test + public void testPolicyAlgorithms(){ + PolicyAlgorithms data = new PolicyAlgorithms(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setShortName("Test"); + assertTrue("Test".equals(data.getShortName())); + data.setXacmlId("Test"); + assertTrue("Test".equals(data.getXacmlId())); + data.setIsStandard(PolicyAlgorithms.STANDARD); + assertTrue(data.isStandard()); + } +} diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BRMSDictionaryJPAClasses.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BRMSDictionaryJPAClasses.java deleted file mode 100644 index 1f09205fd..000000000 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BRMSDictionaryJPAClasses.java +++ /dev/null @@ -1,109 +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 BRMSDictionaryJPAClasses { - - private static Logger logger = FlexLogger.getLogger(BRMSDictionaryJPAClasses.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 testBRMSParamTemplate(){ - BRMSParamTemplate data = new BRMSParamTemplate(); - data.prePersist(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setRule("Test"); - assertTrue("Test".equals(data.getRule())); - data.setRuleName("Test"); - assertTrue("Test".equals(data.getRuleName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - data.setCreatedDate(new Date()); - assertTrue(data.getCreatedDate()!=null); - data.setUserCreatedBy(userInfo); - assertTrue(data.getUserCreatedBy()!=null); - } - - @Test - public void testBRMSController(){ - BRMSController data = new BRMSController(); - data.preUpdate(); - data.prePersist(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setController("Test"); - assertTrue("Test".equals(data.getController())); - data.setControllerName("Test"); - assertTrue("Test".equals(data.getControllerName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - 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 testBRMSDependency(){ - BRMSDependency data = new BRMSDependency(); - data.preUpdate(); - data.prePersist(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setDependency("Test"); - assertTrue("Test".equals(data.getDependency())); - data.setDependencyName("Test"); - assertTrue("Test".equals(data.getDependencyName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - 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); - } - -} 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 new file mode 100644 index 000000000..72c1b7dcd --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BRMSDictionaryJPATest.java @@ -0,0 +1,109 @@ +/*- + * ============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 BRMSDictionaryJPATest { + + private static Logger logger = FlexLogger.getLogger(BRMSDictionaryJPATest.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 testBRMSParamTemplate(){ + BRMSParamTemplate data = new BRMSParamTemplate(); + data.prePersist(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setRule("Test"); + assertTrue("Test".equals(data.getRule())); + data.setRuleName("Test"); + assertTrue("Test".equals(data.getRuleName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + data.setCreatedDate(new Date()); + assertTrue(data.getCreatedDate()!=null); + data.setUserCreatedBy(userInfo); + assertTrue(data.getUserCreatedBy()!=null); + } + + @Test + public void testBRMSController(){ + BRMSController data = new BRMSController(); + data.preUpdate(); + data.prePersist(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setController("Test"); + assertTrue("Test".equals(data.getController())); + data.setControllerName("Test"); + assertTrue("Test".equals(data.getControllerName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + 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 testBRMSDependency(){ + BRMSDependency data = new BRMSDependency(); + data.preUpdate(); + data.prePersist(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setDependency("Test"); + assertTrue("Test".equals(data.getDependency())); + data.setDependencyName("Test"); + assertTrue("Test".equals(data.getDependencyName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + 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); + } + +} diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJPAClasses.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJPAClasses.java deleted file mode 100644 index 4fd1d0cbd..000000000 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJPAClasses.java +++ /dev/null @@ -1,177 +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 ClosedLoopPolicyDictionaryJPAClasses { - - private static Logger logger = FlexLogger.getLogger(ClosedLoopPolicyDictionaryJPAClasses.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 testVSCLAction(){ - VSCLAction data = new VSCLAction(); - new VSCLAction("Test","Test"); - data.preUpdate(); - data.prePersist(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setVsclaction("Test"); - assertTrue("Test".equals(data.getVsclaction())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - 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 testVNFType(){ - VNFType data = new VNFType(); - new VNFType("Test","Test"); - data.preUpdate(); - data.prePersist(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setVnftype("Test"); - assertTrue("Test".equals(data.getVnftype())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - 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 testPEPOptions(){ - PEPOptions data = new PEPOptions(); - new PEPOptions("Test","Test"); - data.preUpdate(); - data.prePersist(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setPepName("Test"); - assertTrue("Test".equals(data.getPepName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - 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 testVarbindDictionary(){ - VarbindDictionary data = new VarbindDictionary(); - new VarbindDictionary("Test","Test"); - data.preUpdate(); - data.prePersist(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setVarbindName("Test"); - assertTrue("Test".equals(data.getVarbindName())); - data.setVarbindDescription("Test"); - assertTrue("Test".equals(data.getVarbindDescription())); - data.setVarbindOID("Test"); - assertTrue("Test".equals(data.getVarbindOID())); - 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 testClosedLoopD2Services(){ - ClosedLoopD2Services data = new ClosedLoopD2Services(); - data.preUpdate(); - data.prePersist(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setServiceName("Test"); - assertTrue("Test".equals(data.getServiceName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - 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 testClosedLoopSite(){ - ClosedLoopSite data = new ClosedLoopSite(); - new ClosedLoopSite("Test","Test"); - data.preUpdate(); - data.prePersist(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setSiteName("Test"); - assertTrue("Test".equals(data.getSiteName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - 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); - } -} 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 new file mode 100644 index 000000000..aa93aacd6 --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJPATest.java @@ -0,0 +1,172 @@ +/*- + * ============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 ClosedLoopPolicyDictionaryJPATest { + + private static Logger logger = FlexLogger.getLogger(ClosedLoopPolicyDictionaryJPATest.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 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.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + 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 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.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + 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 testPEPOptions(){ + PEPOptions data = new PEPOptions(); + data.preUpdate(); + data.prePersist(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setPepName("Test"); + assertTrue("Test".equals(data.getPepName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + 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 testVarbindDictionary(){ + VarbindDictionary data = new VarbindDictionary(); + data.preUpdate(); + data.prePersist(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setVarbindName("Test"); + assertTrue("Test".equals(data.getVarbindName())); + data.setVarbindDescription("Test"); + assertTrue("Test".equals(data.getVarbindDescription())); + data.setVarbindOID("Test"); + assertTrue("Test".equals(data.getVarbindOID())); + 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 testClosedLoopD2Services(){ + ClosedLoopD2Services data = new ClosedLoopD2Services(); + data.preUpdate(); + data.prePersist(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setServiceName("Test"); + assertTrue("Test".equals(data.getServiceName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + 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 testClosedLoopSite(){ + ClosedLoopSite data = new ClosedLoopSite(); + data.preUpdate(); + data.prePersist(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setSiteName("Test"); + assertTrue("Test".equals(data.getSiteName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + 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); + } +} diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJPAClasses.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJPAClasses.java deleted file mode 100644 index eded9ed79..000000000 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJPAClasses.java +++ /dev/null @@ -1,147 +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 java.util.HashSet; - -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 CommonDictionaryJPAClasses { - - private static Logger logger = FlexLogger.getLogger(CommonDictionaryJPAClasses.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 testAttribute(){ - Attribute data = new Attribute(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setCategoryBean(new Category()); - assertTrue(data.getCategoryBean()!=null); - data.setConstraintType(new ConstraintType()); - assertTrue(data.getConstraintType()!=null); - data.setConstraintValues(new HashSet<>()); - assertTrue(data.getConstraintValues()!=null); - data.addConstraintValue(new ConstraintValue()); - data.removeConstraintValue(new ConstraintValue()); - data.removeAllConstraintValues(); - data.preUpdate(); - data.prePersist(); - new Attribute("Test"); - new Attribute(new Attribute()); - data.setAttributeValue("Test"); - assertTrue("Test".equals(data.getAttributeValue())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - data.setXacmlId("Test"); - assertTrue("Test".equals(data.getXacmlId())); - data.setDatatypeBean(new Datatype()); - assertTrue(data.getDatatypeBean()!=null); - data.setIsDesignator(true); - assertTrue(data.isDesignator()); - data.setIssuer("Test"); - assertTrue("Test".equals(data.getIssuer())); - data.setMustBePresent(true); - assertTrue(data.isMustBePresent()); - data.setPriority("Test"); - assertTrue("Test".equals(data.getPriority())); - data.setSelectorPath("Test"); - assertTrue("Test".equals(data.getSelectorPath())); - 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 testOnapName(){ - OnapName data = new OnapName(); - data.preUpdate(); - data.prePersist(); - new OnapName("Test", "Test"); - data.setId(1); - assertTrue(1 == data.getId()); - data.setOnapName("Test"); - assertTrue("Test".equals(data.getOnapName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - 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 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.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - 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 testSafePolicyWarning(){ - SafePolicyWarning data = new SafePolicyWarning(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setName("Test"); - assertTrue("Test".equals(data.getName())); - data.setMessage("Test"); - assertTrue("Test".equals(data.getMessage())); - data.setRiskType("Test"); - assertTrue("Test".equals(data.getRiskType())); - } -} 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 new file mode 100644 index 000000000..afe090503 --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJPATest.java @@ -0,0 +1,146 @@ +/*- + * ============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 java.util.HashSet; + +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 { + + private static Logger logger = FlexLogger.getLogger(CommonDictionaryJPATest.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 testAttribute(){ + Attribute data = new Attribute(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setCategoryBean(new Category()); + assertTrue(data.getCategoryBean()!=null); + data.setConstraintType(new ConstraintType()); + assertTrue(data.getConstraintType()!=null); + data.setConstraintValues(new HashSet<>()); + assertTrue(data.getConstraintValues()!=null); + data.addConstraintValue(new ConstraintValue()); + data.removeConstraintValue(new ConstraintValue()); + data.removeAllConstraintValues(); + data.preUpdate(); + data.prePersist(); + new Attribute("Test"); + new Attribute(new Attribute()); + data.setAttributeValue("Test"); + assertTrue("Test".equals(data.getAttributeValue())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + data.setXacmlId("Test"); + assertTrue("Test".equals(data.getXacmlId())); + data.setDatatypeBean(new Datatype()); + assertTrue(data.getDatatypeBean()!=null); + data.setIsDesignator(true); + assertTrue(data.isDesignator()); + data.setIssuer("Test"); + assertTrue("Test".equals(data.getIssuer())); + data.setMustBePresent(true); + assertTrue(data.isMustBePresent()); + data.setPriority("Test"); + assertTrue("Test".equals(data.getPriority())); + data.setSelectorPath("Test"); + assertTrue("Test".equals(data.getSelectorPath())); + 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 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.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + 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 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.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + 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 testSafePolicyWarning(){ + SafePolicyWarning data = new SafePolicyWarning(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setName("Test"); + assertTrue("Test".equals(data.getName())); + data.setMessage("Test"); + assertTrue("Test".equals(data.getMessage())); + data.setRiskType("Test"); + assertTrue("Test".equals(data.getRiskType())); + } +} diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DecisionDictionaryJPAClasses.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DecisionDictionaryJPAClasses.java deleted file mode 100644 index 3e7d23d90..000000000 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DecisionDictionaryJPAClasses.java +++ /dev/null @@ -1,89 +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 DecisionDictionaryJPAClasses { - - private static Logger logger = FlexLogger.getLogger(DecisionDictionaryJPAClasses.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 testDecisionSettings(){ - DecisionSettings data = new DecisionSettings(); - data.setId(1); - assertTrue(1 == data.getId()); - data.preUpdate(); - data.prePersist(); - new DecisionSettings("Test"); - new DecisionSettings(new DecisionSettings("Test"), "Test"); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - data.setXacmlId("Test"); - assertTrue("Test".equals(data.getXacmlId())); - data.setDatatypeBean(new Datatype()); - assertTrue(data.getDatatypeBean()!=null); - data.setIssuer("Test"); - assertTrue("Test".equals(data.getIssuer())); - data.setMustBePresent(true); - assertTrue(data.isMustBePresent()); - data.setPriority("Test"); - assertTrue("Test".equals(data.getPriority())); - 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 testRainyDayTreatments(){ - RainyDayTreatments data = new RainyDayTreatments(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setBbid("Test"); - assertTrue("Test".equals(data.getBbid())); - data.setWorkstep("Test"); - assertTrue("Test".equals(data.getWorkstep())); - data.setTreatments("Test"); - assertTrue("Test".equals(data.getTreatments())); - } - -} 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 new file mode 100644 index 000000000..0a221b0a2 --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DecisionDictionaryJPATest.java @@ -0,0 +1,87 @@ +/*- + * ============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 DecisionDictionaryJPATest { + + private static Logger logger = FlexLogger.getLogger(DecisionDictionaryJPATest.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 testDecisionSettings(){ + DecisionSettings data = new DecisionSettings(); + data.setId(1); + assertTrue(1 == data.getId()); + data.preUpdate(); + data.prePersist(); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + data.setXacmlId("Test"); + assertTrue("Test".equals(data.getXacmlId())); + data.setDatatypeBean(new Datatype()); + assertTrue(data.getDatatypeBean()!=null); + data.setIssuer("Test"); + assertTrue("Test".equals(data.getIssuer())); + data.setMustBePresent(true); + assertTrue(data.isMustBePresent()); + data.setPriority("Test"); + assertTrue("Test".equals(data.getPriority())); + 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 testRainyDayTreatments(){ + RainyDayTreatments data = new RainyDayTreatments(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setBbid("Test"); + assertTrue("Test".equals(data.getBbid())); + data.setWorkstep("Test"); + assertTrue("Test".equals(data.getWorkstep())); + data.setTreatments("Test"); + assertTrue("Test".equals(data.getTreatments())); + } + +} diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FWDictionaryJPAClasses.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FWDictionaryJPAClasses.java deleted file mode 100644 index fa4c03872..000000000 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FWDictionaryJPAClasses.java +++ /dev/null @@ -1,258 +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 FWDictionaryJPAClasses { - - private static Logger logger = FlexLogger.getLogger(FWDictionaryJPAClasses.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 testActionList(){ - ActionList data = new ActionList(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setActionName("Test"); - assertTrue("Test".equals(data.getActionName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - } - - @Test - public void testPortList(){ - PortList data = new PortList(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setPortName("Test"); - assertTrue("Test".equals(data.getPortName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - } - - @Test - public void testProtocolList(){ - ProtocolList data = new ProtocolList(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setProtocolName("Test"); - assertTrue("Test".equals(data.getProtocolName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - } - - @Test - public void testSecurityZone(){ - SecurityZone data = new SecurityZone(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setZoneName("Test"); - assertTrue("Test".equals(data.getZoneName())); - data.setZoneValue("Test"); - assertTrue("Test".equals(data.getZoneValue())); - } - - @Test - public void testZone(){ - Zone data = new Zone(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setZoneName("Test"); - assertTrue("Test".equals(data.getZoneName())); - data.setZoneValue("Test"); - assertTrue("Test".equals(data.getZoneValue())); - } - - @Test - public void testAddressGroup(){ - AddressGroup data = new AddressGroup(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setServiceList("Test"); - assertTrue("Test".equals(data.getPrefixList())); - data.setGroupName("Test"); - assertTrue("Test".equals(data.getGroupName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - } - - @Test - public void testPrefixList(){ - PrefixList data = new PrefixList(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setPrefixListName("Test"); - assertTrue("Test".equals(data.getPrefixListName())); - data.setPrefixListValue("Test"); - assertTrue("Test".equals(data.getPrefixListValue())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - } - - @Test - public void testFWDictionaryList(){ - FirewallDictionaryList data = new FirewallDictionaryList(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setParentItemName("Test"); - assertTrue("Test".equals(data.getParentItemName())); - data.setAddressList("Test"); - assertTrue("Test".equals(data.getAddressList())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - data.setServiceList("Test"); - assertTrue("Test".equals(data.getServiceList())); - } - - @Test - public void testFWTag(){ - FWTag data = new FWTag(); - data.preUpdate(); - data.prePersist(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setFwTagName("Test"); - assertTrue("Test".equals(data.getFwTagName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - data.setTagValues("Test"); - assertTrue("Test".equals(data.getTagValues())); - 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 testFWTagPicker(){ - FWTagPicker data = new FWTagPicker(); - data.preUpdate(); - data.prePersist(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setTagPickerName("Test"); - assertTrue("Test".equals(data.getTagPickerName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - data.setNetworkRole("Test"); - assertTrue("Test".equals(data.getNetworkRole())); - data.setTagValues("Test"); - assertTrue("Test".equals(data.getTagValues())); - 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 testServiceList(){ - ServiceList data = new ServiceList(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setServiceName("Test"); - assertTrue("Test".equals(data.getServiceName())); - data.setServiceDescription("Test"); - assertTrue("Test".equals(data.getServiceDescription())); - data.setServiceType("Test"); - assertTrue("Test".equals(data.getServiceType())); - data.setServiceTransProtocol("Test"); - assertTrue("Test".equals(data.getServiceTransProtocol())); - data.setServiceAppProtocol("Test"); - assertTrue("Test".equals(data.getServiceAppProtocol())); - data.setServicePorts("Test"); - assertTrue("Test".equals(data.getServicePorts())); - } - - @Test - public void testTermList(){ - TermList data = new TermList(); - data.preUpdate(); - data.prePersist(); - new TermList("Test", "Test"); - data.setId(1); - assertTrue(1 == data.getId()); - data.setTermName("Test"); - assertTrue("Test".equals(data.getTermName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getTermDescription())); - data.setFromZones("Test"); - assertTrue("Test".equals(data.getFromZone())); - data.setToZones("Test"); - assertTrue("Test".equals(data.getToZone())); - 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"); - assertTrue("Test".equals(data.getPortList())); - data.setSrcPortList("Test"); - assertTrue("Test".equals(data.getSrcPortList())); - data.setDestPortList("Test"); - assertTrue("Test".equals(data.getDestPortList())); - data.setAction("Test"); - assertTrue("Test".equals(data.getAction())); - 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 testGroupServiceList(){ - GroupServiceList data = new GroupServiceList(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setGroupName("Test"); - assertTrue("Test".equals(data.getGroupName())); - data.setServiceList("Test"); - assertTrue("Test".equals(data.getServiceList())); - } -} 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 new file mode 100644 index 000000000..bec9fe042 --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FWDictionaryJPATest.java @@ -0,0 +1,257 @@ +/*- + * ============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 FWDictionaryJPATest { + + private static Logger logger = FlexLogger.getLogger(FWDictionaryJPATest.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 testActionList(){ + ActionList data = new ActionList(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setActionName("Test"); + assertTrue("Test".equals(data.getActionName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + } + + @Test + public void testPortList(){ + PortList data = new PortList(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setPortName("Test"); + assertTrue("Test".equals(data.getPortName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + } + + @Test + public void testProtocolList(){ + ProtocolList data = new ProtocolList(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setProtocolName("Test"); + assertTrue("Test".equals(data.getProtocolName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + } + + @Test + public void testSecurityZone(){ + SecurityZone data = new SecurityZone(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setZoneName("Test"); + assertTrue("Test".equals(data.getZoneName())); + data.setZoneValue("Test"); + assertTrue("Test".equals(data.getZoneValue())); + } + + @Test + public void testZone(){ + Zone data = new Zone(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setZoneName("Test"); + assertTrue("Test".equals(data.getZoneName())); + data.setZoneValue("Test"); + assertTrue("Test".equals(data.getZoneValue())); + } + + @Test + public void testAddressGroup(){ + AddressGroup data = new AddressGroup(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setServiceList("Test"); + assertTrue("Test".equals(data.getPrefixList())); + data.setGroupName("Test"); + assertTrue("Test".equals(data.getGroupName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + } + + @Test + public void testPrefixList(){ + PrefixList data = new PrefixList(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setPrefixListName("Test"); + assertTrue("Test".equals(data.getPrefixListName())); + data.setPrefixListValue("Test"); + assertTrue("Test".equals(data.getPrefixListValue())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + } + + @Test + public void testFWDictionaryList(){ + FirewallDictionaryList data = new FirewallDictionaryList(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setParentItemName("Test"); + assertTrue("Test".equals(data.getParentItemName())); + data.setAddressList("Test"); + assertTrue("Test".equals(data.getAddressList())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + data.setServiceList("Test"); + assertTrue("Test".equals(data.getServiceList())); + } + + @Test + public void testFWTag(){ + FWTag data = new FWTag(); + data.preUpdate(); + data.prePersist(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setFwTagName("Test"); + assertTrue("Test".equals(data.getFwTagName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + data.setTagValues("Test"); + assertTrue("Test".equals(data.getTagValues())); + 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 testFWTagPicker(){ + FWTagPicker data = new FWTagPicker(); + data.preUpdate(); + data.prePersist(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setTagPickerName("Test"); + assertTrue("Test".equals(data.getTagPickerName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + data.setNetworkRole("Test"); + assertTrue("Test".equals(data.getNetworkRole())); + data.setTagValues("Test"); + assertTrue("Test".equals(data.getTagValues())); + 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 testServiceList(){ + ServiceList data = new ServiceList(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setServiceName("Test"); + assertTrue("Test".equals(data.getServiceName())); + data.setServiceDescription("Test"); + assertTrue("Test".equals(data.getServiceDescription())); + data.setServiceType("Test"); + assertTrue("Test".equals(data.getServiceType())); + data.setServiceTransProtocol("Test"); + assertTrue("Test".equals(data.getServiceTransProtocol())); + data.setServiceAppProtocol("Test"); + assertTrue("Test".equals(data.getServiceAppProtocol())); + data.setServicePorts("Test"); + assertTrue("Test".equals(data.getServicePorts())); + } + + @Test + public void testTermList(){ + TermList data = new TermList(); + data.preUpdate(); + data.prePersist(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setTermName("Test"); + assertTrue("Test".equals(data.getTermName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getTermDescription())); + data.setFromZones("Test"); + assertTrue("Test".equals(data.getFromZone())); + data.setToZones("Test"); + assertTrue("Test".equals(data.getToZone())); + 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"); + assertTrue("Test".equals(data.getPortList())); + data.setSrcPortList("Test"); + assertTrue("Test".equals(data.getSrcPortList())); + data.setDestPortList("Test"); + assertTrue("Test".equals(data.getDestPortList())); + data.setAction("Test"); + assertTrue("Test".equals(data.getAction())); + 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 testGroupServiceList(){ + GroupServiceList data = new GroupServiceList(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setGroupName("Test"); + assertTrue("Test".equals(data.getGroupName())); + data.setServiceList("Test"); + assertTrue("Test".equals(data.getServiceList())); + } +} diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJPAClasses.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJPAClasses.java deleted file mode 100644 index 465d034bd..000000000 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJPAClasses.java +++ /dev/null @@ -1,183 +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 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 MicroServiceDictionaryJPAClasses { - - private static Logger logger = FlexLogger.getLogger(MicroServiceDictionaryJPAClasses.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 testDCAEUsers(){ - DCAEUsers data = new DCAEUsers(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setName("Test"); - assertTrue("Test".equals(data.getName())); - data.setDescriptionValue("Test"); - assertTrue("Test".equals(data.getDescriptionValue())); - } - - @Test - public void testDCAEuuid(){ - DCAEuuid data = new DCAEuuid(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setName("Test"); - assertTrue("Test".equals(data.getName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - } - - @Test - 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())); - } - - @Test - 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())); - } - - @Test - public void testMSModels(){ - MicroServiceModels data = new MicroServiceModels(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setModelName("Test"); - assertTrue("Test".equals(data.getModelName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - data.setDependency("Test"); - assertTrue("Test".equals(data.getDependency())); - data.setEnumValues("Test"); - assertTrue("Test".equals(data.getEnumValues())); - data.setAnnotation("Test"); - assertTrue("Test".equals(data.getAnnotation())); - data.setAttributes("Test"); - assertTrue("Test".equals(data.getAttributes())); - data.setRef_attributes("Test"); - assertTrue("Test".equals(data.getRef_attributes())); - data.setUserCreatedBy(userInfo); - assertTrue(data.getUserCreatedBy()!=null); - data.setSub_attributes("Test"); - assertTrue("Test".equals(data.getSub_attributes())); - data.setVersion("Test"); - assertTrue("Test".equals(data.getVersion())); - } - - @Test - public void testMSAttributeDictionary(){ - MicroServiceAttribute data = new MicroServiceAttribute(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setName("Test"); - assertTrue("Test".equals(data.getName())); - data.setValue("Test"); - assertTrue("Test".equals(data.getValue())); - data.setModelName("Test"); - assertTrue("Test".equals(data.getModelName())); - } - - @Test - 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())); - } - - @Test - 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())); - } - - @Test - 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())); - } - - @Test - 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())); - } - - @Test - public void testPolicyScopeGroupPolicyScopeList(){ - GroupPolicyScopeList data = new GroupPolicyScopeList(); - data.setId(1); - assertTrue(1 == data.getId()); - data.setGroupName("Test"); - assertTrue("Test".equals(data.getGroupName())); - data.setDescription("Test"); - assertTrue("Test".equals(data.getDescription())); - data.setGroupList("Test"); - assertTrue("Test".equals(data.getGroupList())); - } -} 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 new file mode 100644 index 000000000..eba1c4003 --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJPATest.java @@ -0,0 +1,208 @@ +/*- + * ============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 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 MicroServiceDictionaryJPATest { + + private static Logger logger = FlexLogger.getLogger(MicroServiceDictionaryJPATest.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 testDCAEUsers(){ + DCAEUsers data = new DCAEUsers(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setName("Test"); + assertTrue("Test".equals(data.getName())); + data.setDescriptionValue("Test"); + assertTrue("Test".equals(data.getDescriptionValue())); + } + + @Test + public void testDCAEuuid(){ + DCAEuuid data = new DCAEuuid(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setName("Test"); + assertTrue("Test".equals(data.getName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + } + + @Test + 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())); + } + + @Test + 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())); + } + + @Test + public void testMSModels(){ + MicroServiceModels data = new MicroServiceModels(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setModelName("Test"); + assertTrue("Test".equals(data.getModelName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + data.setDependency("Test"); + assertTrue("Test".equals(data.getDependency())); + data.setEnumValues("Test"); + assertTrue("Test".equals(data.getEnumValues())); + data.setAnnotation("Test"); + assertTrue("Test".equals(data.getAnnotation())); + data.setAttributes("Test"); + assertTrue("Test".equals(data.getAttributes())); + data.setRef_attributes("Test"); + assertTrue("Test".equals(data.getRef_attributes())); + data.setUserCreatedBy(userInfo); + assertTrue(data.getUserCreatedBy()!=null); + data.setSub_attributes("Test"); + assertTrue("Test".equals(data.getSub_attributes())); + data.setVersion("Test"); + assertTrue("Test".equals(data.getVersion())); + } + + @Test + public void testMSAttributeDictionary(){ + MicroServiceAttribute data = new MicroServiceAttribute(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setName("Test"); + assertTrue("Test".equals(data.getName())); + data.setValue("Test"); + assertTrue("Test".equals(data.getValue())); + data.setModelName("Test"); + assertTrue("Test".equals(data.getModelName())); + } + + @Test + 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())); + } + + @Test + 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())); + } + + @Test + 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())); + } + + @Test + 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())); + } + + @Test + public void testPolicyScopeGroupPolicyScopeList(){ + GroupPolicyScopeList data = new GroupPolicyScopeList(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setGroupName("Test"); + assertTrue("Test".equals(data.getGroupName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + data.setGroupList("Test"); + assertTrue("Test".equals(data.getGroupList())); + } + + @Test + public void testClosedLoops(){ + ClosedLoops data = new ClosedLoops(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setClosedLoopControlName("Test"); + assertTrue("Test".equals(data.getClosedLoopControlName())); + data.setAlarmConditions("Test"); + assertTrue("Test".equals(data.getAlarmConditions())); + data.setYaml("Test"); + assertTrue("Test".equals(data.getYaml())); + } + + @Test + public void testVMType(){ + VMType data = new VMType(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setName("Test"); + assertTrue("Test".equals(data.getName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + } + +} 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 new file mode 100644 index 000000000..d114a18c1 --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PIPJPATest.java @@ -0,0 +1,183 @@ +/*- + * ============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.*; + +import java.util.Date; +import java.util.HashSet; +import java.util.Properties; + +import org.junit.Test; + +import com.att.research.xacml.api.pip.PIPException; + +public class PIPJPATest { + + @Test + public void testPIPConfigParam(){ + PIPConfigParam data = new PIPConfigParam(); + new PIPConfigParam("test"); + new PIPConfigParam(new PIPConfigParam()); + data.setId(1); + assertTrue(1 == data.getId()); + data.setParamName("Test"); + assertTrue("Test".equals(data.getParamName())); + data.setParamValue("Test"); + assertTrue("Test".equals(data.getParamValue())); + data.setParamDefault("Test"); + assertTrue("Test".equals(data.getParamDefault())); + data.setPipconfiguration(new PIPConfiguration()); + assertTrue(data.getPipconfiguration()!=null); + data.setRequired(true); + assertTrue(data.isRequired()); + data.toString(); + } + + @Test + public void testPIPResolverParam(){ + PIPResolverParam data = new PIPResolverParam(); + new PIPResolverParam("test"); + new PIPResolverParam(new PIPResolverParam()); + data.setId(1); + assertTrue(1 == data.getId()); + data.setParamName("Test"); + assertTrue("Test".equals(data.getParamName())); + data.setParamValue("Test"); + assertTrue("Test".equals(data.getParamValue())); + data.setParamDefault("Test"); + assertTrue("Test".equals(data.getParamDefault())); + data.setPipresolver(new PIPResolver()); + assertTrue(data.getPipresolver()!=null); + data.setRequired(true); + assertTrue(data.isRequired()); + data.toString(); + } + + @Test + 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()); + data.setType("SQL"); + assertTrue(data.isSQL()); + data.setType("LDAP"); + assertTrue(data.isLDAP()); + data.setType("CSV"); + assertTrue(data.isCSV()); + data.setType("Hyper-CSV"); + assertTrue(data.isHyperCSV()); + data.setType("Custom"); + assertTrue(data.isCustom()); + } + + @Test + public void testPIPResolver(){ + PIPResolver data = new PIPResolver(); + new PIPResolver(new PIPResolver()); + data.prePersist(); + data.preUpdate(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setName("Test"); + assertTrue("Test".equals(data.getName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + data.setIssuer("Test"); + assertTrue("Test".equals(data.getIssuer())); + data.setClassname("Test"); + assertTrue("Test".equals(data.getClassname())); + 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.setPipconfiguration(new PIPConfiguration()); + assertTrue(data.getPipconfiguration()!=null); + data.setPipresolverParams(new HashSet<>()); + assertTrue(data.getPipresolverParams()!=null); + data.addPipresolverParam(new PIPResolverParam()); + data.removePipresolverParam(new PIPResolverParam()); + data.clearParams(); + data.getConfiguration("test"); + data.setReadOnly(true); + assertTrue(data.isReadOnly()); + data.toString(); + Properties properties = new Properties(); + data.generateProperties(properties,"test"); + try { + data.readProperties("test", properties); + } catch (PIPException e) { + fail(); + } + } + + @Test + public void testPIPConfiguration(){ + PIPConfiguration data = new PIPConfiguration(); + data.prePersist(); + data.preUpdate(); + data.setId(1); + assertTrue(1 == data.getId()); + data.setName("Test"); + assertTrue("Test".equals(data.getName())); + data.setDescription("Test"); + assertTrue("Test".equals(data.getDescription())); + data.setIssuer("Test"); + assertTrue("Test".equals(data.getIssuer())); + data.setClassname("Test"); + assertTrue("Test".equals(data.getClassname())); + 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); + try { + data.readProperties("test", data.generateProperties("test")); + } catch (PIPException e) { + fail(); + } + data.setPiptype(new PIPType()); + assertTrue(data.getPiptype()!=null); + data.setPipresolvers(new HashSet<>()); + assertTrue(data.getPipresolvers()!=null); + data.addPipresolver(new PIPResolver()); + data.removePipresolver(new PIPResolver()); + data.getConfiguration("test"); + data.setReadOnly(true); + assertTrue(data.isReadOnly()); + data.setRequiresResolvers(true); + assertTrue(data.requiresResolvers()); + data.toString(); + } + +} diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJPAClasses.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJPAClasses.java deleted file mode 100644 index 96f107bfe..000000000 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJPAClasses.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 PolicyEntityJPAClasses { - - private static Logger logger = FlexLogger.getLogger(PolicyEntityJPAClasses.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..25ea391ca --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJPATest.java @@ -0,0 +1,206 @@ +/*- + * ============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/PolicyUtilsJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyUtilsJPATest.java new file mode 100644 index 000000000..934c27ba6 --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyUtilsJPATest.java @@ -0,0 +1,190 @@ +/*- + * ============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/util/MSAttributeObjectTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/MSAttributeObjectTest.java new file mode 100644 index 000000000..85a11d4d5 --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/MSAttributeObjectTest.java @@ -0,0 +1,73 @@ +/*- + * ============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.util; + +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; + +import org.junit.Test; + +public class MSAttributeObjectTest { + + @Test + public void testMSAttributeObject(){ + MSAttributeObject data = new MSAttributeObject(); + data.setClassName("Test"); + assertTrue("Test".equals(data.getClassName())); + data.setRefAttribute(new HashMap<>()); + assertTrue(data.getRefAttribute()!=null); + data.setAttribute(new HashMap<>()); + assertTrue(data.getAttribute()!=null); + data.setEnumType(new HashMap<>()); + assertTrue(data.getEnumType()!=null); + data.addAttribute("test", "test"); + data.addRefAttribute("test", "test"); + data.addAllAttribute(new HashMap<>()); + data.addAllRefAttribute(new HashMap<>()); + data.setSubClass(new HashMap<>()); + assertTrue(data.getSubClass()!=null); + data.addAllSubClass(new HashMap<>()); + data.setDependency("Test"); + assertTrue("Test".equals(data.getDependency())); + data.addSingleEnum("test", "test"); + data.setMatchingSet(new HashMap<>()); + assertTrue(data.getMatchingSet()!=null); + data.addMatchingSet("test", "test"); + data.addMatchingSet(new HashMap<>()); + data.setPolicyTempalate(true); + assertTrue(data.isPolicyTempalate()); + } + + @Test + public void testMSAttributeValue(){ + MSAttributeValue data = new MSAttributeValue(); + data.setName("Test"); + assertTrue("Test".equals(data.getName())); + data.setType("Test"); + assertTrue("Test".equals(data.getType())); + data.setRequired(true); + assertTrue(data.getRequired()); + data.setArrayValue(true); + assertTrue(data.getArrayValue()); + data.setDefaultValue("Test"); + assertTrue("Test".equals(data.getDefaultValue())); + } +} 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 new file mode 100644 index 000000000..83a82f9cd --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/MSModelUtilsTest.java @@ -0,0 +1,52 @@ +/*- + * ============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.util; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang.StringUtils; +import org.junit.Test; +import org.onap.policy.rest.util.MSModelUtils.MODEL_TYPE; + +public class MSModelUtilsTest { + + @Test + public void testMSModelUtils(){ + HashMap 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 tempMap = utils.processEpackage(file.getAbsolutePath().toString(), MODEL_TYPE.XMI); + classMap.putAll(tempMap); + MSAttributeObject mainClass = classMap.get("StandardDeviationThreshold"); + String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[]{"[", "]", " "}, new String[]{"", "", ""}); + List dependency = new ArrayList(Arrays.asList(dependTemp.split(","))); + dependency = utils.getFullDependencyList(dependency, classMap); + String subAttribute = utils.createSubAttributes(dependency, classMap, "StandardDeviationThreshold"); + assertTrue(subAttribute != null); + } +} diff --git a/ONAP-REST/src/test/resources/DKaTVESPolicy-v1802.xmi b/ONAP-REST/src/test/resources/DKaTVESPolicy-v1802.xmi new file mode 100644 index 000000000..ac7e33926 --- /dev/null +++ b/ONAP-REST/src/test/resources/DKaTVESPolicy-v1802.xmi @@ -0,0 +1,587 @@ + + + +
+
+
+ ss + +
+
+ + + + + + + + +
+ + + +
+ + +
+
+ + + + +
+ + +
+
+ + + + +
+ + +
+
+ + + + +
+ + +
+
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + +
+
+ + + + +
+ + + + +
+ + + + +
+ + +
+
+ + + + +
+ + +
+
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + +
+
+ + + + +
+ + + + +
+ + +
+
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + +
+
+ + + + + + +
+ + +
+
+ + + + +
+ + +
+
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java index 2df70c726..ae473f34f 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * 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. @@ -46,7 +46,6 @@ import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.model.PDPGroupContainer; import org.onap.policy.model.Roles; import org.onap.policy.rest.XACMLRestProperties; -import org.onap.policy.rest.XacmlAdminAuthorization; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.Datatype; import org.onap.policy.rest.jpa.FunctionDefinition; @@ -75,10 +74,6 @@ public class PolicyController extends RestrictedBaseController { private static final Logger policyLogger = FlexLogger.getLogger(PolicyController.class); private static CommonClassDao commonClassDao; - - // Our authorization object - // - XacmlAdminAuthorization authorizer = new XacmlAdminAuthorization(); // // The PAP Engine // @@ -487,14 +482,6 @@ public class PolicyController extends RestrictedBaseController { PolicyController.commonClassDao = commonClassDao; } - public XacmlAdminAuthorization getAuthorizer() { - return authorizer; - } - - public void setAuthorizer(XacmlAdminAuthorization authorizer) { - this.authorizer = authorizer; - } - public static Map> getMapDatatype2Function() { return mapDatatype2Function; } -- cgit 1.2.3-korg