use of org.nzbhydra.mapping.newznab.json.NewznabJsonRoot in project nzbhydra2 by theotherp.
the class JsonMappingTest method shouldSerializeToJson.
@Test
public void shouldSerializeToJson() throws Exception {
ObjectMapper objectMapper = new ObjectMapper();
String json = Resources.toString(Resources.getResource(JsonMappingTest.class, ("nzbsorg_3items.json").toLowerCase()), Charsets.UTF_8);
NewznabJsonRoot root = objectMapper.readValue(json, NewznabJsonRoot.class);
System.out.println(json);
}
use of org.nzbhydra.mapping.newznab.json.NewznabJsonRoot in project nzbhydra2 by theotherp.
the class ExternalApiTest method shouldUseCorrectHeaders.
@Test
public void shouldUseCorrectHeaders() throws Exception {
NewznabJsonRoot jsonRoot = new NewznabJsonRoot();
when(newznabJsonTransformerMock.transformToRoot(any(), any(), anyInt(), any())).thenReturn(jsonRoot);
NewznabParameters parameters = new NewznabParameters();
parameters.setQ("q1");
parameters.setApikey("apikey");
parameters.setT(ActionAttribute.SEARCH);
parameters.setO(OutputType.JSON);
ResponseEntity<?> responseEntity = testee.api(parameters);
assertThat(responseEntity.getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_JSON_UTF8);
NewznabXmlRoot xmlRoot = new NewznabXmlRoot();
when(newznabXmlTransformerMock.getRssRoot(any(), any(), anyInt(), any())).thenReturn(xmlRoot);
parameters.setO(OutputType.XML);
responseEntity = testee.api(parameters);
assertThat(responseEntity.getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_XML);
}
Aggregations