diff options
Diffstat (limited to 'esr-mgr/src/test/java/org/onap/aai')
6 files changed, 376 insertions, 0 deletions
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoDetailTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoDetailTest.java new file mode 100644 index 0000000..02948cc --- /dev/null +++ b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoDetailTest.java @@ -0,0 +1,60 @@ +/** + * Copyright 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.aai.esr.entity.aai; + +import static org.junit.Assert.assertEquals; +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; + +public class EsrNfvoDetailTest { + @Test + public void getterAndSetter4nfvoId() { + final String nfvoId = "nfvoId-test"; + EsrNfvoDetail esrNfvo = new EsrNfvoDetail(); + esrNfvo.setNfvoId(nfvoId); + assertEquals(esrNfvo.getNfvoId(), nfvoId); + } + + @Test + public void getterAndSetter4resourceVersion() { + final String resourceVersion = "resourceVersion-test"; + EsrNfvoDetail esrNfvo = new EsrNfvoDetail(); + esrNfvo.setResourceVersion(resourceVersion); + assertEquals(esrNfvo.getResourceVersion(), resourceVersion); + } + + @Test + public void getterAndSetter4apiRoot() { + final String apiRoot = "apiRoot-test"; + EsrNfvoDetail esrNfvo = new EsrNfvoDetail(); + esrNfvo.setApiroot(apiRoot); + assertEquals(esrNfvo.getApiroot(), apiRoot); + } + + @Test + public void getterAndSetter4esrSystemInfoList() { + final EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList(); + List<EsrSystemInfo> esrSystemInfo = new ArrayList<>(); + EsrSystemInfo esrSystemInfoObj = new EsrSystemInfo(); + esrSystemInfoObj.setEsrSystemInfoId("123"); + esrSystemInfo.add(esrSystemInfoObj); + esrSystemInfoList.setEsrSystemInfo(esrSystemInfo); + EsrNfvoDetail esrNfvoDetail = new EsrNfvoDetail(); + esrNfvoDetail.setEsrSystemInfoList(esrSystemInfoList); + assertEquals(esrNfvoDetail.getEsrSystemInfoList(), esrSystemInfoList); + } +} diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoListTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoListTest.java new file mode 100644 index 0000000..23ade6a --- /dev/null +++ b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoListTest.java @@ -0,0 +1,34 @@ +/** + * Copyright 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.aai.esr.entity.aai; + +import static org.junit.Assert.assertEquals; +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; + +public class EsrNfvoListTest { + @Test + public void getterAndSetter4EsrNfvoList() { + EsrNfvoList esrNfvoList = new EsrNfvoList(); + List<EsrNfvo> esrNfvos = new ArrayList<>(); + EsrNfvo esrNfvo = new EsrNfvo(); + esrNfvo.setNfvoId("fadasf"); + esrNfvos.add(esrNfvo); + esrNfvoList.setEsrNfvo(esrNfvos); + assertEquals(esrNfvoList.getEsrNfvo(), esrNfvos); + } +} diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoTest.java new file mode 100644 index 0000000..70885be --- /dev/null +++ b/esr-mgr/src/test/java/org/onap/aai/esr/entity/aai/EsrNfvoTest.java @@ -0,0 +1,45 @@ +/** + * Copyright 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.aai.esr.entity.aai; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class EsrNfvoTest { + @Test + public void getterAndSetter4nfvoId() { + final String nfvoId = "nfvoId-test"; + EsrNfvo esrNfvo = new EsrNfvo(); + esrNfvo.setNfvoId(nfvoId); + assertEquals(esrNfvo.getNfvoId(), nfvoId); + } + + @Test + public void getterAndSetter4resourceVersion() { + final String resourceVersion = "resourceVersion-test"; + EsrNfvo esrNfvo = new EsrNfvo(); + esrNfvo.setResourceVersion(resourceVersion); + assertEquals(esrNfvo.getResourceVersion(), resourceVersion); + } + + @Test + public void getterAndSetter4apiRoot() { + final String apiRoot = "apiRoot-test"; + EsrNfvo esrNfvo = new EsrNfvo(); + esrNfvo.setApiroot(apiRoot); + assertEquals(esrNfvo.getApiroot(), apiRoot); + } +} diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/entity/rest/NfvoRegisterInfoTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/entity/rest/NfvoRegisterInfoTest.java new file mode 100644 index 0000000..74cc36b --- /dev/null +++ b/esr-mgr/src/test/java/org/onap/aai/esr/entity/rest/NfvoRegisterInfoTest.java @@ -0,0 +1,84 @@ +/** + * Copyright 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.aai.esr.entity.rest; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class NfvoRegisterInfoTest { + + @Test + public void getterAndSetter4nfvoId() { + final String nfvoId = "dafadf"; + NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo(); + nfvoRegisterInfo.setNfvoId(nfvoId); + assertEquals(nfvoRegisterInfo.getNfvoId(), nfvoId); + } + + @Test + public void getterAndSetter4name() { + final String name = "name-test"; + NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo(); + nfvoRegisterInfo.setName(name); + assertEquals(nfvoRegisterInfo.getName(), name); + } + @Test + public void getterAndSetter4apiRoot() { + final String apiRoot = "dafadf"; + NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo(); + nfvoRegisterInfo.setApiroot(apiRoot); + assertEquals(nfvoRegisterInfo.getApiroot(), apiRoot); + } + + @Test + public void getterAndSetter4vendor() { + final String vendor = "zte"; + NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo(); + nfvoRegisterInfo.setVendor(vendor); + assertEquals(nfvoRegisterInfo.getVendor(), vendor); + } + + @Test + public void getterAndSetter4version() { + final String version = "v1.0"; + NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo(); + nfvoRegisterInfo.setVersion(version); + assertEquals(nfvoRegisterInfo.getVersion(), version); + } + @Test + public void getterAndSetter4url() { + final String url = "/home"; + NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo(); + nfvoRegisterInfo.setUrl(url); + assertEquals(nfvoRegisterInfo.getUrl(), url); + } + + @Test + public void getterAndSetter4userName() { + final String userName = "li"; + NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo(); + nfvoRegisterInfo.setUserName(userName); + assertEquals(nfvoRegisterInfo.getUserName(), userName); + } + + @Test + public void getterAndSetter4password() { + final String password = "dfaaf"; + NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo(); + nfvoRegisterInfo.setPassword(password); + assertEquals(nfvoRegisterInfo.getPassword(), password); + } +} diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxyTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxyTest.java index da5d27e..fbfc68a 100644 --- a/esr-mgr/src/test/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxyTest.java +++ b/esr-mgr/src/test/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxyTest.java @@ -21,6 +21,7 @@ import org.onap.aai.esr.common.MsbConfig; import org.onap.aai.esr.entity.aai.EsrEmsDetail;
import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
import org.onap.aai.esr.entity.aai.EsrVnfmDetail;
+import org.onap.aai.esr.entity.aai.EsrNfvoDetail;
import org.onap.aai.esr.exception.ExtsysException;
public class ExternalSystemProxyTest {
@@ -55,6 +56,30 @@ public class ExternalSystemProxyTest { }
@Test(expected = ExtsysException.class)
+ public void testRegisterNfvo() throws ExtsysException {
+ EsrNfvoDetail detail = new EsrNfvoDetail();
+ externalSystemProxy.registerNfvo("nfvo-1", detail);
+ }
+
+ @Test(expected = ExtsysException.class)
+ public void testQueryNfvoDetail() throws ExtsysException {
+ externalSystemProxy.queryNfvoDetail("nfvo-1");
+ }
+
+ @Test(expected = ExtsysException.class)
+ public void testQueryNfvoList() throws ExtsysException {
+ externalSystemProxy.queryNfvoList();
+ }
+
+ @Test(expected = ExtsysException.class)
+ public void testDeleteNfvo() throws ExtsysException {
+ externalSystemProxy.deleteNfvo("nfvo-1", "version-1");
+ }
+
+
+
+
+ @Test(expected = ExtsysException.class)
public void testRegisterSdnc() throws ExtsysException {
EsrThirdpartySdncDetail detail = new EsrThirdpartySdncDetail();
externalSystemProxy.registerSdnc("sdnc-1", detail);
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/NfvoManagerWrapperTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/NfvoManagerWrapperTest.java new file mode 100644 index 0000000..b16006a --- /dev/null +++ b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/NfvoManagerWrapperTest.java @@ -0,0 +1,128 @@ +/** + * Copyright 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.aai.esr.wrapper; + +import static org.junit.Assert.assertEquals; +import java.util.ArrayList; +import java.util.List; +import javax.ws.rs.core.Response; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.aai.esr.common.MsbConfig; +import org.onap.aai.esr.entity.aai.EsrNfvoDetail; +import org.onap.aai.esr.entity.rest.NfvoRegisterInfo; +import org.onap.aai.esr.exception.ExtsysException; +import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy; +import org.onap.aai.esr.util.ExtsysUtil; + +public class NfvoManagerWrapperTest { + + static { + MsbConfig.setMsbServerAddr("http://127.0.0.1:80"); + } + + @Test + public void test_registerNfvo() throws ExtsysException { + NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo(); + nfvoRegisterInfo.setApiroot("abcd/"); + nfvoRegisterInfo.setVersion("v1"); + nfvoRegisterInfo.setVendor("zte"); + nfvoRegisterInfo.setUserName("onap"); + nfvoRegisterInfo.setUrl("http://ip:8000"); + nfvoRegisterInfo.setPassword("987654"); + nfvoRegisterInfo.setName("ONAP NFVO"); + ExternalSystemProxy mockExternalSystemProxy = Mockito.mock(ExternalSystemProxy.class); + Mockito.doNothing().when(mockExternalSystemProxy).registerNfvo(Mockito.anyString(), (EsrNfvoDetail)Mockito.anyObject()); + NfvoManagerWrapper nfvoManagerWrapper = new NfvoManagerWrapper(mockExternalSystemProxy); + Response response = nfvoManagerWrapper.registerNfvo(nfvoRegisterInfo); + if (response != null) { + Assert.assertTrue(response.getStatus() == 200); + } + } + + @Test + public void test_queryNfvoById() throws ExtsysException { + ExtsysUtil extsysUtil = new ExtsysUtil(); + NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo(); + nfvoRegisterInfo.setApiroot("abcd/"); + nfvoRegisterInfo.setVersion("v1"); + nfvoRegisterInfo.setVendor("zte"); + nfvoRegisterInfo.setUserName("onap"); + nfvoRegisterInfo.setUrl("http://ip:8000"); + nfvoRegisterInfo.setPassword("987654"); + nfvoRegisterInfo.setName("ONAP NFVO"); + nfvoRegisterInfo.setNfvoId("123456"); + String esrNfvoDetailStr = "{\"nfvo-id\":\"123456\",\"api-root\":\"abcd/\"," + + "\"esr-system-info-list\":{" + + "\"esr-system-info\":[{\"esr-system-info-id\":\"qwerty\",\"system-name\":\"ONAP NFVO\"," + + "\"vendor\":\"zte\",\"version\":\"v1\"," + + "\"service-url\":\"http://ip:8000\",\"user-name\":\"onap\"," + + "\"password\":\"987654\",\"system-type\":\"NFVO\"}]}}"; + ExternalSystemProxy mockExternalSystemProxy = Mockito.mock(ExternalSystemProxy.class); + Mockito.when(mockExternalSystemProxy.queryNfvoDetail(Mockito.anyString())).thenReturn(esrNfvoDetailStr); + NfvoManagerWrapper nfvoManagerWrapper = new NfvoManagerWrapper(mockExternalSystemProxy); + Response response = nfvoManagerWrapper.queryNfvoById("123456"); + if (response != null) { + Assert.assertTrue(response.getStatus() == 200); + assertEquals(extsysUtil.objectToString(nfvoRegisterInfo), extsysUtil.objectToString(response.getEntity())); + } + } + + @Test + public void test_queryNfvoList() throws ExtsysException { + ExtsysUtil extsysUtil = new ExtsysUtil(); + List<NfvoRegisterInfo> nfvoList = new ArrayList<>(); + NfvoRegisterInfo nfvoRegisterInfo = new NfvoRegisterInfo(); + nfvoRegisterInfo.setApiroot("abcd/"); + nfvoRegisterInfo.setVersion("v1"); + nfvoRegisterInfo.setVendor("zte"); + nfvoRegisterInfo.setUserName("onap"); + nfvoRegisterInfo.setUrl("http://ip:8000"); + nfvoRegisterInfo.setPassword("987654"); + nfvoRegisterInfo.setName("ONAP NFVO"); + nfvoRegisterInfo.setNfvoId("123456"); + nfvoList.add(nfvoRegisterInfo); + String nfvoListStr = "{\"esr-nfvo\": [{\"nfvo-id\": \"123456\",\"api-root\": \"abcd/\"," + + "\"resource-version\": \"1\"}]}"; + String esrNfvoDetailStr = "{\"nfvo-id\":\"123456\",\"api-root\":\"abcd/\"," + + "\"esr-system-info-list\":{" + + "\"esr-system-info\":[{\"esr-system-info-id\":\"qwerty\",\"system-name\":\"ONAP NFVO\"," + + "\"vendor\":\"zte\",\"version\":\"v1\"," + + "\"service-url\":\"http://ip:8000\",\"user-name\":\"onap\"," + + "\"password\":\"987654\",\"system-type\":\"NFVO\"}]}}"; + ExternalSystemProxy mockExternalSystemProxy = Mockito.mock(ExternalSystemProxy.class); + Mockito.when(mockExternalSystemProxy.queryNfvoList()).thenReturn(nfvoListStr); + Mockito.when(mockExternalSystemProxy.queryNfvoDetail(Mockito.anyString())).thenReturn(esrNfvoDetailStr); + NfvoManagerWrapper nfvoManagerWrapper = new NfvoManagerWrapper(mockExternalSystemProxy); + Response response = nfvoManagerWrapper.queryNfvoList(); + if (response != null) { + Assert.assertTrue(response.getStatus() == 200); + assertEquals(extsysUtil.objectToString(nfvoList), extsysUtil.objectToString(response.getEntity())); + } + } + + @Test + public void test_delNfvo() throws ExtsysException { + ExternalSystemProxy mockExternalSystemProxy = Mockito.mock(ExternalSystemProxy.class); + Mockito.doNothing().when(mockExternalSystemProxy).deleteNfvo(Mockito.anyString(), Mockito.anyString()); + NfvoManagerWrapper nfvoManagerWrapper = new NfvoManagerWrapper(mockExternalSystemProxy); + Response response = nfvoManagerWrapper.delNfvo("123456"); + if (response != null) { + Assert.assertTrue(response.getStatus() == 204); + } + } +} |