Skip to content

Commit

Permalink
added some static imports for Appointment.AppointmentStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
mogoodrich committed Apr 3, 2014
1 parent 5e64066 commit 8c8c70e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ List<Appointment> getAppointmentsByAppointmentBlockAndAppointmentTypes(Appointme
* @return a list of the appointments in the given time slot.
* @should not return voided time slots
*/
List<Appointment> getAppointmentsInTimeSlotByStatus(TimeSlot timeSlot, List<Appointment.AppointmentStatus> statuses);
List<Appointment> getAppointmentsInTimeSlotByStatus(TimeSlot timeSlot, List<AppointmentStatus> statuses);

/**
* Retrieve a count of all appointments in a given time slot, filtered by status
Expand All @@ -91,5 +91,5 @@ List<Appointment> getAppointmentsByAppointmentBlockAndAppointmentTypes(Appointme
* @return a cont of the appointments in the given time slot.
* @should not return voided time slots
*/
Integer getCountOfAppointmentsInTimeSlotByStatus(TimeSlot timeSlot, List<Appointment.AppointmentStatus> statuses);
Integer getCountOfAppointmentsInTimeSlotByStatus(TimeSlot timeSlot, List<AppointmentStatus> statuses);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
import org.openmrs.module.appointmentscheduling.Appointment;

public class AppointmentStatusSerializer extends JsonSerializer<Appointment.AppointmentStatus> {
import static org.openmrs.module.appointmentscheduling.Appointment.AppointmentStatus;

public class AppointmentStatusSerializer extends JsonSerializer<AppointmentStatus> {

@Override
public void serialize(Appointment.AppointmentStatus appointmentStatus, JsonGenerator jsonGenerator,
public void serialize(AppointmentStatus appointmentStatus, JsonGenerator jsonGenerator,
SerializerProvider serializerProvider) throws IOException, JsonProcessingException {

jsonGenerator.writeStartObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,63 @@
import org.junit.Assert;
import org.junit.Test;

import static org.openmrs.module.appointmentscheduling.Appointment.AppointmentStatus;
import static org.openmrs.module.appointmentscheduling.Appointment.AppointmentStatusType;

public class AppointmentTest {

@Test
public void shouldReturnAllActiveStatuses() {

List<Appointment.AppointmentStatus> statuses = Appointment.AppointmentStatus
.getAppointmentsStatusByType(Appointment.AppointmentStatusType.ACTIVE);
List<AppointmentStatus> statuses = AppointmentStatus
.getAppointmentsStatusByType(AppointmentStatusType.ACTIVE);
Assert.assertEquals(3, statuses.size());
Assert.assertTrue(statuses
.contains(Appointment.AppointmentStatus.WAITING));
.contains(AppointmentStatus.WAITING));
Assert.assertTrue(statuses
.contains(Appointment.AppointmentStatus.INCONSULTATION));
.contains(AppointmentStatus.INCONSULTATION));
Assert.assertTrue(statuses
.contains(Appointment.AppointmentStatus.WALKIN));
.contains(AppointmentStatus.WALKIN));

}

@Test
public void shouldReturnAllCancelledAndMissedStatuses() {

List<Appointment.AppointmentStatus> statuses = Appointment.AppointmentStatus
List<AppointmentStatus> statuses = AppointmentStatus
.getAppointmentsStatusByTypes(Arrays.asList(
Appointment.AppointmentStatusType.CANCELLED,
Appointment.AppointmentStatusType.MISSED));
AppointmentStatusType.CANCELLED,
AppointmentStatusType.MISSED));
Assert.assertEquals(3, statuses.size());
Assert.assertTrue(statuses
.contains(Appointment.AppointmentStatus.CANCELLED));
.contains(AppointmentStatus.CANCELLED));
Assert.assertTrue(statuses
.contains(Appointment.AppointmentStatus.CANCELLED_AND_NEEDS_RESCHEDULE));
.contains(AppointmentStatus.CANCELLED_AND_NEEDS_RESCHEDULE));
Assert.assertTrue(statuses
.contains(Appointment.AppointmentStatus.MISSED));
.contains(AppointmentStatus.MISSED));

}

@Test
public void shouldReturnAllNotCancelledStatus() {

List<Appointment.AppointmentStatus> statuses = Appointment.AppointmentStatus
List<AppointmentStatus> statuses = AppointmentStatus
.getNotCancelledAppointmentStatuses();
Assert.assertEquals(7, statuses.size());
Assert.assertTrue(statuses
.contains(Appointment.AppointmentStatus.WAITING));
.contains(AppointmentStatus.WAITING));
Assert.assertTrue(statuses
.contains(Appointment.AppointmentStatus.INCONSULTATION));
.contains(AppointmentStatus.INCONSULTATION));
Assert.assertTrue(statuses
.contains(Appointment.AppointmentStatus.WALKIN));
.contains(AppointmentStatus.WALKIN));
Assert.assertTrue(statuses
.contains(Appointment.AppointmentStatus.MISSED));
.contains(AppointmentStatus.MISSED));
Assert.assertTrue(statuses
.contains(Appointment.AppointmentStatus.SCHEDULED));
.contains(AppointmentStatus.SCHEDULED));
Assert.assertTrue(statuses
.contains(Appointment.AppointmentStatus.RESCHEDULED));
.contains(AppointmentStatus.RESCHEDULED));
Assert.assertTrue(statuses
.contains(Appointment.AppointmentStatus.COMPLETED));
.contains(AppointmentStatus.COMPLETED));

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.openmrs.module.appointmentscheduling.rest.resource.openmrs1_9;

import org.openmrs.module.appointmentscheduling.Appointment;
import org.openmrs.module.appointmentscheduling.rest.controller.AppointmentRestController;
import org.openmrs.module.webservices.rest.SimpleObject;
import org.openmrs.module.webservices.rest.web.RequestContext;
Expand All @@ -10,6 +9,8 @@
import org.openmrs.module.webservices.rest.web.resource.api.Searchable;
import org.openmrs.module.webservices.rest.web.response.ResponseException;

import static org.openmrs.module.appointmentscheduling.Appointment.AppointmentStatus;

@Resource(name = RestConstants.VERSION_1
+ AppointmentRestController.APPOINTMENT_SCHEDULING_REST_NAMESPACE
+ "/appointmentstatus", supportedClass = AppointmentStatusResource1_9.class, supportedOpenmrsVersions = "1.9.*")
Expand All @@ -18,7 +19,7 @@ public class AppointmentStatusResource1_9 implements Listable, Searchable {
@Override
public SimpleObject getAll(RequestContext requestContext)
throws ResponseException {
Appointment.AppointmentStatus[] appointmentStatus = Appointment.AppointmentStatus
AppointmentStatus[] appointmentStatus = AppointmentStatus
.values();
SimpleObject simpleObject = new SimpleObject().add("results",
appointmentStatus);
Expand All @@ -29,7 +30,7 @@ public SimpleObject getAll(RequestContext requestContext)
public String getUri(Object o) {
return RestConstants.URI_PREFIX
+ "/appointmentscheduling/appointmentstatus/"
+ ((Appointment.AppointmentStatus) o).getName();
+ ((AppointmentStatus) o).getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.openmrs.module.appointmentscheduling.rest.resource.openmrs1_9;

import org.openmrs.module.appointmentscheduling.Appointment;
import org.openmrs.module.appointmentscheduling.rest.controller.AppointmentRestController;
import org.openmrs.module.webservices.rest.SimpleObject;
import org.openmrs.module.webservices.rest.web.RequestContext;
Expand All @@ -10,6 +9,8 @@
import org.openmrs.module.webservices.rest.web.resource.api.Searchable;
import org.openmrs.module.webservices.rest.web.response.ResponseException;

import static org.openmrs.module.appointmentscheduling.Appointment.AppointmentStatusType;

@Resource(name = RestConstants.VERSION_1
+ AppointmentRestController.APPOINTMENT_SCHEDULING_REST_NAMESPACE
+ "/appointmentstatustype", supportedClass = AppointmentStatusTypeResource1_9.class, supportedOpenmrsVersions = "1.9.*")
Expand All @@ -18,7 +19,7 @@ public class AppointmentStatusTypeResource1_9 implements Listable, Searchable {
@Override
public SimpleObject getAll(RequestContext requestContext)
throws ResponseException {
Appointment.AppointmentStatusType[] appointmentStatusType = Appointment.AppointmentStatusType
AppointmentStatusType[] appointmentStatusType = AppointmentStatusType
.values();
SimpleObject simpleObject = new SimpleObject().add("results",
appointmentStatusType);
Expand All @@ -28,7 +29,7 @@ public SimpleObject getAll(RequestContext requestContext)
@Override
public String getUri(Object o) {
return RestConstants.URI_PREFIX + "/appointmentscheduling/appointmentstatustype/"
+ ((Appointment.AppointmentStatusType) o).getName();
+ ((AppointmentStatusType) o).getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package org.openmrs.module.appointmentscheduling.rest.resource.openmrs1_9;

import java.io.IOException;

import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import org.openmrs.module.appointmentscheduling.Appointment;
import org.openmrs.module.webservices.rest.SimpleObject;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.web.test.BaseModuleWebContextSensitiveTest;

import java.io.IOException;

import static org.junit.Assert.assertTrue;
import static org.openmrs.module.appointmentscheduling.Appointment.AppointmentStatus;

public class AppointmentStatusResource1_9Test extends BaseModuleWebContextSensitiveTest {

Expand All @@ -22,7 +22,7 @@ public void testName() throws Exception {

String appointmentStatusJson = toJson(simpleObject);

for (Appointment.AppointmentStatus appointmentStatus : Appointment.AppointmentStatus.values()) {
for (AppointmentStatus appointmentStatus : AppointmentStatus.values()) {
assertTrue(appointmentStatusJson.contains(appointmentStatus.getName()));
}
}
Expand Down

0 comments on commit 8c8c70e

Please sign in to comment.