summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhekeguang <hekeguang@chinamobile.com>2020-02-20 15:36:53 +0800
committerhekeguang <hekeguang@chinamobile.com>2020-02-20 15:37:09 +0800
commite3b45042535ce8d8880c349be82d5f7c6ff9b5dd (patch)
treeddf80a8c01bb0815611bcd66f7bb937af9b56431
parent35304999f52473b3435e6d52c0096b17b62df2f9 (diff)
Add test code related to nsmf.
Issue-ID: USECASEUI-374 Change-Id: I096b396d121f5d243e6c4b6e08af69954b247be4 Signed-off-by: hekeguang <hekeguang@chinamobile.com>
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/controller/csmf/SlicingControllerTest.java53
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/controller/nsmf/ResourceMgtControllerTest.java178
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/controller/nsmf/ResourceMonitorControllerTest.java83
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/controller/nsmf/TaskMgtControllerTest.java90
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/util/nsmf/NsmfCommonUtilTest.java50
5 files changed, 454 insertions, 0 deletions
diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/csmf/SlicingControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/csmf/SlicingControllerTest.java
new file mode 100644
index 00000000..eb7c8833
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/controller/csmf/SlicingControllerTest.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2020 CMCC, Inc. and others. 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.usecaseui.server.controller.csmf;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import org.junit.Test;
+import org.onap.usecaseui.server.bean.csmf.SlicingOrder;
+import org.onap.usecaseui.server.controller.nsmf.TaskMgtController;
+import org.onap.usecaseui.server.service.csmf.SlicingService;
+import org.onap.usecaseui.server.service.nsmf.TaskMgtService;
+
+public class SlicingControllerTest {
+
+ @Test
+ public void testCreateSlicingService() {
+ SlicingService slicingService = mock(SlicingService.class);
+
+ SlicingController slicingController = new SlicingController();
+ slicingController.setSlicingService(slicingService);
+
+ SlicingOrder slicingOrder = new SlicingOrder();
+ slicingController.createSlicingService(slicingOrder);
+ verify(slicingService, times(1)).createSlicingService(slicingOrder);
+ }
+
+ @Test
+ public void testQuerySlicingServiceOrder() {
+ SlicingService slicingService = mock(SlicingService.class);
+
+ SlicingController slicingController = new SlicingController();
+ slicingController.setSlicingService(slicingService);
+
+ SlicingOrder slicingOrder = new SlicingOrder();
+ slicingController.querySlicingServiceOrder("processing", "1", "100");
+ verify(slicingService, times(1)).querySlicingOrderList("processing", "1", "100");
+ }
+}
diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/nsmf/ResourceMgtControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/nsmf/ResourceMgtControllerTest.java
new file mode 100644
index 00000000..4eef0aaf
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/controller/nsmf/ResourceMgtControllerTest.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 2019 CMCC, Inc. and others. 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.usecaseui.server.controller.nsmf;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import org.junit.Test;
+import org.onap.usecaseui.server.controller.lcm.CustomerController;
+import org.onap.usecaseui.server.service.lcm.CustomerService;
+import org.onap.usecaseui.server.service.nsmf.ResourceMgtService;
+
+public class ResourceMgtControllerTest {
+
+ @Test
+ public void testQuerySlicingBusiness() {
+ ResourceMgtService resourceMgtService = mock(ResourceMgtService.class);
+ ResourceMgtController resourceMgtController = new ResourceMgtController();
+ resourceMgtController.setResourceMgtService(resourceMgtService);
+
+ resourceMgtController.querySlicingBusiness(1, 10);
+ verify(resourceMgtService, times(1)).querySlicingBusiness(1, 10);
+ }
+
+ @Test
+ public void testQuerySlicingBusinessByStatus() {
+ ResourceMgtService resourceMgtService = mock(ResourceMgtService.class);
+ ResourceMgtController resourceMgtController = new ResourceMgtController();
+ resourceMgtController.setResourceMgtService(resourceMgtService);
+
+ resourceMgtController.querySlicingBusinessByStatus("Planning", 1, 10);
+ verify(resourceMgtService, times(1)).querySlicingBusinessByStatus("Planning", 1, 10);
+ }
+
+ @Test
+ public void testQuerySlicingBusinessDetails() {
+ ResourceMgtService resourceMgtService = mock(ResourceMgtService.class);
+ ResourceMgtController resourceMgtController = new ResourceMgtController();
+ resourceMgtController.setResourceMgtService(resourceMgtService);
+
+ resourceMgtController.querySlicingBusinessDetails("oou9-876e-jhy7-uy78");
+ verify(resourceMgtService, times(1)).querySlicingBusinessDetails("oou9-876e-jhy7-uy78");
+ }
+
+ @Test
+ public void testQueryNsiInstances() {
+ ResourceMgtService resourceMgtService = mock(ResourceMgtService.class);
+ ResourceMgtController resourceMgtController = new ResourceMgtController();
+ resourceMgtController.setResourceMgtService(resourceMgtService);
+
+ resourceMgtController.queryNsiInstances(1, 10);
+ verify(resourceMgtService, times(1)).queryNsiInstances(1, 10);
+ }
+
+ @Test
+ public void testQueryNsiInstancesByStatus() {
+ ResourceMgtService resourceMgtService = mock(ResourceMgtService.class);
+ ResourceMgtController resourceMgtController = new ResourceMgtController();
+ resourceMgtController.setResourceMgtService(resourceMgtService);
+
+ resourceMgtController.queryNsiInstancesByStatus("activated", 1, 10);
+ verify(resourceMgtService, times(1)).queryNsiInstancesByStatus("activated", 1, 10);
+ }
+
+ @Test
+ public void testQueryNsiDetails() {
+ ResourceMgtService resourceMgtService = mock(ResourceMgtService.class);
+ ResourceMgtController resourceMgtController = new ResourceMgtController();
+ resourceMgtController.setResourceMgtService(resourceMgtService);
+
+ resourceMgtController.queryNsiDetails("oou9-876e-jhy7-uy78");
+ verify(resourceMgtService, times(1)).queryNsiDetails("oou9-876e-jhy7-uy78");
+ }
+
+ @Test
+ public void testQueryNsiRelatedNssiInfo() {
+ ResourceMgtService resourceMgtService = mock(ResourceMgtService.class);
+ ResourceMgtController resourceMgtController = new ResourceMgtController();
+ resourceMgtController.setResourceMgtService(resourceMgtService);
+
+ resourceMgtController.queryNsiRelatedNssiInfo("oou9-876e-jhy7-uy78");
+ verify(resourceMgtService, times(1)).queryNsiRelatedNssiInfo("oou9-876e-jhy7-uy78");
+ }
+
+ @Test
+ public void testQueryNssiInstances() {
+ ResourceMgtService resourceMgtService = mock(ResourceMgtService.class);
+ ResourceMgtController resourceMgtController = new ResourceMgtController();
+ resourceMgtController.setResourceMgtService(resourceMgtService);
+
+ resourceMgtController.queryNssiInstances(1, 10);
+ verify(resourceMgtService, times(1)).queryNssiInstances(1, 10);
+ }
+
+ @Test
+ public void testQueryNssiInstancesByStatus() {
+ ResourceMgtService resourceMgtService = mock(ResourceMgtService.class);
+ ResourceMgtController resourceMgtController = new ResourceMgtController();
+ resourceMgtController.setResourceMgtService(resourceMgtService);
+
+ resourceMgtController.queryNssiInstancesByStatus("activated", 1, 10);
+ verify(resourceMgtService, times(1)).queryNssiInstancesByStatus("activated", 1, 10);
+ }
+
+ @Test
+ public void testQueryNssiInstancesByEnvironment() {
+ ResourceMgtService resourceMgtService = mock(ResourceMgtService.class);
+ ResourceMgtController resourceMgtController = new ResourceMgtController();
+ resourceMgtController.setResourceMgtService(resourceMgtService);
+
+ resourceMgtController.queryNssiInstancesByEnvironment("activated", 1, 10);
+ verify(resourceMgtService, times(1)).queryNssiInstancesByEnvironment("activated", 1, 10);
+ }
+
+ @Test
+ public void testQueryNssiDetails() {
+ ResourceMgtService resourceMgtService = mock(ResourceMgtService.class);
+ ResourceMgtController resourceMgtController = new ResourceMgtController();
+ resourceMgtController.setResourceMgtService(resourceMgtService);
+
+ resourceMgtController.queryNssiDetails("oou9-876e-jhy7-uy78");
+ verify(resourceMgtService, times(1)).queryNssiDetails("oou9-876e-jhy7-uy78");
+ }
+
+ @Test
+ public void testActivateSlicingService() {
+ ResourceMgtService resourceMgtService = mock(ResourceMgtService.class);
+ ResourceMgtController resourceMgtController = new ResourceMgtController();
+ resourceMgtController.setResourceMgtService(resourceMgtService);
+
+ resourceMgtController.activateSlicingService("oou9-876e-jhy7-uy78");
+ verify(resourceMgtService, times(1)).activateSlicingService("oou9-876e-jhy7-uy78");
+ }
+
+ @Test
+ public void testDeactivateSlicingService() {
+ ResourceMgtService resourceMgtService = mock(ResourceMgtService.class);
+ ResourceMgtController resourceMgtController = new ResourceMgtController();
+ resourceMgtController.setResourceMgtService(resourceMgtService);
+
+ resourceMgtController.deactivateSlicingService("oou9-876e-jhy7-uy78");
+ verify(resourceMgtService, times(1)).deactivateSlicingService("oou9-876e-jhy7-uy78");
+ }
+
+ @Test
+ public void testTerminateSlicingService() {
+ ResourceMgtService resourceMgtService = mock(ResourceMgtService.class);
+ ResourceMgtController resourceMgtController = new ResourceMgtController();
+ resourceMgtController.setResourceMgtService(resourceMgtService);
+
+ resourceMgtController.terminateSlicingService("oou9-876e-jhy7-uy78");
+ verify(resourceMgtService, times(1)).terminateSlicingService("oou9-876e-jhy7-uy78");
+ }
+
+ @Test
+ public void testQueryOperationProgress() {
+ ResourceMgtService resourceMgtService = mock(ResourceMgtService.class);
+ ResourceMgtController resourceMgtController = new ResourceMgtController();
+ resourceMgtController.setResourceMgtService(resourceMgtService);
+
+ resourceMgtController.queryOperationProgress("oou9-876e-jhy7-uy78");
+ verify(resourceMgtService, times(1)).queryOperationProgress("oou9-876e-jhy7-uy78");
+ }
+}
diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/nsmf/ResourceMonitorControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/nsmf/ResourceMonitorControllerTest.java
new file mode 100644
index 00000000..451852a1
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/controller/nsmf/ResourceMonitorControllerTest.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2019 CMCC, Inc. and others. 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.usecaseui.server.controller.nsmf;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+import org.onap.usecaseui.server.bean.nsmf.monitor.ServiceInfo;
+import org.onap.usecaseui.server.bean.nsmf.monitor.ServiceList;
+import org.onap.usecaseui.server.service.nsmf.ResourceMgtService;
+import org.onap.usecaseui.server.service.nsmf.ResourceMonitorService;
+
+public class ResourceMonitorControllerTest {
+
+ @Test
+ public void testQuerySlicingUsageTraffic() {
+ ResourceMonitorService resourceMonitorService = mock(ResourceMonitorService.class);
+ ResourceMonitorController resourceMonitorController = new ResourceMonitorController();
+ resourceMonitorController.setResourceMonitorService(resourceMonitorService);
+
+ ServiceList serviceList = new ServiceList();
+ List<ServiceInfo> serviceInfoList = new ArrayList<>();
+ ServiceInfo serviceInfo = new ServiceInfo();
+ serviceInfo.setServiceId("1234-9067-4356-9876");
+ serviceInfoList.add(serviceInfo);
+ serviceList.setServiceInfoList(serviceInfoList);
+
+ resourceMonitorController.querySlicingUsageTraffic("1577016963000", serviceList);
+ verify(resourceMonitorService, times(1)).querySlicingUsageTraffic("1577016963000", serviceList);
+
+ }
+
+ @Test
+ public void testQuerySlicingOnlineUserNumber() {
+ ResourceMonitorService resourceMonitorService = mock(ResourceMonitorService.class);
+ ResourceMonitorController resourceMonitorController = new ResourceMonitorController();
+ resourceMonitorController.setResourceMonitorService(resourceMonitorService);
+
+ ServiceList serviceList = new ServiceList();
+ List<ServiceInfo> serviceInfoList = new ArrayList<>();
+ ServiceInfo serviceInfo = new ServiceInfo();
+ serviceInfo.setServiceId("1234-9067-4356-9876");
+ serviceInfoList.add(serviceInfo);
+ serviceList.setServiceInfoList(serviceInfoList);
+
+ resourceMonitorController.querySlicingOnlineUserNumber("1577016963000", serviceList);
+ verify(resourceMonitorService, times(1)).querySlicingOnlineUserNumber("1577016963000", serviceList);
+ }
+
+ @Test
+ public void testQuerySlicingTotalBandwidth() {
+ ResourceMonitorService resourceMonitorService = mock(ResourceMonitorService.class);
+ ResourceMonitorController resourceMonitorController = new ResourceMonitorController();
+ resourceMonitorController.setResourceMonitorService(resourceMonitorService);
+
+ ServiceList serviceList = new ServiceList();
+ List<ServiceInfo> serviceInfoList = new ArrayList<>();
+ ServiceInfo serviceInfo = new ServiceInfo();
+ serviceInfo.setServiceId("1234-9067-4356-9876");
+ serviceInfoList.add(serviceInfo);
+ serviceList.setServiceInfoList(serviceInfoList);
+
+ resourceMonitorController.querySlicingTotalBandwidth("1577016963000", serviceList);
+ verify(resourceMonitorService, times(1)).querySlicingTotalBandwidth("1577016963000", serviceList);
+ }
+}
diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/nsmf/TaskMgtControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/nsmf/TaskMgtControllerTest.java
new file mode 100644
index 00000000..58be5e1a
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/controller/nsmf/TaskMgtControllerTest.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2019 CMCC, Inc. and others. 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.usecaseui.server.controller.nsmf;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import org.junit.Test;
+import org.onap.usecaseui.server.bean.nsmf.task.SlicingTaskAuditInfo;
+import org.onap.usecaseui.server.service.nsmf.ResourceMgtService;
+import org.onap.usecaseui.server.service.nsmf.TaskMgtService;
+
+public class TaskMgtControllerTest {
+
+ @Test
+ public void testQuerySlicingTask() {
+ TaskMgtService taskMgtService = mock(TaskMgtService.class);
+ TaskMgtController taskMgtController = new TaskMgtController();
+ taskMgtController.setTaskMgtService(taskMgtService);
+
+ taskMgtController.querySlicingTask(1, 10);
+ verify(taskMgtService, times(1)).querySlicingTask(1, 10);
+ }
+
+ @Test
+ public void testQuerySlicingTaskByStatus() {
+ TaskMgtService taskMgtService = mock(TaskMgtService.class);
+ TaskMgtController taskMgtController = new TaskMgtController();
+ taskMgtController.setTaskMgtService(taskMgtService);
+
+ taskMgtController.querySlicingTaskByStatus("Planning", 1, 10);
+ verify(taskMgtService, times(1)).querySlicingTaskByStatus("Planning", 1, 10);
+ }
+
+ @Test
+ public void testQueryTaskAuditInfo() {
+ TaskMgtService taskMgtService = mock(TaskMgtService.class);
+ TaskMgtController taskMgtController = new TaskMgtController();
+ taskMgtController.setTaskMgtService(taskMgtService);
+
+ taskMgtController.queryTaskAuditInfo("oou9-876e-jhy7-uy78");
+ verify(taskMgtService, times(1)).queryTaskAuditInfo("oou9-876e-jhy7-uy78");
+ }
+
+ @Test
+ public void testUpdateTaskAuditInfo() {
+ TaskMgtService taskMgtService = mock(TaskMgtService.class);
+ TaskMgtController taskMgtController = new TaskMgtController();
+ taskMgtController.setTaskMgtService(taskMgtService);
+
+ SlicingTaskAuditInfo slicingTaskAuditInfo = new SlicingTaskAuditInfo();
+ taskMgtController.updateTaskAuditInfo(slicingTaskAuditInfo);
+ verify(taskMgtService, times(1)).updateTaskAuditInfo(slicingTaskAuditInfo);
+ }
+
+ @Test
+ public void testQueryTaskCreationInfo() {
+ TaskMgtService taskMgtService = mock(TaskMgtService.class);
+ TaskMgtController taskMgtController = new TaskMgtController();
+ taskMgtController.setTaskMgtService(taskMgtService);
+
+ taskMgtController.queryTaskCreationInfo("oou9-876e-jhy7-uy78");
+ verify(taskMgtService, times(1)).queryTaskCreationInfo("oou9-876e-jhy7-uy78");
+ }
+
+ @Test
+ public void testQueryTaskCreationProgress() {
+ TaskMgtService taskMgtService = mock(TaskMgtService.class);
+ TaskMgtController taskMgtController = new TaskMgtController();
+ taskMgtController.setTaskMgtService(taskMgtService);
+
+ taskMgtController.queryTaskCreationProgress("oou9-876e-jhy7-uy78");
+ verify(taskMgtService, times(1)).queryTaskCreationProgress("oou9-876e-jhy7-uy78");
+ }
+
+}
diff --git a/server/src/test/java/org/onap/usecaseui/server/util/nsmf/NsmfCommonUtilTest.java b/server/src/test/java/org/onap/usecaseui/server/util/nsmf/NsmfCommonUtilTest.java
new file mode 100644
index 00000000..401e4a1b
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/util/nsmf/NsmfCommonUtilTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2019 CMCC, Inc. and others. 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.usecaseui.server.util.nsmf;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import org.junit.Test;
+import org.onap.usecaseui.server.bean.nsmf.resource.SlicingBusinessInfo;
+
+public class NsmfCommonUtilTest {
+
+ @Test
+ public void testTimestamp2Time() {
+ try {
+ System.out.println(NsmfCommonUtil.timestamp2Time("2019-12-23 11:31:19"));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testTime2Timestamp() {
+ System.out.println(NsmfCommonUtil.time2Timestamp("1577071879000"));
+ }
+
+ @Test
+ public void testGetPagedList() {
+ List<SlicingBusinessInfo> slicingBusinessInfoList = new ArrayList<>();
+ NsmfCommonUtil.getPagedList(slicingBusinessInfoList, 1, 100);
+
+ List<SlicingBusinessInfo> slicingBusinessInfoListNull = null;
+ NsmfCommonUtil.getPagedList(slicingBusinessInfoListNull, 1, 100);
+ }
+}