- @Test
- void collectFile_AllOkWithJWTToken() throws Exception {
- dfcHttpClientSpy = spy(new DfcHttpClient(fileServerDataWithJWTToken()));
- String REMOTE_FILE = "any";
- Flux<InputStream> fis = Flux.just(new ByteArrayInputStream("ReturnedString".getBytes()));
-
- dfcHttpClientSpy.open();
- HttpClientConfig config = dfcHttpClientSpy.client.configuration();
- assertEquals(HttpUtils.jwtAuthContent(JWT_PASSWORD), config.headers().get("Authorization"));
-
- when(dfcHttpClientSpy.getServerResponse(any())).thenReturn(fis);
- doReturn(false).when(dfcHttpClientSpy).isDownloadFailed(any());
-
- dfcHttpClientSpy.collectFile(REMOTE_FILE, pathMock);
- dfcHttpClientSpy.close();
-
- verify(dfcHttpClientSpy, times(1)).getServerResponse(ArgumentMatchers.eq(REMOTE_FILE));
- verify(dfcHttpClientSpy, times(1)).processDataFromServer(any(), any(), any());
- verify(dfcHttpClientSpy, times(1)).isDownloadFailed(any());
- }
-