use of com.axway.ats.rbv.imap.ImapMetaData in project ats-framework by Axway.
the class MimePartRule method performMatch.
@Override
protected boolean performMatch(MetaData metaData) throws RbvException {
boolean actualResult = false;
//get the emailMessage
//the meta data type check already passed, so it is safe to cast
MimePackage emailMessage = ((ImapMetaData) metaData).getMimePackage();
try {
InputStream actualPartDataStream = null;
try {
actualPartDataStream = emailMessage.getPartData(partIndex, isPartAttachment);
} catch (NoSuchMimePartException e) {
//if there is no such mime part then the parts do not match
log.debug("No MIME part at position '" + partIndex + "'");
return false;
}
if (actualPartDataStream != null) {
long actualChecksum = emailMessage.getPartChecksum(partIndex, isPartAttachment);
actualResult = (expectedChecksum == actualChecksum);
} else {
log.debug("MIME part at position '" + partIndex + "' does not have any content");
return false;
}
} catch (PackageException pe) {
throw new RbvException(pe);
}
return actualResult;
}
use of com.axway.ats.rbv.imap.ImapMetaData in project ats-framework by Axway.
the class Test_StringInMimePartRule method isMatchRegexRegularPartUTF8Positive.
@Test
public void isMatchRegexRegularPartUTF8Positive() throws RbvException, PackageException {
MimePackage utf8Package = new MimePackage();
utf8Package.addPart("Изчерпателна информация", MimePackage.PART_TYPE_TEXT_PLAIN, "utf-8");
ImapMetaData utf8MetaData = new ImapMetaData(utf8Package);
//expected true
StringInMimePartRule rule = new StringInMimePartRule(".*информация$", true, 0, false, "isMatchRegexRegularPartPositive1", true);
assertTrue(rule.isMatch(utf8MetaData));
//expected false
rule = new StringInMimePartRule("Изчерпателна.*яа", true, 0, false, "isMatchRegexRegularPartPositive2", false);
assertTrue(rule.isMatch(utf8MetaData));
}
use of com.axway.ats.rbv.imap.ImapMetaData in project ats-framework by Axway.
the class Test_MimePartRule method isMatchRegularPartNoSuchPart.
@Test
public void isMatchRegularPartNoSuchPart() throws PackageException, RbvException {
mailMessage = new MimePackage(Test_MimePartRule.class.getResourceAsStream("mail_with_one_attachment.msg"));
metaData = new ImapMetaData(mailMessage);
//expected true
MimePartRule rule = new MimePartRule(expectedMailMessage, 2, false, "isMatchRegularPartNoSuchPart1", true);
assertFalse(rule.isMatch(metaData));
//expected false
rule = new MimePartRule(expectedMailMessage, 2, false, "isMatchRegularPartNoSuchPart2", false);
assertTrue(rule.isMatch(metaData));
}
use of com.axway.ats.rbv.imap.ImapMetaData in project ats-framework by Axway.
the class Test_StringInMimePartRule method setUp.
@Before
public void setUp() throws PackageException, RbvException {
mailMessage = new MimePackage(Test_StringInMimePartRule.class.getResourceAsStream("mail_with_text_plain_attachment.msg"));
metaData = new ImapMetaData(mailMessage);
}
use of com.axway.ats.rbv.imap.ImapMetaData in project ats-framework by Axway.
the class Test_OrRuleOperation method setUpTest_AndRuleOperation.
@BeforeClass
public static void setUpTest_AndRuleOperation() throws PackageException, RbvException {
MimePackage testMessage = new MimePackage(Test_ImapStorage.class.getResourceAsStream("mail.msg"));
//init the meta data with the test message
metaData = new ImapMetaData(testMessage);
}
Aggregations