Search in sources :

Example 6 with AndRuleOperation

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

the class Test_DbBinaryFieldRule method isMatchExpectedFalseMultipleRulesNegative.

@Test
public void isMatchExpectedFalseMultipleRulesNegative() throws RbvException {
    DbMetaData metaData = new DbMetaData();
    metaData.putProperty("table.column", new byte[] { 0, 2 });
    metaData.putProperty("table.column2", new byte[] { 0, 5 });
    AndRuleOperation andRule = new AndRuleOperation();
    andRule.addRule(ruleTest1ExpectFalse);
    andRule.addRule(ruleTest2ExpectFalse);
    assertFalse(andRule.isMatch(metaData));
}
Also used : DbMetaData(com.axway.ats.rbv.db.DbMetaData) AndRuleOperation(com.axway.ats.rbv.rules.AndRuleOperation) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 7 with AndRuleOperation

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

the class Test_DbBinaryFieldRule method isMatchExpectedTrueMultipleRulesNegativeDontMatch.

@Test
public void isMatchExpectedTrueMultipleRulesNegativeDontMatch() throws RbvException {
    DbMetaData metaData = new DbMetaData();
    metaData.putProperty("table.column", new byte[] { 0, 2 });
    metaData.putProperty("table.column2", new byte[] { 0, 6 });
    AndRuleOperation andRule = new AndRuleOperation();
    andRule.addRule(ruleTest1ExpectTrue);
    andRule.addRule(ruleTest2ExpectTrue);
    assertFalse(andRule.isMatch(metaData));
}
Also used : DbMetaData(com.axway.ats.rbv.db.DbMetaData) AndRuleOperation(com.axway.ats.rbv.rules.AndRuleOperation) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 8 with AndRuleOperation

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

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

the class Test_SnapshotExecutor method matchAfterMultipleUpdateNegative.

/**
 * UnitTest
 * @throws RbvException
 */
@Test
public void matchAfterMultipleUpdateNegative() throws RbvException {
    MetaData meta = new DbMetaData();
    meta.putProperty(META_KEY_1, MOD_META_VALUE_1 + 2);
    meta.putProperty(META_KEY_2, MOD_META_VALUE_2 + 2);
    meta.putProperty(META_KEY_3, MOD_META_VALUE_3 + 2);
    meta.putProperty(META_KEY_4, META_VALUE_4 + 2);
    this.newData.add(meta);
    DbStringFieldRule keyRule = new DbStringFieldRule(TABLE_NAME, COLUMN_NAME_2, MOD_META_VALUE_2 + 2, DbStringFieldRule.MatchRelation.EQUALS, "key_rule_1", true);
    DbStringFieldRule matchingRule1 = new DbStringFieldRule(TABLE_NAME, COLUMN_NAME_1, MOD_META_VALUE_1 + 2, DbStringFieldRule.MatchRelation.EQUALS, "match_metakey_1", true);
    DbStringFieldRule matchingRule2 = new DbStringFieldRule(TABLE_NAME, COLUMN_NAME_2, MOD_META_VALUE_2 + 2, DbStringFieldRule.MatchRelation.EQUALS, "match_metakey_2", true);
    AndRuleOperation rule = new AndRuleOperation();
    rule.addRule(matchingRule1);
    rule.addRule(matchingRule2);
    SnapshotExecutor executor = new SnapshotExecutor(this.snapshot);
    executor.addRule(keyRule, rule);
    List<MetaData> result = executor.evaluate(this.newData);
    assertTrue(result == null || result.isEmpty());
}
Also used : DbMetaData(com.axway.ats.rbv.db.DbMetaData) DbMetaData(com.axway.ats.rbv.db.DbMetaData) MetaData(com.axway.ats.rbv.MetaData) SnapshotExecutor(com.axway.ats.rbv.executors.SnapshotExecutor) AndRuleOperation(com.axway.ats.rbv.rules.AndRuleOperation) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 10 with AndRuleOperation

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

the class Test_DbNumericFieldRule method isMatchExpectedFalseMultipleRulesNegative.

@Test
public void isMatchExpectedFalseMultipleRulesNegative() throws RbvException {
    DbMetaData metaData = new DbMetaData();
    metaData.putProperty("table.column", 2);
    metaData.putProperty("table.column2", 5);
    AndRuleOperation andRule = new AndRuleOperation();
    andRule.addRule(ruleTest1ExpectFalse);
    andRule.addRule(ruleTest2ExpectFalse);
    assertFalse(andRule.isMatch(metaData));
}
Also used : DbMetaData(com.axway.ats.rbv.db.DbMetaData) AndRuleOperation(com.axway.ats.rbv.rules.AndRuleOperation) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Aggregations

BaseTest (com.axway.ats.rbv.BaseTest)25 AndRuleOperation (com.axway.ats.rbv.rules.AndRuleOperation)25 Test (org.junit.Test)25 DbMetaData (com.axway.ats.rbv.db.DbMetaData)20 HeaderRule (com.axway.ats.rbv.imap.rules.HeaderRule)4 MetaData (com.axway.ats.rbv.MetaData)2 DbStringFieldRule (com.axway.ats.rbv.db.rules.DbStringFieldRule)2 SnapshotExecutor (com.axway.ats.rbv.executors.SnapshotExecutor)2 FilePackage (com.axway.ats.action.objects.FilePackage)1 FileSystemMetaData (com.axway.ats.rbv.filesystem.FileSystemMetaData)1 FileFolderRule (com.axway.ats.rbv.filesystem.rules.FileFolderRule)1 FilePathRule (com.axway.ats.rbv.filesystem.rules.FilePathRule)1