Extend meta source length (#6532)
* Add test * Extend field * Migration (aimed to backport) * Add migration for HFJ_RES_VER_PROV table --------- Co-authored-by: juan.marchionatto <juan.marchionatto@smilecdr.com>
This commit is contained in:
parent
0a88c31cf3
commit
9d584d1b83
|
@ -125,6 +125,7 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
||||||
init700();
|
init700();
|
||||||
init720();
|
init720();
|
||||||
init740();
|
init740();
|
||||||
|
init760();
|
||||||
init780();
|
init780();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +155,25 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
||||||
.withType(ColumnTypeEnum.STRING, 512);
|
.withType(ColumnTypeEnum.STRING, 512);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Built at 2024.11.02 to be backported to version 7.6
|
||||||
|
*/
|
||||||
|
protected void init760() {
|
||||||
|
final Builder version = forVersion(VersionEnum.V7_6_0);
|
||||||
|
|
||||||
|
version.onTable("HFJ_RES_VER")
|
||||||
|
.modifyColumn("20241102.10", "SOURCE_URI")
|
||||||
|
.nullable()
|
||||||
|
.withType(ColumnTypeEnum.STRING, 768)
|
||||||
|
.failureAllowed();
|
||||||
|
|
||||||
|
version.onTable("HFJ_RES_VER_PROV")
|
||||||
|
.modifyColumn("20241102.20", "SOURCE_URI")
|
||||||
|
.nullable()
|
||||||
|
.withType(ColumnTypeEnum.STRING, 768)
|
||||||
|
.failureAllowed();
|
||||||
|
}
|
||||||
|
|
||||||
protected void init740() {
|
protected void init740() {
|
||||||
// Start of migrations from 7.2 to 7.4
|
// Start of migrations from 7.2 to 7.4
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ import java.util.Collection;
|
||||||
})
|
})
|
||||||
public class ResourceHistoryTable extends BaseHasResource implements Serializable {
|
public class ResourceHistoryTable extends BaseHasResource implements Serializable {
|
||||||
public static final String IDX_RESVER_ID_VER = "IDX_RESVER_ID_VER";
|
public static final String IDX_RESVER_ID_VER = "IDX_RESVER_ID_VER";
|
||||||
public static final int SOURCE_URI_LENGTH = 100;
|
public static final int SOURCE_URI_LENGTH = ResourceIndexedSearchParamString.MAX_LENGTH;
|
||||||
/**
|
/**
|
||||||
* @see ResourceEncodingEnum
|
* @see ResourceEncodingEnum
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
package ca.uhn.fhir.jpa.entity;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.jpa.rp.r4.PatientResourceProvider;
|
||||||
|
import ca.uhn.fhir.jpa.test.BaseJpaR4Test;
|
||||||
|
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||||
|
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||||
|
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.test.utilities.JettyUtil;
|
||||||
|
import org.eclipse.jetty.ee10.servlet.ServletContextHandler;
|
||||||
|
import org.eclipse.jetty.ee10.servlet.ServletHolder;
|
||||||
|
import org.eclipse.jetty.server.Server;
|
||||||
|
import org.h2.util.StringUtils;
|
||||||
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
|
import org.hl7.fhir.r4.model.Meta;
|
||||||
|
import org.hl7.fhir.r4.model.Patient;
|
||||||
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
public class MetaSourceTest extends BaseJpaR4Test {
|
||||||
|
|
||||||
|
private static RestfulServer ourRestServer;
|
||||||
|
private static final FhirContext ourCtx = FhirContext.forR4Cached();
|
||||||
|
private static Server ourServer;
|
||||||
|
private static String ourServerBase;
|
||||||
|
private IGenericClient myClient;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void beforeStartServer() throws Exception {
|
||||||
|
if (ourRestServer == null) {
|
||||||
|
|
||||||
|
PatientResourceProvider patientRp = new PatientResourceProvider();
|
||||||
|
patientRp.setContext(ourCtx);
|
||||||
|
patientRp.setDao(myPatientDao);
|
||||||
|
|
||||||
|
RestfulServer restServer = new RestfulServer(ourCtx);
|
||||||
|
restServer.setResourceProviders(patientRp);
|
||||||
|
|
||||||
|
restServer.registerProviders(mySystemProvider);
|
||||||
|
|
||||||
|
ourServer = new Server(0);
|
||||||
|
|
||||||
|
ServletContextHandler proxyHandler = new ServletContextHandler();
|
||||||
|
proxyHandler.setContextPath("/");
|
||||||
|
|
||||||
|
ServletHolder servletHolder = new ServletHolder();
|
||||||
|
servletHolder.setServlet(restServer);
|
||||||
|
proxyHandler.addServlet(servletHolder, "/fhir/context/*");
|
||||||
|
|
||||||
|
restServer.setFhirContext(ourCtx);
|
||||||
|
|
||||||
|
ourServer.setHandler(proxyHandler);
|
||||||
|
JettyUtil.startServer(ourServer);
|
||||||
|
int myPort = JettyUtil.getPortForStartedServer(ourServer);
|
||||||
|
ourServerBase = "http://localhost:" + myPort + "/fhir/context";
|
||||||
|
|
||||||
|
ourCtx.getRestfulClientFactory().setSocketTimeout(600 * 1_000);
|
||||||
|
ourRestServer = restServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
myClient = ourCtx.newRestfulGenericClient(ourServerBase);
|
||||||
|
SimpleRequestHeaderInterceptor simpleHeaderInterceptor = new SimpleRequestHeaderInterceptor();
|
||||||
|
myClient.registerInterceptor(simpleHeaderInterceptor);
|
||||||
|
|
||||||
|
ourRestServer.setDefaultResponseEncoding(EncodingEnum.XML);
|
||||||
|
ourRestServer.setPagingProvider(myPagingProvider);
|
||||||
|
|
||||||
|
LoggingInterceptor loggingInterceptor = new LoggingInterceptor();
|
||||||
|
loggingInterceptor.setLogRequestBody(true);
|
||||||
|
loggingInterceptor.setLogResponseBody(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testMetaSourceSupportsMaxLength() {
|
||||||
|
int metaSourceLength = 700;
|
||||||
|
|
||||||
|
Patient p1 = new Patient();
|
||||||
|
p1.setActive(true);
|
||||||
|
|
||||||
|
Meta meta = new Meta();
|
||||||
|
String longSourceValue = StringUtils.pad("http://", metaSourceLength, "abc", true);
|
||||||
|
meta.setSource(longSourceValue);
|
||||||
|
p1.setMeta(meta);
|
||||||
|
IIdType patientId = myClient.create().resource(p1).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
|
// verify
|
||||||
|
Patient patient = myClient.read().resource(Patient.class).withId(patientId.getValueAsString()).execute();
|
||||||
|
assertThat(patient.getMeta().getSource()).hasSizeGreaterThan(metaSourceLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@AfterAll
|
||||||
|
public static void afterClassClearContext() throws Exception {
|
||||||
|
JettyUtil.closeServer(ourServer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue