From e6d6f3174cb805ea7acdab92c0e99f173c3ef7c5 Mon Sep 17 00:00:00 2001 From: johnS93 Date: Sat, 26 Jun 2021 00:06:38 -0400 Subject: [PATCH] I have a problem with LoginLab --- LogginLab1.iml | 16 ++++++++++++++++ pom.xml | 17 +++++++++++++++++ src/main/java/LogginLab.java | 8 ++++++-- src/test/java/LogginLabTest.java | 24 +++++++++++++++++++++++- 4 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 LogginLab1.iml diff --git a/LogginLab1.iml b/LogginLab1.iml new file mode 100644 index 0000000..450282a --- /dev/null +++ b/LogginLab1.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 68a484b..dbed95b 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,23 @@ rocks.zipcode LogginLab1 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 14 + 14 + + + + + + 1.4 + 1.4 + + junit diff --git a/src/main/java/LogginLab.java b/src/main/java/LogginLab.java index 11744ac..0508817 100644 --- a/src/main/java/LogginLab.java +++ b/src/main/java/LogginLab.java @@ -32,6 +32,10 @@ public boolean thresholdExceeds(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. + + public boolean thresholdReached(Integer limit) { + return (this.threshold < limit ); + } + } + diff --git a/src/test/java/LogginLabTest.java b/src/test/java/LogginLabTest.java index be1c95f..539220a 100644 --- a/src/test/java/LogginLabTest.java +++ b/src/test/java/LogginLabTest.java @@ -14,8 +14,29 @@ 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() { + public void thresholdExeeds() { Integer finalLimit = 5; LogginLab lab = new LogginLab(); @@ -29,6 +50,7 @@ public void thresholdExceeds() { logger.log(Level.INFO, "Threshold finally reached!"); assertFalse(lab.thresholdExceeds(i)); } + } } } \ No newline at end of file