From 5af510f5e0a3ac0d981292ecaf0bb6b3cef1d7e7 Mon Sep 17 00:00:00 2001 From: "phani.y" Date: Fri, 5 Feb 2021 18:46:37 +0530 Subject: Added vfc adaptor Issue-ID: SO-3520 Signed-off-by: phani.y Change-Id: I8e219a416072fc3e6de09c6cb5aab6f70470bd16 --- .../vfc/exceptions/ApplicationExceptionTest.java | 36 + .../onap/so/adapters/vfc/model/AddPnfDataTest.java | 189 +++++ .../so/adapters/vfc/model/AddressRangeTest.java | 39 ++ .../onap/so/adapters/vfc/model/AffectedNsTest.java | 40 ++ .../so/adapters/vfc/model/AffectedPnfTest.java | 69 ++ .../so/adapters/vfc/model/AffectedSapTest.java | 49 ++ .../vfc/model/AffectedVirtualLinkTest.java | 49 ++ .../so/adapters/vfc/model/AffectedVnfTest.java | 69 ++ .../so/adapters/vfc/model/AffectedVnffgTest.java | 39 ++ .../vfc/model/AffinityOrAntiAffinityRuleTest.java | 283 ++++++++ .../so/adapters/vfc/model/ChangedInfoTest.java | 39 ++ .../vfc/model/CivicAddressElementTest.java | 39 ++ .../so/adapters/vfc/model/CpProtocolDataTest.java | 39 ++ .../so/adapters/vfc/model/CreateNsRequestTest.java | 49 ++ .../so/adapters/vfc/model/CustomerModelTest.java | 49 ++ .../so/adapters/vfc/model/ExtLinkPortInfoTest.java | 40 ++ .../adapters/vfc/model/ExtVirtualLinkInfoTest.java | 49 ++ .../vfc/model/InstantiateNsRequestTest.java | 413 +++++++++++ .../so/adapters/vfc/model/IpAddressesTest.java | 188 +++++ .../vfc/model/IpOverEthernetAddressDataTest.java | 158 +++++ .../org/onap/so/adapters/vfc/model/LinkTest.java | 29 + .../org/onap/so/adapters/vfc/model/LinksTest.java | 89 +++ .../adapters/vfc/model/LocationConstraintTest.java | 49 ++ .../vfc/model/LocationConstraintsTest.java | 40 ++ .../adapters/vfc/model/ModifyVnfInfoDataTest.java | 90 +++ .../vfc/model/NSResourceInputParameterTest.java | 69 ++ .../so/adapters/vfc/model/NsCreateReqTest.java | 69 ++ .../adapters/vfc/model/NsInstantiateReqTest.java | 39 ++ .../onap/so/adapters/vfc/model/NsLcmOpOccTest.java | 142 ++++ .../so/adapters/vfc/model/NsOperationKeyTest.java | 79 +++ .../so/adapters/vfc/model/NsParametersTest.java | 51 ++ .../adapters/vfc/model/NsProgressStatusTest.java | 60 ++ .../so/adapters/vfc/model/ParamsForVnfTest.java | 41 ++ .../so/adapters/vfc/model/PnfExtCpDataTest.java | 168 +++++ .../so/adapters/vfc/model/ProblemDetailsTest.java | 69 ++ .../so/adapters/vfc/model/ResourceChangesTest.java | 773 +++++++++++++++++++++ .../so/adapters/vfc/model/ResourceHandleTest.java | 59 ++ .../adapters/vfc/model/ResponseDescriptorTest.java | 79 +++ .../so/adapters/vfc/model/RestfulResponseTest.java | 75 ++ .../onap/so/adapters/vfc/model/SapDataTest.java | 179 +++++ .../so/adapters/vfc/model/VimLocationTest.java | 39 ++ .../so/adapters/vfc/model/VnfInstanceDataTest.java | 39 ++ .../vfc/model/VnfLocationConstraintTest.java | 39 ++ .../adapters/vfc/rest/EmbeddedMariaDbConfig.java | 86 +++ .../adapters/vfc/rest/HealthCheckHandlerTest.java | 67 ++ .../so/adapters/vfc/rest/VfcManagerSol005Test.java | 221 ++++++ .../onap/so/adapters/vfc/rest/VfcManagerTest.java | 156 +++++ .../onap/so/adapters/vfc/util/RestfulUtilTest.java | 164 +++++ src/test/resources/application-test.yaml | 64 ++ src/test/resources/json/LICENSE.txt | 19 + src/test/resources/json/aainfvoResponse.json | 10 + src/test/resources/json/createNsReq.json | 56 ++ src/test/resources/json/createNsRsp.json | 3 + .../resources/json/createNsSol005Response.json | 210 ++++++ src/test/resources/json/deleteNsReq.json | 7 + src/test/resources/json/instantiateNsReq.json | 32 + src/test/resources/json/instantiateNsRsp.json | 3 + src/test/resources/json/lcmOperRsp.json | 7 + src/test/resources/json/queryJobReq.json | 7 + src/test/resources/json/queryJobRsp.json | 10 + src/test/resources/json/terminateNsReq.json | 7 + src/test/resources/json/terminateNsRsp.json | 3 + src/test/resources/logback-test.xml | 42 ++ 63 files changed, 5465 insertions(+) create mode 100644 src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/AddPnfDataTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/AddressRangeTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/AffectedNsTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/AffectedPnfTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/AffectedSapTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/AffectedVirtualLinkTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/AffectedVnfTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/AffectedVnffgTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/AffinityOrAntiAffinityRuleTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/ChangedInfoTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/CivicAddressElementTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/CpProtocolDataTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/CreateNsRequestTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/ExtLinkPortInfoTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/ExtVirtualLinkInfoTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/InstantiateNsRequestTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/IpAddressesTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/IpOverEthernetAddressDataTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/LinkTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/LinksTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintsTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/ModifyVnfInfoDataTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/NsLcmOpOccTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/ParamsForVnfTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/PnfExtCpDataTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/ProblemDetailsTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/ResourceChangesTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/ResourceHandleTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/SapDataTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/VnfInstanceDataTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/model/VnfLocationConstraintTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/rest/EmbeddedMariaDbConfig.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerSol005Test.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java create mode 100644 src/test/java/org/onap/so/adapters/vfc/util/RestfulUtilTest.java create mode 100644 src/test/resources/application-test.yaml create mode 100644 src/test/resources/json/LICENSE.txt create mode 100644 src/test/resources/json/aainfvoResponse.json create mode 100644 src/test/resources/json/createNsReq.json create mode 100644 src/test/resources/json/createNsRsp.json create mode 100644 src/test/resources/json/createNsSol005Response.json create mode 100644 src/test/resources/json/deleteNsReq.json create mode 100644 src/test/resources/json/instantiateNsReq.json create mode 100644 src/test/resources/json/instantiateNsRsp.json create mode 100644 src/test/resources/json/lcmOperRsp.json create mode 100644 src/test/resources/json/queryJobReq.json create mode 100644 src/test/resources/json/queryJobRsp.json create mode 100644 src/test/resources/json/terminateNsReq.json create mode 100644 src/test/resources/json/terminateNsRsp.json create mode 100644 src/test/resources/logback-test.xml (limited to 'src/test') diff --git a/src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java b/src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java new file mode 100644 index 0000000..c0305f1 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java @@ -0,0 +1,36 @@ +/* + * ============LICENSE_START======================================================= ONAP : SO + * ================================================================================ Copyright (C) 2018 TechMahindra + * ================================================================================ Licensed under the Apache License, + * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.so.adapters.vfc.exceptions; + +import static org.junit.Assert.*; +import org.junit.Test; + +public class ApplicationExceptionTest { + private ApplicationException application = new ApplicationException(500, null); + + @Test + public void testApplicationException() { + application.setErrorCode(500); + application.setErrorMsg("ErrorMsg"); + assertEquals(application.getErrorCode(), 500); + assertEquals(application.getErrorMsg(), "ErrorMsg"); + } + + @Test + public void testbuildErrorResponse() { + assert (application.buildErrorResponse() != null); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/AddPnfDataTest.java b/src/test/java/org/onap/so/adapters/vfc/model/AddPnfDataTest.java new file mode 100644 index 0000000..1fedac9 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/AddPnfDataTest.java @@ -0,0 +1,189 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class AddPnfDataTest { + AddPnfData pnfData = new AddPnfData(); + + @Test + public void getPnfId() { + pnfData.getPnfId(); + } + + + @Test + public void setPnfId() { + pnfData.setPnfId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getPnfName() { + pnfData.getPnfName(); + } + + @Test + public void setPnfName() { + pnfData.setPnfName("Router"); + } + + @Test + public void getPnfdId() { + pnfData.getPnfdId(); + } + + @Test + public void setPnfdId() { + pnfData.setPnfdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getPnfProfileId() { + pnfData.getPnfProfileId(); + } + + @Test + public void setPnfProfileId() { + pnfData.setPnfProfileId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getCpData() { + pnfData.getCpData(); + } + + @Test + public void setCpData() { + pnfData.setCpData(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(PnfExtCpData pnfExtCpData) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public PnfExtCpData get(int index) { + return null; + } + + @Override + public PnfExtCpData set(int index, PnfExtCpData element) { + return null; + } + + @Override + public void add(int index, PnfExtCpData element) { + + } + + @Override + public PnfExtCpData remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/AddressRangeTest.java b/src/test/java/org/onap/so/adapters/vfc/model/AddressRangeTest.java new file mode 100644 index 0000000..9444efd --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/AddressRangeTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class AddressRangeTest { + AddressRange addressRange = new AddressRange(); + + @Test + public void getMinAddress() { + addressRange.getMinAddress(); + } + + @Test + public void setMinAddress() { + addressRange.setMinAddress("192.168.10.10"); + } + + @Test + public void getMaxAddress() { + addressRange.getMaxAddress(); + } + + @Test + public void setMaxAddress() { + addressRange.setMaxAddress("192.168.10.10"); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/AffectedNsTest.java b/src/test/java/org/onap/so/adapters/vfc/model/AffectedNsTest.java new file mode 100644 index 0000000..06c52e2 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/AffectedNsTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class AffectedNsTest { + + AffectedNs affectedNs = new AffectedNs(); + + @Test + public void getNsInstanceId() { + affectedNs.getNsInstanceId(); + } + + @Test + public void setNsInstanceId() { + affectedNs.setNsInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getNsdId() { + affectedNs.getNsdId(); + } + + @Test + public void setNsdId() { + affectedNs.setNsdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/AffectedPnfTest.java b/src/test/java/org/onap/so/adapters/vfc/model/AffectedPnfTest.java new file mode 100644 index 0000000..beecbe0 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/AffectedPnfTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class AffectedPnfTest { + AffectedPnf affectedPnf = new AffectedPnf(); + + @Test + public void getPnfid() { + affectedPnf.getPnfid(); + } + + @Test + public void setPnfid() { + affectedPnf.setPnfid("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getPnfdid() { + affectedPnf.getPnfdid(); + } + + @Test + public void setPnfdid() { + affectedPnf.setPnfdid("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getPnfProfileId() { + affectedPnf.getPnfProfileId(); + } + + @Test + public void setPnfProfileId() { + affectedPnf.setPnfProfileId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getPnfName() { + affectedPnf.getPnfName(); + } + + @Test + public void setPnfName() { + affectedPnf.setPnfName("Router"); + } + + @Test + public void getCpInstanceId() { + affectedPnf.getCpInstanceId(); + } + + @Test + public void setCpInstanceId() { + affectedPnf.setCpInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/AffectedSapTest.java b/src/test/java/org/onap/so/adapters/vfc/model/AffectedSapTest.java new file mode 100644 index 0000000..b96fe32 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/AffectedSapTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class AffectedSapTest { + AffectedSap affectedSap = new AffectedSap(); + + @Test + public void getSapInstanceId() { + affectedSap.getSapInstanceId(); + } + + @Test + public void setSapInstanceId() { + affectedSap.setSapInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getSapdId() { + affectedSap.getSapdId(); + } + + @Test + public void setSapdId() { + affectedSap.setSapdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getSapName() { + affectedSap.getSapName(); + } + + @Test + public void setSapName() { + affectedSap.setSapName("Dummy SAP"); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/AffectedVirtualLinkTest.java b/src/test/java/org/onap/so/adapters/vfc/model/AffectedVirtualLinkTest.java new file mode 100644 index 0000000..dbc6d08 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/AffectedVirtualLinkTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class AffectedVirtualLinkTest { + AffectedVirtualLink affectedVirtualLink = new AffectedVirtualLink(); + + @Test + public void getNsVirtualLinkInstanceId() { + affectedVirtualLink.getNsVirtualLinkInstanceId(); + } + + @Test + public void setNsVirtualLinkInstanceId() { + affectedVirtualLink.setNsVirtualLinkInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getNsVirtualLinkDescId() { + affectedVirtualLink.getNsVirtualLinkDescId(); + } + + @Test + public void setNsVirtualLinkDescId() { + affectedVirtualLink.setNsVirtualLinkDescId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVlProfileId() { + affectedVirtualLink.getVlProfileId(); + } + + @Test + public void setVlProfileId() { + affectedVirtualLink.setVlProfileId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/AffectedVnfTest.java b/src/test/java/org/onap/so/adapters/vfc/model/AffectedVnfTest.java new file mode 100644 index 0000000..810f32d --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/AffectedVnfTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class AffectedVnfTest { + AffectedVnf affectedVnf = new AffectedVnf(); + + @Test + public void getVnfInstanceId() { + affectedVnf.getVnfInstanceId(); + } + + @Test + public void setVnfInstanceId() { + affectedVnf.setVnfInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnfdId() { + affectedVnf.getVnfdId(); + } + + @Test + public void setVnfdId() { + affectedVnf.setVnfdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnfProfileId() { + affectedVnf.getVnfProfileId(); + } + + @Test + public void setVnfProfileId() { + affectedVnf.setVnfProfileId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnfName() { + affectedVnf.getVnfName(); + } + + @Test + public void setVnfName() { + affectedVnf.setVnfName("Dummy Vnf Name"); + } + + @Test + public void getChangedInfo() { + affectedVnf.getChangedInfo(); + } + + @Test + public void setChangedInfo() { + affectedVnf.setChangedInfo(new ChangedInfo()); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/AffectedVnffgTest.java b/src/test/java/org/onap/so/adapters/vfc/model/AffectedVnffgTest.java new file mode 100644 index 0000000..0d56701 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/AffectedVnffgTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class AffectedVnffgTest { + AffectedVnffg affectedVnffg = new AffectedVnffg(); + + @Test + public void getVnffgInstanceId() { + affectedVnffg.getVnffgInstanceId(); + } + + @Test + public void setVnffgInstanceId() { + affectedVnffg.setVnffgInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnffgdId() { + affectedVnffg.getVnffgdId(); + } + + @Test + public void setVnffgdId() { + affectedVnffg.setVnffgdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/AffinityOrAntiAffinityRuleTest.java b/src/test/java/org/onap/so/adapters/vfc/model/AffinityOrAntiAffinityRuleTest.java new file mode 100644 index 0000000..99a40e4 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/AffinityOrAntiAffinityRuleTest.java @@ -0,0 +1,283 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class AffinityOrAntiAffinityRuleTest { + AffinityOrAntiAffinityRule affinityOrAntiAffinityRule = new AffinityOrAntiAffinityRule(); + + @Test + public void getVnfdId() { + affinityOrAntiAffinityRule.getVnfdId(); + } + + @Test + public void setVnfdId() { + affinityOrAntiAffinityRule.setVnfdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnfProfileId() { + affinityOrAntiAffinityRule.getVnfProfileId(); + } + + @Test + public void setVnfProfileId() { + affinityOrAntiAffinityRule.setVnfProfileId(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(String s) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public String get(int index) { + return null; + } + + @Override + public String set(int index, String element) { + return null; + } + + @Override + public void add(int index, String element) { + + } + + @Override + public String remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getVnfInstanceId() { + affinityOrAntiAffinityRule.getVnfInstanceId(); + } + + @Test + public void setVnfInstanceId() { + affinityOrAntiAffinityRule.setVnfInstanceId(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(String s) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public String get(int index) { + return null; + } + + @Override + public String set(int index, String element) { + return null; + } + + @Override + public void add(int index, String element) { + + } + + @Override + public String remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/ChangedInfoTest.java b/src/test/java/org/onap/so/adapters/vfc/model/ChangedInfoTest.java new file mode 100644 index 0000000..41077fb --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/ChangedInfoTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class ChangedInfoTest { + ChangedInfo changedInfo = new ChangedInfo(); + + @Test + public void getChangedVnfInfo() { + changedInfo.getChangedVnfInfo(); + } + + @Test + public void setChangedVnfInfo() { + changedInfo.setChangedVnfInfo(new ModifyVnfInfoData()); + } + + @Test + public void getChangedExtConnectivity() { + changedInfo.getChangedExtConnectivity(); + } + + @Test + public void setChangedExtConnectivity() { + changedInfo.setChangedExtConnectivity(new ExtVirtualLinkInfo()); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/CivicAddressElementTest.java b/src/test/java/org/onap/so/adapters/vfc/model/CivicAddressElementTest.java new file mode 100644 index 0000000..e9c011b --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/CivicAddressElementTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class CivicAddressElementTest { + CivicAddressElement civicAddressElement = new CivicAddressElement(); + + @Test + public void getCaType() { + civicAddressElement.getCaType(); + } + + @Test + public void setCaType() { + civicAddressElement.setCaType(12); + } + + @Test + public void getCaValue() { + civicAddressElement.getCaValue(); + } + + @Test + public void setCaValue() { + civicAddressElement.setCaValue("Dummy Ca value"); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/CpProtocolDataTest.java b/src/test/java/org/onap/so/adapters/vfc/model/CpProtocolDataTest.java new file mode 100644 index 0000000..e47d02c --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/CpProtocolDataTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class CpProtocolDataTest { + CpProtocolData cpProtocolData = new CpProtocolData(); + + @Test + public void getLayerProtocol() { + cpProtocolData.getLayerProtocol(); + } + + @Test + public void setLayerProtocol() { + cpProtocolData.setLayerProtocol("BGP"); + } + + @Test + public void getIpOverEthernet() { + cpProtocolData.getIpOverEthernet(); + } + + @Test + public void setIpOverEthernet() { + cpProtocolData.setIpOverEthernet(new IpOverEthernetAddressData()); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/CreateNsRequestTest.java b/src/test/java/org/onap/so/adapters/vfc/model/CreateNsRequestTest.java new file mode 100644 index 0000000..a2a6ae4 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/CreateNsRequestTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class CreateNsRequestTest { + CreateNsRequest createNsRequest = new CreateNsRequest(); + + @Test + public void getNsdId() { + createNsRequest.getNsdId(); + } + + @Test + public void setNsdId() { + createNsRequest.setNsdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getNsDescription() { + createNsRequest.getNsDescription(); + } + + @Test + public void setNsDescription() { + createNsRequest.setNsDescription("Dummy description"); + } + + @Test + public void getNsName() { + createNsRequest.getNsName(); + } + + @Test + public void setNsName() { + createNsRequest.setNsName("Dummy Name"); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java b/src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java new file mode 100644 index 0000000..548d8b3 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All 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.so.adapters.vfc.model; + +import org.junit.Test; + +public class CustomerModelTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + CustomerModel customerModel = new CustomerModel(); + + @Test + public void getGlobalCustomerId() throws Exception { + customerModel.getGlobalCustomerId(); + } + + @Test + public void setGlobalCustomerId() throws Exception { + customerModel.setGlobalCustomerId("test"); + } + + @Test + public void getServiceType() throws Exception { + customerModel.getServiceType(); + } + + @Test + public void setServiceType() throws Exception { + customerModel.setServiceType("service"); + } + +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/ExtLinkPortInfoTest.java b/src/test/java/org/onap/so/adapters/vfc/model/ExtLinkPortInfoTest.java new file mode 100644 index 0000000..92cec88 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/ExtLinkPortInfoTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class ExtLinkPortInfoTest { + + ExtLinkPortInfo extLinkPortInfo = new ExtLinkPortInfo(); + + @Test + public void getId() { + extLinkPortInfo.getId(); + } + + @Test + public void setId() { + extLinkPortInfo.setId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getResourceHandle() { + extLinkPortInfo.getResourceHandle(); + } + + @Test + public void setResourceHandle() { + extLinkPortInfo.setResourceHandle(new ResourceHandle()); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/ExtVirtualLinkInfoTest.java b/src/test/java/org/onap/so/adapters/vfc/model/ExtVirtualLinkInfoTest.java new file mode 100644 index 0000000..c455b36 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/ExtVirtualLinkInfoTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class ExtVirtualLinkInfoTest { + ExtVirtualLinkInfo extVirtualLinkInfo = new ExtVirtualLinkInfo(); + + @Test + public void getId() { + extVirtualLinkInfo.getId(); + } + + @Test + public void setId() { + extVirtualLinkInfo.setId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getResourceHandle() { + extVirtualLinkInfo.getResourceHandle(); + } + + @Test + public void setResourceHandle() { + extVirtualLinkInfo.setResourceHandle(new ResourceHandle()); + } + + @Test + public void getExtLinkPorts() { + extVirtualLinkInfo.getExtLinkPorts(); + } + + @Test + public void setExtLinkPorts() { + extVirtualLinkInfo.setExtLinkPorts(new ExtLinkPortInfo()); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/InstantiateNsRequestTest.java b/src/test/java/org/onap/so/adapters/vfc/model/InstantiateNsRequestTest.java new file mode 100644 index 0000000..f27b041 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/InstantiateNsRequestTest.java @@ -0,0 +1,413 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class InstantiateNsRequestTest { + InstantiateNsRequest instantiateNsRequest = new InstantiateNsRequest(); + + @Test + public void getNsFlavourId() { + instantiateNsRequest.getNsFlavourId(); + } + + @Test + public void setNsFlavourId() { + instantiateNsRequest.setNsFlavourId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getSapData() { + instantiateNsRequest.getSapData(); + } + + @Test + public void setSapData() { + instantiateNsRequest.setSapData(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(SapData sapData) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public SapData get(int index) { + return null; + } + + @Override + public SapData set(int index, SapData element) { + return null; + } + + @Override + public void add(int index, SapData element) { + + } + + @Override + public SapData remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getAddpnfData() { + instantiateNsRequest.getAddpnfData(); + } + + @Test + public void setAddpnfData() { + instantiateNsRequest.setAddpnfData(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(AddPnfData addPnfData) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public AddPnfData get(int index) { + return null; + } + + @Override + public AddPnfData set(int index, AddPnfData element) { + return null; + } + + @Override + public void add(int index, AddPnfData element) { + + } + + @Override + public AddPnfData remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getVnfInstanceData() { + instantiateNsRequest.getVnfInstanceData(); + } + + @Test + public void setVnfInstanceData() { + instantiateNsRequest.setVnfInstanceData(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(VnfInstanceData vnfInstanceData) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public VnfInstanceData get(int index) { + return null; + } + + @Override + public VnfInstanceData set(int index, VnfInstanceData element) { + return null; + } + + @Override + public void add(int index, VnfInstanceData element) { + + } + + @Override + public VnfInstanceData remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getNestedNsInstanceId() { + instantiateNsRequest.getNestedNsInstanceId(); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/IpAddressesTest.java b/src/test/java/org/onap/so/adapters/vfc/model/IpAddressesTest.java new file mode 100644 index 0000000..edf6346 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/IpAddressesTest.java @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class IpAddressesTest { + IpAddresses ipAddresses = new IpAddresses(); + + @Test + public void getType() { + ipAddresses.getType(); + } + + @Test + public void setType() { + ipAddresses.setType("Dummy Type"); + } + + @Test + public void getFixedAddresses() { + ipAddresses.getFixedAddresses(); + } + + @Test + public void setFixedAddresses() { + ipAddresses.setFixedAddresses(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(String s) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public String get(int index) { + return null; + } + + @Override + public String set(int index, String element) { + return null; + } + + @Override + public void add(int index, String element) { + + } + + @Override + public String remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getNumDynamicAddresses() { + ipAddresses.getNumDynamicAddresses(); + } + + @Test + public void setNumDynamicAddresses() { + ipAddresses.setNumDynamicAddresses(5); + } + + @Test + public void getAddressRange() { + ipAddresses.getAddressRange(); + } + + @Test + public void setAddressRange() { + ipAddresses.setAddressRange(new AddressRange()); + } + + @Test + public void getSubnetId() { + ipAddresses.getSubnetId(); + } + + @Test + public void setSubnetId() { + ipAddresses.setSubnetId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/IpOverEthernetAddressDataTest.java b/src/test/java/org/onap/so/adapters/vfc/model/IpOverEthernetAddressDataTest.java new file mode 100644 index 0000000..0088cdc --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/IpOverEthernetAddressDataTest.java @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class IpOverEthernetAddressDataTest { + IpOverEthernetAddressData ipOverEthernetAddressData = new IpOverEthernetAddressData(); + + @Test + public void getMacAddress() { + ipOverEthernetAddressData.getMacAddress(); + } + + @Test + public void setMacAddress() { + ipOverEthernetAddressData.setMacAddress("4e:86:9f:62:c1:bf"); + } + + @Test + public void getIpAddresses() { + ipOverEthernetAddressData.getIpAddresses(); + } + + @Test + public void setIpAddresses() { + ipOverEthernetAddressData.setIpAddresses(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(IpAddresses ipAddresses) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public IpAddresses get(int index) { + return null; + } + + @Override + public IpAddresses set(int index, IpAddresses element) { + return null; + } + + @Override + public void add(int index, IpAddresses element) { + + } + + @Override + public IpAddresses remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/LinkTest.java b/src/test/java/org/onap/so/adapters/vfc/model/LinkTest.java new file mode 100644 index 0000000..e447c85 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/LinkTest.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class LinkTest { + Link link = new Link(); + + @Test + public void getHref() { + link.getHref(); + } + + @Test + public void setHref() { + link.setHref("dummy href"); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/LinksTest.java b/src/test/java/org/onap/so/adapters/vfc/model/LinksTest.java new file mode 100644 index 0000000..aef87c4 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/LinksTest.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class LinksTest { + Links links = new Links(); + + @Test + public void getSelf() { + links.getSelf(); + } + + @Test + public void setSelf() { + links.setSelf(new Link()); + } + + @Test + public void getNsInstance() { + links.getNsInstance(); + } + + @Test + public void setNsInstance() { + links.setNsInstance(new Link()); + } + + @Test + public void getCancel() { + links.getCancel(); + } + + @Test + public void setCancel() { + links.setCancel(new Link()); + } + + @Test + public void getRetry() { + links.getRetry(); + } + + @Test + public void setRetry() { + links.setRetry(new Link()); + } + + @Test + public void getRollback() { + links.getRollback(); + } + + @Test + public void setRollback() { + links.setRollback(new Link()); + } + + @Test + public void getContinues() { + links.getContinues(); + } + + @Test + public void setContinues() { + links.setContinues(new Link()); + } + + @Test + public void getFail() { + links.getFail(); + } + + @Test + public void setFail() { + links.setFail(new Link()); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java b/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java new file mode 100644 index 0000000..2b21746 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All 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.so.adapters.vfc.model; + +import org.junit.Test; + +public class LocationConstraintTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + LocationConstraint locationConstraint = new LocationConstraint(); + + @Test + public void getVnfProfileId() throws Exception { + locationConstraint.getVnfProfileId(); + } + + @Test + public void setVnfProfileId() throws Exception { + locationConstraint.setVnfProfileId("profileID"); + } + + @Test + public void getLocationConstraints() throws Exception { + locationConstraint.getLocationConstraints(); + } + + @Test + public void setLocationConstraints() throws Exception { + locationConstraint.setLocationConstraints(new VimLocation()); + } + +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintsTest.java b/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintsTest.java new file mode 100644 index 0000000..e68b12a --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintsTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class LocationConstraintsTest { + LocationConstraints locationConstraints = new LocationConstraints(); + + @Test + public void getCountryCode() { + locationConstraints.getCountryCode(); + } + + @Test + public void setCountryCode() { + locationConstraints.setCountryCode("IND"); + + } + + @Test + public void getCivicAddressElement() { + locationConstraints.getCivicAddressElement(); + } + + @Test + public void setCivicAddressElement() { + locationConstraints.setCivicAddressElement(new CivicAddressElement()); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/ModifyVnfInfoDataTest.java b/src/test/java/org/onap/so/adapters/vfc/model/ModifyVnfInfoDataTest.java new file mode 100644 index 0000000..c300923 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/ModifyVnfInfoDataTest.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.HashMap; +import static org.junit.Assert.*; + +public class ModifyVnfInfoDataTest { + ModifyVnfInfoData modifyVnfInfoData = new ModifyVnfInfoData(); + + @Test + public void getVnfInstanceId() { + modifyVnfInfoData.getVnfInstanceId(); + } + + @Test + public void setVnfInstanceId() { + modifyVnfInfoData.setVnfInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnfInstanceName() { + modifyVnfInfoData.getVnfInstanceName(); + } + + @Test + public void setVnfInstanceName() { + modifyVnfInfoData.setVnfInstanceName("Dummy vnfInstanceName"); + } + + @Test + public void getVnfInstanceDescription() { + modifyVnfInfoData.getVnfInstanceDescription(); + } + + @Test + public void setVnfInstanceDescription() { + modifyVnfInfoData.setVnfInstanceDescription("Dummy vnfInstanceDescription"); + } + + @Test + public void getVnfPkgId() { + modifyVnfInfoData.getVnfPkgId(); + } + + @Test + public void setVnfPkgId() { + modifyVnfInfoData.setVnfPkgId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnfConfigurableProperties() { + modifyVnfInfoData.getVnfConfigurableProperties(); + } + + @Test + public void setVnfConfigurableProperties() { + modifyVnfInfoData.setVnfConfigurableProperties(new HashMap<>()); + } + + @Test + public void getMetadata() { + modifyVnfInfoData.getMetadata(); + } + + @Test + public void setMetadata() { + modifyVnfInfoData.setMetadata(new HashMap<>()); + } + + @Test + public void getExtensions() { + modifyVnfInfoData.getExtensions(); + } + + @Test + public void setExtensions() { + modifyVnfInfoData.setExtensions(new HashMap<>()); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java b/src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java new file mode 100644 index 0000000..082d4e6 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All 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.so.adapters.vfc.model; + +import org.junit.Test; + +public class NSResourceInputParameterTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + NSResourceInputParameter nsResourceInputParameter = new NSResourceInputParameter(); + + @Test + public void getNsServiceName() throws Exception { + nsResourceInputParameter.getNsServiceName(); + } + + @Test + public void setNsServiceName() throws Exception { + nsResourceInputParameter.setNsServiceName("service"); + } + + @Test + public void getNsServiceDescription() throws Exception { + nsResourceInputParameter.getNsServiceDescription(); + } + + @Test + public void setNsServiceDescription() throws Exception { + nsResourceInputParameter.setNsServiceDescription("desc"); + } + + @Test + public void getNsParameters() throws Exception { + nsResourceInputParameter.getNsParameters(); + } + + @Test + public void setNsParameters() throws Exception { + nsResourceInputParameter.setNsParameters(new NsParameters()); + } + + @Test + public void getNsOperationKey() throws Exception { + nsResourceInputParameter.getNsOperationKey(); + } + + @Test + public void setNsOperationKey() throws Exception { + nsResourceInputParameter.setNsOperationKey(new NsOperationKey()); + } + +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java b/src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java new file mode 100644 index 0000000..c2e6b58 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All 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.so.adapters.vfc.model; + +import org.junit.Test; + +public class NsCreateReqTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + NsCreateReq nsCreateReq = new NsCreateReq(); + + @Test + public void getContext() throws Exception { + nsCreateReq.getContext(); + } + + @Test + public void setContext() throws Exception { + nsCreateReq.setContext(new CustomerModel()); + } + + @Test + public void getCsarId() throws Exception { + nsCreateReq.getCsarId(); + } + + @Test + public void setCsarId() throws Exception { + nsCreateReq.setCsarId("csarid"); + } + + @Test + public void getNsName() throws Exception { + nsCreateReq.getNsName(); + } + + @Test + public void setNsName() throws Exception { + nsCreateReq.setNsName("nsname"); + } + + @Test + public void getDescription() throws Exception { + nsCreateReq.getDescription(); + } + + @Test + public void setDescription() throws Exception { + nsCreateReq.setDescription("desc"); + } + +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java b/src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java new file mode 100644 index 0000000..70e54a1 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All 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.so.adapters.vfc.model; + +import org.junit.Test; + +public class NsInstantiateReqTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + NsInstantiateReq nsInstantiateReq = new NsInstantiateReq(); + + @Test + public void getNsInstanceId() throws Exception { + nsInstantiateReq.getNsInstanceId(); + } + + @Test + public void setNsInstanceId() throws Exception { + nsInstantiateReq.setNsInstanceId("test"); + } + +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/NsLcmOpOccTest.java b/src/test/java/org/onap/so/adapters/vfc/model/NsLcmOpOccTest.java new file mode 100644 index 0000000..f5d485a --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/NsLcmOpOccTest.java @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import org.onap.so.adapters.vfc.constant.CommonConstant; +import java.time.LocalDateTime; +import java.util.Date; +import static org.junit.Assert.*; + +public class NsLcmOpOccTest { + NsLcmOpOcc nsLcmOpOcc = new NsLcmOpOcc(); + + @Test + public void getLcmOperationType() { + nsLcmOpOcc.getLcmOperationType(); + } + + @Test + public void setLcmOperationType() { + nsLcmOpOcc.setLcmOperationType(CommonConstant.lcmOperationType.INSTANTIATE); + } + + @Test + public void getCancelMode() { + nsLcmOpOcc.getCancelMode(); + } + + @Test + public void setCancelMode() { + nsLcmOpOcc.setCancelMode(CommonConstant.cancelMode.GRACEFUL); + } + + @Test + public void getOperationState() { + nsLcmOpOcc.getOperationState(); + } + + @Test + public void setOperationState() { + nsLcmOpOcc.setOperationState(CommonConstant.operationState.COMPLETED); + } + + @Test + public void getId() { + nsLcmOpOcc.getId(); + } + + @Test + public void setId() { + nsLcmOpOcc.setId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getStatusEnteredTime() { + nsLcmOpOcc.getStatusEnteredTime(); + } + + @Test + public void setStatusEnteredTime() { + nsLcmOpOcc.setStatusEnteredTime(LocalDateTime.now().toString()); + } + + @Test + public void getNsInstanceId() { + nsLcmOpOcc.getNsInstanceId(); + } + + @Test + public void setNsInstanceId() { + nsLcmOpOcc.setNsInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getStartTime() { + nsLcmOpOcc.getStartTime(); + } + + @Test + public void setStartTime() { + nsLcmOpOcc.setStartTime(LocalDateTime.now().toString()); + } + + @Test + public void getAutomaticInvocation() { + nsLcmOpOcc.getAutomaticInvocation(); + } + + @Test + public void setAutomaticInvocation() { + nsLcmOpOcc.setAutomaticInvocation(true); + } + + @Test + public void getOperationParams() { + nsLcmOpOcc.getOperationParams(); + } + + @Test + public void setOperationParams() { + nsLcmOpOcc.setOperationParams("Dummy operationParams"); + } + + @Test + public void getCancelPending() { + nsLcmOpOcc.getCancelPending(); + } + + @Test + public void setCancelPending() { + nsLcmOpOcc.setCancelPending(true); + } + + @Test + public void getError() { + nsLcmOpOcc.getError(); + } + + @Test + public void setError() { + nsLcmOpOcc.setError(new ProblemDetails()); + } + + @Test + public void getLinks() { + nsLcmOpOcc.getLinks(); + } + + @Test + public void setLinks() { + nsLcmOpOcc.setLinks(new Links()); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java b/src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java new file mode 100644 index 0000000..a8939f8 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All 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.so.adapters.vfc.model; + +import org.junit.Test; + +public class NsOperationKeyTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + NsOperationKey nsOperationKey = new NsOperationKey(); + + @Test + public void getGlobalSubscriberId() throws Exception { + nsOperationKey.getGlobalSubscriberId(); + } + + @Test + public void setGlobalSubscriberId() throws Exception { + nsOperationKey.setGlobalSubscriberId("subscriberid"); + } + + @Test + public void getServiceType() throws Exception { + nsOperationKey.getServiceType(); + } + + @Test + public void setServiceType() throws Exception { + nsOperationKey.setServiceType("servicetype"); + } + + @Test + public void getServiceId() throws Exception { + nsOperationKey.getServiceId(); + } + + @Test + public void setServiceId() throws Exception { + nsOperationKey.setServiceId("serviceid"); + } + + @Test + public void getOperationId() throws Exception { + nsOperationKey.getOperationId(); + } + + @Test + public void setOperationId() throws Exception { + nsOperationKey.setOperationId("test"); + } + + @Test + public void getNodeTemplateUUID() throws Exception { + nsOperationKey.getNodeTemplateUUID(); + } + + @Test + public void setNodeTemplateUUID() throws Exception { + nsOperationKey.setNodeTemplateUUID("nodeTemplateid"); + } + +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java b/src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java new file mode 100644 index 0000000..45c46ed --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All 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.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collections; +import java.util.HashMap; + +public class NsParametersTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + NsParameters nsParameters = new NsParameters(); + + @Test + public void getLocationConstraints() throws Exception { + nsParameters.getLocationConstraints(); + } + + @Test + public void setLocationConstraints() throws Exception { + nsParameters.setLocationConstraints(Collections.emptyList()); + } + + @Test + public void getAdditionalParamForNs() throws Exception { + nsParameters.getAdditionalParamForNs(); + } + + @Test + public void setAdditionalParamForNs() throws Exception { + nsParameters.setAdditionalParamForNs(new HashMap<>()); + } + +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java b/src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java new file mode 100644 index 0000000..b1040ef --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All 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.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Arrays; + +public class NsProgressStatusTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + NsProgressStatus nsProgressStatus = new NsProgressStatus(); + + @Test + public void getJobId() throws Exception { + nsProgressStatus.getJobId(); + } + + @Test + public void setJobId() throws Exception { + nsProgressStatus.setJobId("jobid"); + } + + @Test + public void getResponseDescriptor() throws Exception { + nsProgressStatus.getResponseDescriptor(); + } + + @Test + public void setResponseDescriptor() throws Exception { + nsProgressStatus.setResponseDescriptor(new ResponseDescriptor()); + } + + @Test + public void getResponseHistoryList() throws Exception { + nsProgressStatus.getResponseHistoryList(); + } + + @Test + public void setResponseHistoryList() throws Exception { + nsProgressStatus.setResponseHistoryList(Arrays.asList(new ResponseDescriptor())); + } + +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/ParamsForVnfTest.java b/src/test/java/org/onap/so/adapters/vfc/model/ParamsForVnfTest.java new file mode 100644 index 0000000..e0455b0 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/ParamsForVnfTest.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.HashMap; +import static org.junit.Assert.*; + +public class ParamsForVnfTest { + + ParamsForVnf paramsForVnf = new ParamsForVnf(); + + @Test + public void getVnfProfileId() { + paramsForVnf.getVnfProfileId(); + } + + @Test + public void setVnfProfileId() { + paramsForVnf.setVnfProfileId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getAdditionalParams() { + paramsForVnf.getAdditionalParams(); + } + + @Test + public void setAdditionalParams() { + paramsForVnf.setAdditionalParams(new HashMap<>()); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/PnfExtCpDataTest.java b/src/test/java/org/onap/so/adapters/vfc/model/PnfExtCpDataTest.java new file mode 100644 index 0000000..c586c7e --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/PnfExtCpDataTest.java @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class PnfExtCpDataTest { + PnfExtCpData pnfExtCpData = new PnfExtCpData(); + + @Test + public void getCpInstanceI16() { + pnfExtCpData.getCpInstanceI16(); + } + + @Test + public void setCpInstanceI16() { + pnfExtCpData.setCpInstanceI16("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getCpdId() { + pnfExtCpData.getCpdId(); + } + + @Test + public void setCpdId() { + pnfExtCpData.setCpdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getCpProtocolData() { + pnfExtCpData.getCpProtocolData(); + } + + @Test + public void setCpProtocolData() { + pnfExtCpData.setCpProtocolData(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(CpProtocolData cpProtocolData) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public CpProtocolData get(int index) { + return null; + } + + @Override + public CpProtocolData set(int index, CpProtocolData element) { + return null; + } + + @Override + public void add(int index, CpProtocolData element) { + + } + + @Override + public CpProtocolData remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/ProblemDetailsTest.java b/src/test/java/org/onap/so/adapters/vfc/model/ProblemDetailsTest.java new file mode 100644 index 0000000..ddea6cc --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/ProblemDetailsTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class ProblemDetailsTest { + ProblemDetails problemDetails = new ProblemDetails(); + + @Test + public void getType() { + problemDetails.getType(); + } + + @Test + public void setType() { + problemDetails.setType("Dummy Type"); + } + + @Test + public void getTitle() { + problemDetails.getTitle(); + } + + @Test + public void setTitle() { + problemDetails.setTitle("Dummy Title"); + } + + @Test + public void getStatus() { + problemDetails.getStatus(); + } + + @Test + public void setStatus() { + problemDetails.setStatus(200); + } + + @Test + public void getDetail() { + problemDetails.getDetail(); + } + + @Test + public void setDetail() { + problemDetails.setTitle("Dummy Title"); + } + + @Test + public void getInstance() { + problemDetails.getInstance(); + } + + @Test + public void setInstance() { + problemDetails.setInstance("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/ResourceChangesTest.java b/src/test/java/org/onap/so/adapters/vfc/model/ResourceChangesTest.java new file mode 100644 index 0000000..9c4a029 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/ResourceChangesTest.java @@ -0,0 +1,773 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class ResourceChangesTest { + ResourceChanges resourceChanges = new ResourceChanges(); + + @Test + public void getAffectedVnfs() { + resourceChanges.getAffectedVnfs(); + } + + @Test + public void setAffectedVnfs() { + resourceChanges.setAffectedVnfs(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(AffectedVnf affectedVnf) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public AffectedVnf get(int index) { + return null; + } + + @Override + public AffectedVnf set(int index, AffectedVnf element) { + return null; + } + + @Override + public void add(int index, AffectedVnf element) { + + } + + @Override + public AffectedVnf remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getAffectedPnfs() { + resourceChanges.getAffectedPnfs(); + } + + @Test + public void setAffectedPnfs() { + resourceChanges.setAffectedPnfs(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(AffectedPnf affectedPnf) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public AffectedPnf get(int index) { + return null; + } + + @Override + public AffectedPnf set(int index, AffectedPnf element) { + return null; + } + + @Override + public void add(int index, AffectedPnf element) { + + } + + @Override + public AffectedPnf remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getAffectedVls() { + resourceChanges.getAffectedVls(); + } + + @Test + public void setAffectedVls() { + resourceChanges.setAffectedVls(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(AffectedVirtualLink affectedVirtualLink) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public AffectedVirtualLink get(int index) { + return null; + } + + @Override + public AffectedVirtualLink set(int index, AffectedVirtualLink element) { + return null; + } + + @Override + public void add(int index, AffectedVirtualLink element) { + + } + + @Override + public AffectedVirtualLink remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getAffectedVnffgs() { + resourceChanges.getAffectedVnffgs(); + } + + @Test + public void setAffectedVnffgs() { + resourceChanges.setAffectedVnffgs(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(AffectedVnffg affectedVnffg) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public AffectedVnffg get(int index) { + return null; + } + + @Override + public AffectedVnffg set(int index, AffectedVnffg element) { + return null; + } + + @Override + public void add(int index, AffectedVnffg element) { + + } + + @Override + public AffectedVnffg remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getAffectedNss() { + resourceChanges.getAffectedNss(); + } + + @Test + public void setAffectedNss() { + resourceChanges.setAffectedNss(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(AffectedNs affectedNs) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public AffectedNs get(int index) { + return null; + } + + @Override + public AffectedNs set(int index, AffectedNs element) { + return null; + } + + @Override + public void add(int index, AffectedNs element) { + + } + + @Override + public AffectedNs remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getAffectedSaps() { + resourceChanges.getAffectedSaps(); + } + + @Test + public void setAffectedSaps() { + resourceChanges.setAffectedSaps(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(AffectedSap affectedSap) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public AffectedSap get(int index) { + return null; + } + + @Override + public AffectedSap set(int index, AffectedSap element) { + return null; + } + + @Override + public void add(int index, AffectedSap element) { + + } + + @Override + public AffectedSap remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/ResourceHandleTest.java b/src/test/java/org/onap/so/adapters/vfc/model/ResourceHandleTest.java new file mode 100644 index 0000000..6390c5a --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/ResourceHandleTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class ResourceHandleTest { + ResourceHandle resourceHandle = new ResourceHandle(); + + @Test + public void getVimId() { + resourceHandle.getVimId(); + } + + @Test + public void setVimId() { + resourceHandle.setVimId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getResourceProviderId() { + resourceHandle.getResourceProviderId(); + } + + @Test + public void setResourceProviderId() { + resourceHandle.setResourceProviderId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getResourceId() { + resourceHandle.getResourceId(); + } + + @Test + public void setResourceId() { + resourceHandle.setResourceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVimLevelResourceType() { + resourceHandle.getVimLevelResourceType(); + } + + @Test + public void setVimLevelResourceType() { + resourceHandle.setVimLevelResourceType("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java b/src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java new file mode 100644 index 0000000..3f2f735 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All 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.so.adapters.vfc.model; + +import org.junit.Test; + +public class ResponseDescriptorTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + ResponseDescriptor responseDescriptor = new ResponseDescriptor(); + + @Test + public void getStatus() throws Exception { + responseDescriptor.getStatus(); + } + + @Test + public void setStatus() throws Exception { + responseDescriptor.setStatus("test"); + } + + @Test + public void getProgress() throws Exception { + responseDescriptor.getProgress(); + } + + @Test + public void setProgress() throws Exception { + responseDescriptor.setProgress("10"); + } + + @Test + public void getStatusDescription() throws Exception { + responseDescriptor.getStatusDescription(); + } + + @Test + public void setStatusDescription() throws Exception { + responseDescriptor.setStatusDescription("test"); + } + + @Test + public void getErrorCode() throws Exception { + responseDescriptor.getErrorCode(); + } + + @Test + public void setErrorCode() throws Exception { + responseDescriptor.setErrorCode(-1); + } + + @Test + public void getResponseId() throws Exception { + responseDescriptor.getResponseId(); + } + + @Test + public void setResponseId() throws Exception { + responseDescriptor.setResponseId(1); + } + +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java b/src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java new file mode 100644 index 0000000..64f8da6 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All 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.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.HashMap; + +public class RestfulResponseTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + RestfulResponse restfulResponse = new RestfulResponse(); + + @Test + public void getStatus() throws Exception { + restfulResponse.getStatus(); + } + + @Test + public void setStatus() throws Exception { + restfulResponse.setStatus(1); + } + + @Test + public void getRespHeaderMap() throws Exception { + restfulResponse.getRespHeaderMap(); + } + + @Test + public void setRespHeaderMap() throws Exception { + restfulResponse.setRespHeaderMap(new HashMap<>()); + } + + @Test + public void getRespHeaderInt() throws Exception { + restfulResponse.getRespHeaderInt("1"); + } + + @Test + public void getRespHeaderLong() throws Exception { + restfulResponse.getRespHeaderLong("1"); + } + + @Test + public void getRespHeaderStr() throws Exception { + restfulResponse.getRespHeaderStr("test"); + } + + @Test + public void getResponseContent() throws Exception { + restfulResponse.getResponseContent(); + } + + @Test + public void setResponseContent() throws Exception { + restfulResponse.setResponseContent("responseString"); + } + +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/SapDataTest.java b/src/test/java/org/onap/so/adapters/vfc/model/SapDataTest.java new file mode 100644 index 0000000..2a45599 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/SapDataTest.java @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class SapDataTest { + + SapData sapData = new SapData(); + + @Test + public void getSapdId() { + sapData.getSapdId(); + } + + @Test + public void setSapdId() { + sapData.setSapdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getSapName() { + sapData.getSapName(); + } + + @Test + public void setSapName() { + sapData.setSapName("Dummy SapName"); + } + + @Test + public void getDescription() { + sapData.getDescription(); + } + + @Test + public void setDescription() { + sapData.setDescription("Dummy Description"); + } + + @Test + public void getSapProtocolData() { + sapData.getSapProtocolData(); + } + + @Test + public void setSapProtocolData() { + sapData.setSapProtocolData(new List() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(CpProtocolData cpProtocolData) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public CpProtocolData get(int index) { + return null; + } + + @Override + public CpProtocolData set(int index, CpProtocolData element) { + return null; + } + + @Override + public void add(int index, CpProtocolData element) { + + } + + @Override + public CpProtocolData remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return null; + } + }); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java b/src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java new file mode 100644 index 0000000..85d3a13 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java @@ -0,0 +1,39 @@ + +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All 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.so.adapters.vfc.model; + +import org.junit.Test; + +public class VimLocationTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + VimLocation vimLocation = new VimLocation(); + + @Test + public void getVimId() throws Exception { + vimLocation.getVimId(); + } + + @Test + public void setVimId() throws Exception { + vimLocation.setVimId("vimid"); + } + +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/VnfInstanceDataTest.java b/src/test/java/org/onap/so/adapters/vfc/model/VnfInstanceDataTest.java new file mode 100644 index 0000000..b9bdfe3 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/VnfInstanceDataTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class VnfInstanceDataTest { + VnfInstanceData vnfInstanceData = new VnfInstanceData(); + + @Test + public void getVnfInstanceId() { + vnfInstanceData.getVnfInstanceId(); + } + + @Test + public void setVnfInstanceId() { + vnfInstanceData.setVnfInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnfProfileId() { + vnfInstanceData.getVnfProfileId(); + } + + @Test + public void setVnfProfileId() { + vnfInstanceData.setVnfProfileId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/model/VnfLocationConstraintTest.java b/src/test/java/org/onap/so/adapters/vfc/model/VnfLocationConstraintTest.java new file mode 100644 index 0000000..b8f9b8e --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/model/VnfLocationConstraintTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class VnfLocationConstraintTest { + VnfLocationConstraint vnfLocationConstraint = new VnfLocationConstraint(); + + @Test + public void getVnfProfileId() { + vnfLocationConstraint.getVnfProfileId(); + } + + @Test + public void setVnfProfileId() { + vnfLocationConstraint.setVnfProfileId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getLocationConstraints() { + vnfLocationConstraint.getLocationConstraints(); + } + + @Test + public void setLocationConstraints() { + vnfLocationConstraint.setLocationConstraints(new LocationConstraint()); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/rest/EmbeddedMariaDbConfig.java b/src/test/java/org/onap/so/adapters/vfc/rest/EmbeddedMariaDbConfig.java new file mode 100644 index 0000000..feb40f7 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/rest/EmbeddedMariaDbConfig.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.vfc.rest; + +import ch.vorburger.exec.ManagedProcessException; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; +import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; + +@Configuration +@Profile({"test"}) +@EnableTransactionManagement +@EnableJpaRepositories(entityManagerFactoryRef = "requestEntityManagerFactory", + transactionManagerRef = "requestTransactionManager", basePackages = {"org.onap.so.db.request.data.repository"}) +public class EmbeddedMariaDbConfig { + + @Bean + MariaDB4jSpringService mariaDB4jSpringService() { + return new MariaDB4jSpringService(); + } + + @Primary + @Bean(name = "requestDataSource") + @ConfigurationProperties(prefix = "spring.datasource") + DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, + @Value("${mariaDB4j.databaseName}") String databaseName, + @Value("${spring.datasource.username}") String datasourceUsername, + @Value("${spring.datasource.password}") String datasourcePassword, + @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { + // Create our database with default root user and no password + mariaDB4jSpringService.getDB().createDB(databaseName); + + DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); + + return DataSourceBuilder.create().username(datasourceUsername).password(datasourcePassword) + .url(config.getURL(databaseName)).driverClassName(datasourceDriver).build(); + } + + @Primary + @Bean(name = "requestEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder, + @Qualifier("requestDataSource") DataSource dataSource) { + return builder.dataSource(dataSource).packages("org.onap.so.db.request.beans").persistenceUnit("requestDB") + .build(); + } + + @Primary + @Bean(name = "requestTransactionManager") + public PlatformTransactionManager transactionManager( + @Qualifier("requestEntityManagerFactory") EntityManagerFactory entityManagerFactory) { + return new JpaTransactionManager(entityManagerFactory); + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java b/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java new file mode 100644 index 0000000..fe2bd0b --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.vfc.rest; + +import static org.junit.Assert.*; +import javax.ws.rs.core.Response; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.adapters.vfc.MSOVfcApplication; +import org.springframework.boot.configurationprocessor.json.JSONException; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = MSOVfcApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class HealthCheckHandlerTest { + + @LocalServerPort + private int port; + + TestRestTemplate restTemplate = new TestRestTemplate(); + + HttpHeaders headers = new HttpHeaders(); + + + @Test + public void testHealthcheck() throws JSONException { + + HttpEntity entity = new HttpEntity(null, headers); + + ResponseEntity response = + restTemplate.exchange(createURLWithPort("manage/health"), HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + } + + private String createURLWithPort(String uri) { + return "http://localhost:" + port + uri; + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerSol005Test.java b/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerSol005Test.java new file mode 100644 index 0000000..799283d --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerSol005Test.java @@ -0,0 +1,221 @@ +/* + * Copyright (C) 2019 Verizon. All 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. + */ + +package org.onap.so.adapters.vfc.rest; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.so.adapters.vfc.exceptions.ApplicationException; +import org.onap.so.adapters.vfc.model.NSResourceInputParameter; +import org.onap.so.adapters.vfc.model.RestfulResponse; +import org.onap.so.adapters.vfc.util.JsonUtil; +import org.onap.so.adapters.vfc.util.RestfulUtil; +import org.onap.so.db.request.beans.InstanceNfvoMapping; +import org.onap.so.db.request.beans.OperationStatus; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.db.request.data.repository.InstanceNfvoMappingRepository; +import org.onap.so.db.request.data.repository.OperationStatusRepository; +import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.springframework.test.context.junit4.SpringRunner; +import java.io.File; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import static org.mockito.Mockito.when; + +@RunWith(SpringRunner.class) +public class VfcManagerSol005Test { + @InjectMocks + VfcManagerSol005 vfcManagerSol005; + + @Mock + InstanceNfvoMappingRepository instanceNfvoMappingRepository; + + @Mock + ResourceOperationStatusRepository resourceOperationStatusRepository; + + @Mock + OperationStatusRepository operationStatusRepository; + + @Mock + RestfulUtil restfulUtil; + + OperationStatus operationStatus = new OperationStatus(); + + InstanceNfvoMapping instanceNfvoMapping = new InstanceNfvoMapping(); + RestfulResponse restfulResponse = new RestfulResponse(); + RestfulResponse vfcrestfulResponse = new RestfulResponse(); + NSResourceInputParameter nsResourceInputParameter = new NSResourceInputParameter(); + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus(); + + @Test + public void createNs() throws ApplicationException, Exception { + restfulResponse.setStatus(200); + ClassLoader classLoader = ClassLoader.getSystemClassLoader(); + + File file = new File(classLoader.getResource("json/createNsReq.json").getFile()); + String content = new String(Files.readAllBytes(file.toPath())).replace("\n", ""); + nsResourceInputParameter = JsonUtil.unMarshal(content, NSResourceInputParameter.class); + file = new File(classLoader.getResource("json/aainfvoResponse.json").getFile()); + content = new String(Files.readAllBytes(file.toPath())).replace("\n", ""); + restfulResponse.setResponseContent(content); + // restfulResponse.setResponseContent("{\"nfvoId\":\"6ee79fe2-9579-475a-9bb9-20cf4358a19e\",\"name\":\"external_nfvo\",\"api-root\":\"xyz\",\"vendor\":\"vz\",\"version\":\"v1.0\",\"url\":\"http://sample.com/\",\"userName\":\"admin\",\"password\":\"sacjnasnc\"}"); + file = new File(classLoader.getResource("json/createNsSol005Response.json").getFile()); + content = new String(Files.readAllBytes(file.toPath())).replace("\n", ""); + vfcrestfulResponse.setStatus(202); + vfcrestfulResponse.setResponseContent(content); + // vfcrestfulResponse.setResponseContent("{\"_links\": {\"heal\": {\"href\": \"\"}, \"instantiate\": {\"href\": + // \"\"}, \"nestedNsInstances\": {\"href\": \"\"}, \"scale\": {\"href\": \"\"}, \"self\": {\"href\": \"\"}, + // \"terminate\": {\"href\": \"\"}, \"update\": {\"href\": \"\"}}, \"additionalAffinityOrAntiAffiniityRule\": + // [{\"Scope\": \"\", \"affinityOrAntiAffiinty\": \"\", \"vnfInstanceId\": [], \"vnfProfileId\": [], \"vnfdId\": + // []}], \"flavourId\": \"\", \"id\": \"c9f0a95e-dea0-4698-96e5-5a79bc5a233d\", \"nestedNsInstanceId\": [], + // \"nsInstanceDescription\": \"\", \"nsInstanceName\": \"\", \"nsScaleStatus\": [{\"nsScaleLevelId\": \"\", + // \"nsScalingAspectId\": \"\"}], \"nsState\": \"\", \"nsdId\": \"\", \"nsdInfoId\": \"\", \"pnfInfo\": + // [{\"cpInfo\": [{\"cpInstanceId\": \"\", \"cpProtocolData\": {\"ipOverEthernet\": {\"ipAddresses\": + // {\"addressRange\": {\"maxAddress\": \"\", \"minAddress\": \"\"}, \"fixedAddresses\": \"\", + // \"numDynamicAddresses\": 1, \"subnetId\": \"\", \"type\": \"\"}, \"macAddress\": {}}, \"layerProtocol\": + // \"IP_OVER_ETHERNET\"}, \"cpdId\": \"\"}], \"pnfId\": \"\", \"pnfName\": \"\", \"pnfProfileId\": \"\", + // \"pnfdId\": \"\", \"pnfdInfoId\": \"\"}], \"sapInfo\": [{\"description\": \"\", \"id\": \"\", \"sapName\": + // \"\", \"sapProtocolInfo\": {\"ipOverEthernet\": {\"ipAddresses\": {\"addressRange\": {\"maxAddress\": \"\", + // \"minAddress\": \"\"}, \"fixedAddresses\": \"\", \"numDynamicAddresses\": 1, \"subnetId\": \"\", \"type\": + // \"\"}, \"macAddress\": \"\"}, \"layerProtocol\": \"IP_OVER_ETHERNET\"}, \"sapdId\": \"\"}], + // \"virtualLinkInfo\": [{\"id\": \"\", \"linkPort\": [{\"id\": \"\", \"resourceHandle\": {\"resourceId\": \"\", + // \"resourceProviderId\": \"\", \"vimId\": \"\", \"vimLevelResourceType\": \"\"}}], \"nsVirtualLinkDescId\": + // \"\", \"resourceHandle\": [{\"resourceId\": \"\", \"resourceProviderId\": \"\", \"vimId\": \"\", + // \"vimLevelResourceType\": \"\"}]}], \"vnfInstance\": [{\"vnfInstanceId\": \"\", \"vnfProfileId\": \"\"}], + // \"vnffgInfo\": [{\"id\": \"\", \"nfpInfo\": [{\"description\": \"\", \"id\": \"\", \"nfpName\": \"\", + // \"nfpRule\": {\"destinationIpAddressPrefix\": \"\", \"destinationPortRange\": \"\", \"dscp\": \"\", + // \"etherDestinationAddress\": \"\", \"etherSourceAddress\": \"\", \"etherType\": \"\", \"extendedCriteria\": + // [{\"length\": 1, \"startingPoint\": 1, \"value\": \"\"}], \"protocol\": \"\", \"sourceIpAddressPrefix\": + // \"\", \"sourcePortRange\": \"\", \"vlanTag\": []}, \"nfpState\": \"\", \"nfpdId\": \"\", \"nscpHandle\": + // [{\"nsInstanceId\": \"\", \"nsSapInstanceId\": \"\", \"pnfExtCpInstanceId\": \"\", \"pnfInfoId\": \"\", + // \"vnfExtCpInstanceId\": \"\", \"vnfInstanceId\": \"\"}], \"totalCp\": 1}], \"nsCpHandle\": + // [{\"nsInstanceId\": \"\", \"nsSapInstanceId\": \"\", \"pnfExtCpInstanceId\": \"\", \"pnfInfoId\": \"\", + // \"vnfExtCpInstanceId\": \"\", \"vnfInstanceId\": \"\"}], \"nsVirtualLinkInfoId\": [], \"pnfInfoId\": [], + // \"vnfInstanceId\": [], \"vnffgdId\": \"\"}]}"); + + resourceOperationStatus.setStatus("processing"); + resourceOperationStatus.setOperationId(nsResourceInputParameter.getNsOperationKey().getOperationId()); + resourceOperationStatus.setServiceId(nsResourceInputParameter.getNsOperationKey().getServiceId()); + resourceOperationStatus + .setResourceTemplateUUID(nsResourceInputParameter.getNsOperationKey().getNodeTemplateUUID()); + when(instanceNfvoMappingRepository.save(instanceNfvoMapping)).thenReturn(instanceNfvoMapping); + when(restfulUtil.getNfvoFromAAI("b1bb0ce7-2222-4fa7-95ed-4840d70a1101")).thenReturn(restfulResponse); + when(restfulUtil.send(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyMap())) + .thenReturn(vfcrestfulResponse); + when(resourceOperationStatusRepository.save(resourceOperationStatus)).thenReturn(resourceOperationStatus); + vfcManagerSol005.createNs(nsResourceInputParameter); + + } + + @Test + public void terminateNs() throws Exception { + instanceNfvoMapping.setInstanceId("b1bb0ce7-2222-4fa7-95ed-4840d70a1101"); + instanceNfvoMapping.setPassword("sacjnasnc"); + instanceNfvoMapping.setUsername("admin"); + instanceNfvoMapping.setNfvoName("external_nfvo"); + instanceNfvoMapping.setEndpoint("http://sample.com/"); + instanceNfvoMapping.setApiRoot("xyz"); + String nsInstanceId = "c9f0a95e-dea0-4698-96e5-5a79bc5a233d"; + ClassLoader classLoader = ClassLoader.getSystemClassLoader(); + File file = new File(classLoader.getResource("json/createNsReq.json").getFile()); + String content = new String(Files.readAllBytes(file.toPath())).replace("\n", ""); + nsResourceInputParameter = JsonUtil.unMarshal(content, NSResourceInputParameter.class); + Map header = new HashMap<>(); + header.put("Location", "http://192.168.10.57:5000/ns_lcm_op_ops/12204a12-7da2-4ddf-8c2f-992a1a1acebf"); + vfcrestfulResponse.setStatus(202); + vfcrestfulResponse.setResponseContent(null); + vfcrestfulResponse.setRespHeaderMap(header); + when(instanceNfvoMappingRepository.findOneByInstanceId(nsInstanceId)).thenReturn(instanceNfvoMapping); + when(restfulUtil.send(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())) + .thenReturn(vfcrestfulResponse); + vfcManagerSol005.terminateNs(nsResourceInputParameter.getNsOperationKey(), nsInstanceId); + } + + @Test + public void getNsProgress() throws Exception { + String jobId = "12204a12-7da2-4ddf-8c2f-992a1a1acebf"; + instanceNfvoMapping.setInstanceId("b1bb0ce7-2222-4fa7-95ed-4840d70a1101"); + instanceNfvoMapping.setPassword("sacjnasnc"); + instanceNfvoMapping.setUsername("admin"); + instanceNfvoMapping.setNfvoName("external_nfvo"); + instanceNfvoMapping.setEndpoint("http://sample.com/"); + instanceNfvoMapping.setApiRoot("xyz"); + instanceNfvoMapping.setJobId(jobId); + ClassLoader classLoader = ClassLoader.getSystemClassLoader(); + File file = new File(classLoader.getResource("json/createNsReq.json").getFile()); + String content = new String(Files.readAllBytes(file.toPath())).replace("\n", ""); + nsResourceInputParameter = JsonUtil.unMarshal(content, NSResourceInputParameter.class); + operationStatus.setProgress("40"); + operationStatus.setServiceId(nsResourceInputParameter.getNsOperationKey().getServiceId()); + operationStatus.setOperationId(nsResourceInputParameter.getNsOperationKey().getOperationId()); + ResourceOperationStatus resourceOperationStatus = + new ResourceOperationStatus(nsResourceInputParameter.getNsOperationKey().getServiceId(), + nsResourceInputParameter.getNsOperationKey().getOperationId(), + nsResourceInputParameter.getNsOperationKey().getNodeTemplateUUID()); + file = new File(classLoader.getResource("json/lcmOperRsp.json").getFile()); + content = new String(Files.readAllBytes(file.toPath())).replace("\n", ""); + vfcrestfulResponse.setStatus(202); + vfcrestfulResponse.setResponseContent(content); + List resourceOperationStatuses = new ArrayList<>(); + resourceOperationStatuses.add(resourceOperationStatus); + when(instanceNfvoMappingRepository.findOneByJobId(jobId)).thenReturn(instanceNfvoMapping); + when(restfulUtil.send(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())) + .thenReturn(vfcrestfulResponse); + when(operationStatusRepository.findOneByServiceIdAndOperationId( + nsResourceInputParameter.getNsOperationKey().getServiceId(), + nsResourceInputParameter.getNsOperationKey().getOperationId())).thenReturn(operationStatus); + when(resourceOperationStatusRepository.findByServiceIdAndOperationId( + nsResourceInputParameter.getNsOperationKey().getServiceId(), + nsResourceInputParameter.getNsOperationKey().getOperationId())).thenReturn(resourceOperationStatuses); + when(operationStatusRepository.save(operationStatus)).thenReturn(operationStatus); + vfcManagerSol005.getNsProgress(nsResourceInputParameter.getNsOperationKey(), jobId); + + } + + @Test + public void instantiateNs() throws Exception { + String nsInstanceId = "c9f0a95e-dea0-4698-96e5-5a79bc5a233d"; + ClassLoader classLoader = ClassLoader.getSystemClassLoader(); + File file = new File(classLoader.getResource("json/createNsReq.json").getFile()); + String content = new String(Files.readAllBytes(file.toPath())).replace("\n", ""); + nsResourceInputParameter = JsonUtil.unMarshal(content, NSResourceInputParameter.class); + instanceNfvoMapping.setInstanceId("b1bb0ce7-2222-4fa7-95ed-4840d70a1101"); + instanceNfvoMapping.setPassword("sacjnasnc"); + instanceNfvoMapping.setUsername("admin"); + instanceNfvoMapping.setNfvoName("external_nfvo"); + instanceNfvoMapping.setEndpoint("http://sample.com/"); + instanceNfvoMapping.setApiRoot("xyz"); + resourceOperationStatus.setStatus("processing"); + resourceOperationStatus.setOperationId(nsResourceInputParameter.getNsOperationKey().getOperationId()); + resourceOperationStatus.setServiceId(nsResourceInputParameter.getNsOperationKey().getServiceId()); + resourceOperationStatus + .setResourceTemplateUUID(nsResourceInputParameter.getNsOperationKey().getNodeTemplateUUID()); + Map header = new HashMap<>(); + header.put("Location", "http://192.168.10.57:5000/ns_lcm_op_ops/12204a12-7da2-4ddf-8c2f-992a1a1acebf"); + vfcrestfulResponse.setStatus(202); + vfcrestfulResponse.setResponseContent(null); + vfcrestfulResponse.setRespHeaderMap(header); + when(instanceNfvoMappingRepository.findOneByInstanceId(nsInstanceId)).thenReturn(instanceNfvoMapping); + when(restfulUtil.send(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())) + .thenReturn(vfcrestfulResponse); + when(resourceOperationStatusRepository.save(resourceOperationStatus)).thenReturn(resourceOperationStatus); + when(instanceNfvoMappingRepository.save(instanceNfvoMapping)).thenReturn(instanceNfvoMapping); + vfcManagerSol005.instantiateNs(nsInstanceId, nsResourceInputParameter); + + } +} diff --git a/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java b/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java new file mode 100644 index 0000000..08fe618 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerTest.java @@ -0,0 +1,156 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2019 Samsung. All 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.so.adapters.vfc.rest; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.adapters.vfc.constant.CommonConstant; +import org.onap.so.adapters.vfc.model.NSResourceInputParameter; +import org.onap.so.adapters.vfc.model.NsOperationKey; +import org.onap.so.adapters.vfc.model.NsParameters; +import org.onap.so.adapters.vfc.model.NsScaleParameters; +import org.onap.so.adapters.vfc.model.RestfulResponse; +import org.onap.so.adapters.vfc.util.RestfulUtil; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.springframework.http.HttpStatus; +import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class VfcManagerTest { + + @Mock + private ResourceOperationStatusRepository resourceOperationStatusRepository; + + @Mock + private RestfulUtil restfulUtil; + + @InjectMocks + @Spy + private VfcManager vfcManager; + + @Test + public void createNs() throws Exception { + + NSResourceInputParameter segInput = new NSResourceInputParameter(); + segInput.setNsOperationKey(new NsOperationKey()); + + RestfulResponse restfulResponse = new RestfulResponse(); + restfulResponse.setStatus(HttpStatus.OK.value()); + restfulResponse.setResponseContent("{\"" + CommonConstant.NS_INSTANCE_ID + "\": \"someNsInstanceId\"}"); + when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse); + + RestfulResponse response = vfcManager.createNs(segInput); + assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus()); + } + + @Test + public void deleteNs() throws Exception { + + RestfulResponse restfulResponse = new RestfulResponse(); + restfulResponse.setStatus(HttpStatus.OK.value()); + restfulResponse.setResponseContent("{\"" + CommonConstant.NS_INSTANCE_ID + "\": \"someNsInstanceId\"}"); + when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse); + + NsOperationKey nsOperationKey = new NsOperationKey(); + + RestfulResponse response = vfcManager.deleteNs(nsOperationKey, "someNsInstanceId"); + assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus()); + } + + @Test + public void instantiateNs() throws Exception { + + RestfulResponse restfulResponse = new RestfulResponse(); + restfulResponse.setStatus(HttpStatus.OK.value()); + restfulResponse.setResponseContent("{\"" + CommonConstant.JOB_ID + "\": \"someJobId\"}"); + when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse); + + NsParameters nsParameters = new NsParameters(); + NSResourceInputParameter segInput = new NSResourceInputParameter(); + segInput.setNsParameters(nsParameters); + segInput.setNsOperationKey(new NsOperationKey()); + + RestfulResponse response = vfcManager.instantiateNs("someNsInstanceId", segInput); + assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus()); + } + + @Test + public void terminateNs() throws Exception { + + NsOperationKey nsOperationKey = new NsOperationKey(); + + RestfulResponse restfulResponse = new RestfulResponse(); + restfulResponse.setStatus(HttpStatus.OK.value()); + restfulResponse.setResponseContent("{\"" + CommonConstant.JOB_ID + "\": \"someJobId\"}"); + when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse); + + RestfulResponse response = vfcManager.terminateNs(nsOperationKey, "someNsInstanceId"); + assertEquals(HttpStatus.OK.value(), response.getStatus()); + } + + @Test + public void getNsProgress() throws Exception { + + NsOperationKey nsOperationKey = new NsOperationKey(); + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus(); + + RestfulResponse restfulResponse = new RestfulResponse(); + restfulResponse.setStatus(HttpStatus.OK.value()); + restfulResponse.setResponseContent( + "{\"" + CommonConstant.JOB_ID + "\": \"someJobId\", " + "\"responseDescriptor\" : {}}"); + when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse); + + when(resourceOperationStatusRepository.findOne(any())) + .thenReturn(java.util.Optional.ofNullable(resourceOperationStatus)); + + RestfulResponse response = vfcManager.getNsProgress(nsOperationKey, "someJobId"); + assertEquals(HttpStatus.OK.value(), response.getStatus()); + } + + @Test + public void scaleNs() throws Exception { + + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus(); + NSResourceInputParameter segInput = new NSResourceInputParameter(); + NsScaleParameters nsScaleParameters = new NsScaleParameters(); + segInput.setNsScaleParameters(nsScaleParameters); + + RestfulResponse restfulResponse = new RestfulResponse(); + restfulResponse.setStatus(HttpStatus.OK.value()); + segInput.setNsOperationKey(new NsOperationKey()); + restfulResponse.setResponseContent("{\"" + CommonConstant.JOB_ID + "\": \"someJobId\"}"); + when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse); + + when(resourceOperationStatusRepository.findOne(any())) + .thenReturn(java.util.Optional.ofNullable(resourceOperationStatus)); + + RestfulResponse response = vfcManager.scaleNs("someNsInstanceId", segInput); + assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus()); + } + +} diff --git a/src/test/java/org/onap/so/adapters/vfc/util/RestfulUtilTest.java b/src/test/java/org/onap/so/adapters/vfc/util/RestfulUtilTest.java new file mode 100644 index 0000000..4b6baa5 --- /dev/null +++ b/src/test/java/org/onap/so/adapters/vfc/util/RestfulUtilTest.java @@ -0,0 +1,164 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2019 Samsung. All 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.so.adapters.vfc.util; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.Header; +import org.apache.http.message.BasicHeader; +import org.apache.http.StatusLine; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.adapters.vfc.model.RestfulResponse; +import org.springframework.http.HttpStatus; +import javax.ws.rs.HttpMethod; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class RestfulUtilTest { + + @InjectMocks + @Spy + private RestfulUtil restfulUtil; + + @Mock + private HttpClient client; + + private HttpEntity httpEntity; + private HttpResponse httpResponse; + private StatusLine statusLine; + private Header httpResponseHeader; + + @Before + public void setUp() { + httpEntity = mock(HttpEntity.class); + httpResponse = mock(HttpResponse.class); + statusLine = mock(StatusLine.class); + httpResponseHeader = mock(Header.class); + } + + private void sendInit() throws IOException { + + Header[] headerList = new BasicHeader[2]; + headerList[0] = new BasicHeader("Content-Type", "application/json"); + headerList[1] = new BasicHeader("cache-control", "no-cache"); + doReturn("https://testHost/").when(restfulUtil).getMsbHost(); + + when(statusLine.getStatusCode()).thenReturn(HttpStatus.OK.value()); + when(httpResponse.getStatusLine()).thenReturn(statusLine); + when(httpResponse.getEntity()).thenReturn(httpEntity); + when(httpResponse.getAllHeaders()).thenReturn(headerList); + } + + @Test + public void sendGet() throws Exception { + + sendInit(); + + ByteArrayInputStream responseStream = new ByteArrayInputStream(new String("GET").getBytes()); + when(client.execute(any(HttpGet.class))).thenReturn(httpResponse); + when(httpEntity.getContent()).thenReturn(responseStream); + + RestfulResponse restfulResponse = restfulUtil.send("test", HttpMethod.GET, "some request content"); + + assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus()); + assertEquals("GET", restfulResponse.getResponseContent()); + + } + + @Test + public void sendPost() throws Exception { + + sendInit(); + + + ByteArrayInputStream responseStream = new ByteArrayInputStream(new String("POST").getBytes()); + when(client.execute(any(HttpPost.class))).thenReturn(httpResponse); + when(httpEntity.getContent()).thenReturn(responseStream); + + RestfulResponse restfulResponse = restfulUtil.send("test", HttpMethod.POST, "some request content"); + + assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus()); + assertEquals("POST", restfulResponse.getResponseContent()); + + } + + @Test + public void sendPut() throws Exception { + + sendInit(); + + ByteArrayInputStream responseStream = new ByteArrayInputStream(new String("PUT").getBytes()); + when(client.execute(any(HttpPut.class))).thenReturn(httpResponse); + when(httpEntity.getContent()).thenReturn(responseStream); + + RestfulResponse restfulResponse = restfulUtil.send("test", HttpMethod.PUT, "some request content"); + + assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus()); + assertEquals("PUT", restfulResponse.getResponseContent()); + + } + + @Test + public void sendDelete() throws Exception { + + sendInit(); + + ByteArrayInputStream responseStream = new ByteArrayInputStream(new String("DELETE").getBytes()); + when(client.execute(any(HttpDelete.class))).thenReturn(httpResponse); + when(httpEntity.getContent()).thenReturn(responseStream); + + RestfulResponse restfulResponse = restfulUtil.send("test", HttpMethod.DELETE, "some request content"); + + assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus()); + assertEquals("DELETE", restfulResponse.getResponseContent()); + + } + + @Test + public void sendOptions() throws Exception { + + doReturn("https://testHost/").when(restfulUtil).getMsbHost(); + + RestfulResponse restfulResponse = restfulUtil.send("test", HttpMethod.OPTIONS, "some request content"); + + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR.value(), restfulResponse.getStatus()); + assertEquals("Error processing request to VFC", restfulResponse.getResponseContent()); + + } + +} diff --git a/src/test/resources/application-test.yaml b/src/test/resources/application-test.yaml new file mode 100644 index 0000000..b43d382 --- /dev/null +++ b/src/test/resources/application-test.yaml @@ -0,0 +1,64 @@ + +server: + port: 8080 + tomcat: + max-threads: 50 +ssl-enable: false +mso: + adapters: + requestDb: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + endpoint: http://localhost:8081 + logPath: logs + site-name: localSite + infra-requests: + archived: + period: 1 +spring: + datasource: + jdbc-url: jdbc:mariadb://localhost:3307/requestdb + username: root + password: password + driver-class-name: org.mariadb.jdbc.Driver + initialize: true + initialization-mode: never + jpa: + generate-ddl: false + show-sql: false + hibernate: + ddl-auto: validate + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true + database-platform: org.hibernate.dialect.MySQL5InnoDBDialect + security: + usercredentials: + - + username: test + password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' + role: BPEL-Client +mariaDB4j: + dataDir: + port: 3307 + databaseName: requestdb + +#Actuator +management: + endpoints: + web: + base-path: /manage + server: + servlet: + context-path: /manage + metrics: + se-global-registry: false + export: + prometheus: + enabled: true # Whether exporting of metrics to Prometheus is enabled. + step: 1m # Step size (i.e. reporting frequency) to use. + + +flyway: + baseline-on-migrate: false + url: jdbc:mariadb://localhost:3307/requestdb + user: root + password: password diff --git a/src/test/resources/json/LICENSE.txt b/src/test/resources/json/LICENSE.txt new file mode 100644 index 0000000..bc40e66 --- /dev/null +++ b/src/test/resources/json/LICENSE.txt @@ -0,0 +1,19 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All 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========================================================= + */ \ No newline at end of file diff --git a/src/test/resources/json/aainfvoResponse.json b/src/test/resources/json/aainfvoResponse.json new file mode 100644 index 0000000..35047a9 --- /dev/null +++ b/src/test/resources/json/aainfvoResponse.json @@ -0,0 +1,10 @@ +{ + "nfvoId":"6ee79fe2-9579-475a-9bb9-20cf4358a19e", + "name":"external_nfvo", + "api-root":"xyz", + "vendor":"vz", + "version":"v1.0", + "url":"http://sample.com/", + "userName":"admin", + "password":"sacjnasnc" +} \ No newline at end of file diff --git a/src/test/resources/json/createNsReq.json b/src/test/resources/json/createNsReq.json new file mode 100644 index 0000000..aec8ae8 --- /dev/null +++ b/src/test/resources/json/createNsReq.json @@ -0,0 +1,56 @@ +{ + "nsServiceName":"vcpe_e2e_vnf_test2", + "nsServiceDescription":"null", + "nsServiceModelUUID":"c9f0a95e-dea0-4698-96e5-5a79bc5a233d", + "nsOperationKey":{ + "globalSubscriberId":"Demonstration", + "serviceType":"vCPE", + "serviceId":"996fadbb-e806-4a19-b0e5-3454ad6ac29e", + "operationId":"1f1dd6b2-b027-4008-a9df-3b6c8274fb24", + "nodeTemplateUUID":"4d3a835c-29c8-4a63-83a4-50de5f7ffe16" + }, + "nsParameters":{ + "locationConstraints":[ + { + "locationConstraints":{ + "vimId":"CloudOwner_regionOne" + }, + "vnfProfileId":"b1bb0ce7-2222-4fa7-95ed-4840d70a1101" + }, + { + "locationConstraints":{ + "vimId":"CloudOwner_regionOne" + }, + "vnfProfileId":"0408f076-e6c0-4c82-9940-272fddbb82de" + }, + { + "locationConstraints":{ + "vimId":"CloudOwner_regionOne" + }, + "vnfProfileId":"b1bb0ce7-2222-4fa7-95ed-4840d70a1100" + }, + { + "locationConstraints":{ + "vimId":"CloudOwner_regionOne" + }, + "vnfProfileId":"b1bb0ce7-2222-4fa7-95ed-4840d70a1102" + }, + { + "locationConstraints":{ + "vimId":"CloudOwner_regionOne" + }, + "vnfProfileId":"3fca3543-07f5-492f-812c-ed462e4f94f4" + } + ], + "additionalParamForNs":{ + "orchestrator":"", + "nfvo":"b1bb0ce7-2222-4fa7-95ed-4840d70a1101", + "nf_naming":"true", + "multi_stage_design":"false", + "availability_zone_max_count":"1", + "xyz":"123", + "nsd0_providing_service_invariant_uuid":"12204a12-7da2-4ddf-8c2f-992a1a1acebf", + "nsd0_providing_service_uuid":"5791dbeb-19d4-43e8-bf44-5b327ccf6bca" + } + } +} diff --git a/src/test/resources/json/createNsRsp.json b/src/test/resources/json/createNsRsp.json new file mode 100644 index 0000000..ccd1d66 --- /dev/null +++ b/src/test/resources/json/createNsRsp.json @@ -0,0 +1,3 @@ +{ + "nsInstanceId": "9b9f02c0-298b-458a-bc9c-be3692e4f354" +} \ No newline at end of file diff --git a/src/test/resources/json/createNsSol005Response.json b/src/test/resources/json/createNsSol005Response.json new file mode 100644 index 0000000..938969a --- /dev/null +++ b/src/test/resources/json/createNsSol005Response.json @@ -0,0 +1,210 @@ +{ + "_links":{ + "heal":{ + "href":"" + }, + "instantiate":{ + "href":"" + }, + "nestedNsInstances":{ + "href":"" + }, + "scale":{ + "href":"" + }, + "self":{ + "href":"" + }, + "terminate":{ + "href":"" + }, + "update":{ + "href":"" + } + }, + "additionalAffinityOrAntiAffiniityRule":[ + { + "Scope":"", + "affinityOrAntiAffiinty":"", + "vnfInstanceId":[ + + ], + "vnfProfileId":[ + + ], + "vnfdId":[ + + ] + } + ], + "flavourId":"", + "id":"c9f0a95e-dea0-4698-96e5-5a79bc5a233d", + "nestedNsInstanceId":[ + + ], + "nsInstanceDescription":"", + "nsInstanceName":"", + "nsScaleStatus":[ + { + "nsScaleLevelId":"", + "nsScalingAspectId":"" + } + ], + "nsState":"", + "nsdId":"", + "nsdInfoId":"", + "pnfInfo":[ + { + "cpInfo":[ + { + "cpInstanceId":"", + "cpProtocolData":{ + "ipOverEthernet":{ + "ipAddresses":{ + "addressRange":{ + "maxAddress":"", + "minAddress":"" + }, + "fixedAddresses":"", + "numDynamicAddresses":1, + "subnetId":"", + "type":"" + }, + "macAddress":{ + + } + }, + "layerProtocol":"IP_OVER_ETHERNET" + }, + "cpdId":"" + } + ], + "pnfId":"", + "pnfName":"", + "pnfProfileId":"", + "pnfdId":"", + "pnfdInfoId":"" + } + ], + "sapInfo":[ + { + "description":"", + "id":"", + "sapName":"", + "sapProtocolInfo":{ + "ipOverEthernet":{ + "ipAddresses":{ + "addressRange":{ + "maxAddress":"", + "minAddress":"" + }, + "fixedAddresses":"", + "numDynamicAddresses":1, + "subnetId":"", + "type":"" + }, + "macAddress":"" + }, + "layerProtocol":"IP_OVER_ETHERNET" + }, + "sapdId":"" + } + ], + "virtualLinkInfo":[ + { + "id":"", + "linkPort":[ + { + "id":"", + "resourceHandle":{ + "resourceId":"", + "resourceProviderId":"", + "vimId":"", + "vimLevelResourceType":"" + } + } + ], + "nsVirtualLinkDescId":"", + "resourceHandle":[ + { + "resourceId":"", + "resourceProviderId":"", + "vimId":"", + "vimLevelResourceType":"" + } + ] + } + ], + "vnfInstance":[ + { + "vnfInstanceId":"", + "vnfProfileId":"" + } + ], + "vnffgInfo":[ + { + "id":"", + "nfpInfo":[ + { + "description":"", + "id":"", + "nfpName":"", + "nfpRule":{ + "destinationIpAddressPrefix":"", + "destinationPortRange":"", + "dscp":"", + "etherDestinationAddress":"", + "etherSourceAddress":"", + "etherType":"", + "extendedCriteria":[ + { + "length":1, + "startingPoint":1, + "value":"" + } + ], + "protocol":"", + "sourceIpAddressPrefix":"", + "sourcePortRange":"", + "vlanTag":[ + + ] + }, + "nfpState":"", + "nfpdId":"", + "nscpHandle":[ + { + "nsInstanceId":"", + "nsSapInstanceId":"", + "pnfExtCpInstanceId":"", + "pnfInfoId":"", + "vnfExtCpInstanceId":"", + "vnfInstanceId":"" + } + ], + "totalCp":1 + } + ], + "nsCpHandle":[ + { + "nsInstanceId":"", + "nsSapInstanceId":"", + "pnfExtCpInstanceId":"", + "pnfInfoId":"", + "vnfExtCpInstanceId":"", + "vnfInstanceId":"" + } + ], + "nsVirtualLinkInfoId":[ + + ], + "pnfInfoId":[ + + ], + "vnfInstanceId":[ + + ], + "vnffgdId":"" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/json/deleteNsReq.json b/src/test/resources/json/deleteNsReq.json new file mode 100644 index 0000000..ac095e6 --- /dev/null +++ b/src/test/resources/json/deleteNsReq.json @@ -0,0 +1,7 @@ +{ + "globalSubscriberId":"9b9f02c0-298b-458a-bc9c-be3692e4f350", + "serviceType":"service", + "serviceId":"9b9f02c0-298b-458a-bc9c-be3692e4f351", + "operationId":"9b9f02c0-298b-458a-bc9c-be3692e4f352", + "nodeTemplateUUID":"9b9f02c0-298b-458a-bc9c-be3692e4f353" +} \ No newline at end of file diff --git a/src/test/resources/json/instantiateNsReq.json b/src/test/resources/json/instantiateNsReq.json new file mode 100644 index 0000000..047c810 --- /dev/null +++ b/src/test/resources/json/instantiateNsReq.json @@ -0,0 +1,32 @@ +{ + "nsServiceName":"vIMS", + "nsServiceDescription":"vIMS NS", + "nsOperationKey":{ + "globalSubscriberId":"9b9f02c0-298b-458a-bc9c-be3692e4f350", + "serviceType":"service", + "serviceId":"9b9f02c0-298b-458a-bc9c-be3692e4f351", + "operationId":"9b9f02c0-298b-458a-bc9c-be3692e4f352", + "nodeTemplateUUID":"9b9f02c0-298b-458a-bc9c-be3692e4f353" + }, + "nsParameters":{ + "locationConstraints":[ + { + "vnfProfileId":"zte-CSCF-1.0", + "locationConstraints":{ + "vimId":"1" + } + } + ], + "additionalParamForNs":{ + "externalDataNetworkName":"Flow_out_net", + "m6000_mng_ip":"192.168.20.2", + "externalCompanyFtpDataNetworkName":"Flow_out_net", + "externalPluginManageNetworkName":"plugin_net_2014", + "externalManageNetworkName":"mng_net_2017", + "sfc_data_network":"sfc_data_net_2016", + "NatIpRange":"210.1.1.10-210.1.1.20", + "location":"4050083f-465f-4838-af1e-47a545222ad0", + "sdncontroller":"9b9f02c0-298b-458a-bc9c-be3692e4f35e" + } + } +} \ No newline at end of file diff --git a/src/test/resources/json/instantiateNsRsp.json b/src/test/resources/json/instantiateNsRsp.json new file mode 100644 index 0000000..51e4d01 --- /dev/null +++ b/src/test/resources/json/instantiateNsRsp.json @@ -0,0 +1,3 @@ +{ + "jobId":"1" +} \ No newline at end of file diff --git a/src/test/resources/json/lcmOperRsp.json b/src/test/resources/json/lcmOperRsp.json new file mode 100644 index 0000000..111afc1 --- /dev/null +++ b/src/test/resources/json/lcmOperRsp.json @@ -0,0 +1,7 @@ +{ + "id":"12204a12-7da2-4ddf-8c2f-992a1a1acebf", + "lcmOperationType":"INSTANTIATE", + "nsInstanceId":"c9f0a95e-dea0-4698-96e5-5a79bc5a233d", + "operationState":"PROCESSING", + "statusEnteredTime":"Time" +} \ No newline at end of file diff --git a/src/test/resources/json/queryJobReq.json b/src/test/resources/json/queryJobReq.json new file mode 100644 index 0000000..ac095e6 --- /dev/null +++ b/src/test/resources/json/queryJobReq.json @@ -0,0 +1,7 @@ +{ + "globalSubscriberId":"9b9f02c0-298b-458a-bc9c-be3692e4f350", + "serviceType":"service", + "serviceId":"9b9f02c0-298b-458a-bc9c-be3692e4f351", + "operationId":"9b9f02c0-298b-458a-bc9c-be3692e4f352", + "nodeTemplateUUID":"9b9f02c0-298b-458a-bc9c-be3692e4f353" +} \ No newline at end of file diff --git a/src/test/resources/json/queryJobRsp.json b/src/test/resources/json/queryJobRsp.json new file mode 100644 index 0000000..9238b47 --- /dev/null +++ b/src/test/resources/json/queryJobRsp.json @@ -0,0 +1,10 @@ +{ + "jobId": "1", + "responseDescriptor": { + "progress": "100", + "status": "finished", + "statusDescription": "OMC VMs are decommissioned in VIM", + "errorCode": "", + "responseId": "22" + } +} \ No newline at end of file diff --git a/src/test/resources/json/terminateNsReq.json b/src/test/resources/json/terminateNsReq.json new file mode 100644 index 0000000..ac095e6 --- /dev/null +++ b/src/test/resources/json/terminateNsReq.json @@ -0,0 +1,7 @@ +{ + "globalSubscriberId":"9b9f02c0-298b-458a-bc9c-be3692e4f350", + "serviceType":"service", + "serviceId":"9b9f02c0-298b-458a-bc9c-be3692e4f351", + "operationId":"9b9f02c0-298b-458a-bc9c-be3692e4f352", + "nodeTemplateUUID":"9b9f02c0-298b-458a-bc9c-be3692e4f353" +} \ No newline at end of file diff --git a/src/test/resources/json/terminateNsRsp.json b/src/test/resources/json/terminateNsRsp.json new file mode 100644 index 0000000..51e4d01 --- /dev/null +++ b/src/test/resources/json/terminateNsRsp.json @@ -0,0 +1,3 @@ +{ + "jobId":"1" +} \ No newline at end of file diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml new file mode 100644 index 0000000..c2e0098 --- /dev/null +++ b/src/test/resources/logback-test.xml @@ -0,0 +1,42 @@ + + + + + + + + %d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n + + + + + + + + + + + + + + + + + + + + + + + + -- cgit 1.2.3-korg