diff --git a/src/main/java/mil/dds/anet/beans/Report.java b/src/main/java/mil/dds/anet/beans/Report.java index 38115d0838..6f530909c5 100644 --- a/src/main/java/mil/dds/anet/beans/Report.java +++ b/src/main/java/mil/dds/anet/beans/Report.java @@ -788,7 +788,7 @@ public List getAuthorizationGroups() { @JsonIgnore public boolean isFutureEngagement() { - return engagementDate != null && engagementDate.isAfter(Utils.endOfToday()); + return engagementDate != null && engagementDate.isAfter(Instant.now()); } @GraphQLQuery(name = "engagementStatus") diff --git a/src/main/java/mil/dds/anet/search/AbstractReportSearcher.java b/src/main/java/mil/dds/anet/search/AbstractReportSearcher.java index 0a0d81a02e..6ff05f25df 100644 --- a/src/main/java/mil/dds/anet/search/AbstractReportSearcher.java +++ b/src/main/java/mil/dds/anet/search/AbstractReportSearcher.java @@ -3,6 +3,7 @@ import com.google.common.base.Joiner; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; +import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; @@ -29,7 +30,6 @@ import mil.dds.anet.database.ReportDao; import mil.dds.anet.search.AbstractSearchQueryBuilder.Comparison; import mil.dds.anet.utils.DaoUtils; -import mil.dds.anet.utils.Utils; public abstract class AbstractReportSearcher extends AbstractSearcher implements IReportSearcher { @@ -177,11 +177,11 @@ protected void buildQuery(Set subFields, ReportSearchQuery query) { switch (es) { case HAPPENED: engagementStatusClauses.add(" reports.\"engagementDate\" <= :endOfHappened"); - DaoUtils.addInstantAsLocalDateTime(qb.sqlArgs, "endOfHappened", Utils.endOfToday()); + DaoUtils.addInstantAsLocalDateTime(qb.sqlArgs, "endOfHappened", Instant.now()); break; case FUTURE: engagementStatusClauses.add(" reports.\"engagementDate\" > :startOfFuture"); - DaoUtils.addInstantAsLocalDateTime(qb.sqlArgs, "startOfFuture", Utils.endOfToday()); + DaoUtils.addInstantAsLocalDateTime(qb.sqlArgs, "startOfFuture", Instant.now()); break; case CANCELLED: engagementStatusClauses.add(" reports.state = :cancelledState"); diff --git a/src/main/java/mil/dds/anet/threads/FutureEngagementWorker.java b/src/main/java/mil/dds/anet/threads/FutureEngagementWorker.java index 7aae270625..6bf82e3b42 100644 --- a/src/main/java/mil/dds/anet/threads/FutureEngagementWorker.java +++ b/src/main/java/mil/dds/anet/threads/FutureEngagementWorker.java @@ -1,6 +1,7 @@ package mil.dds.anet.threads; import java.lang.invoke.MethodHandles; +import java.time.Instant; import java.util.List; import java.util.Map; import mil.dds.anet.AnetObjectEngine; @@ -8,7 +9,6 @@ import mil.dds.anet.beans.Report; import mil.dds.anet.database.ReportDao; import mil.dds.anet.emails.FutureEngagementUpdated; -import mil.dds.anet.utils.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +43,7 @@ private void runInternal() { // afterwards this report needs to go through the approval process of past // engagements. List reports = - AnetObjectEngine.getInstance().getReportDao().getFutureToPastReports(Utils.endOfToday()); + AnetObjectEngine.getInstance().getReportDao().getFutureToPastReports(Instant.now()); // update to draft state and send emails to the authors to let them know we updated their // report. diff --git a/src/main/java/mil/dds/anet/utils/Utils.java b/src/main/java/mil/dds/anet/utils/Utils.java index dd114f4aff..3acb2d2f4f 100644 --- a/src/main/java/mil/dds/anet/utils/Utils.java +++ b/src/main/java/mil/dds/anet/utils/Utils.java @@ -11,7 +11,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.lang.invoke.MethodHandles; -import java.time.Instant; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -450,14 +449,6 @@ private static Pattern domainToRegexPattern(final String domain, final String wi return Pattern.compile("^" + regex + "$"); } - - // Returns an instant representing the very end of today. - // Used to determine if a date is tomorrow or later. - public static Instant endOfToday() { - return Instant.now().atZone(DaoUtils.getDefaultZoneId()).withHour(23).withMinute(59) - .withSecond(59).withNano(999999999).toInstant(); - } - /** * Resizes an image. * diff --git a/src/test/java/mil/dds/anet/test/integration/db/FutureEngagementWorkerTest.java b/src/test/java/mil/dds/anet/test/integration/db/FutureEngagementWorkerTest.java index 09b442084d..2cd97e8d66 100644 --- a/src/test/java/mil/dds/anet/test/integration/db/FutureEngagementWorkerTest.java +++ b/src/test/java/mil/dds/anet/test/integration/db/FutureEngagementWorkerTest.java @@ -28,7 +28,6 @@ import mil.dds.anet.test.integration.utils.TestBeans; import mil.dds.anet.threads.AnetEmailWorker; import mil.dds.anet.threads.FutureEngagementWorker; -import mil.dds.anet.utils.Utils; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -119,7 +118,7 @@ public void testReportDueInFuture() { public void testReportDueEndToday() { final AnetObjectEngine engine = AnetObjectEngine.getInstance(); final Report report = createTestReport("testReportDueEndToday_1"); - report.setEngagementDate(Utils.endOfToday()); + report.setEngagementDate(Instant.now()); engine.getReportDao().update(report); expectedIds.add("testReportDueEndToday_1"); @@ -197,7 +196,7 @@ public void testApprovalStepReport() { ra.setStep(step); ra.setStepUuid(step.getUuid()); ra.setType(ActionType.APPROVE); - ra.setCreatedAt(Utils.endOfToday()); + ra.setCreatedAt(Instant.now()); engine.getReportActionDao().insert(ra); unexpectedIds.add("testApprovalStepReport_1");