verifyZeroInteractions(userServiceMock);
}
@Test
public void registerUserAccount_NormalRegistration_ShouldCreateNewUserAccountAndRenderHomePage() throws Exception {
User registered = new UserBuilder()
.id(1L)
.email(EMAIL)
.firstName(FIRST_NAME)
.lastName(LAST_NAME)
.password(PASSWORD)
.build();
when(userServiceMock.registerNewUserAccount(isA(RegistrationForm.class))).thenReturn(registered);
mockMvc.perform(post("/user/register")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.param(WebTestConstants.FORM_FIELD_EMAIL, EMAIL)
.param(WebTestConstants.FORM_FIELD_FIRST_NAME, FIRST_NAME)
.param(WebTestConstants.FORM_FIELD_LAST_NAME, LAST_NAME)
.param(WebTestConstants.FORM_FIELD_PASSWORD, PASSWORD)
.param(WebTestConstants.FORM_FIELD_PASSWORD_VERIFICATION, PASSWORD)
.sessionAttr(WebTestConstants.SESSION_ATTRIBUTE_USER_FORM, new RegistrationForm())
)
.andExpect(status().isMovedTemporarily())
.andExpect(redirectedUrl("/"));
assertThat(SecurityContextHolder.getContext())
.loggedInUserIs(registered)
.loggedInUserHasPassword(registered.getPassword())
.loggedInUserIsRegisteredByUsingNormalRegistration();
ArgumentCaptor<RegistrationForm> registrationFormArgument = ArgumentCaptor.forClass(RegistrationForm.class);
verify(userServiceMock, times(1)).registerNewUserAccount(registrationFormArgument.capture());
verifyNoMoreInteractions(userServiceMock);