Skip to content

Commit

Permalink
Feature: Added test cases for appointment confirmation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tasmi1 committed Jul 12, 2020
1 parent 0ce9b42 commit 1e6428d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;

import java.time.LocalDate;
Expand All @@ -27,12 +29,14 @@
import com.pemits.webcare.api.doctor.repository.spec.DoctorSpecBuilder;
import com.pemits.webcare.api.patient.entity.Patient;
import com.pemits.webcare.api.patient.repository.PatientRepository;
import com.pemits.webcare.core.enums.AppointmentStatus;

public class AppointmentRepositoryTest extends BaseJpaTest {

private static final long MOCK_DEPARTMENT1_ID = 1L;
private static final long MOCK_PATIENT1_ID = 1L;
private static final long MOCK_PATIENT2_ID = 2L;
private static final long MOCK_APPOINTMENT_ID = 1L;

@Autowired
private DepartmentRepository departmentRepository;
Expand Down Expand Up @@ -126,4 +130,30 @@ public void testSaveAllShouldReturnAllSavedAppointments() {
assertThat(saved.get(1).getId(), notNullValue());
assertThat(appointmentRepository.count(), equalTo(2L));
}

@Test
@DatabaseSetup("/dataset/department/department-config.xml")
@DatabaseSetup({
"/dataset/user/users-of-type-doctor.xml",
"/dataset/user/users-of-type-patient.xml"
})
@DatabaseSetup("/dataset/doctor/doctor-config.xml")
@DatabaseSetup("/dataset/patient/patient-config.xml")
@DatabaseSetup("/dataset/appointment/appointment-config.xml")
public void testSaveShouldUpdateAppointmentStatus() {
Appointment appointment = appointmentRepository.getOne(MOCK_APPOINTMENT_ID);

AppointmentStatus oldStatus = AppointmentStatus.PENDING;
AppointmentStatus newStatus = AppointmentStatus.APPROVED;

assertThat(appointment.getStatus(), is(oldStatus));

appointment.setStatus(newStatus);
appointmentRepository.save(appointment);

Appointment saved = appointmentRepository.getOne(MOCK_APPOINTMENT_ID);

assertThat(saved.getStatus(), not(oldStatus));
assertThat(saved.getStatus(), is(newStatus));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<dataset>
<!-- NULL: created_by, last_modified_by -->
<appointment
id="1"
created_at="2020-06-20 15:30:00"
last_modified_at="2020-06-20 15:30:00"
version="0"
patient_id="1"
department_id="1"
doctor_id="1"
appointment_date="2020-07-20"
appointment_time="09:25:00"
status="0"
/>
</dataset>

0 comments on commit 1e6428d

Please sign in to comment.