Search in sources :

Example 31 with DbMetaData

use of com.axway.ats.rbv.db.DbMetaData in project ats-framework by Axway.

the class Test_SnapshotExecutor method matchDifferentSizeOfPropertiesName.

/**
     * UnitTest
     * @throws RbvException
     */
@Test
public void matchDifferentSizeOfPropertiesName() throws RbvException {
    MetaData meta = new DbMetaData();
    meta.putProperty(META_KEY_1, MOD_META_VALUE_1 + 2);
    meta.putProperty(META_KEY_2, META_VALUE_2 + 2);
    meta.putProperty(META_KEY_3, META_VALUE_3 + 2);
    meta.putProperty("Some_other_disturbingly_wrong_name", META_VALUE_4 + 2);
    this.newData.add(meta);
    DbStringFieldRule keyRule = new DbStringFieldRule(TABLE_NAME, COLUMN_NAME_2, META_VALUE_2 + 2, DbStringFieldRule.MatchRelation.EQUALS, "key_rule", true);
    DbStringFieldRule matchingRule = new DbStringFieldRule(TABLE_NAME, COLUMN_NAME_1, MOD_META_VALUE_1 + 2, DbStringFieldRule.MatchRelation.EQUALS, "match_metakey_1", true);
    SnapshotExecutor executor = new SnapshotExecutor(this.snapshot);
    executor.addRule(keyRule, matchingRule);
    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) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 32 with DbMetaData

use of com.axway.ats.rbv.db.DbMetaData 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 33 with DbMetaData

use of com.axway.ats.rbv.db.DbMetaData in project ats-framework by Axway.

the class Test_SnapshotExecutor method matchExcludeKeysScenarioPositive.

/**
     * UnitTest
     * @throws RbvException
     */
@Test
public void matchExcludeKeysScenarioPositive() throws RbvException {
    // remove first piece of default MetaData
    this.newData = new ArrayList<MetaData>();
    MetaData meta = new DbMetaData();
    meta.putProperty(META_KEY_1, MOD_META_VALUE_1 + 1);
    meta.putProperty(META_KEY_2, META_VALUE_2 + 1);
    meta.putProperty(META_KEY_3, META_VALUE_3 + 1);
    meta.putProperty(META_KEY_4, META_VALUE_4 + 1);
    this.newData.add(meta);
    meta = new DbMetaData();
    meta.putProperty(META_KEY_1, META_VALUE_1 + 2);
    meta.putProperty(META_KEY_2, MOD_META_VALUE_2 + 2);
    meta.putProperty(META_KEY_3, META_VALUE_3 + 2);
    meta.putProperty(META_KEY_4, META_VALUE_4 + 2);
    this.newData.add(meta);
    meta = new DbMetaData();
    meta.putProperty(META_KEY_1, META_VALUE_1 + 3);
    meta.putProperty(META_KEY_2, META_VALUE_2 + 3);
    meta.putProperty(META_KEY_3, META_VALUE_3 + 3);
    meta.putProperty(META_KEY_4, META_VALUE_4 + 3);
    this.newData.add(meta);
    DbStringFieldRule keyRule = new DbStringFieldRule(TABLE_NAME, COLUMN_NAME_2, META_VALUE_2 + 1, DbStringFieldRule.MatchRelation.EQUALS, "key_rule", true);
    DbStringFieldRule matchingRule = new DbStringFieldRule(TABLE_NAME, COLUMN_NAME_1, MOD_META_VALUE_1 + 1, DbStringFieldRule.MatchRelation.EQUALS, "match_metakey_1", true);
    SnapshotExecutor executor = new SnapshotExecutor(this.snapshot);
    executor.addRule(keyRule, matchingRule);
    List<String> list = new ArrayList<String>();
    list.add(META_KEY_2);
    executor.excludeKeys(list);
    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) ArrayList(java.util.ArrayList) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 34 with DbMetaData

use of com.axway.ats.rbv.db.DbMetaData in project ats-framework by Axway.

the class Test_SnapshotExecutor method setUp.

/**
     * Build up {@link MetaData} to use in the test
     * @throws IOException
     * @throws RbvException
     */
@Before
public void setUp() throws IOException, RbvException {
    this.snapshot = new ArrayList<MetaData>();
    this.newData = new ArrayList<MetaData>();
    DbMetaData meta = new DbMetaData();
    meta.putProperty(META_KEY_1, META_VALUE_1 + 1);
    meta.putProperty(META_KEY_2, META_VALUE_2 + 1);
    meta.putProperty(META_KEY_3, META_VALUE_3 + 1);
    meta.putProperty(META_KEY_4, META_VALUE_4 + 1);
    this.snapshot.add(meta);
    this.newData.add(meta);
    meta = new DbMetaData();
    meta.putProperty(META_KEY_1, META_VALUE_1 + 2);
    meta.putProperty(META_KEY_2, META_VALUE_2 + 2);
    meta.putProperty(META_KEY_3, META_VALUE_3 + 2);
    meta.putProperty(META_KEY_4, META_VALUE_4 + 2);
    this.snapshot.add(meta);
    meta = new DbMetaData();
    meta.putProperty(META_KEY_1, META_VALUE_1 + 3);
    meta.putProperty(META_KEY_2, META_VALUE_2 + 3);
    meta.putProperty(META_KEY_3, META_VALUE_3 + 3);
    meta.putProperty(META_KEY_4, META_VALUE_4 + 3);
    this.snapshot.add(meta);
    this.newData.add(meta);
}
Also used : DbMetaData(com.axway.ats.rbv.db.DbMetaData) DbMetaData(com.axway.ats.rbv.db.DbMetaData) MetaData(com.axway.ats.rbv.MetaData) Before(org.junit.Before)

Example 35 with DbMetaData

use of com.axway.ats.rbv.db.DbMetaData in project ats-framework by Axway.

the class Test_DbStringFieldRule method isMatchExpectedFalseMultipleRulesPositiveDontMatch.

@Test
public void isMatchExpectedFalseMultipleRulesPositiveDontMatch() throws RbvException {
    DbMetaData metaData = new DbMetaData();
    metaData.putProperty("test1", "test");
    metaData.putProperty("test2", "test123");
    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

DbMetaData (com.axway.ats.rbv.db.DbMetaData)57 BaseTest (com.axway.ats.rbv.BaseTest)50 Test (org.junit.Test)50 AndRuleOperation (com.axway.ats.rbv.rules.AndRuleOperation)20 MetaData (com.axway.ats.rbv.MetaData)16 DbStringFieldRule (com.axway.ats.rbv.db.rules.DbStringFieldRule)15 SnapshotExecutor (com.axway.ats.rbv.executors.SnapshotExecutor)15 MetaDataIncorrectException (com.axway.ats.rbv.model.MetaDataIncorrectException)4 ArrayList (java.util.ArrayList)2 DbMetaDataKey (com.axway.ats.rbv.db.DbMetaDataKey)1 DbDateFieldRule (com.axway.ats.rbv.db.rules.DbDateFieldRule)1 RbvException (com.axway.ats.rbv.model.RbvException)1 Rule (com.axway.ats.rbv.rules.Rule)1 Calendar (java.util.Calendar)1 Pattern (java.util.regex.Pattern)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1