diff --git a/src/main/java/LogginLab.java b/src/main/java/LogginLab.java index 0b4965f..afc45c6 100644 --- a/src/main/java/LogginLab.java +++ b/src/main/java/LogginLab.java @@ -4,7 +4,7 @@ public class LogginLab { private final static Logger logger = Logger.getLogger(LogginLab.class.getName()); - private Integer threshold = 0; + private Integer threshold; public LogginLab() { this.threshold = 0; @@ -35,6 +35,14 @@ public boolean thresholdExceeds(Integer limit) { return false; } + public boolean thresholdReached(Integer limit) { + if (limit > this.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..bbb7d6a 100644 --- a/src/test/java/LogginLabTest.java +++ b/src/test/java/LogginLabTest.java @@ -31,4 +31,22 @@ public void thresholdExceeds() { } } } + @org.junit.Test + public void thresholdReached() { + Integer finalLimit = 5; + + LogginLab lab = new LogginLab(); + lab.setThreshold(finalLimit); + + for (Integer i = 1; i <= finalLimit +1; i++) { + if (lab.thresholdReached(i)) { + logger.log(Level.INFO, "Threshold is over the limit of " + finalLimit + " with a value of " + i); + assertTrue(lab.thresholdReached(i)); + } else { + logger.log(Level.INFO, "Threshold is at " + i + " still not over the limit of " + finalLimit); + assertFalse(lab.thresholdReached(i)); + } + } + } + } \ No newline at end of file