Fix broken unit test and allow invalid dates in web testewr UI

This commit is contained in:
James Agnew 2015-04-28 10:33:14 -04:00
parent 5e8fe01af1
commit 3a1cc48048
8 changed files with 60 additions and 15 deletions

View File

@ -75,6 +75,7 @@ public interface IRestfulClientFactory {
/** /**
* @deprecated Use {@link #getServerValidationMode()} instead * @deprecated Use {@link #getServerValidationMode()} instead
*/ */
@Deprecated
ServerValidationModeEnum getServerValidationModeEnum(); ServerValidationModeEnum getServerValidationModeEnum();
/** /**
@ -168,6 +169,7 @@ public interface IRestfulClientFactory {
/** /**
* @deprecated Use {@link #setServerValidationMode(ServerValidationModeEnum)} instead. This method was incorrectly named. * @deprecated Use {@link #setServerValidationMode(ServerValidationModeEnum)} instead. This method was incorrectly named.
*/ */
@Deprecated
void setServerValidationModeEnum(ServerValidationModeEnum theServerValidationMode); void setServerValidationModeEnum(ServerValidationModeEnum theServerValidationMode);
/** /**

View File

@ -1875,7 +1875,7 @@ public abstract class BaseFhirResourceDao<T extends IResource> extends BaseFhirD
if (Character.isDigit(theResource.getId().getIdPart().charAt(0))) { if (Character.isDigit(theResource.getId().getIdPart().charAt(0))) {
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirResourceDao.class, "failedToCreateWithClientAssignedNumericId", theResource.getId().getIdPart())); throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirResourceDao.class, "failedToCreateWithClientAssignedNumericId", theResource.getId().getIdPart()));
} }
return doCreate(theResource, null, true); return doCreate(theResource, null, thePerformIndexing);
} }
} }

View File

@ -4,6 +4,7 @@ import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.emptyString; import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
@ -11,9 +12,11 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.IOUtils;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -22,10 +25,12 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.jpa.entity.TagTypeEnum; import ca.uhn.fhir.jpa.entity.TagTypeEnum;
import ca.uhn.fhir.jpa.provider.SystemProviderTest;
import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum; import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.model.api.TagList; import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.base.composite.BaseCodingDt; import ca.uhn.fhir.model.base.composite.BaseCodingDt;
import ca.uhn.fhir.model.dstu2.resource.OperationOutcome;
import ca.uhn.fhir.model.dstu2.composite.CodingDt; import ca.uhn.fhir.model.dstu2.composite.CodingDt;
import ca.uhn.fhir.model.dstu2.composite.MetaDt; import ca.uhn.fhir.model.dstu2.composite.MetaDt;
import ca.uhn.fhir.model.dstu2.resource.Bundle; import ca.uhn.fhir.model.dstu2.resource.Bundle;
@ -94,6 +99,30 @@ public class FhirSystemDaoDstu2Test {
} }
@Test
public void testTransactionFromBundle() throws Exception {
InputStream bundleRes = SystemProviderTest.class.getResourceAsStream("/transaction_link_patient_eve.xml");
String bundleStr = IOUtils.toString(bundleRes);
Bundle bundle = ourFhirContext.newXmlParser().parseResource(Bundle.class, bundleStr);
Bundle resp = ourSystemDao.transaction(bundle);
ourLog.info(ourFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp));
OperationOutcome oo = (OperationOutcome) resp.getEntry().get(0).getResource();
assertThat(oo.getIssue().get(0).getDetailsElement().getValue(), containsString("Transaction completed"));
assertThat(resp.getEntry().get(1).getTransactionResponse().getLocation(), startsWith("Patient/a555-44-4444/_history/"));
assertThat(resp.getEntry().get(2).getTransactionResponse().getLocation(), startsWith("Patient/temp6789/_history/"));
assertThat(resp.getEntry().get(3).getTransactionResponse().getLocation(), startsWith("Organization/GHH/_history/"));
Patient p = ourPatientDao.read(new IdDt("Patient/a555-44-4444/_history/1"));
assertEquals("Patient/temp6789", p.getLink().get(0).getOther().getReference().getValue());
}
@Test @Test
public void testTransactionReadAndSearch() { public void testTransactionReadAndSearch() {
String methodName = "testTransactionReadAndSearch"; String methodName = "testTransactionReadAndSearch";

View File

@ -1,8 +1,6 @@
package ca.uhn.fhir.jpa.provider; package ca.uhn.fhir.jpa.provider;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
@ -19,8 +17,6 @@ import ca.uhn.fhir.jpa.rp.dstu.ObservationResourceProvider;
import ca.uhn.fhir.jpa.rp.dstu.OrganizationResourceProvider; import ca.uhn.fhir.jpa.rp.dstu.OrganizationResourceProvider;
import ca.uhn.fhir.jpa.rp.dstu.PatientResourceProvider; import ca.uhn.fhir.jpa.rp.dstu.PatientResourceProvider;
import ca.uhn.fhir.jpa.testutil.RandomServerPortProvider; import ca.uhn.fhir.jpa.testutil.RandomServerPortProvider;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.resource.Observation; import ca.uhn.fhir.model.dstu.resource.Observation;
import ca.uhn.fhir.model.dstu.resource.Organization; import ca.uhn.fhir.model.dstu.resource.Organization;
import ca.uhn.fhir.model.dstu.resource.Patient; import ca.uhn.fhir.model.dstu.resource.Patient;
@ -30,7 +26,7 @@ import ca.uhn.fhir.rest.server.RestfulServer;
public class SystemProviderTest { public class SystemProviderTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SystemProviderTest.class);
private static Server ourServer; private static Server ourServer;
private static ClassPathXmlApplicationContext ourAppCtx; private static ClassPathXmlApplicationContext ourAppCtx;
private static FhirContext ourCtx; private static FhirContext ourCtx;
@ -41,8 +37,8 @@ public class SystemProviderTest {
InputStream bundleRes = SystemProviderTest.class.getResourceAsStream("/transaction_link_patient_eve.xml"); InputStream bundleRes = SystemProviderTest.class.getResourceAsStream("/transaction_link_patient_eve.xml");
String bundle = IOUtils.toString(bundleRes); String bundle = IOUtils.toString(bundleRes);
String response = ourClient.transaction().withBundle(bundle).execute(); String response = ourClient.transaction().withBundle(bundle).prettyPrint().execute();
ourLog.info(response);
} }

View File

@ -6,7 +6,7 @@
<Patient> <Patient>
<!-- PID|||555-44-4444||EVERYWOMAN^EVE^E^^^^L|JONES|19620320|F|||153 FERNWOOD DR.^ <!-- PID|||555-44-4444||EVERYWOMAN^EVE^E^^^^L|JONES|19620320|F|||153 FERNWOOD DR.^
^STATESVILLE^OH^35292||(206)3345232|(206)752-121||||AC555444444||67-A4335^OH^20030520 --> ^STATESVILLE^OH^35292||(206)3345232|(206)752-121||||AC555444444||67-A4335^OH^20030520 -->
<id value="555-44-4444"/> <id value="a555-44-4444"/>
<extension url="http://ihe.net/ITI-78/Profile/pdqm#mothersMaidenName"> <extension url="http://ihe.net/ITI-78/Profile/pdqm#mothersMaidenName">
<valueHumanName> <valueHumanName>
<family value="Jones"/> <family value="Jones"/>
@ -62,8 +62,8 @@
</Patient> </Patient>
</resource> </resource>
<transaction> <transaction>
<method code="PUT"/> <method value="PUT"/>
<url value="Patient/555-44-4444"/> <url value="Patient/a555-44-4444"/>
</transaction> </transaction>
</entry> </entry>
<entry> <entry>
@ -88,7 +88,7 @@
</managingOrganization> </managingOrganization>
<link> <link>
<other> <other>
<reference value="Patient/555-44-4444"/> <reference value="Patient/a555-44-4444"/>
</other> </other>
<type value="replace"/> <type value="replace"/>
</link> </link>
@ -96,8 +96,19 @@
</Patient> </Patient>
</resource> </resource>
<transaction> <transaction>
<method code="PUT"/> <method value="PUT"/>
<url value="Patient/temp6789"/> <url value="Patient/temp6789"/>
</transaction> </transaction>
</entry> </entry>
<entry>
<resource>
<Organization>
<id value="GHH"/>
</Organization>
</resource>
<transaction>
<method value="PUT"/>
<url value="Organization/GHH"/>
</transaction>
</entry>
</Bundle> </Bundle>

View File

@ -127,7 +127,8 @@
$('#server-history-datetime').datetimepicker({ $('#server-history-datetime').datetimepicker({
sideBySide: true, sideBySide: true,
use24hours: true, use24hours: true,
showToday: true showToday: true,
keepInvalid: true
}); });
}); });
$('#server-history-btn').click( $('#server-history-btn').click(

View File

@ -326,7 +326,8 @@
$('#resource-history-datetime').datetimepicker({ $('#resource-history-datetime').datetimepicker({
sideBySide: true, sideBySide: true,
use24hours: true, use24hours: true,
showToday: true showToday: true,
keepInvalid: true
}); });
}); });
$('#resource-history-btn').click( $('#resource-history-btn').click(

View File

@ -159,6 +159,11 @@
Allow fluent/generic client users to execute a transaction using a raw string (containing a bundle resource) Allow fluent/generic client users to execute a transaction using a raw string (containing a bundle resource)
as input instead of a Bundle resource class instance. as input instead of a Bundle resource class instance.
</action> </action>
<action type="fix">
Disable date validation in the web tester UI, so that it is possible to
enter partial dates, or dates without times, or even test out invalid date
options.
</action>
</release> </release>
<release version="0.9" date="2015-Mar-14"> <release version="0.9" date="2015-Mar-14">
<action type="add"> <action type="add">