-
Notifications
You must be signed in to change notification settings - Fork 6
Recording refreshFrom, remove unnecessary interface #461
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
Conversation
|
|
||
| private final LocalDate targetDate = LocalDate.of(2025, 1, 1); | ||
| private final Instant targetDateAsInstant = targetDate.atStartOfDay().toInstant(ZoneOffset.UTC); | ||
| private static final LocalDate targetDate = LocalDate.of(2025, 1, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By convention, static final should be all uppercase
i.e. TARGET_DATE, ONE_DAY_EARLIER, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather make them non-static 😓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With @sophia-chen-ttd 's suggestion no longer need those.
| var result1 = saltRotation.rotateSalts(lastSnapshot, minAges, 0.2, targetDate); | ||
| assertFalse(result1.hasSnapshot()); | ||
| final ISaltRotation.Result result2 = saltRotation.rotateSalts(lastSnapshot, minAges, 0.2, targetDate.minusDays(1)); | ||
| var result2 = saltRotation.rotateSalts(lastSnapshot, minAges, 0.2, targetDate.minusDays(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with some other parts, but you already have the oneDayEarlier variable set so you can just use that directly
Also wondering if we should just parametrize this test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The one day earlier variable is an Instant, while here we need a LocalDate, converting would be even longer.
Parametrization - probably will be riddled with if statements, maybe an exercise for another day.
| .withEntries(3, sixDaysEarlier) | ||
| .withEntries(5, fiveDaysEarlier) | ||
| .withEntries(2, fourDaysEarlier) | ||
| .build(targetDateAsInstant.minus(1, DAYS), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here regarding the day variables you created previously
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this one, fixed
| } | ||
|
|
||
| private long calculateRefreshFrom(long lastUpdated, long nextEffective) { | ||
| long thirtyDaysMillis = 2592000000L; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use Duration.ofDays(30).toMillis();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done 1 million times in a loop so I wanted to reduce logic to minimum. Perhaps could move it to class level so it doesn't get recomputed every time.
| private static final Instant sixDaysEarlier = targetDateAsInstant.minus(6, DAYS); | ||
| private static final Instant tenDaysEarlier = targetDateAsInstant.minus(10, DAYS); | ||
| private static final Instant sixDaysLater = targetDateAsInstant.plus(6, DAYS); | ||
| private static final Instant sevenDaysLater = targetDateAsInstant.plus(7, DAYS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be worth having a small function where we can put in the days to we want to add / subtract so this can be more flexible? When we start testing for rotations on intervals of 30s, these values will need to change anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, we already have those.
No description provided.