コード例 #1
0
 @Test
 public void testGetCarClassCompetitionResultsByCarClassCompetition() throws Exception {
   List<CarClassCompetitionResult> carClassCompetitionResults =
       new ArrayList<CarClassCompetitionResult>();
   CarClassCompetitionResult result1 = new CarClassCompetitionResult();
   CarClassCompetitionResult result2 = new CarClassCompetitionResult();
   CarClassCompetition carClassCompetition = new CarClassCompetition();
   carClassCompetition.setCircleCount(5);
   result1.setComment("test1 result");
   result1.setComment("test2 result");
   carClassCompetitionResults.add(result1);
   carClassCompetitionResults.add(result2);
   when(carClassCompetitionResultDAO.getCarClassCompetitionResultsByCarClassCompetition(
           carClassCompetition))
       .thenReturn(carClassCompetitionResults);
   assertEquals(
       "Expected 2 results",
       2,
       (carClassCompetitionResultServiceImpl
           .getCarClassCompetitionResultsByCarClassCompetition(carClassCompetition)
           .size()));
 }
コード例 #2
0
  @Test
  public void setAbsoluteResultsTest2() {
    Race race = new Race();
    race.setRaceNumber(2);
    CarClassCompetition carClassCompetition = new CarClassCompetition();
    carClassCompetition.setId(112);
    List<CarClassCompetitionResult> absoluteResultsList =
        new ArrayList<CarClassCompetitionResult>();
    List<RaceResult> raceResults = new ArrayList<RaceResult>();

    Competition competition = new Competition();
    competition.setEnabled(false);
    carClassCompetition.setCompetition(competition);
    RacerCarClassCompetitionNumber racerCarClassCompetitionNumber =
        new RacerCarClassCompetitionNumber();
    racerCarClassCompetitionNumber.setNumberInCompetition(12);
    CarClassCompetitionResult carClassCompetitionResult = new CarClassCompetitionResult();
    carClassCompetitionResult.setAbsolutePlace(0);
    carClassCompetitionResult.setAbsolutePoints(0);
    carClassCompetitionResult.setRace2points(0);
    carClassCompetitionResult.setRacerCarClassCompetitionNumber(racerCarClassCompetitionNumber);

    RaceResult raceResult = new RaceResult();
    raceResult.setCarNumber(12);
    raceResult.setPlace(1);
    raceResult.setPoints(100);
    raceResults.add(raceResult);
    absoluteResultsList.add(carClassCompetitionResult);

    when(raceResultService.getRaceResultsByRace(race)).thenReturn(raceResults);
    doNothing()
        .when(carClassCompetitionResultDAO)
        .updateCarClassCompetitionResult(carClassCompetitionResult);

    carClassCompetitionResultServiceImpl.setAbsoluteResults(carClassCompetition, race);
    verify(raceResultService, times(1)).getRaceResultsByRace(race);
    verifyNoMoreInteractions(raceResultService);
  }