Search in sources :

Example 1 with NewznabJsonRoot

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);
}
Also used : NewznabJsonRoot(org.nzbhydra.mapping.newznab.json.NewznabJsonRoot) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 2 with NewznabJsonRoot

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);
}
Also used : NewznabJsonRoot(org.nzbhydra.mapping.newznab.json.NewznabJsonRoot) NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) NewznabParameters(org.nzbhydra.mapping.newznab.NewznabParameters) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 NewznabJsonRoot (org.nzbhydra.mapping.newznab.json.NewznabJsonRoot)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 NewznabParameters (org.nzbhydra.mapping.newznab.NewznabParameters)1 NewznabXmlRoot (org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot)1