Search in sources :

Example 6 with BaseMandrillAnonymousListResponse

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

the class MandrillRESTRequestTest method testTemplateListResponseConversion.

@Test
public void testTemplateListResponseConversion() throws IOException {
    this.initRequestWithActualMapper();
    StringWriter sw = new StringWriter();
    IOUtils.copy(this.getClass().getClassLoader().getResourceAsStream("templates/templatesListResponse.txt"), sw);
    TypeReference templatesListReference = new TypeReference<List<TemplateResponse>>() {
    };
    BaseMandrillAnonymousListResponse<TemplateResponse> response = (BaseMandrillAnonymousListResponse<TemplateResponse>) this.request.convertAnonymousListResponseData(sw.toString(), TemplateResponse.class, templatesListReference);
    assertEquals(2, response.getList().size());
    TemplateResponse tr = response.getList().get(0);
    assertEquals("example name1", tr.getName());
    assertEquals("example code1", tr.getCode());
    assertEquals("example created_at1", tr.getCreated_at());
    assertEquals("example updated_at1", tr.getUpdated_at());
    tr = response.getList().get(1);
    assertEquals("example name11", tr.getName());
    assertEquals("example code11", tr.getCode());
    assertEquals("example created_at11", tr.getCreated_at());
    assertEquals("example updated_at11", tr.getUpdated_at());
}
Also used : BaseMandrillAnonymousListResponse(com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse) StringWriter(java.io.StringWriter) TemplateResponse(com.cribbstechnologies.clients.mandrill.model.response.templates.TemplateResponse) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Test(org.junit.Test)

Example 7 with BaseMandrillAnonymousListResponse

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

the class MandrillRESTRequestTest method testListTagsResponseConversion.

@Test
public void testListTagsResponseConversion() throws IOException {
    this.initRequestWithActualMapper();
    StringWriter sw = new StringWriter();
    IOUtils.copy(this.getClass().getClassLoader().getResourceAsStream("tags/listResponse.txt"), sw);
    TypeReference tagListReference = new TypeReference<List<BaseTag>>() {
    };
    BaseMandrillAnonymousListResponse<BaseTag> response = (BaseMandrillAnonymousListResponse<BaseTag>) this.request.convertAnonymousListResponseData(sw.toString(), TagListResponse.class, tagListReference);
    assertEquals(2, response.getList().size());
    BaseTag tag = response.getList().get(0);
    assertEquals("example tag1", tag.getTag());
    assertEquals(1, tag.getSent());
    assertEquals(2, tag.getHard_bounces());
    assertEquals(3, tag.getSoft_bounces());
    assertEquals(4, tag.getRejects());
    assertEquals(5, tag.getComplaints());
    assertEquals(6, tag.getUnsubs());
    assertEquals(7, tag.getOpens());
    assertEquals(8, tag.getClicks());
    tag = response.getList().get(1);
    assertEquals("example tag11", tag.getTag());
    assertEquals(11, tag.getSent());
    assertEquals(12, tag.getHard_bounces());
    assertEquals(13, tag.getSoft_bounces());
    assertEquals(14, tag.getRejects());
    assertEquals(15, tag.getComplaints());
    assertEquals(16, tag.getUnsubs());
    assertEquals(17, tag.getOpens());
    assertEquals(18, tag.getClicks());
}
Also used : BaseMandrillAnonymousListResponse(com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse) TagListResponse(com.cribbstechnologies.clients.mandrill.model.response.tags.TagListResponse) StringWriter(java.io.StringWriter) TypeReference(com.fasterxml.jackson.core.type.TypeReference) BaseTag(com.cribbstechnologies.clients.mandrill.model.response.tags.BaseTag) Test(org.junit.Test)

Aggregations

BaseMandrillAnonymousListResponse (com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse)7 TypeReference (com.fasterxml.jackson.core.type.TypeReference)7 StringWriter (java.io.StringWriter)7 Test (org.junit.Test)7 TimeUrlResponse (com.cribbstechnologies.clients.mandrill.model.response.urls.TimeUrlResponse)2 MessageResponse (com.cribbstechnologies.clients.mandrill.model.response.message.MessageResponse)1 SendMessageResponse (com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse)1 BaseTag (com.cribbstechnologies.clients.mandrill.model.response.tags.BaseTag)1 TagListResponse (com.cribbstechnologies.clients.mandrill.model.response.tags.TagListResponse)1 TagSeriesResponse (com.cribbstechnologies.clients.mandrill.model.response.tags.TagSeriesResponse)1 TagWithTime (com.cribbstechnologies.clients.mandrill.model.response.tags.TagWithTime)1 TemplateResponse (com.cribbstechnologies.clients.mandrill.model.response.templates.TemplateResponse)1 UrlListResponse (com.cribbstechnologies.clients.mandrill.model.response.urls.UrlListResponse)1 UrlResponse (com.cribbstechnologies.clients.mandrill.model.response.urls.UrlResponse)1 UrlTimeResponse (com.cribbstechnologies.clients.mandrill.model.response.urls.UrlTimeResponse)1 MandrillSender (com.cribbstechnologies.clients.mandrill.model.response.users.MandrillSender)1 UsersSendersResponse (com.cribbstechnologies.clients.mandrill.model.response.users.UsersSendersResponse)1