Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main/java/LogginLab.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/LogginLabTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}

}