Skip to content

Commit

Permalink
#950 - Add unit tests to verify time slosts are sorted by start date
Browse files Browse the repository at this point in the history
  • Loading branch information
pamcdm committed Jan 2, 2014
1 parent 0091730 commit c8bf52a
Showing 1 changed file with 48 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,9 @@
*/
package org.openmrs.module.appointmentscheduling.api;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.openmrs.Location;
import org.openmrs.Patient;
Expand All @@ -36,13 +24,20 @@
import org.openmrs.api.APIException;
import org.openmrs.api.context.Context;
import org.openmrs.module.appointmentscheduling.Appointment;
import org.openmrs.module.appointmentscheduling.Appointment.AppointmentStatus;
import org.openmrs.module.appointmentscheduling.AppointmentType;
import org.openmrs.module.appointmentscheduling.TimeSlot;
import org.openmrs.module.appointmentscheduling.Appointment.AppointmentStatus;
import org.openmrs.module.appointmentscheduling.api.AppointmentService;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.openmrs.test.Verifies;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import static junit.framework.Assert.*;

/**
* Tests Appointment methods in the {@link $ AppointmentService} .
*/
Expand Down Expand Up @@ -394,5 +389,42 @@ public void shouldChangeCorrectAppointments_cleanOpenAppointments() {
assertTrue(appointment.getStatus().equals(AppointmentStatus.MISSED));

}



@Ignore
@Test
public void shouldGetAllTimeSlotsByConstraintsSortedByStartDate() throws ParseException{
AppointmentType type = service.getAppointmentType(1);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
Date fromDate = format.parse("2005-01-01 00:00:00.0");

List<TimeSlot> result = service.getTimeSlotsByConstraintsIncludingFull(type,fromDate,null,null,null);
assertNotNull(result);
assertTrue(result.size() == 6);

TimeSlot firstTimeSlot = result.get(0);
assertTrue(firstTimeSlot.getTimeSlotId().equals(5));

TimeSlot lastTimeSlot = result.get(result.size()-1);
assertTrue(lastTimeSlot.getTimeSlotId().equals(4));
}

@Ignore
@Test
public void shouldGetOnlyAvailableTimeSlotsByConstraintsSortedByStartDate() throws ParseException{
AppointmentType type = service.getAppointmentType(1);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
Date fromDate = format.parse("2005-01-01 00:00:00.0");

List<TimeSlot> result = service.getTimeSlotsByConstraints(type,fromDate,null,null,null);
assertNotNull(result);
assertTrue(result.size() == 4);

TimeSlot firstTimeSlot = result.get(0);
assertTrue(firstTimeSlot.getTimeSlotId().equals(5));

TimeSlot lastTimeSlot = result.get(result.size()-1);
assertTrue(lastTimeSlot.getTimeSlotId().equals(2));
}

}

0 comments on commit c8bf52a

Please sign in to comment.