Пример #1
0
  public List<Season> getCurrentSeasons() {
    List<Season> s = new ArrayList<Season>();
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    int currentYear = calendar.get(Calendar.YEAR);

    for (LeagueType lt : LeagueType.values()) {
      Iterable<Season> seasons = seasonRepository.getSeasonsByLeagueType(lt.toString());
      for (Season season : seasons) {
        if (season.getStartYear() >= currentYear) s.add(season);
      }
    }

    return s;
  }
Пример #2
0
  @Test
  public void testSeason() {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    int currentYear = calendar.get(Calendar.YEAR);

    Season season =
        new SeasonBuilder(UUID.randomUUID().toString())
            .withStartYear(currentYear)
            .withEndYear(currentYear + 1)
            .withLeagueType(LeagueType.pickem)
            .build();

    when(seasonRepositoryMock.save(season)).thenReturn(season);
    when(seasonRepositoryMock.getSeasonsByLeagueType(LeagueType.pickem.toString()))
        .thenReturn(Arrays.asList(season));

    season = seasonService.createSeason(season);

    Assert.assertTrue(seasonService.getCurrentSeasons().contains(season));
  }