Last active
February 12, 2022 10:33
-
-
Save mgryszko/d7223c25c7d436fe3d96f08414142bcb to your computer and use it in GitHub Desktop.
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
@Test | |
void deleteDefault() { | |
var profile = ScoringProfile.builder().id(profileId).defaultProfile(true).build(); | |
setupStubs(profile); | |
recalculateService.calculateAndPersist(profile); | |
verifyMocks(profile, inactiveScoresToKeep); | |
} | |
@Test | |
void deleteCustom() { | |
var profile = ScoringProfile.builder().id(profileId).defaultProfile(false).build(); | |
setupStubs(profile); | |
recalculateService.calculateAndPersist(profile); | |
verifyMocks(profile, 0); | |
} | |
private void setupStubs(ScoringProfile profile) { | |
when(versioner.nextVersion(profile)).thenReturn(version); | |
when(scoresStorer.getPersister(profileId, version)).thenReturn(persister); | |
} | |
private void verifyMocks(ScoringProfile profile, int expectedScoresToKeep) { | |
var inOrder = inOrder(persister, calculator, versioner); | |
inOrder.verify(persister).deleteInactive(profileId, inactiveScoresToKeep); | |
inOrder.verify(versioner).deleteInactive(profileId, expectedScoresToKeep); | |
inOrder.verify(calculator).calculateScores(profile, persister); | |
inOrder.verify(versioner).calculationFinished(version); | |
inOrder.verify(versioner).activateVersion(profile, version); | |
inOrder.verify(persister).deleteInactive(profileId, expectedScoresToKeep); | |
inOrder.verify(versioner).deleteInactive(profileId, expectedScoresToKeep); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment