diff options
author | zhangab <zhanganbing@chinamobile.com> | 2018-04-04 15:09:50 +0800 |
---|---|---|
committer | zhangab <zhanganbing@chinamobile.com> | 2018-04-04 15:09:54 +0800 |
commit | 8756fd16d1ee828dd67e03fa240cbf4d1d181c51 (patch) | |
tree | 3a462bcfd60f2badf8bdb27e933a4f68e5ba89f2 | |
parent | 210ca669dadf91521d4cea1927df0bd3f2da21d4 (diff) |
improve sonar coverage for uui-server
Change-Id: I58d8530748289421d79f0fd4ae2c303f13a2e813
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 | 81 |
1 files changed, 69 insertions, 12 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 db3d3855..12553986 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 @@ -50,12 +50,41 @@ import mockit.MockUp; */ public class AlarmsHeaderServiceImplTest { AlarmsHeaderServiceImpl alarmsHeaderServiceImpl = null; + private static final long serialVersionUID = 1L; @Before public void before() throws Exception { alarmsHeaderServiceImpl = new AlarmsHeaderServiceImpl(); + + 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 int executeUpdate(String name, Date value) { + return 0; + } + @Mock + public Query setMaxResults(int value) { + return mockUpQuery.getMockInstance(); + } + @Mock + public Object uniqueResult() { + return "result"; + } + }; MockUp<Session> mockedSession = new MockUp<Session>() { @Mock public Query createQuery(String sql) { @@ -63,7 +92,11 @@ public class AlarmsHeaderServiceImplTest { } @Mock public Transaction beginTransaction() { - return transaction; + return mockUpTransaction.getMockInstance(); + } + @Mock + public Transaction getTransaction() { + return mockUpTransaction.getMockInstance(); } @Mock public Serializable save(Object object) { @@ -91,23 +124,47 @@ public class AlarmsHeaderServiceImplTest { public void after() throws Exception { } - private static final long serialVersionUID = 1L; - private Session session; - private Transaction transaction; - private Query query; - @Test public void testSaveAlarmsHeader() throws Exception { - new MockUp<Transaction>() { - @Mock - public void commit() { - } - }; - AlarmsHeader ah = null; + AlarmsHeader ah = new AlarmsHeader(); + ah.setEventName("a"); + ah.setStatus("1"); + ah.setVfStatus("1"); + ah.setEventId("1119"); + ah.setDomain("asb"); + ah.setEventCategory("s"); + ah.setAlarmCondition("ea"); + ah.setAlarmInterfaceA("cs"); + ah.setCreateTime(DateUtils.now()); + ah.setEventServrity("s"); + ah.setEventSourceType("q"); + ah.setEventType("q"); + ah.setFaultFieldsVersion("v1"); + ah.setLastEpochMicroSec("csa"); + ah.setNfcNamingCode("std"); + ah.setNfNamingCode("cout"); + ah.setPriority("cs"); + ah.setReportingEntityId("112"); + ah.setReportingEntityName("asfs"); + ah.setSequence("cgg"); + ah.setSourceId("123"); + ah.setSourceName("eggs"); + ah.setSpecificProblem("especially"); + ah.setStartEpochMicrosec("wallet"); + ah.setUpdateTime(DateUtils.now()); + ah.setVersion("va2"); alarmsHeaderServiceImpl.saveAlarmsHeader(ah); } + @Test + public void testUpdateAlarmsHeader2018() throws Exception { + alarmsHeaderServiceImpl.updateAlarmsHeader2018("status", new Timestamp(System.currentTimeMillis()), "startEpochMicrosecCleared", "lastEpochMicroSecCleared", "eventName", "reportingEntityName", "specificProblem"); + } + @Test + public void testGetStatusBySourceName() throws Exception { + alarmsHeaderServiceImpl.getStatusBySourceName("sourceName"); + } |