diff --git a/pom.xml b/pom.xml index 68a484b..26501f1 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,18 @@ rocks.zipcode LogginLab1 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 14 + 14 + + + + junit diff --git a/src/main/java/LogginLab.java b/src/main/java/LogginLab.java index 11744ac..691fb41 100644 --- a/src/main/java/LogginLab.java +++ b/src/main/java/LogginLab.java @@ -32,6 +32,12 @@ public boolean thresholdExceeds(Integer limit) { return (this.threshold > limit); } + public boolean thresholdReached(int limit){ + if (limit > threshold) { + return true; + } + return false; + } // Write a method called thresholdReached, returns true if argument 'limit' is over the threshold. // 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..738eabd 100644 --- a/src/test/java/LogginLabTest.java +++ b/src/test/java/LogginLabTest.java @@ -14,6 +14,23 @@ public void setUp() throws Exception { public void tearDown() throws Exception { } + @org.junit.Test + public void thresholdReached() { + Integer finalLimit = 5; + + LogginLab lab = new LogginLab(); + lab.setThreshold(finalLimit); + + for (Integer i = 1; i <= finalLimit; i++) { + if (lab.thresholdReached(i)) { + logger.log(Level.INFO, "Threshold not reached! It is "+i); + assertTrue(lab.thresholdReached(i)); + } else { + logger.log(Level.INFO, "Threshold finally reached!"); + assertFalse(lab.thresholdReached(i)); + } + } + } @org.junit.Test public void thresholdExceeds() { Integer finalLimit = 5; @@ -31,4 +48,4 @@ public void thresholdExceeds() { } } } -} \ No newline at end of file +}