public void shouldFindEmployeesByOffice()

in component-test/src/main/java/org/apache/fineract/cn/office/TestEmployee.java [80:103]


  public void shouldFindEmployeesByOffice() throws Exception {
    final Office office = OfficeFactory.createRandomOffice();
    this.organizationManager.createOffice(office);
    this.eventRecorder.wait(EventConstants.OPERATION_POST_OFFICE, office.getIdentifier());

    final Employee employee = EmployeeFactory.createRandomEmployee();
    employee.setAssignedOffice(office.getIdentifier());
    this.organizationManager.createEmployee(employee);

    this.eventRecorder.wait(EventConstants.OPERATION_POST_EMPLOYEE, employee.getIdentifier());

    final EmployeePage employeePage = this.organizationManager.fetchEmployees(null, office.getIdentifier(), 0, 20, null, null);
    Assert.assertEquals(Long.valueOf(1L), employeePage.getTotalElements());
    final Employee savedEmployee = employeePage.getEmployees().get(0);
    Assert.assertEquals(employee.getIdentifier(), savedEmployee.getIdentifier());
    Assert.assertEquals(employee.getGivenName(), savedEmployee.getGivenName());
    Assert.assertEquals(employee.getMiddleName(), savedEmployee.getMiddleName());
    Assert.assertEquals(employee.getSurname(), savedEmployee.getSurname());

    this.organizationManager.deleteEmployee(employee.getIdentifier());
    this.eventRecorder.wait(EventConstants.OPERATION_DELETE_EMPLOYEE, employee.getIdentifier());
    this.organizationManager.deleteOffice(office.getIdentifier());
    this.eventRecorder.wait(EventConstants.OPERATION_DELETE_OFFICE, office.getIdentifier());
  }