Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I have commited #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
16 changes: 16 additions & 0 deletions LogginLab1.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_19">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
</properties>


</project>
4 changes: 3 additions & 1 deletion src/main/java/LogginLab.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ public boolean thresholdExceeds(Integer 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); }
};

23 changes: 21 additions & 2 deletions src/test/java/LogginLabTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,33 @@ public void thresholdExceeds() {
LogginLab lab = new LogginLab();
lab.setThreshold(finalLimit);

for (Integer i = 1; i <= finalLimit; i++) {
for (Integer i = 1; i < finalLimit; i++) {
if (lab.thresholdExceeds(i)) {
logger.log(Level.INFO, "Threshold not reached! It is "+i);
logger.log(Level.INFO, "Threshold not reached! It is " + i);
assertTrue(lab.thresholdExceeds(i));
} else {
logger.log(Level.INFO, "Threshold finally reached!");
assertFalse(lab.thresholdExceeds(i));
}
}
}

@org.junit.Test
public void thresholdReached() {
Integer finalLimit = 5;

LogginLab lab = new LogginLab();
lab.setThreshold(finalLimit);

for (Integer i = 5; i == finalLimit; i++) {
if (lab.thresholdReached(i)) {
logger.log(Level.INFO, "Limit is not reached!" + i);
assertTrue(lab.thresholdReached(i));

} else {
logger.log(Level.INFO, "Limit finally reached!");
assertFalse(lab.thresholdReached(i));
}
}
}
}