I'm developing a Spring webflow, trying to use TDD so I've extended AbstractXmlFlowExecutionTests. I can't see an obvious way to assert what I would have thought would be a simple thing: that a view state has an associated view of a given name. For example, given this flow (excerpt):
<?xml version="1.0" encoding="UTF-8"?>
<flow ...>
...
<view-state id="foo" view="barView">
</view-state>
</flow>
and unit test
public void testAssertFooStateHasBarView() {
...
assertCurrentStateEquals("foo");
assertTrue( getFlowDefinition().getState("confirmation").isViewState());
// Surely there's an easier way...?
ViewState viewState = (ViewState)getFlowDefinition().getState("foo");
View view = viewState.getViewFactory().getView(new MockRequestContext());
// yuck!
assertTrue(view.toString().contains("barView"));
}
Is there a simpler way to assert that state foo
has view barView
?