-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configuration property defaultPageSize (#2235)
Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
- Loading branch information
1 parent
1527df7
commit eaba471
Showing
10 changed files
with
211 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
fhir-persistence/src/test/java/com/ibm/fhir/persistence/FHIRPersistenceFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* (C) Copyright IBM Corp. 2021, 2021 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.ibm.fhir.persistence; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
|
||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
import com.ibm.fhir.config.FHIRConfiguration; | ||
import com.ibm.fhir.config.FHIRRequestContext; | ||
import com.ibm.fhir.core.FHIRConstants; | ||
import com.ibm.fhir.exception.FHIRException; | ||
import com.ibm.fhir.persistence.context.FHIRHistoryContext; | ||
import com.ibm.fhir.persistence.context.FHIRPersistenceContextFactory; | ||
import com.ibm.fhir.search.SearchConstants; | ||
|
||
public class FHIRPersistenceFactoryTest { | ||
@BeforeClass | ||
public void setUpBeforeClass() { | ||
FHIRConfiguration.setConfigHome("target/test-classes"); | ||
} | ||
|
||
@BeforeMethod | ||
@AfterMethod | ||
public void clearThreadLocal() { | ||
FHIRRequestContext.remove(); | ||
} | ||
|
||
@Test | ||
public void testCreateWithDefaultPageSize() throws Exception { | ||
runCreateTest("default", FHIRConstants.FHIR_PAGE_SIZE_DEFAULT); | ||
} | ||
|
||
@Test | ||
public void testCreateWithUserConfiguredPageSize() throws Exception { | ||
runCreateTest("pagesize-valid", 500); | ||
} | ||
|
||
@Test | ||
public void testCreateWithUserConfiguredPageSizeBeyondMaxium() throws Exception { | ||
runCreateTest("pagesize-invalid", SearchConstants.MAX_PAGE_SIZE); | ||
} | ||
|
||
private void runCreateTest(String tenantId, int expectedPageSize) throws FHIRException { | ||
FHIRRequestContext.set(new FHIRRequestContext(tenantId)); | ||
FHIRHistoryContext ctx = FHIRPersistenceContextFactory.createHistoryContext(); | ||
assertEquals (ctx.getPageSize(), expectedPageSize); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
fhir-persistence/src/test/resources/config/pagesize-invalid/fhir-server-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"fhirServer": { | ||
"core": { | ||
"defaultPageSize": 5000 | ||
}, | ||
"persistence": { | ||
"factoryClassname": "com.ibm.fhir.persistence.test.MockPersistenceFactory" | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
fhir-persistence/src/test/resources/config/pagesize-valid/fhir-server-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"fhirServer": { | ||
"core": { | ||
"defaultPageSize": 500 | ||
}, | ||
"persistence": { | ||
"factoryClassname": "com.ibm.fhir.persistence.test.MockPersistenceFactory" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
fhir-search/src/test/java/com/ibm/fhir/search/context/FHIRSearchContextFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* (C) Copyright IBM Corp. 2021 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.ibm.fhir.search.context; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
|
||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
import com.ibm.fhir.config.FHIRConfiguration; | ||
import com.ibm.fhir.config.FHIRRequestContext; | ||
import com.ibm.fhir.core.FHIRConstants; | ||
import com.ibm.fhir.exception.FHIRException; | ||
import com.ibm.fhir.search.SearchConstants; | ||
|
||
public class FHIRSearchContextFactoryTest { | ||
@BeforeClass | ||
public void setUpBeforeClass() { | ||
FHIRConfiguration.setConfigHome("target/test-classes"); | ||
} | ||
|
||
@BeforeMethod | ||
@AfterMethod | ||
public void clearThreadLocal() { | ||
FHIRRequestContext.remove(); | ||
} | ||
|
||
@Test | ||
public void testCreateWithDefaultPageSize() throws Exception { | ||
runCreateTest("default", FHIRConstants.FHIR_PAGE_SIZE_DEFAULT); | ||
} | ||
|
||
@Test | ||
public void testCreateWithUserConfiguredPageSize() throws Exception { | ||
runCreateTest("tenant1", 500); | ||
} | ||
|
||
@Test | ||
public void testCreateWithUserConfiguredPageSizeBeyondMaxium() throws Exception { | ||
runCreateTest("tenant2", SearchConstants.MAX_PAGE_SIZE); | ||
} | ||
|
||
private void runCreateTest(String tenantId, int expectedPageSize) throws FHIRException { | ||
FHIRRequestContext.set(new FHIRRequestContext(tenantId)); | ||
FHIRSearchContext ctx = FHIRSearchContextFactory.createSearchContext(); | ||
assertEquals (ctx.getPageSize(), expectedPageSize); | ||
} | ||
} |
59 changes: 31 additions & 28 deletions
59
fhir-search/src/test/resources/config/tenant1/fhir-server-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
{ | ||
"__comment": "FHIR Server configuration", | ||
"fhirServer": { | ||
"resources": { | ||
"open": true, | ||
"Device": { | ||
"searchParameters": { | ||
"patient": "http://hl7.org/fhir/SearchParameter/Device-patient", | ||
"organization": "http://hl7.org/fhir/SearchParameter/Device-organization" | ||
} | ||
}, | ||
"Observation": { | ||
"searchParameters": { | ||
"code": "http://hl7.org/fhir/SearchParameter/clinical-code", | ||
"value-range": "http://hl7.org/fhir/SearchParameter/Observation-value-range" | ||
} | ||
}, | ||
"Patient": { | ||
"searchParameters": { | ||
"active": "http://hl7.org/fhir/SearchParameter/Patient-active", | ||
"address": "http://hl7.org/fhir/SearchParameter/individual-address", | ||
"birthdate": "http://hl7.org/fhir/SearchParameter/individual-birthdate", | ||
"name": "http://hl7.org/fhir/SearchParameter/Patient-name" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
{ | ||
"__comment": "FHIR Server configuration", | ||
"fhirServer": { | ||
"resources": { | ||
"open": true, | ||
"Device": { | ||
"searchParameters": { | ||
"patient": "http://hl7.org/fhir/SearchParameter/Device-patient", | ||
"organization": "http://hl7.org/fhir/SearchParameter/Device-organization" | ||
} | ||
}, | ||
"Observation": { | ||
"searchParameters": { | ||
"code": "http://hl7.org/fhir/SearchParameter/clinical-code", | ||
"value-range": "http://hl7.org/fhir/SearchParameter/Observation-value-range" | ||
} | ||
}, | ||
"Patient": { | ||
"searchParameters": { | ||
"active": "http://hl7.org/fhir/SearchParameter/Patient-active", | ||
"address": "http://hl7.org/fhir/SearchParameter/individual-address", | ||
"birthdate": "http://hl7.org/fhir/SearchParameter/individual-birthdate", | ||
"name": "http://hl7.org/fhir/SearchParameter/Patient-name" | ||
} | ||
} | ||
}, | ||
"core": { | ||
"defaultPageSize": 500 | ||
} | ||
} | ||
} |
19 changes: 11 additions & 8 deletions
19
fhir-search/src/test/resources/config/tenant2/fhir-server-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
{ | ||
"__comment": "FHIR Server configuration", | ||
"fhirServer": { | ||
"search": { | ||
"useStoredCompartmentParam": false | ||
} | ||
} | ||
} | ||
{ | ||
"__comment": "FHIR Server configuration", | ||
"fhirServer": { | ||
"search": { | ||
"useStoredCompartmentParam": false | ||
}, | ||
"core": { | ||
"defaultPageSize": 5000 | ||
} | ||
} | ||
} |