Fix some tests

This commit is contained in:
James Agnew 2016-06-11 06:43:27 -05:00
parent 1d2aee3dbe
commit 23840ecb7a
3 changed files with 56 additions and 0 deletions

View File

@ -357,6 +357,13 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
throw new InvalidRequestException("DateRange parameter does not suppport OR queries");
}
String param = paramList.get(0);
/*
* Since ' ' is escaped as '+' we'll be nice to anyone might have accidentally not
* escaped theirs
*/
param = param.replace(' ', '+');
DateParam parsed = new DateParam();
parsed.setValueAsQueryToken(paramList.getQualifier(), param);
addParam(parsed);

View File

@ -21,6 +21,7 @@ import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TimeZone;
import org.hl7.fhir.dstu3.model.Coding;
import org.hl7.fhir.dstu3.model.IdType;
@ -183,6 +184,44 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
}
@Test
public void testUpdateConditionalByLastUpdatedWithWrongTimezone() throws Exception {
TimeZone def = TimeZone.getDefault();
try {
TimeZone.setDefault(TimeZone.getTimeZone("GMT-0:00"));
String methodName = "testUpdateByUrl";
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName + "2");
myPatientDao.create(p, mySrd).getId();
InstantDt start = InstantDt.withCurrentTime();
Thread.sleep(100);
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
IIdType id = myPatientDao.create(p, mySrd).getId();
ourLog.info("Created patient, got it: {}", id);
Thread.sleep(100);
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.setId("Patient/" + methodName);
myPatientDao.update(p, "Patient?_lastUpdated=gt" + start.getValueAsString(), mySrd);
p = myPatientDao.read(id.toVersionless(), mySrd);
assertThat(p.getIdElement().toVersionless().toString(), not(containsString("test")));
assertEquals(id.toVersionless(), p.getIdElement().toVersionless());
assertNotEquals(id, p.getIdElement());
assertThat(p.getIdElement().toString(), endsWith("/_history/2"));
} finally {
TimeZone.setDefault(def);
}
}
@Test
public void testUpdateCreatesTextualIdIfItDoesntAlreadyExist() {
Patient p = new Patient();

View File

@ -49,6 +49,16 @@ public class BaseDateTimeDtDstu2Test {
myDateInstantZoneParser = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSSZ", TimeZone.getTimeZone("GMT-02:00"));
}
@Test
public void testEncodeZeroOffset() {
DateTimeDt dt = new DateTimeDt();
dt.setValueAsString("2011-01-01T12:00:00");
dt.setTimeZone(TimeZone.getTimeZone("GMT-0:00"));
String val = dt.getValueAsString();
assertEquals("2011-01-01T18:00:00+00:00", val);
}
@Test
public void setTimezoneToZulu() {