improve sonar coverage for uui-server 81/42681/1
authorzhangab <zhanganbing@chinamobile.com>
Fri, 13 Apr 2018 08:12:47 +0000 (16:12 +0800)
committerzhangab <zhanganbing@chinamobile.com>
Fri, 13 Apr 2018 08:12:51 +0000 (16:12 +0800)
Change-Id: Iecb4f6b938c91f7ba7a335cbb04369efba8e5744
Issue-ID: USECASEUI-103
Signed-off-by: zhangab <zhanganbing@chinamobile.com>
server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java
server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java
server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImplTest.java
server/src/test/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImplTest.java

index f0ac9c3..980a3a6 100755 (executable)
@@ -52,7 +52,7 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
 \r
        @Override\r
        public String saveAlarmsInformation(AlarmsInformation alarmsInformation) {\r
-                try(Session session = getSession();){\r
+                try(Session session = getSession()){\r
                    if (null == alarmsInformation) {\r
                        logger.error("alarmsInformation saveAlarmsInformation alarmsInformation is null!");\r
                    }\r
@@ -71,7 +71,7 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
 \r
        @Override\r
        public String updateAlarmsInformation(AlarmsInformation alarmsInformation) {\r
-               try(Session session = getSession();){\r
+               try(Session session = getSession()){\r
             if (null == alarmsInformation) {\r
                 logger.error("alarmsInformation updateAlarmsInformation alarmsInformation is null!");\r
             }\r
@@ -89,7 +89,7 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
        \r
 \r
        public int getAllCount(AlarmsInformation alarmsInformation, int currentPage, int pageSize) {\r
-               try(Session session = getSession();){\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
@@ -114,11 +114,13 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
                        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
+            }\r
+\r
+                       Query query = session.createQuery(hql.toString());\r
+                       Object obj = query.uniqueResult();\r
+                       session.flush();\r
+                       return Integer.parseInt(obj.toString());\r
+               } catch (Exception e) {\r
             logger.error("exception occurred while performing AlarmsInformationServiceImpl getAllCount. Details:" + e.getMessage());\r
             return 0;\r
         }\r
@@ -132,7 +134,7 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
                int allRow =this.getAllCount(alarmsInformation,currentPage,pageSize);\r
                int offset = page.countOffset(currentPage, pageSize);\r
                \r
-               try(Session session = getSession();){\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
index 77810b9..705112d 100755 (executable)
@@ -41,44 +41,37 @@ import org.springframework.stereotype.Service;
 @org.springframework.context.annotation.Configuration\r
 @EnableAspectJAutoProxy\r
 public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {\r
-       \r
+\r
     private static final Logger logger = LoggerFactory.getLogger(PerformanceHeaderServiceImpl.class);\r
 \r
     @Autowired\r
     private SessionFactory sessionFactory;\r
 \r
-\r
-\r
-       private Session getSessionFactory(){\r
+       private Session getSession(){\r
                return sessionFactory.openSession();\r
        }\r
 \r
-\r
-\r
-\r
        @Override\r
        public String savePerformanceHeader(PerformanceHeader performanceHeder) {\r
-                try(Session session = getSessionFactory();){\r
-                   if (null == performanceHeder){\r
-                       logger.error("PerformanceHeaderServiceImpl savePerformanceHeader performanceHeder is null!");\r
-                   }\r
-                   logger.info("PerformanceHeaderServiceImpl savePerformanceHeader: performanceHeder={}", performanceHeder);\r
-                   Transaction tx = session.beginTransaction();     \r
-                   session.save(performanceHeder);\r
-                   tx.commit();\r
-                   session.flush();\r
-                   return "1";\r
-               } catch (Exception e) {\r
-                   logger.error("exception occurred while performing PerformanceHeaderServiceImpl savePerformanceHeader. Details:" + e.getMessage());\r
-                   return "0";\r
-               }\r
-               \r
+                try(Session session = getSession()){\r
+            if (null == performanceHeder){\r
+                logger.error("PerformanceHeaderServiceImpl savePerformanceHeader performanceHeder is null!");\r
+            }\r
+            logger.info("PerformanceHeaderServiceImpl savePerformanceHeader: performanceHeder={}", performanceHeder);\r
+            Transaction tx = session.beginTransaction();     \r
+            session.save(performanceHeder);\r
+            tx.commit();\r
+            session.flush();\r
+            return "1";\r
+        } catch (Exception e) {\r
+            logger.error("exception occurred while performing PerformanceHeaderServiceImpl savePerformanceHeader. Details:" + e.getMessage());\r
+            return "0";\r
+        }\r
        }\r
 \r
-\r
        @Override\r
        public String updatePerformanceHeader(PerformanceHeader performanceHeder) {\r
-               try(Session session = getSessionFactory();){\r
+               try(Session session = getSession()){\r
             if (null == performanceHeder){\r
                 logger.error("PerformanceHeaderServiceImpl updatePerformanceHeader performanceHeder is null!");\r
             }\r
@@ -94,49 +87,30 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
         }\r
        }\r
 \r
-\r
-\r
-\r
-\r
-\r
-\r
        @Override\r
        public int getAllCountByEventType(){\r
-               try (Session session = getSessionFactory()){\r
+               try (Session session = getSession()){\r
                        StringBuffer count = new StringBuffer("select count(*) from PerformanceHeader a where 1=1");\r
-                       /*if(!"0".equals(status)){\r
-                               count.append(" and a.status=:status");\r
-                       }*/\r
                        Query  query =session.createQuery(count.toString());\r
-                       /*query.setString("status",status);*/\r
-                       //int q = (int)query.uniqueResult();\r
-                       long q=(long)query.uniqueResult();\r
+                       Object obj = query.uniqueResult();\r
                        session.flush();\r
-                       return (int)q;\r
+                       return Integer.parseInt(obj.toString());\r
                }catch (Exception e){\r
                        logger.error("exception occurred while performing PerformanceHeaderServiceImpl getAllCount."+e.getMessage());\r
                        return 0;\r
                }\r
        }\r
 \r
-       \r
-       \r
-       \r
-       \r
        @Override\r
        public List<PerformanceHeader> getAllByEventType(String eventName,String sourceName,String reportingEntityName,  Date createTime, Date endTime){\r
-               try (Session session = getSessionFactory()){\r
+               try (Session session = getSession()){\r
                        StringBuffer string = new StringBuffer("from PerformanceHeader a where 1=1");\r
-                       /*if(!"0".equals(status)){\r
-                               string.append(" and a.status=:status");\r
-                       }*/\r
                        if(!"0".equals(eventName) &&  eventName!=null){\r
                 string.append(" and a.eventName=:eventName");\r
             }\r
             if(!"0".equals(sourceName) &&  sourceName!=null){\r
                 string.append(" and a.sourceName=:sourceName");\r
             }\r
-\r
             if(!"0".equals(reportingEntityName) &&  reportingEntityName!=null){\r
                 string.append(" and a.reportingEntityName=:reportingEntityName");\r
             }\r
@@ -144,54 +118,36 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
                 string.append(" and a.createTime between :startTime and :endTime");\r
             }\r
             Query query = session.createQuery(string.toString());\r
-                       /*if(!"0".equals(status)) {\r
-                               query.setString("status", status);\r
-                       }*/\r
                        if(!"0".equals(eventName) &&  eventName!=null) {\r
                                query.setString("eventName", eventName);\r
                        }\r
                        if(!"0".equals(sourceName) &&  sourceName!=null) {\r
                                query.setString("sourceName", sourceName);\r
                        }\r
-\r
                        if(!"0".equals(reportingEntityName) &&  reportingEntityName!=null) {\r
                                query.setString("reportingEntityName", reportingEntityName);\r
                        }\r
             if( null!=createTime && endTime!= null) {\r
                 query.setDate("startTime",createTime);\r
                 query.setDate("endTime",endTime);\r
-\r
             }\r
-\r
                        List<PerformanceHeader> list =query.list();\r
-\r
                        return list;\r
-\r
                }catch (Exception e){\r
-\r
                        logger.error("exception occurred while performing PerformanceHeaderServiceImpl getAllCount."+e.getMessage());\r
                        return null;\r
                }\r
-\r
-\r
-\r
        }\r
 \r
-\r
-\r
-\r
-\r
        @Override\r
        public PerformanceHeader getPerformanceHeaderDetail(Integer id) {\r
-               try(Session session = getSessionFactory()) {\r
-\r
+               try(Session session = getSession()) {\r
                        String string = "from PerformanceHeader a where 1=1 and a.id=:id";\r
                        Query q = session.createQuery(string);\r
                        q.setInteger("id",id);\r
                        PerformanceHeader performanceHeader =(PerformanceHeader)q.uniqueResult();\r
                        session.flush();\r
                        return performanceHeader;\r
-\r
                }catch (Exception e){\r
                        logger.error("exception occurred while performing PerformanceHeaderServiceImpl getPerformanceHeaderDetail."+e.getMessage());\r
                        return null;\r
@@ -200,63 +156,29 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
 \r
        @Override\r
        public int getAllByDatetime(String eventId,  String createTime) {\r
-               try (Session session = getSessionFactory();){\r
+               try (Session session = getSession()){\r
                        StringBuffer string = new StringBuffer("select count(*) as count from PerformanceHeader a where 1=1");\r
-\r
-                       /*if(!"0".equals(status) &&  status!=null){\r
-                               string.append(" and a.status=:status");\r
-                       }*/\r
                        if(!"0".equals(eventId) &&  eventId!=null){\r
                                string.append(" and a.eventId=:eventId");\r
                        }\r
-\r
-\r
-\r
-                       /*if( null!=createTime && endTime!= null) {\r
-                               string.append(" and a.createTime between :startTime and :endTime");\r
-                       }*/\r
                        if( null!=createTime) {\r
                                string.append(" and to_days(a.createTime) = to_days('"+createTime+"')");\r
                        }\r
-\r
-                       /*string.append("     group by DATE_FORMAT(a.createTime,'%y-%m-%d')");*/\r
                        Query query = session.createQuery(string.toString());\r
-                       /*if(!"0".equals(status) &&  status!=null) {\r
-                               query.setString("status", status);\r
-                       }*/\r
-                               if(!"0".equals(eventId) &&  eventId!=null) {\r
-                                       query.setString("eventId", eventId);\r
-                               }\r
-\r
-                       //query.setDate("createTime",createTime);\r
-\r
-                       /*if( null!=createTime && endTime!= null) {\r
-                               query.setDate("startTime",createTime);\r
-                               query.setDate("endTime",endTime);\r
-\r
-                       }*/\r
-                       long l = (long)query.uniqueResult();\r
-                       int a = (int) l;\r
-                       //List<PerformanceHeader> list =query.list();\r
+                       if(!"0".equals(eventId) &&  eventId!=null) {\r
+                               query.setString("eventId", eventId);\r
+                       }\r
+                       Object obj = query.uniqueResult();\r
                        session.flush();\r
-                       return a;\r
-\r
+                       return Integer.parseInt(obj.toString());\r
                }catch (Exception e){\r
-\r
                        logger.error("exception occurred while performing PerformanceHeaderServiceImpl getAllCount."+e.getMessage());\r
                        return 0;\r
                }\r
-\r
        }\r
 \r
-\r
-\r
-\r
-\r
-\r
-\r
        public int getAllCount(PerformanceHeader performanceHeder, int currentPage, int pageSize) {\r
-               try(Session session = getSessionFactory();){\r
+               try(Session session = getSession()){\r
                        StringBuffer hql = new StringBuffer("select count(*) from PerformanceHeader a where 1=1");\r
                        if (null == performanceHeder) {\r
                 //logger.error("PerformanceHeaderServiceImpl getAllCount performanceHeder is null!");\r
@@ -334,13 +256,14 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
                 }\r
             }\r
             Query query = session.createQuery(hql.toString());\r
-                       if (null != performanceHeder)\r
+                       if (null != performanceHeder) {\r
                 if(null!=performanceHeder.getCreateTime() && null!=performanceHeder.getUpdateTime()) {\r
                     query.setDate("startTime",performanceHeder.getCreateTime()).setDate("endTime",performanceHeder.getUpdateTime());\r
                 }\r
-            long q=(long)query.uniqueResult();\r
-            session.flush();\r
-            return (int)q;\r
+                       }\r
+                       Object obj = query.uniqueResult();\r
+                       session.flush();\r
+                       return Integer.parseInt(obj.toString());\r
         } catch (Exception e) {\r
             logger.error("exception occurred while performing PerformanceHeaderServiceImpl getAllCount. Details:" + e.getMessage());\r
             return 0;\r
@@ -349,13 +272,12 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
 \r
        @SuppressWarnings("unchecked")\r
        @Override\r
-       public Page<PerformanceHeader> queryPerformanceHeader(PerformanceHeader performanceHeder, int currentPage,\r
-                       int pageSize) {\r
+       public Page<PerformanceHeader> queryPerformanceHeader(PerformanceHeader performanceHeder, int currentPage, int pageSize) {\r
                Page<PerformanceHeader> page = new Page<PerformanceHeader>();\r
                int allRow =this.getAllCount(performanceHeder,currentPage,pageSize);\r
                int offset = page.countOffset(currentPage, pageSize);\r
-               \r
-               try(Session session = getSessionFactory();){\r
+\r
+               try(Session session = getSession()){\r
                        StringBuffer hql =new StringBuffer("from PerformanceHeader a where 1=1");\r
             if (null == performanceHeder) {\r
                 //logger.error("PerformanceHeaderServiceImpl queryPerformanceHeader performanceHeder is null!");\r
@@ -434,10 +356,11 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
             }\r
             logger.info("PerformanceHeaderServiceImpl queryPerformanceHeader: performanceHeder={}", performanceHeder);\r
             Query query = session.createQuery(hql.toString());\r
-                       if (null != performanceHeder)\r
+                       if (null != performanceHeder) {\r
                 if(null!=performanceHeder.getCreateTime() && null!=performanceHeder.getUpdateTime()) {\r
                     query.setDate("startTime",performanceHeder.getCreateTime()).setDate("endTime",performanceHeder.getUpdateTime());\r
                 }\r
+                       }\r
             query.setFirstResult(offset);\r
             query.setMaxResults(pageSize);\r
             List<PerformanceHeader> list= query.list();\r
@@ -453,11 +376,10 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
         }\r
        }\r
 \r
-\r
        @SuppressWarnings("unchecked")\r
        @Override\r
        public List<PerformanceHeader> queryId(String[] id) {\r
-               try(Session session = getSessionFactory();) {\r
+               try(Session session = getSession()) {\r
                        if(id.length==0) {\r
                                logger.error("PerformanceHeaderServiceImpl queryId is null!");\r
                        }\r
@@ -471,10 +393,9 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
                }\r
        }\r
 \r
-\r
        @Override\r
        public List<String> queryAllSourceId() {\r
-               try(Session session = getSessionFactory();) {\r
+               try(Session session = getSession()) {\r
                        Query query = session.createQuery("select a.sourceId from PerformanceHeader a");\r
                        return query.list();\r
                } catch (Exception e) {\r
index d6dcc1b..9cc926d 100644 (file)
@@ -193,6 +193,15 @@ public class AlarmsInformationServiceImplTest {
 
        @Test
        public void testQueryDateBetween() throws Exception {
+               new MockUp<Query>() {
+                       @Mock
+                       public List<Object[]> list() {
+                               List<Object[]> resultlist = new ArrayList<Object[]>();
+                               Object[] objs = {"name", "value"};
+                               resultlist.add(objs);
+                               return resultlist;
+                       }
+               };
                new MockUp<List>() {
                        @Mock
                        private Iterator iterator() {
index 4271c49..b2fe2b4 100644 (file)
@@ -24,7 +24,7 @@ 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.service.PerformanceHeaderService;
+import org.onap.usecaseui.server.service.impl.PerformanceHeaderServiceImpl;
 import org.onap.usecaseui.server.util.DateUtils;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -32,6 +32,10 @@ import org.springframework.test.context.web.WebAppConfiguration;
 
 import javax.annotation.Resource;
 
+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;
@@ -39,7 +43,6 @@ import org.hibernate.Transaction;
 
 import mockit.Mock;
 import mockit.MockUp;
-
 import static org.mockito.Mockito.mock;
 
 /** 
@@ -50,35 +53,82 @@ import static org.mockito.Mockito.mock;
 * @version 1.0 
 */
 public class PerformanceHeaderServiceImplTest {
-  /*  @Resource(name = "PerformanceHeaderService")
-    PerformanceHeaderService performanceHeaderService;*/
-  PerformanceHeaderServiceImpl service;
-@Before
-public void before() throws Exception {
-    service = mock(PerformanceHeaderServiceImpl.class);
-} 
-
-@After
-public void after() throws Exception { 
-} 
-
-private Session session;
-private Transaction transaction;
-private Query query;
-/**
- * mockupUtil 
- */
-public void mockupUtil(){
-        MockUp<Query> mockUpQuery = new MockUp<Query>() {
-     };
+
+       PerformanceHeaderServiceImpl performanceHeaderServiceImpl = null;
+       private static final long serialVersionUID = 1L;
+
+       @Before
+       public void before() throws Exception {
+               performanceHeaderServiceImpl = new PerformanceHeaderServiceImpl();
+
+               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<PerformanceHeader> list() {
+                               PerformanceHeader ph = new PerformanceHeader();
+                               return Arrays.asList(ph);
+                       }
+                       @Mock
+                       public Object uniqueResult() {
+                               return "0";
+                       }
+               };
                MockUp<Session> mockedSession = new MockUp<Session>() {
-         @Mock
-         public Query createQuery(String sql) {
-             return mockUpQuery.getMockInstance();
-         }
+                       @Mock
+                       public Query createQuery(String sql) {
+                               return mockUpQuery.getMockInstance();
+                       }
                        @Mock
                        public Transaction beginTransaction() {
-                               return transaction;
+                               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>() {
@@ -87,144 +137,238 @@ public void mockupUtil(){
                                return mockedSession.getMockInstance();
                        }
                };
-               new MockUp<Transaction>() {
+               new MockUp<PerformanceHeaderServiceImpl>() {
                        @Mock
-                       public void commit() {
+                       private Session getSession() {
+                               return mockedSession.getMockInstance();
                        }
                };
-     new MockUp<AlarmsInformationServiceImpl>() {
-         @Mock
-         private Session getSession() {
-             return mockedSession.getMockInstance();
-         }
-     };
-}
+       }
 
-/** 
-* 
-* Method: savePerformanceHeader(PerformanceHeader performanceHeder) 
-* 
-*/ 
-@Test
-public void testSavePerformanceHeader() throws Exception { 
-//TODO: Test goes here...
-    PerformanceHeader p = new PerformanceHeader();
-    p.setCreateTime(DateUtils.now());
-    p.setEventId("2202");
-    p.setEventName("fxc");
-    p.setDomain("asb");
-    p.setCreateTime(DateUtils.now());
-    p.setEventType("q");
-    p.setLastEpochMicroSec("csa");
-    p.setNfcNamingCode("std");
-    p.setNfNamingCode("cout");
-    p.setPriority("cs");
-    p.setReportingEntityId("112");
-    p.setReportingEntityName("asfs");
-    p.setSequence("cgg");
-    p.setSourceId("123");
-    p.setSourceName("eggs");
-    p.setStartEpochMicrosec("wallet");
-    p.setUpdateTime(DateUtils.now());
-    p.setVersion("va2");
-    p.setMeasurementInterval("12");
-    p.setMeasurementsForVfScalingVersion("12");
-    mockupUtil();
-    service.savePerformanceHeader(p);
-} 
+       @After
+       public void after() throws Exception {
+       }
 
-/** 
-* 
-* Method: updatePerformanceHeader(PerformanceHeader performanceHeder) 
-* 
-*/ 
-@Test
-public void testUpdatePerformanceHeader() throws Exception { 
-//TODO: Test goes here...
-    PerformanceHeader p = new PerformanceHeader();
-    p.setCreateTime(DateUtils.now());
-    p.setEventId("110");
-    p.setEventName("fxc");
-    p.setDomain("asb");
-    p.setCreateTime(DateUtils.now());
-    p.setEventType("q");
-    p.setLastEpochMicroSec("csa");
-    p.setNfcNamingCode("std");
-    p.setNfNamingCode("cout");
-    p.setPriority("cs");
-    p.setReportingEntityId("112");
-    p.setReportingEntityName("asfs");
-    p.setSequence("cgg");
-    p.setSourceId("123");
-    p.setSourceName("eggs");
-    p.setStartEpochMicrosec("wallet");
-    p.setUpdateTime(DateUtils.now());
-    p.setVersion("va2");
-    p.setMeasurementInterval("12");
-    p.setMeasurementsForVfScalingVersion("12");
-    mockupUtil();
-    service.updatePerformanceHeader(p);
-} 
+       @Test
+       public void testSavePerformanceHeader() throws Exception {
+               PerformanceHeader ph = null;
+               performanceHeaderServiceImpl.savePerformanceHeader(ph);
+       }
 
-/** 
-* 
-* Method: getAllCount(PerformanceHeader performanceHeder, int currentPage, int pageSize) 
-* 
-*/ 
-@Test
-public void testGetAllCount() throws Exception { 
-//TODO: Test goes here...
+       @Test
+       public void testUpdatePerformanceHeader() throws Exception {
+               PerformanceHeader ph = null;
+               performanceHeaderServiceImpl.updatePerformanceHeader(ph);
+       }
 
-    PerformanceHeader performanceHeader = new PerformanceHeader();
-    performanceHeader.setSourceName("vnf_a_3");
+       @Test
+       public void testGetAllCountByEventType() throws Exception {
+               performanceHeaderServiceImpl.getAllCountByEventType();
+       }
 
-    mockupUtil();
-    service.getAllCount(performanceHeader,0,12);
+       @Test
+       public void testGetAllByEventType() throws Exception {
+               new MockUp<Query>() {
+                       @Mock
+                       public List<PerformanceHeader> list() {
+                               PerformanceHeader ph = new PerformanceHeader();
+                               return Arrays.asList(ph);
+                       }
+               };
+               performanceHeaderServiceImpl.getAllByEventType("eventName", "sourceName", "reportingEntityName", DateUtils.now(), DateUtils.now());
+       }
 
-} 
+       @Test
+       public void testGetPerformanceHeaderDetail() throws Exception {
+               performanceHeaderServiceImpl.getPerformanceHeaderDetail(1);
+       }
 
-/** 
-* 
-* Method: queryPerformanceHeader(PerformanceHeader performanceHeder, int currentPage, int pageSize) 
-* 
-*/ 
-@Test
-public void testQueryPerformanceHeader() throws Exception { 
-//TODO: Test goes here...
-    PerformanceHeader p = new PerformanceHeader();
-    p.setEventId("110");
-    mockupUtil();
-    service.queryPerformanceHeader(p,1,100);
-          //  .getList().forEach(per -> System.out.println(per));
-} 
+       @Test
+       public void testGetAllByDatetime() throws Exception {
+               performanceHeaderServiceImpl.getAllByDatetime("eventId", "createTime");
+       }
 
-/** 
-* 
-* Method: queryId(String[] id) 
-* 
-*/ 
-@Test
-public void testQueryId() throws Exception { 
-//TODO: Test goes here...
-       mockupUtil();
-    service.queryId(new String[]{"110"});
-           // .forEach(pe -> System.out.println(pe.getCreateTime()));
-} 
+       @Test
+       public void testGetAllCount() throws Exception {
+               PerformanceHeader ph = new PerformanceHeader();
+               ph.setVersion("version");
+               ph.setEventName("eventName");
+               ph.setDomain("domain");
+               ph.setEventId("eventId");
+               ph.setNfcNamingCode("nfcNamingCode");
+               ph.setNfNamingCode("nfNamingCode");
+               ph.setSourceId("sourceId");
+               ph.setSourceName("sourceName");
+               ph.setReportingEntityId("reportingEntityId");
+               ph.setReportingEntityName("reportingEntityName");
+               ph.setPriority("priority");
+               ph.setStartEpochMicrosec("startEpochMicrosec");
+               ph.setLastEpochMicroSec("lastEpochMicroSec");
+               ph.setSequence("sequence");
+               ph.setMeasurementsForVfScalingVersion("measurementsForVfScalingVersion");
+               ph.setMeasurementInterval("measurementInterval");
+               ph.setEventType("eventType");
+               ph.setCreateTime(DateUtils.now());
+               ph.setUpdateTime(DateUtils.now());
+               performanceHeaderServiceImpl.getAllCount(ph, 1, 10);
+       }
 
-/** 
-* 
-* Method: queryAllSourceId() 
-* 
-*/ 
-@Test
-public void testQueryAllSourceId() throws Exception { 
-//TODO: Test goes here...
-    PerformanceHeader p = new PerformanceHeader();
-    p.setSourceId("123");
-    mockupUtil();
-    service.queryPerformanceHeader(p,1,100);
-            //.getList().forEach(per -> System.out.println(per));
-} 
-
-
-} 
+       @Test
+       public void testQueryPerformanceHeader() throws Exception {
+               new MockUp<PerformanceHeaderServiceImpl>() {
+                       @Mock
+                       private int getAllCount(PerformanceHeader performanceHeader, int currentPage, int pageSize) {
+                               return 10;
+                       }
+               };
+               PerformanceHeader ph = new PerformanceHeader();
+               ph.setVersion("version");
+               ph.setEventName("eventName");
+               ph.setDomain("domain");
+               ph.setEventId("eventId");
+               ph.setNfcNamingCode("nfcNamingCode");
+               ph.setNfNamingCode("nfNamingCode");
+               ph.setSourceId("sourceId");
+               ph.setSourceName("sourceName");
+               ph.setReportingEntityId("reportingEntityId");
+               ph.setReportingEntityName("reportingEntityName");
+               ph.setPriority("priority");
+               ph.setStartEpochMicrosec("startEpochMicrosec");
+               ph.setLastEpochMicroSec("lastEpochMicroSec");
+               ph.setSequence("sequence");
+               ph.setMeasurementsForVfScalingVersion("measurementsForVfScalingVersion");
+               ph.setMeasurementInterval("measurementInterval");
+               ph.setEventType("eventType");
+               ph.setCreateTime(DateUtils.now());
+               ph.setUpdateTime(DateUtils.now());
+               performanceHeaderServiceImpl.queryPerformanceHeader(ph, 1, 10);
+       }
+
+       @Test
+       public void testQueryId() throws Exception {
+               String[] id = {};
+               performanceHeaderServiceImpl.queryId(id);
+       }
+
+       @Test
+       public void testQueryAllSourceId() throws Exception {
+               String[] id = {};
+               performanceHeaderServiceImpl.queryAllSourceId();
+       }
+
+       @Test(expected = Exception.class)
+       public void testSavePerformanceHeaderException() throws Exception {
+               new MockUp<PerformanceHeaderServiceImpl>() {
+                       @Mock
+                       private Session getSession() throws Exception {
+                               throw new Exception();
+                       }
+               };
+               PerformanceHeader ph = null;
+               performanceHeaderServiceImpl.savePerformanceHeader(ph);
+       }
+
+       @Test(expected = Exception.class)
+       public void testUpdatePerformanceHeaderException() throws Exception {
+               new MockUp<PerformanceHeaderServiceImpl>() {
+                       @Mock
+                       private Session getSession() throws Exception {
+                               throw new Exception();
+                       }
+               };
+               PerformanceHeader ph = null;
+               performanceHeaderServiceImpl.updatePerformanceHeader(ph);
+       }
+
+       @Test(expected = Exception.class)
+       public void testGetAllCountByEventTypeException() throws Exception {
+               new MockUp<PerformanceHeaderServiceImpl>() {
+                       @Mock
+                       private Session getSession() throws Exception {
+                               throw new Exception();
+                       }
+               };
+               performanceHeaderServiceImpl.getAllCountByEventType();
+       }
+
+       @Test(expected = Exception.class)
+       public void testGetAllByEventTypeException() throws Exception {
+               new MockUp<PerformanceHeaderServiceImpl>() {
+                       @Mock
+                       private Session getSession() throws Exception {
+                               throw new Exception();
+                       }
+               };
+               performanceHeaderServiceImpl.getAllByEventType("eventName", "sourceName", "reportingEntityName", DateUtils.now(), DateUtils.now());
+       }
+
+       @Test(expected = Exception.class)
+       public void testGetPerformanceHeaderDetailException() throws Exception {
+               new MockUp<PerformanceHeaderServiceImpl>() {
+                       @Mock
+                       private Session getSession() throws Exception {
+                               throw new Exception();
+                       }
+               };
+               performanceHeaderServiceImpl.getPerformanceHeaderDetail(1);
+       }
+
+       @Test(expected = Exception.class)
+       public void testGetAllByDatetimeException() throws Exception {
+               new MockUp<PerformanceHeaderServiceImpl>() {
+                       @Mock
+                       private Session getSession() throws Exception {
+                               throw new Exception();
+                       }
+               };
+               performanceHeaderServiceImpl.getAllByDatetime("eventId", "createTime");
+       }
+
+       @Test(expected = Exception.class)
+       public void testGetAllCountException() throws Exception {
+               new MockUp<PerformanceHeaderServiceImpl>() {
+                       @Mock
+                       private Session getSession() throws Exception {
+                               throw new Exception();
+                       }
+               };
+               PerformanceHeader ph = new PerformanceHeader();
+               performanceHeaderServiceImpl.getAllCount(ph, 1, 10);
+       }
+
+       @Test(expected = Exception.class)
+       public void testQueryPerformanceHeaderException() throws Exception {
+               new MockUp<PerformanceHeaderServiceImpl>() {
+                       @Mock
+                       private Session getSession() throws Exception {
+                               throw new Exception();
+                       }
+               };
+               PerformanceHeader ph = new PerformanceHeader();
+               performanceHeaderServiceImpl.queryPerformanceHeader(ph, 1, 10);
+       }
+
+       @Test(expected = Exception.class)
+       public void testQueryIdException() throws Exception {
+               new MockUp<PerformanceHeaderServiceImpl>() {
+                       @Mock
+                       private Session getSession() throws Exception {
+                               throw new Exception();
+                       }
+               };
+               String[] id = {};
+               performanceHeaderServiceImpl.queryId(id);
+       }
+
+       @Test(expected = Exception.class)
+       public void testQueryAllSourceIdException() throws Exception {
+               new MockUp<PerformanceHeaderServiceImpl>() {
+                       @Mock
+                       private Session getSession() throws Exception {
+                               throw new Exception();
+                       }
+               };
+               String[] id = {};
+               performanceHeaderServiceImpl.queryAllSourceId();
+       }
+}
\ No newline at end of file