コード例 #1
0
  @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);
  }
コード例 #2
0
  @Test
  public void createDepartment() throws Exception {
    int databaseSizeBeforeCreate = departmentRepository.findAll().size();

    // Create the Department
    DepartmentDTO departmentDTO = departmentMapper.departmentToDepartmentDTO(department);

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

    // Validate the Department in the database
    List<Department> departments = departmentRepository.findAll();
    assertThat(departments).hasSize(databaseSizeBeforeCreate + 1);
    Department testDepartment = departments.get(departments.size() - 1);
    assertThat(testDepartment.getName()).isEqualTo(DEFAULT_NAME);
  }
コード例 #3
0
  @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()));
  }
コード例 #4
0
  @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);
  }
コード例 #5
0
 @Before
 public void initTest() {
   departmentRepository.deleteAll();
   department = new Department();
   department.setName(DEFAULT_NAME);
 }