Merge branch 'master' of github.com:jamesagnew/hapi-fhir

This commit is contained in:
jamesagnew 2014-07-03 18:35:54 -04:00
commit de51a40904
5 changed files with 35 additions and 6 deletions

View File

@ -126,7 +126,7 @@ public class StringDt extends BasePrimitive<String> implements IQueryParameterTy
*/ */
@Override @Override
public boolean isEmpty() { public boolean isEmpty() {
return super.isEmpty() && StringUtils.isBlank(getValue()); return super.isBaseEmpty() && StringUtils.isBlank(getValue());
} }
@Override @Override

View File

@ -968,9 +968,10 @@ public class JsonParser extends BaseParser implements IParser {
theEventWriter.writeStartObject(); theEventWriter.writeStartObject();
theEventWriter.write("url", ext.getUrl().getValue()); theEventWriter.write("url", ext.getUrl().getValue());
if (value == null && ext.getAllUndeclaredExtensions().isEmpty()) { boolean noValue = value == null || value.isEmpty();
if (noValue && ext.getAllUndeclaredExtensions().isEmpty()) {
ourLog.debug("Extension with URL[{}] has no value", ext.getUrl().getValue()); ourLog.debug("Extension with URL[{}] has no value", ext.getUrl().getValue());
} else if (value == null) { } else if (noValue) {
theEventWriter.writeStartArray("extension"); theEventWriter.writeStartArray("extension");
for (ExtensionDt next : ext.getUndeclaredExtensions()) { for (ExtensionDt next : ext.getUndeclaredExtensions()) {
writeUndeclaredExt(theResDef, theResource, theEventWriter, next); writeUndeclaredExt(theResDef, theResource, theEventWriter, next);

View File

@ -558,7 +558,7 @@ public class RestfulServer extends HttpServlet {
statusCode=((BaseServerResponseException) e).getStatusCode(); statusCode=((BaseServerResponseException) e).getStatusCode();
issue.getDetails().setValue(e.getMessage()); issue.getDetails().setValue(e.getMessage());
} else { } else {
ourLog.error("Failure during REST processing: {}"+ e.toString(), e); ourLog.error("Failure during REST processing", e);
issue.getDetails().setValue(e.toString() + "\n\n" + ExceptionUtils.getStackTrace(e)); issue.getDetails().setValue(e.toString() + "\n\n" + ExceptionUtils.getStackTrace(e));
} }

View File

@ -0,0 +1,16 @@
package ca.uhn.fhir.model.primitive;
import static org.junit.Assert.*;
import org.junit.Test;
public class StringDtTest {
@Test
public void testBlank() {
assertTrue(new StringDt("").isEmpty());
}
}

View File

@ -68,12 +68,24 @@ public class JsonParserTest {
@Test @Test
public void testEncodingNullExtension() { public void testEncodingNullExtension() {
Patient p = new Patient(); Patient p = new Patient();
p.addUndeclaredExtension(new ExtensionDt(false, "http://foo#bar")); ExtensionDt extension = new ExtensionDt(false, "http://foo#bar");
String str = new FhirContext().newJsonParser().encodeResourceToString(p); p.addUndeclaredExtension(extension);
String str = ourCtx.newJsonParser().encodeResourceToString(p);
assertEquals("{\"resourceType\":\"Patient\",\"extension\":[{\"url\":\"http://foo#bar\"}]}", str); assertEquals("{\"resourceType\":\"Patient\",\"extension\":[{\"url\":\"http://foo#bar\"}]}", str);
extension.setValue(new StringDt());
str = ourCtx.newJsonParser().encodeResourceToString(p);
assertEquals("{\"resourceType\":\"Patient\",\"extension\":[{\"url\":\"http://foo#bar\"}]}", str);
extension.setValue(new StringDt(""));
str = ourCtx.newJsonParser().encodeResourceToString(p);
assertEquals("{\"resourceType\":\"Patient\",\"extension\":[{\"url\":\"http://foo#bar\"}]}", str);
} }
@Test @Test
public void testEncodeBinaryResource() { public void testEncodeBinaryResource() {