Exemplo n.º 1
0
  /** Make sure Invariants are executed! */
  @Test
  public void testInvariants() {
    // state2.equals(state3)
    StateVertex state2 = new StateVertex("state2", "<table><div>state2</div></table>");
    StateVertex state3 = new StateVertex("state3", "<table><div>state2</div></table>");

    hit = false;
    ImmutableList<Invariant> iList =
        ImmutableList.of(
            new Invariant(
                "Test123",
                new Condition() {

                  @Override
                  public NodeList getAffectedNodes() {
                    return null;
                  }

                  @Override
                  public boolean check(EmbeddedBrowser browser) {
                    hit = true;
                    return false;
                  }
                }));
    StateMachine smLocal =
        new StateMachine(new StateFlowGraph(index), index, iList, Plugins.noPlugins());

    Eventable c = new Eventable(new Identification(How.xpath, "/bla"), EventType.click);

    assertTrue(smLocal.updateAndCheckIfClone(c, state2, dummyBrowser, new CrawlSession(dummyPool)));

    // New State so hit must be true;
    assertTrue("Invariants are exeucted", hit);
    hit = false;
    assertFalse("Hit reseted", hit);

    Eventable c2 = new Eventable(new Identification(How.xpath, "/bla"), EventType.click);

    assertFalse(
        smLocal.updateAndCheckIfClone(c2, state3, dummyBrowser, new CrawlSession(dummyPool)));
    // CLONE State so hit must be true;
    assertTrue("Invariants are exeucted", hit);
  }
Exemplo n.º 2
0
 /** Run before every test case. */
 @Before
 public void initStateMachine() {
   StateFlowGraph sfg = new StateFlowGraph(index);
   sm = new StateMachine(sfg, index, ImmutableList.<Invariant>of(), Plugins.noPlugins());
 }