From ce22a669e75d1a0b9f7dbd1abe08dc42b524067c Mon Sep 17 00:00:00 2001 From: dhannyamohangeetha Date: Fri, 3 Mar 2023 22:19:38 -0500 Subject: [PATCH] Logginlab completed --- src/main/java/LogginLab.java | 12 ++++++++++-- src/test/java/LogginLabTest.java | 19 ++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/main/java/LogginLab.java b/src/main/java/LogginLab.java index 0b4965f..dde8707 100644 --- a/src/main/java/LogginLab.java +++ b/src/main/java/LogginLab.java @@ -29,12 +29,20 @@ public void setThreshold(Integer threshold) { } public boolean thresholdExceeds(Integer limit) { - if (this.threshold > limit) - return true; + if (this.threshold > limit) + return true; else return false; } + public boolean thresholdReached(int limit) { + if (limit > threshold) { + return true; + } else { + return false; + } + + } // Write a method called thresholdReached, returns true if argument 'limit' is over the threshold. // use thresholdExceeds for a pattern. // Write a test for the method in the Test class. diff --git a/src/test/java/LogginLabTest.java b/src/test/java/LogginLabTest.java index be1c95f..afbdb0b 100644 --- a/src/test/java/LogginLabTest.java +++ b/src/test/java/LogginLabTest.java @@ -20,7 +20,6 @@ public void thresholdExceeds() { LogginLab lab = new LogginLab(); lab.setThreshold(finalLimit); - for (Integer i = 1; i <= finalLimit; i++) { if (lab.thresholdExceeds(i)) { logger.log(Level.INFO, "Threshold not reached! It is "+i); @@ -31,4 +30,22 @@ public void thresholdExceeds() { } } } + + @org.junit.Test + public void thresholdExceeds() { + Integer finalLimit = 6; + + LogginLab lab = new LogginLab(); + lab.setThreshold(finalLimit); + + for (Integer i = 1; i <= finalLimit; i++) { + if (lab.thresholdReached(i)) { + logger.log(Level.INFO, "Threshold finally reached!"); + assertTrue(lab.thresholdExceeds(i)); + } else { + logger.log(Level.INFO, "Threshold not reached! It is "+i); + assertFalse(lab.thresholdReached(i)); + } + } + } } \ No newline at end of file