use of eu.europeana.metis.network.AbstractHttpClient.ContentRetriever in project metis-framework by europeana.
the class StringHttpClientTest method createResult.
@Test
void createResult() throws URISyntaxException, IOException {
List<Closeable> closeables = new ArrayList<>();
HttpEntity responseEntity = new BasicHttpEntity(new ByteArrayInputStream("content".getBytes()), ContentType.TEXT_PLAIN);
final ContentRetriever contentRetriever = ContentRetriever.forNonCloseableContent(responseEntity == null ? InputStream::nullInputStream : responseEntity::getContent, closeables::add);
StringContent actualContent = stringHttpClient.createResult(new URI("/resource/provided"), new URI("/resource/actual"), "text/plain", 7L, contentRetriever);
assertEquals("content", actualContent.getContent());
assertEquals("text/plain", actualContent.getContentType());
}
use of eu.europeana.metis.network.AbstractHttpClient.ContentRetriever in project metis-framework by europeana.
the class StringHttpClientTest method createResultWithException.
@Disabled("TODO: MET-4250 Handle MockMaker in Jenkins")
@Test
void createResultWithException() throws IOException {
final ContentRetriever contentRetriever = mock(ContentRetriever.class);
when(contentRetriever.getContent()).thenThrow(IOException.class);
assertThrows(IOException.class, () -> {
stringHttpClient.createResult(new URI("/resource/provided"), new URI("/resource/actual"), "text/plain", 7L, contentRetriever);
});
}
Aggregations