use of com.axway.ats.rbv.db.rules.DbStringFieldRule in project ats-framework by Axway.
the class Test_SimpleMonitorListener method monitorStartTwice.
@Test(expected = RbvException.class)
public void monitorStartTwice() throws RbvException {
DbFieldsRule dbRule = new DbStringFieldRule("", "key1", "value10", MatchRelation.EQUALS, "monitorStartTwice", 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);
monitor.start(listener);
monitor.start(listener);
}
use of com.axway.ats.rbv.db.rules.DbStringFieldRule in project ats-framework by Axway.
the class Test_SimpleMonitorListener method evaluateMonitorsOneMonitorExpectedFalsePositive.
@Test
public void evaluateMonitorsOneMonitorExpectedFalsePositive() throws RbvException {
DbFieldsRule dbRule = new DbStringFieldRule("", "key1", "value101", MatchRelation.EQUALS, "evaluateMonitorsOneMonitorExpectedFalsePositive", true);
Monitor monitor = new Monitor("monitor1", matchable, dbRule, pollingParams, false, false, false);
List<Monitor> monitors = new ArrayList<Monitor>();
monitors.add(monitor);
SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
assertTrue(listener.evaluateMonitors(TIME_END_POLL));
}
use of com.axway.ats.rbv.db.rules.DbStringFieldRule in project ats-framework by Axway.
the class Test_SimpleMonitorListener method evaluateMonitorsMultipleMonitorsPositive.
@Test
public void evaluateMonitorsMultipleMonitorsPositive() 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, "evaluateMonitorsMultipleMonitorsPositive", 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);
assertTrue(listener.evaluateMonitors(TIME_END_POLL));
}
use of com.axway.ats.rbv.db.rules.DbStringFieldRule in project ats-framework by Axway.
the class Test_SimpleMonitorListener method monitorGetAllMachingMetaDataEndOnFirstMatch.
@Test
public void monitorGetAllMachingMetaDataEndOnFirstMatch() 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("It's not a first match!", after - before < TIME_BEFORE_END_POLL);
List<MetaData> matchingMetaData = monitor.getAllMatchedMetaData();
assertEquals(1, matchingMetaData.size());
String value = (String) matchingMetaData.get(0).getProperty("key1");
//there is no guarantee for the hash map order so we check for both possible values
assertTrue(value.equals("value00") || value.equals("value10"));
}
use of com.axway.ats.rbv.db.rules.DbStringFieldRule in project ats-framework by Axway.
the class Test_SimpleMonitorListener method verifyNeverMatches_ButHasAMatch.
@Test
public void verifyNeverMatches_ButHasAMatch() throws RbvException {
DbFieldsRule dbRule = new DbStringFieldRule("", "test_key", "test_value", MatchRelation.EQUALS, "verifyNeverMatches_ButHasAMatch", true);
Monitor monitor = new Monitor("monitor1", matchable, dbRule, pollingParams, false, false, true);
List<Monitor> monitors = new ArrayList<Monitor>();
monitors.add(monitor);
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);
}
Aggregations