public void registerUserShouldFailIfPluginThrowsUnexpectedErrorException() throws Exception {
RegisterUserDto userDto = createRegisterUserDto("username", "password", "email@email.em", null);
RegistrationPlugin plugin = mock(RegistrationPlugin.class);
when(plugin.getState()).thenReturn(Plugin.State.ENABLED);
when(plugin.registerUser(userDto.getUserDto(), 1L))
.thenThrow(new UnexpectedErrorException());
when(pluginService.getRegistrationPlugins()).thenReturn(
new ImmutableMap.Builder<Long, RegistrationPlugin>().put(1L, plugin).build());
authenticator.register(userDto);
}