@Test
  @Transactional
  public void getCourse() throws Exception {
    // Initialize the database
    courseRepository.saveAndFlush(course);

    // Get the course
    restCourseMockMvc
        .perform(get("/api/courses/{id}", course.getId()))
        .andExpect(status().isOk())
        .andExpect(content().contentType(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.id").value(course.getId().intValue()))
        .andExpect(jsonPath("$.title").value(DEFAULT_TITLE.toString()));
  }
  @Test
  @Transactional
  public void createCourse() throws Exception {
    int databaseSizeBeforeCreate = courseRepository.findAll().size();

    // Create the Course
    restCourseMockMvc
        .perform(
            post("/api/courses")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(course)))
        .andExpect(status().isCreated());

    // Validate the Course in the database
    List<Course> courses = courseRepository.findAll();
    assertThat(courses).hasSize(databaseSizeBeforeCreate + 1);
    Course testCourse = courses.get(courses.size() - 1);
    assertThat(testCourse.getTitle()).isEqualTo(DEFAULT_TITLE);
  }
  @Test
  @Transactional
  public void updateCourse() throws Exception {
    // Initialize the database
    courseRepository.saveAndFlush(course);

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

    // Update the course
    course.setTitle(UPDATED_TITLE);
    restCourseMockMvc
        .perform(
            put("/api/courses")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(course)))
        .andExpect(status().isOk());

    // Validate the Course in the database
    List<Course> courses = courseRepository.findAll();
    assertThat(courses).hasSize(databaseSizeBeforeUpdate);
    Course testCourse = courses.get(courses.size() - 1);
    assertThat(testCourse.getTitle()).isEqualTo(UPDATED_TITLE);
  }
  @Test
  @Transactional
  public void deleteCourse() throws Exception {
    // Initialize the database
    courseRepository.saveAndFlush(course);

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

    // Get the course
    restCourseMockMvc
        .perform(delete("/api/courses/{id}", course.getId()).accept(TestUtil.APPLICATION_JSON_UTF8))
        .andExpect(status().isOk());

    // Validate the database is empty
    List<Course> courses = courseRepository.findAll();
    assertThat(courses).hasSize(databaseSizeBeforeDelete - 1);
  }
 @Before
 public void initTest() {
   course = new Course();
   course.setTitle(DEFAULT_TITLE);
 }