Search in sources :

Example 51 with DbStringFieldRule

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

the class Test_SimpleMonitorListener method verifyAlwaysHasAMatch_IntiallyFoundAMatch_ButThenNoMatch.

@Test
public void verifyAlwaysHasAMatch_IntiallyFoundAMatch_ButThenNoMatch() throws RbvException {
    DbFieldsRule dbRule = new DbStringFieldRule("", "test_key", "test_value", MatchRelation.EQUALS, "IntiallyFoundAMatch_ButThenNoMatch", true);
    Monitor monitor = new Monitor("monitor1", matchable, dbRule, pollingParams, true, false, true);
    List<Monitor> monitors = new ArrayList<Monitor>();
    monitors.add(monitor);
    changeDBValues(3 * POLLING_INTERVAL);
    SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
    long before = System.currentTimeMillis();
    assertFalse(listener.evaluateMonitors(TIME_END_POLL));
    long after = System.currentTimeMillis();
    assertTrue(after - before > TIME_AFTER_START_POLL && after - before < TIME_END_POLL);
}
Also used : Monitor(com.axway.ats.rbv.Monitor) SimpleMonitorListener(com.axway.ats.rbv.SimpleMonitorListener) ArrayList(java.util.ArrayList) DbFieldsRule(com.axway.ats.rbv.db.rules.DbFieldsRule) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) Test(org.junit.Test)

Example 52 with DbStringFieldRule

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

the class Test_SimpleMonitorListener method evaluateMonitorsMultipleMonitorsEndOnFirstMatchExpectedFalsePositive.

@Test
public void evaluateMonitorsMultipleMonitorsEndOnFirstMatchExpectedFalsePositive() throws RbvException {
    PollingParameters longPollingParams = new PollingParameters(0, 5000, 10);
    DbStorage storage = new DbStorage(new MockDbProvider());
    Matchable matchable1 = storage.getFolder(new DbSearchTerm(""));
    Matchable matchable2 = storage.getFolder(new DbSearchTerm(""));
    Matchable matchable3 = storage.getFolder(new DbSearchTerm(""));
    DbFieldsRule dbRule = new DbStringFieldRule("", "key1", "value2345", MatchRelation.EQUALS, "evaluateMonitorsMultipleMonitorsEndOnFirstMatchPositive", true);
    Monitor monitor1 = new Monitor("monitor1", matchable1, dbRule, longPollingParams, false, true, false);
    Monitor monitor2 = new Monitor("monitor2", matchable2, dbRule, longPollingParams, false, true, false);
    Monitor monitor3 = new Monitor("monitor3", matchable3, dbRule, longPollingParams, false, true, false);
    List<Monitor> monitors = new ArrayList<Monitor>();
    monitors.add(monitor1);
    monitors.add(monitor2);
    monitors.add(monitor3);
    long timeBefore = Calendar.getInstance().getTimeInMillis();
    SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
    listener.evaluateMonitors(TIME_END_POLL);
    long timeAfter = Calendar.getInstance().getTimeInMillis();
    //make sure less than (3 * poling interval) seconds have passed
    //this means that only one iteration was made
    assertTrue(timeAfter - timeBefore < 3 * POLLING_INTERVAL - 500);
}
Also used : Monitor(com.axway.ats.rbv.Monitor) DbStorage(com.axway.ats.rbv.db.DbStorage) SimpleMonitorListener(com.axway.ats.rbv.SimpleMonitorListener) DbSearchTerm(com.axway.ats.rbv.db.DbSearchTerm) ArrayList(java.util.ArrayList) DbFieldsRule(com.axway.ats.rbv.db.rules.DbFieldsRule) PollingParameters(com.axway.ats.rbv.PollingParameters) MockDbProvider(com.axway.ats.rbv.db.MockDbProvider) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) Matchable(com.axway.ats.rbv.storage.Matchable) Test(org.junit.Test)

Example 53 with DbStringFieldRule

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

the class Test_SimpleMonitorListener method monitorGetFirstMachingMetaDataNull.

@Test
public void monitorGetFirstMachingMetaDataNull() throws RbvException {
    DbFieldsRule dbRule = new DbStringFieldRule("", "table1", "value10", MatchRelation.EQUALS, "monitorGetFirstMachingMetaDataNull", true);
    Monitor monitor = new Monitor("monitor1", matchable, dbRule, pollingParams, true, false, false);
    List<Monitor> monitors = new ArrayList<Monitor>();
    monitors.add(monitor);
    SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
    listener.evaluateMonitors(TIME_END_POLL);
    assertEquals(null, monitor.getFirstMatchedMetaData());
}
Also used : Monitor(com.axway.ats.rbv.Monitor) SimpleMonitorListener(com.axway.ats.rbv.SimpleMonitorListener) ArrayList(java.util.ArrayList) DbFieldsRule(com.axway.ats.rbv.db.rules.DbFieldsRule) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) Test(org.junit.Test)

Example 54 with DbStringFieldRule

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

the class Test_SimpleMonitorListener method evaluateMonitorsMultipleMonitorsStressPositive.

@Test
public void evaluateMonitorsMultipleMonitorsStressPositive() throws RbvException {
    DbStorage storage = new DbStorage(new MockDbProvider());
    Matchable matchable1 = storage.getFolder(new DbSearchTerm(""));
    Matchable matchable2 = storage.getFolder(new DbSearchTerm(""));
    Matchable matchable3 = storage.getFolder(new DbSearchTerm(""));
    DbFieldsRule dbRule = new DbStringFieldRule("", "key1", "value10", MatchRelation.EQUALS, "evaluateMonitorsMultipleMonitorsStressPositive", true);
    Monitor monitor1 = new Monitor("monitor1", matchable1, dbRule, pollingParams, true, false, false);
    Monitor monitor2 = new Monitor("monitor2", matchable2, dbRule, pollingParams, true, false, false);
    Monitor monitor3 = new Monitor("monitor3", matchable3, dbRule, pollingParams, true, false, false);
    List<Monitor> monitors = new ArrayList<Monitor>();
    monitors.add(monitor1);
    monitors.add(monitor2);
    monitors.add(monitor3);
    SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
    for (int i = 0; i < 5; i++) {
        assertTrue(listener.evaluateMonitors(TIME_END_POLL));
    }
}
Also used : Monitor(com.axway.ats.rbv.Monitor) DbStorage(com.axway.ats.rbv.db.DbStorage) SimpleMonitorListener(com.axway.ats.rbv.SimpleMonitorListener) DbSearchTerm(com.axway.ats.rbv.db.DbSearchTerm) ArrayList(java.util.ArrayList) DbFieldsRule(com.axway.ats.rbv.db.rules.DbFieldsRule) MockDbProvider(com.axway.ats.rbv.db.MockDbProvider) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) Matchable(com.axway.ats.rbv.storage.Matchable) Test(org.junit.Test)

Example 55 with DbStringFieldRule

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

the class Test_SimpleMonitorListener method monitor_EndOnFirstMatch.

@Test
public void monitor_EndOnFirstMatch() throws RbvException {
    DbFieldsRule dbRule = new DbStringFieldRule("", "key1", "value101", MatchRelation.EQUALS, "monitorGetAllMachingMetaDataEndOnFirstMatch", false);
    Monitor monitor = new Monitor("monitor1", matchable, dbRule, pollingParams, true, true, false);
    List<Monitor> monitors = new ArrayList<Monitor>();
    monitors.add(monitor);
    SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
    long before = System.currentTimeMillis();
    listener.evaluateMonitors(TIME_END_POLL);
    long after = System.currentTimeMillis();
    assertTrue(after - before < TIME_BEFORE_END_POLL);
}
Also used : Monitor(com.axway.ats.rbv.Monitor) SimpleMonitorListener(com.axway.ats.rbv.SimpleMonitorListener) ArrayList(java.util.ArrayList) DbFieldsRule(com.axway.ats.rbv.db.rules.DbFieldsRule) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) Test(org.junit.Test)

Aggregations

DbStringFieldRule (com.axway.ats.rbv.db.rules.DbStringFieldRule)64 Test (org.junit.Test)57 ArrayList (java.util.ArrayList)34 Monitor (com.axway.ats.rbv.Monitor)33 DbFieldsRule (com.axway.ats.rbv.db.rules.DbFieldsRule)33 SimpleMonitorListener (com.axway.ats.rbv.SimpleMonitorListener)32 BaseTest (com.axway.ats.rbv.BaseTest)24 MetaData (com.axway.ats.rbv.MetaData)17 DbMetaData (com.axway.ats.rbv.db.DbMetaData)15 SnapshotExecutor (com.axway.ats.rbv.executors.SnapshotExecutor)15 DbSearchTerm (com.axway.ats.rbv.db.DbSearchTerm)8 DbStorage (com.axway.ats.rbv.db.DbStorage)8 MockDbProvider (com.axway.ats.rbv.db.MockDbProvider)8 Matchable (com.axway.ats.rbv.storage.Matchable)8 PublicAtsApi (com.axway.ats.common.PublicAtsApi)7 PollingParameters (com.axway.ats.rbv.PollingParameters)3 AndRuleOperation (com.axway.ats.rbv.rules.AndRuleOperation)2 Rule (com.axway.ats.rbv.rules.Rule)1