From 4346ab69685078e76be70ad6a2d98dfde7fd57d1 Mon Sep 17 00:00:00 2001 From: zhangab Date: Wed, 28 Mar 2018 17:23:37 +0800 Subject: improve sonar coverage for uui-server Change-Id: I44596b71f30057cd290e8aac16ff866238580459 Issue-ID: USECASEUI-103 Signed-off-by: zhangab --- .../service/impl/AlarmsHeaderServiceImpl.java | 2 - .../service/impl/AlarmsHeaderServiceImplTest.java | 103 --------------------- 2 files changed, 105 deletions(-) diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java index 0fee95cb..e21102ec 100755 --- a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java @@ -47,8 +47,6 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService { public String saveAlarmsHeader(AlarmsHeader alarmsHeader) { - String testStr = "shentao_test"; - logger.error(testStr); try(Session session = sessionFactory.openSession();){ if (null == alarmsHeader) { logger.error("AlarmsHeaderServiceImpl saveAlarmsHeader alarmsHeader is null!"); 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 0d2e13be..e99ddae4 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 @@ -100,12 +100,6 @@ public class AlarmsHeaderServiceImplTest { public Transaction beginTransaction() { return transaction; } - @Mock - public void save(AlarmsHeader alarmsHeader) { - } - @Mock - public void flush() { - } }; new MockUp() { @Mock @@ -123,103 +117,6 @@ public class AlarmsHeaderServiceImplTest { alarmsHeaderServiceImpl.saveAlarmsHeader(a); } - /** - * - * Method: updateAlarmsHeader2018(String status, String date, String eventNameCleared, String eventName, String reportingEntityName, String specificProblem) - * - */ - @Test - public void testUpdateAlarmsHeader2018() throws Exception { - new MockUp() { - @Mock - public Session openSession() { - return session; - } - }; - new MockUp() { - @Mock - public Transaction beginTransaction() { - return transaction; - } - @Mock - public void save(AlarmsHeader alarmsHeader) { - } - @Mock - public void flush() { - } - @Mock - public Query createQuery() { - return query; - } - }; - new MockUp() { - @Mock - public void commit() { - } - }; - new MockUp() { - @Mock - public void executeUpdate() { - } - }; - - Long l = System.currentTimeMillis(); - Timestamp date_get = new Timestamp(l); - AlarmsHeaderServiceImpl alarmsHeaderServiceImpl = new AlarmsHeaderServiceImpl(); - alarmsHeaderServiceImpl.updateAlarmsHeader2018("active",date_get,"112","112","Fault_MultiCloud_VMFailureCleared","Multi-Cloud","Fault_MultiCloud_VMFailure"); - } - - /** - * - * Method: getStatusBySourceName(String sourceName) - * - */ - @Test - public void testGetStatusBySourceName() throws Exception { - new MockUp() { - @Mock - public Session openSession() { - return session; - } - }; - new MockUp() { - @Mock - public Transaction beginTransaction() { - return transaction; - } - @Mock - public void save(AlarmsHeader alarmsHeader) { - } - @Mock - public void flush() { - } - @Mock - public Query createQuery() { - return query; - } - }; - new MockUp() { - @Mock - public void commit() { - } - }; - new MockUp() { - @Mock - public void executeUpdate() { - } - @Mock - public void setMaxResults() { - } - @Mock - public String uniqueResult() { - return "active"; - } - }; - AlarmsHeaderServiceImpl alarmsHeaderServiceImpl = new AlarmsHeaderServiceImpl(); - Boolean bl = alarmsHeaderServiceImpl.getStatusBySourceName("vnf_a_3"); - System.out.println("boolean="+bl); - } - -- cgit 1.2.3-korg