summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Shen <shentao@chinamobile.com>2019-03-21 07:33:24 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-21 07:33:24 +0000
commit667e918f4d8019c9beb0d4c82c12719514ce492c (patch)
tree83cd929528cf77377418fb4d14c107a50a1a4b1f
parent3f5483de35ab6e6ef666261a4c00f74a69392c74 (diff)
parentf961169ed61307d8638821febd280c9080566a2e (diff)
Merge "add test coverage"
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java4
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceControllerTest.java51
2 files changed, 50 insertions, 5 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java
index b44a5c27..00c9a51c 100755
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java
@@ -18,9 +18,7 @@ package org.onap.usecaseui.server.service.impl;
import java.util.ArrayList;
import java.util.List;
-
import javax.transaction.Transactional;
-
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
@@ -89,7 +87,7 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
public int getAllCount(AlarmsInformation alarmsInformation, int currentPage, int pageSize) {
try(Session session = getSession()){
- StringBuffer hql = new StringBuffer("select count(*) from AlarmsInformation a where 1=1");
+ StringBuilder hql = new StringBuilder("select count(*) from AlarmsInformation a where 1=1");
if (null == alarmsInformation) {
}else {
if(null!=alarmsInformation.getName()) {
diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceControllerTest.java
index d82913a4..64e0979f 100644
--- a/server/src/test/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceControllerTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceControllerTest.java
@@ -15,14 +15,43 @@
*/
package org.onap.usecaseui.server.controller.lcm;
+import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.onap.usecaseui.server.service.lcm.ServiceInstanceService;
-
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.MvcResult;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import javax.servlet.http.HttpServletRequest;
-
+import javax.ws.rs.core.MediaType;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {ServiceInstanceController.class })
+@WebAppConfiguration
+@EnableWebMvc
+
public class ServiceInstanceControllerTest {
+
+ private MockMvc mockMvc;
+
+ @Autowired
+ private WebApplicationContext wac;
+
+ @Before
+ public void setUp() {
+ mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
+ }
+
@Test
public void testListServiceInstances() throws Exception {
ServiceInstanceController controller = new ServiceInstanceController();
@@ -39,5 +68,23 @@ public class ServiceInstanceControllerTest {
verify(service, times(1)).listServiceInstances(customerId, serviceType);
}
+
+
+ @Test
+ public void testListNsOrServiceInstances() throws Exception {
+
+ ServiceInstanceController controller = new ServiceInstanceController();
+ ServiceInstanceService service = mock(ServiceInstanceService.class);
+ controller.setServiceInstanceService(service);
+
+ String uri = "/uui-lcm/service-ns-instances";
+ MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(uri)
+ .accept(MediaType.APPLICATION_JSON)).andReturn();
+
+ int status = mvcResult.getResponse().getStatus();
+ assertEquals(200, status);
+
+ }
+
} \ No newline at end of file