Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testGetContent_shouldGetPreviousBuildFailures()
throws Exception {
AbstractBuild failureBuild = createBuild(Result.FAILURE, 41, "Changes for a failed build.");

AbstractBuild currentBuild = createBuild(Result.SUCCESS, 42, "Changes for a successful build.");
AbstractBuild currentBuild = createBuild4(Result.SUCCESS, 42, "Changes for a successful build.");
when(currentBuild.getPreviousBuild()).thenReturn(failureBuild);
when(failureBuild.getNextBuild()).thenReturn(currentBuild);

Expand All @@ -82,10 +82,9 @@ public void testGetContent_whenReverseOrderIsTrueShouldReverseOrderOfChanges()

AbstractBuild failureBuild = createBuild(Result.FAILURE, 41, "Changes for a failed build.");

AbstractBuild currentBuild = createBuild(Result.SUCCESS, 42, "Changes for a successful build.");
AbstractBuild currentBuild = createBuild4(Result.SUCCESS, 42, "Changes for a successful build.");
when(currentBuild.getPreviousBuild()).thenReturn(failureBuild);
when(failureBuild.getNextBuild()).thenReturn(currentBuild);


String contentStr = content.evaluate(currentBuild, listener, ChangesSinceLastUnstableBuildMacro.MACRO_NAME);

assertEquals("Changes for Build #42\n" + "[Ash Lux] Changes for a successful build.\n" + "\n" + "\n"
Expand All @@ -97,15 +96,12 @@ public void testGetContent_shouldGetPreviousBuildsThatArentUnstable_HUDSON3519()
throws Exception {
// Test for HUDSON-3519

AbstractBuild successfulBuild = createBuild(Result.SUCCESS, 2, "Changes for a successful build.");
AbstractBuild successfulBuild = createBuild3(Result.SUCCESS, 2, "Changes for a successful build.");

AbstractBuild unstableBuild = createBuild(Result.UNSTABLE, 3, "Changes for an unstable build.");
when(unstableBuild.getPreviousBuild()).thenReturn(successfulBuild);
when(successfulBuild.getNextBuild()).thenReturn(unstableBuild);
AbstractBuild unstableBuild = createBuild2(Result.UNSTABLE, 3, "Changes for an unstable build.");

AbstractBuild abortedBuild = createBuild(Result.ABORTED, 4, "Changes for an aborted build.");
when(abortedBuild.getPreviousBuild()).thenReturn(unstableBuild);
when(unstableBuild.getNextBuild()).thenReturn(abortedBuild);

AbstractBuild failureBuild = createBuild(Result.FAILURE, 5, "Changes for a failed build.");
when(failureBuild.getPreviousBuild()).thenReturn(abortedBuild);
Expand All @@ -115,7 +111,7 @@ public void testGetContent_shouldGetPreviousBuildsThatArentUnstable_HUDSON3519()
when(notBuiltBuild.getPreviousBuild()).thenReturn(failureBuild);
when(failureBuild.getNextBuild()).thenReturn(notBuiltBuild);

AbstractBuild currentBuild = createBuild(Result.UNSTABLE, 7, "Changes for an unstable build.");
AbstractBuild currentBuild = createBuild4(Result.UNSTABLE, 7, "Changes for an unstable build.");
when(currentBuild.getPreviousBuild()).thenReturn(notBuiltBuild);
when(notBuiltBuild.getNextBuild()).thenReturn(currentBuild);

Expand Down Expand Up @@ -147,7 +143,7 @@ public void testShouldPrintDate()

AbstractBuild failureBuild = createBuild(Result.FAILURE, 41, "Changes for a failed build.");

AbstractBuild currentBuild = createBuild(Result.SUCCESS, 42, "Changes for a successful build.");
AbstractBuild currentBuild = createBuild4(Result.SUCCESS, 42, "Changes for a successful build.");
when(currentBuild.getPreviousBuild()).thenReturn(failureBuild);
when(failureBuild.getNextBuild()).thenReturn(currentBuild);

Expand All @@ -166,7 +162,7 @@ public void testShouldPrintRevision()

AbstractBuild failureBuild = createBuild(Result.FAILURE, 41, "Changes for a failed build.");

AbstractBuild currentBuild = createBuild(Result.SUCCESS, 42, "Changes for a successful build.");
AbstractBuild currentBuild = createBuild4(Result.SUCCESS, 42, "Changes for a successful build.");
when(currentBuild.getPreviousBuild()).thenReturn(failureBuild);
when(failureBuild.getNextBuild()).thenReturn(currentBuild);

Expand All @@ -182,7 +178,7 @@ public void testShouldPrintPath()

AbstractBuild failureBuild = createBuild(Result.FAILURE, 41, "Changes for a failed build.");

AbstractBuild currentBuild = createBuild(Result.SUCCESS, 42, "Changes for a successful build.");
AbstractBuild currentBuild = createBuild4(Result.SUCCESS, 42, "Changes for a successful build.");
when(currentBuild.getPreviousBuild()).thenReturn(failureBuild);
when(failureBuild.getNextBuild()).thenReturn(currentBuild);

Expand All @@ -199,7 +195,7 @@ public void testWhenShowPathsIsTrueShouldPrintPath()

AbstractBuild failureBuild = createBuild(Result.FAILURE, 41, "Changes for a failed build.");

AbstractBuild currentBuild = createBuild(Result.SUCCESS, 42, "Changes for a successful build.");
AbstractBuild currentBuild = createBuild4(Result.SUCCESS, 42, "Changes for a successful build.");
when(currentBuild.getPreviousBuild()).thenReturn(failureBuild);
when(failureBuild.getNextBuild()).thenReturn(currentBuild);

Expand All @@ -219,7 +215,7 @@ public void testRegexReplace()

AbstractBuild failureBuild = createBuild(Result.FAILURE, 41, "<defectId>DEFECT-666</defectId><message>Changes for a failed build.</message>");

AbstractBuild currentBuild = createBuild(Result.SUCCESS, 42, "<defectId>DEFECT-666</defectId><message>Changes for a successful build.</message>");
AbstractBuild currentBuild = createBuild4(Result.SUCCESS, 42, "<defectId>DEFECT-666</defectId><message>Changes for a successful build.</message>");
when(currentBuild.getPreviousBuild()).thenReturn(failureBuild);
when(failureBuild.getNextBuild()).thenReturn(currentBuild);

Expand Down Expand Up @@ -321,9 +317,7 @@ public void testShouldEscapeHtmlWhenArgumentEscapeHtmlSetToTrue()

private AbstractBuild createBuildWithNoChanges(Result result, int buildNumber) {
AbstractBuild build = mock(AbstractBuild.class);
when(build.getResult()).thenReturn(result);
ChangeLogSet changes1 = createEmptyChangeLog();
when(build.getChangeSet()).thenReturn(changes1);
when(build.getChangeSets()).thenReturn(Collections.singletonList(changes1));
when(build.getNumber()).thenReturn(buildNumber);

Expand All @@ -333,7 +327,6 @@ private AbstractBuild createBuildWithNoChanges(Result result, int buildNumber) {
public ChangeLogSet createEmptyChangeLog() {
ChangeLogSet changes = mock(ChangeLogSet.class);
List<ChangeLogSet.Entry> entries = Collections.emptyList();
when(changes.iterator()).thenReturn(entries.iterator());
when(changes.isEmptySet()).thenReturn(true);

return changes;
Expand All @@ -343,7 +336,6 @@ private AbstractBuild createBuild(Result result, int buildNumber, String message
AbstractBuild build = mock(AbstractBuild.class);
when(build.getResult()).thenReturn(result);
ChangeLogSet changes1 = createChangeLog(message);
when(build.getChangeSet()).thenReturn(changes1);
when(build.getChangeSets()).thenReturn(Collections.singletonList(changes1));
when(build.getNumber()).thenReturn(buildNumber);

Expand Down Expand Up @@ -406,4 +398,33 @@ public long getTimestamp() {
return 1382409540000L;
}
}

private AbstractBuild createBuild2(Result result, int buildNumber, String message) {
AbstractBuild build = mock(AbstractBuild.class);
ChangeLogSet changes1 = createChangeLog2(message);
when(build.getResult()).thenReturn(result);
return build;
}

private AbstractBuild createBuild3(Result result, int buildNumber, String message) {
AbstractBuild build = mock(AbstractBuild.class);
ChangeLogSet changes1 = createChangeLog2(message);
return build;
}

private AbstractBuild createBuild4(Result result, int buildNumber, String message) {
AbstractBuild build = mock(AbstractBuild.class);
ChangeLogSet changes1 = createChangeLog(message);
when(build.getChangeSets()).thenReturn(Collections.singletonList(changes1));
when(build.getNumber()).thenReturn(buildNumber);
return build;
}

public ChangeLogSet createChangeLog2(String message) {
ChangeLogSet changes = mock(ChangeLogSet.class);
List<ChangeLogSet.Entry> entries = new LinkedList<ChangeLogSet.Entry>();
ChangeLogSet.Entry entry = new ChangeLogEntry(message, "Ash Lux");
entries.add(entry);
return changes;
}
}