From 8c8c70ecb5703c7acb364eaa9b4980e6019a59c1 Mon Sep 17 00:00:00 2001 From: mogoodrich Date: Thu, 3 Apr 2014 18:15:22 -0400 Subject: [PATCH] added some static imports for Appointment.AppointmentStatus --- .../api/db/AppointmentDAO.java | 4 +- .../AppointmentStatusSerializer.java | 7 ++-- .../AppointmentTest.java | 41 ++++++++++--------- .../AppointmentStatusResource1_9.java | 7 ++-- .../AppointmentStatusTypeResource1_9.java | 7 ++-- .../AppointmentStatusResource1_9Test.java | 8 ++-- 6 files changed, 40 insertions(+), 34 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/appointmentscheduling/api/db/AppointmentDAO.java b/api/src/main/java/org/openmrs/module/appointmentscheduling/api/db/AppointmentDAO.java index be531286..4352f215 100644 --- a/api/src/main/java/org/openmrs/module/appointmentscheduling/api/db/AppointmentDAO.java +++ b/api/src/main/java/org/openmrs/module/appointmentscheduling/api/db/AppointmentDAO.java @@ -81,7 +81,7 @@ List getAppointmentsByAppointmentBlockAndAppointmentTypes(Appointme * @return a list of the appointments in the given time slot. * @should not return voided time slots */ - List getAppointmentsInTimeSlotByStatus(TimeSlot timeSlot, List statuses); + List getAppointmentsInTimeSlotByStatus(TimeSlot timeSlot, List statuses); /** * Retrieve a count of all appointments in a given time slot, filtered by status @@ -91,5 +91,5 @@ List getAppointmentsByAppointmentBlockAndAppointmentTypes(Appointme * @return a cont of the appointments in the given time slot. * @should not return voided time slots */ - Integer getCountOfAppointmentsInTimeSlotByStatus(TimeSlot timeSlot, List statuses); + Integer getCountOfAppointmentsInTimeSlotByStatus(TimeSlot timeSlot, List statuses); } diff --git a/api/src/main/java/org/openmrs/module/appointmentscheduling/serialize/AppointmentStatusSerializer.java b/api/src/main/java/org/openmrs/module/appointmentscheduling/serialize/AppointmentStatusSerializer.java index dc0c4a13..6e61b005 100644 --- a/api/src/main/java/org/openmrs/module/appointmentscheduling/serialize/AppointmentStatusSerializer.java +++ b/api/src/main/java/org/openmrs/module/appointmentscheduling/serialize/AppointmentStatusSerializer.java @@ -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 { +import static org.openmrs.module.appointmentscheduling.Appointment.AppointmentStatus; + +public class AppointmentStatusSerializer extends JsonSerializer { @Override - public void serialize(Appointment.AppointmentStatus appointmentStatus, JsonGenerator jsonGenerator, + public void serialize(AppointmentStatus appointmentStatus, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException { jsonGenerator.writeStartObject(); diff --git a/api/src/test/java/org/openmrs/module/appointmentscheduling/AppointmentTest.java b/api/src/test/java/org/openmrs/module/appointmentscheduling/AppointmentTest.java index 0a0f599a..0567207e 100644 --- a/api/src/test/java/org/openmrs/module/appointmentscheduling/AppointmentTest.java +++ b/api/src/test/java/org/openmrs/module/appointmentscheduling/AppointmentTest.java @@ -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 statuses = Appointment.AppointmentStatus - .getAppointmentsStatusByType(Appointment.AppointmentStatusType.ACTIVE); + List 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 statuses = Appointment.AppointmentStatus + List 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 statuses = Appointment.AppointmentStatus + List 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)); } } diff --git a/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusResource1_9.java b/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusResource1_9.java index b752ebb3..10472442 100644 --- a/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusResource1_9.java +++ b/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusResource1_9.java @@ -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; @@ -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.*") @@ -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); @@ -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 diff --git a/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusTypeResource1_9.java b/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusTypeResource1_9.java index d0b8fbc9..7b1f45d9 100644 --- a/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusTypeResource1_9.java +++ b/omod/src/main/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusTypeResource1_9.java @@ -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; @@ -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.*") @@ -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); @@ -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 diff --git a/omod/src/test/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusResource1_9Test.java b/omod/src/test/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusResource1_9Test.java index 28974866..fed51f0b 100644 --- a/omod/src/test/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusResource1_9Test.java +++ b/omod/src/test/java/org/openmrs/module/appointmentscheduling/rest/resource/openmrs1_9/AppointmentStatusResource1_9Test.java @@ -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 { @@ -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())); } }