@Test public void shouldDeleteUser() { stubFor(delete(urlPathEqualTo("/api/users/123456789")) .willReturn(ok())); TestObserver testObserver = userProvider.delete("123456789").test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); }
@Override public Completable delete(String id) { try { DefaultUser deleteUser = new DefaultUser(null); deleteUser.setId(id); AuthenticationContext authenticationContext = new SimpleAuthenticationContext(); TemplateEngine templateEngine = authenticationContext.getTemplateEngine(); templateEngine.getTemplateContext().setVariable(USER_CONTEXT_KEY, deleteUser); final HttpUsersResourceConfiguration usersResourceConfiguration = configuration.getUsersResource(); final HttpResourceConfiguration deleteResourceConfiguration = usersResourceConfiguration.getPaths().getDeleteResource(); final String deleteUserURI = usersResourceConfiguration.getBaseURL() + deleteResourceConfiguration.getBaseURL(); final HttpMethod deleteUserHttpMethod = HttpMethod.valueOf(deleteResourceConfiguration.getHttpMethod().toString()); final List<HttpHeader> deleteUserHttpHeaders = deleteResourceConfiguration.getHttpHeaders(); final String updateUserBody = deleteResourceConfiguration.getHttpBody(); final Single<HttpResponse<Buffer>> requestHandler = processRequest(templateEngine, deleteUserURI, deleteUserHttpMethod, deleteUserHttpHeaders, updateUserBody); return requestHandler .flatMapCompletable(httpResponse -> { final List<HttpResponseErrorCondition> errorConditions = deleteResourceConfiguration.getHttpResponseErrorConditions(); try { processResponse(templateEngine, errorConditions, httpResponse); return Completable.complete(); } catch (Exception ex) { return Completable.error(ex); } }) .onErrorResumeNext(ex -> { if (ex instanceof AbstractManagementException) { return Completable.error(ex); } LOGGER.error("An error has occurred while deleting user {} from the remote HTTP identity provider", id, ex); return Completable.error(new TechnicalManagementException("An error has occurred while deleting user from the remote HTTP identity provider", ex)); }); } catch (Exception ex) { LOGGER.error("An error has occurred while deleting the user {}", id, ex); return Completable.error(new TechnicalManagementException("An error has occurred while deleting the user", ex)); } }
HttpUserProvider implements UserProvider { @Override public Completable delete(String id) { try { DefaultUser deleteUser = new DefaultUser(null); deleteUser.setId(id); AuthenticationContext authenticationContext = new SimpleAuthenticationContext(); TemplateEngine templateEngine = authenticationContext.getTemplateEngine(); templateEngine.getTemplateContext().setVariable(USER_CONTEXT_KEY, deleteUser); final HttpUsersResourceConfiguration usersResourceConfiguration = configuration.getUsersResource(); final HttpResourceConfiguration deleteResourceConfiguration = usersResourceConfiguration.getPaths().getDeleteResource(); final String deleteUserURI = usersResourceConfiguration.getBaseURL() + deleteResourceConfiguration.getBaseURL(); final HttpMethod deleteUserHttpMethod = HttpMethod.valueOf(deleteResourceConfiguration.getHttpMethod().toString()); final List<HttpHeader> deleteUserHttpHeaders = deleteResourceConfiguration.getHttpHeaders(); final String updateUserBody = deleteResourceConfiguration.getHttpBody(); final Single<HttpResponse<Buffer>> requestHandler = processRequest(templateEngine, deleteUserURI, deleteUserHttpMethod, deleteUserHttpHeaders, updateUserBody); return requestHandler .flatMapCompletable(httpResponse -> { final List<HttpResponseErrorCondition> errorConditions = deleteResourceConfiguration.getHttpResponseErrorConditions(); try { processResponse(templateEngine, errorConditions, httpResponse); return Completable.complete(); } catch (Exception ex) { return Completable.error(ex); } }) .onErrorResumeNext(ex -> { if (ex instanceof AbstractManagementException) { return Completable.error(ex); } LOGGER.error("An error has occurred while deleting user {} from the remote HTTP identity provider", id, ex); return Completable.error(new TechnicalManagementException("An error has occurred while deleting user from the remote HTTP identity provider", ex)); }); } catch (Exception ex) { LOGGER.error("An error has occurred while deleting the user {}", id, ex); return Completable.error(new TechnicalManagementException("An error has occurred while deleting the user", ex)); } } }
HttpUserProvider implements UserProvider { @Override public Completable delete(String id) { try { DefaultUser deleteUser = new DefaultUser(null); deleteUser.setId(id); AuthenticationContext authenticationContext = new SimpleAuthenticationContext(); TemplateEngine templateEngine = authenticationContext.getTemplateEngine(); templateEngine.getTemplateContext().setVariable(USER_CONTEXT_KEY, deleteUser); final HttpUsersResourceConfiguration usersResourceConfiguration = configuration.getUsersResource(); final HttpResourceConfiguration deleteResourceConfiguration = usersResourceConfiguration.getPaths().getDeleteResource(); final String deleteUserURI = usersResourceConfiguration.getBaseURL() + deleteResourceConfiguration.getBaseURL(); final HttpMethod deleteUserHttpMethod = HttpMethod.valueOf(deleteResourceConfiguration.getHttpMethod().toString()); final List<HttpHeader> deleteUserHttpHeaders = deleteResourceConfiguration.getHttpHeaders(); final String updateUserBody = deleteResourceConfiguration.getHttpBody(); final Single<HttpResponse<Buffer>> requestHandler = processRequest(templateEngine, deleteUserURI, deleteUserHttpMethod, deleteUserHttpHeaders, updateUserBody); return requestHandler .flatMapCompletable(httpResponse -> { final List<HttpResponseErrorCondition> errorConditions = deleteResourceConfiguration.getHttpResponseErrorConditions(); try { processResponse(templateEngine, errorConditions, httpResponse); return Completable.complete(); } catch (Exception ex) { return Completable.error(ex); } }) .onErrorResumeNext(ex -> { if (ex instanceof AbstractManagementException) { return Completable.error(ex); } LOGGER.error("An error has occurred while deleting user {} from the remote HTTP identity provider", id, ex); return Completable.error(new TechnicalManagementException("An error has occurred while deleting user from the remote HTTP identity provider", ex)); }); } catch (Exception ex) { LOGGER.error("An error has occurred while deleting the user {}", id, ex); return Completable.error(new TechnicalManagementException("An error has occurred while deleting the user", ex)); } }  }
HttpUserProvider implements UserProvider { @Override public Completable delete(String id) { try { DefaultUser deleteUser = new DefaultUser(null); deleteUser.setId(id); AuthenticationContext authenticationContext = new SimpleAuthenticationContext(); TemplateEngine templateEngine = authenticationContext.getTemplateEngine(); templateEngine.getTemplateContext().setVariable(USER_CONTEXT_KEY, deleteUser); final HttpUsersResourceConfiguration usersResourceConfiguration = configuration.getUsersResource(); final HttpResourceConfiguration deleteResourceConfiguration = usersResourceConfiguration.getPaths().getDeleteResource(); final String deleteUserURI = usersResourceConfiguration.getBaseURL() + deleteResourceConfiguration.getBaseURL(); final HttpMethod deleteUserHttpMethod = HttpMethod.valueOf(deleteResourceConfiguration.getHttpMethod().toString()); final List<HttpHeader> deleteUserHttpHeaders = deleteResourceConfiguration.getHttpHeaders(); final String updateUserBody = deleteResourceConfiguration.getHttpBody(); final Single<HttpResponse<Buffer>> requestHandler = processRequest(templateEngine, deleteUserURI, deleteUserHttpMethod, deleteUserHttpHeaders, updateUserBody); return requestHandler .flatMapCompletable(httpResponse -> { final List<HttpResponseErrorCondition> errorConditions = deleteResourceConfiguration.getHttpResponseErrorConditions(); try { processResponse(templateEngine, errorConditions, httpResponse); return Completable.complete(); } catch (Exception ex) { return Completable.error(ex); } }) .onErrorResumeNext(ex -> { if (ex instanceof AbstractManagementException) { return Completable.error(ex); } LOGGER.error("An error has occurred while deleting user {} from the remote HTTP identity provider", id, ex); return Completable.error(new TechnicalManagementException("An error has occurred while deleting user from the remote HTTP identity provider", ex)); }); } catch (Exception ex) { LOGGER.error("An error has occurred while deleting the user {}", id, ex); return Completable.error(new TechnicalManagementException("An error has occurred while deleting the user", ex)); } }  @Override Maybe<User> findByUsername(String username); @Override Single<User> create(User user); @Override Single<User> update(String id, User updateUser); @Override Completable delete(String id); }
HttpUserProvider implements UserProvider { @Override public Completable delete(String id) { try { DefaultUser deleteUser = new DefaultUser(null); deleteUser.setId(id); AuthenticationContext authenticationContext = new SimpleAuthenticationContext(); TemplateEngine templateEngine = authenticationContext.getTemplateEngine(); templateEngine.getTemplateContext().setVariable(USER_CONTEXT_KEY, deleteUser); final HttpUsersResourceConfiguration usersResourceConfiguration = configuration.getUsersResource(); final HttpResourceConfiguration deleteResourceConfiguration = usersResourceConfiguration.getPaths().getDeleteResource(); final String deleteUserURI = usersResourceConfiguration.getBaseURL() + deleteResourceConfiguration.getBaseURL(); final HttpMethod deleteUserHttpMethod = HttpMethod.valueOf(deleteResourceConfiguration.getHttpMethod().toString()); final List<HttpHeader> deleteUserHttpHeaders = deleteResourceConfiguration.getHttpHeaders(); final String updateUserBody = deleteResourceConfiguration.getHttpBody(); final Single<HttpResponse<Buffer>> requestHandler = processRequest(templateEngine, deleteUserURI, deleteUserHttpMethod, deleteUserHttpHeaders, updateUserBody); return requestHandler .flatMapCompletable(httpResponse -> { final List<HttpResponseErrorCondition> errorConditions = deleteResourceConfiguration.getHttpResponseErrorConditions(); try { processResponse(templateEngine, errorConditions, httpResponse); return Completable.complete(); } catch (Exception ex) { return Completable.error(ex); } }) .onErrorResumeNext(ex -> { if (ex instanceof AbstractManagementException) { return Completable.error(ex); } LOGGER.error("An error has occurred while deleting user {} from the remote HTTP identity provider", id, ex); return Completable.error(new TechnicalManagementException("An error has occurred while deleting user from the remote HTTP identity provider", ex)); }); } catch (Exception ex) { LOGGER.error("An error has occurred while deleting the user {}", id, ex); return Completable.error(new TechnicalManagementException("An error has occurred while deleting the user", ex)); } }  @Override Maybe<User> findByUsername(String username); @Override Single<User> create(User user); @Override Single<User> update(String id, User updateUser); @Override Completable delete(String id);  }