Skip to content

Commit 8fcdf8d

Browse files
Deletes duplicated method and issues reported by sonar (#179)
1 parent 88dea26 commit 8fcdf8d

File tree

3 files changed

+16
-27
lines changed

3 files changed

+16
-27
lines changed

src/test/java/pl/damianszczepanik/jenkins/buildhistorymanager/model/actions/DeleteLogFileActionTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void perform_OnExistingLogFile_DeletesLogFile() throws IOException, InterruptedE
2727
// then
2828
run.assertLogFileIsNotAvailable();
2929
}
30-
30+
3131
@Test
3232
void perform_OnMissingLogFile_SkipDeletion() throws IOException, InterruptedException {
3333

@@ -62,7 +62,7 @@ public File getLogFile() {
6262
}
6363

6464
@Test
65-
public void perform_DeleteLogFileDoesNotWork_IgnoresFailure() throws IOException, InterruptedException {
65+
void perform_DeleteLogFileDoesNotWork_IgnoresFailure() throws IOException, InterruptedException {
6666

6767
// given
6868
Action action = new DeleteLogFileAction();
@@ -82,5 +82,5 @@ public File getLogFile() {
8282
// then
8383
run.assertLogFileIsAvailable();
8484
}
85-
85+
8686
}

src/test/java/pl/damianszczepanik/jenkins/buildhistorymanager/model/conditions/BuildResultConditionTest.java

-15
Original file line numberDiff line numberDiff line change
@@ -346,19 +346,4 @@ void match_OnNotMatchNotBuiltAndResultNotBuilt_ReturnsFalse() throws IOException
346346
// then
347347
assertThat(matched).isFalse();
348348
}
349-
350-
@Test
351-
void match_OnMatchNotBuiltAndResultNotNotBuilt_ReturnsFalse() throws IOException {
352-
353-
// given
354-
BuildResultCondition condition = new BuildResultCondition();
355-
condition.setMatchNotBuilt(true);
356-
Run<?, ?> run = new RunStub(Result.FAILURE);
357-
358-
// when
359-
boolean matched = condition.matches(run, null);
360-
361-
// then
362-
assertThat(matched).isFalse();
363-
}
364349
}

src/test/java/pl/damianszczepanik/jenkins/buildhistorymanager/utils/RunStub.java

+13-9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class RunStub extends Run {
2626
public enum LogFileAvailability {
2727
PRESENT, ABSENT
2828
}
29+
2930
private Result result;
3031
private LogFileAvailability logFileState = LogFileAvailability.PRESENT;
3132
private List<Cause> causes;
@@ -37,7 +38,7 @@ public RunStub(LogFileAvailability logFileState) throws IOException {
3738
this();
3839
this.logFileState = logFileState;
3940
}
40-
41+
4142
public RunStub(int buildNumber) throws IOException {
4243
this();
4344
setBuildNumber(buildNumber);
@@ -66,11 +67,10 @@ public RunStub(String causeClass) throws IOException {
6667

6768
public RunStub(String[] causeClass) throws IOException {
6869
this();
69-
List<Cause> causes = new ArrayList<>();
70+
causes = new ArrayList<>();
7071
for (String cause : causeClass) {
7172
causes.add(new MockCause(cause));
7273
}
73-
this.causes = causes;
7474
}
7575

7676
public RunStub() throws IOException {
@@ -120,9 +120,9 @@ public void checkPermission(Permission permission) {
120120
}
121121

122122
private boolean deleteLogFile() {
123-
boolean result = logFileState == LogFileAvailability.PRESENT;
123+
boolean deleteResult = logFileState == LogFileAvailability.PRESENT;
124124
logFileState = LogFileAvailability.ABSENT;
125-
return result;
125+
return deleteResult;
126126
}
127127

128128
public void assertBuildWasDeleted() {
@@ -141,10 +141,14 @@ public void assertArtifactsAreAvailable() {
141141
assertThat(deleteArtifactsTimes).isZero();
142142
}
143143

144-
public void assertLogFileIsNotAvailable() { assertThat(logFileState).isEqualTo(LogFileAvailability.ABSENT); }
145-
146-
public void assertLogFileIsAvailable() { assertThat(logFileState).isEqualTo(LogFileAvailability.PRESENT); }
147-
144+
public void assertLogFileIsNotAvailable() {
145+
assertThat(logFileState).isEqualTo(LogFileAvailability.ABSENT);
146+
}
147+
148+
public void assertLogFileIsAvailable() {
149+
assertThat(logFileState).isEqualTo(LogFileAvailability.PRESENT);
150+
}
151+
148152

149153
@Override
150154
public Result getResult() {

0 commit comments

Comments
 (0)