-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3cee58
commit ff54bae
Showing
939 changed files
with
34,952 additions
and
31,258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,3 @@ public int getExpirationTimeInMinute() { | |
return this.expirationTime / 60; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 7 additions & 12 deletions
19
...in/java/io/openbas/collectors/expectations_expiration_manager/utils/ExpectationUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,27 @@ | ||
package io.openbas.collectors.expectations_expiration_manager.utils; | ||
|
||
import static io.openbas.database.model.InjectExpectation.EXPECTATION_TYPE.DETECTION; | ||
import static io.openbas.database.model.InjectExpectation.EXPECTATION_TYPE.PREVENTION; | ||
|
||
import io.openbas.database.model.InjectExpectation; | ||
import io.openbas.database.model.InjectExpectation.EXPECTATION_TYPE; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
import java.time.Instant; | ||
import java.time.temporal.ChronoUnit; | ||
|
||
import static io.openbas.database.model.InjectExpectation.EXPECTATION_TYPE.DETECTION; | ||
import static io.openbas.database.model.InjectExpectation.EXPECTATION_TYPE.PREVENTION; | ||
|
||
public class ExpectationUtils { | ||
|
||
private ExpectationUtils() { | ||
|
||
} | ||
private ExpectationUtils() {} | ||
|
||
public static boolean isExpired(@NotNull final InjectExpectation expectation) { | ||
Instant expirationTime = Instant.now().minus(expectation.getExpirationTime() / 60, ChronoUnit.MINUTES); | ||
Instant expirationTime = | ||
Instant.now().minus(expectation.getExpirationTime() / 60, ChronoUnit.MINUTES); | ||
return expectation.getCreatedAt().isBefore(expirationTime); | ||
} | ||
|
||
public static String computeFailedMessage(@NotNull final EXPECTATION_TYPE expectationType) { | ||
return DETECTION.equals(expectationType) | ||
? "Not Detected" | ||
: PREVENTION.equals(expectationType) | ||
? "Not Prevented" | ||
: "FAILED"; | ||
: PREVENTION.equals(expectationType) ? "Not Prevented" : "FAILED"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.