Search in sources :

Example 36 with DbMetaData

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

the class Test_DbStringFieldRule method isMatchExpectedTrueNegative.

@Test
public void isMatchExpectedTrueNegative() throws RbvException {
    DbMetaData metaData = new DbMetaData();
    metaData.putProperty("test1", "test123");
    assertFalse(ruleTest1ExpectTrue.isMatch(metaData));
}
Also used : DbMetaData(com.axway.ats.rbv.db.DbMetaData) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 37 with DbMetaData

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

the class Test_DbStringFieldRule method isMatchExpectedTruePositive.

@Test
public void isMatchExpectedTruePositive() throws RbvException {
    DbMetaData metaData = new DbMetaData();
    metaData.putProperty("test1", "test");
    assertTrue(ruleTest1ExpectTrue.isMatch(metaData));
}
Also used : DbMetaData(com.axway.ats.rbv.db.DbMetaData) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 38 with DbMetaData

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

the class Test_DbStringFieldRule method isMatchExpectedFalseNegative.

@Test
public void isMatchExpectedFalseNegative() throws RbvException {
    DbMetaData metaData = new DbMetaData();
    metaData.putProperty("test1", "test");
    assertFalse(ruleTest1ExpectFalse.isMatch(metaData));
}
Also used : DbMetaData(com.axway.ats.rbv.db.DbMetaData) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 39 with DbMetaData

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

the class DbDateFieldRule method performMatch.

@Override
protected boolean performMatch(MetaData metaData) throws RbvException {
    //this cast is safe, as isMatch has already checked the type of meta data            
    DbMetaData dbMetaData = (DbMetaData) metaData;
    Object actualValue = dbMetaData.getProperty(this.expectedMetaDataKey.toString());
    // check for null
    if (this.expectedValue == null) {
        if (actualValue == null) {
            return true;
        }
        return false;
    }
    // expected value is not null, but if actual is null then we have a negative match
    if (actualValue == null) {
        return false;
    }
    if (expectedValue instanceof String) {
        return checkString(dbMetaData);
    }
    return checkDate(dbMetaData);
}
Also used : DbMetaData(com.axway.ats.rbv.db.DbMetaData)

Example 40 with DbMetaData

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

the class DbBinaryFieldRule method performMatch.

@Override
protected boolean performMatch(MetaData metaData) throws RbvException {
    boolean actualResult = false;
    //this cast is safe, as isMatch has already checked the type of meta data            
    DbMetaData dbMetaData = (DbMetaData) metaData;
    byte[] actualValue;
    try {
        actualValue = (byte[]) dbMetaData.getProperty(expectedMetaDataKey.toString());
    } catch (ClassCastException cce) {
        throw new MetaDataIncorrectException("Meta data is incorrect - expected byte[]");
    }
    if (Arrays.equals((byte[]) expectedValue, actualValue)) {
        actualResult = true;
    }
    return actualResult;
}
Also used : DbMetaData(com.axway.ats.rbv.db.DbMetaData) MetaDataIncorrectException(com.axway.ats.rbv.model.MetaDataIncorrectException)

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