Don't export a _format on paging links if the request didn't have one
This commit is contained in:
parent
8794de7a22
commit
16989435b0
|
@ -344,7 +344,8 @@ abstract class BaseResourceReturningMethodBinding extends BaseMethodBinding<Obje
|
|||
}
|
||||
|
||||
IVersionSpecificBundleFactory bundleFactory = theServer.getFhirContext().newBundleFactory();
|
||||
bundleFactory.initializeBundleFromBundleProvider(theServer, result, responseEncoding, theRequest.getFhirServerBase(), linkSelf, prettyPrint, 0, count, null, getResponseBundleType(),
|
||||
EncodingEnum linkEncoding = theRequest.getParameters().containsKey(Constants.PARAM_FORMAT) ? responseEncoding : null;
|
||||
bundleFactory.initializeBundleFromBundleProvider(theServer, result, linkEncoding, theRequest.getFhirServerBase(), linkSelf, prettyPrint, 0, count, null, getResponseBundleType(),
|
||||
includes);
|
||||
Bundle bundle = bundleFactory.getDstu1Bundle();
|
||||
if (bundle != null) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package ca.uhn.fhir.jpa.provider;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
@ -36,8 +38,12 @@ import ca.uhn.fhir.model.dstu2.resource.OperationDefinition;
|
|||
import ca.uhn.fhir.model.dstu2.resource.OperationOutcome;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.FifoMemoryPagingProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
|
||||
import net.sf.saxon.lib.OutputURIResolver;
|
||||
|
||||
public class SystemProviderDstu2Test extends BaseJpaTest {
|
||||
|
||||
|
@ -48,6 +54,7 @@ public class SystemProviderDstu2Test extends BaseJpaTest {
|
|||
private static IGenericClient ourClient;
|
||||
private static String ourServerBase;
|
||||
private static CloseableHttpClient ourHttpClient;
|
||||
private static RestfulServer restServer;
|
||||
|
||||
@Test
|
||||
public void testEverythingType() throws Exception {
|
||||
|
@ -60,6 +67,34 @@ public class SystemProviderDstu2Test extends BaseJpaTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEverythingReturnsCorrectFormatInPagingLink() throws Exception {
|
||||
restServer.setDefaultResponseEncoding(EncodingEnum.JSON);
|
||||
restServer.setPagingProvider(new FifoMemoryPagingProvider(1).setDefaultPageSize(10));
|
||||
ResponseHighlighterInterceptor interceptor = new ResponseHighlighterInterceptor();
|
||||
restServer.registerInterceptor(interceptor);
|
||||
|
||||
for (int i = 0; i < 11; i++) {
|
||||
Patient p = new Patient();
|
||||
p.addName().addFamily("Name" + i);
|
||||
ourClient.create().resource(p).execute();
|
||||
}
|
||||
|
||||
HttpGet get = new HttpGet(ourServerBase + "/Patient/$everything");
|
||||
get.addHeader("Accept", "application/xml, text/html");
|
||||
CloseableHttpResponse http = ourHttpClient.execute(get);
|
||||
try {
|
||||
String response = IOUtils.toString(http.getEntity().getContent());
|
||||
ourLog.info(response);
|
||||
assertThat(response, not(containsString("_format")));
|
||||
assertEquals(200, http.getStatusLine().getStatusCode());
|
||||
} finally {
|
||||
http.close();
|
||||
}
|
||||
|
||||
restServer.unregisterInterceptor(interceptor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionFromBundle4() throws Exception {
|
||||
InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/simone_bundle.xml");
|
||||
|
@ -193,7 +228,7 @@ public class SystemProviderDstu2Test extends BaseJpaTest {
|
|||
OrganizationResourceProvider organizationRp = new OrganizationResourceProvider();
|
||||
organizationRp.setDao(organizationDao);
|
||||
|
||||
RestfulServer restServer = new RestfulServer(ourCtx);
|
||||
restServer = new RestfulServer(ourCtx);
|
||||
restServer.setResourceProviders(patientRp, questionnaireRp, observationRp, organizationRp);
|
||||
|
||||
JpaSystemProviderDstu2 systemProv = ourAppCtx.getBean(JpaSystemProviderDstu2.class, "mySystemProviderDstu2");
|
||||
|
|
|
@ -279,6 +279,9 @@ public class ResponseHighlightingInterceptorTest {
|
|||
assertThat(output, containsString("resourceType"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testHighlightProducesDefaultJsonWithBrowserRequest2() throws Exception {
|
||||
ResponseHighlighterInterceptor ic = new ResponseHighlighterInterceptor();
|
||||
|
|
Loading…
Reference in New Issue