@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 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); }