Search in sources :

Example 1 with MandrillSender

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

Example 2 with MandrillSender

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

the class MandrillUsersRequest method getSenders.

/**
     * Return the senders that have tried to use this account, both verified and unverified
     * 
     * @param sendersRequest
     *            a populated @see com.cribbstechnologies.clients.mandrill.model.BaseMandrillRequest
     * @throws RequestFailedException
     */
public UsersSendersResponse getSenders(BaseMandrillRequest sendersRequest) throws RequestFailedException {
    UsersSendersResponse response = new UsersSendersResponse();
    response.setList(((BaseMandrillAnonymousListResponse<MandrillSender>) request.postRequest(sendersRequest, ServiceMethods.Users.SENDERS, UsersSendersResponse.class, usersListReference)).getList());
    return response;
}
Also used : UsersSendersResponse(com.cribbstechnologies.clients.mandrill.model.response.users.UsersSendersResponse) MandrillSender(com.cribbstechnologies.clients.mandrill.model.response.users.MandrillSender)

Aggregations

MandrillSender (com.cribbstechnologies.clients.mandrill.model.response.users.MandrillSender)2 UsersSendersResponse (com.cribbstechnologies.clients.mandrill.model.response.users.UsersSendersResponse)2 BaseMandrillAnonymousListResponse (com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse)1 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 StringWriter (java.io.StringWriter)1 Test (org.junit.Test)1