I do have those lines in my code. I really don't see the problem so I'll post the code.
manager-flow:
Code:
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<secured attributes="ROLE_SUPER_MANAGER, ROLE_SECTION_MANAGER" match="any"/>
<var name="dataManager" class="ch.unibe.iam.applicationManager.service.DataManager" />
<!--
view states
-->
<view-state id="manager_welcome" view="/manager/manager_welcome">
<on-entry>
<evaluate expression="dataManager.getUser(currentUser)" result="flowScope.currentAppUser"/>
<set name="flowScope.currentRole" value="currentAppUser.getAuthority()" />
<set name="flowScope.currentState" value="flowExecutionContext.activeSession.state.id" />
</on-entry>
<on-render>
<evaluate expression="dataManager.getLatestDossiers(flowExecutionUrl, currentAppUser)" result="flowScope.latestDossiersByState"/>
</on-render>
<transition on="select_dossier_action" to="view_dossier">
<evaluate expression="dataManager.getDossier(requestParameters.dossier)" result="flowScope.currentDossier"/>
</transition>
</view-state>
...
test:
Code:
public class ManagerWelcomeTest extends AbstractXmlFlowExecutionTests{
private IDataManager dataManager;
private MockExternalContext context;
protected void setUp() {
this.context = new MockExternalContext();
this.dataManager = createStrictMock(IDataManager.class);
}
@Override
protected FlowDefinitionResource getResource(
FlowDefinitionResourceFactory resourceFactory) {
return resourceFactory.createFileResource(
"src/main/webapp/WEB-INF/flows/manager-flow.xml");
}
@Override
protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext) {
builderContext.registerBean("dataManager", this.dataManager);
}
/*
* Test cases
*/
public void testStartManagerFlow() {
User user = new User();
user.setAuthority(Role.USER.getRoleName());
PrincipalSpringSecurityUserToken authToken = new PrincipalSpringSecurityUserToken(
"key", "username", "password", new GrantedAuthority[]{
new GrantedAuthorityImpl(Role.USER.getRoleName())
}, user);
this.context.setCurrentUser(authToken);
expect(this.dataManager.getUser(authToken)).andReturn(user);
replay(this.dataManager);
startFlow(this.context);
assertCurrentStateEquals("manager_welcome");
verify(this.dataManager);
}
...
The line causing the exception is this one in the flow:
Code:
<set name="flowScope.currentRole" value="currentAppUser.getAuthority()" />
and this line in the test:
Code:
startFlow(this.context);
That should be all of the relevant code. Please let me know if you need to see more.