@Test public void should_not_throw_BeanInitializationException_when_no_current_event(){ when(eventRepository.findByCurrent(true)).thenReturn(new ArrayList<>()); eventService.initCurrentEvent(); }
@VisibleForTesting protected void initCurrentEvent() { List<Event> event = eventRepository.findByCurrent(true); if (event.isEmpty()) { logger.error("Error on init event service", new BeanInitializationException("There's no current event in database")); } else{ currentEvent = event.get(0); } if (event.size() > 1) { throw new BeanInitializationException("There's more than one current event in database"); } }
EventService { @VisibleForTesting protected void initCurrentEvent() { List<Event> event = eventRepository.findByCurrent(true); if (event.isEmpty()) { logger.error("Error on init event service", new BeanInitializationException("There's no current event in database")); } else{ currentEvent = event.get(0); } if (event.size() > 1) { throw new BeanInitializationException("There's more than one current event in database"); } } }
EventService { @VisibleForTesting protected void initCurrentEvent() { List<Event> event = eventRepository.findByCurrent(true); if (event.isEmpty()) { logger.error("Error on init event service", new BeanInitializationException("There's no current event in database")); } else{ currentEvent = event.get(0); } if (event.size() > 1) { throw new BeanInitializationException("There's more than one current event in database"); } }  }
EventService { @VisibleForTesting protected void initCurrentEvent() { List<Event> event = eventRepository.findByCurrent(true); if (event.isEmpty()) { logger.error("Error on init event service", new BeanInitializationException("There's no current event in database")); } else{ currentEvent = event.get(0); } if (event.size() > 1) { throw new BeanInitializationException("There's more than one current event in database"); } }  @PostConstruct void initBean(); static Event getCurrent(); Event getEvent(Integer year); }
EventService { @VisibleForTesting protected void initCurrentEvent() { List<Event> event = eventRepository.findByCurrent(true); if (event.isEmpty()) { logger.error("Error on init event service", new BeanInitializationException("There's no current event in database")); } else{ currentEvent = event.get(0); } if (event.size() > 1) { throw new BeanInitializationException("There's more than one current event in database"); } }  @PostConstruct void initBean(); static Event getCurrent(); Event getEvent(Integer year);  }