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