Search in sources :

Example 1 with FilePathRule

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();
}
Also used : FilePackage(com.axway.ats.action.objects.FilePackage) FileFolderRule(com.axway.ats.rbv.filesystem.rules.FileFolderRule) FilePathRule(com.axway.ats.rbv.filesystem.rules.FilePathRule) AndRuleOperation(com.axway.ats.rbv.rules.AndRuleOperation) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 2 with FilePathRule

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();
}
Also used : FilePathRule(com.axway.ats.rbv.filesystem.rules.FilePathRule) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) MetaData(com.axway.ats.rbv.MetaData) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with FilePathRule

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();
}
Also used : FilePathRule(com.axway.ats.rbv.filesystem.rules.FilePathRule) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) MetaData(com.axway.ats.rbv.MetaData) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with FilePathRule

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();
}
Also used : FilePathRule(com.axway.ats.rbv.filesystem.rules.FilePathRule) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with FilePathRule

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()));
}
Also used : FilePathRule(com.axway.ats.rbv.filesystem.rules.FilePathRule) ArrayList(java.util.ArrayList) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

BaseTest (com.axway.ats.rbv.BaseTest)14 FilePathRule (com.axway.ats.rbv.filesystem.rules.FilePathRule)14 Test (org.junit.Test)14 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)13 FileSystemMetaData (com.axway.ats.rbv.filesystem.FileSystemMetaData)11 MetaData (com.axway.ats.rbv.MetaData)10 FilePackage (com.axway.ats.action.objects.FilePackage)1 FileFolderRule (com.axway.ats.rbv.filesystem.rules.FileFolderRule)1 AndRuleOperation (com.axway.ats.rbv.rules.AndRuleOperation)1 ArrayList (java.util.ArrayList)1