start with failing test
This commit is contained in:
parent
dded46d220
commit
15098109c8
|
@ -107,6 +107,16 @@
|
||||||
<artifactId>logback-classic</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -190,6 +190,7 @@ public class InMemoryResourceMatcher {
|
||||||
return theAndOrParams.stream().flatMap(List::stream).anyMatch(param -> param.getQueryParameterQualifier() != null);
|
return theAndOrParams.stream().flatMap(List::stream).anyMatch(param -> param.getQueryParameterQualifier() != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME KHS change to hasUnsupportedPrefixes
|
||||||
private boolean hasPrefixes(List<List<IQueryParameterType>> theAndOrParams) {
|
private boolean hasPrefixes(List<List<IQueryParameterType>> theAndOrParams) {
|
||||||
Predicate<IQueryParameterType> hasPrefixPredicate = param -> param instanceof BaseParamWithPrefix &&
|
Predicate<IQueryParameterType> hasPrefixPredicate = param -> param instanceof BaseParamWithPrefix &&
|
||||||
((BaseParamWithPrefix) param).getPrefix() != null;
|
((BaseParamWithPrefix) param).getPrefix() != null;
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package ca.uhn.fhir.jpa.searchparam.matcher;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||||
|
import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
|
||||||
|
import ca.uhn.fhir.jpa.searchparam.extractor.ResourceIndexedSearchParams;
|
||||||
|
import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamRegistry;
|
||||||
|
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
|
||||||
|
import org.hl7.fhir.r5.model.DateTimeType;
|
||||||
|
import org.hl7.fhir.r5.model.Observation;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
public class InMemoryResourceMatcherTest {
|
||||||
|
@Autowired
|
||||||
|
InMemoryResourceMatcher myInMemoryResourceMatcher;
|
||||||
|
|
||||||
|
@MockBean
|
||||||
|
ISearchParamRegistry mySearchParamRegistry;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public static class SpringConfig {
|
||||||
|
@Bean
|
||||||
|
InMemoryResourceMatcher inMemoryResourceMatcher() {
|
||||||
|
return new InMemoryResourceMatcher();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
MatchUrlService matchUrlService() {
|
||||||
|
return new MatchUrlService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
FhirContext fhirContext() {
|
||||||
|
return FhirContext.forR5();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before() {
|
||||||
|
RuntimeSearchParam searchParams = new RuntimeSearchParam(null, null, null, null, "Observation.effective", RestSearchParameterTypeEnum.DATE, null, null, null, RuntimeSearchParam.RuntimeSearchParamStatusEnum.ACTIVE);
|
||||||
|
when(mySearchParamRegistry.getSearchParamByName(any(), any())).thenReturn(searchParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDateGe() {
|
||||||
|
Observation observation = new Observation();
|
||||||
|
observation.setEffective(new DateTimeType("1970-01-01"));
|
||||||
|
ResourceIndexedSearchParams searchParams = new ResourceIndexedSearchParams();
|
||||||
|
InMemoryMatchResult result = myInMemoryResourceMatcher.match("date=ge1965-08-09", observation, searchParams);
|
||||||
|
assertTrue(result.getUnsupportedReason(), result.supported());
|
||||||
|
assertTrue(result.matched());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue