Search in sources :

Example 1 with TimeUrlResponse

use of com.cribbstechnologies.clients.mandrill.model.response.urls.TimeUrlResponse in project Java-Mandrill-Wrapper by cribbstechnologies.

the class MandrillRESTRequestTest method testUrlTimeResponseConversion.

@Test
public void testUrlTimeResponseConversion() throws IOException {
    this.initRequestWithActualMapper();
    StringWriter sw = new StringWriter();
    IOUtils.copy(this.getClass().getClassLoader().getResourceAsStream("urls/urlTimeResponse.txt"), sw);
    TypeReference urlTimeReference = new TypeReference<List<TimeUrlResponse>>() {
    };
    BaseMandrillAnonymousListResponse<TimeUrlResponse> response = (BaseMandrillAnonymousListResponse<TimeUrlResponse>) this.request.convertAnonymousListResponseData(sw.toString(), UrlTimeResponse.class, urlTimeReference);
    assertEquals(2, response.getList().size());
    TimeUrlResponse timeUrlResponse = response.getList().get(0);
    assertEquals("example time1", timeUrlResponse.getTime());
    assertEquals(2, timeUrlResponse.getSent());
    assertEquals(3, timeUrlResponse.getClicks());
    assertEquals(4, timeUrlResponse.getUnique_clicks());
    timeUrlResponse = response.getList().get(1);
    assertEquals("example time11", timeUrlResponse.getTime());
    assertEquals(12, timeUrlResponse.getSent());
    assertEquals(13, timeUrlResponse.getClicks());
    assertEquals(14, timeUrlResponse.getUnique_clicks());
}
Also used : BaseMandrillAnonymousListResponse(com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse) StringWriter(java.io.StringWriter) TimeUrlResponse(com.cribbstechnologies.clients.mandrill.model.response.urls.TimeUrlResponse) TypeReference(com.fasterxml.jackson.core.type.TypeReference) UrlTimeResponse(com.cribbstechnologies.clients.mandrill.model.response.urls.UrlTimeResponse) Test(org.junit.Test)

Aggregations

BaseMandrillAnonymousListResponse (com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse)1 TimeUrlResponse (com.cribbstechnologies.clients.mandrill.model.response.urls.TimeUrlResponse)1 UrlTimeResponse (com.cribbstechnologies.clients.mandrill.model.response.urls.UrlTimeResponse)1 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 StringWriter (java.io.StringWriter)1 Test (org.junit.Test)1