Working on #89 - Won't mark it until server is redeployed though

This commit is contained in:
jamesagnew 2015-01-24 13:01:32 +01:00
parent b36932aed4
commit aa8684c977
4 changed files with 51 additions and 7 deletions

View File

@ -286,6 +286,7 @@ public class JsonParser extends BaseParser implements IParser {
writeOptionalTagWithTextNode(theEventWriter, "versionId", nextEntry.getResource().getId().getVersionIdPart()); writeOptionalTagWithTextNode(theEventWriter, "versionId", nextEntry.getResource().getId().getVersionIdPart());
} }
writeTagWithTextNode(theEventWriter, "instant", nextEntry.getDeletedAt()); writeTagWithTextNode(theEventWriter, "instant", nextEntry.getDeletedAt());
theEventWriter.writeEnd();
} }
// linkStarted = false; // linkStarted = false;

View File

@ -93,6 +93,32 @@ public class CompleteResourceProviderTest {
} }
} }
/**
* Test for issue #60
*/
@Test
public void testReadAllInstancesOfType() throws Exception {
Patient pat;
pat = new Patient();
pat.addIdentifier().setSystem("urn:system").setValue("testReadAllInstancesOfType_01");
ourClient.create().resource(pat).prettyPrint().encodedXml().execute().getId();
pat = new Patient();
pat.addIdentifier().setSystem("urn:system").setValue("testReadAllInstancesOfType_02");
ourClient.create().resource(pat).prettyPrint().encodedXml().execute().getId();
{
Bundle returned = ourClient.search().forResource(Patient.class).encodedXml().execute();
assertThat(returned.size(), greaterThan(1));
}
{
Bundle returned = ourClient.search().forResource(Patient.class).encodedJson().execute();
assertThat(returned.size(), greaterThan(1));
}
}
@Test @Test
public void testSearchWithInclude() throws Exception { public void testSearchWithInclude() throws Exception {
Organization org = new Organization(); Organization org = new Organization();

View File

@ -1,21 +1,18 @@
package ca.uhn.fhir.parser; package ca.uhn.fhir.parser;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.StringReader; import java.io.IOException;
import net.sf.json.JSON; import net.sf.json.JSON;
import net.sf.json.JSONSerializer; import net.sf.json.JSONSerializer;
import net.sf.json.JsonConfig; import net.sf.json.JsonConfig;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.custommonkey.xmlunit.Diff;
import org.junit.Test; import org.junit.Test;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.ExtensionDt; import ca.uhn.fhir.model.api.ExtensionDt;
@ -46,6 +43,25 @@ public class JsonParserTest {
assertEquals("{\"resourceType\":\"Binary\",\"id\":\"11\",\"meta\":{\"versionId\":\"22\"},\"contentType\":\"foo\",\"content\":\"AQIDBA==\"}", val); assertEquals("{\"resourceType\":\"Binary\",\"id\":\"11\",\"meta\":{\"versionId\":\"22\"},\"contentType\":\"foo\",\"content\":\"AQIDBA==\"}", val);
} }
/**
* Fixing #89
*/
@Test
public void testEncodeBundleWithDeletedEntry() throws ConfigurationException, DataFormatException, IOException {
Bundle b = ourCtx.newXmlParser().parseBundle(IOUtils.toString(JsonParserTest.class.getResourceAsStream("/xml-bundle.xml")));
String val = ourCtx.newJsonParser().encodeBundleToString(b);
ourLog.info(val);
//@formatter:off
assertThat(val, containsString("\"deleted\":{" +
"\"type\":\"Patient\"," +
"\"resourceId\":\"4384\"," +
"\"instant\":\"2015-01-15T11:04:43.054-05:00\"" +
"}"));
//@formatter:on
}
/** /**
* #65 * #65
*/ */

File diff suppressed because one or more lines are too long