From 1f4b2ed804e2ab8de339318398da5d34cb40f298 Mon Sep 17 00:00:00 2001 From: yurak Date: Thu, 16 Feb 2023 18:47:06 +0900 Subject: [PATCH] Invoke method(s) only conditionally by sonarcloud #3049 --- .../tier/schedule/CallRandomPublshSchedule.java | 16 +++++++++++++--- .../schedule/CallRandomPublshScheduleTest.java | 3 +-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/application/scheduled-quarkus/src/main/java/webapp/tier/schedule/CallRandomPublshSchedule.java b/application/scheduled-quarkus/src/main/java/webapp/tier/schedule/CallRandomPublshSchedule.java index d1536822f..349b56eb7 100644 --- a/application/scheduled-quarkus/src/main/java/webapp/tier/schedule/CallRandomPublshSchedule.java +++ b/application/scheduled-quarkus/src/main/java/webapp/tier/schedule/CallRandomPublshSchedule.java @@ -1,5 +1,6 @@ package webapp.tier.schedule; +import java.util.Objects; import java.util.logging.Level; import java.util.logging.Logger; @@ -46,11 +47,20 @@ void callRandomPublsh() { @Scheduled(every = "10m") void callDeleteDbs() { logger.log(Level.INFO, "Call: Delete Postgres"); - logger.log(Level.INFO, postgressvc.delete()); + String pstgresp = postgressvc.delete(); + if(!Objects.isNull(pstgresp)) { + logger.log(Level.INFO, pstgresp); + } logger.log(Level.INFO, "Call: Delete Mysql"); - logger.log(Level.INFO, mysqlsvc.delete()); + String mysqlresp = mysqlsvc.delete(); + if(!Objects.isNull(mysqlresp)) { + logger.log(Level.INFO, mysqlresp); + } logger.log(Level.INFO, "Call: Delete Mongodb"); - logger.log(Level.INFO, mongodbsvc.delete()); + String mongoresp = mongodbsvc.delete(); + if(!Objects.isNull(mongoresp)) { + logger.log(Level.INFO, mongoresp); + } } } diff --git a/application/scheduled-quarkus/src/test/java/webapp/tier/schedule/CallRandomPublshScheduleTest.java b/application/scheduled-quarkus/src/test/java/webapp/tier/schedule/CallRandomPublshScheduleTest.java index b10dc7f25..729509c0d 100644 --- a/application/scheduled-quarkus/src/test/java/webapp/tier/schedule/CallRandomPublshScheduleTest.java +++ b/application/scheduled-quarkus/src/test/java/webapp/tier/schedule/CallRandomPublshScheduleTest.java @@ -25,7 +25,7 @@ void testCallRandomPublsh() { } @Test - void testCallDeleteDbsError() { + void testCallDeleteDbs() { try { rps.callDeleteDbs(); } catch (Exception expected) { @@ -33,5 +33,4 @@ void testCallDeleteDbsError() { fail(); } } - }