Search in sources :

Example 36 with MetaData

use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.

the class Test_MimePartRule method isMatchWrongMetaData.

@Test(expected = MetaDataIncorrectException.class)
public void isMatchWrongMetaData() throws RbvException {
    MimePartRule rule = new MimePartRule(expectedMailMessage, 0, false, "isMatchEmptyMetaData", true);
    metaData = new MetaData();
    assertFalse(rule.isMatch(metaData));
}
Also used : ImapMetaData(com.axway.ats.rbv.imap.ImapMetaData) MetaData(com.axway.ats.rbv.MetaData) MimePartRule(com.axway.ats.rbv.imap.rules.MimePartRule) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 37 with MetaData

use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.

the class Test_SnapshotExecutor method matchExcludeKeysScenarioPositive.

/**
 * UnitTest
 * @throws RbvException
 */
@Test
public void matchExcludeKeysScenarioPositive() throws RbvException {
    // remove first piece of default MetaData
    this.newData = new ArrayList<MetaData>();
    MetaData meta = new DbMetaData();
    meta.putProperty(META_KEY_1, MOD_META_VALUE_1 + 1);
    meta.putProperty(META_KEY_2, META_VALUE_2 + 1);
    meta.putProperty(META_KEY_3, META_VALUE_3 + 1);
    meta.putProperty(META_KEY_4, META_VALUE_4 + 1);
    this.newData.add(meta);
    meta = new DbMetaData();
    meta.putProperty(META_KEY_1, META_VALUE_1 + 2);
    meta.putProperty(META_KEY_2, MOD_META_VALUE_2 + 2);
    meta.putProperty(META_KEY_3, META_VALUE_3 + 2);
    meta.putProperty(META_KEY_4, META_VALUE_4 + 2);
    this.newData.add(meta);
    meta = new DbMetaData();
    meta.putProperty(META_KEY_1, META_VALUE_1 + 3);
    meta.putProperty(META_KEY_2, META_VALUE_2 + 3);
    meta.putProperty(META_KEY_3, META_VALUE_3 + 3);
    meta.putProperty(META_KEY_4, META_VALUE_4 + 3);
    this.newData.add(meta);
    DbStringFieldRule keyRule = new DbStringFieldRule(TABLE_NAME, COLUMN_NAME_2, META_VALUE_2 + 1, DbStringFieldRule.MatchRelation.EQUALS, "key_rule", true);
    DbStringFieldRule matchingRule = new DbStringFieldRule(TABLE_NAME, COLUMN_NAME_1, MOD_META_VALUE_1 + 1, DbStringFieldRule.MatchRelation.EQUALS, "match_metakey_1", true);
    SnapshotExecutor executor = new SnapshotExecutor(this.snapshot);
    executor.addRule(keyRule, matchingRule);
    List<String> list = new ArrayList<String>();
    list.add(META_KEY_2);
    executor.excludeKeys(list);
    List<MetaData> result = executor.evaluate(this.newData);
    assertTrue(result != null && !result.isEmpty());
}
Also used : DbMetaData(com.axway.ats.rbv.db.DbMetaData) DbMetaData(com.axway.ats.rbv.db.DbMetaData) MetaData(com.axway.ats.rbv.MetaData) SnapshotExecutor(com.axway.ats.rbv.executors.SnapshotExecutor) ArrayList(java.util.ArrayList) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 38 with MetaData

use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.

the class Test_SnapshotExecutor method matchGlobalRuleAndSnapshotRulesNegative.

/**
 * UnitTest
 * @throws RbvException
 */
@Test
public void matchGlobalRuleAndSnapshotRulesNegative() throws RbvException {
    this.newData = new ArrayList<MetaData>();
    DbMetaData meta;
    meta = new DbMetaData();
    meta.putProperty(META_KEY_1, MOD_META_VALUE_1 + 33);
    meta.putProperty(META_KEY_2, META_VALUE_2 + 1);
    meta.putProperty(META_KEY_3, META_VALUE_3 + 1);
    meta.putProperty(META_KEY_4, META_VALUE_4 + 1);
    this.newData.add(meta);
    meta = new DbMetaData();
    meta.putProperty(META_KEY_1, MOD_META_VALUE_1 + 33);
    meta.putProperty(META_KEY_2, META_VALUE_2 + 2);
    meta.putProperty(META_KEY_3, META_VALUE_3 + 2);
    meta.putProperty(META_KEY_4, META_VALUE_4 + 2);
    this.newData.add(meta);
    meta = new DbMetaData();
    meta.putProperty(META_KEY_1, MOD_META_VALUE_1 + 33);
    meta.putProperty(META_KEY_2, META_VALUE_2 + 3);
    meta.putProperty(META_KEY_3, META_VALUE_3 + 3);
    meta.putProperty(META_KEY_4, META_VALUE_4 + 3);
    this.newData.add(meta);
    DbStringFieldRule globalRule = new DbStringFieldRule(TABLE_NAME, COLUMN_NAME_1, MOD_META_VALUE_1 + 33, DbStringFieldRule.MatchRelation.EQUALS, "global_rule", true);
    DbStringFieldRule keyRule = new DbStringFieldRule(TABLE_NAME, COLUMN_NAME_2, META_VALUE_2 + 1, DbStringFieldRule.MatchRelation.EQUALS, "key_rule", true);
    DbStringFieldRule matchingRule = new DbStringFieldRule(TABLE_NAME, COLUMN_NAME_1, MOD_META_VALUE_1 + 35, DbStringFieldRule.MatchRelation.EQUALS, "match_metakey_1", true);
    SnapshotExecutor executor = new SnapshotExecutor(this.snapshot);
    executor.addRule(keyRule, matchingRule);
    executor.setRootRule(globalRule);
    List<MetaData> result = executor.evaluate(this.newData);
    assertTrue(result == null || result.isEmpty());
}
Also used : DbMetaData(com.axway.ats.rbv.db.DbMetaData) DbMetaData(com.axway.ats.rbv.db.DbMetaData) MetaData(com.axway.ats.rbv.MetaData) SnapshotExecutor(com.axway.ats.rbv.executors.SnapshotExecutor) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 39 with MetaData

use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.

the class BlobStorageFolder method getContainerAllMetaData.

private MetaData getContainerAllMetaData() {
    if (operations.doesContainerExist(containerName)) {
        MetaData metadata = new MetaData();
        metadata.putProperty(BlobStorageMetaData.CONTAINER_NAME, this.containerName);
        return metadata;
    } else {
        return null;
    }
}
Also used : MetaData(com.axway.ats.rbv.MetaData)

Example 40 with MetaData

use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.

the class BlobStorageFolder method getAllMetaData.

@Override
public List<MetaData> getAllMetaData() throws RbvException {
    // first check if the folder is already open
    if (!isOpen) {
        throw new MatchableNotOpenException("Azure Blob Storage folder is not open");
    }
    newMetaData.clear();
    HashMap<String, MetaData> tempMetaData = new HashMap<String, MetaData>();
    if (containerOperationsOnly) {
        MetaData md = getContainerAllMetaData();
        if (md != null) {
            tempMetaData.put(this.containerName, md);
        }
    } else {
        if (blobName == null) {
            blobName = ".*";
        }
        List<BlobInfo> blobs = null;
        String directory = null;
        String actualBlobName = blobName;
        if (blobName.contains("/")) {
            if (blobName.endsWith("/")) {
                directory = blobName;
                actualBlobName = ".*";
            } else {
                directory = blobName.substring(0, blobName.lastIndexOf("/"));
                actualBlobName = blobName.substring(blobName.lastIndexOf("/"));
            }
        }
        if (searchRecursively) {
            throw new RuntimeException("Not implemented for searchRecursively = " + searchRecursively);
        } else {
            if (StringUtils.isNullOrEmpty(directory)) {
                blobs = this.operations.listBlobs(this.containerName, actualBlobName);
            } else {
                blobs = this.operations.listBlobs(this.containerName, directory, actualBlobName);
            }
        }
        if (blobs != null) {
            for (BlobInfo blob : blobs) {
                MetaData metaData = new BlobStorageMetaData();
                metaData.putProperty(BlobStorageMetaData.BLOB_NAME, blob.getBlobName());
                metaData.putProperty(BlobStorageMetaData.BLOB_TYPE, blob.getBlobType());
                metaData.putProperty(BlobStorageMetaData.CONTAINER_NAME, blob.getContainerName());
                metaData.putProperty(BlobStorageMetaData.CONTENT_TYPE, blob.getContentType());
                metaData.putProperty(BlobStorageMetaData.CREATION_TIME, blob.getCreationTime());
                metaData.putProperty(BlobStorageMetaData.E_TAG, blob.getETag());
                metaData.putProperty(BlobStorageMetaData.LAST_MODIFIED, blob.getLastModified());
                metaData.putProperty(BlobStorageMetaData.MD5, blob.getMd5());
                metaData.putProperty(BlobStorageMetaData.META_DATA, blob.getMetadata());
                metaData.putProperty(BlobStorageMetaData.SIZE, blob.getSize());
                String hashKey = blob.toString();
                if (!allMetaData.containsKey(hashKey)) {
                    newMetaData.add(metaData);
                }
                tempMetaData.put(hashKey, metaData);
            }
        }
    }
    allMetaData.clear();
    allMetaData.putAll(tempMetaData);
    return new ArrayList<MetaData>(allMetaData.values());
}
Also used : MatchableNotOpenException(com.axway.ats.rbv.model.MatchableNotOpenException) HashMap(java.util.HashMap) MetaData(com.axway.ats.rbv.MetaData) ArrayList(java.util.ArrayList) BlobInfo(com.axway.ats.action.azure.BlobInfo)

Aggregations

MetaData (com.axway.ats.rbv.MetaData)85 Test (org.junit.Test)74 BaseTest (com.axway.ats.rbv.BaseTest)71 FileSystemMetaData (com.axway.ats.rbv.filesystem.FileSystemMetaData)49 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)45 DbMetaData (com.axway.ats.rbv.db.DbMetaData)16 DbStringFieldRule (com.axway.ats.rbv.db.rules.DbStringFieldRule)15 SnapshotExecutor (com.axway.ats.rbv.executors.SnapshotExecutor)15 FileMd5Rule (com.axway.ats.rbv.filesystem.rules.FileMd5Rule)10 FilePathRule (com.axway.ats.rbv.filesystem.rules.FilePathRule)10 FileSizeRule (com.axway.ats.rbv.filesystem.rules.FileSizeRule)10 FilePackage (com.axway.ats.action.objects.FilePackage)9 ArrayList (java.util.ArrayList)7 FileModtimeRule (com.axway.ats.rbv.filesystem.rules.FileModtimeRule)6 FilePermRule (com.axway.ats.rbv.filesystem.rules.FilePermRule)6 ImapMetaData (com.axway.ats.rbv.imap.ImapMetaData)5 FileContentRule (com.axway.ats.rbv.filesystem.rules.FileContentRule)4 RbvException (com.axway.ats.rbv.model.RbvException)4 S3ObjectInfo (com.axway.ats.action.s3.S3ObjectInfo)3 FileSystemFolder (com.axway.ats.rbv.filesystem.FileSystemFolder)3