Source:
<code>public FormValidation doTestConnection(@QueryParameter("baseUrl") final String baseUrl, @QueryParameter("teamDomain") final String teamDomain, @QueryParameter("tokenCredentialId") final String tokenCredentialId, @QueryParameter("botUser") final boolean botUser, @QueryParameter("room") final String room, @QueryParameter("iconEmoji") final String iconEmoji, @QueryParameter("username") final String username, @AncestorInPath Project project) { if (project == null) { Jenkins.get().checkPermission(Jenkins.ADMINISTER); } else { project.checkPermission(Item.CONFIGURE); } try { String targetUrl = baseUrl; if(targetUrl != null && !targetUrl.isEmpty() && !targetUrl.endsWith("/")) { targetUrl += "/"; } if (StringUtils.isEmpty(targetUrl)) { targetUrl = this.baseUrl; } String targetDomain = Util.fixEmpty(teamDomain) != null ? teamDomain : this.teamDomain; String targetRoom = Util.fixEmpty(room) != null ? room : this.room; <START> SlackService testSlackService = getSlackService(new StandardSlackServiceBuilder() <END> .withBaseUrl(targetUrl) .withTeamDomain(targetDomain) .withBotUser(botUser) .withRoomId(targetRoom) .withIconEmoji(iconEmoji) .withUsername(username) ,tokenCredentialId, project ); String message = "Slack/Jenkins plugin: you're all set on " + DisplayURLProvider.get().getRoot(); boolean success = testSlackService.publish(message, "good"); return success ? FormValidation.ok("Success") : FormValidation.error("Failure"); } catch (Exception e) { logger.log(Level.WARNING, "Slack config form validation error", e); return FormValidation.error("Client error : " + e.getMessage()); } }</code><technical_language>suggestion SlackService testSlackService = getSlackService(StandardSlackServiceBuilder.builder()</technical_language>

Target:
public FormValidation doTestConnection(@QueryParameter("baseUrl") final String baseUrl, @QueryParameter("teamDomain") final String teamDomain, @QueryParameter("tokenCredentialId") final String tokenCredentialId, @QueryParameter("botUser") final boolean botUser, @QueryParameter("room") final String room, @QueryParameter("iconEmoji") final String iconEmoji, @QueryParameter("username") final String username, @AncestorInPath Project project) { if (project == null) { Jenkins.get().checkPermission(Jenkins.ADMINISTER); } else { project.checkPermission(Item.CONFIGURE); } try { String targetUrl = baseUrl; if(targetUrl != null && !targetUrl.isEmpty() && !targetUrl.endsWith("/")) { targetUrl += "/"; } if (StringUtils.isEmpty(targetUrl)) { targetUrl = this.baseUrl; } String targetDomain = Util.fixEmpty(teamDomain) != null ? teamDomain : this.teamDomain; String targetRoom = Util.fixEmpty(room) != null ? room : this.room; boolean targetBotUser = botUser || this.botUser; String targetTokenCredentialId = Util.fixEmpty(tokenCredentialId) != null ? tokenCredentialId : this.tokenCredentialId; String targetIconEmoji = Util.fixEmpty(iconEmoji) != null ? iconEmoji : this.iconEmoji; String targetUsername = Util.fixEmpty(username) != null ? username : this.username; SlackService testSlackService = getSlackService(StandardSlackService.builder() .withBaseUrl(targetUrl) .withTeamDomain(targetDomain) .withBotUser(targetBotUser) .withRoomId(targetRoom) .withIconEmoji(targetIconEmoji) .withUsername(targetUsername), targetTokenCredentialId, project ); String message = "Slack/Jenkins plugin: you're all set on " + DisplayURLProvider.get().getRoot(); boolean success = testSlackService.publish(message, "good"); return success ? FormValidation.ok("Success") : FormValidation.error( getErrorMessage(testSlackService.getResponseString()) ); } catch (Exception e) { logger.log(Level.WARNING, "Slack config form validation error", e); return FormValidation.error("Client error : " + e.getMessage()); } }