use of org.nzbhydra.downloading.AddFilesRequest in project nzbhydra2 by theotherp.
the class NzbDownloadingTests method shouldSendUrlToDownloader.
@Test
public void shouldSendUrlToDownloader() throws Exception {
baseConfig.getDownloading().getDownloaders().get(0).setNzbAddingType(NzbAddingType.SEND_LINK);
// http://127.0.0.1:7070/sabnzbd/api?apikey=apikey&output=json&mode=addurl&name=http://127.0.0.1:5076/getnzb/api/5293954792479313301?apikey&nzbname=someNzb.nzb
// http://192.168.1.111:5077/getnzb/api/-338204003302262369?apikey
HttpRequest expectedRequest = HttpRequest.request("/sabnzbd/api").withQueryStringParameter("mode", "addurl").withQueryStringParameter("name", "http://localhost/getnzb/api/" + searchResultId + "?apikey=apikey").withMethod("POST");
mockServer.when(expectedRequest).respond(HttpResponse.response().withStatusCode(200).withBody("{\"isStatus\":true}"));
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.put("/internalapi/downloader/addNzbs");
SearchResultWebTO item = SearchResultWebTO.builder().searchResultId(String.valueOf(searchResultId)).build();
AddFilesRequest addNzbsRequest = new AddFilesRequest("sabnzbd", Collections.singletonList(new AddFilesRequest.SearchResult(item.getSearchResultId(), item.getOriginalCategory())), "");
request.contentType(MediaType.APPLICATION_JSON_VALUE);
request.content(new ObjectMapper().writeValueAsString(addNzbsRequest));
request.with(csrf());
ResultActions perform = mvc.perform(request);
perform.andExpect(status().is(200));
mockServer.verify(expectedRequest);
}
Aggregations