@Test public void itShouldSetHandicapTimeForCleanRun() { when(run.getCones()).thenReturn(0); BigDecimal expected = BigDecimal.valueOf(87600, 3); interactor.score(scoredRun); verify(scoredRun).setHandicapTimeScored(eq(expected)); }
@Override public void score(ScoredRun scoredRun) { Run run = scoredRun.getRun(); BigDecimal scratchTime = run.getRawTime(); BigDecimal handicapGroupFactor = run.getRegistration().getHandicapGroup().getFactor(); BigDecimal competitionGroupFactor = run.getRegistration().getCompetitionGroup().getFactor(); BigDecimal handicapTimeScratch = scratchTime.multiply(handicapGroupFactor) .multiply(competitionGroupFactor) .setScale(3, RoundingMode.HALF_UP); BigDecimal eventConePenaltySeconds = scoredRun.getRun().getEvent().getConePenaltySeconds(); BigDecimal conePenaltySeconds = eventConePenaltySeconds.multiply(BigDecimal.valueOf(run.getCones())); BigDecimal handicapTimeScored = handicapTimeScratch.add(conePenaltySeconds); scoredRun.setHandicapTimeScored(handicapTimeScored); }
FlatConePenaltyHandicapTimeScoringInteractor implements HandicapTimeScoringInteractor { @Override public void score(ScoredRun scoredRun) { Run run = scoredRun.getRun(); BigDecimal scratchTime = run.getRawTime(); BigDecimal handicapGroupFactor = run.getRegistration().getHandicapGroup().getFactor(); BigDecimal competitionGroupFactor = run.getRegistration().getCompetitionGroup().getFactor(); BigDecimal handicapTimeScratch = scratchTime.multiply(handicapGroupFactor) .multiply(competitionGroupFactor) .setScale(3, RoundingMode.HALF_UP); BigDecimal eventConePenaltySeconds = scoredRun.getRun().getEvent().getConePenaltySeconds(); BigDecimal conePenaltySeconds = eventConePenaltySeconds.multiply(BigDecimal.valueOf(run.getCones())); BigDecimal handicapTimeScored = handicapTimeScratch.add(conePenaltySeconds); scoredRun.setHandicapTimeScored(handicapTimeScored); } }
FlatConePenaltyHandicapTimeScoringInteractor implements HandicapTimeScoringInteractor { @Override public void score(ScoredRun scoredRun) { Run run = scoredRun.getRun(); BigDecimal scratchTime = run.getRawTime(); BigDecimal handicapGroupFactor = run.getRegistration().getHandicapGroup().getFactor(); BigDecimal competitionGroupFactor = run.getRegistration().getCompetitionGroup().getFactor(); BigDecimal handicapTimeScratch = scratchTime.multiply(handicapGroupFactor) .multiply(competitionGroupFactor) .setScale(3, RoundingMode.HALF_UP); BigDecimal eventConePenaltySeconds = scoredRun.getRun().getEvent().getConePenaltySeconds(); BigDecimal conePenaltySeconds = eventConePenaltySeconds.multiply(BigDecimal.valueOf(run.getCones())); BigDecimal handicapTimeScored = handicapTimeScratch.add(conePenaltySeconds); scoredRun.setHandicapTimeScored(handicapTimeScored); } @Inject  FlatConePenaltyHandicapTimeScoringInteractor(); }
FlatConePenaltyHandicapTimeScoringInteractor implements HandicapTimeScoringInteractor { @Override public void score(ScoredRun scoredRun) { Run run = scoredRun.getRun(); BigDecimal scratchTime = run.getRawTime(); BigDecimal handicapGroupFactor = run.getRegistration().getHandicapGroup().getFactor(); BigDecimal competitionGroupFactor = run.getRegistration().getCompetitionGroup().getFactor(); BigDecimal handicapTimeScratch = scratchTime.multiply(handicapGroupFactor) .multiply(competitionGroupFactor) .setScale(3, RoundingMode.HALF_UP); BigDecimal eventConePenaltySeconds = scoredRun.getRun().getEvent().getConePenaltySeconds(); BigDecimal conePenaltySeconds = eventConePenaltySeconds.multiply(BigDecimal.valueOf(run.getCones())); BigDecimal handicapTimeScored = handicapTimeScratch.add(conePenaltySeconds); scoredRun.setHandicapTimeScored(handicapTimeScored); } @Inject  FlatConePenaltyHandicapTimeScoringInteractor(); @Override void score(ScoredRun scoredRun); }
FlatConePenaltyHandicapTimeScoringInteractor implements HandicapTimeScoringInteractor { @Override public void score(ScoredRun scoredRun) { Run run = scoredRun.getRun(); BigDecimal scratchTime = run.getRawTime(); BigDecimal handicapGroupFactor = run.getRegistration().getHandicapGroup().getFactor(); BigDecimal competitionGroupFactor = run.getRegistration().getCompetitionGroup().getFactor(); BigDecimal handicapTimeScratch = scratchTime.multiply(handicapGroupFactor) .multiply(competitionGroupFactor) .setScale(3, RoundingMode.HALF_UP); BigDecimal eventConePenaltySeconds = scoredRun.getRun().getEvent().getConePenaltySeconds(); BigDecimal conePenaltySeconds = eventConePenaltySeconds.multiply(BigDecimal.valueOf(run.getCones())); BigDecimal handicapTimeScored = handicapTimeScratch.add(conePenaltySeconds); scoredRun.setHandicapTimeScored(handicapTimeScored); } @Inject  FlatConePenaltyHandicapTimeScoringInteractor(); @Override void score(ScoredRun scoredRun);  }