@org.springframework.context.annotation.Configuration\r
@EnableAspectJAutoProxy\r
public class AlarmsInformationServiceImpl implements AlarmsInformationService {\r
- private static final Logger logger = LoggerFactory.getLogger(AlarmsInformationServiceImpl.class);\r
+ private static final Logger logger = LoggerFactory.getLogger(AlarmsInformationServiceImpl.class);\r
\r
- @Autowired\r
- private SessionFactory sessionFactory;\r
+ @Autowired\r
+ private SessionFactory sessionFactory;\r
+\r
+ private Session getSession() {\r
+ return sessionFactory.openSession();\r
+ }\r
\r
@Override\r
public String saveAlarmsInformation(AlarmsInformation alarmsInformation) {\r
- try(Session session = sessionFactory.openSession();){\r
- if (null == alarmsInformation) {\r
- logger.error("alarmsInformation saveAlarmsInformation alarmsInformation is null!");\r
- }\r
- logger.info("AlarmsInformationServiceImpl saveAlarmsInformation: alarmsInformation={}", alarmsInformation);\r
- Transaction tx = session.beginTransaction(); \r
- session.save(alarmsInformation);\r
- tx.commit();\r
- session.flush();\r
- return "1";\r
- } catch (Exception e) {\r
- logger.error("exception occurred while performing AlarmsInformationServiceImpl saveAlarmsInformation. Details:" + e.getMessage());\r
- return "0";\r
- }\r
- \r
+ try(Session session = getSession()){\r
+ if (null == alarmsInformation) {\r
+ logger.error("alarmsInformation saveAlarmsInformation alarmsInformation is null!");\r
+ }\r
+ logger.info("AlarmsInformationServiceImpl saveAlarmsInformation: alarmsInformation={}", alarmsInformation);\r
+ Transaction tx = session.beginTransaction();\r
+ session.save(alarmsInformation);\r
+ tx.commit();\r
+ session.flush();\r
+ return "1";\r
+ } catch (Exception e) {\r
+ logger.error("exception occurred while performing AlarmsInformationServiceImpl saveAlarmsInformation. Details:" + e.getMessage());\r
+ return "0";\r
+ }\r
+ \r
}\r
\r
@Override\r
public String updateAlarmsInformation(AlarmsInformation alarmsInformation) {\r
- try(Session session = sessionFactory.openSession();){\r
- if (null == alarmsInformation) {\r
- logger.error("alarmsInformation updateAlarmsInformation alarmsInformation is null!");\r
- }\r
- logger.info("AlarmsInformationServiceImpl updateAlarmsInformation: alarmsInformation={}", alarmsInformation);\r
- Transaction tx = session.beginTransaction(); \r
- session.update(alarmsInformation);\r
- tx.commit();\r
- session.flush();\r
- return "1";\r
- } catch (Exception e) {\r
- logger.error("exception occurred while performing AlarmsInformationServiceImpl updateAlarmsInformation. Details:" + e.getMessage());\r
- return "0";\r
- }\r
+ try(Session session = getSession()){\r
+ if (null == alarmsInformation) {\r
+ logger.error("alarmsInformation updateAlarmsInformation alarmsInformation is null!");\r
+ }\r
+ logger.info("AlarmsInformationServiceImpl updateAlarmsInformation: alarmsInformation={}", alarmsInformation);\r
+ Transaction tx = session.beginTransaction();\r
+ session.update(alarmsInformation);\r
+ tx.commit();\r
+ session.flush();\r
+ return "1";\r
+ } catch (Exception e) {\r
+ logger.error("exception occurred while performing AlarmsInformationServiceImpl updateAlarmsInformation. Details:" + e.getMessage());\r
+ return "0";\r
+ }\r
}\r
\r
\r
public int getAllCount(AlarmsInformation alarmsInformation, int currentPage, int pageSize) {\r
- try(Session session = sessionFactory.openSession();){\r
+ try(Session session = getSession()){\r
StringBuffer hql = new StringBuffer("select count(*) from AlarmsInformation a where 1=1");\r
if (null == alarmsInformation) {\r
- //logger.error("AlarmsInformationServiceImpl getAllCount alarmsInformation is null!");\r
- }else {\r
- if(null!=alarmsInformation.getName()) {\r
- String ver=alarmsInformation.getName();\r
- hql.append(" and a.name like '%"+ver+"%'");\r
- }\r
- if(null!=alarmsInformation.getValue()) {\r
- String ver=alarmsInformation.getValue();\r
- hql.append(" and a.value like '%"+ver+"%'");\r
- }\r
- if(null!=alarmsInformation.getEventId()) {\r
- String ver=alarmsInformation.getEventId();\r
- hql.append(" and a.eventId = '"+ver+"'");\r
- }\r
- if(null!=alarmsInformation.getCreateTime()) {\r
- Date ver =alarmsInformation.getCreateTime();\r
- hql.append(" and a.createTime > '%"+ver+"%'");\r
- }\r
- if(null!=alarmsInformation.getUpdateTime()) {\r
- Date ver =alarmsInformation.getUpdateTime();\r
- hql.append(" and a.updateTime like '%"+ver+"%'");\r
- }\r
- } \r
- long q=(long)session.createQuery(hql.toString()).uniqueResult();\r
- session.flush();\r
- return (int)q;\r
- } catch (Exception e) {\r
- logger.error("exception occurred while performing AlarmsInformationServiceImpl getAllCount. Details:" + e.getMessage());\r
- return 0;\r
- }\r
+ logger.error("AlarmsInformationServiceImpl getAllCount alarmsInformation is null!");\r
+ }else {\r
+ if(null!=alarmsInformation.getName()) {\r
+ String ver=alarmsInformation.getName();\r
+ hql.append(" and a.name like '%"+ver+"%'");\r
+ }\r
+ if(null!=alarmsInformation.getValue()) {\r
+ String ver=alarmsInformation.getValue();\r
+ hql.append(" and a.value like '%"+ver+"%'");\r
+ }\r
+ if(null!=alarmsInformation.getEventId()) {\r
+ String ver=alarmsInformation.getEventId();\r
+ hql.append(" and a.eventId = '"+ver+"'");\r
+ }\r
+ if(null!=alarmsInformation.getCreateTime()) {\r
+ Date ver =alarmsInformation.getCreateTime();\r
+ hql.append(" and a.createTime > '%"+ver+"%'");\r
+ }\r
+ if(null!=alarmsInformation.getUpdateTime()) {\r
+ Date ver =alarmsInformation.getUpdateTime();\r
+ hql.append(" and a.updateTime like '%"+ver+"%'");\r
+ }\r
+ } \r
+ long q=(long)session.createQuery(hql.toString()).uniqueResult();\r
+ session.flush();\r
+ return (int)q;\r
+ } catch (Exception e) {\r
+ logger.error("exception occurred while performing AlarmsInformationServiceImpl getAllCount. Details:" + e.getMessage());\r
+ return 0;\r
+ }\r
}\r
\r
@SuppressWarnings("unchecked")\r
int allRow =this.getAllCount(alarmsInformation,currentPage,pageSize);\r
int offset = page.countOffset(currentPage, pageSize);\r
\r
- try(Session session = sessionFactory.openSession();){\r
+ try(Session session = getSession()){\r
StringBuffer hql =new StringBuffer("from AlarmsInformation a where 1=1");\r
- if (null == alarmsInformation) {\r
- //logger.error("AlarmsInformationServiceImpl queryAlarmsInformation alarmsInformation is null!");\r
- }else {\r
- if(null!=alarmsInformation.getName()) {\r
- String ver=alarmsInformation.getName();\r
- hql.append(" and a.name like '%"+ver+"%'");\r
- }\r
- if(null!=alarmsInformation.getValue()) {\r
- String ver=alarmsInformation.getValue();\r
- hql.append(" and a.value like '%"+ver+"%'");\r
- }\r
- if(null!=alarmsInformation.getEventId()) {\r
- String ver=alarmsInformation.getEventId();\r
- hql.append(" and a.eventId = '"+ver+"'");\r
- }\r
- if(null!=alarmsInformation.getCreateTime()) {\r
- Date ver =alarmsInformation.getCreateTime();\r
- hql.append(" and a.createTime > '%"+ver+"%'");\r
- }\r
- if(null!=alarmsInformation.getUpdateTime()) {\r
- Date ver =alarmsInformation.getUpdateTime();\r
- hql.append(" and a.updateTime like '%"+ver+"%'");\r
- }\r
- }\r
- logger.info("AlarmsInformationServiceImpl queryAlarmsInformation: alarmsInformation={}", alarmsInformation);\r
- Query query = session.createQuery(hql.toString());\r
- query.setFirstResult(offset);\r
- query.setMaxResults(pageSize);\r
- List<AlarmsInformation> list= query.list();\r
- page.setPageNo(currentPage);\r
- page.setPageSize(pageSize);\r
- page.setTotalRecords(allRow);\r
- page.setList(list);\r
- session.flush();\r
- return page;\r
- } catch (Exception e) {\r
- logger.error("exception occurred while performing AlarmsInformationServiceImpl queryAlarmsInformation. Details:" + e.getMessage());\r
- return null;\r
- }\r
+ if (null == alarmsInformation) {\r
+ //logger.error("AlarmsInformationServiceImpl queryAlarmsInformation alarmsInformation is null!");\r
+ }else {\r
+ if(null!=alarmsInformation.getName()) {\r
+ String ver=alarmsInformation.getName();\r
+ hql.append(" and a.name like '%"+ver+"%'");\r
+ }\r
+ if(null!=alarmsInformation.getValue()) {\r
+ String ver=alarmsInformation.getValue();\r
+ hql.append(" and a.value like '%"+ver+"%'");\r
+ }\r
+ if(null!=alarmsInformation.getEventId()) {\r
+ String ver=alarmsInformation.getEventId();\r
+ hql.append(" and a.eventId = '"+ver+"'");\r
+ }\r
+ if(null!=alarmsInformation.getCreateTime()) {\r
+ Date ver =alarmsInformation.getCreateTime();\r
+ hql.append(" and a.createTime > '%"+ver+"%'");\r
+ }\r
+ if(null!=alarmsInformation.getUpdateTime()) {\r
+ Date ver =alarmsInformation.getUpdateTime();\r
+ hql.append(" and a.updateTime like '%"+ver+"%'");\r
+ }\r
+ }\r
+ logger.info("AlarmsInformationServiceImpl queryAlarmsInformation: alarmsInformation={}", alarmsInformation);\r
+ Query query = session.createQuery(hql.toString());\r
+ query.setFirstResult(offset);\r
+ query.setMaxResults(pageSize);\r
+ List<AlarmsInformation> list= query.list();\r
+ page.setPageNo(currentPage);\r
+ page.setPageSize(pageSize);\r
+ page.setTotalRecords(allRow);\r
+ page.setList(list);\r
+ session.flush();\r
+ return page;\r
+ } catch (Exception e) {\r
+ logger.error("exception occurred while performing AlarmsInformationServiceImpl queryAlarmsInformation. Details:" + e.getMessage());\r
+ return null;\r
+ }\r
}\r
\r
@SuppressWarnings("unchecked")\r
logger.error("AlarmsInformationServiceImpl queryId is null!");\r
}\r
List<AlarmsInformation> list = new ArrayList<AlarmsInformation>();\r
- Session session = sessionFactory.openSession();\r
+ Session session = getSession();\r
Query query = session.createQuery("from AlarmsInformation a where a.eventId IN (:alist)");\r
list = query.setParameterList("alist", id).list();\r
session.close();\r
\r
@Override\r
public List<Map<String,String>> queryDateBetween(String sourceId, String startTime, String endTime) {\r
- try(Session session = sessionFactory.openSession();) {\r
+ try(Session session = getSession()) {\r
List<Map<String,String>> mapList = new ArrayList<>();\r
String hql = "select a.createTime,count(*) from AlarmsInformation a where 1=1 ";\r
if (sourceId != null && !"".equals(sourceId)){\r
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onap.usecaseui.server.service.impl;
+package org.onap.usecaseui.server.bean;
import org.junit.Test;
import org.junit.Before;
--- /dev/null
+/*
+ * 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.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 mockit.Mock;
+import mockit.MockUp;
+
+public class AlarmsInformationTest implements Serializable {
+
+ @Before
+ public void before() throws Exception {
+ }
+
+ @After
+ public void after() throws Exception {
+ }
+
+ @Test
+ public void testGetAlarmsInformation() throws Exception {
+ AlarmsInformation ai = new AlarmsInformation("name", "value", "eventId", DateUtils.now(), DateUtils.now());
+ ai.getName();
+ ai.getValue();
+ ai.getEventId();
+ ai.getCreateTime();
+ ai.getUpdateTime();
+ ai.getId();
+ ai.toString();
+ }
+
+ @Test
+ public void testSetAlarmsInformation() throws Exception {
+ AlarmsInformation ai = new AlarmsInformation("eventId");
+ ai.setName("");
+ ai.setValue("");
+ ai.setEventId("");
+ ai.setCreateTime(DateUtils.now());
+ ai.setUpdateTime(DateUtils.now());
+ ai.setId(1);
+ }
+}
--- /dev/null
+/*
+ * 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.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.PerformanceHeader;
+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 {
+
+ @Before
+ public void before() throws Exception {
+ }
+
+ @After
+ public void after() throws Exception {
+ }
+
+ @Test
+ public void testGetPerformanceHeader() throws Exception {
+ PerformanceHeader ph = new PerformanceHeader("version", "eventName", "domain", "eventId", "eventType", "nfcNamingCode", "nfNamingCode",
+ "sourceId", "sourceName", "reportingEntityId", "reportingEntityName", "priority",
+ "startEpochMicrosec", "lastEpochMicroSec", "sequence", "measurementsForVfScalingVersion",
+ "measurementInterval", DateUtils.now(), DateUtils.now());
+ ph.getVersion();
+ ph.getEventName();
+ ph.getDomain();
+ ph.getEventId();
+ ph.getEventType();
+ ph.getNfcNamingCode();
+ ph.getNfNamingCode();
+ ph.getSourceId();
+ ph.getSourceName();
+ ph.getReportingEntityId();
+ ph.getReportingEntityName();
+ ph.getPriority();
+ ph.getStartEpochMicrosec();
+ ph.getLastEpochMicroSec();
+ ph.getSequence();
+ ph.getMeasurementsForVfScalingVersion();
+ ph.getMeasurementInterval();
+ ph.getCreateTime();
+ ph.getUpdateTime();
+ }
+
+ @Test
+ public void testSetPerformanceHeader() throws Exception {
+ PerformanceHeader ph = new PerformanceHeader("sourceId");
+ ph.setVersion("");
+ ph.setEventName("");
+ ph.setDomain("");
+ ph.setEventId("");
+ ph.setEventType("");
+ ph.setNfcNamingCode("");
+ ph.setNfNamingCode("");
+ ph.setSourceId("");
+ ph.setSourceName("");
+ ph.setReportingEntityId("");
+ ph.setReportingEntityName("");
+ ph.setPriority("");
+ ph.setStartEpochMicrosec("");
+ ph.setLastEpochMicroSec("");
+ ph.setSequence("");
+ ph.setMeasurementsForVfScalingVersion("");
+ ph.setMeasurementInterval("");
+ ph.setCreateTime(DateUtils.now());
+ ph.setUpdateTime(DateUtils.now());
+ }
+}
--- /dev/null
+/*
+ * 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.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 mockit.Mock;
+import mockit.MockUp;
+
+public class PerformanceInformationTest implements Serializable {
+
+ @Before
+ public void before() throws Exception {
+ }
+
+ @After
+ public void after() throws Exception {
+ }
+
+ @Test
+ public void testGetPerformanceInformation() throws Exception {
+ PerformanceInformation pi = new PerformanceInformation("name", "value", "eventId", DateUtils.now(), DateUtils.now());
+ pi.getName();
+ pi.getValue();
+ pi.getEventId();
+ pi.getCreateTime();
+ pi.getUpdateTime();
+ pi.getId();
+ }
+
+ @Test
+ public void testSetPerformanceInformation() throws Exception {
+ PerformanceInformation pi = new PerformanceInformation("eventId");
+ pi.setName("");
+ pi.setValue("");
+ pi.setEventId("");
+ pi.setCreateTime(DateUtils.now());
+ pi.setUpdateTime(DateUtils.now());
+ pi.setId(1);
+ }
+}
+
--- /dev/null
+/**
+ * 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.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;
+
+public class ServiceTemplateInputTest {
+
+ @Before
+ public void before() throws Exception {
+ }
+
+ @After
+ public void after() throws Exception {
+ }
+
+ @Test
+ public void testGetServiceTemplateInput() throws Exception {
+ ServiceTemplateInput sti = new ServiceTemplateInput("invariantUUID", "uuid", "name", "type", "version", "description", "category", "subcategory", null);
+ sti.getInvariantUUID();
+ sti.getUuid();
+ sti.getName();
+ sti.getType();
+ sti.getVersion();
+ sti.getDescription();
+ sti.getCategory();
+ sti.getSubcategory();
+ sti.getInputs();
+ sti.getNestedTemplates();
+ sti.toString();
+ sti.hashCode();
+ }
+
+ @Test
+ public void testSetServiceTemplateInput() throws Exception {
+ ServiceTemplateInput sti = new ServiceTemplateInput("invariantUUID", "uuid", "name", "type", "version", "description", "category", "subcategory", null);
+ sti.addNestedTemplate(null);
+ sti.addInputs(null);
+ sti.addInput(null);
+ sti.setType("type");
+ sti.equals(sti);
+ }
+}
--- /dev/null
+/**
+ * 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.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;
+
+public class TemplateInputTest {
+
+ @Before
+ public void before() throws Exception {
+ }
+
+ @After
+ public void after() throws Exception {
+ }
+
+ @Test
+ public void testGetTemplateInput() throws Exception {
+ TemplateInput ti = new TemplateInput("name", "type", "description", "isRequired", "defaultValue");
+ ti.getName();
+ ti.getType();
+ ti.getDescription();
+ ti.getIsRequired();
+ ti.getDefaultValue();
+ ti.toString();
+ ti.hashCode();
+ }
+
+ @Test
+ public void testSetTemplateInput() throws Exception {
+ TemplateInput ti = new TemplateInput("name", "type", "description", "isRequired", "defaultValue");
+ ti.equals(ti);
+ }
+}
--- /dev/null
+/**
+ * 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.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;
+
+public class VfNsPackageInfoTest {
+
+ @Before
+ public void before() throws Exception {
+ }
+
+ @After
+ public void after() throws Exception {
+ }
+
+ @Test
+ public void testGetVfNsPackageInfo() throws Exception {
+ VfNsPackageInfo vpi = new VfNsPackageInfo(null, null);
+ vpi.getNsPackage();
+ vpi.getVnfPackages();
+ vpi.hashCode();
+ }
+
+ @Test
+ public void testSetVfNsPackageInfo() throws Exception {
+ VfNsPackageInfo vpi = new VfNsPackageInfo(null, null);
+ vpi.equals(vpi);
+ }
+}
--- /dev/null
+/**
+ * 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.service.impl;
+
+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.service.impl.AlarmsInformationServiceImpl;
+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;
+
+/**
+* AlarmsInformationServiceImpl Tester.
+*
+* @author <Authors name>
+* @since <pre>8, 2018</pre>
+* @version 1.0
+*/
+public class AlarmsInformationServiceImplTest {
+ AlarmsInformationServiceImpl alarmsInformationServiceImpl = null;
+ private static final long serialVersionUID = 1L;
+
+ @Before
+ public void before() throws Exception {
+ alarmsInformationServiceImpl = new AlarmsInformationServiceImpl();
+
+ MockUp<Transaction> mockUpTransaction = new MockUp<Transaction>() {
+ @Mock
+ public void commit() {
+ }
+ };
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ };
+ new MockUp<Query>() {
+ @Mock
+ public Query setString(String name, String value) {
+ return mockUpQuery.getMockInstance();
+ }
+ @Mock
+ public Query setDate(String name, Date value) {
+ return mockUpQuery.getMockInstance();
+ }
+ @Mock
+ public Query setInteger(String name, int value) {
+ return mockUpQuery.getMockInstance();
+ }
+ @Mock
+ public int executeUpdate() {
+ return 0;
+ }
+ @Mock
+ public Query setMaxResults(int value) {
+ return mockUpQuery.getMockInstance();
+ }
+ @Mock
+ public Query setFirstResult(int firstResult) {
+ return mockUpQuery.getMockInstance();
+ }
+ @Mock
+ public Query setParameterList(String name, Object[] values) {
+ return mockUpQuery.getMockInstance();
+ }
+ @Mock
+ public List<AlarmsInformation> list() {
+ AlarmsInformation ai = new AlarmsInformation();
+ return Arrays.asList(ai);
+ }
+ @Mock
+ public Object uniqueResult() {
+ return "0";
+ }
+ };
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String sql) {
+ return mockUpQuery.getMockInstance();
+ }
+ @Mock
+ public Transaction beginTransaction() {
+ return mockUpTransaction.getMockInstance();
+ }
+ @Mock
+ public Transaction getTransaction() {
+ return mockUpTransaction.getMockInstance();
+ }
+ @Mock
+ public Serializable save(Object object) {
+ return (Serializable) serialVersionUID;
+ }
+ @Mock
+ public void flush() {
+ }
+ @Mock
+ public void update(Object object) {
+ }
+ };
+ new MockUp<SessionFactory>() {
+ @Mock
+ public Session openSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ new MockUp<AlarmsInformationServiceImpl>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ }
+
+ @After
+ public void after() throws Exception {
+ }
+
+ @Test
+ public void testSaveAlarmsInformation() throws Exception {
+ AlarmsInformation ai = null;
+ alarmsInformationServiceImpl.saveAlarmsInformation(ai);
+ }
+
+ @Test
+ public void testUpdateAlarmsInformation() throws Exception {
+ AlarmsInformation ai = null;
+ alarmsInformationServiceImpl.updateAlarmsInformation(ai);
+ }
+
+ @Test
+ public void testGetAllCount() throws Exception {
+ new MockUp<Query>() {
+ @Mock
+ public Object uniqueResult() {
+ return "1";
+ }
+ };
+ AlarmsInformation ai = new AlarmsInformation();
+ ai.getName();
+ ai.getValue();
+ ai.getEventId();
+ ai.getCreateTime();
+ ai.getUpdateTime();
+ alarmsInformationServiceImpl.getAllCount(ai, 1, 1);
+ }
+
+ @Test
+ public void testQueryAlarmsInformation() throws Exception {
+ AlarmsInformation ai = new AlarmsInformation();
+ ai.getName();
+ ai.getValue();
+ ai.getEventId();
+ ai.getCreateTime();
+ ai.getUpdateTime();
+ alarmsInformationServiceImpl.queryAlarmsInformation(ai, 1, 1);
+ }
+
+ @Test
+ public void testQueryId() throws Exception {
+ String[] id = {"1", "2", "3"};
+ alarmsInformationServiceImpl.queryId(id);
+ }
+
+ @Test
+ public void testQueryDateBetween() throws Exception {
+ alarmsInformationServiceImpl.queryDateBetween("sourceId", "startTime", "endTime");
+ }
+
+ @Test(expected = Exception.class)
+ public void testSaveAlarmsInformationException() throws Exception {
+ new MockUp<AlarmsInformationServiceImpl>() {
+ @Mock
+ private Session getSession() throws Exception {
+ throw new Exception();
+ }
+ };
+ AlarmsInformation ai = new AlarmsInformation();
+ alarmsInformationServiceImpl.saveAlarmsInformation(ai);
+ }
+
+ @Test(expected = Exception.class)
+ public void testUpdateAlarmsInformationException() throws Exception {
+ new MockUp<AlarmsInformationServiceImpl>() {
+ @Mock
+ private Session getSession() throws Exception {
+ throw new Exception();
+ }
+ };
+ AlarmsInformation ai = new AlarmsInformation();
+ alarmsInformationServiceImpl.updateAlarmsInformation(ai);
+ }
+
+ @Test(expected = Exception.class)
+ public void testGetAllCountException() throws Exception {
+ new MockUp<AlarmsInformationServiceImpl>() {
+ @Mock
+ private Session getSession() throws Exception {
+ throw new Exception();
+ }
+ };
+ AlarmsInformation ai = new AlarmsInformation();
+ alarmsInformationServiceImpl.getAllCount(ai, 1, 1);
+ }
+
+ @Test(expected = Exception.class)
+ public void testQueryAlarmsInformationException() throws Exception {
+ new MockUp<AlarmsInformationServiceImpl>() {
+ @Mock
+ private Session getSession() throws Exception {
+ throw new Exception();
+ }
+ };
+ AlarmsInformation ai = new AlarmsInformation();
+ alarmsInformationServiceImpl.queryAlarmsInformation(ai, 1, 1);
+ }
+
+ @Test(expected = Exception.class)
+ public void testQueryIdException() throws Exception {
+ new MockUp<AlarmsInformationServiceImpl>() {
+ @Mock
+ private Session getSession() throws Exception {
+ throw new Exception();
+ }
+ };
+ String[] id = {"1", "2", "3"};
+ alarmsInformationServiceImpl.queryId(id);
+ }
+
+ @Test(expected = Exception.class)
+ public void testQueryDateBetweenException() throws Exception {
+ new MockUp<AlarmsInformationServiceImpl>() {
+ @Mock
+ private Session getSession() throws Exception {
+ throw new Exception();
+ }
+ };
+ alarmsInformationServiceImpl.queryDateBetween("sourceId", "startTime", "endTime");
+ }
+}