From eacfd659ed404f7ec84ac40a5e7c6582bac7b029 Mon Sep 17 00:00:00 2001 From: Jorge Date: Fri, 26 Feb 2021 18:58:06 -0500 Subject: [PATCH 1/2] added limit check method and test 2 --- src/main/java/LogginLab.java | 6 +++++- src/test/java/LogginLabTest.java | 24 ++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/main/java/LogginLab.java b/src/main/java/LogginLab.java index 11744ac..c4e9acb 100644 --- a/src/main/java/LogginLab.java +++ b/src/main/java/LogginLab.java @@ -31,7 +31,11 @@ public void setThreshold(Integer threshold) { public boolean thresholdExceeds(Integer limit) { return (this.threshold > limit); } - + public boolean thresholdReached(Integer limit) + { + return (this.threshold < limit); + } // 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..8215cab 100644 --- a/src/test/java/LogginLabTest.java +++ b/src/test/java/LogginLabTest.java @@ -1,9 +1,11 @@ +import org.junit.Test; + import java.util.logging.Level; import java.util.logging.Logger; import static org.junit.Assert.*; -public class LogginLabTest { +public class LogginLabTest { private final static Logger logger = Logger.getLogger(LogginLab.class.getName()); @org.junit.Before @@ -14,7 +16,7 @@ public void setUp() throws Exception { public void tearDown() throws Exception { } - @org.junit.Test + @Test public void thresholdExceeds() { Integer finalLimit = 5; @@ -31,4 +33,22 @@ public void thresholdExceeds() { } } } + + @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, "true"); + assertTrue(lab.thresholdReached(i)); + } else { + logger.log(Level.INFO, "false"); + assertFalse(lab.thresholdReached(i)); + } + } + } } \ No newline at end of file From a4ca9bc0de9e212d0c73e2ac9ae44284ba6dcc72 Mon Sep 17 00:00:00 2001 From: Jorge Date: Fri, 26 Feb 2021 22:04:00 -0500 Subject: [PATCH 2/2] Modified thresholdReached and TestClass --- src/main/java/LogginLab.java | 4 ++-- src/test/java/LogginLabTest.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/LogginLab.java b/src/main/java/LogginLab.java index c4e9acb..dd1aa83 100644 --- a/src/main/java/LogginLab.java +++ b/src/main/java/LogginLab.java @@ -33,8 +33,8 @@ public boolean thresholdExceeds(Integer limit) { } public boolean thresholdReached(Integer limit) { - return (this.threshold < limit); - } + return (this.threshold < limit); + } // 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 8215cab..61640ad 100644 --- a/src/test/java/LogginLabTest.java +++ b/src/test/java/LogginLabTest.java @@ -37,16 +37,16 @@ public void thresholdExceeds() { @Test public void thresholdReached() { Integer finalLimit = 5; - + Integer largerLimit = 6; LogginLab lab = new LogginLab(); lab.setThreshold(finalLimit); - for (Integer i = 1; i <= finalLimit; i++) { + for (Integer i = 1; i <= largerLimit; i++) { if (lab.thresholdReached(i)) { - logger.log(Level.INFO, "true"); + logger.log(Level.INFO, "True " + i); assertTrue(lab.thresholdReached(i)); } else { - logger.log(Level.INFO, "false"); + logger.log(Level.INFO, "False " + i); assertFalse(lab.thresholdReached(i)); } }