Search in sources :

Example 1 with Session

use of site.model.Session in project jprime by bgjug.

the class SessionControllerTest method shouldChangeSessionType.

@Test
public void shouldChangeSessionType() throws Exception {
    mockMvc.perform(post("/admin/session/add").param("submission", "").param("startTime", "27.05.2017 10:15").param("endTime", "27.05.2017 11:15").param("title", "Opening").param("hall", "").param("id", bootSession.getId() + "")).andExpect(status().isFound()).andExpect(view().name("redirect:/admin/session/view"));
    List<Session> sessions = sessionRepository.findAll();
    assertThat(sessions.size(), is(1));
    Session session = sessions.get(0);
    assertNull(session.getSubmission());
    assertThat(session.getStartTime(), is(new DateTime().withYear(2017).withMonthOfYear(5).withDayOfMonth(27).withHourOfDay(10).withMinuteOfHour(15).withSecondOfMinute(0).withMillisOfSecond(0)));
    assertThat(session.getEndTime(), is(new DateTime().withYear(2017).withMonthOfYear(5).withDayOfMonth(27).withHourOfDay(11).withMinuteOfHour(15).withSecondOfMinute(0).withMillisOfSecond(0)));
    assertNull(session.getHall());
    assertThat(session.getTitle(), is("Opening"));
}
Also used : DateTime(org.joda.time.DateTime) Session(site.model.Session) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with Session

use of site.model.Session in project jprime by bgjug.

the class AdminSessionController method addSession.

@RequestMapping(value = "/add", method = RequestMethod.POST)
public String addSession(@RequestParam String submission, @RequestParam @DateTimeFormat(pattern = "dd.MM.yyyy HH:mm") DateTime startTime, @RequestParam @DateTimeFormat(pattern = "dd.MM.yyyy HH:mm") DateTime endTime, @RequestParam String title, @RequestParam String hall, @RequestParam String id) {
    Session session = new Session();
    if (!"".equals(id)) {
        session = adminFacade.findOneSession(Long.parseLong(id));
    }
    if (title != null && !title.equals("")) {
        session.setTitle(title);
        session.setSubmission(null);
        session.setHall(null);
    } else {
        session.setSubmission(adminFacade.findOneSubmission(Long.parseLong(submission)));
        session.setHall(adminFacade.findOneVenueHall(Long.parseLong(hall)));
        session.setTitle(null);
    }
    session.setStartTime(startTime);
    session.setEndTime(endTime);
    adminFacade.saveSession(session);
    return "redirect:/admin/session/view";
}
Also used : Session(site.model.Session) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Session

use of site.model.Session in project jprime by bgjug.

the class AgendaController method getById.

// read a single agenda post
@RequestMapping("/agenda/{id}")
public String getById(@PathVariable("id") final long id, Model model) {
    Session talk = userService.findSessionTalk(id);
    model.addAttribute("talk", talk);
    return "/talk.jsp";
}
Also used : Session(site.model.Session) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with Session

use of site.model.Session in project jprime by bgjug.

the class SessionControllerTest method setup.

@Before
public void setup() throws Exception {
    mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
    this.forgeSubmission = submissionRepository.save(new Submission("Forge with me", "Forge is the best", SessionLevel.BEGINNER, SessionType.ConferenceSession, new Speaker("Ivan St.", "Ivanov", "ivan.st.ivanov@example.com", "The Forge Guy", "@forge", false, true)));
    forgeSubmission.setStatus(SubmissionStatus.ACCEPTED);
    Submission bootSubmission = submissionRepository.save(new Submission("Spring Boot", "Bootiful or what?", SessionLevel.BEGINNER, SessionType.ConferenceSession, new Speaker("Nayden", "Gochev", "nayden.gochev@example.com", "The Spring Guy", "@sprink", true, true)));
    bootSubmission.setStatus(SubmissionStatus.ACCEPTED);
    this.betaHall = venueHallRepository.save(new VenueHall("Beta", "600 seats"));
    venueHallRepository.save(new VenueHall("Alpha", "400 seats"));
    this.bootSession = sessionRepository.save(new Session(bootSubmission, DateTime.now(), DateTime.now(), betaHall));
}
Also used : VenueHall(site.model.VenueHall) Submission(site.model.Submission) Speaker(site.model.Speaker) Session(site.model.Session) Before(org.junit.Before)

Example 5 with Session

use of site.model.Session in project jprime by bgjug.

the class SessionControllerTest method shouldAddNewSession.

@Test
public void shouldAddNewSession() throws Exception {
    mockMvc.perform(post("/admin/session/add").param("submission", forgeSubmission.getId() + "").param("startTime", "26.05.2017 10:15").param("endTime", "26.05.2017 11:15").param("title", "").param("hall", betaHall.getId() + "").param("id", "")).andExpect(status().isFound()).andExpect(view().name("redirect:/admin/session/view"));
    List<Session> sessions = sessionRepository.findAll();
    assertThat(sessions.size(), is(2));
    Session session = sessions.get(1);
    assertThat(session.getSubmission().getTitle(), is(forgeSubmission.getTitle()));
    assertThat(session.getStartTime(), is(new DateTime().withYear(2017).withMonthOfYear(5).withDayOfMonth(26).withHourOfDay(10).withMinuteOfHour(15).withSecondOfMinute(0).withMillisOfSecond(0)));
    assertThat(session.getEndTime(), is(new DateTime().withYear(2017).withMonthOfYear(5).withDayOfMonth(26).withHourOfDay(11).withMinuteOfHour(15).withSecondOfMinute(0).withMillisOfSecond(0)));
    assertThat(session.getHall().getName(), is(betaHall.getName()));
    assertTrue(session.getTitle().startsWith(session.getSubmission().getTitle()) && session.getTitle().endsWith(session.getSubmission().getSpeaker().getLastName()));
}
Also used : DateTime(org.joda.time.DateTime) Session(site.model.Session) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Session (site.model.Session)7 DateTime (org.joda.time.DateTime)4 Test (org.junit.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Submission (site.model.Submission)2 Before (org.junit.Before)1 Speaker (site.model.Speaker)1 VenueHall (site.model.VenueHall)1