Skip to content

Commit

Permalink
Periodic reports no long flush report items at initialization. (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnhatch authored Oct 25, 2024
1 parent 73be5ce commit 81cf47b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -168,7 +168,7 @@ public void testHourlyReport() {

Map<ReportItem, Integer> expectedReportItems = expectedConsumer.getOutputItemMap(ReportItem.class);
Map<ReportItem, Integer> actualReportItems = testOutputConsumer.getOutputItemMap(ReportItem.class);

assertEquals(expectedReportItems, actualReportItems);

}
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ protected void flush(ReportContext reportContext) {

@Override
protected void prepare(ReportContext reportContext) {
//does nothing
// does nothing

}

}
Expand Down Expand Up @@ -86,13 +86,12 @@ protected void flush(ReportContext reportContext) {
reportContext.releaseOutput(reportItem);

}

@Override
protected void prepare(ReportContext reportContext) {
//does nothing

}
// does nothing

}

}

Expand Down Expand Up @@ -138,13 +137,12 @@ protected void flush(ReportContext reportContext) {

reportContext.releaseOutput(reportItem);
}

@Override
protected void prepare(ReportContext reportContext) {
//does nothing

}
// does nothing

}

}

Expand Down Expand Up @@ -180,11 +178,11 @@ protected void flush(ReportContext reportContext) {

assertEquals(0, reportItem.size());
}

@Override
protected void prepare(ReportContext reportContext) {
//does nothing
// does nothing

}

}
Expand All @@ -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

}

}
Expand Down Expand Up @@ -294,7 +292,7 @@ public void testFillTimeFields_Daily() {

int maxDay = (int) FastMath.ceil(simulationEndTime);
Set<Integer> expectedDays = new LinkedHashSet<>();
for (int i = 0; i <= maxDay; i++) {
for (int i = 1; i <= maxDay; i++) {
expectedDays.add(i);
}

Expand Down Expand Up @@ -343,7 +341,7 @@ public void testFillTimeFields_Hourly() {

// hours 0 through 3d 15h inclusive
Set<Integer> expectedHours = new LinkedHashSet<>();
for (int i = 0; i < 88; i++) {
for (int i = 1; i < 88; i++) {
expectedHours.add(i);
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down

0 comments on commit 81cf47b

Please sign in to comment.