Add tests
This commit is contained in:
parent
493ec707ca
commit
c5f48b6b47
|
@ -37,64 +37,7 @@ public class SearchParamExtractorR4Test {
|
||||||
@Before
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
|
|
||||||
mySearchParamRegistry = new ISearchParamRegistry() {
|
mySearchParamRegistry = new MySearchParamRegistry();
|
||||||
@Override
|
|
||||||
public void forceRefresh() {
|
|
||||||
// nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RuntimeSearchParam getActiveSearchParam(String theResourceName, String theParamName) {
|
|
||||||
return getActiveSearchParams(theResourceName).get(theParamName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean refreshCacheIfNecessary() {
|
|
||||||
// nothing
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Map<String, RuntimeSearchParam>> getActiveSearchParams() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, RuntimeSearchParam> getActiveSearchParams(String theResourceName) {
|
|
||||||
Map<String, RuntimeSearchParam> sps = new HashMap<>();
|
|
||||||
RuntimeResourceDefinition nextResDef = ourCtx.getResourceDefinition(theResourceName);
|
|
||||||
for (RuntimeSearchParam nextSp : nextResDef.getSearchParams()) {
|
|
||||||
sps.put(nextSp.getName(), nextSp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sps;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<JpaRuntimeSearchParam> getActiveUniqueSearchParams(String theResourceName, Set<String> theParamNames) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<JpaRuntimeSearchParam> getActiveUniqueSearchParams(String theResourceName) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void requestRefresh() {
|
|
||||||
// nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RuntimeSearchParam getSearchParamByName(RuntimeResourceDefinition theResourceDef, String theParamName) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<RuntimeSearchParam> getSearchParamsByResourceType(RuntimeResourceDefinition theResourceDef) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +55,20 @@ public class SearchParamExtractorR4Test {
|
||||||
assertEquals("CODE", token.getValue());
|
assertEquals("CODE", token.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTokenOnSearchParamContext() {
|
||||||
|
SearchParameter sp = new SearchParameter();
|
||||||
|
sp.addUseContext().setCode(new Coding().setSystem("http://system").setCode("code"));
|
||||||
|
|
||||||
|
SearchParamExtractorR4 extractor = new SearchParamExtractorR4(new ModelConfig(), ourCtx, ourValidationSupport, mySearchParamRegistry);
|
||||||
|
Set<BaseResourceIndexedSearchParam> tokens = extractor.extractSearchParamTokens(sp);
|
||||||
|
assertEquals(1, tokens.size());
|
||||||
|
ResourceIndexedSearchParamToken token = (ResourceIndexedSearchParamToken) tokens.iterator().next();
|
||||||
|
assertEquals("context-type", token.getParamName());
|
||||||
|
assertEquals("http://system", token.getSystem());
|
||||||
|
assertEquals("code", token.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReferenceWithResolve() {
|
public void testReferenceWithResolve() {
|
||||||
Encounter enc = new Encounter();
|
Encounter enc = new Encounter();
|
||||||
|
@ -171,6 +128,65 @@ public class SearchParamExtractorR4Test {
|
||||||
assertEquals(4, links.size());
|
assertEquals(4, links.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class MySearchParamRegistry implements ISearchParamRegistry {
|
||||||
|
@Override
|
||||||
|
public void forceRefresh() {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RuntimeSearchParam getActiveSearchParam(String theResourceName, String theParamName) {
|
||||||
|
return getActiveSearchParams(theResourceName).get(theParamName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean refreshCacheIfNecessary() {
|
||||||
|
// nothing
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Map<String, RuntimeSearchParam>> getActiveSearchParams() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, RuntimeSearchParam> getActiveSearchParams(String theResourceName) {
|
||||||
|
Map<String, RuntimeSearchParam> sps = new HashMap<>();
|
||||||
|
RuntimeResourceDefinition nextResDef = ourCtx.getResourceDefinition(theResourceName);
|
||||||
|
for (RuntimeSearchParam nextSp : nextResDef.getSearchParams()) {
|
||||||
|
sps.put(nextSp.getName(), nextSp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sps;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<JpaRuntimeSearchParam> getActiveUniqueSearchParams(String theResourceName, Set<String> theParamNames) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<JpaRuntimeSearchParam> getActiveUniqueSearchParams(String theResourceName) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void requestRefresh() {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RuntimeSearchParam getSearchParamByName(RuntimeResourceDefinition theResourceDef, String theParamName) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<RuntimeSearchParam> getSearchParamsByResourceType(RuntimeResourceDefinition theResourceDef) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterClassClearContext() {
|
public static void afterClassClearContext() {
|
||||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||||
|
|
Loading…
Reference in New Issue