Skip to content

Commit e5689a0

Browse files
committed
Added Contact and Email converter tests
1 parent 61bf550 commit e5689a0

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/test/java/com/aspose/email/cloud/sdk/api/EmailApiTests.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,46 @@ public void ConvertCalendarTest() throws ApiException, UnsupportedEncodingExcept
455455
assert location.equals(dto.getLocation());
456456
}
457457

458+
@Test(groups = {"pipeline"})
459+
public void ConvertContactTest() throws ApiException, UnsupportedEncodingException {
460+
final String surname = "Cane";
461+
ContactDto contactDto = new ContactDto()
462+
.surname(surname)
463+
.givenName("John")
464+
.gender("Male")
465+
.emailAddresses(Collections.singletonList(new EmailAddress().address("address@aspose.com")))
466+
.phoneNumbers(Collections.singletonList(new PhoneNumber().number("+472343234542342")));
467+
byte[] mapiBytes = api.convertContactModelToFile(
468+
new ConvertContactModelToFileRequestData(
469+
"Msg", contactDto));
470+
byte[] vcardBytes = api.convertContact(new ConvertContactRequestData("VCard", "Msg", mapiBytes));
471+
String contactContent = new String(vcardBytes, "UTF-8");
472+
assert contactContent.contains(surname);
473+
ContactDto dto = api.getContactFileAsModel(
474+
new GetContactFileAsModelRequestData("VCard", vcardBytes));
475+
assert surname.equals(dto.getSurname());
476+
}
477+
478+
@Test(groups = {"pipeline"})
479+
public void ConvertEmailTest() throws ApiException, UnsupportedEncodingException {
480+
final String from = "from@aspose.com";
481+
EmailDto emailDto = new EmailDto()
482+
.from(new MailAddress().address(from))
483+
.to(Collections.singletonList(new MailAddress().address("to@aspose.com")))
484+
.subject("Some subject")
485+
.body("Some body")
486+
.date(new Date());
487+
byte[] mapiBytes = api.convertEmailModelToFile(
488+
new ConvertEmailModelToFileRequestData(
489+
"Msg", emailDto));
490+
byte[] emlBytes = api.convertEmail(new ConvertEmailRequestData("Eml", mapiBytes));
491+
String emlContent = new String(emlBytes, "UTF-8");
492+
assert emlContent.contains(from);
493+
EmailDto dto = api.getEmailFileAsModel(
494+
new GetEmailFileAsModelRequestData(emlBytes));
495+
assert from.equals(dto.getFrom().getAddress());
496+
}
497+
458498
private String createCalendar() throws ApiException {
459499
Calendar startDate = Calendar.getInstance();
460500
return createCalendar(startDate);

0 commit comments

Comments
 (0)