@Before
 public void initTest() {
   session = new Session();
   session.setSessionName(DEFAULT_SESSION_NAME);
   session.setStartTime(DEFAULT_START_TIME);
   session.setEndTime(DEFAULT_END_TIME);
   session.setIsBreak(DEFAULT_IS_BREAK);
 }
  @Test
  @Transactional
  public void updateSession() throws Exception {
    // Initialize the database
    sessionRepository.saveAndFlush(session);

    int databaseSizeBeforeUpdate = sessionRepository.findAll().size();

    // Update the session
    session.setSessionName(UPDATED_SESSION_NAME);
    session.setStartTime(UPDATED_START_TIME);
    session.setEndTime(UPDATED_END_TIME);
    session.setIsBreak(UPDATED_IS_BREAK);

    restSessionMockMvc
        .perform(
            put("/api/sessions")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(session)))
        .andExpect(status().isOk());

    // Validate the Session in the database
    List<Session> sessions = sessionRepository.findAll();
    assertThat(sessions).hasSize(databaseSizeBeforeUpdate);
    Session testSession = sessions.get(sessions.size() - 1);
    assertThat(testSession.getSessionName()).isEqualTo(UPDATED_SESSION_NAME);
    assertThat(testSession.getStartTime()).isEqualTo(UPDATED_START_TIME);
    assertThat(testSession.getEndTime()).isEqualTo(UPDATED_END_TIME);
    assertThat(testSession.getIsBreak()).isEqualTo(UPDATED_IS_BREAK);
  }
  @Test
  @Transactional
  public void getSession() throws Exception {
    // Initialize the database
    sessionRepository.saveAndFlush(session);

    // Get the session
    restSessionMockMvc
        .perform(get("/api/sessions/{id}", session.getId()))
        .andExpect(status().isOk())
        .andExpect(content().contentType(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.id").value(session.getId().intValue()))
        .andExpect(jsonPath("$.sessionName").value(DEFAULT_SESSION_NAME.toString()))
        .andExpect(jsonPath("$.startTime").value(DEFAULT_START_TIME.toString()))
        .andExpect(jsonPath("$.endTime").value(DEFAULT_END_TIME.toString()))
        .andExpect(jsonPath("$.isBreak").value(DEFAULT_IS_BREAK.booleanValue()));
  }
  @Test
  @Transactional
  public void createSession() throws Exception {
    int databaseSizeBeforeCreate = sessionRepository.findAll().size();

    // Create the Session

    restSessionMockMvc
        .perform(
            post("/api/sessions")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(session)))
        .andExpect(status().isCreated());

    // Validate the Session in the database
    List<Session> sessions = sessionRepository.findAll();
    assertThat(sessions).hasSize(databaseSizeBeforeCreate + 1);
    Session testSession = sessions.get(sessions.size() - 1);
    assertThat(testSession.getSessionName()).isEqualTo(DEFAULT_SESSION_NAME);
    assertThat(testSession.getStartTime()).isEqualTo(DEFAULT_START_TIME);
    assertThat(testSession.getEndTime()).isEqualTo(DEFAULT_END_TIME);
    assertThat(testSession.getIsBreak()).isEqualTo(DEFAULT_IS_BREAK);
  }
  @Test
  @Transactional
  public void deleteSession() throws Exception {
    // Initialize the database
    sessionRepository.saveAndFlush(session);

    int databaseSizeBeforeDelete = sessionRepository.findAll().size();

    // Get the session
    restSessionMockMvc
        .perform(
            delete("/api/sessions/{id}", session.getId()).accept(TestUtil.APPLICATION_JSON_UTF8))
        .andExpect(status().isOk());

    // Validate the database is empty
    List<Session> sessions = sessionRepository.findAll();
    assertThat(sessions).hasSize(databaseSizeBeforeDelete - 1);
  }