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

BAH-4154 Unit tests fail when run in certain timezones #165

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.openmrs.module.appointments.web.controller;

import org.apache.commons.lang.time.DateUtils;
import org.codehaus.jackson.type.TypeReference;
import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -240,14 +241,20 @@ public void shouldThrowExceptionWhenThereIsNoRequestPayload() throws Exception {

@Test
public void shouldNotUpdateAppointmentMetadataOnConflictsCall() throws Exception {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
Date startDatetime = dateFormat.parse("2107-07-15T17:30:00.0");
Date endDatetime = DateUtils.addHours(startDatetime, 1);
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
String startDateStr = dateFormat.format(startDatetime);
String endDateStr = dateFormat.format(endDatetime);

String content = "{" +
"\"uuid\":\"c36006e5-9fbb-4f20-866b-0ece245615a7\"," +
"\"patientUuid\": \"2c33920f-7aa6-48d6-998a-60412d8ff7d5\"," +
"\"serviceUuid\": \"c36006d4-9fbb-4f20-866b-0ece245615c1\"," +
"\"serviceTypeUuid\": \"672546e5-9fbb-4f20-866b-0ece24564578\"," +
"\"startDateTime\": \"2107-07-15T17:30:00.0\"," +
"\"endDateTime\": \"2107-07-15T18:30:00.0\"," +
"\"startDateTime\": \"" + startDateStr + "\"," +
"\"endDateTime\": \"" + endDateStr + "\"," +
"\"providers\": [{" +
"\"uuid\": \"2bdc3f7d-d911-401a-84e9-5494dda83e8e\"," +
"\"response\": \"ACCEPTED\"," +
Expand All @@ -266,8 +273,9 @@ public void shouldNotUpdateAppointmentMetadataOnConflictsCall() throws Exception
assertNotNull(editResponse);
assertEquals(200, editResponse.getStatus());
AppointmentDefaultResponse appointmentEditResponse = deserialize(editResponse, new TypeReference<AppointmentDefaultResponse>() {});

assertEquals("c36006e5-9fbb-4f20-866b-0ece245615a7", appointmentEditResponse.getUuid());
assertEquals("Fri Jul 15 17:30:00 UTC 2107", appointmentEditResponse.getStartDateTime().toString());
assertEquals("Fri Jul 15 18:30:00 UTC 2107", appointmentEditResponse.getEndDateTime().toString());
assertEquals(startDatetime, appointmentEditResponse.getStartDateTime());
assertEquals(endDatetime, appointmentEditResponse.getEndDateTime());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,6 @@ public void shouldThrowExceptionWhenEndDateIsDecreasedAndFutureRecurringAppointm

@Test
public void setAppointments_shouldThrowWhenFrequecyIsDecreasedSuchThatEndDateIsInPast() {
TimeZone.setDefault(TimeZone.getTimeZone("IST"));
Date date = new Date();

RecurringAppointmentRequest recurringRequest = getAppointmentRequest(addDays(date, +7), addHours(addDays(date, +7), +1));
Expand Down
Loading