Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hapi-fhir-storage-cr: Disable conformance validation to speed up storage-cr tests. #6760

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.client.api.IRestfulClientFactory;
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import ca.uhn.fhir.rest.client.interceptor.SimpleRequestHeaderInterceptor;
import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
Expand All @@ -30,15 +33,13 @@
import org.eclipse.jetty.ee10.servlet.ServletHolder;
import org.eclipse.jetty.server.Server;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.Resource;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.opencds.cqf.fhir.cql.EvaluationSettings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.test.context.ContextConfiguration;

import java.util.List;
import java.util.concurrent.TimeUnit;


Expand All @@ -63,8 +64,6 @@ public abstract class BaseCrR4TestServer extends BaseJpaR4Test implements IResou
public static IParser ourParser;


//@Autowired
//ApplicationContext myApplicationContext;
private SimpleRequestHeaderInterceptor mySimpleHeaderInterceptor;

@Autowired
Expand Down Expand Up @@ -108,20 +107,16 @@ public void beforeStartServer() throws Exception {
builder.setConnectionManager(connectionManager);
ourHttpClient = builder.build();

ourCtx.getRestfulClientFactory().setSocketTimeout(600 * 1000);
ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
ourClient.setLogRequestAndResponse(true);

ourParser = ourCtx.newJsonParser().setPrettyPrint(true);

ourRestfulServer.setDefaultResponseEncoding(EncodingEnum.XML);
ourPagingProvider = myAppCtx.getBean(DatabaseBackedPagingProvider.class);
ourRestfulServer.setPagingProvider(ourPagingProvider);

mySimpleHeaderInterceptor = new SimpleRequestHeaderInterceptor();
ourClient.registerInterceptor(mySimpleHeaderInterceptor);
myStorageSettings.setIndexMissingFields(JpaStorageSettings.IndexEnabledEnum.DISABLED);

ourClient = initClient(mySimpleHeaderInterceptor);
}

@Override
Expand All @@ -139,23 +134,6 @@ public void loadBundle(String theLocation) {
ourClient.transaction().withBundle(bundy).execute();
}


public Bundle makeBundle(List<? extends Resource> theResources) {
return makeBundle(theResources.toArray(new Resource[theResources.size()]));
}

public Bundle makeBundle(Resource... theResources) {
Bundle bundle = new Bundle();
bundle.setType(Bundle.BundleType.SEARCHSET);
bundle.setTotal(theResources != null ? theResources.length : 0);
if (theResources != null) {
for (Resource l : theResources) {
bundle.addEntry().setResource(l).setFullUrl("/" + l.fhirType() + "/" + l.getId());
}
}
return bundle;
}

protected RequestDetails setupRequestDetails() {
var requestDetails = new ServletRequestDetails();
requestDetails.setServletRequest(new MockHttpServletRequest());
Expand All @@ -164,4 +142,21 @@ protected RequestDetails setupRequestDetails() {
return requestDetails;
}

private static IGenericClient initClient(SimpleRequestHeaderInterceptor simpleHeaderInterceptor) {
final IRestfulClientFactory restfulClientFactory = ourCtx.getRestfulClientFactory();

restfulClientFactory.setServerValidationMode(ServerValidationModeEnum.NEVER);
restfulClientFactory.setSocketTimeout(600 * 1000);

final IGenericClient genericClient = restfulClientFactory.newGenericClient(ourServerBase);

var loggingInterceptor = new LoggingInterceptor();
loggingInterceptor.setLogRequestBody(true);
loggingInterceptor.setLogResponseBody(true);

genericClient.registerInterceptor(loggingInterceptor);
genericClient.registerInterceptor(simpleHeaderInterceptor);

return genericClient;
}
}
Loading