use of com.axway.ats.rbv.filesystem.FileSystemMetaData in project ats-framework by Axway.
the class Test_AndRuleOperation method isMatchPriority.
@Test
public void isMatchPriority() throws RbvException, PackageException {
FileSystemMetaData meta = createMock(FileSystemMetaData.class);
FilePackage pack = createMock(FilePackage.class);
expect(meta.getFilePackage()).andReturn(pack);
expect(pack.isFile()).andReturn(true);
// at this point the evaluation should stop since this is the first rule to
// evaluate and it fails thus the second should not be evaluated at all
// if the priority does not work then the second rule would fail the unit test
// because we are not expecting any calls it would do to the mock objects
replayAll();
FilePathRule rule = new FilePathRule("some/path/some.file", "pathRule1", true, 2);
FileFolderRule anotherRule = new FileFolderRule(false, "folderRule", true, 1);
AndRuleOperation andRule = new AndRuleOperation();
andRule.addRule(rule);
andRule.addRule(anotherRule);
assertFalse(andRule.isMatch(meta));
verifyAll();
}
use of com.axway.ats.rbv.filesystem.FileSystemMetaData 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.filesystem.FileSystemMetaData 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.filesystem.FileSystemMetaData 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.filesystem.FileSystemMetaData in project ats-framework by Axway.
the class FileModtimeRule method performMatch.
@Override
public boolean performMatch(MetaData metaData) throws RbvException {
boolean actualResult = false;
if (metaData instanceof FileSystemMetaData) {
//get the file from the meta data
FilePackage file = ((FileSystemMetaData) metaData).getFilePackage();
try {
//get destination file's size
long destModtime = file.getModTime();
actualResult = destModtime == this.srcModtime;
} catch (PackageException pe) {
throw new RbvStorageException(pe);
}
}
return actualResult;
}
Aggregations