Search in sources :

Example 21 with FileSystemMetaData

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

the class FilePathRule 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();
        String destAbsolutePath = file.getAbsolutePath();
        log.info("Actual value is '" + destAbsolutePath + "'");
        if (filenameRegex == null) {
            actualResult = !StringUtils.isNullOrEmpty(destAbsolutePath) && destAbsolutePath.equals(this.path);
        } else {
            String fileName = file.getName();
            String filePath = IoUtils.getFilePath(destAbsolutePath);
            Pattern pattern = Pattern.compile(filenameRegex);
            Matcher matcher = pattern.matcher(fileName);
            actualResult = !StringUtils.isNullOrEmpty(filePath) && filePath.equals(this.path) && matcher.matches();
        }
    }
    return actualResult;
}
Also used : FilePackage(com.axway.ats.action.objects.FilePackage) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData)

Example 22 with FileSystemMetaData

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

the class FileSizeRule method performMatch.

@Override
public boolean performMatch(MetaData metaData) throws RbvException {
    boolean actuaResult = false;
    if (metaData instanceof FileSystemMetaData) {
        //get the file from the meta data
        FilePackage file = ((FileSystemMetaData) metaData).getFilePackage();
        try {
            //get destination file's size
            long destSize = file.getSize();
            actuaResult = this.srcSize == destSize;
        } catch (PackageException pe) {
            throw new RbvStorageException(pe);
        }
    }
    return actuaResult;
}
Also used : FilePackage(com.axway.ats.action.objects.FilePackage) PackageException(com.axway.ats.action.objects.model.PackageException) RbvStorageException(com.axway.ats.rbv.model.RbvStorageException) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData)

Example 23 with FileSystemMetaData

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

the class Test_FileMD5Rule method isMatchConstructWithMd5ExpectTruePositive.

@Test
public void isMatchConstructWithMd5ExpectTruePositive() throws PackageException, RbvException {
    expect(pack.getMd5sum(true)).andReturn(md5sum);
    replayAll();
    FileMd5Rule rule = new FileMd5Rule(md5sum, "isMatchConstructWithMd5ExpectTruePositive", true);
    MetaData metaData = new FileSystemMetaData(pack);
    assertTrue(rule.isMatch(metaData));
    verifyAll();
}
Also used : FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) MetaData(com.axway.ats.rbv.MetaData) FileMd5Rule(com.axway.ats.rbv.filesystem.rules.FileMd5Rule) 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 24 with FileSystemMetaData

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

the class Test_FileMD5Rule method isMatchNullMetaDataContent.

@Test(expected = MetaDataIncorrectException.class)
public void isMatchNullMetaDataContent() throws PackageException, RbvException {
    expect(pack.getMd5sum(true)).andReturn(md5sum);
    replayAll();
    FileMd5Rule rule = new FileMd5Rule("", "isMatchNullMetaDataContent", true);
    MetaData metaData = new FileSystemMetaData(null);
    assertFalse(rule.isMatch(metaData));
    verifyAll();
}
Also used : FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) MetaData(com.axway.ats.rbv.MetaData) FileMd5Rule(com.axway.ats.rbv.filesystem.rules.FileMd5Rule) 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 25 with FileSystemMetaData

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

the class Test_FileModtimeRule method isMatchConstructWithModTimeExpectTrueNegativeWrongFile.

@Test
public void isMatchConstructWithModTimeExpectTrueNegativeWrongFile() throws Exception {
    expect(pack.getModTime()).andReturn(123L);
    replayAll();
    FileModtimeRule rule = new FileModtimeRule(modtime, "isMatchConstructWithModTimeExpectTrueNegativeWrongFile", true);
    MetaData metaData = new FileSystemMetaData(pack);
    assertFalse(rule.isMatch(metaData));
    verifyAll();
}
Also used : FileModtimeRule(com.axway.ats.rbv.filesystem.rules.FileModtimeRule) 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)

Aggregations

FileSystemMetaData (com.axway.ats.rbv.filesystem.FileSystemMetaData)47 BaseTest (com.axway.ats.rbv.BaseTest)43 Test (org.junit.Test)43 MetaData (com.axway.ats.rbv.MetaData)42 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)38 FilePackage (com.axway.ats.action.objects.FilePackage)13 FilePathRule (com.axway.ats.rbv.filesystem.rules.FilePathRule)10 FileMd5Rule (com.axway.ats.rbv.filesystem.rules.FileMd5Rule)9 FileSizeRule (com.axway.ats.rbv.filesystem.rules.FileSizeRule)9 FileModtimeRule (com.axway.ats.rbv.filesystem.rules.FileModtimeRule)5 FilePermRule (com.axway.ats.rbv.filesystem.rules.FilePermRule)5 PackageException (com.axway.ats.action.objects.model.PackageException)4 FileContentRule (com.axway.ats.rbv.filesystem.rules.FileContentRule)4 RbvStorageException (com.axway.ats.rbv.model.RbvStorageException)3 FileSystemFolder (com.axway.ats.rbv.filesystem.FileSystemFolder)1 FileSystemFolderSearchTerm (com.axway.ats.rbv.filesystem.FileSystemFolderSearchTerm)1 FileFolderRule (com.axway.ats.rbv.filesystem.rules.FileFolderRule)1 AndRuleOperation (com.axway.ats.rbv.rules.AndRuleOperation)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1