From 81cf47b65228bd83b4fd673ac57687cf2d52dd23 Mon Sep 17 00:00:00 2001 From: shawnhatch <30730734+shawnhatch@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:10:44 -0400 Subject: [PATCH] Periodic reports no long flush report items at initialization. (#267) --- .../reports/support/PeriodicReport.java | 3 -- .../reports/AT_GroupPopulationReport.java | 14 +++---- .../reports/AT_PersonPropertyReport.java | 8 ++-- .../reports/support/AT_PeriodicReport.java | 38 +++++++++---------- 4 files changed, 29 insertions(+), 34 deletions(-) diff --git a/simulation/src/main/java/gov/hhs/aspr/ms/gcm/simulation/plugins/reports/support/PeriodicReport.java b/simulation/src/main/java/gov/hhs/aspr/ms/gcm/simulation/plugins/reports/support/PeriodicReport.java index 77f00867b..ce0e38963 100644 --- a/simulation/src/main/java/gov/hhs/aspr/ms/gcm/simulation/plugins/reports/support/PeriodicReport.java +++ b/simulation/src/main/java/gov/hhs/aspr/ms/gcm/simulation/plugins/reports/support/PeriodicReport.java @@ -127,13 +127,10 @@ public final void init(ReportContext reportContext) { prepare(reportContext); - if (reportContext.getTime() == 0) { if (reportPeriod != ReportPeriod.END_OF_SIMULATION) { - flush(reportContext); incrementReportingTimeFields(); reportContext.addPlan(this::executePlan, getNextPlanTime()); } - } } /** diff --git a/simulation/src/test/java/gov/hhs/aspr/ms/gcm/simulation/plugins/groups/reports/AT_GroupPopulationReport.java b/simulation/src/test/java/gov/hhs/aspr/ms/gcm/simulation/plugins/groups/reports/AT_GroupPopulationReport.java index 40290b0b3..f474016eb 100644 --- a/simulation/src/test/java/gov/hhs/aspr/ms/gcm/simulation/plugins/groups/reports/AT_GroupPopulationReport.java +++ b/simulation/src/test/java/gov/hhs/aspr/ms/gcm/simulation/plugins/groups/reports/AT_GroupPopulationReport.java @@ -115,9 +115,9 @@ public void testHourlyReport() { // place the initial data into the expected output consumer TestOutputConsumer expectedConsumer = new TestOutputConsumer(); - expectedConsumer.accept(getReportItem(ReportPeriod.HOURLY, 0, 0, TestGroupTypeId.GROUP_TYPE_1, 3, 1)); - expectedConsumer.accept(getReportItem(ReportPeriod.HOURLY, 0, 0, TestGroupTypeId.GROUP_TYPE_2, 3, 1)); - expectedConsumer.accept(getReportItem(ReportPeriod.HOURLY, 0, 0, TestGroupTypeId.GROUP_TYPE_3, 0, 1)); +// expectedConsumer.accept(getReportItem(ReportPeriod.HOURLY, 0, 0, TestGroupTypeId.GROUP_TYPE_1, 3, 1)); +// expectedConsumer.accept(getReportItem(ReportPeriod.HOURLY, 0, 0, TestGroupTypeId.GROUP_TYPE_2, 3, 1)); +// expectedConsumer.accept(getReportItem(ReportPeriod.HOURLY, 0, 0, TestGroupTypeId.GROUP_TYPE_3, 0, 1)); for (int hour = 1; hour < 24; hour++) { expectedConsumer.accept(getReportItem(ReportPeriod.HOURLY, 0, hour, TestGroupTypeId.GROUP_TYPE_1, 3, 2)); @@ -168,7 +168,7 @@ public void testHourlyReport() { Map expectedReportItems = expectedConsumer.getOutputItemMap(ReportItem.class); Map actualReportItems = testOutputConsumer.getOutputItemMap(ReportItem.class); - + assertEquals(expectedReportItems, actualReportItems); } @@ -248,9 +248,9 @@ public void testDailyReport() { // place the initial data into the expected output consumer - expectedConsumer.accept(getReportItem(ReportPeriod.DAILY, 0, TestGroupTypeId.GROUP_TYPE_1, 3, 1)); - expectedConsumer.accept(getReportItem(ReportPeriod.DAILY, 0, TestGroupTypeId.GROUP_TYPE_2, 3, 1)); - expectedConsumer.accept(getReportItem(ReportPeriod.DAILY, 0, TestGroupTypeId.GROUP_TYPE_3, 0, 1)); +// expectedConsumer.accept(getReportItem(ReportPeriod.DAILY, 0, TestGroupTypeId.GROUP_TYPE_1, 3, 1)); +// expectedConsumer.accept(getReportItem(ReportPeriod.DAILY, 0, TestGroupTypeId.GROUP_TYPE_2, 3, 1)); +// expectedConsumer.accept(getReportItem(ReportPeriod.DAILY, 0, TestGroupTypeId.GROUP_TYPE_3, 0, 1)); expectedConsumer.accept(getReportItem(ReportPeriod.DAILY, 1, TestGroupTypeId.GROUP_TYPE_1, 3, 2)); expectedConsumer.accept(getReportItem(ReportPeriod.DAILY, 1, TestGroupTypeId.GROUP_TYPE_2, 3, 1)); diff --git a/simulation/src/test/java/gov/hhs/aspr/ms/gcm/simulation/plugins/personproperties/reports/AT_PersonPropertyReport.java b/simulation/src/test/java/gov/hhs/aspr/ms/gcm/simulation/plugins/personproperties/reports/AT_PersonPropertyReport.java index 7b3be5435..27ecdb4d9 100644 --- a/simulation/src/test/java/gov/hhs/aspr/ms/gcm/simulation/plugins/personproperties/reports/AT_PersonPropertyReport.java +++ b/simulation/src/test/java/gov/hhs/aspr/ms/gcm/simulation/plugins/personproperties/reports/AT_PersonPropertyReport.java @@ -220,10 +220,10 @@ public String toString() { TestOutputConsumer expectedOutputConsumer = new TestOutputConsumer(); // expected report at time 0 - expectedOutputConsumer.accept(getReportItem(ReportPeriod.DAILY, 0, TestRegionId.REGION_1, TestPersonPropertyId.PERSON_PROPERTY_1_BOOLEAN_MUTABLE_NO_TRACK, false, 15)); - expectedOutputConsumer.accept(getReportItem(ReportPeriod.DAILY, 0, TestRegionId.REGION_1, TestPersonPropertyId.PERSON_PROPERTY_2_INTEGER_MUTABLE_NO_TRACK, 0, 15)); - expectedOutputConsumer.accept(getReportItem(ReportPeriod.DAILY, 0, TestRegionId.REGION_2, TestPersonPropertyId.PERSON_PROPERTY_1_BOOLEAN_MUTABLE_NO_TRACK, false, 15)); - expectedOutputConsumer.accept(getReportItem(ReportPeriod.DAILY, 0, TestRegionId.REGION_2, TestPersonPropertyId.PERSON_PROPERTY_2_INTEGER_MUTABLE_NO_TRACK, 0, 15)); +// expectedOutputConsumer.accept(getReportItem(ReportPeriod.DAILY, 0, TestRegionId.REGION_1, TestPersonPropertyId.PERSON_PROPERTY_1_BOOLEAN_MUTABLE_NO_TRACK, false, 15)); +// expectedOutputConsumer.accept(getReportItem(ReportPeriod.DAILY, 0, TestRegionId.REGION_1, TestPersonPropertyId.PERSON_PROPERTY_2_INTEGER_MUTABLE_NO_TRACK, 0, 15)); +// expectedOutputConsumer.accept(getReportItem(ReportPeriod.DAILY, 0, TestRegionId.REGION_2, TestPersonPropertyId.PERSON_PROPERTY_1_BOOLEAN_MUTABLE_NO_TRACK, false, 15)); +// expectedOutputConsumer.accept(getReportItem(ReportPeriod.DAILY, 0, TestRegionId.REGION_2, TestPersonPropertyId.PERSON_PROPERTY_2_INTEGER_MUTABLE_NO_TRACK, 0, 15)); // expected report at time 1 expectedOutputConsumer.accept(getReportItem(ReportPeriod.DAILY, 1, TestRegionId.REGION_1, TestPersonPropertyId.PERSON_PROPERTY_1_BOOLEAN_MUTABLE_NO_TRACK, false, 15)); diff --git a/simulation/src/test/java/gov/hhs/aspr/ms/gcm/simulation/plugins/reports/support/AT_PeriodicReport.java b/simulation/src/test/java/gov/hhs/aspr/ms/gcm/simulation/plugins/reports/support/AT_PeriodicReport.java index 7ad25a9e5..a5e6a7bbc 100644 --- a/simulation/src/test/java/gov/hhs/aspr/ms/gcm/simulation/plugins/reports/support/AT_PeriodicReport.java +++ b/simulation/src/test/java/gov/hhs/aspr/ms/gcm/simulation/plugins/reports/support/AT_PeriodicReport.java @@ -42,8 +42,8 @@ protected void flush(ReportContext reportContext) { @Override protected void prepare(ReportContext reportContext) { - //does nothing - + // does nothing + } } @@ -86,13 +86,12 @@ protected void flush(ReportContext reportContext) { reportContext.releaseOutput(reportItem); } - + @Override protected void prepare(ReportContext reportContext) { - //does nothing - - } + // does nothing + } } @@ -138,13 +137,12 @@ protected void flush(ReportContext reportContext) { reportContext.releaseOutput(reportItem); } - + @Override protected void prepare(ReportContext reportContext) { - //does nothing - - } + // does nothing + } } @@ -180,11 +178,11 @@ protected void flush(ReportContext reportContext) { assertEquals(0, reportItem.size()); } - + @Override protected void prepare(ReportContext reportContext) { - //does nothing - + // does nothing + } } @@ -200,11 +198,11 @@ public InitTestReport(ReportLabel reportLabel, ReportPeriod reportPeriod) { protected void flush(ReportContext reportContext) { flushTimes.add(reportContext.getTime()); } - + @Override protected void prepare(ReportContext reportContext) { - //does nothing - + // does nothing + } } @@ -294,7 +292,7 @@ public void testFillTimeFields_Daily() { int maxDay = (int) FastMath.ceil(simulationEndTime); Set expectedDays = new LinkedHashSet<>(); - for (int i = 0; i <= maxDay; i++) { + for (int i = 1; i <= maxDay; i++) { expectedDays.add(i); } @@ -343,7 +341,7 @@ public void testFillTimeFields_Hourly() { // hours 0 through 3d 15h inclusive Set expectedHours = new LinkedHashSet<>(); - for (int i = 0; i < 88; i++) { + for (int i = 1; i < 88; i++) { expectedHours.add(i); } @@ -451,7 +449,7 @@ public void testInit() { switch (reportPeriod) { case DAILY: int lastDay = (int) simulationEndTime; - for (int i = 0; i <= lastDay; i++) { + for (int i = 1; i <= lastDay; i++) { double time = i; expectedTimes.add(time); } @@ -464,7 +462,7 @@ public void testInit() { case HOURLY: int lastHour = (int) (simulationEndTime * 24); - for (int i = 0; i <= lastHour; i++) { + for (int i = 1; i <= lastHour; i++) { double time = i; time /= 24; expectedTimes.add(time);