use of com.ibm.cohort.fhir.client.config.DefaultFhirClientBuilder in project quality-measure-and-cohort-service by Alvearie.
the class FhirClientTimeoutTest method testDefaultFhirClientBuilder_requestTimesOut.
@Test(expected = FhirClientConnectionException.class)
public void testDefaultFhirClientBuilder_requestTimesOut() {
FhirServerConfig fhirServerConfig = getFhirServerConfig();
fhirServerConfig.setSocketTimeout(CONFIG_TIMEOUT_MILLIS);
DefaultFhirClientBuilder builder = new DefaultFhirClientBuilder(fhirContext);
IGenericClient client = builder.createFhirClient(fhirServerConfig);
client.read().resource(Patient.class).withId(PATIENT_ID).execute();
}
use of com.ibm.cohort.fhir.client.config.DefaultFhirClientBuilder in project quality-measure-and-cohort-service by Alvearie.
the class DefaultVT method cleanUp.
@After
public void cleanUp() {
// get the fhir client object used to call to FHIR
FhirContext ctx = FhirContext.forR4();
DefaultFhirClientBuilder builder = new DefaultFhirClientBuilder(ctx);
IGenericClient terminologyClient = builder.createFhirClient(dataServerConfig);
terminologyClient.delete().resourceConditionalByType("ValueSet").where(ValueSet.URL.matches().value("http://cts.nlm.nih.gov/fhir/ValueSet/testValueSet")).execute();
}
use of com.ibm.cohort.fhir.client.config.DefaultFhirClientBuilder in project quality-measure-and-cohort-service by Alvearie.
the class FHIRRestUtilsTest method testParseEmptyAuthenticationHeaderInfo.
@PrepareForTest({ FHIRRestUtils.class, DefaultFhirClientBuilder.class })
@Test(expected = IllegalArgumentException.class)
public void testParseEmptyAuthenticationHeaderInfo() throws Exception {
DefaultFhirClientBuilder mockDefaultFhirClientBuilder = Mockito.mock(DefaultFhirClientBuilder.class);
PowerMockito.whenNew(DefaultFhirClientBuilder.class).withAnyArguments().thenReturn(mockDefaultFhirClientBuilder);
when(mockHttpHeaders.getRequestHeader(HttpHeaders.AUTHORIZATION)).thenReturn(emptyHttpHeadersList);
FHIRRestUtils.parseAuthenticationHeaderInfo(mockHttpHeaders);
}
use of com.ibm.cohort.fhir.client.config.DefaultFhirClientBuilder in project quality-measure-and-cohort-service by Alvearie.
the class FHIRRestUtilsTest method testParseAuthenticationHeaderInfo.
@PrepareForTest({ FHIRRestUtils.class, DefaultFhirClientBuilder.class })
@Test
public void testParseAuthenticationHeaderInfo() throws Exception {
DefaultFhirClientBuilder mockDefaultFhirClientBuilder = Mockito.mock(DefaultFhirClientBuilder.class);
PowerMockito.whenNew(DefaultFhirClientBuilder.class).withAnyArguments().thenReturn(mockDefaultFhirClientBuilder);
when(mockHttpHeaders.getRequestHeader(HttpHeaders.AUTHORIZATION)).thenReturn(httpHeadersList);
String[] authParts = FHIRRestUtils.parseAuthenticationHeaderInfo(mockHttpHeaders);
assertEquals("username", authParts[0]);
assertEquals("password", authParts[1]);
}
use of com.ibm.cohort.fhir.client.config.DefaultFhirClientBuilder in project quality-measure-and-cohort-service by Alvearie.
the class FHIRRestUtilsTest method testParseAuthenticationHeaderMissingPasswordInfo.
@PrepareForTest({ FHIRRestUtils.class, DefaultFhirClientBuilder.class })
@Test(expected = IllegalArgumentException.class)
public void testParseAuthenticationHeaderMissingPasswordInfo() throws Exception {
DefaultFhirClientBuilder mockDefaultFhirClientBuilder = Mockito.mock(DefaultFhirClientBuilder.class);
PowerMockito.whenNew(DefaultFhirClientBuilder.class).withAnyArguments().thenReturn(mockDefaultFhirClientBuilder);
when(mockHttpHeaders.getRequestHeader(HttpHeaders.AUTHORIZATION)).thenReturn(justUserNameHttpHeadersList);
FHIRRestUtils.parseAuthenticationHeaderInfo(mockHttpHeaders);
}
Aggregations