示例#1
0
  public Season createSeason(Season season) {

    String id = UUID.randomUUID().toString();

    season.setId(id);

    return seasonRepository.save(season);
  }
  @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));
  }
示例#3
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;
  }
示例#4
0
 public void deleteSeason(String seasonId) {
   seasonRepository.delete(seasonId);
 }
示例#5
0
 public Season updateSeason(Season season) {
   return seasonRepository.save(season);
 }