Skip to content

Commit

Permalink
[#60feature/#60-restlib] sonar issues fixed
Browse files Browse the repository at this point in the history
Signed-off-by: huluvu424242 <huluvu424242@gmail.com>
  • Loading branch information
Huluvu424242 committed Jan 25, 2023
1 parent 9cf15a4 commit 73f8f69
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void ladeJobsStatus(final AbstractJobBeschreibungen<JobStatusBeschreibung


@Tag("headfull")
public class JenkinsMonitorTrayTest {
class JenkinsMonitorTrayTest {

protected static URL LOCALHOST_JOB_TEST_URL;

Expand All @@ -114,8 +114,8 @@ protected TrayIcon getTrayIcon(final JenkinsMonitorTray jenkinsMonitorTray) {

@Test
@DisplayName("Bei leerer Configuration wird ein graues Icon angezeigt mit Tooltipp <<No jobs watching>>")
public void shouldShowNoJobsWatching() {
final JenkinsMonitorTray jenkinsMonitorTray = new JenkinsMonitorTray(jenkinsHttpClient, ConfigurationMockEmpty.getOrCreateInstance().reload());
void shouldShowNoJobsWatching() {
final JenkinsMonitorTray jenkinsMonitorTray = new JenkinsMonitorTray(jenkinsHttpClient, ConfigurationMockEmpty.getOrCreateInstance().reload());
jenkinsMonitorTray.updateJobStatus();
final TrayIcon trayIcon = getTrayIcon(jenkinsMonitorTray);
assertEquals("Keine Jobs überwachend", trayIcon.getToolTip());
Expand All @@ -124,7 +124,7 @@ public void shouldShowNoJobsWatching() {

@Test
@DisplayName("Bei einem erfolreichen Job soll das TrayIcon grün sein und der Tooltipp soll einen Eintrag enthalten: <<MultibranchJob/master success>>")
public void shouldShowOneSuccessJobWatching() {
void shouldShowOneSuccessJobWatching() {
final JenkinsMonitorTray jenkinsMonitorTray = new JenkinsMonitorTray(clock, new JenkinsHttpClientMock(JobStatus.SUCCESS), ConfigurationMockOneJobSuccess.getOrCreateInstance().reload());

jenkinsMonitorTray.updateJobStatus();
Expand All @@ -135,8 +135,8 @@ public void shouldShowOneSuccessJobWatching() {

@Test
@DisplayName("Bei einem instabilen Job soll das TrayIcon gelb sein und der Tooltipp soll einen Eintrag enthalten: <<MultibranchJob/master unstable>>")
public void shouldShowOneInstabilJobWatching() {
final JenkinsMonitorTray jenkinsMonitorTray = new JenkinsMonitorTray(clock, new JenkinsHttpClientMock(JobStatus.UNSTABLE), ConfigurationMockOneJobUnstable.getOrCreateInstance().reload());
void shouldShowOneInstabilJobWatching() {
final JenkinsMonitorTray jenkinsMonitorTray = new JenkinsMonitorTray(clock, new JenkinsHttpClientMock(JobStatus.UNSTABLE), ConfigurationMockOneJobUnstable.getOrCreateInstance().reload());

jenkinsMonitorTray.updateJobStatus();

Expand All @@ -146,7 +146,7 @@ public void shouldShowOneInstabilJobWatching() {

@Test
@DisplayName("Bei einem fehlschlagenden Job soll das TrayIcon rot sein und der Tooltipp soll einen Eintrag enthalten: <<MultibranchJob/master failed>>")
public void shouldShowOneFailedJobWatching() {
void shouldShowOneFailedJobWatching() {
final JenkinsMonitorTray jenkinsMonitorTray = new JenkinsMonitorTray(clock, new JenkinsHttpClientMock(JobStatus.FAILURE), ConfigurationMockOneJobFailed.getOrCreateInstance().reload());

jenkinsMonitorTray.updateJobStatus();
Expand All @@ -157,7 +157,7 @@ public void shouldShowOneFailedJobWatching() {

@Test
@DisplayName("Bei 2 Jobs - einer grün, einer rot erscheinen die Status im Tooltipp.")
protected void showStatusAsToolstippsIfJobPresent() {
void showStatusAsToolstippsIfJobPresent() {
final JenkinsMonitorTray jenkinsMonitorTray = new JenkinsMonitorTray(clock, new JenkinsHttpClientMockAuto(JobStatus.SUCCESS, JobStatus.FAILURE), ConfigurationMockValidTwoJobs.getOrCreateInstance().reload());

jenkinsMonitorTray.updateJobStatus();
Expand All @@ -170,7 +170,7 @@ protected void showStatusAsToolstippsIfJobPresent() {

@Test
@DisplayName("Bei 3 Jobs - einer grün, einer rot, einer gelb erscheinen die Status im Tooltipp.")
protected void showStatusAsToolstippsIfJobsPresent() {
void showStatusAsToolstippsIfJobsPresent() {
final JenkinsMonitorTray jenkinsMonitorTray = new JenkinsMonitorTray(clock, new JenkinsHttpClientMockAuto(JobStatus.SUCCESS, JobStatus.FAILURE, JobStatus.UNSTABLE), ConfigurationMockValidTreeJobs.getOrCreateInstance().reload());

jenkinsMonitorTray.updateJobStatus();
Expand All @@ -186,7 +186,7 @@ protected void showStatusAsToolstippsIfJobsPresent() {
@Test
@DisplayName("Status aktualisiert sich nach Ablauf der Zeitperiode durch Jobs update")
// @Disabled("wackelt")
public void updateJobsAfterTimePeriod() {
void updateJobsAfterTimePeriod() {

final JenkinsMonitorTray jenkinsMonitorTray = new JenkinsMonitorTray(clock, new JenkinsHttpClientMockAuto(JobStatus.SUCCESS, JobStatus.FAILURE, JobStatus.UNSTABLE, JobStatus.SUCCESS, JobStatus.SUCCESS, JobStatus.SUCCESS), ConfigurationMockValidTreeJobs.getOrCreateInstance().reload());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
import com.github.funthomas424242.jenkinsmonitor.gui.JobStatusBeschreibungen;
import com.github.tomakehurst.wiremock.WireMockServer;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;


public class JenkinsHttpClientTest {
class JenkinsHttpClientTest {

protected WireMockServer wireMockServer;

Expand All @@ -60,23 +60,21 @@ protected void tearDown() {

@Test
@DisplayName("ladeStatus beim Auftreten einer IO Exception wird diese geloggt")
protected void checkLadeStatusWithException() {
void checkLadeStatusWithException() {
// TODO Logging Mock erstellen und auswerten

final JobBeschreibungen jobBeschreibungen = new JobBeschreibungen();
final JobBeschreibung jobBeschreibung = new JobBeschreibung(null, new JobAbfragedaten(NetworkHelper.urlOf("http://localhost:8099/job/multibranchjobred/job/master")));
jobBeschreibungen.put(jobBeschreibung.getPrimaryKey(), jobBeschreibung);

assertDoesNotThrow(() -> {
jenkinsHttpClient.ladeJobsStatus(jobStatusBeschreibungen, jobBeschreibungen);
});
Assertions.assertDoesNotThrow(() -> jenkinsHttpClient.ladeJobsStatus(jobStatusBeschreibungen, jobBeschreibungen));
assertEquals(1, jobStatusBeschreibungen.size());
}


@Test
@DisplayName("prüfe ladeJobStatus für einen Job mit rotem Build")
protected void checkLadeOneJobStatusFailure() {
void checkLadeOneJobStatusFailure() {
final JobBeschreibungen jobBeschreibungen = new JobBeschreibungen();
final JobBeschreibung jobBeschreibung = new JobBeschreibung(null, new JobAbfragedaten(NetworkHelper.urlOf("http://localhost:8099/job/multibranchjobred/job/master")));
jobBeschreibungen.put(jobBeschreibung.getPrimaryKey(), jobBeschreibung);
Expand All @@ -93,7 +91,7 @@ protected void checkLadeOneJobStatusFailure() {

@Test
@DisplayName("prüfe ladeJobStatutus für zwei Jobs einer rot und einer gelb")
protected void checkLadeTwoJobStatusSUCCESSandUNSTABLE() {
void checkLadeTwoJobStatusSUCCESSandUNSTABLE() {

final JobBeschreibungen jobBeschreibungen = new JobBeschreibungen();
final JobBeschreibung jobBeschreibung1 = new JobBeschreibung("#2", new JobAbfragedaten(NetworkHelper.urlOf("http://localhost:8099/job/multibranchjobred/job/master")));
Expand Down

0 comments on commit 73f8f69

Please sign in to comment.