Search in sources :

Example 1 with ImapMetaData

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;
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) ImapMetaData(com.axway.ats.rbv.imap.ImapMetaData) InputStream(java.io.InputStream) RbvException(com.axway.ats.rbv.model.RbvException) NoSuchMimePartException(com.axway.ats.action.objects.model.NoSuchMimePartException) PackageException(com.axway.ats.action.objects.model.PackageException)

Example 2 with ImapMetaData

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));
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) ImapMetaData(com.axway.ats.rbv.imap.ImapMetaData) StringInMimePartRule(com.axway.ats.rbv.imap.rules.StringInMimePartRule) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 3 with ImapMetaData

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));
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) ImapMetaData(com.axway.ats.rbv.imap.ImapMetaData) MimePartRule(com.axway.ats.rbv.imap.rules.MimePartRule) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 4 with ImapMetaData

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);
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) ImapMetaData(com.axway.ats.rbv.imap.ImapMetaData) Before(org.junit.Before)

Example 5 with ImapMetaData

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);
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) ImapMetaData(com.axway.ats.rbv.imap.ImapMetaData) Test_ImapStorage(com.axway.ats.rbv.imap.Test_ImapStorage) BeforeClass(org.junit.BeforeClass)

Aggregations

ImapMetaData (com.axway.ats.rbv.imap.ImapMetaData)20 MimePackage (com.axway.ats.action.objects.MimePackage)15 BaseTest (com.axway.ats.rbv.BaseTest)11 Test (org.junit.Test)11 Before (org.junit.Before)6 StringInMimePartRule (com.axway.ats.rbv.imap.rules.StringInMimePartRule)5 Test_ImapStorage (com.axway.ats.rbv.imap.Test_ImapStorage)4 MimePartRule (com.axway.ats.rbv.imap.rules.MimePartRule)3 BeforeClass (org.junit.BeforeClass)2 NoSuchMimePartException (com.axway.ats.action.objects.model.NoSuchMimePartException)1 PackageException (com.axway.ats.action.objects.model.PackageException)1 HeaderRule (com.axway.ats.rbv.imap.rules.HeaderRule)1 MimePartCountRule (com.axway.ats.rbv.imap.rules.MimePartCountRule)1 SubjectRule (com.axway.ats.rbv.imap.rules.SubjectRule)1 RbvException (com.axway.ats.rbv.model.RbvException)1 InputStream (java.io.InputStream)1