@Test
  public void getDepartment() throws Exception {
    // Initialize the database
    departmentRepository.save(department);

    // Get the department
    restDepartmentMockMvc
        .perform(get("/api/departments/{id}", department.getId()))
        .andExpect(status().isOk())
        .andExpect(content().contentType(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.id").value(department.getId().toString()))
        .andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString()));
  }
  @Test
  public void deleteDepartment() throws Exception {
    // Initialize the database
    departmentRepository.save(department);

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

    // Get the department
    restDepartmentMockMvc
        .perform(
            delete("/api/departments/{id}", department.getId())
                .accept(TestUtil.APPLICATION_JSON_UTF8))
        .andExpect(status().isOk());

    // Validate the database is empty
    List<Department> departments = departmentRepository.findAll();
    assertThat(departments).hasSize(databaseSizeBeforeDelete - 1);
  }
  @Test
  public void updateDepartment() throws Exception {
    // Initialize the database
    departmentRepository.save(department);

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

    // Update the department
    department.setName(UPDATED_NAME);
    DepartmentDTO departmentDTO = departmentMapper.departmentToDepartmentDTO(department);

    restDepartmentMockMvc
        .perform(
            put("/api/departments")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(departmentDTO)))
        .andExpect(status().isOk());

    // Validate the Department in the database
    List<Department> departments = departmentRepository.findAll();
    assertThat(departments).hasSize(databaseSizeBeforeUpdate);
    Department testDepartment = departments.get(departments.size() - 1);
    assertThat(testDepartment.getName()).isEqualTo(UPDATED_NAME);
  }