Search in sources :

Example 1 with FileContentRule

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

the class Test_FileContentRule method isMatchNegativeException.

@Test(expected = RbvException.class)
public void isMatchNegativeException() throws Exception {
    expect(testFilePackage.grep(EXPRESSION, false)).andThrow(new PackageException(""));
    replayAll();
    FileContentRule rule = new FileContentRule(EXPRESSION, RULE_NAME, false, true);
    MetaData metaData = new FileSystemMetaData(testFilePackage);
    rule.isMatch(metaData);
    verifyAll();
}
Also used : FileContentRule(com.axway.ats.rbv.filesystem.rules.FileContentRule) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) MetaData(com.axway.ats.rbv.MetaData) PackageException(com.axway.ats.action.objects.model.PackageException) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 2 with FileContentRule

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

the class Test_FileContentRule method isMatchRegularExpression.

@Test
public void isMatchRegularExpression() throws Exception {
    expect(testFilePackage.grep(EXPRESSION, true)).andReturn(new String[] { EXPRESSION });
    replayAll();
    FileContentRule rule = new FileContentRule(EXPRESSION, RULE_NAME, true, true);
    MetaData metaData = new FileSystemMetaData(testFilePackage);
    assertTrue(rule.isMatch(metaData));
    verifyAll();
}
Also used : FileContentRule(com.axway.ats.rbv.filesystem.rules.FileContentRule) 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)

Example 3 with FileContentRule

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

the class FileSystemVerification method checkContents.

/**
     * Add rule to check if the file contains (or does not contain) the specified expression.
     * Accepts both regular expressions and simple strings.
     *
     * @param expression the expression to look for
     * @param isRegularExpression true if the expression is a regular expression
     * @param expectedResult whether or not we would expect the expression to be present in the file
     * @throws RbvException thrown on error
     */
@PublicAtsApi
public void checkContents(String expression, boolean isRegularExpression, boolean expectedResult) throws RbvException {
    FileContentRule rule = new FileContentRule(expression, "checkContents", isRegularExpression, expectedResult);
    rootRule.addRule(rule);
}
Also used : FileContentRule(com.axway.ats.rbv.filesystem.rules.FileContentRule) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 4 with FileContentRule

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

the class Test_FileContentRule method isMatchNegative.

@Test
public void isMatchNegative() throws Exception {
    expect(testFilePackage.grep(EXPRESSION, false)).andReturn(new String[0]);
    replayAll();
    FileContentRule rule = new FileContentRule(EXPRESSION, RULE_NAME, false, true);
    MetaData metaData = new FileSystemMetaData(testFilePackage);
    assertFalse(rule.isMatch(metaData));
    verifyAll();
}
Also used : FileContentRule(com.axway.ats.rbv.filesystem.rules.FileContentRule) 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)

Example 5 with FileContentRule

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

the class Test_FileContentRule method getMetaDataKeys.

@Test
public void getMetaDataKeys() throws Exception {
    replayAll();
    FileContentRule rule = new FileContentRule(EXPRESSION, RULE_NAME, true, true);
    ArrayList<String> expected = new ArrayList<String>();
    expected.add(FileSystemMetaData.FILE_PACKAGE);
    assertTrue(Arrays.equals(expected.toArray(), rule.getMetaDataKeys().toArray()));
    verifyAll();
}
Also used : FileContentRule(com.axway.ats.rbv.filesystem.rules.FileContentRule) ArrayList(java.util.ArrayList) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Aggregations

FileContentRule (com.axway.ats.rbv.filesystem.rules.FileContentRule)6 BaseTest (com.axway.ats.rbv.BaseTest)5 Test (org.junit.Test)5 MetaData (com.axway.ats.rbv.MetaData)4 FileSystemMetaData (com.axway.ats.rbv.filesystem.FileSystemMetaData)4 PackageException (com.axway.ats.action.objects.model.PackageException)1 PublicAtsApi (com.axway.ats.common.PublicAtsApi)1 ArrayList (java.util.ArrayList)1