use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.
the class Test_SimpleMonitorListener method monitorGetAllMachingMetaData.
@Test
public void monitorGetAllMachingMetaData() throws RbvException {
DbFieldsRule dbRule = new DbStringFieldRule("", "key1", "value101", MatchRelation.EQUALS, "monitorGetAllMachingMetaData", false);
Monitor monitor = new Monitor("monitor1", matchable, dbRule, pollingParams, true, false, false);
List<Monitor> monitors = new ArrayList<Monitor>();
monitors.add(monitor);
SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
listener.evaluateMonitors(TIME_END_POLL);
List<MetaData> matchingMetaData = monitor.getAllMatchedMetaData();
assertEquals(1, matchingMetaData.size());
ArrayList<String> results = new ArrayList<String>();
results.add((String) matchingMetaData.get(0).getProperty("key1"));
assertTrue(results.contains("value10") || results.contains("value00"));
}
use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.
the class Test_FileSystemFolder method getNewMetadataChangeLastModified.
@Test
public void getNewMetadataChangeLastModified() throws Exception {
expectNew(SystemOperations.class, "localhost:0000").andReturn(systemOperations).times(7);
expect(systemOperations.getOperatingSystemType()).andReturn(OperatingSystemType.LINUX);
// now we call getNewMetaData() 3 times
expect(fileSystemOperations.findFiles(path, ".*", true, true, false)).andReturn(fileList).times(3);
// 3 times x 2 files
expectNew(FileSystemOperations.class, "localhost:0000").andReturn(fileSystemOperations).times(7);
expect(fileSystemOperations.getFileUniqueId(file1)).andReturn(file1_hash).times(2);
expect(fileSystemOperations.getFileUniqueId(file2)).andReturn(file2_hash).times(3);
// modify the modification timestamp of file1 for the last getNewMetaData() call
expect(fileSystemOperations.getFileUniqueId(file1)).andReturn(file1_hash_changed);
replayAll();
FileSystemFolder folder = (FileSystemFolder) storage.getFolder(new FileSystemFolderSearchTerm(path, null, true, false));
folder.open();
List<MetaData> list = folder.getNewMetaData();
assertEquals(2, list.size());
for (MetaData metaData : list) {
((FileSystemMetaData) metaData).getFilePackage();
}
assertEquals(0, folder.getNewMetaData().size());
assertEquals(1, folder.getNewMetaData().size());
verifyAll();
}
use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.
the class Test_FileContentRule method isMatchNegative.
@Test
public void isMatchNegative() throws Exception {
expect(testFilePackage.grep(EXPRESSION, false)).andReturn(new String[0]);
replayAll();
FileContentRule rule = new FileContentRule(EXPRESSION, RULE_NAME, false, true);
MetaData metaData = new FileSystemMetaData(testFilePackage);
assertFalse(rule.isMatch(metaData));
verifyAll();
}
use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.
the class Test_FileContentRule method isMatch.
@Test
public void isMatch() throws Exception {
expect(testFilePackage.grep(EXPRESSION, false)).andReturn(new String[] { EXPRESSION });
replayAll();
FileContentRule rule = new FileContentRule(EXPRESSION, RULE_NAME, false, true);
MetaData metaData = new FileSystemMetaData(testFilePackage);
assertTrue(rule.isMatch(metaData));
verifyAll();
}
use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.
the class MetaExecutor method evaluate.
/**
* Evaluates the {@link MetaData} received as a parameter against the rules
* that were previously set.
* @param metaData the {@link List} of {@link MetaData} to be verified
*
* @see com.axway.ats.rbv.executors.Executor#evaluate(java.util.List)
*/
public List<MetaData> evaluate(List<MetaData> metaData) throws RbvException {
List<MetaData> matched = new ArrayList<MetaData>();
for (MetaData currentMeta : metaData) {
if (this.rootRule.isMatch(currentMeta)) {
log.info("Matched a meta data!");
// we matched a piece of MetaData - add it to the
// collection that would be returned as a result
matched.add(currentMeta);
if (this.endOnFirstMatch) {
return matched;
}
}
}
return matched;
}
Aggregations