@Nullable private SFinishedBuild getPreviousNonPersonalBuild(SRunningBuild paramSRunningBuild) { List<SFinishedBuild> localList = buildServer.getHistory().getEntriesBefore(paramSRunningBuild, false); for (SFinishedBuild localSFinishedBuild : localList) if (!(localSFinishedBuild.isPersonal())) return localSFinishedBuild; return null; }
@Nullable private SFinishedBuild getPreviousNonPersonalBuild(SRunningBuild paramSRunningBuild) { List<SFinishedBuild> localList = this.myBuildServer.getHistory().getEntriesBefore(paramSRunningBuild, false); for (SFinishedBuild localSFinishedBuild : localList) if (!(localSFinishedBuild.isPersonal())) return localSFinishedBuild; return null; }
@Before public void setUp() throws Exception { resolverManager.registerVariableResolverFactory(variableResolverFactory); when(previousSuccessfulBuild.getBuildStatus()).thenReturn(Status.NORMAL); when(previousSuccessfulBuild.isPersonal()).thenReturn(false); when(previousFailedBuild.getBuildStatus()).thenReturn(Status.FAILURE); when(previousFailedBuild.isPersonal()).thenReturn(false); when(buildHistory.getEntriesBefore(sRunningBuild, false)).thenReturn(finishedSuccessfulBuilds); when(server.getHistory()).thenReturn(buildHistory); sBuildType.setProject(sProject); }
@Test @Ignore public void testBeforeBuildFinishSRunningBuild() throws FileNotFoundException, IOException { BuildState state = new BuildState(); state.enable(BuildStateEnum.BEFORE_BUILD_FINISHED); projSettings.addNewWebHook("1234", "MyProject", "http://text/test", true, state, "JSON", "testXMLtemplate", true, true, new HashSet<String>()); when(buildHistory.getEntriesBefore(sRunningBuild, false)).thenReturn(finishedSuccessfulBuilds); whl.beforeBuildFinish(sRunningBuild); verify(factory.getWebHook(webHookConfig,null), times(1)).post(); }
@Test @Ignore public void testBuildFinishedSRunningBuild() throws FileNotFoundException, IOException { BuildState state = new BuildState().setAllEnabled(); projSettings.addNewWebHook("1234", "MyProject", "http://text/test", true, state , "JSON", "testXMLtemplate", true, true, new HashSet<String>()); when(webhook.isEnabled()).thenReturn(state.allEnabled()); when(buildHistory.getEntriesBefore(sRunningBuild, false)).thenReturn(finishedSuccessfulBuilds); whl.buildFinished(sRunningBuild); verify(factory.getWebHook(webHookConfig,null), times(1)).post(); }
@Test @Ignore public void testBuildFinishedSRunningBuildSuccessAfterSuccess() throws FileNotFoundException, IOException { BuildState state = new BuildState(); state.enable(BuildStateEnum.BUILD_FIXED); projSettings.addNewWebHook("1234", "MyProject", "http://text/test", true, state, "JSON", "testXMLtemplate", true, true, new HashSet<String>()); when(webhook.isEnabled()).thenReturn(state.enabled(BuildStateEnum.BUILD_FIXED)); when(buildHistory.getEntriesBefore(sRunningBuild, false)).thenReturn(finishedSuccessfulBuilds); whl.buildFinished(sRunningBuild); verify(factory.getWebHook(webHookConfig,null), times(0)).post(); }
@Test @Ignore public void testBuildInterruptedSRunningBuild() throws FileNotFoundException, IOException { BuildState state = new BuildState().setAllEnabled(); projSettings.addNewWebHook("1234", "MyProject", "http://text/test", true, state, "JSON", "testXMLtemplate", true, true, new HashSet<String>()); when(buildHistory.getEntriesBefore(sRunningBuild, false)).thenReturn(finishedSuccessfulBuilds); whl.buildInterrupted(sRunningBuild); verify(factory.getWebHook(webHookConfig,null), times(1)).post(); }
@Test @Ignore public void testBuildFinishedSRunningBuildSuccessAfterFailure() throws FileNotFoundException, IOException { BuildState state = new BuildState(); state.enable(BuildStateEnum.BUILD_FIXED); state.enable(BuildStateEnum.BUILD_FINISHED); state.enable(BuildStateEnum.BUILD_SUCCESSFUL); projSettings.addNewWebHook("1234", "MyProject", "http://text/test", true, state, "JSON", "testXMLtemplate", true, true, new HashSet<String>()); when(webhook.isEnabled()).thenReturn(state.enabled(BuildStateEnum.BUILD_FIXED)); when(buildHistory.getEntriesBefore(sRunningBuild, false)).thenReturn(finishedFailedBuilds); whl.buildFinished(sRunningBuild); verify(factory.getWebHook(webHookConfig,null), times(1)).post(); }
@Test @Ignore public void testBuildStartedSRunningBuild() throws FileNotFoundException, IOException { BuildState state = new BuildState(); state.enable(BuildStateEnum.BUILD_STARTED); projSettings.addNewWebHook("project1", "MyProject", "http://text/test", true, state, "JSON", "testXMLtemplate", true, true, new HashSet<String>()); //when(webhook.isEnabled()).thenReturn(state.enabled(BuildStateEnum.BUILD_STARTED)); when(buildHistory.getEntriesBefore(sRunningBuild, false)).thenReturn(finishedSuccessfulBuilds); whl.buildStarted(sRunningBuild); assertTrue(webHookImpl.isEnabled()); //verify(factory.getWebHook(webHookConfig,null), times(1)).post(); //webHookFactory.getWebHook(whc, myMainSettings.getProxyConfigForUrl(whc.getUrl())); }
finishedBuilds.add(previousBuild); BuildHistory buildHistory = mock(BuildHistory.class); when(buildHistory.getEntriesBefore(sRunningBuild, false)).thenReturn(finishedBuilds); when(sBuildServer.getRootUrl()).thenReturn("http://my-server/"); when (sBuildServer.getHistory()).thenReturn(buildHistory);
BuildHistory buildHistory = mock(BuildHistory.class); Status buildHistoryStatus = Status.FAILURE; when(buildHistory.getEntriesBefore(sRunningBuild, false)).thenReturn(finishedBuilds); when (sBuildServer.getRootUrl()).thenReturn("http://test.url"); when (sBuildServer.getHistory()).thenReturn(buildHistory);
finishedBuilds.add(previousBuild); BuildHistory buildHistory = mock(BuildHistory.class); when(buildHistory.getEntriesBefore(sRunningBuild, false)).thenReturn(finishedBuilds); when (sBuildServer.getHistory()).thenReturn(buildHistory); MockSProject sProject = new MockSProject("Test Project", "A test project", "project1", "ATestProject", sBuildType);