use of com.axway.ats.rbv.filesystem.rules.FilePathRule 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.rules.FilePathRule in project ats-framework by Axway.
the class Test_FilePathRule method isMatchNullMetaDataContent.
@Test(expected = MetaDataIncorrectException.class)
public void isMatchNullMetaDataContent() throws Exception {
expect(pack.getAbsolutePath()).andReturn(testFileAbsPath);
replayAll();
FilePathRule rule = new FilePathRule(testFileAbsPath, "isMatchNullMetaDataContent", true);
MetaData metaData = new FileSystemMetaData(null);
assertFalse(rule.isMatch(metaData));
verifyAll();
}
use of com.axway.ats.rbv.filesystem.rules.FilePathRule in project ats-framework by Axway.
the class Test_FilePathRule method isMatchExpectedTruePositiveRegex.
@Test
public void isMatchExpectedTruePositiveRegex() throws Exception {
expect(pack.getAbsolutePath()).andReturn(testFileAbsPath);
expect(pack.getName()).andReturn(testFileAbsPath.substring(testFileAbsPath.lastIndexOf('/') + 1));
replayAll();
FilePathRule rule = new FilePathRule(testFileDir, "p.*1.+xt", "isMatchExpectedTruePositive", true, 1);
MetaData metaData = new FileSystemMetaData(pack);
assertTrue(rule.isMatch(metaData));
verifyAll();
}
use of com.axway.ats.rbv.filesystem.rules.FilePathRule in project ats-framework by Axway.
the class Test_FilePathRule method isMatchNullMetaData.
@Test(expected = RbvException.class)
public void isMatchNullMetaData() throws Exception {
expect(pack.getAbsolutePath()).andReturn(testFileAbsPath);
replayAll();
FilePathRule rule = new FilePathRule(testFileAbsPath, "isMatchNullMetaData", true);
assertFalse(rule.isMatch(null));
verifyAll();
}
use of com.axway.ats.rbv.filesystem.rules.FilePathRule in project ats-framework by Axway.
the class Test_FilePathRule method getMetaKeys.
@Test
public void getMetaKeys() {
FilePathRule rule = new FilePathRule(testFileAbsPath, "isMatchExpectedFalseNegative", false);
List<String> list = new ArrayList<String>();
list.add(FileSystemMetaData.FILE_PACKAGE);
assertTrue(Arrays.equals(rule.getMetaDataKeys().toArray(), list.toArray()));
}
Aggregations