@Test @Transactional public void getCycle() throws Exception { // Initialize the database cycleRepository.saveAndFlush(cycle); // Get the cycle restCycleMockMvc .perform(get("/api/cycles/{id}", cycle.getId())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id").value(cycle.getId().intValue())) .andExpect(jsonPath("$.intitule").value(DEFAULT_INTITULE.toString())); }
@Test @Transactional public void createCycle() throws Exception { int databaseSizeBeforeCreate = cycleRepository.findAll().size(); // Create the Cycle restCycleMockMvc .perform( post("/api/cycles") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(cycle))) .andExpect(status().isCreated()); // Validate the Cycle in the database List<Cycle> cycles = cycleRepository.findAll(); assertThat(cycles).hasSize(databaseSizeBeforeCreate + 1); Cycle testCycle = cycles.get(cycles.size() - 1); assertThat(testCycle.getIntitule()).isEqualTo(DEFAULT_INTITULE); }
@Test @Transactional public void updateCycle() throws Exception { // Initialize the database cycleRepository.saveAndFlush(cycle); int databaseSizeBeforeUpdate = cycleRepository.findAll().size(); // Update the cycle cycle.setIntitule(UPDATED_INTITULE); restCycleMockMvc .perform( put("/api/cycles") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(cycle))) .andExpect(status().isOk()); // Validate the Cycle in the database List<Cycle> cycles = cycleRepository.findAll(); assertThat(cycles).hasSize(databaseSizeBeforeUpdate); Cycle testCycle = cycles.get(cycles.size() - 1); assertThat(testCycle.getIntitule()).isEqualTo(UPDATED_INTITULE); }
@Test @Transactional public void deleteCycle() throws Exception { // Initialize the database cycleRepository.saveAndFlush(cycle); int databaseSizeBeforeDelete = cycleRepository.findAll().size(); // Get the cycle restCycleMockMvc .perform(delete("/api/cycles/{id}", cycle.getId()).accept(TestUtil.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); // Validate the database is empty List<Cycle> cycles = cycleRepository.findAll(); assertThat(cycles).hasSize(databaseSizeBeforeDelete - 1); }
@Test @Transactional public void checkIntituleIsRequired() throws Exception { int databaseSizeBeforeTest = cycleRepository.findAll().size(); // set the field null cycle.setIntitule(null); // Create the Cycle, which fails. restCycleMockMvc .perform( post("/api/cycles") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(cycle))) .andExpect(status().isBadRequest()); List<Cycle> cycles = cycleRepository.findAll(); assertThat(cycles).hasSize(databaseSizeBeforeTest); }
@Before public void initTest() { cycle = new Cycle(); cycle.setIntitule(DEFAULT_INTITULE); }