diff options
author | zhangab <zhanganbing@chinamobile.com> | 2018-03-29 14:25:00 +0800 |
---|---|---|
committer | zhangab <zhanganbing@chinamobile.com> | 2018-03-29 14:25:04 +0800 |
commit | 0349d9a57424ddf68c0e4a499582c5e067628a60 (patch) | |
tree | f1fb3e8b6bf64bb29baf46565c518b46666bce5c | |
parent | ad1aff2bdebf0956f3ab2856ca723565423c673d (diff) |
improve sonar coverage for uui-server
Change-Id: I9ac7fb3b49fa0c566130d6bc17226be0beeadfd6
Issue-ID: USECASEUI-103
Signed-off-by: zhangab <zhanganbing@chinamobile.com>
-rw-r--r-- | server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImplTest.java | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImplTest.java index 94b87a66..e13dfb89 100644 --- a/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImplTest.java +++ b/server/src/test/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImplTest.java @@ -48,8 +48,46 @@ import mockit.MockUp; * @version 1.0 */ public class AlarmsHeaderServiceImplTest { + AlarmsHeaderServiceImpl alarmsHeaderServiceImpl = null; + @Before public void before() throws Exception { + alarmsHeaderServiceImpl = new AlarmsHeaderServiceImpl(); + MockUp<Query> mockUpQuery = new MockUp<Query>() { + }; + MockUp<Session> mockedSession = new MockUp<Session>() { + @Mock + public Query createQuery(String sql) { + return mockUpQuery.getMockInstance(); + } + @Mock + public Transaction beginTransaction() { + return transaction; + } + @Mock + public void save(Object object) { + } + @Mock + public void flush() { + } + }; + new MockUp<SessionFactory>() { + @Mock + public Session openSession() { + return mockedSession.getMockInstance(); + } + }; + new MockUp<Transaction>() { + @Mock + public void commit() { + } + }; + new MockUp<AlarmsHeaderServiceImpl>() { + @Mock + private Session getSession() { + return mockedSession.getMockInstance(); + } + }; } @After @@ -90,43 +128,6 @@ public class AlarmsHeaderServiceImplTest { ah.setUpdateTime(DateUtils.now()); ah.setVersion("va2"); - MockUp<Query> mockUpQuery = new MockUp<Query>() { - }; - MockUp<Session> mockedSession = new MockUp<Session>() { - @Mock - public Query createQuery(String sql) { - return mockUpQuery.getMockInstance(); - } - @Mock - public Transaction beginTransaction() { - return transaction; - } - @Mock - public void save(Object object) { - } - @Mock - public void flush() { - } - }; - new MockUp<SessionFactory>() { - @Mock - public Session openSession() { - return mockedSession.getMockInstance(); - } - }; - new MockUp<Transaction>() { - @Mock - public void commit() { - } - }; - new MockUp<AlarmsHeaderServiceImpl>() { - @Mock - private Session getSession() { - return mockedSession.getMockInstance(); - } - }; - - AlarmsHeaderServiceImpl alarmsHeaderServiceImpl = new AlarmsHeaderServiceImpl(); alarmsHeaderServiceImpl.saveAlarmsHeader(ah); } |