@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
}\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
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
\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
}\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
\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
}\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
}\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
}\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
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;
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;
import mockit.Mock;
import mockit.MockUp;
-
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>() {
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