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;
}
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;
}
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();
}
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();
}
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();
}
Aggregations