Search in sources :

Example 6 with FileFolderRule

use of com.axway.ats.rbv.filesystem.rules.FileFolderRule 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 7 with FileFolderRule

use of com.axway.ats.rbv.filesystem.rules.FileFolderRule in project ats-framework by Axway.

the class FileSystemVerification method addFileCheckRule.

private void addFileCheckRule() {
    // set the second highest priority for this rule - if the file path is correct the second most
    // important thing is to check if the entity is a file
    FileFolderRule rule = new FileFolderRule(true, "checkIsFile", true, Integer.MIN_VALUE);
    rootRule.addRule(rule);
}
Also used : FileFolderRule(com.axway.ats.rbv.filesystem.rules.FileFolderRule)

Example 8 with FileFolderRule

use of com.axway.ats.rbv.filesystem.rules.FileFolderRule in project ats-framework by Axway.

the class Test_FileFolderRule method performMatchNegative.

@Test
public void performMatchNegative() throws RbvException, PackageException {
    expect(meta.getFilePackage()).andReturn(pack);
    expect(pack.isFile()).andReturn(false);
    replayAll();
    rule = new FileFolderRule(true, "ruleName", true);
    assertFalse(rule.performMatch(meta));
    verifyAll();
}
Also used : FileFolderRule(com.axway.ats.rbv.filesystem.rules.FileFolderRule) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 9 with FileFolderRule

use of com.axway.ats.rbv.filesystem.rules.FileFolderRule in project ats-framework by Axway.

the class Test_FileFolderRule method performMatchException.

@Test(expected = RbvException.class)
public void performMatchException() throws RbvException, PackageException {
    expect(meta.getFilePackage()).andReturn(pack);
    expect(pack.isFile()).andThrow(new PackageException(""));
    replayAll();
    rule = new FileFolderRule(true, "ruleName", true);
    assertTrue(rule.performMatch(meta));
    verifyAll();
}
Also used : FileFolderRule(com.axway.ats.rbv.filesystem.rules.FileFolderRule) PackageException(com.axway.ats.action.objects.model.PackageException) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Aggregations

FileFolderRule (com.axway.ats.rbv.filesystem.rules.FileFolderRule)9 BaseTest (com.axway.ats.rbv.BaseTest)7 Test (org.junit.Test)7 FilePackage (com.axway.ats.action.objects.FilePackage)1 PackageException (com.axway.ats.action.objects.model.PackageException)1 FileSystemMetaData (com.axway.ats.rbv.filesystem.FileSystemMetaData)1 FilePathRule (com.axway.ats.rbv.filesystem.rules.FilePathRule)1 AndRuleOperation (com.axway.ats.rbv.rules.AndRuleOperation)1 ArrayList (java.util.ArrayList)1