use of com.cribbstechnologies.clients.mandrill.model.response.templates.TemplateResponse in project Java-Mandrill-Wrapper by cribbstechnologies.
the class MandrillRESTRequestTest method testTemplateResponseConversion.
@Test
public void testTemplateResponseConversion() throws IOException {
this.initRequestWithActualMapper();
StringWriter sw = new StringWriter();
IOUtils.copy(this.getClass().getClassLoader().getResourceAsStream("templates/templateResponse.txt"), sw);
TemplateResponse response = (TemplateResponse) this.request.convertResponseData(sw.toString(), TemplateResponse.class);
assertEquals("example name", response.getName());
assertEquals("example code", response.getCode());
assertEquals("example created_at", response.getCreated_at());
assertEquals("example updated_at", response.getUpdated_at());
}
use of com.cribbstechnologies.clients.mandrill.model.response.templates.TemplateResponse in project Java-Mandrill-Wrapper by cribbstechnologies.
the class MandrillTemplatesRequest method getTemplates.
public TemplateListResponse getTemplates(BaseMandrillRequest listRequest) throws RequestFailedException {
TemplateListResponse response = new TemplateListResponse();
response.setList(((BaseMandrillAnonymousListResponse<TemplateResponse>) request.postRequest(listRequest, ServiceMethods.Templates.LIST, TemplateResponse.class, templatesListReference)).getList());
return response;
}
use of com.cribbstechnologies.clients.mandrill.model.response.templates.TemplateResponse 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());
}
use of com.cribbstechnologies.clients.mandrill.model.response.templates.TemplateResponse in project Java-Mandrill-Wrapper by cribbstechnologies.
the class TemplatesTest method testUpdateTemplate.
@Test
public void testUpdateTemplate() {
MandrillRequestWithCode request = new MandrillRequestWithCode();
request.setName("template1");
String newVal = "<html><body>Not template</body></html>";
request.setCode(newVal);
MandrillRequestWithName retrieve = new MandrillRequestWithName();
retrieve.setName("template1");
try {
TemplateResponse response = templatesRequest.getTemplateInfo(retrieve);
String oldVal = response.getCode();
templatesRequest.updateTemplate(request);
response = templatesRequest.getTemplateInfo(retrieve);
assertFalse(oldVal.equals(newVal));
assertEquals(newVal, response.getCode());
} catch (RequestFailedException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations