Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test cases to increase branch coverage & set threshold to 0.60 #152

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.65</minimum>
<minimum>0.60</minimum>
</limit>
</limits>
</rule>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,77 @@ public void shouldReturnDateLessAppointments() {
assertNotNull(appointments);
assertEquals(3, appointments.size());
}

@Test
public void shouldReturnAppointmentsBasedOnAppointmentSearchRequestModelPatientAndLocation() {

List<Appointment> allAppointments = appointmentDao.getAllAppointments(null);
AppointmentSearchRequestModel searchQuery = new AppointmentSearchRequestModel();
List<String> patientUuids=new ArrayList<>();
patientUuids.add(allAppointments.get(0).getPatient().getUuid());
List<String> locationUuids=new ArrayList<>();
locationUuids.add(allAppointments.get(0).getLocation().getUuid());

searchQuery.setPatientUuids(patientUuids);
searchQuery.setLocationUuids(locationUuids);
searchQuery.setStatus(null);

List<Appointment> appointments = appointmentDao.search(searchQuery);

assertNotNull(appointments);
assertEquals(3, appointments.size());
}

@Test
public void shouldReturnAppointmentsBasedOnAppointmentSearchRequestModelServiceAndServiceType() {

List<Appointment> allAppointments = appointmentDao.getAllAppointments(null);
AppointmentSearchRequestModel searchQuery = new AppointmentSearchRequestModel();
List<String> serviceUuids=new ArrayList<>();
serviceUuids.add(allAppointments.get(0).getService().getUuid());
List<String> serviceTypeUuids=new ArrayList<>();
serviceTypeUuids.add(allAppointments.get(0).getServiceType().getUuid());

searchQuery.setServiceUuids(serviceUuids);
searchQuery.setServiceTypeUuids(serviceTypeUuids);
searchQuery.setStatus(null);

List<Appointment> appointments = appointmentDao.search(searchQuery);

assertNotNull(appointments);
assertEquals(2, appointments.size());
}

@Test
public void shouldReturnAppointmentsBasedOnAppointmentSearchRequestModelPriority() {

List<Appointment> allAppointments = appointmentDao.getAllAppointments(null);
AppointmentSearchRequestModel searchQuery = new AppointmentSearchRequestModel();
List<String> priorities=new ArrayList<>();
priorities.add("AsNeeded");

searchQuery.setPriorities(priorities);
searchQuery.setStatus(null);

List<Appointment> appointments = appointmentDao.search(searchQuery);

assertNotNull(appointments);
assertEquals(1, appointments.size());
}

@Test
public void shouldReturnEmptyAppointmentsBasedOnAppointmentSearchRequestModelProviderWhenNoAppointmentsAreAssignedToProvider() {

AppointmentSearchRequestModel searchQuery = new AppointmentSearchRequestModel();
List<String> providerUuids=new ArrayList<>();
providerUuids.add(UUID.randomUUID().toString());

searchQuery.setProviderUuids(providerUuids);
searchQuery.setStatus(null);

List<Appointment> appointments = appointmentDao.search(searchQuery);

assertNotNull(appointments);
assertEquals(0, appointments.size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,17 @@ public void shouldSearchForAnAppointment() {
verify(appointmentDao, times(1)).search(appointment);
}

@Test
public void shouldSearchForAnAppointmentBasedOnAppointmentSearchRequestModel() {
AppointmentSearchRequestModel appointmentSearchRequestModel = new AppointmentSearchRequestModel();
appointmentSearchRequestModel.setStatus("Scheduled");
List<Appointment> appointmentList = new ArrayList<>();
appointmentList.add(appointment);
when(appointmentDao.search(appointmentSearchRequestModel)).thenReturn(appointmentList);
appointmentsService.search(appointmentSearchRequestModel);
verify(appointmentDao, times(1)).search(appointmentSearchRequestModel);
}

@Test
public void shouldThrowExceptionIfValidationFailsOnAppointmentSave() {
String errorMessage = "Appointment cannot be created without Patient";
Expand Down
2 changes: 1 addition & 1 deletion api/src/test/resources/appointmentTestData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<appointment_service appointment_service_id="2" name="Treatment" description="Treatment" start_time="09:00:00" end_time="17:00:00" location_id="1" uuid="c36006d4-9fbb-4f20-866b-0ece245615b1"
speciality_id="1" max_appointments_limit="4" duration_mins="30" creator="1" voided="true" voided_by="1" void_reason=""/>

<patient_appointment patient_appointment_id="1" patient_id ="1" creator="1" date_created="2008-08-15 15:57:09.0" voided="false" void_reason="" uuid="75504r42-3ca8-11e3-bf2b-0800271c1b77" location_id = "1" appointment_service_id="1"/>
<patient_appointment patient_appointment_id="1" patient_id ="1" creator="1" date_created="2008-08-15 15:57:09.0" voided="false" void_reason="" uuid="75504r42-3ca8-11e3-bf2b-0800271c1b77" location_id = "1" appointment_service_id="1" appointment_service_type_id="1" priority="AsNeeded"/>
<patient_appointment patient_appointment_id="2" patient_id ="1" appointment_service_id="1" start_date_time="2108-08-15 12:00:00.0" end_date_time="2108-08-15 13:00:00.0" status="Scheduled" creator="1" date_created="2108-08-10 15:57:09.0" voided="false" void_reason="" uuid="75504r42-3ca8-11e3-bf2b-0800271c1111"/>
<patient_appointment patient_appointment_id="3" patient_id ="1" appointment_service_id="1" start_date_time="2108-08-15 13:00:00.0" end_date_time="2108-08-15 14:00:00.0" status="CheckedIn" creator="1" date_created="2108-08-10 15:57:09.0" voided="false" void_reason="" uuid="75504r42-3ca8-11e3-bf2b-0800271c12222"/>
<patient_appointment patient_appointment_id="5" patient_id ="1" appointment_service_id="1" start_date_time="2108-08-15 13:00:00.0" end_date_time="2108-08-15 14:00:00.0" status="Scheduled" creator="1" date_created="2108-08-10 15:57:09.0" voided="true" void_reason="" uuid="75504r42-3ca8-11e3-bf2b-0800271c13344"/>
Expand Down
Loading