ActionCondition extends AbstractCondition { @Override public boolean isSatisfied(TestContext context) { if (action == null) { return false; } try { action.execute(context); } catch (Exception e) { this.caughtException = e; log.warn(String.format("Nested action did not perform as expected - %s", Optional.ofNullable(e.getMessage()) .map(msg -> e.getClass().getName() + ": " + msg) .orElse(e.getClass().getName()))); return false; } return true; } ActionCondition();  ActionCondition(TestAction action); @Override boolean isSatisfied(TestContext context); @Override String getSuccessMessage(TestContext context); @Override String getErrorMessage(TestContext context); TestAction getAction(); void setAction(TestAction action); Exception getCaughtException(); void setCaughtException(Exception caughtException); @Override String toString();  }
@Test public void isSatisfiedShouldSucceed() { ActionCondition testling = new ActionCondition(new EchoAction.Builder().build()); Assert.assertTrue(testling.isSatisfied(context)); }
@Test public void isSatisfiedShouldFail() { ActionCondition testling = new ActionCondition(new FailAction.Builder().message("Fail!").build()); when(context.replaceDynamicContentInString("Fail!")).thenReturn("Fail!"); Assert.assertFalse(testling.isSatisfied(context)); }