diff options
author | Yan Yang <yangyanyj@chinamobile.com> | 2018-03-01 02:14:28 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-03-01 02:14:28 +0000 |
commit | fb84e01fe22a1cb0ae4778a38f01ce13e85c06d6 (patch) | |
tree | ec8a9bdddc867eeff26492bd8c2c3cce7d9f894e /nokiav2/generatedapis/src/test | |
parent | 37740765e55b70eae2fc46c4968f01d86bb9dbee (diff) | |
parent | b17042b955489d8a023d09abad5436ff9b900dc3 (diff) |
Merge "Updating Nokia driver"
Diffstat (limited to 'nokiav2/generatedapis/src/test')
-rw-r--r-- | nokiav2/generatedapis/src/test/java/TestInhertence.java | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/nokiav2/generatedapis/src/test/java/TestInhertence.java b/nokiav2/generatedapis/src/test/java/TestInhertence.java new file mode 100644 index 00000000..8e7d551e --- /dev/null +++ b/nokiav2/generatedapis/src/test/java/TestInhertence.java @@ -0,0 +1,113 @@ +/* + * Copyright 2016-2017, Nokia Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.nokia.cbam.lcm.v32.ApiClient; +import com.nokia.cbam.lcm.v32.model.*; +import org.junit.Test; + +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertNull; +import static junit.framework.TestCase.assertTrue; + +public class TestInhertence { + + /** + * test OpenStack v2 inheritence handling in serialization and deserialization + */ + @Test + public void testOpenStackV2(){ + InstantiateVnfRequest req = new InstantiateVnfRequest(); + OPENSTACKV2INFO vim = new OPENSTACKV2INFO(); + req.getVims().add(vim); + vim.setVimInfoType(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO); + OpenStackAccessInfoV2 accessInfo = new OpenStackAccessInfoV2(); + accessInfo.setPassword("myPassword"); + vim.setAccessInfo(accessInfo); + String serialize = new ApiClient().getJSON().serialize(req); + assertTrue(serialize.contains("myPassword")); + InstantiateVnfRequest deserialize = new ApiClient().getJSON().deserialize(serialize, InstantiateVnfRequest.class); + assertEquals(1, deserialize.getVims().size()); + OPENSTACKV2INFO deserializedVim = (OPENSTACKV2INFO) deserialize.getVims().get(0); + assertEquals("myPassword", deserializedVim.getAccessInfo().getPassword()); + } + + /** + * test OpenStack v3 inheritence handling in serialization and deserialization + */ + @Test + public void testOpenStackV3(){ + InstantiateVnfRequest req = new InstantiateVnfRequest(); + OPENSTACKV3INFO vim = new OPENSTACKV3INFO(); + req.getVims().add(vim); + vim.setVimInfoType(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO); + OpenStackAccessInfoV3 accessInfo = new OpenStackAccessInfoV3(); + accessInfo.setPassword("myPassword"); + vim.setAccessInfo(accessInfo); + String serialize = new ApiClient().getJSON().serialize(req); + assertTrue(serialize.contains("myPassword")); + InstantiateVnfRequest deserialize = new ApiClient().getJSON().deserialize(serialize, InstantiateVnfRequest.class); + assertEquals(1, deserialize.getVims().size()); + OPENSTACKV3INFO deserializedVim = (OPENSTACKV3INFO) deserialize.getVims().get(0); + assertEquals("myPassword", deserializedVim.getAccessInfo().getPassword()); + } + + /** + * test vCloud inheritence handling in serialization and deserialization + */ + @Test + public void testVCloud(){ + InstantiateVnfRequest req = new InstantiateVnfRequest(); + VMWAREVCLOUDINFO vim = new VMWAREVCLOUDINFO(); + req.getVims().add(vim); + vim.setVimInfoType(VimInfo.VimInfoTypeEnum.VMWARE_VCLOUD_INFO); + VCloudAccessInfo accessInfo = new VCloudAccessInfo(); + accessInfo.setPassword("myPassword"); + vim.setAccessInfo(accessInfo); + String serialize = new ApiClient().getJSON().serialize(req); + assertTrue(serialize.contains("myPassword")); + InstantiateVnfRequest deserialize = new ApiClient().getJSON().deserialize(serialize, InstantiateVnfRequest.class); + assertEquals(1, deserialize.getVims().size()); + VMWAREVCLOUDINFO deserializedVim = (VMWAREVCLOUDINFO) deserialize.getVims().get(0); + assertEquals("myPassword", deserializedVim.getAccessInfo().getPassword()); + } + + /** + * test LCN serialization and deserialization + */ + @Test + public void testLcn() throws Exception{ + VnfLifecycleChangeNotification vnfLifecycleChangeNotification = new VnfLifecycleChangeNotification(); + vnfLifecycleChangeNotification.setNotificationType(VnfNotificationType.VNFLIFECYCLECHANGENOTIFICATION); + vnfLifecycleChangeNotification.setVnfInstanceId("myId"); + String serialize = new ApiClient().getJSON().serialize(vnfLifecycleChangeNotification); + VnfLifecycleChangeNotification deserialize = new ApiClient().getJSON().deserialize(serialize, VnfLifecycleChangeNotification.class); + assertEquals("myId", deserialize.getVnfInstanceId()); + } + + /** + * test arrays are not initialized to empty arrays + */ + @Test + public void testArrayBehaviour() throws Exception{ + VnfLifecycleChangeNotification vnfLifecycleChangeNotification = new VnfLifecycleChangeNotification(); + vnfLifecycleChangeNotification.setNotificationType(VnfNotificationType.VNFLIFECYCLECHANGENOTIFICATION); + vnfLifecycleChangeNotification.setVnfInstanceId("myId"); + String serialize = new ApiClient().getJSON().serialize(vnfLifecycleChangeNotification); + VnfLifecycleChangeNotification deserialize = new ApiClient().getJSON().deserialize(serialize, VnfLifecycleChangeNotification.class); + assertNull(deserialize.getAffectedVirtualLinks()); + } + +} |