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));
}
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());
}
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());
}
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;
}
}
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());
}
Aggregations