@Test public void itShouldNotScoreNullRun() { run = null; ScoredRun actual = interactor.score(run); assertThat(actual).isNull(); verifyZeroInteractions(rawTimeScoringInteractor, handicapTimeScoringInteractor); }
public ScoredRun score(Run run) { if (!shouldScore(run)) { return null; } ScoredRun scoredRun = new ScoredRun(); scoredRun.setRun(run); if (!run.getDidNotFinish()) { rawTimeScoringInteractor.score(scoredRun); HandicapTimeScoringMethod handicapTimeScoringMethod = run.getEvent().getHandicapTimeScoringMethod(); if (handicapTimeScoringInteractors.containsKey(handicapTimeScoringMethod)) { handicapTimeScoringInteractors.get(handicapTimeScoringMethod) .score(scoredRun); } else { throw new UnsupportedOperationException( "Unsupported HandicapTimeScoringMethod: " + handicapTimeScoringMethod ); } } else { scoredRun.setRawTimeScored(TIME_DID_NOT_FINISH); scoredRun.setHandicapTimeScored(TIME_DID_NOT_FINISH); } return scoredRun; }
RunScoringInteractor { public ScoredRun score(Run run) { if (!shouldScore(run)) { return null; } ScoredRun scoredRun = new ScoredRun(); scoredRun.setRun(run); if (!run.getDidNotFinish()) { rawTimeScoringInteractor.score(scoredRun); HandicapTimeScoringMethod handicapTimeScoringMethod = run.getEvent().getHandicapTimeScoringMethod(); if (handicapTimeScoringInteractors.containsKey(handicapTimeScoringMethod)) { handicapTimeScoringInteractors.get(handicapTimeScoringMethod) .score(scoredRun); } else { throw new UnsupportedOperationException( "Unsupported HandicapTimeScoringMethod: " + handicapTimeScoringMethod ); } } else { scoredRun.setRawTimeScored(TIME_DID_NOT_FINISH); scoredRun.setHandicapTimeScored(TIME_DID_NOT_FINISH); } return scoredRun; } }
RunScoringInteractor { public ScoredRun score(Run run) { if (!shouldScore(run)) { return null; } ScoredRun scoredRun = new ScoredRun(); scoredRun.setRun(run); if (!run.getDidNotFinish()) { rawTimeScoringInteractor.score(scoredRun); HandicapTimeScoringMethod handicapTimeScoringMethod = run.getEvent().getHandicapTimeScoringMethod(); if (handicapTimeScoringInteractors.containsKey(handicapTimeScoringMethod)) { handicapTimeScoringInteractors.get(handicapTimeScoringMethod) .score(scoredRun); } else { throw new UnsupportedOperationException( "Unsupported HandicapTimeScoringMethod: " + handicapTimeScoringMethod ); } } else { scoredRun.setRawTimeScored(TIME_DID_NOT_FINISH); scoredRun.setHandicapTimeScored(TIME_DID_NOT_FINISH); } return scoredRun; } @Inject  RunScoringInteractor(
            RawTimeScoringInteractor rawTimeScoringInteractor,
            Map<HandicapTimeScoringMethod, HandicapTimeScoringInteractor> handicapTimeScoringInteractors
    ); }
RunScoringInteractor { public ScoredRun score(Run run) { if (!shouldScore(run)) { return null; } ScoredRun scoredRun = new ScoredRun(); scoredRun.setRun(run); if (!run.getDidNotFinish()) { rawTimeScoringInteractor.score(scoredRun); HandicapTimeScoringMethod handicapTimeScoringMethod = run.getEvent().getHandicapTimeScoringMethod(); if (handicapTimeScoringInteractors.containsKey(handicapTimeScoringMethod)) { handicapTimeScoringInteractors.get(handicapTimeScoringMethod) .score(scoredRun); } else { throw new UnsupportedOperationException( "Unsupported HandicapTimeScoringMethod: " + handicapTimeScoringMethod ); } } else { scoredRun.setRawTimeScored(TIME_DID_NOT_FINISH); scoredRun.setHandicapTimeScored(TIME_DID_NOT_FINISH); } return scoredRun; } @Inject  RunScoringInteractor(
            RawTimeScoringInteractor rawTimeScoringInteractor,
            Map<HandicapTimeScoringMethod, HandicapTimeScoringInteractor> handicapTimeScoringInteractors
    ); ScoredRun score(Run run); }
RunScoringInteractor { public ScoredRun score(Run run) { if (!shouldScore(run)) { return null; } ScoredRun scoredRun = new ScoredRun(); scoredRun.setRun(run); if (!run.getDidNotFinish()) { rawTimeScoringInteractor.score(scoredRun); HandicapTimeScoringMethod handicapTimeScoringMethod = run.getEvent().getHandicapTimeScoringMethod(); if (handicapTimeScoringInteractors.containsKey(handicapTimeScoringMethod)) { handicapTimeScoringInteractors.get(handicapTimeScoringMethod) .score(scoredRun); } else { throw new UnsupportedOperationException( "Unsupported HandicapTimeScoringMethod: " + handicapTimeScoringMethod ); } } else { scoredRun.setRawTimeScored(TIME_DID_NOT_FINISH); scoredRun.setHandicapTimeScored(TIME_DID_NOT_FINISH); } return scoredRun; } @Inject  RunScoringInteractor(
            RawTimeScoringInteractor rawTimeScoringInteractor,
            Map<HandicapTimeScoringMethod, HandicapTimeScoringInteractor> handicapTimeScoringInteractors
    ); ScoredRun score(Run run); static final BigDecimal TIME_DID_NOT_FINISH; }