-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #1708 use ibm-internal stored parameters for compartment searches
Signed-off-by: Robin Arnold <robin.arnold23@ibm.com>
- Loading branch information
1 parent
398bbdc
commit 2d89c8a
Showing
11 changed files
with
669 additions
and
20 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
48 changes: 48 additions & 0 deletions
48
fhir-examples/src/main/resources/json/ibm/basic/BasicCompartment.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,48 @@ | ||
{ | ||
"resourceType": "Basic", | ||
"code": { | ||
"text": "test" | ||
}, | ||
"author": { | ||
"reference": "Patient/123" | ||
}, | ||
"extension": [ | ||
{ | ||
"url": "http://example.org/uri", | ||
"valueUri": "urn:uuid:53fefa32-1111-2222-3333-55ee120877b7" | ||
}, | ||
{ | ||
"url": "http://example.org/Reference", | ||
"valueReference": { | ||
"reference": "Basic/123" | ||
} | ||
}, | ||
{ | ||
"url": "http://example.org/Reference-id", | ||
"valueReference": { | ||
"identifier": { | ||
"system": "http://example.org/identifier", | ||
"value": "123" | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "http://example.org/Reference-relative", | ||
"valueReference": { | ||
"reference": "Patient/123" | ||
} | ||
}, | ||
{ | ||
"url": "http://example.org/Reference-absolute", | ||
"valueReference": { | ||
"reference": "https://example.com/Patient/123" | ||
} | ||
}, | ||
{ | ||
"url": "http://example.org/Reference-display", | ||
"valueReference": { | ||
"display": "text alternative for the resource" | ||
} | ||
} | ||
] | ||
} |
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
68 changes: 68 additions & 0 deletions
68
...bc/src/test/java/com/ibm/fhir/persistence/jdbc/search/test/JDBCSearchCompartmentTest.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,68 @@ | ||
/* | ||
* (C) Copyright IBM Corp. 2020 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.ibm.fhir.persistence.jdbc.search.test; | ||
|
||
import java.util.Properties; | ||
|
||
import com.ibm.fhir.database.utils.api.IConnectionProvider; | ||
import com.ibm.fhir.database.utils.pool.PoolConnectionProvider; | ||
import com.ibm.fhir.model.test.TestUtil; | ||
import com.ibm.fhir.persistence.FHIRPersistence; | ||
import com.ibm.fhir.persistence.jdbc.FHIRPersistenceJDBCCache; | ||
import com.ibm.fhir.persistence.jdbc.cache.CommonTokenValuesCacheImpl; | ||
import com.ibm.fhir.persistence.jdbc.cache.FHIRPersistenceJDBCCacheImpl; | ||
import com.ibm.fhir.persistence.jdbc.cache.NameIdCache; | ||
import com.ibm.fhir.persistence.jdbc.dao.api.ICommonTokenValuesCache; | ||
import com.ibm.fhir.persistence.jdbc.impl.FHIRPersistenceJDBCImpl; | ||
import com.ibm.fhir.persistence.jdbc.test.util.DerbyInitializer; | ||
import com.ibm.fhir.persistence.search.test.AbstractSearchCompartmentTest; | ||
|
||
/** | ||
* JDBC unit-tests for compartment-based searches | ||
*/ | ||
public class JDBCSearchCompartmentTest extends AbstractSearchCompartmentTest { | ||
|
||
private Properties testProps; | ||
|
||
private PoolConnectionProvider connectionPool; | ||
|
||
private FHIRPersistenceJDBCCache cache; | ||
|
||
public JDBCSearchCompartmentTest() throws Exception { | ||
this.testProps = TestUtil.readTestProperties("test.jdbc.properties"); | ||
} | ||
|
||
@Override | ||
public void bootstrapDatabase() throws Exception { | ||
DerbyInitializer derbyInit; | ||
String dbDriverName = this.testProps.getProperty("dbDriverName"); | ||
if (dbDriverName != null && dbDriverName.contains("derby")) { | ||
derbyInit = new DerbyInitializer(this.testProps); | ||
IConnectionProvider cp = derbyInit.getConnectionProvider(false); | ||
this.connectionPool = new PoolConnectionProvider(cp, 1); | ||
ICommonTokenValuesCache rrc = new CommonTokenValuesCacheImpl(100, 100); | ||
cache = new FHIRPersistenceJDBCCacheImpl(new NameIdCache<Integer>(), new NameIdCache<Integer>(), rrc); | ||
} | ||
} | ||
|
||
@Override | ||
public FHIRPersistence getPersistenceImpl() throws Exception { | ||
if (this.connectionPool == null) { | ||
throw new IllegalStateException("Database not bootstrapped"); | ||
} | ||
return new FHIRPersistenceJDBCImpl(this.testProps, this.connectionPool, cache); | ||
} | ||
|
||
@Override | ||
protected void shutdownPools() throws Exception { | ||
// Mark the pool as no longer in use. This allows the pool to check for | ||
// lingering open connections/transactions. | ||
if (this.connectionPool != null) { | ||
this.connectionPool.close(); | ||
} | ||
} | ||
} |
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
61 changes: 61 additions & 0 deletions
61
...nce/src/test/java/com/ibm/fhir/persistence/search/test/AbstractSearchCompartmentTest.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,61 @@ | ||
/* | ||
* (C) Copyright IBM Corp. 2020 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.ibm.fhir.persistence.search.test; | ||
|
||
import static org.testng.AssertJUnit.assertEquals; | ||
|
||
import java.util.List; | ||
|
||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
import com.ibm.fhir.config.FHIRRequestContext; | ||
import com.ibm.fhir.exception.FHIRException; | ||
import com.ibm.fhir.model.resource.Basic; | ||
import com.ibm.fhir.model.resource.Resource; | ||
import com.ibm.fhir.model.test.TestUtil; | ||
|
||
/** | ||
* Unit tests for compartment-based searches | ||
* @see https://hl7.org/fhir/r4/search.html | ||
* GET [base]/Patient/[id]/[type]?parameter(s) | ||
*/ | ||
public abstract class AbstractSearchCompartmentTest extends AbstractPLSearchTest { | ||
|
||
@Override | ||
protected Basic getBasicResource() throws Exception { | ||
return TestUtil.readExampleResource("json/ibm/basic/BasicCompartment.json"); | ||
} | ||
|
||
@Override | ||
protected void setTenant() throws Exception { | ||
FHIRRequestContext.get().setTenantId("compartment"); | ||
|
||
// Need to set reference before storing the resource. The server-url | ||
// is now used to determine if an absolute reference is local (can be served | ||
// from this FHIR server). | ||
createReference(); | ||
} | ||
|
||
@BeforeClass | ||
public void createReference() throws FHIRException { | ||
String originalRequestUri = "https://example.com/Patient/123"; | ||
FHIRRequestContext context = FHIRRequestContext.get(); | ||
context.setOriginalRequestUri(originalRequestUri); | ||
} | ||
|
||
@Test | ||
public void testSearchCompartment() throws Exception { | ||
// The saved Basic resource is a member of the compartment Patient/123 | ||
// Check that we can find the resource with additional query parameters | ||
// Note that "Reference-relative just happens to be another searchable | ||
// parameter in the BasicCompartment.json resource | ||
List<Resource> results = runQueryTest("Patient", "123", | ||
Basic.class, "Reference-relative", "Patient/123"); | ||
assertEquals(1, results.size()); | ||
} | ||
} |
Oops, something went wrong.