Search in sources :

Example 6 with Monitor

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

the class Test_SimpleMonitorListener method evaluateMonitorsMultipleMonitorsEndOnFirstMatchNegative.

@Test
public void evaluateMonitorsMultipleMonitorsEndOnFirstMatchNegative() 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 dbRuleRight = new DbStringFieldRule("", "key1", "value10", MatchRelation.EQUALS, "evaluateMonitorsMultipleMonitorsEndOnFirstMatchNegative1", true);
    DbFieldsRule dbRuleWrong = new DbStringFieldRule("", "table1", "value10", MatchRelation.EQUALS, "evaluateMonitorsMultipleMonitorsEndOnFirstMatchNegative2", true);
    Monitor monitor1 = new Monitor("monitor1", matchable1, dbRuleRight, pollingParams, true, true, false);
    Monitor monitor2 = new Monitor("monitor2", matchable2, dbRuleRight, pollingParams, true, true, false);
    Monitor monitor3 = new Monitor("monitor3", matchable3, dbRuleWrong, pollingParams, true, true, false);
    List<Monitor> monitors = new ArrayList<Monitor>();
    monitors.add(monitor1);
    monitors.add(monitor2);
    monitors.add(monitor3);
    SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
    assertFalse(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 7 with Monitor

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

the class Test_SimpleMonitorListener method verifyNeverMatches_NoMatchAllTheTime.

@Test
public void verifyNeverMatches_NoMatchAllTheTime() throws RbvException {
    DbFieldsRule dbRule = new DbStringFieldRule("", "test_key", "test_value_00", MatchRelation.EQUALS, "NoMatchAllTheTime", 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();
    assertTrue(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)

Example 8 with Monitor

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

the class Test_SimpleMonitorListener method evaluateMonitorsOneMonitorNegative.

@Test
public void evaluateMonitorsOneMonitorNegative() throws RbvException {
    DbFieldsRule dbRule = new DbStringFieldRule("", "table1", "value10", MatchRelation.EQUALS, "evaluateMonitorsOneMonitorNegative", 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);
    assertFalse(listener.evaluateMonitors(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 9 with Monitor

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

the class Test_SimpleMonitorListener method verifyNoMatch_IntiallyFoundAMatch_ButThenNoMatch.

@Test
public void verifyNoMatch_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, false, true, false);
    List<Monitor> monitors = new ArrayList<Monitor>();
    monitors.add(monitor);
    changeDBValues(3 * POLLING_INTERVAL);
    SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
    long before = System.currentTimeMillis();
    assertTrue(listener.evaluateMonitors(TIME_END_POLL));
    long after = System.currentTimeMillis();
    System.out.println("verifyNoMatch_IntiallyFoundAMatch_ButThenNoMatch: Actual time for monitor evaliation: " + (after - before) + "ms.");
    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 10 with Monitor

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

the class Test_SimpleMonitorListener method monitorGetMatchable.

@Test
public void monitorGetMatchable() throws RbvException {
    DbFieldsRule dbRule = new DbStringFieldRule("", "key1", "value10", MatchRelation.EQUALS, "monitorGetMatchable", true);
    Monitor monitor = new Monitor("monitor1", matchable, dbRule, pollingParams, true, false, false);
    assertEquals(matchable, monitor.getMatchable());
}
Also used : Monitor(com.axway.ats.rbv.Monitor) DbFieldsRule(com.axway.ats.rbv.db.rules.DbFieldsRule) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) Test(org.junit.Test)

Aggregations

Monitor (com.axway.ats.rbv.Monitor)34 SimpleMonitorListener (com.axway.ats.rbv.SimpleMonitorListener)33 DbFieldsRule (com.axway.ats.rbv.db.rules.DbFieldsRule)33 DbStringFieldRule (com.axway.ats.rbv.db.rules.DbStringFieldRule)33 ArrayList (java.util.ArrayList)33 Test (org.junit.Test)33 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 PollingParameters (com.axway.ats.rbv.PollingParameters)4 MetaData (com.axway.ats.rbv.MetaData)2 ConfigurationException (com.axway.ats.config.exceptions.ConfigurationException)1 RbvException (com.axway.ats.rbv.model.RbvException)1 RbvVerificationException (com.axway.ats.rbv.model.RbvVerificationException)1