Exemplo n.º 1
0
  @Test
  public void failureSelector() {
    final CountedBehavior goal = new CountedBehavior(BehaviorStatus.SUCCESS);
    CountedBehavior goal2 = new CountedBehavior(BehaviorStatus.FAILURE);
    Selector p =
        Selector.selecting(goal2, goal)
            .selectionFunction(
                new Function<List<Behavior>, Behavior>() {
                  int idx;

                  @Override
                  public Behavior apply(List<Behavior> input) {
                    Behavior b = input.get(idx++);
                    if (idx >= input.size()) idx = 0;
                    return b;
                  }
                })
            .retryChildren()
            .build();
    test.addGoal(p, 1);
    test.run();
    assertThat("Reset count first", goal.resetCount, is(1));
    assertThat("Run count first", goal.runCount, is(1));
    assertThat("Should execute count first", goal.shouldExecuteCount, is(1));
    assertThat("Reset count second", goal2.resetCount, is(1));
    assertThat("Run count second", goal2.runCount, is(1));
    assertThat("Should execute count second", goal2.shouldExecuteCount, is(1));
  }
Exemplo n.º 2
0
 @Test
 public void singleSelector() {
   CountedBehavior goal = new CountedBehavior(BehaviorStatus.SUCCESS);
   Selector p = Selector.selecting(goal).build();
   test.addGoal(p, 1);
   test.run();
   assertThat("Reset count", goal.resetCount, is(1));
   assertThat("Run count", goal.runCount, is(1));
   assertThat("Should execute count", goal.shouldExecuteCount, is(1));
 }