@Test public void testCreateSychronusSession() { SynchronousSession session = new SynchronousSession(); session.setOrganizer(user); session.setCategory(category); Session savedSession = sessionService.addSession(session); assertEquals(session.getSessionId(), savedSession.getSessionId()); }
@Test public void testCreateAsynchronousSessionSession() { AsynchronousSession session = new AsynchronousSession(); session.setOrganizer(user); session.setCategory(category); session.setSecondsBetweenMoves(15); Session savedSession = sessionService.addSession(session); assertEquals(session.getSessionId(), savedSession.getSessionId()); }
@Test(expected = SessionServiceException.class) public void addSessionWithLessCardsThanRequiredPerUser() { Session session = new SynchronousSession(); session.setOrganizer(user); session.setCategory(category); session.setMinNumberOfCardsPerParticipant(6); session = sessionService.addSession(session); }
@Test public void testAddSyncSessionWithDateAfterToday() { SynchronousSession session = new SynchronousSession(); session.setOrganizer(user); session.setCategory(category); session.setStartDateTime(LocalDateTime.now().plusDays(1)); Session savedSession = sessionService.addSession(session); assertEquals(session.getSessionId(), savedSession.getSessionId()); }
@Test(expected = SessionServiceException.class) public void addSessionWithLessMaxCardsThanMinCardsThrowsException() { Session session = new SynchronousSession(); session.setOrganizer(user); session.setCategory(category); session.setMinNumberOfCardsPerParticipant(5); session.setMaxNumberOfCardsPerParticipant(4); sessionService.addSession(session); }
@Test public void addSessionWithLessCirclesThanMinimum() { Session session = new SynchronousSession(); session.setOrganizer(user); session.setCategory(category); session.setAmountOfCircles(2); session = sessionService.addSession(session); Assert.assertEquals(Session.MIN_CIRCLE_AMOUNT, session.getAmountOfCircles()); }
@Test(expected = SessionServiceException.class) public void addSessionAsNonOrganizerThrowsException() { User nonOrganizer = new User("test-non-organizer", "pass"); nonOrganizer.setEmail("nonorganizer@localhost"); nonOrganizer = userRepository.save(nonOrganizer); Session session = new SynchronousSession(); session.setCategory(category); session.setOrganizer(nonOrganizer); sessionService.addSession(session); }
@Test public void testAddSessionToTopic() { cardService.addCardDetailsToTopic(topic, cardDetails1); cardService.addCardDetailsToTopic(topic, cardDetails2); cardService.addCardDetailsToTopic(topic, cardDetails3); cardService.addCardDetailsToTopic(topic, cardDetails4); cardService.addCardDetailsToTopic(topic, cardDetails5); Session session = new SynchronousSession(); session.setOrganizer(user); session.setCategory(category); session.setTopic(this.topic); Session savedSession = sessionService.addSession(session); assertEquals(savedSession.getTopic().getName(), topic.getName()); assertEquals(savedSession.getOrganizer().getUserId(), this.user.getUserId()); }