diff options
author | zhangab <zhanganbing@chinamobile.com> | 2018-03-28 09:28:46 +0800 |
---|---|---|
committer | zhangab <zhanganbing@chinamobile.com> | 2018-03-28 09:28:50 +0800 |
commit | e38578b73d84b2de66ba748f40ba538124bbfffe (patch) | |
tree | b878d7f173ac72782270849f680bf9aeb67be7f4 | |
parent | fc8d3f3e4def8b976b2d7c8f2b7bdeb3f838b601 (diff) |
improve sonar coverage for uui-server
Change-Id: I1bfa1d75a840f6dfab12198eaba403e585a75be6
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 | 22 |
1 files changed, 12 insertions, 10 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 4e8c3db3..75c996ee 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 @@ -34,9 +34,8 @@ import java.util.Date; import org.hibernate.Session; import org.hibernate.SessionFactory; -import mockit.Expectations; -import mockit.Mocked; -import mockit.integration.junit4.JMockit; +import mockit.Mock; +import mockit.MockUp; /** * AlarmsHeaderServiceImpl Tester. * @@ -44,7 +43,6 @@ import mockit.integration.junit4.JMockit; * @since <pre>8, 2018</pre> * @version 1.0 */ -@RunWith(JMockit.class) public class AlarmsHeaderServiceImplTest { @Before public void before() throws Exception { @@ -60,9 +58,7 @@ public class AlarmsHeaderServiceImplTest { * */ @Test -public void testSaveAlarmsHeader(@Mocked SessionFactory sessionFactory, - @Mocked Session session -) throws Exception { +public void testSaveAlarmsHeader() throws Exception { //TODO: Test goes here... AlarmsHeader a = new AlarmsHeader(); a.setEventName("a"); @@ -92,9 +88,15 @@ public void testSaveAlarmsHeader(@Mocked SessionFactory sessionFactory, a.setUpdateTime(DateUtils.now()); a.setVersion("va2"); - new Expectations() {{ - sessionFactory.openSession(); result = session; - }}; + MockUp<Session> mockedSession = new MockUp<Session>() { + }; + + new MockUp<SessionFactory>() { + @Mock + private Session openSession() { + return mockedSession.getMockInstance(); + } + }; AlarmsHeaderServiceImpl alarmsHeaderServiceImpl = new AlarmsHeaderServiceImpl(); System.out.println(alarmsHeaderServiceImpl.saveAlarmsHeader(a)); |