Search in sources :

Example 1 with FilePackage

use of com.axway.ats.action.objects.FilePackage in project ats-framework by Axway.

the class Test_FileUIDRule method performMatchOtherFile.

@Test
public void performMatchOtherFile() throws Exception {
    FilePackage remotePack = createMock(FilePackage.class, null, "/root/file.name");
    expectNew(FilePackage.class, null, null, "/root/file.name").andReturn(remotePack);
    expect(remotePack.getUid()).andReturn(1L);
    expect(meta.getFilePackage()).andReturn(pack);
    expect(pack.getUid()).andReturn(1L);
    replayAll();
    rule = new FileUidRule(null, "/root/file.name", "ruleName", true);
    assertTrue(rule.performMatch(meta));
    verifyAll();
}
Also used : FilePackage(com.axway.ats.action.objects.FilePackage) FileUidRule(com.axway.ats.rbv.filesystem.rules.FileUidRule) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with FilePackage

use of com.axway.ats.action.objects.FilePackage in project ats-framework by Axway.

the class Test_FileUIDRule method performMatchOtherFileException.

@Test(expected = RbvException.class)
public void performMatchOtherFileException() throws Exception {
    FilePackage remotePack = createMock(FilePackage.class, null, "/root/file.name");
    expectNew(FilePackage.class, null, null, "/root/file.name").andReturn(remotePack);
    expect(remotePack.getUid()).andThrow(new PackageException("Test"));
    replayAll();
    rule = new FileUidRule(null, "/root/file.name", "ruleName", true);
    verifyAll();
}
Also used : FilePackage(com.axway.ats.action.objects.FilePackage) FileUidRule(com.axway.ats.rbv.filesystem.rules.FileUidRule) PackageException(com.axway.ats.action.objects.model.PackageException) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with FilePackage

use of com.axway.ats.action.objects.FilePackage in project ats-framework by Axway.

the class Test_FileGIDRule method performMatchOtherFileNull.

@Test
public void performMatchOtherFileNull() throws Exception {
    FilePackage remotePack = createMock(FilePackage.class);
    expectNew(FilePackage.class, null, null, "/root/file.name").andReturn(remotePack);
    expect(remotePack.getGid()).andReturn(1L);
    expect(meta.getFilePackage()).andReturn(pack);
    expect(pack.getGid()).andReturn(1L);
    replayAll();
    rule = new FileGidRule(null, "/root/file.name", "ruleName", true);
    assertTrue(rule.performMatch(meta));
    verifyAll();
}
Also used : FilePackage(com.axway.ats.action.objects.FilePackage) FileGidRule(com.axway.ats.rbv.filesystem.rules.FileGidRule) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with FilePackage

use of com.axway.ats.action.objects.FilePackage in project ats-framework by Axway.

the class Test_FileGIDRule method performMatchOtherFileException.

@Test(expected = RbvException.class)
public void performMatchOtherFileException() throws Exception {
    FilePackage remotePack = createMock(FilePackage.class);
    expectNew(FilePackage.class, null, null, "/root/file.name").andReturn(remotePack);
    expect(remotePack.getGid()).andThrow(new PackageException(""));
    replayAll();
    rule = new FileGidRule(null, "/root/file.name", "ruleName", true);
    verifyAll();
}
Also used : FilePackage(com.axway.ats.action.objects.FilePackage) PackageException(com.axway.ats.action.objects.model.PackageException) FileGidRule(com.axway.ats.rbv.filesystem.rules.FileGidRule) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with FilePackage

use of com.axway.ats.action.objects.FilePackage 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)

Aggregations

FilePackage (com.axway.ats.action.objects.FilePackage)12 PackageException (com.axway.ats.action.objects.model.PackageException)7 BaseTest (com.axway.ats.rbv.BaseTest)7 Test (org.junit.Test)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 FileSystemMetaData (com.axway.ats.rbv.filesystem.FileSystemMetaData)5 RbvStorageException (com.axway.ats.rbv.model.RbvStorageException)4 FileGidRule (com.axway.ats.rbv.filesystem.rules.FileGidRule)3 FileUidRule (com.axway.ats.rbv.filesystem.rules.FileUidRule)2 FileSystemOperations (com.axway.ats.action.filesystem.FileSystemOperations)1 SystemOperations (com.axway.ats.action.system.SystemOperations)1 MetaData (com.axway.ats.rbv.MetaData)1 FileSystemFolder (com.axway.ats.rbv.filesystem.FileSystemFolder)1 FileFolderRule (com.axway.ats.rbv.filesystem.rules.FileFolderRule)1 FilePathRule (com.axway.ats.rbv.filesystem.rules.FilePathRule)1 MatchableAlreadyOpenException (com.axway.ats.rbv.model.MatchableAlreadyOpenException)1 MatchableNotOpenException (com.axway.ats.rbv.model.MatchableNotOpenException)1 RbvException (com.axway.ats.rbv.model.RbvException)1 AndRuleOperation (com.axway.ats.rbv.rules.AndRuleOperation)1 ArrayList (java.util.ArrayList)1