@Test public void testGetFromConfig() { String expectedConfigDirectory = "."; ServerPaths serverPaths = mock(ServerPaths.class); when(serverPaths.getConfigDir()).thenReturn(expectedConfigDirectory); BuildState buildState = new BuildState(); SlackNotificationMainSettings mainSettings = new SlackNotificationMainSettings(sBuildServer, serverPaths); mainSettings.readFrom(getFullConfigElement()); SlackNotificationConfig config = new SlackNotificationConfig("", "#general", "teamName", "<default>", true, buildState, true, true, null, true, true, true, true); SlackNotificationListener whl = new SlackNotificationListener(sBuildServer, settings, mainSettings, manager, factory); whl.getFromConfig(slackNotificationImpl, config); assertEquals("myproxy.mycompany.com", slackNotificationImpl.getProxyHost()); assertEquals(8080, slackNotificationImpl.getProxyPort()); }
public void getFromConfig(SlackNotification slackNotification, SlackNotificationConfig slackNotificationConfig){ slackNotification.setChannel(StringUtil.isEmpty(slackNotificationConfig.getChannel()) ? myMainSettings.getDefaultChannel() : slackNotificationConfig.getChannel()); slackNotification.setTeamName(myMainSettings.getTeamName()); slackNotification.setToken(StringUtil.isEmpty(slackNotificationConfig.getToken()) ? myMainSettings.getToken() : slackNotificationConfig.getToken()); slackNotification.setIconUrl(myMainSettings.getIconUrl()); slackNotification.setBotName(myMainSettings.getBotName()); slackNotification.setEnabled(myMainSettings.getEnabled() && slackNotificationConfig.getEnabled()); slackNotification.setBuildStates(slackNotificationConfig.getBuildStates()); slackNotification.setProxy(myMainSettings.getProxyConfig()); slackNotification.setShowBuildAgent(myMainSettings.getShowBuildAgent()); slackNotification.setShowElapsedBuildTime(myMainSettings.getShowElapsedBuildTime()); slackNotification.setShowCommits(myMainSettings.getShowCommits()); slackNotification.setShowCommitters(myMainSettings.getShowCommitters()); slackNotification.setFilterBranchName(slackNotificationConfig.getFilterBranchName()); slackNotification.setShowTriggeredBy(myMainSettings.getShowTriggeredBy()); slackNotification.setShowFailureReason(myMainSettings.getShowFailureReason() == null ? SlackNotificationContentConfig.DEFAULT_SHOW_FAILURE_REASON : myMainSettings.getShowFailureReason()); slackNotification.setMaxCommitsToDisplay(myMainSettings.getMaxCommitsToDisplay()); slackNotification.setMentionChannelEnabled(slackNotificationConfig.getMentionChannelEnabled()); slackNotification.setMentionSlackUserEnabled(slackNotificationConfig.getMentionSlackUserEnabled()); slackNotification.setMentionWhoTriggeredEnabled(slackNotificationConfig.isMentionWhoTriggeredEnabled()); slackNotification.setMentionHereEnabled(slackNotificationConfig.getMentionHereEnabled()); slackNotification.setShowElapsedBuildTime(myMainSettings.getShowElapsedBuildTime()); if(slackNotificationConfig.getContent() != null && slackNotificationConfig.getContent().isEnabled()) { slackNotification.setBotName(slackNotificationConfig.getContent().getBotName()); slackNotification.setIconUrl(slackNotificationConfig.getContent().getIconUrl()); slackNotification.setMaxCommitsToDisplay(slackNotificationConfig.getContent().getMaxCommitsToDisplay()); slackNotification.setShowBuildAgent(slackNotificationConfig.getContent().getShowBuildAgent()); slackNotification.setShowElapsedBuildTime(slackNotificationConfig.getContent().getShowElapsedBuildTime()); slackNotification.setShowCommits(slackNotificationConfig.getContent().getShowCommits()); slackNotification.setShowCommitters(slackNotificationConfig.getContent().getShowCommitters()); slackNotification.setShowTriggeredBy(slackNotificationConfig.getContent().getShowTriggeredBy()); slackNotification.setShowFailureReason(slackNotificationConfig.getContent().getShowFailureReason() == null ? SlackNotificationContentConfig.DEFAULT_SHOW_FAILURE_REASON : slackNotificationConfig.getContent().getShowFailureReason()); } Loggers.ACTIVITIES.debug("SlackNotificationListener :: SlackNotification proxy set to " + slackNotification.getProxyHost() + " for " + slackNotificationConfig.getChannel()); }
SlackNotificationListener extends BuildServerAdapter { public void getFromConfig(SlackNotification slackNotification, SlackNotificationConfig slackNotificationConfig){ slackNotification.setChannel(StringUtil.isEmpty(slackNotificationConfig.getChannel()) ? myMainSettings.getDefaultChannel() : slackNotificationConfig.getChannel()); slackNotification.setTeamName(myMainSettings.getTeamName()); slackNotification.setToken(StringUtil.isEmpty(slackNotificationConfig.getToken()) ? myMainSettings.getToken() : slackNotificationConfig.getToken()); slackNotification.setIconUrl(myMainSettings.getIconUrl()); slackNotification.setBotName(myMainSettings.getBotName()); slackNotification.setEnabled(myMainSettings.getEnabled() && slackNotificationConfig.getEnabled()); slackNotification.setBuildStates(slackNotificationConfig.getBuildStates()); slackNotification.setProxy(myMainSettings.getProxyConfig()); slackNotification.setShowBuildAgent(myMainSettings.getShowBuildAgent()); slackNotification.setShowElapsedBuildTime(myMainSettings.getShowElapsedBuildTime()); slackNotification.setShowCommits(myMainSettings.getShowCommits()); slackNotification.setShowCommitters(myMainSettings.getShowCommitters()); slackNotification.setFilterBranchName(slackNotificationConfig.getFilterBranchName()); slackNotification.setShowTriggeredBy(myMainSettings.getShowTriggeredBy()); slackNotification.setShowFailureReason(myMainSettings.getShowFailureReason() == null ? SlackNotificationContentConfig.DEFAULT_SHOW_FAILURE_REASON : myMainSettings.getShowFailureReason()); slackNotification.setMaxCommitsToDisplay(myMainSettings.getMaxCommitsToDisplay()); slackNotification.setMentionChannelEnabled(slackNotificationConfig.getMentionChannelEnabled()); slackNotification.setMentionSlackUserEnabled(slackNotificationConfig.getMentionSlackUserEnabled()); slackNotification.setMentionWhoTriggeredEnabled(slackNotificationConfig.isMentionWhoTriggeredEnabled()); slackNotification.setMentionHereEnabled(slackNotificationConfig.getMentionHereEnabled()); slackNotification.setShowElapsedBuildTime(myMainSettings.getShowElapsedBuildTime()); if(slackNotificationConfig.getContent() != null && slackNotificationConfig.getContent().isEnabled()) { slackNotification.setBotName(slackNotificationConfig.getContent().getBotName()); slackNotification.setIconUrl(slackNotificationConfig.getContent().getIconUrl()); slackNotification.setMaxCommitsToDisplay(slackNotificationConfig.getContent().getMaxCommitsToDisplay()); slackNotification.setShowBuildAgent(slackNotificationConfig.getContent().getShowBuildAgent()); slackNotification.setShowElapsedBuildTime(slackNotificationConfig.getContent().getShowElapsedBuildTime()); slackNotification.setShowCommits(slackNotificationConfig.getContent().getShowCommits()); slackNotification.setShowCommitters(slackNotificationConfig.getContent().getShowCommitters()); slackNotification.setShowTriggeredBy(slackNotificationConfig.getContent().getShowTriggeredBy()); slackNotification.setShowFailureReason(slackNotificationConfig.getContent().getShowFailureReason() == null ? SlackNotificationContentConfig.DEFAULT_SHOW_FAILURE_REASON : slackNotificationConfig.getContent().getShowFailureReason()); } Loggers.ACTIVITIES.debug("SlackNotificationListener :: SlackNotification proxy set to " + slackNotification.getProxyHost() + " for " + slackNotificationConfig.getChannel()); } }
SlackNotificationListener extends BuildServerAdapter { public void getFromConfig(SlackNotification slackNotification, SlackNotificationConfig slackNotificationConfig){ slackNotification.setChannel(StringUtil.isEmpty(slackNotificationConfig.getChannel()) ? myMainSettings.getDefaultChannel() : slackNotificationConfig.getChannel()); slackNotification.setTeamName(myMainSettings.getTeamName()); slackNotification.setToken(StringUtil.isEmpty(slackNotificationConfig.getToken()) ? myMainSettings.getToken() : slackNotificationConfig.getToken()); slackNotification.setIconUrl(myMainSettings.getIconUrl()); slackNotification.setBotName(myMainSettings.getBotName()); slackNotification.setEnabled(myMainSettings.getEnabled() && slackNotificationConfig.getEnabled()); slackNotification.setBuildStates(slackNotificationConfig.getBuildStates()); slackNotification.setProxy(myMainSettings.getProxyConfig()); slackNotification.setShowBuildAgent(myMainSettings.getShowBuildAgent()); slackNotification.setShowElapsedBuildTime(myMainSettings.getShowElapsedBuildTime()); slackNotification.setShowCommits(myMainSettings.getShowCommits()); slackNotification.setShowCommitters(myMainSettings.getShowCommitters()); slackNotification.setFilterBranchName(slackNotificationConfig.getFilterBranchName()); slackNotification.setShowTriggeredBy(myMainSettings.getShowTriggeredBy()); slackNotification.setShowFailureReason(myMainSettings.getShowFailureReason() == null ? SlackNotificationContentConfig.DEFAULT_SHOW_FAILURE_REASON : myMainSettings.getShowFailureReason()); slackNotification.setMaxCommitsToDisplay(myMainSettings.getMaxCommitsToDisplay()); slackNotification.setMentionChannelEnabled(slackNotificationConfig.getMentionChannelEnabled()); slackNotification.setMentionSlackUserEnabled(slackNotificationConfig.getMentionSlackUserEnabled()); slackNotification.setMentionWhoTriggeredEnabled(slackNotificationConfig.isMentionWhoTriggeredEnabled()); slackNotification.setMentionHereEnabled(slackNotificationConfig.getMentionHereEnabled()); slackNotification.setShowElapsedBuildTime(myMainSettings.getShowElapsedBuildTime()); if(slackNotificationConfig.getContent() != null && slackNotificationConfig.getContent().isEnabled()) { slackNotification.setBotName(slackNotificationConfig.getContent().getBotName()); slackNotification.setIconUrl(slackNotificationConfig.getContent().getIconUrl()); slackNotification.setMaxCommitsToDisplay(slackNotificationConfig.getContent().getMaxCommitsToDisplay()); slackNotification.setShowBuildAgent(slackNotificationConfig.getContent().getShowBuildAgent()); slackNotification.setShowElapsedBuildTime(slackNotificationConfig.getContent().getShowElapsedBuildTime()); slackNotification.setShowCommits(slackNotificationConfig.getContent().getShowCommits()); slackNotification.setShowCommitters(slackNotificationConfig.getContent().getShowCommitters()); slackNotification.setShowTriggeredBy(slackNotificationConfig.getContent().getShowTriggeredBy()); slackNotification.setShowFailureReason(slackNotificationConfig.getContent().getShowFailureReason() == null ? SlackNotificationContentConfig.DEFAULT_SHOW_FAILURE_REASON : slackNotificationConfig.getContent().getShowFailureReason()); } Loggers.ACTIVITIES.debug("SlackNotificationListener :: SlackNotification proxy set to " + slackNotification.getProxyHost() + " for " + slackNotificationConfig.getChannel()); } SlackNotificationListener();  SlackNotificationListener(SBuildServer sBuildServer, ProjectSettingsManager settings,
                                     SlackNotificationMainSettings configSettings, SlackNotificationPayloadManager manager,
                                     SlackNotificationFactory factory); }
SlackNotificationListener extends BuildServerAdapter { public void getFromConfig(SlackNotification slackNotification, SlackNotificationConfig slackNotificationConfig){ slackNotification.setChannel(StringUtil.isEmpty(slackNotificationConfig.getChannel()) ? myMainSettings.getDefaultChannel() : slackNotificationConfig.getChannel()); slackNotification.setTeamName(myMainSettings.getTeamName()); slackNotification.setToken(StringUtil.isEmpty(slackNotificationConfig.getToken()) ? myMainSettings.getToken() : slackNotificationConfig.getToken()); slackNotification.setIconUrl(myMainSettings.getIconUrl()); slackNotification.setBotName(myMainSettings.getBotName()); slackNotification.setEnabled(myMainSettings.getEnabled() && slackNotificationConfig.getEnabled()); slackNotification.setBuildStates(slackNotificationConfig.getBuildStates()); slackNotification.setProxy(myMainSettings.getProxyConfig()); slackNotification.setShowBuildAgent(myMainSettings.getShowBuildAgent()); slackNotification.setShowElapsedBuildTime(myMainSettings.getShowElapsedBuildTime()); slackNotification.setShowCommits(myMainSettings.getShowCommits()); slackNotification.setShowCommitters(myMainSettings.getShowCommitters()); slackNotification.setFilterBranchName(slackNotificationConfig.getFilterBranchName()); slackNotification.setShowTriggeredBy(myMainSettings.getShowTriggeredBy()); slackNotification.setShowFailureReason(myMainSettings.getShowFailureReason() == null ? SlackNotificationContentConfig.DEFAULT_SHOW_FAILURE_REASON : myMainSettings.getShowFailureReason()); slackNotification.setMaxCommitsToDisplay(myMainSettings.getMaxCommitsToDisplay()); slackNotification.setMentionChannelEnabled(slackNotificationConfig.getMentionChannelEnabled()); slackNotification.setMentionSlackUserEnabled(slackNotificationConfig.getMentionSlackUserEnabled()); slackNotification.setMentionWhoTriggeredEnabled(slackNotificationConfig.isMentionWhoTriggeredEnabled()); slackNotification.setMentionHereEnabled(slackNotificationConfig.getMentionHereEnabled()); slackNotification.setShowElapsedBuildTime(myMainSettings.getShowElapsedBuildTime()); if(slackNotificationConfig.getContent() != null && slackNotificationConfig.getContent().isEnabled()) { slackNotification.setBotName(slackNotificationConfig.getContent().getBotName()); slackNotification.setIconUrl(slackNotificationConfig.getContent().getIconUrl()); slackNotification.setMaxCommitsToDisplay(slackNotificationConfig.getContent().getMaxCommitsToDisplay()); slackNotification.setShowBuildAgent(slackNotificationConfig.getContent().getShowBuildAgent()); slackNotification.setShowElapsedBuildTime(slackNotificationConfig.getContent().getShowElapsedBuildTime()); slackNotification.setShowCommits(slackNotificationConfig.getContent().getShowCommits()); slackNotification.setShowCommitters(slackNotificationConfig.getContent().getShowCommitters()); slackNotification.setShowTriggeredBy(slackNotificationConfig.getContent().getShowTriggeredBy()); slackNotification.setShowFailureReason(slackNotificationConfig.getContent().getShowFailureReason() == null ? SlackNotificationContentConfig.DEFAULT_SHOW_FAILURE_REASON : slackNotificationConfig.getContent().getShowFailureReason()); } Loggers.ACTIVITIES.debug("SlackNotificationListener :: SlackNotification proxy set to " + slackNotification.getProxyHost() + " for " + slackNotificationConfig.getChannel()); } SlackNotificationListener();  SlackNotificationListener(SBuildServer sBuildServer, ProjectSettingsManager settings,
                                     SlackNotificationMainSettings configSettings, SlackNotificationPayloadManager manager,
                                     SlackNotificationFactory factory); void register(); void getFromConfig(SlackNotification slackNotification, SlackNotificationConfig slackNotificationConfig); @Override void buildStarted(SRunningBuild sRunningBuild); @Override void buildFinished(SRunningBuild sRunningBuild); @Override void buildInterrupted(SRunningBuild sRunningBuild); @Override void beforeBuildFinish(SRunningBuild sRunningBuild); @Deprecated /** This method has been removed from the TeamCity API as of version 7.1 * * @param sBuildType * @param responsibilityInfoOld * @param responsibilityInfoNew * @param isUserAction */ void responsibleChanged(@NotNull SBuildType sBuildType, 
    							   @NotNull ResponsibilityInfo responsibilityInfoOld, 
    							   @NotNull ResponsibilityInfo responsibilityInfoNew, 
    							   boolean isUserAction); @Override void responsibleChanged(SProject project,
			Collection<TestName> testNames, ResponsibilityEntry entry,
			boolean isUserAction); @Override void responsibleChanged(SProject project, TestNameResponsibilityEntry oldTestNameResponsibilityEntry, TestNameResponsibilityEntry newTestNameResponsibilityEntry, boolean isUserAction); @Override void responsibleChanged(@NotNull SBuildType sBuildType,
            @NotNull ResponsibilityEntry responsibilityEntryOld,
            @NotNull ResponsibilityEntry responsibilityEntryNew); @Override void responsibleRemoved(SProject project, TestNameResponsibilityEntry entry); void doPost(SlackNotification notification); }
SlackNotificationListener extends BuildServerAdapter { public void getFromConfig(SlackNotification slackNotification, SlackNotificationConfig slackNotificationConfig){ slackNotification.setChannel(StringUtil.isEmpty(slackNotificationConfig.getChannel()) ? myMainSettings.getDefaultChannel() : slackNotificationConfig.getChannel()); slackNotification.setTeamName(myMainSettings.getTeamName()); slackNotification.setToken(StringUtil.isEmpty(slackNotificationConfig.getToken()) ? myMainSettings.getToken() : slackNotificationConfig.getToken()); slackNotification.setIconUrl(myMainSettings.getIconUrl()); slackNotification.setBotName(myMainSettings.getBotName()); slackNotification.setEnabled(myMainSettings.getEnabled() && slackNotificationConfig.getEnabled()); slackNotification.setBuildStates(slackNotificationConfig.getBuildStates()); slackNotification.setProxy(myMainSettings.getProxyConfig()); slackNotification.setShowBuildAgent(myMainSettings.getShowBuildAgent()); slackNotification.setShowElapsedBuildTime(myMainSettings.getShowElapsedBuildTime()); slackNotification.setShowCommits(myMainSettings.getShowCommits()); slackNotification.setShowCommitters(myMainSettings.getShowCommitters()); slackNotification.setFilterBranchName(slackNotificationConfig.getFilterBranchName()); slackNotification.setShowTriggeredBy(myMainSettings.getShowTriggeredBy()); slackNotification.setShowFailureReason(myMainSettings.getShowFailureReason() == null ? SlackNotificationContentConfig.DEFAULT_SHOW_FAILURE_REASON : myMainSettings.getShowFailureReason()); slackNotification.setMaxCommitsToDisplay(myMainSettings.getMaxCommitsToDisplay()); slackNotification.setMentionChannelEnabled(slackNotificationConfig.getMentionChannelEnabled()); slackNotification.setMentionSlackUserEnabled(slackNotificationConfig.getMentionSlackUserEnabled()); slackNotification.setMentionWhoTriggeredEnabled(slackNotificationConfig.isMentionWhoTriggeredEnabled()); slackNotification.setMentionHereEnabled(slackNotificationConfig.getMentionHereEnabled()); slackNotification.setShowElapsedBuildTime(myMainSettings.getShowElapsedBuildTime()); if(slackNotificationConfig.getContent() != null && slackNotificationConfig.getContent().isEnabled()) { slackNotification.setBotName(slackNotificationConfig.getContent().getBotName()); slackNotification.setIconUrl(slackNotificationConfig.getContent().getIconUrl()); slackNotification.setMaxCommitsToDisplay(slackNotificationConfig.getContent().getMaxCommitsToDisplay()); slackNotification.setShowBuildAgent(slackNotificationConfig.getContent().getShowBuildAgent()); slackNotification.setShowElapsedBuildTime(slackNotificationConfig.getContent().getShowElapsedBuildTime()); slackNotification.setShowCommits(slackNotificationConfig.getContent().getShowCommits()); slackNotification.setShowCommitters(slackNotificationConfig.getContent().getShowCommitters()); slackNotification.setShowTriggeredBy(slackNotificationConfig.getContent().getShowTriggeredBy()); slackNotification.setShowFailureReason(slackNotificationConfig.getContent().getShowFailureReason() == null ? SlackNotificationContentConfig.DEFAULT_SHOW_FAILURE_REASON : slackNotificationConfig.getContent().getShowFailureReason()); } Loggers.ACTIVITIES.debug("SlackNotificationListener :: SlackNotification proxy set to " + slackNotification.getProxyHost() + " for " + slackNotificationConfig.getChannel()); } SlackNotificationListener();  SlackNotificationListener(SBuildServer sBuildServer, ProjectSettingsManager settings,
                                     SlackNotificationMainSettings configSettings, SlackNotificationPayloadManager manager,
                                     SlackNotificationFactory factory); void register(); void getFromConfig(SlackNotification slackNotification, SlackNotificationConfig slackNotificationConfig); @Override void buildStarted(SRunningBuild sRunningBuild); @Override void buildFinished(SRunningBuild sRunningBuild); @Override void buildInterrupted(SRunningBuild sRunningBuild); @Override void beforeBuildFinish(SRunningBuild sRunningBuild); @Deprecated /** This method has been removed from the TeamCity API as of version 7.1 * * @param sBuildType * @param responsibilityInfoOld * @param responsibilityInfoNew * @param isUserAction */ void responsibleChanged(@NotNull SBuildType sBuildType, 
    							   @NotNull ResponsibilityInfo responsibilityInfoOld, 
    							   @NotNull ResponsibilityInfo responsibilityInfoNew, 
    							   boolean isUserAction); @Override void responsibleChanged(SProject project,
			Collection<TestName> testNames, ResponsibilityEntry entry,
			boolean isUserAction); @Override void responsibleChanged(SProject project, TestNameResponsibilityEntry oldTestNameResponsibilityEntry, TestNameResponsibilityEntry newTestNameResponsibilityEntry, boolean isUserAction); @Override void responsibleChanged(@NotNull SBuildType sBuildType,
            @NotNull ResponsibilityEntry responsibilityEntryOld,
            @NotNull ResponsibilityEntry responsibilityEntryNew); @Override void responsibleRemoved(SProject project, TestNameResponsibilityEntry entry); void doPost(SlackNotification notification);  }