From 3c739025a9727597b874df03c17bb439261857e4 Mon Sep 17 00:00:00 2001 From: rb7147 Date: Fri, 9 Feb 2018 00:04:44 -0500 Subject: Added JUNITS for ONAP-REST Component Added JUnits for all Pojo classes. Issue-ID: POLICY-338 Change-Id: I0142903899f0793a8e147a01aeea83d467e49981 Signed-off-by: rb7147 --- .../rest/adapter/AutoPushTabAdapterTest.java | 38 +++ .../rest/adapter/ClosedLoopFaultTrapDatasTest.java | 50 ---- .../rest/adapter/ClosedLoopPolicyAdaptersTest.java | 161 +++++++++++++ .../rest/adapter/FirewallPolicyAdaptersTest.java | 230 ++++++++++++++++++ .../policy/rest/adapter/PolicyRestAdapterTest.java | 260 +++++++++++++++++++++ .../policy/rest/adapter/RainyDayParamsTest.java | 48 ++++ .../onap/policy/rest/adapter/YAMLParamsTest.java | 55 +++++ 7 files changed, 792 insertions(+), 50 deletions(-) create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/adapter/AutoPushTabAdapterTest.java delete mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ClosedLoopFaultTrapDatasTest.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ClosedLoopPolicyAdaptersTest.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/adapter/FirewallPolicyAdaptersTest.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/adapter/PolicyRestAdapterTest.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/adapter/RainyDayParamsTest.java create mode 100644 ONAP-REST/src/test/java/org/onap/policy/rest/adapter/YAMLParamsTest.java (limited to 'ONAP-REST/src/test/java/org/onap') diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/AutoPushTabAdapterTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/AutoPushTabAdapterTest.java new file mode 100644 index 000000000..eb4784e29 --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/AutoPushTabAdapterTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.policy.rest.adapter; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; + +import org.junit.Test; + +public class AutoPushTabAdapterTest { + + @Test + public void testAutoPushTabAdapter(){ + AutoPushTabAdapter adapter = new AutoPushTabAdapter(); + adapter.setPdpDatas(new ArrayList<>()); + assertTrue(adapter.getPdpDatas() != null); + adapter.setPolicyDatas(new ArrayList<>()); + assertTrue(adapter.getPolicyDatas() != null); + } +} diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ClosedLoopFaultTrapDatasTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ClosedLoopFaultTrapDatasTest.java deleted file mode 100644 index bb8385bc3..000000000 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ClosedLoopFaultTrapDatasTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP Policy Engine - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.policy.rest.adapter; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -public class ClosedLoopFaultTrapDatasTest { - - @Test - public void testClosedLoopFaultTrapDatas(){ - List trap = new ArrayList<>(); - trap.add("Test"); - ClosedLoopFaultTrapDatas closedLoopTrapData = new ClosedLoopFaultTrapDatas(); - closedLoopTrapData.setTrap1(trap); - assertTrue("Test".equals(closedLoopTrapData.getTrap1().get(0))); - closedLoopTrapData.setTrap2(trap); - assertTrue("Test".equals(closedLoopTrapData.getTrap2().get(0))); - closedLoopTrapData.setTrap3(trap); - assertTrue("Test".equals(closedLoopTrapData.getTrap3().get(0))); - closedLoopTrapData.setTrap4(trap); - assertTrue("Test".equals(closedLoopTrapData.getTrap4().get(0))); - closedLoopTrapData.setTrap5(trap); - assertTrue("Test".equals(closedLoopTrapData.getTrap5().get(0))); - closedLoopTrapData.setTrap6(trap); - assertTrue("Test".equals(closedLoopTrapData.getTrap6().get(0))); - - } -} diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ClosedLoopPolicyAdaptersTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ClosedLoopPolicyAdaptersTest.java new file mode 100644 index 000000000..6f310e09c --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ClosedLoopPolicyAdaptersTest.java @@ -0,0 +1,161 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.policy.rest.adapter; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.junit.Test; + +public class ClosedLoopPolicyAdaptersTest { + + @Test + public void testClosedLoopFaultTrapDatas(){ + List trap = new ArrayList<>(); + trap.add("Test"); + ClosedLoopFaultTrapDatas closedLoopTrapData = new ClosedLoopFaultTrapDatas(); + closedLoopTrapData.setTrap1(trap); + assertTrue("Test".equals(closedLoopTrapData.getTrap1().get(0))); + closedLoopTrapData.setTrap2(trap); + assertTrue("Test".equals(closedLoopTrapData.getTrap2().get(0))); + closedLoopTrapData.setTrap3(trap); + assertTrue("Test".equals(closedLoopTrapData.getTrap3().get(0))); + closedLoopTrapData.setTrap4(trap); + assertTrue("Test".equals(closedLoopTrapData.getTrap4().get(0))); + closedLoopTrapData.setTrap5(trap); + assertTrue("Test".equals(closedLoopTrapData.getTrap5().get(0))); + closedLoopTrapData.setTrap6(trap); + assertTrue("Test".equals(closedLoopTrapData.getTrap6().get(0))); + + } + + @Test + public void testClosedLoopFaultBody(){ + ClosedLoopFaultBody faultBody = new ClosedLoopFaultBody(); + faultBody.setTrinity(true); + assertTrue(faultBody.isTrinity()); + faultBody.setvUSP(true); + assertTrue(faultBody.isvUSP()); + faultBody.setMcr(true); + assertTrue(faultBody.isMcr()); + faultBody.setGamma(true); + assertTrue(faultBody.isGamma()); + faultBody.setvDNS(true); + assertTrue(faultBody.isvDNS()); + faultBody.setVnfType("Test"); + assertTrue("Test".equals(faultBody.getVnfType())); + faultBody.setvServices("Test"); + assertTrue("Test".equals(faultBody.getvServices())); + faultBody.setONAPname("Test"); + assertTrue("Test".equals(faultBody.getONAPname())); + faultBody.setClosedLoopPolicyStatus("Active"); + assertTrue("Active".equals(faultBody.getClosedLoopPolicyStatus())); + + ClosedLoopSignatures triggerSignatures = new ClosedLoopSignatures(); + triggerSignatures.setSignatures("Test"); + triggerSignatures.setTimeWindow(1); + triggerSignatures.setTrapMaxAge(2); + assertTrue("Test".equals(triggerSignatures.getSignatures())); + assertTrue(1 == triggerSignatures.getTimeWindow()); + assertTrue(2 == triggerSignatures.getTrapMaxAge()); + + faultBody.setTriggerSignatures(triggerSignatures); + assertTrue(faultBody.getTriggerSignatures()!=null); + faultBody.setActions("Test"); + assertTrue("Test".equals(faultBody.getActions())); + faultBody.setTimeInterval(1); + assertTrue(1 == faultBody.getTimeInterval()); + faultBody.setTimeOutvPRO(2); + assertTrue(2 == faultBody.getTimeOutvPRO()); + faultBody.setTimeOutRuby(3); + assertTrue(3 == faultBody.getTimeOutRuby()); + faultBody.setRetrys(4); + assertTrue(4 == faultBody.getRetrys()); + faultBody.setAgingWindow(5); + assertTrue(5 == faultBody.getAgingWindow()); + faultBody.setGeoLink("Test"); + assertTrue("Test".equals(faultBody.getGeoLink())); + faultBody.setEmailAddress("test@test.com"); + assertTrue("test@test.com".equals(faultBody.getEmailAddress())); + faultBody.setVerificationSignatures(triggerSignatures); + assertTrue(faultBody.getVerificationSignatures()!=null); + + faultBody.setConditions(ClosedLoopPolicyConditions.SEND); + assertTrue(ClosedLoopPolicyConditions.SEND.equals(faultBody.getConditions())); + + faultBody.setConditions(ClosedLoopPolicyConditions.NOTSEND); + assertTrue(ClosedLoopPolicyConditions.NOTSEND.equals(faultBody.getConditions())); + + ClosedLoopFaultTriggerUISignatures uiSignatures = new ClosedLoopFaultTriggerUISignatures(); + uiSignatures.setConnectSignatures("Test"); + uiSignatures.setSignatures("Test"); + assertTrue("Test".equals(uiSignatures.getConnectSignatures())); + assertTrue("Test".equals(uiSignatures.getSignatures())); + + faultBody.setTriggerSignaturesUsedForUI(uiSignatures); + assertTrue(faultBody.getTriggerSignaturesUsedForUI()!=null); + faultBody.setVerificationSignaturesUsedForUI(uiSignatures); + assertTrue(faultBody.getVerificationSignaturesUsedForUI()!=null); + faultBody.setTriggerTimeWindowUsedForUI(1); + assertTrue(1 == faultBody.getTriggerTimeWindowUsedForUI()); + faultBody.setVerificationTimeWindowUsedForUI(2); + assertTrue(2 == faultBody.getVerificationTimeWindowUsedForUI()); + faultBody.setPepName("Test"); + assertTrue("Test".equals(faultBody.getPepName())); + faultBody.setPepAction("Test"); + assertTrue("Test".equals(faultBody.getPepAction())); + faultBody.setTemplateVersion("1802"); + assertTrue("1802".equals(faultBody.getTemplateVersion())); + faultBody.setTrapMaxAge(3); + assertTrue(3 == faultBody.getTrapMaxAge()); + } + + @Test + public void testClosedLoopPMBody(){ + ClosedLoopPMBody pmBody = new ClosedLoopPMBody(); + pmBody.setTrinity(true); + assertTrue(pmBody.isTrinity()); + pmBody.setvUSP(true); + assertTrue(pmBody.isvUSP()); + pmBody.setMcr(true); + assertTrue(pmBody.isMcr()); + pmBody.setGamma(true); + assertTrue(pmBody.isGamma()); + pmBody.setvDNS(true); + assertTrue(pmBody.isvDNS()); + pmBody.setvServices("Test"); + assertTrue("Test".equals(pmBody.getvServices())); + pmBody.setONAPname("Test"); + assertTrue("Test".equals(pmBody.getONAPname())); + pmBody.setEmailAddress("test@test.com"); + assertTrue("test@test.com".equals(pmBody.getEmailAddress())); + pmBody.setServiceTypePolicyName("Test"); + assertTrue("Test".equals(pmBody.getServiceTypePolicyName())); + pmBody.setTemplateVersion("1802"); + assertTrue("1802".equals(pmBody.getTemplateVersion())); + pmBody.setAttributes(new HashMap()); + assertTrue(pmBody.getAttributes() != null); + pmBody.setGeoLink("Test"); + assertTrue("Test".equals(pmBody.getGeoLink())); + } +} diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/FirewallPolicyAdaptersTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/FirewallPolicyAdaptersTest.java new file mode 100644 index 000000000..729efa6d6 --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/FirewallPolicyAdaptersTest.java @@ -0,0 +1,230 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.policy.rest.adapter; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +public class FirewallPolicyAdaptersTest { + + @Test + public void AddressGroupJSON(){ + AddressGroupJson groupJSON = new AddressGroupJson(); + groupJSON.setName("Test"); + assertTrue("Test".equals(groupJSON.getName())); + groupJSON.setDescription("Test"); + assertTrue("Test".equals(groupJSON.getDescription())); + + AddressMembersJson membersJSON = new AddressMembersJson(); + membersJSON.setType("Test"); + assertTrue("Test".equals(membersJSON.getType())); + membersJSON.setName("Test"); + assertTrue("Test".equals(membersJSON.getName())); + + groupJSON.setMembers(null); + assertTrue(groupJSON.getMembers() != null); + } + + @Test + public void testAddressMembers(){ + AddressMembers members = new AddressMembers(); + members.setName("Test"); + assertTrue("Test".equals(members.getName())); + members.setType("Test"); + assertTrue("Test".equals(members.getType())); + members.setValue("Test"); + assertTrue("Test".equals(members.getValue())); + + PrefixIPList prefixList = new PrefixIPList(); + prefixList.setName("Test"); + assertTrue("Test".equals(prefixList.getName())); + prefixList.setDescription("Test"); + assertTrue("Test".equals(prefixList.getDescription())); + prefixList.setMembers(null); + assertTrue(prefixList.getMembers() != null); + } + + @Test + public void testAddressJSON(){ + AddressJson addressJSON = new AddressJson(); + addressJSON.setName("Test"); + assertTrue("Test".equals(addressJSON.getName())); + addressJSON.setType("Test"); + assertTrue("Test".equals(addressJSON.getType())); + } + + + @Test + public void testGridData(){ + GridData data = new GridData(); + data.setAttributes(new ArrayList<>()); + data.setAppProtocols(new ArrayList<>()); + data.setTransportProtocols(new ArrayList<>()); + assertTrue(data.getAttributes() != null); + assertTrue(data.getAppProtocols() != null); + assertTrue(data.getTransportProtocols() != null); + } + + @Test + public void testTermCollector(){ + + TermCollector termCollector = new TermCollector(); + termCollector.setServiceTypeId("Test"); + assertTrue("Test".equals(termCollector.getServiceTypeId())); + termCollector.setConfigName("Test"); + assertTrue("Test".equals(termCollector.getConfigName())); + + DeployNowJson deployNowJson = new DeployNowJson(); + deployNowJson.setDeployNow(true); + assertTrue(deployNowJson.getDeployNow()); + + termCollector.setDeploymentOption(deployNowJson); + assertTrue(termCollector.getDeploymentOption() != null); + termCollector.setSecurityZoneId("Test"); + assertTrue("Test".equals(termCollector.getSecurityZoneId())); + termCollector.setVendorServiceId("Test"); + assertTrue("Test".equals(termCollector.getVendorServiceId())); + + IdMap idMap = new IdMap(); + idMap.setAstraId("Test"); + idMap.setVendorId("Test"); + assertTrue("Test".equals(idMap.getAstraId())); + assertTrue("Test".equals(idMap.getVendorId())); + + List idMapList = new ArrayList<>(); + idMapList.add(idMap); + + VendorSpecificData vendorData = new VendorSpecificData(); + vendorData.setIdMap(idMapList); + assertTrue(vendorData.getIdMap() != null); + termCollector.setVendorSpecificData(vendorData); + assertTrue(termCollector.getVendorSpecificData()!=null); + + termCollector.setServiceGroups(null); + assertTrue(termCollector.getServiceGroups()!=null); + termCollector.setAddressGroups(null); + assertTrue(termCollector.getAddressGroups()!=null); + + Term term = new Term(); + term.setPosition("Test"); + assertTrue("Test".equals(term.getPosition())); + term.setRuleName("Test"); + assertTrue("Test".equals(term.getRuleName())); + term.setFromZones(null); + assertTrue(term.getFromZones() != null); + term.setToZones(null); + assertTrue(term.getToZones() != null); + term.setNegateSource(true); + assertTrue(term.getNegateSource()); + term.setNegateDestination(true); + assertTrue(term.getNegateDestination()); + term.setSourceList(null); + assertTrue(term.getSourceList() != null); + term.setDestinationList(null); + assertTrue(term.getDestinationList() != null); + term.setSourceServices(null); + assertTrue(term.getSourceServices() != null); + term.setDestServices(null); + assertTrue(term.getDestServices() != null); + term.setAction("Test"); + assertTrue("Test".equals(term.getAction())); + term.setDescription("Test"); + assertTrue("Test".equals(term.getDescription())); + term.setEnabled(true); + assertTrue(term.getEnabled()); + term.setLog(true); + assertTrue(term.getLog()); + + termCollector.setFirewallRuleList(null); + assertTrue(termCollector.getFirewallRuleList()!=null); + + Tags tags = new Tags(); + tags.setRuleName("Test"); + assertTrue("Test".equals(tags.getRuleName())); + + TagDefines tagDefines = new TagDefines(); + tagDefines.setKey("Test"); + assertTrue("Test".equals(tagDefines.getKey())); + tagDefines.setValue("Test"); + assertTrue("Test".equals(tagDefines.getValue())); + tags.setTags(new ArrayList<>()); + assertTrue(tags.getTags()!=null); + tags.setTagPickerName("Test"); + assertTrue("Test".equals(tags.getTagPickerName())); + tags.setNetworkRole("Test"); + assertTrue("Test".equals(tags.getNetworkRole())); + List ruleToTag = new ArrayList<>(); + ruleToTag.add(tags); + + termCollector.setRuleToTag(ruleToTag); + assertTrue(termCollector.getRuleToTag()!=null); + } + + @Test + public void testServiceGroupJson(){ + ServiceGroupJson serviceGroup = new ServiceGroupJson(); + serviceGroup.setName("Test"); + assertTrue("Test".equals(serviceGroup.getName())); + serviceGroup.setDescription("Test"); + assertTrue("Test".equals(serviceGroup.getDescription())); + serviceGroup.setMembers(new ArrayList<>()); + assertTrue(serviceGroup.getMembers()!=null); + } + + @Test + public void testServiceListJson(){ + ServiceListJson serviceGroup = new ServiceListJson(); + serviceGroup.setName("Test"); + assertTrue("Test".equals(serviceGroup.getName())); + serviceGroup.setDescription("Test"); + assertTrue("Test".equals(serviceGroup.getDescription())); + serviceGroup.setType("Test"); + assertTrue("Test".equals(serviceGroup.getType())); + serviceGroup.setTransportProtocol("Test"); + assertTrue("Test".equals(serviceGroup.getTransportProtocol())); + serviceGroup.setAppProtocol("Test"); + assertTrue("Test".equals(serviceGroup.getAppProtocol())); + serviceGroup.setPorts("Test"); + assertTrue("Test".equals(serviceGroup.getPorts())); + } + + @Test + public void testServiceMembers(){ + ServiceMembers serviceGroup = new ServiceMembers(); + serviceGroup.setName("Test"); + assertTrue("Test".equals(serviceGroup.getName())); + serviceGroup.setType("Test"); + assertTrue("Test".equals(serviceGroup.getType())); + } + + @Test + public void testServiceJson(){ + ServicesJson serviceGroup = new ServicesJson(); + serviceGroup.setName("Test"); + assertTrue("Test".equals(serviceGroup.getName())); + serviceGroup.setType("Test"); + assertTrue("Test".equals(serviceGroup.getType())); + } + +} diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/PolicyRestAdapterTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/PolicyRestAdapterTest.java new file mode 100644 index 000000000..43567674e --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/PolicyRestAdapterTest.java @@ -0,0 +1,260 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.policy.rest.adapter; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; + +import org.junit.Test; +import org.onap.policy.rest.jpa.OnapName; + +public class PolicyRestAdapterTest { + + @Test + public void testPolicyExportAdapter(){ + PolicyExportAdapter adapter = new PolicyExportAdapter(); + adapter.setPolicyDatas(new ArrayList<>()); + assertTrue(adapter.getPolicyDatas() != null); + } + + @Test + public void testPolicyRestAdapter(){ + PolicyRestAdapter adapter = new PolicyRestAdapter(); + adapter.setData(new Object()); + assertTrue(adapter.getData() != null); + adapter.setPolicyName("com.Config_test.1.xml"); + assertTrue("com.Config_test.1.xml".equals(adapter.getPolicyName())); + adapter.setConfigBodyData("Test"); + assertTrue("Test".equals(adapter.getConfigBodyData())); + adapter.setConfigType("Config_PM"); + assertTrue("Config_PM".equals(adapter.getConfigType())); + adapter.setPolicyID("Test"); + assertTrue("Test".equals(adapter.getPolicyID())); + adapter.setPolicyType("Config"); + assertTrue("Config".equals(adapter.getPolicyType())); + adapter.setComboPolicyType("Test"); + assertTrue("Test".equals(adapter.getComboPolicyType())); + adapter.setConfigPolicyType("Test"); + assertTrue("Test".equals(adapter.getConfigPolicyType())); + adapter.setPolicyDescription("Test"); + assertTrue("Test".equals(adapter.getPolicyDescription())); + adapter.setOnapName("Test"); + assertTrue("Test".equals(adapter.getOnapName())); + adapter.setConfigName("Test"); + assertTrue("Test".equals(adapter.getConfigName())); + adapter.setRuleID("Test"); + assertTrue("Test".equals(adapter.getRuleID())); + adapter.setParentPath("config/webapps"); + assertTrue("config/webapps".equals(adapter.getParentPath())); + adapter.setValidData(true); + assertTrue(adapter.isValidData()); + adapter.setAdminNotification("TestNotification"); + assertTrue("TestNotification".equals(adapter.getAdminNotification())); + adapter.setEditPolicy(true); + assertTrue(adapter.isEditPolicy()); + adapter.setViewPolicy(true); + assertTrue(adapter.isViewPolicy()); + adapter.setDraft(true); + assertTrue(adapter.isDraft()); + adapter.setPolicyData("Test Policy"); + assertTrue("Test Policy".equals(adapter.getPolicyData())); + adapter.setGitPath("config/webapps"); + assertTrue("config/webapps".equals(adapter.getGitPath())); + adapter.setReadOnly(true); + assertTrue(adapter.isReadOnly()); + adapter.setConfigName("Test"); + assertTrue("Test".equals(adapter.getConfigName())); + adapter.setConfigUrl("Test"); + assertTrue("Test".equals(adapter.getConfigUrl())); + adapter.setFinalPolicyPath("config/webapps"); + assertTrue("config/webapps".equals(adapter.getFinalPolicyPath())); + adapter.setVersion("1"); + assertTrue("1".equals(adapter.getVersion())); + adapter.setJsonBody("Test"); + assertTrue("Test".equals(adapter.getJsonBody())); + adapter.setApiflag("API"); + assertTrue("API".equals(adapter.getApiflag())); + adapter.setPrevJsonBody("Test"); + assertTrue("Test".equals(adapter.getPrevJsonBody())); + adapter.setHighestVersion(1); + assertTrue(1 == adapter.getHighestVersion()); + adapter.setPolicyExists(true); + assertTrue(adapter.getPolicyExists()); + adapter.setOldPolicyFileName("Config_oldtest.1.xml"); + assertTrue("Config_oldtest.1.xml".equals(adapter.getOldPolicyFileName())); + adapter.setDomainDir("Test"); + assertTrue("Test".equals(adapter.getDomainDir())); + adapter.setUserId("Test"); + assertTrue("Test".equals(adapter.getUserId())); + adapter.setNewFileName("Test"); + assertTrue("Test".equals(adapter.getNewFileName())); + adapter.setClWarning("Test"); + assertTrue("Test".equals(adapter.getClWarning())); + adapter.setNewCLName("Test"); + assertTrue("Test".equals(adapter.getNewCLName())); + adapter.setExistingCLName("Test"); + assertTrue("Test".equals(adapter.getExistingCLName())); + adapter.setOnapNameField(new OnapName()); + assertTrue(adapter.getOnapNameField()!=null); + adapter.setJsonBodyData(new Object()); + assertTrue(adapter.getJsonBodyData()!=null); + adapter.setDirPath("Test"); + assertTrue("Test".equals(adapter.getDirPath())); + adapter.setConfigBodyPath("Test"); + assertTrue("Test".equals(adapter.getConfigBodyPath())); + adapter.setAttributes(new ArrayList<>()); + assertTrue(adapter.getAttributes()!=null); + adapter.setSettings(new ArrayList<>()); + assertTrue(adapter.getSettings()!=null); + adapter.setRuleAlgorithmschoices(new ArrayList<>()); + assertTrue(adapter.getRuleAlgorithmschoices()!=null); + adapter.setServiceTypePolicyName(new HashMap<>()); + assertTrue(adapter.getServiceTypePolicyName()!=null); + adapter.setVerticaMetrics(new HashMap<>()); + assertTrue(adapter.getVerticaMetrics()!=null); + adapter.setDescription(new LinkedHashMap<>()); + assertTrue(adapter.getVerticaMetrics()!=null); + adapter.setAttributeFields(new LinkedHashMap<>()); + assertTrue(adapter.getAttributeFields()!=null); + adapter.setClearTimeOut("Test"); + assertTrue("Test".equals(adapter.getClearTimeOut())); + adapter.setTrapMaxAge("Test"); + assertTrue("Test".equals(adapter.getTrapMaxAge())); + adapter.setVerificationclearTimeOut("Test"); + assertTrue("Test".equals(adapter.getVerificationclearTimeOut())); + adapter.setDynamicLayoutMap(new HashMap<>()); + assertTrue(adapter.getDynamicLayoutMap()!=null); + adapter.setTrapDatas(new ClosedLoopFaultTrapDatas()); + assertTrue(adapter.getTrapDatas()!=null); + adapter.setFaultDatas(new ClosedLoopFaultTrapDatas()); + assertTrue(adapter.getFaultDatas()!=null); + adapter.setFwPolicyType("Test"); + assertTrue("Test".equals(adapter.getFwPolicyType())); + adapter.setFwattributes(new ArrayList<>()); + assertTrue(adapter.getFwattributes()!=null); + adapter.setParentForChild("Test"); + assertTrue("Test".equals(adapter.getParentForChild())); + adapter.setSecurityZone("Test"); + assertTrue("Test".equals(adapter.getSecurityZone())); + adapter.setRuleCombiningAlgId("Test"); + assertTrue("Test".equals(adapter.getRuleCombiningAlgId())); + adapter.setDynamicFieldConfigAttributes(new HashMap<>()); + assertTrue(adapter.getDynamicFieldConfigAttributes()!=null); + adapter.setDynamicSettingsMap(new HashMap<>()); + assertTrue(adapter.getDynamicSettingsMap()!=null); + adapter.setDropDownMap(new HashMap<>()); + assertTrue(adapter.getDropDownMap()!=null); + adapter.setActionPerformer("Test"); + assertTrue("Test".equals(adapter.getActionPerformer())); + adapter.setActionAttribute("Test"); + assertTrue("Test".equals(adapter.getActionAttribute())); + adapter.setDynamicRuleAlgorithmLabels(new ArrayList<>()); + assertTrue(adapter.getDynamicRuleAlgorithmLabels()!=null); + adapter.setDynamicRuleAlgorithmCombo(new ArrayList<>()); + assertTrue(adapter.getDynamicRuleAlgorithmCombo()!=null); + adapter.setDynamicRuleAlgorithmField1(new ArrayList<>()); + assertTrue(adapter.getDynamicRuleAlgorithmField1()!=null); + adapter.setDynamicRuleAlgorithmField2(new ArrayList<>()); + assertTrue(adapter.getDynamicRuleAlgorithmField2()!=null); + adapter.setDynamicVariableList(new ArrayList<>()); + assertTrue(adapter.getDynamicVariableList()!=null); + adapter.setDataTypeList(new ArrayList<>()); + assertTrue(adapter.getDataTypeList()!=null); + adapter.setActionAttributeValue("Test"); + assertTrue("Test".equals(adapter.getActionAttributeValue())); + adapter.setRuleProvider("Test"); + assertTrue("Test".equals(adapter.getRuleProvider())); + adapter.setActionBody("Test"); + assertTrue("Test".equals(adapter.getActionBody())); + adapter.setActionDictHeader("Test"); + assertTrue("Test".equals(adapter.getActionDictHeader())); + adapter.setActionDictType("Test"); + assertTrue("Test".equals(adapter.getActionDictType())); + adapter.setActionDictUrl("Test"); + assertTrue("Test".equals(adapter.getActionDictUrl())); + adapter.setActionDictMethod("Test"); + assertTrue("Test".equals(adapter.getActionDictMethod())); + adapter.setYamlparams(new YAMLParams()); + assertTrue(adapter.getYamlparams()!=null); + adapter.setRainyday(new RainyDayParams()); + assertTrue(adapter.getRainyday()!=null); + adapter.setRainydayMap(new HashMap<>()); + assertTrue(adapter.getRainydayMap()!=null); + adapter.setErrorCodeList(new ArrayList<>()); + assertTrue(adapter.getErrorCodeList()!=null); + adapter.setTreatmentList(new ArrayList<>()); + assertTrue(adapter.getTreatmentList()!=null); + adapter.setServiceType("Test"); + assertTrue("Test".equals(adapter.getServiceType())); + adapter.setUuid("Test"); + assertTrue("Test".equals(adapter.getUuid())); + adapter.setLocation("Test"); + assertTrue("Test".equals(adapter.getLocation())); + adapter.setPriority("Test"); + assertTrue("Test".equals(adapter.getPriority())); + adapter.setMsLocation("Test"); + assertTrue("Test".equals(adapter.getMsLocation())); + adapter.setPolicyJSON("Test"); + assertTrue("Test".equals(adapter.getPolicyJSON())); + adapter.setRuleName("Test"); + assertTrue("Test".equals(adapter.getRuleName())); + adapter.setBrmsParamBody(new HashMap<>()); + assertTrue(adapter.getBrmsParamBody()!=null); + adapter.setBrmsController("Test"); + assertTrue("Test".equals(adapter.getBrmsController())); + adapter.setBrmsDependency(new ArrayList<>()); + assertTrue(adapter.getBrmsDependency()!=null); + adapter.setRuleData(new LinkedHashMap<>()); + assertTrue(adapter.getRuleData()!=null); + adapter.setRuleListData(new LinkedHashMap<>()); + assertTrue(adapter.getRuleListData()!=null); + adapter.setDrlRuleAndUIParams(new LinkedHashMap<>()); + assertTrue(adapter.getDrlRuleAndUIParams()!=null); + adapter.setPolicyScope("Test"); + assertTrue("Test".equals(adapter.getPolicyScope())); + adapter.setProviderComboBox("Test"); + assertTrue("Test".equals(adapter.getProviderComboBox())); + adapter.setRiskType("Test"); + assertTrue("Test".equals(adapter.getRiskType())); + adapter.setRiskLevel("Test"); + assertTrue("Test".equals(adapter.getRiskLevel())); + adapter.setGuard("Test"); + assertTrue("Test".equals(adapter.getGuard())); + adapter.setTtlDate("Test"); + assertTrue("Test".equals(adapter.getTtlDate())); + adapter.setMatching(new LinkedHashMap<>()); + assertTrue(adapter.getMatching()!=null); + adapter.setTriggerSignatures(new ArrayList<>()); + assertTrue(adapter.getTriggerSignatures()!=null); + adapter.setSymptomSignatures(new ArrayList<>()); + assertTrue(adapter.getSymptomSignatures()!=null); + adapter.setLogicalConnector("Test"); + assertTrue("Test".equals(adapter.getLogicalConnector())); + adapter.setPolicyStatus("Test"); + assertTrue("Test".equals(adapter.getPolicyStatus())); + adapter.setGocServerScope("Test"); + assertTrue("Test".equals(adapter.getGocServerScope())); + adapter.setSupressionType("Test"); + assertTrue("Test".equals(adapter.getSupressionType())); + } +} diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/RainyDayParamsTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/RainyDayParamsTest.java new file mode 100644 index 000000000..521eafdf9 --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/RainyDayParamsTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.policy.rest.adapter; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; + +import org.junit.Test; + +public class RainyDayParamsTest { + + @Test + public void testRainyDayParams(){ + RainyDayParams params = new RainyDayParams(); + params.setServiceType("Test"); + assertTrue("Test".equals(params.getServiceType())); + params.setVnfType("Test"); + assertTrue("Test".equals(params.getVnfType())); + params.setBbid("Test"); + assertTrue("Test".equals(params.getBbid())); + params.setWorkstep("Test"); + assertTrue("Test".equals(params.getWorkstep())); + params.setTreatmentTableChoices(new ArrayList<>()); + assertTrue(params.getTreatmentTableChoices() != null); + params.setErrorcode(new ArrayList<>()); + assertTrue(params.getErrorcode() != null); + params.setTreatment(new ArrayList<>()); + assertTrue(params.getTreatment() != null); + } +} diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/YAMLParamsTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/YAMLParamsTest.java new file mode 100644 index 000000000..007141f41 --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/YAMLParamsTest.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.policy.rest.adapter; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; + +import org.junit.Test; + +public class YAMLParamsTest { + + @Test + public void testYAMLParams(){ + YAMLParams yamlParams = new YAMLParams(); + yamlParams.setActor("Test"); + assertTrue("Test".equals(yamlParams.getActor())); + yamlParams.setRecipe("Test"); + assertTrue("Test".equals(yamlParams.getRecipe())); + yamlParams.setClname("Test"); + assertTrue("Test".equals(yamlParams.getClname())); + yamlParams.setGuardActiveEnd("Test"); + assertTrue("Test".equals(yamlParams.getGuardActiveEnd())); + yamlParams.setGuardActiveStart("Test"); + assertTrue("Test".equals(yamlParams.getGuardActiveStart())); + yamlParams.setLimit("Test"); + assertTrue("Test".equals(yamlParams.getLimit())); + yamlParams.setBlackList(new ArrayList<>()); + assertTrue(yamlParams.getBlackList() != null); + yamlParams.setTargets(new ArrayList<>()); + assertTrue(yamlParams.getTargets() != null); + yamlParams.setTimeUnits("Test"); + assertTrue("Test".equals(yamlParams.getTimeUnits())); + yamlParams.setTimeWindow("Test"); + assertTrue("Test".equals(yamlParams.getTimeWindow())); + } + +} -- cgit 1.2.3-korg