@Test public void testACreateEvent() { User user = _dbInjecter.injectUser("EventUser"); Team team = _dbInjecter.injectTeam("EventTeam", "EventUser"); Event event = new Event(); event.setName("Event"); event.setUser(user); event.setTeam(team); try { _eventService.create(event); } catch (IpatException e) { fail(String.format("Error when creating Event\nerrorCode: %s", e.getErrorInfos().get(0).getErrorCode())); } assertEquals(1L, _eventRepository.count()); }
public Event create(Event event) throws IpatException { IpatPreconditions.checkNotNull(event, ErrorCodes.EVENT_IS_NULL); IpatPreconditions.checkArgument(event.getId() == null, ErrorCodes.EVENT_ALREADY_EXISTS); return eventRepository.save(event); }
EventService { public Event create(Event event) throws IpatException { IpatPreconditions.checkNotNull(event, ErrorCodes.EVENT_IS_NULL); IpatPreconditions.checkArgument(event.getId() == null, ErrorCodes.EVENT_ALREADY_EXISTS); return eventRepository.save(event); } }
EventService { public Event create(Event event) throws IpatException { IpatPreconditions.checkNotNull(event, ErrorCodes.EVENT_IS_NULL); IpatPreconditions.checkArgument(event.getId() == null, ErrorCodes.EVENT_ALREADY_EXISTS); return eventRepository.save(event); }  }
EventService { public Event create(Event event) throws IpatException { IpatPreconditions.checkNotNull(event, ErrorCodes.EVENT_IS_NULL); IpatPreconditions.checkArgument(event.getId() == null, ErrorCodes.EVENT_ALREADY_EXISTS); return eventRepository.save(event); }  Event create(Event event); Event getEvent(Long eventId); @Transactional void delete(Long eventId); Event update(Event event); @Transactional void generateCodes(Long eventId, List<Long> cartIds); }
EventService { public Event create(Event event) throws IpatException { IpatPreconditions.checkNotNull(event, ErrorCodes.EVENT_IS_NULL); IpatPreconditions.checkArgument(event.getId() == null, ErrorCodes.EVENT_ALREADY_EXISTS); return eventRepository.save(event); }  Event create(Event event); Event getEvent(Long eventId); @Transactional void delete(Long eventId); Event update(Event event); @Transactional void generateCodes(Long eventId, List<Long> cartIds);  }