Search in sources :

Example 1 with BaseMandrillAnonymousListResponse

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

the class MandrillRESTRequestTest method testSendMessageResponseConversion.

@Test
public void testSendMessageResponseConversion() throws IOException {
    this.initRequestWithActualMapper();
    StringWriter sw = new StringWriter();
    IOUtils.copy(this.getClass().getClassLoader().getResourceAsStream("messages/sendMessageResponse.txt"), sw);
    TypeReference responseListReference = new TypeReference<List<MessageResponse>>() {
    };
    BaseMandrillAnonymousListResponse<MessageResponse> response = (BaseMandrillAnonymousListResponse<MessageResponse>) this.request.convertAnonymousListResponseData(sw.toString(), SendMessageResponse.class, responseListReference);
    assertEquals(2, response.getList().size());
    MessageResponse resp = response.getList().get(0);
    assertEquals("example email", resp.getEmail());
    assertEquals("example status", resp.getStatus());
    resp = response.getList().get(1);
    assertEquals("example email2", resp.getEmail());
    assertEquals("example status2", resp.getStatus());
}
Also used : BaseMandrillAnonymousListResponse(com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse) SendMessageResponse(com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse) StringWriter(java.io.StringWriter) MessageResponse(com.cribbstechnologies.clients.mandrill.model.response.message.MessageResponse) SendMessageResponse(com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Test(org.junit.Test)

Example 2 with BaseMandrillAnonymousListResponse

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

the class MandrillRESTRequestTest method testUrlListResponseConversion.

@Test
public void testUrlListResponseConversion() throws IOException {
    this.initRequestWithActualMapper();
    StringWriter sw = new StringWriter();
    IOUtils.copy(this.getClass().getClassLoader().getResourceAsStream("urls/urlList.txt"), sw);
    TypeReference urlListReference = new TypeReference<List<UrlResponse>>() {
    };
    BaseMandrillAnonymousListResponse<UrlResponse> response = (BaseMandrillAnonymousListResponse<UrlResponse>) this.request.convertAnonymousListResponseData(sw.toString(), UrlListResponse.class, urlListReference);
    assertEquals(2, response.getList().size());
    UrlResponse urlResponse = response.getList().get(0);
    assertEquals("example url1", urlResponse.getUrl());
    assertEquals(2, urlResponse.getSent());
    assertEquals(3, urlResponse.getClicks());
    assertEquals(4, urlResponse.getUnique_clicks());
    urlResponse = response.getList().get(1);
    assertEquals("example url11", urlResponse.getUrl());
    assertEquals(12, urlResponse.getSent());
    assertEquals(13, urlResponse.getClicks());
    assertEquals(14, urlResponse.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) UrlResponse(com.cribbstechnologies.clients.mandrill.model.response.urls.UrlResponse) TypeReference(com.fasterxml.jackson.core.type.TypeReference) UrlListResponse(com.cribbstechnologies.clients.mandrill.model.response.urls.UrlListResponse) Test(org.junit.Test)

Example 3 with BaseMandrillAnonymousListResponse

use of com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse 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)

Example 4 with BaseMandrillAnonymousListResponse

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

the class MandrillRESTRequestTest method testTimeTagsResponseConversion.

@Test
public void testTimeTagsResponseConversion() throws IOException {
    this.initRequestWithActualMapper();
    StringWriter sw = new StringWriter();
    IOUtils.copy(this.getClass().getClassLoader().getResourceAsStream("tags/timeSeriesResponse.txt"), sw);
    TypeReference tagListReference = new TypeReference<List<TagWithTime>>() {
    };
    BaseMandrillAnonymousListResponse<TagWithTime> response = (BaseMandrillAnonymousListResponse<TagWithTime>) this.request.convertAnonymousListResponseData(sw.toString(), TagSeriesResponse.class, tagListReference);
    assertEquals(2, response.getList().size());
    TagWithTime tag = response.getList().get(0);
    assertEquals("example time1", tag.getTime());
    assertEquals(2, tag.getSent());
    assertEquals(3, tag.getHard_bounces());
    assertEquals(4, tag.getSoft_bounces());
    assertEquals(5, tag.getRejects());
    assertEquals(6, tag.getComplaints());
    assertEquals(7, tag.getOpens());
    assertEquals(8, tag.getUnique_opens());
    assertEquals(9, tag.getClicks());
    assertEquals(10, tag.getUnique_clicks());
    tag = response.getList().get(1);
    assertEquals("example time11", tag.getTime());
    assertEquals(12, tag.getSent());
    assertEquals(13, tag.getHard_bounces());
    assertEquals(14, tag.getSoft_bounces());
    assertEquals(15, tag.getRejects());
    assertEquals(16, tag.getComplaints());
    assertEquals(17, tag.getOpens());
    assertEquals(18, tag.getUnique_opens());
    assertEquals(19, tag.getClicks());
    assertEquals(110, tag.getUnique_clicks());
}
Also used : TagWithTime(com.cribbstechnologies.clients.mandrill.model.response.tags.TagWithTime) BaseMandrillAnonymousListResponse(com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse) StringWriter(java.io.StringWriter) TagSeriesResponse(com.cribbstechnologies.clients.mandrill.model.response.tags.TagSeriesResponse) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Test(org.junit.Test)

Example 5 with BaseMandrillAnonymousListResponse

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

the class MandrillRESTRequestTest method testSendersResponseConversion.

@Test
public void testSendersResponseConversion() throws IOException {
    this.initRequestWithActualMapper();
    StringWriter sw = new StringWriter();
    IOUtils.copy(this.getClass().getClassLoader().getResourceAsStream("users/sendersResponse.txt"), sw);
    TypeReference usersListReference = new TypeReference<List<MandrillSender>>() {
    };
    BaseMandrillAnonymousListResponse<MandrillSender> response = (BaseMandrillAnonymousListResponse<MandrillSender>) this.request.convertAnonymousListResponseData(sw.toString(), UsersSendersResponse.class, usersListReference);
    assertEquals(2, response.getList().size());
    MandrillSender sender = response.getList().get(0);
    assertEquals("example address", sender.getAddress());
    assertEquals("example created_at", sender.getCreated_at());
    assertTrue(sender.getIs_enabled());
    sender = response.getList().get(1);
    assertEquals("example address2", sender.getAddress());
    assertEquals("example created_at2", sender.getCreated_at());
    assertFalse(sender.getIs_enabled());
}
Also used : BaseMandrillAnonymousListResponse(com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse) StringWriter(java.io.StringWriter) UsersSendersResponse(com.cribbstechnologies.clients.mandrill.model.response.users.UsersSendersResponse) MandrillSender(com.cribbstechnologies.clients.mandrill.model.response.users.MandrillSender) TypeReference(com.fasterxml.jackson.core.type.TypeReference) 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