You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why is my model validator spring bean not called when I trigger a transition?
First here is my flow configuration:
<on-start>
<!-- Build the form used by the view states -->
<evaluateexpression="grantPHRAccessFormFactory.getForm(externalContext.sessionMap.get('currentPerson'))"result="flowScope.grantPHRAccessForm"/>
</on-start>
<view-stateid="enterEmail"view="grant-phr-access/enter-email"model="grantPHRAccessForm">
<transitionon="next"to="checkIfIsEmailForNewUserKnown"validate="true"/>
<transitionon="cancel"to="cancel"/>
</view-state>
<decision-stateid="checkIfIsEmailForNewUserKnown">
<iftest="grantPHRAccessForm.isEmailForNewUserKnown()"then="checkIfUserAlreadyExistForEmail"else="createNewUser"/>
</decision-state>
<decision-stateid="checkIfUserAlreadyExistForEmail">
<iftest="userServiceImpl.findByEmailNotDeleted(grantPHRAccessForm.emailForNewUser).size() > 0"then="grantAccessToExistingPersonAccount"else="createNewUser"/>
</decision-state>
<view-stateid="grantAccessToExistingPersonAccount"view="grant-phr-access/existing-person-account">
<transitionon="back"to="enterEmail"/>
<transitionon="next"to="doYouWantToGenerateNewPassword"/>
<transitionon="cancel"to="cancel"/>
</view-state>
<view-stateid="createNewUser"view="grant-phr-access/create-new-user"model="grantPHRAccessForm">
<transitionon="back"to="enterEmail"/>
<transitionon="next"to="communicateCredentials"/>
<transitionon="cancel"to="cancel"validate="false"/>
</view-state>
Here is my flow execution test with its configuration:
@AutowiredprivateGrantPHRAccessFormValidatorgrantPHRAccessFormValidator;
@OverrideprotectedFlowDefinitionResourcegetResource(FlowDefinitionResourceFactoryflowDefinitionResourceFactory) {
returnflowDefinitionResourceFactory.createFileResource("src/main/webapp/WEB-INF/flows/grant-phr-access.xml");
}
@OverrideprotectedvoidconfigureFlowBuilderContext(MockFlowBuilderContextbuilderContext) {
builderContext.registerBean("grantPHRAccessFormValidator", grantPHRAccessFormValidator);
builderContext.registerBean("GrantPHRAccessFormValidator", grantPHRAccessFormValidator);
}
@TestpublicvoidtransitionFromEmailToCreateNewPersonAccountTest() {
// ToolfinalGrantPHRAccessFormgrantPHRAccessForm = GrantPHRAccessForm.builder() //
.isEmailForNewUserKnown(false) //
.build();
// Configure data for this testcontext.getSessionMap().put("currentPerson", newPerson());
when(grantPHRAccessFormFactory.getForm(any(Person.class))).thenReturn(grantPHRAccessForm);
// Start the flow, trigger event and check if we went through the correct states in the order expectedstartFlow(context);
assertCurrentStateEquals("enterEmail");
context.setEventId("next");
resumeFlow(context);
assertCurrentStateEquals("createNewUser");
verify(grantPHRAccessFormValidator, times(1)).validateEnterEmail(grantPHRAccessForm, any(ValidationContext.class));
}
My code goes through the states I expected but the "grantPHRAccessFormValidator.validateEnterEmail()" method is not triggered.
Do I have to simulate somehow a "submit form" instead of the "context.setEventId("next");"
Or do I have to register the "grantPHRAccessFormValidator" bean in another way?
Thank you for you support.
Best regards
The text was updated successfully, but these errors were encountered:
Hi
I'm writing flow execution tests
Why is my model validator spring bean not called when I trigger a transition?
First here is my flow configuration:
Here is my flow execution test with its configuration:
And here is my model validator bean:
My code goes through the states I expected but the "grantPHRAccessFormValidator.validateEnterEmail()" method is not triggered.
Do I have to simulate somehow a "submit form" instead of the "context.setEventId("next");"
Or do I have to register the "grantPHRAccessFormValidator" bean in another way?
Thank you for you support.
Best regards
The text was updated successfully, but these errors were encountered: