use of com.ibm.cohort.fhir.client.config.DefaultFhirClientBuilder in project quality-measure-and-cohort-service by Alvearie.
the class FHIRRestUtilsTest method testParseNoUserPassAuthenticationHeaderStrInfo.
@PrepareForTest({ FHIRRestUtils.class, DefaultFhirClientBuilder.class })
@Test(expected = IllegalArgumentException.class)
public void testParseNoUserPassAuthenticationHeaderStrInfo() throws Exception {
DefaultFhirClientBuilder mockDefaultFhirClientBuilder = Mockito.mock(DefaultFhirClientBuilder.class);
PowerMockito.whenNew(DefaultFhirClientBuilder.class).withAnyArguments().thenReturn(mockDefaultFhirClientBuilder);
when(mockHttpHeaders.getRequestHeader(HttpHeaders.AUTHORIZATION)).thenReturn(noUserPassHttpHeadersList);
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 testParseNUllAuthenticationHeaderInfo.
@PrepareForTest({ FHIRRestUtils.class, DefaultFhirClientBuilder.class })
@Test(expected = IllegalArgumentException.class)
public void testParseNUllAuthenticationHeaderInfo() throws Exception {
DefaultFhirClientBuilder mockDefaultFhirClientBuilder = Mockito.mock(DefaultFhirClientBuilder.class);
PowerMockito.whenNew(DefaultFhirClientBuilder.class).withAnyArguments().thenReturn(mockDefaultFhirClientBuilder);
when(mockHttpHeaders.getRequestHeader(HttpHeaders.AUTHORIZATION)).thenReturn(nullHttpHeadersList);
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 testParseEmptyAuthenticationHeaderStrInfo.
@PrepareForTest({ FHIRRestUtils.class, DefaultFhirClientBuilder.class })
@Test(expected = IllegalArgumentException.class)
public void testParseEmptyAuthenticationHeaderStrInfo() throws Exception {
DefaultFhirClientBuilder mockDefaultFhirClientBuilder = Mockito.mock(DefaultFhirClientBuilder.class);
PowerMockito.whenNew(DefaultFhirClientBuilder.class).withAnyArguments().thenReturn(mockDefaultFhirClientBuilder);
when(mockHttpHeaders.getRequestHeader(HttpHeaders.AUTHORIZATION)).thenReturn(emptyStrHttpHeadersList);
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 testParseAuthenticationHeaderBadPasswordInfo.
@PrepareForTest({ FHIRRestUtils.class, DefaultFhirClientBuilder.class })
@Test(expected = IllegalArgumentException.class)
public void testParseAuthenticationHeaderBadPasswordInfo() throws Exception {
DefaultFhirClientBuilder mockDefaultFhirClientBuilder = Mockito.mock(DefaultFhirClientBuilder.class);
PowerMockito.whenNew(DefaultFhirClientBuilder.class).withAnyArguments().thenReturn(mockDefaultFhirClientBuilder);
when(mockHttpHeaders.getRequestHeader(HttpHeaders.AUTHORIZATION)).thenReturn(badHttpHeadersList);
FHIRRestUtils.parseAuthenticationHeaderInfo(mockHttpHeaders);
}
use of com.ibm.cohort.fhir.client.config.DefaultFhirClientBuilder in project quality-measure-and-cohort-service by Alvearie.
the class FHIRRestUtils method getFHIRClient.
/**
* @param fhirEndpoint The REST endpoint for the FHIR server
* @param bearerToken OAuth token value
* @param fhirTenantIdHeader the header used by FHIR to identify the tenant
* @param fhirTenantId the actual FHIR tenant id
* @param fhirDataSourceIdHeader The header used by FHIR to identify the datasource
* @param fhirDataSourceId the actual FHIR datasource name
* @return IGenericClient A client that can be used to make calls to the FHIR server
*
* Convenience method to get a FHIR client
*/
public static IGenericClient getFHIRClient(String fhirEndpoint, String bearerToken, String fhirTenantIdHeader, String fhirTenantId, String fhirDataSourceIdHeader, String fhirDataSourceId) {
IBMFhirServerConfig config = getPartialFHIRConfig(fhirEndpoint, fhirTenantIdHeader, fhirTenantId, fhirDataSourceIdHeader, fhirDataSourceId);
config.setToken(bearerToken);
FhirContext ctx = FhirContext.forR4();
DefaultFhirClientBuilder builder = new DefaultFhirClientBuilder(ctx);
return builder.createFhirClient(config);
}
Aggregations