aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhangab <zhanganbing@chinamobile.com>2018-05-29 18:58:51 +0800
committerzhangab <zhanganbing@chinamobile.com>2018-05-29 19:33:19 +0800
commit523be3f632b29e0faf9f9fce4e5dc0aad0a36946 (patch)
treebc49e8377318e767a5cfeb0a3b3e135e603d7adb
parent9898020025e33215e1c395975e42d8a690c57c3b (diff)
improve sonar coverage for uui-serverv1.1.12.0.0-ONAPbeijing2.0.0-ONAP
Change-Id: I109f23e9598573db36d8cfe2a21d9d35f11b0f0e Issue-ID: USECASEUI-123 Signed-off-by: zhangab <zhanganbing@chinamobile.com>
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java37
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java78
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java4
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java2
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/SaveOrUpdateOperationRsp.java5
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmService.java1
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/bean/AlarmsHeaderTest.java2
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/bean/AlarmsInformationTest.java29
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/bean/PerformanceHeaderTest.java28
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/bean/PerformanceInformationTest.java29
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/bean/lcm/TemplateInputTest.java3
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/bean/lcm/VfNsPackageInfoTest.java25
-rwxr-xr-xserver/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java75
-rwxr-xr-xserver/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java94
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImplTest.java52
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java26
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImplTest.java23
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java19
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerServiceTest.java20
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceServiceTest.java26
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmServiceTest.java77
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java14
-rwxr-xr-xserver/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java26
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/util/PageTest.java40
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/wrapper/AlarmWrapperTest.java48
-rw-r--r--standalone/src/main/assembly/bin/run.sh4
26 files changed, 496 insertions, 291 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java b/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java
index 0e1ea8c3..031d21f8 100755
--- a/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java
+++ b/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java
@@ -15,11 +15,16 @@
*/
package org.onap.usecaseui.server.controller;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.onap.usecaseui.server.bean.AlarmsHeader;
import org.onap.usecaseui.server.bean.AlarmsInformation;
import org.onap.usecaseui.server.bo.AlarmBo;
@@ -28,21 +33,19 @@ import org.onap.usecaseui.server.service.AlarmsHeaderService;
import org.onap.usecaseui.server.service.AlarmsInformationService;
import org.onap.usecaseui.server.util.DateUtils;
import org.onap.usecaseui.server.util.Page;
-import org.onap.usecaseui.server.util.ResponseUtil;
import org.onap.usecaseui.server.util.UuiCommonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
@RestController
@@ -51,7 +54,6 @@ import java.util.*;
public class AlarmController
{
-
private final Logger logger = LoggerFactory.getLogger(AlarmController.class);
@Resource(name = "AlarmsHeaderService")
@@ -60,6 +62,15 @@ public class AlarmController
@Resource(name = "AlarmsInformationService")
private AlarmsInformationService alarmsInformationService;
+ public void setAlarmsHeaderService(AlarmsHeaderService alarmsHeaderService) {
+ this.alarmsHeaderService = alarmsHeaderService;
+ }
+
+
+ public void setAlarmsInformationService(AlarmsInformationService alarmsInformationService) {
+ this.alarmsInformationService = alarmsInformationService;
+ }
+
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
private String formatDate = "yyyy-MM-dd";
diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java b/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java
index bc602126..4f090538 100755
--- a/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java
+++ b/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java
@@ -65,7 +65,16 @@ public class PerformanceController {
private PerformanceInformationService performanceInformationService;
private Logger logger = LoggerFactory.getLogger(PerformanceController.class);
+
+ public void setPerformanceHeaderService(PerformanceHeaderService performanceHeaderService) {
+ this.performanceHeaderService = performanceHeaderService;
+ }
+
+ public void setPerformanceInformationService(PerformanceInformationService performanceInformationService) {
+ this.performanceInformationService = performanceInformationService;
+ }
+
private final String[] PerformanceCSVHeaders = {"version",
"eventName","domain","eventId","eventType","nfcNamingCode",
"nfNamingCode","sourceId","sourceName","reportingEntityId",
@@ -142,75 +151,6 @@ public class PerformanceController {
}
}
- @ResponseBody
- @RequestMapping(value = {"/performance/diagram/{unit}/{eventId}"}, method = RequestMethod.GET, produces = "application/json")
- public String generateDiagram(@PathVariable String unit,@PathVariable String eventId) throws ParseException, JsonProcessingException {
- Map<String,List<Integer>> diagramSource = new HashMap<>();
- String[] names = {"cpu","network","disk","memory"};
- switch (unit){
- case "hour":
- for(int i = 0 ; i < 4 ; i++){
- Date startDateHour = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,1,1,-1,0,0));
- Date endDateHour = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,1,1,-1,0,0));
- endDateHour = DateUtils.stringToDate(DateUtils.addDate(endDateHour,"minute",15));
- List<Integer> values = new ArrayList<>();
- for (int j = 0 ; j < 4 ; j++){
- logger.info(DateUtils.dateToString(startDateHour));
- logger.info(DateUtils.dateToString(endDateHour));
- values.add(performanceInformationService.queryDataBetweenSum(eventId,names[i],startDateHour,endDateHour));
- startDateHour = DateUtils.stringToDate(DateUtils.addDate(startDateHour,"minute",15));
- endDateHour = DateUtils.stringToDate(DateUtils.addDate(endDateHour,"minute",15));
- }
- diagramSource.put(names[i],values);
- }
- break;
- case "day":
- for(int i = 0 ; i < 4 ; i++){
- Date startDateDay = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,1,-1,0,0,0));
- Date endDateDay = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,1,-1,0,0,0));
- endDateDay = DateUtils.stringToDate(DateUtils.addDate(endDateDay,"hour",1));
- List<Integer> values = new ArrayList<>();
- for (int j = 0 ; j < 24 ; j++){
- values.add(performanceInformationService.queryDataBetweenSum(eventId,names[i],startDateDay,endDateDay));
- startDateDay = DateUtils.stringToDate(DateUtils.addDate(startDateDay,"hour",1));
- endDateDay = DateUtils.stringToDate(DateUtils.addDate(endDateDay,"hour",1));
- }
- diagramSource.put(names[i],values);
- }
- break;
- case "month":
- for(int i = 0 ; i < 4 ; i++){
- Date startDateMonth = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,-1,0,0,0,0));
- Date endDateMonth = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,-1,0,0,0,0));
- endDateMonth = DateUtils.stringToDate(DateUtils.addDate(endDateMonth,"day",1));
- List<Integer> values = new ArrayList<>();
- for (int j = 0 ; j < 31 ; j++){
- values.add(performanceInformationService.queryDataBetweenSum(eventId,names[i],startDateMonth,endDateMonth));
- startDateMonth = DateUtils.stringToDate(DateUtils.addDate(startDateMonth,"day",1));
- endDateMonth = DateUtils.stringToDate(DateUtils.addDate(endDateMonth,"day",1));
- }
- diagramSource.put(names[i],values);
- }
- break;
- case "year":
- for(int i = 0 ; i < 4 ; i++){
- Date startDateYear = DateUtils.stringToDate(DateUtils.initDate(new Date(),-1,0,0,0,0,0));
- Date endDateYear = DateUtils.stringToDate(DateUtils.initDate(new Date(),-1,0,0,0,0,0));
- endDateYear = DateUtils.stringToDate(DateUtils.addDate(endDateYear,"month",1));
- List<Integer> values = new ArrayList<>();
- for (int j = 0 ; j < 12 ; j++){
- values.add(performanceInformationService.queryDataBetweenSum(eventId,names[i],startDateYear,endDateYear));
- startDateYear = DateUtils.stringToDate(DateUtils.addDate(startDateYear,"month",1));
- endDateYear = DateUtils.stringToDate(DateUtils.addDate(endDateYear,"month",1));
- }
- diagramSource.put(names[i],values);
- }
- break;
- }
- omPerformance.setDateFormat(new SimpleDateFormat(Constant.DATE_FORMAT));
- return omPerformance.writeValueAsString(diagramSource);
- }
-
@RequestMapping(value = {"/performance/diagram"}, method = RequestMethod.POST, produces = "application/json")
public String generateDiagram(@RequestParam String sourceId,@RequestParam String startTime,@RequestParam String endTime,@RequestParam String nameParent,@RequestParam String format) {
long timeInterval = 0;
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java
index d290708c..0daf2c9c 100755
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java
@@ -395,7 +395,7 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
@Override
public String queryStatusCount(String status) {
- try(Session session = sessionFactory.openSession()){
+ try(Session session = getSession()){
String hql = "select count(status) from AlarmsHeader a";
if (!status.equals("0"))
hql+=" where a.status = :status";
@@ -411,7 +411,7 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
@Override
public AlarmsHeader getAlarmsHeaderById(String id) {
- try(Session session = sessionFactory.openSession()) {
+ try(Session session = getSession()) {
String string = "from AlarmsHeader a where 1=1 and a.id=:id";
Query q = session.createQuery(string);
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java
index 9a30b212..618fdedb 100755
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java
@@ -310,7 +310,7 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
@Override
public PerformanceHeader getPerformanceHeaderById(String id) {
- try(Session session = sessionFactory.openSession()) {
+ try(Session session = getSession()) {
String string = "from PerformanceHeader a where 1=1 and a.id=:id";
Query q = session.createQuery(string);
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/SaveOrUpdateOperationRsp.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/SaveOrUpdateOperationRsp.java
index ed718e66..b5584d8f 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/SaveOrUpdateOperationRsp.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/SaveOrUpdateOperationRsp.java
@@ -29,4 +29,9 @@ public class SaveOrUpdateOperationRsp {
public void setOperationId(String operationId) {
this.operationId = operationId;
}
+
+ @Override
+ public String toString() {
+ return "SaveOrUpdateOperationRsp [operationId=" + operationId + "]";
+ }
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmService.java
index 1e9895de..498650ab 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmService.java
@@ -114,6 +114,7 @@ public class DefaultServiceLcmService implements ServiceLcmService {
Response<SaveOrUpdateOperationRsp> response = soService.scaleService(serviceId,requestBody).execute();
logger.info("so scale has finished");
if(response.isSuccessful()){
+ logger.info("scaleService response content is :"+response.body().toString());
return response.body();
}else{
logger.error(String.format("Can not scaleService service[code=%s, message=%s]", response.code(), response.message()));
diff --git a/server/src/test/java/org/onap/usecaseui/server/bean/AlarmsHeaderTest.java b/server/src/test/java/org/onap/usecaseui/server/bean/AlarmsHeaderTest.java
index 2b8afa39..a3c7b746 100644
--- a/server/src/test/java/org/onap/usecaseui/server/bean/AlarmsHeaderTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/bean/AlarmsHeaderTest.java
@@ -81,6 +81,7 @@ public class AlarmsHeaderTest {
ah.getVfStatus();
ah.getAlarmInterfaceA();
ah.getStatus();
+ ah.getId();
}
@Test
@@ -112,5 +113,6 @@ public class AlarmsHeaderTest {
ah.setStatus("");
ah.setStartEpochMicrosec(DateUtils.now().getTime()+"");
ah.setLastEpochMicroSec(DateUtils.now().getTime()+"");
+ ah.setId("");
}
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/bean/AlarmsInformationTest.java b/server/src/test/java/org/onap/usecaseui/server/bean/AlarmsInformationTest.java
index 6f7274c6..40ff78ac 100644
--- a/server/src/test/java/org/onap/usecaseui/server/bean/AlarmsInformationTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/bean/AlarmsInformationTest.java
@@ -15,30 +15,11 @@
*/
package org.onap.usecaseui.server.bean;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-import org.junit.runner.RunWith;
-import org.onap.usecaseui.server.UsecaseuiServerApplication;
-import org.onap.usecaseui.server.bean.AlarmsInformation;
-import org.onap.usecaseui.server.util.DateUtils;
-import org.onap.usecaseui.server.util.Page;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.io.*;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
+import java.io.Serializable;
-import mockit.Mock;
-import mockit.MockUp;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
public class AlarmsInformationTest implements Serializable {
@@ -59,6 +40,7 @@ public class AlarmsInformationTest implements Serializable {
ai.getStartEpochMicroSec();
ai.getLastEpochMicroSec();
ai.getId();
+ ai.setHeaderId("");
ai.toString();
}
@@ -71,5 +53,6 @@ public class AlarmsInformationTest implements Serializable {
ai.setStartEpochMicroSec("");;
ai.setLastEpochMicroSec("");;
ai.setId(1);
+ ai.setHeaderId("");
}
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/bean/PerformanceHeaderTest.java b/server/src/test/java/org/onap/usecaseui/server/bean/PerformanceHeaderTest.java
index 7710aacc..24d1242e 100644
--- a/server/src/test/java/org/onap/usecaseui/server/bean/PerformanceHeaderTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/bean/PerformanceHeaderTest.java
@@ -15,30 +15,12 @@
*/
package org.onap.usecaseui.server.bean;
-import org.junit.Test;
-import org.junit.Before;
+import java.io.Serializable;
+
import org.junit.After;
-import org.junit.runner.RunWith;
-import org.onap.usecaseui.server.UsecaseuiServerApplication;
-import org.onap.usecaseui.server.bean.PerformanceHeader;
+import org.junit.Before;
+import org.junit.Test;
import org.onap.usecaseui.server.util.DateUtils;
-import org.onap.usecaseui.server.util.Page;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.io.*;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-
-import mockit.Mock;
-import mockit.MockUp;
public class PerformanceHeaderTest implements Serializable {
@@ -73,6 +55,7 @@ public class PerformanceHeaderTest implements Serializable {
ph.getSequence();
ph.getMeasurementsForVfScalingVersion();
ph.getMeasurementInterval();
+ ph.getId();
}
@Test
@@ -95,5 +78,6 @@ public class PerformanceHeaderTest implements Serializable {
ph.setSequence("");
ph.setMeasurementsForVfScalingVersion("");
ph.setMeasurementInterval("");
+ ph.setId("");
}
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/bean/PerformanceInformationTest.java b/server/src/test/java/org/onap/usecaseui/server/bean/PerformanceInformationTest.java
index 245272f2..e134e747 100644
--- a/server/src/test/java/org/onap/usecaseui/server/bean/PerformanceInformationTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/bean/PerformanceInformationTest.java
@@ -15,30 +15,11 @@
*/
package org.onap.usecaseui.server.bean;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-import org.junit.runner.RunWith;
-import org.onap.usecaseui.server.UsecaseuiServerApplication;
-import org.onap.usecaseui.server.bean.PerformanceInformation;
-import org.onap.usecaseui.server.util.DateUtils;
-import org.onap.usecaseui.server.util.Page;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.io.*;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
+import java.io.Serializable;
-import mockit.Mock;
-import mockit.MockUp;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
public class PerformanceInformationTest implements Serializable {
@@ -59,6 +40,7 @@ public class PerformanceInformationTest implements Serializable {
pi.getStartEpochMicrosec();
pi.getLastEpochMicroSec();
pi.getId();
+ pi.getHeaderId();
}
@Test
@@ -70,6 +52,7 @@ public class PerformanceInformationTest implements Serializable {
pi.setStartEpochMicrosec("");;
pi.setLastEpochMicroSec("");;
pi.setId(1);
+ pi.setHeaderId("");
}
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/bean/lcm/TemplateInputTest.java b/server/src/test/java/org/onap/usecaseui/server/bean/lcm/TemplateInputTest.java
index c2ffad8c..d9062be4 100644
--- a/server/src/test/java/org/onap/usecaseui/server/bean/lcm/TemplateInputTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/bean/lcm/TemplateInputTest.java
@@ -65,6 +65,7 @@ public class TemplateInputTest {
@Test
public void testSetTemplateInput() throws Exception {
TemplateInput ti = new TemplateInput("name", "type", "description", "isRequired", "defaultValue");
- ti.equals(ti);
+ TemplateInput ti2 = new TemplateInput("names", "types", "descriptions", "isRequireds", "defaultValues");
+ System.out.println(ti.equals(ti2));
}
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/bean/lcm/VfNsPackageInfoTest.java b/server/src/test/java/org/onap/usecaseui/server/bean/lcm/VfNsPackageInfoTest.java
index 65c317ea..9ef7dcc2 100644
--- a/server/src/test/java/org/onap/usecaseui/server/bean/lcm/VfNsPackageInfoTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/bean/lcm/VfNsPackageInfoTest.java
@@ -15,30 +15,9 @@
*/
package org.onap.usecaseui.server.bean.lcm;
-import org.junit.Test;
-import org.junit.Before;
import org.junit.After;
-import org.junit.runner.RunWith;
-import org.onap.usecaseui.server.UsecaseuiServerApplication;
-import org.onap.usecaseui.server.bean.lcm.*;
-import org.onap.usecaseui.server.util.DateUtils;
-import org.onap.usecaseui.server.util.Page;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.io.*;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-
-import mockit.Mock;
-import mockit.MockUp;
+import org.junit.Before;
+import org.junit.Test;
public class VfNsPackageInfoTest {
diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java
index ecda5354..e48197e4 100755
--- a/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/controller/AlarmControllerTest.java
@@ -15,59 +15,37 @@
*/
package org.onap.usecaseui.server.controller;
-import org.junit.Test;
-import org.junit.Before;
+import static org.mockito.Mockito.mock;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.onap.usecaseui.server.bean.AlarmsHeader;
import org.onap.usecaseui.server.bean.AlarmsInformation;
import org.onap.usecaseui.server.service.AlarmsHeaderService;
import org.onap.usecaseui.server.service.AlarmsInformationService;
-import org.onap.usecaseui.server.util.DateUtils;
import org.onap.usecaseui.server.util.Page;
-import java.util.*;
-
-import mockit.Mock;
-import mockit.MockUp;
-
public class AlarmControllerTest {
AlarmController controller = null;
+ AlarmsHeaderService service;
+ AlarmsInformationService alService;
@Before
public void before() throws Exception {
controller = new AlarmController();
+ service = mock(AlarmsHeaderService.class);
+ alService = mock(AlarmsInformationService.class);
+ controller.setAlarmsHeaderService(service);
+ controller.setAlarmsInformationService(alService);
- new MockUp<AlarmsHeaderService>() {
- @Mock
- public Page<AlarmsHeader> queryAlarmsHeader(AlarmsHeader alarmsHeader, int currentPage, int pageSize) {
- AlarmsHeader ah = new AlarmsHeader("sourceId");
- List<AlarmsHeader> list = new ArrayList<>();
- list.add(ah);
- Page<AlarmsHeader> resultPage = new Page<AlarmsHeader>();
- resultPage.setList(list);
- return resultPage;
- }
- @Mock
- public List<AlarmsHeader> queryId(String[] id) {
- AlarmsHeader ah = new AlarmsHeader();
- return Arrays.asList(ah);
- }
- };
- new MockUp<AlarmsInformationService>() {
- @Mock
- public Page<AlarmsInformation> queryAlarmsInformation(AlarmsInformation alarmsInformation, int currentPage, int pageSize) {
- return new Page<AlarmsInformation>();
- }
- @Mock
- public List<Map<String,String>> queryDateBetween(String sourceId, String startTime, String endTime) {
- Map<String,String> map = new HashMap<String,String>();
- map.put("name", "value");
- List<Map<String,String>> resultList = new ArrayList<>();
- resultList.add(map);
- return resultList;
- }
- };
}
@After
@@ -101,9 +79,28 @@ public class AlarmControllerTest {
@Test
public void testGenDiagram() throws Exception {
try {
- controller.diagram("sourceId", "startTime", "endTime","format");
+ controller.diagram("sourceId", "2018-5-24 14:58:29", "2018-5-25 14:58:29", "day");
+ controller.diagram("sourceId", "2018-5-24 14:58:29", "2018-5-25 14:58:29", "hour");
+ controller.diagram("sourceId", "2018-5-24 14:58:29", "2018-5-25 14:58:29","month");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ @Test
+ public void testStatusCount() throws Exception {
+ try {
+ controller.getStatusCount();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ @Test
+ public void testGetAlarmsHeaderDetail() throws Exception {
+ try {
+ controller.getAlarmsHeaderDetail("33a8353381bb4e8fabbc739f9f7e02bf");
} catch (Exception e) {
e.printStackTrace();
}
}
+
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java
index ab2f5de5..c18ae944 100755
--- a/server/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/controller/PerformanceControllerTest.java
@@ -15,61 +15,33 @@
*/
package org.onap.usecaseui.server.controller;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Date;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import javax.servlet.http.HttpServletResponse;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.usecaseui.server.bean.PerformanceHeader;
-import org.onap.usecaseui.server.bean.PerformanceInformation;
import org.onap.usecaseui.server.service.PerformanceHeaderService;
import org.onap.usecaseui.server.service.PerformanceInformationService;
-import org.onap.usecaseui.server.util.Page;
-import mockit.Mock;
-import mockit.MockUp;
+import com.fasterxml.jackson.core.JsonProcessingException;
public class PerformanceControllerTest {
- PerformanceController controller = null;
-
+ PerformanceController controller;
+ PerformanceHeaderService phs;
+ PerformanceInformationService pihs;
@Before
public void before() throws Exception {
controller = new PerformanceController();
-
- new MockUp<PerformanceHeaderService>() {
- @Mock
- public Page<PerformanceHeader> queryPerformanceHeader(PerformanceHeader performanceHeder, int currentPage, int pageSize) {
- return new Page<PerformanceHeader>();
- }
- @Mock
- public List<PerformanceHeader> queryId(String[] id) {
- PerformanceHeader ph = new PerformanceHeader();
- return Arrays.asList(ph);
- }
- @Mock
- public List<String> queryAllSourceId() {
- String str = "abc";
- return Arrays.asList(str);
- }
- };
- new MockUp<PerformanceInformationService>() {
- @Mock
- public Page<PerformanceInformation> queryPerformanceInformation(PerformanceInformation performanceInformation, int currentPage, int pageSize) {
- return new Page<PerformanceInformation>();
- }
- @Mock
- public int queryDataBetweenSum(String eventId, String name, Date startDate, Date endDate) {
- return 1;
- }
- @Mock
- public List<PerformanceInformation> queryDateBetween(String resourceId, String name, String startTime, String endTime) {
- PerformanceInformation pi = new PerformanceInformation();
- return Arrays.asList(pi);
- }
- };
+ phs=mock(PerformanceHeaderService.class);
+ pihs =mock(PerformanceInformationService.class);
+ controller.setPerformanceHeaderService(phs);
+ controller.setPerformanceInformationService(pihs);
}
@After
@@ -79,11 +51,9 @@ public class PerformanceControllerTest {
@Test
public void testGenerateDiagram() {
try {
- controller.generateDiagram("hour", "eventId");
- controller.generateDiagram("day", "eventId");
- controller.generateDiagram("month", "eventId");
- controller.generateDiagram("year", "eventId");
- controller.generateDiagram("sourceId", "startTime", "endTime", "nameParent", "nameChild");
+ controller.generateDiagram("sourceId", "2018-5-24 14:58:29", "2018-5-25 14:58:29", "nameParent", "day");
+ controller.generateDiagram("sourceId", "2018-5-24 14:58:29", "2018-5-25 14:58:29", "nameParent", "hour");
+ controller.generateDiagram("sourceId", "2018-5-24 14:58:29", "2018-5-25 14:58:29", "nameParent", "minute");
} catch (Exception e) {
e.printStackTrace();
}
@@ -93,15 +63,45 @@ public class PerformanceControllerTest {
public void testGetSourceIds() {
try {
controller.getSourceIds();
+ verify(phs,times(1)).queryAllSourceId();
} catch (Exception e) {
e.printStackTrace();
}
}
+ @Test
+ public void testGetPerformanceData() throws JsonProcessingException {
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ int currentPage = 1;
+ int pageSize=12;
+ String sourceId="uui_test_vm5";
+ String sourceName="2b8957a6-46d4-4e91-8d50-17c29e8583ac";
+ String priority="Normal";
+ String startTime="1521678529000";
+ String endTime="1521680329000";
+ PerformanceHeader header = new PerformanceHeader();
+
+
+ controller.getPerformanceData(response,currentPage,pageSize,sourceId,sourceName,priority,startTime,endTime);
+ controller.getPerformanceData(response,currentPage,pageSize,null,null,null,null,null);
+ verify(phs,times(1)).queryPerformanceHeader(header,currentPage,pageSize);
+
+}
@Test
public void testGetNames() {
try {
- controller.getNames("sourceId");
+ controller.getNames("vnf_test_3");
+ verify(pihs,times(1)).queryDateBetween("vnf_test_3",null,null,null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ @Test
+ public void testGetPerformanceHeaderDetail() {
+ try {
+ controller.getPerformanceHeaderDetail("0a573f09d50f46adaae0c10e741fea4d");
+ verify(phs,times(1)).getPerformanceHeaderById("0a573f09d50f46adaae0c10e741fea4d");
+ verify(pihs,times(1)).getAllPerformanceInformationByHeaderId("0a573f09d50f46adaae0c10e741fea4d");
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImplTest.java
index 7302ee93..2023ffeb 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImplTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImplTest.java
@@ -15,19 +15,20 @@
*/
package org.onap.usecaseui.server.service.impl;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-import org.onap.usecaseui.server.bean.AlarmsHeader;
-import org.onap.usecaseui.server.service.impl.AlarmsHeaderServiceImpl;
-import org.onap.usecaseui.server.util.DateUtils;
+import java.io.Serializable;
+import java.sql.Timestamp;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
-import java.util.*;
-import java.io.*;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.usecaseui.server.bean.AlarmsHeader;
import mockit.Mock;
import mockit.MockUp;
@@ -140,6 +141,7 @@ public class AlarmsHeaderServiceImplTest {
try {
AlarmsHeader ah = null;
alarmsHeaderServiceImpl.saveAlarmsHeader(ah);
+ alarmsHeaderServiceImpl.saveAlarmsHeader(new AlarmsHeader());
} catch (Exception e) {
e.printStackTrace();
}
@@ -150,6 +152,7 @@ public class AlarmsHeaderServiceImplTest {
try {
AlarmsHeader ah = null;
alarmsHeaderServiceImpl.updateAlarmsHeader(ah);
+ alarmsHeaderServiceImpl.updateAlarmsHeader(new AlarmsHeader());
} catch (Exception e) {
e.printStackTrace();
}
@@ -238,4 +241,37 @@ public class AlarmsHeaderServiceImplTest {
e.printStackTrace();
}
}
+
+ @Test
+ public void testGetAlarmsHeaderById() throws Exception {
+ try {
+ alarmsHeaderServiceImpl.getAlarmsHeaderById(null);
+ alarmsHeaderServiceImpl.getAlarmsHeaderById("1e578e892ebf4bcdbdd3e71fbad2a202");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testQueryStatusCount() throws Exception {
+ try {
+ alarmsHeaderServiceImpl.queryStatusCount(null);
+ alarmsHeaderServiceImpl.queryStatusCount("active");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testUpdateAlarmsHeader2018() throws Exception {
+ try {
+ Long l = System.currentTimeMillis();
+
+ Timestamp date_get = new Timestamp(l);
+ alarmsHeaderServiceImpl.updateAlarmsHeader2018(null, null, null, null, null, null, null);
+ alarmsHeaderServiceImpl.updateAlarmsHeader2018("close",date_get,"1527145109000", "1527145109000", "eventName","reportingEntityName","specificProblem");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java
index 9233f0d9..49d3fa46 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java
@@ -15,19 +15,19 @@
*/
package org.onap.usecaseui.server.service.impl;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-import org.onap.usecaseui.server.bean.AlarmsInformation;
-import org.onap.usecaseui.server.service.impl.AlarmsInformationServiceImpl;
-import org.onap.usecaseui.server.util.DateUtils;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
-import java.util.*;
-import java.io.*;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.usecaseui.server.bean.AlarmsInformation;
import mockit.Mock;
import mockit.MockUp;
@@ -209,4 +209,14 @@ public class AlarmsInformationServiceImplTest {
e.printStackTrace();
}
}
+
+ @Test
+ public void testGetAllAlarmsInformationByHeaderId() throws Exception {
+ try {
+ alarmsInformationServiceImpl.getAllAlarmsInformationByHeaderId(null);
+ alarmsInformationServiceImpl.getAllAlarmsInformationByHeaderId("headerId");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImplTest.java
index 78dbf941..7b980221 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImplTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImplTest.java
@@ -139,7 +139,9 @@ public class PerformanceHeaderServiceImplTest {
public void testSavePerformanceHeader() throws Exception {
try {
PerformanceHeader ph = null;
+ PerformanceHeader phNew = new PerformanceHeader();
performanceHeaderServiceImpl.savePerformanceHeader(ph);
+ performanceHeaderServiceImpl.savePerformanceHeader(phNew);
} catch (Exception e) {
e.printStackTrace();
}
@@ -149,7 +151,9 @@ public class PerformanceHeaderServiceImplTest {
public void testUpdatePerformanceHeader() throws Exception {
try {
PerformanceHeader ph = null;
+ PerformanceHeader phNew = new PerformanceHeader();
performanceHeaderServiceImpl.updatePerformanceHeader(ph);
+ performanceHeaderServiceImpl.updatePerformanceHeader(phNew);
} catch (Exception e) {
e.printStackTrace();
}
@@ -185,6 +189,10 @@ public class PerformanceHeaderServiceImplTest {
ph.setStartEpochMicrosec("");;
ph.setLastEpochMicroSec("");;
performanceHeaderServiceImpl.getAllCount(ph, 1, 1);
+
+ PerformanceHeader phNew = new PerformanceHeader();
+ performanceHeaderServiceImpl.getAllCount(phNew, 1, 1);
+ performanceHeaderServiceImpl.getAllCount(null, 1, 1);
} catch (Exception e) {
e.printStackTrace();
}
@@ -213,7 +221,11 @@ public class PerformanceHeaderServiceImplTest {
ph.setEventType("");
ph.setStartEpochMicrosec("");;
ph.setLastEpochMicroSec("");;
- performanceHeaderServiceImpl.queryPerformanceHeader(ph, 1, 1);
+ performanceHeaderServiceImpl.queryPerformanceHeader(ph, 1, 10);
+
+ PerformanceHeader phNew = new PerformanceHeader();
+ performanceHeaderServiceImpl.queryPerformanceHeader(phNew, 1, 1);
+ performanceHeaderServiceImpl.queryPerformanceHeader(null, 1, 1);
} catch (Exception e) {
e.printStackTrace();
}
@@ -237,4 +249,13 @@ public class PerformanceHeaderServiceImplTest {
e.printStackTrace();
}
}
+
+ @Test
+ public void testGetPerformanceHeaderById() throws Exception {
+ try {
+ performanceHeaderServiceImpl.getPerformanceHeaderById("0a573f09d50f46adaae0c10e741fea4d");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java
index 24e9e0d3..08a9c8b2 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImplTest.java
@@ -219,4 +219,23 @@ public class PerformanceInformationServiceImplTest {
e.printStackTrace();
}
}
+
+ @Test
+ public void testQueryMaxValueByBetweenDate() throws Exception {
+ try {
+ performanceInformationServiceImpl.queryMaxValueByBetweenDate("", "","","");
+ performanceInformationServiceImpl.queryMaxValueByBetweenDate("eventId", "name","1527151520000","1527151620000");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testGetAllPerformanceInformationByHeaderId() throws Exception {
+ try {
+ performanceInformationServiceImpl.getAllPerformanceInformationByHeaderId("0a573f09d50f46adaae0c10e741fea4d");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerServiceTest.java
index f0838005..6ba2fa35 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerServiceTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerServiceTest.java
@@ -15,6 +15,15 @@
*/
package org.onap.usecaseui.server.service.lcm.impl;
+import static java.util.Collections.singletonList;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.usecaseui.server.util.CallStub.emptyBodyCall;
+import static org.onap.usecaseui.server.util.CallStub.failedCall;
+import static org.onap.usecaseui.server.util.CallStub.successfulCall;
+
+import java.util.List;
+
import org.junit.Assert;
import org.junit.Test;
import org.onap.usecaseui.server.service.lcm.CustomerService;
@@ -24,16 +33,8 @@ import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomerRsp;
import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIServiceSubscription;
import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceSubscriptionRsp;
import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException;
-import retrofit2.Call;
-import java.util.List;
-
-import static java.util.Collections.singletonList;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.onap.usecaseui.server.util.CallStub.emptyBodyCall;
-import static org.onap.usecaseui.server.util.CallStub.failedCall;
-import static org.onap.usecaseui.server.util.CallStub.successfulCall;
+import retrofit2.Call;
public class DefaultCustomerServiceTest {
@@ -99,6 +100,7 @@ public class DefaultCustomerServiceTest {
@Test
public void itWillRetrieveEmptyListWhenNoServiceSubscriptionsInAAI() {
+ DefaultCustomerService dc = new DefaultCustomerService();
AAIService aaiService = mock(AAIService.class);
Call<ServiceSubscriptionRsp> call = emptyBodyCall();
when(aaiService.listServiceSubscriptions("1")).thenReturn(call);
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceServiceTest.java
index 0304e42d..a8e2dd45 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceServiceTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceServiceTest.java
@@ -72,4 +72,30 @@ public class DefaultServiceInstanceServiceTest {
Assert.assertTrue("service instances should be empty.", serviceInstances.isEmpty());
}
+
+ @Test(expected = AAIException.class)
+ public void getRelationShipDataWillThrowExceptionWhenAAIIsNotAvailable() {
+ AAIService aaiService = mock(AAIService.class);
+ String customerId = "1";
+ String serviceType = "service";
+ String result="result";
+ when(aaiService.getAAIServiceInstance(customerId, serviceType,result)).thenReturn(failedCall("AAI is not available!"));
+
+ ServiceInstanceService service = new DefaultServiceInstanceService(aaiService);
+ service.getRelationShipData(customerId, serviceType,result);
+ }
+
+ @Test
+ public void getRelationShipDataWillThrowExceptionWhenNoServiceInstancesInAAI() {
+ AAIService aaiService = mock(AAIService.class);
+ String customerId = "1";
+ String serviceType = "service";
+ String result="result";
+ when(aaiService.getAAIServiceInstance(customerId, serviceType,result)).thenReturn(emptyBodyCall());
+
+ ServiceInstanceService service = new DefaultServiceInstanceService(aaiService);
+ String aa = service.getRelationShipData(customerId, serviceType,result);
+
+ Assert.assertTrue("service instances should be empty.", aa.isEmpty());
+ }
} \ No newline at end of file
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmServiceTest.java
index 517e4b1c..1bfe5e35 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmServiceTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmServiceTest.java
@@ -22,6 +22,7 @@ import org.onap.usecaseui.server.service.lcm.domain.so.SOService;
import org.onap.usecaseui.server.service.lcm.domain.so.bean.DeleteOperationRsp;
import org.onap.usecaseui.server.service.lcm.domain.so.bean.Operation;
import org.onap.usecaseui.server.service.lcm.domain.so.bean.OperationProgressInformation;
+import org.onap.usecaseui.server.service.lcm.domain.so.bean.SaveOrUpdateOperationRsp;
import org.onap.usecaseui.server.service.lcm.domain.so.bean.ServiceOperation;
import org.onap.usecaseui.server.service.lcm.domain.so.exceptions.SOException;
@@ -181,4 +182,80 @@ public class DefaultServiceLcmServiceTest {
service.queryOperationProgress(serviceId, operationId);
}
+
+ @Test(expected = SOException.class)
+ public void scaleServiceWillThrowExceptionWhenSOIsNotAvailable() throws IOException {
+ SOService soService = mock(SOService.class);
+ String serviceId = "1";
+ when(soService.scaleService(eq(serviceId), anyObject())).thenReturn(failedCall("SO is not available!"));
+ HttpServletRequest request = mockRequest();
+
+ ServiceLcmService service = new DefaultServiceLcmService(soService);
+
+ service.scaleService(serviceId, request);
+ }
+
+ @Test(expected = SOException.class)
+ public void scaleServiceWillThrowExceptionWhenSOResponseError() throws IOException {
+ SOService soService = mock(SOService.class);
+ String serviceId = "1";
+ when(soService.scaleService(eq(serviceId), anyObject())).thenReturn(emptyBodyCall());
+ HttpServletRequest request = mockRequest();
+
+ ServiceLcmService service = new DefaultServiceLcmService(soService);
+
+ service.scaleService(serviceId, request);
+ }
+
+ @Test
+ public void itCanScaleService() throws IOException {
+ SOService soService = mock(SOService.class);
+ String serviceId = "1";
+ SaveOrUpdateOperationRsp rsp = new SaveOrUpdateOperationRsp();
+ rsp.setOperationId("1");
+ when(soService.scaleService(eq(serviceId), anyObject())).thenReturn(successfulCall(rsp));
+ HttpServletRequest request = mockRequest();
+
+ ServiceLcmService service = new DefaultServiceLcmService(soService);
+
+ Assert.assertSame(rsp, service.scaleService(serviceId, request));
+ }
+
+ @Test(expected = SOException.class)
+ public void updateServiceWillThrowExceptionWhenSOIsNotAvailable() throws IOException {
+ SOService soService = mock(SOService.class);
+ String serviceId = "1";
+ when(soService.updateService(eq(serviceId), anyObject())).thenReturn(failedCall("SO is not available!"));
+ HttpServletRequest request = mockRequest();
+
+ ServiceLcmService service = new DefaultServiceLcmService(soService);
+
+ service.updateService(serviceId, request);
+ }
+
+ @Test(expected = SOException.class)
+ public void updateServiceWillThrowExceptionWhenSOResponseError() throws IOException {
+ SOService soService = mock(SOService.class);
+ String serviceId = "1";
+ when(soService.updateService(eq(serviceId), anyObject())).thenReturn(emptyBodyCall());
+ HttpServletRequest request = mockRequest();
+
+ ServiceLcmService service = new DefaultServiceLcmService(soService);
+
+ service.updateService(serviceId, request);
+ }
+
+ @Test
+ public void itCanUpdateService() throws IOException {
+ SOService soService = mock(SOService.class);
+ String serviceId = "1";
+ SaveOrUpdateOperationRsp rsp = new SaveOrUpdateOperationRsp();
+ rsp.setOperationId("1");
+ when(soService.updateService(eq(serviceId), anyObject())).thenReturn(successfulCall(rsp));
+ HttpServletRequest request = mockRequest();
+
+ ServiceLcmService service = new DefaultServiceLcmService(soService);
+
+ Assert.assertSame(rsp, service.updateService(serviceId, request));
+ }
} \ No newline at end of file
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java
index ac0d2694..0534838a 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java
@@ -16,9 +16,11 @@
package org.onap.usecaseui.server.service.lcm.impl;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput;
import org.onap.usecaseui.server.bean.lcm.TemplateInput;
+import org.onap.usecaseui.server.service.impl.AlarmsInformationServiceImpl;
import org.onap.usecaseui.server.service.lcm.ServiceTemplateService;
import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
import org.onap.usecaseui.server.service.lcm.domain.aai.bean.SDNCController;
@@ -49,7 +51,12 @@ import static org.onap.usecaseui.server.util.CallStub.failedCall;
import static org.onap.usecaseui.server.util.CallStub.successfulCall;
public class DefaultServiceTemplateServiceTest {
-
+
+ DefaultServiceTemplateService dsts = null;
+ @Before
+ public void before() throws Exception {
+ dsts = new DefaultServiceTemplateService();
+ }
@Test
public void itCanListDistributedServiceTemplate() {
List<SDCServiceTemplate> templates = Collections.singletonList(new SDCServiceTemplate("uuid", "uuid", "name", "V1","url", "category"));
@@ -286,4 +293,9 @@ public class DefaultServiceTemplateServiceTest {
ServiceTemplateService service = new DefaultServiceTemplateService(null,aaiService);
service.listSDNCControllers();
}
+
+ @Test(expected = AAIException.class)
+ public void testDownloadFile() throws IOException {
+ dsts.downloadFile("toscaModelPath", "toPath");
+ }
} \ No newline at end of file
diff --git a/server/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java b/server/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java
index d7ffe3de..15fda126 100755
--- a/server/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/util/DateUtilsTest.java
@@ -62,4 +62,30 @@ public class DateUtilsTest {
e.printStackTrace();
}
}
+ @Test
+ public void TestGetYearMonthDayHourMinuteSecond(){
+ System.out.println(DateUtils.getYearMonthDayHourMinuteSecond(1527145109000L));
+ System.out.println(DateUtils.getYearMonthDayHourMinuteSecond(1514736000000L));
+ }
+ @Test
+ public void TestGetResultDate(){
+ System.out.println(DateUtils.getResultDate(1514736000000L,"yyyy-MM-dd"));
+ System.out.println(DateUtils.getResultDate(1527145109000L,"month"));
+ System.out.println(DateUtils.getResultDate(1527145109000L,"day"));
+ System.out.println(DateUtils.getResultDate(1527145109000L,"minute"));
+ System.out.println(DateUtils.getResultDate(1527145109000L,"hour"));
+ }
+ @Test
+ public void TestMonthOfDay(){
+ System.out.println(DateUtils.MonthOfDay("2018-02-12","yyyy-MM-dd"));
+ System.out.println(DateUtils.MonthOfDay("dateTime","yyyy-MM-dd"));
+ }
+
+ @Test
+ public void TestAddDate() throws ParseException{
+ DateUtils.addDate(new Date(), "year", 1);
+ DateUtils.addDate(new Date(), "day", 1);
+ DateUtils.addDate(new Date(), "hour", 1);
+ DateUtils.addDate(new Date(), "minute", 1);
+ }
}
diff --git a/server/src/test/java/org/onap/usecaseui/server/util/PageTest.java b/server/src/test/java/org/onap/usecaseui/server/util/PageTest.java
new file mode 100644
index 00000000..7f2f97b7
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/util/PageTest.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2017 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;
+
+import org.junit.Test;
+import org.onap.usecaseui.server.bean.AlarmsHeader;
+
+public class PageTest {
+
+ @Test
+ public void testPageGet(){
+ Page<AlarmsHeader> resultPage = new Page<AlarmsHeader>();
+ resultPage.setTotalRecords(20);
+ resultPage.setPageSize(5);
+ resultPage.setPageNo(5);
+
+ resultPage.getList();
+ resultPage.getTotalRecords();
+ resultPage.getPageSize();
+ resultPage.getPageNo();
+ resultPage.getTotalPages();
+ int topPage=resultPage.getTopageNo();
+ resultPage.getPreviousPageNo();
+ resultPage.getBottomPageNo();
+ resultPage.getNextPageNo();
+ }
+}
diff --git a/server/src/test/java/org/onap/usecaseui/server/wrapper/AlarmWrapperTest.java b/server/src/test/java/org/onap/usecaseui/server/wrapper/AlarmWrapperTest.java
new file mode 100644
index 00000000..5b28ca23
--- /dev/null
+++ b/server/src/test/java/org/onap/usecaseui/server/wrapper/AlarmWrapperTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2017 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.wrapper;
+
+import org.junit.After;
+import org.junit.Before;
+import org.onap.usecaseui.server.bean.AlarmsHeader;
+import org.onap.usecaseui.server.bean.AlarmsInformation;
+
+public class AlarmWrapperTest {
+
+ @Before
+ public void before() throws Exception {
+ }
+
+ @After
+ public void after() throws Exception {
+ }
+
+ public void testGetAlarmWrapper(){
+ AlarmWrapper aw = new AlarmWrapper();
+ aw.getAlarmsHeader();
+ aw.getAlarmsInformation();
+ aw.getCurrentPage();
+ aw.getPageSize();
+ }
+
+ public void testSetAlarmWrapper(){
+ AlarmWrapper aw = new AlarmWrapper();
+ aw.setAlarmsHeader(new AlarmsHeader());;
+ aw.setAlarmsInformation(new AlarmsInformation());
+ aw.setCurrentPage(1);
+ aw.setPageSize(10);
+ }
+}
diff --git a/standalone/src/main/assembly/bin/run.sh b/standalone/src/main/assembly/bin/run.sh
index 25a83d59..95850849 100644
--- a/standalone/src/main/assembly/bin/run.sh
+++ b/standalone/src/main/assembly/bin/run.sh
@@ -21,8 +21,10 @@ echo @RUNHOME@ $RUNHOME
echo "Starting mysql"
service mysql start
-sleep 100
+sleep 10
+echo "grep initDB status"
+ps -fe | grep initDB.sh
SCRIPT="/home/uui/resources/bin/initDB.sh"
chmod 755 $SCRIPT
$SCRIPT root root 3306 127.0.0.1