Esempio n. 1
0
  public Season createSeason(Season season) {

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

    season.setId(id);

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