aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2021-11-18 16:45:02 -0600
committersonartech <sonartech@sonarsource.com>2021-11-20 20:03:51 +0000
commit3f9445c25962f914ccdd889c002ddd8e19b0cf89 (patch)
treeeb4f34a62b7164a71fd0bbe34d6f59621a687d8d /server/sonar-ce
parentaa640be9e2b9cfa2c027ef0768940b31ebb5536c (diff)
downloadsonarqube-3f9445c25962f914ccdd889c002ddd8e19b0cf89.tar.gz
sonarqube-3f9445c25962f914ccdd889c002ddd8e19b0cf89.zip
Improve code quality
Diffstat (limited to 'server/sonar-ce')
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/cleaning/CeCleaningSchedulerImplTest.java2
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/configuration/CeConfigurationImplTest.java8
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CEQueueStatusImplConcurrentTest.java2
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CommonCEQueueStatusImplTest.java6
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java22
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java4
6 files changed, 22 insertions, 22 deletions
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/cleaning/CeCleaningSchedulerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/cleaning/CeCleaningSchedulerImplTest.java
index c6e43313cb8..783866c7eb1 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/cleaning/CeCleaningSchedulerImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/cleaning/CeCleaningSchedulerImplTest.java
@@ -138,7 +138,7 @@ public class CeCleaningSchedulerImplTest {
mockedInternalCeQueue, mockCeDistributedInformation(jobLock));
underTest.startScheduling();
- assertThat(executorService.schedulerCounter).isEqualTo(1);
+ assertThat(executorService.schedulerCounter).isOne();
}
private CeConfiguration mockCeConfiguration(long cleanCeTasksInitialDelay, long cleanCeTasksDelay) {
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/configuration/CeConfigurationImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/configuration/CeConfigurationImplTest.java
index a2d1f1690bd..a76d275c3e5 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/configuration/CeConfigurationImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/configuration/CeConfigurationImplTest.java
@@ -36,12 +36,12 @@ public class CeConfigurationImplTest {
@Test
public void getWorkerCount_returns_1_when_there_is_no_WorkerCountProvider() {
- assertThat(new CeConfigurationImpl(EMPTY_CONFIGURATION).getWorkerCount()).isEqualTo(1);
+ assertThat(new CeConfigurationImpl(EMPTY_CONFIGURATION).getWorkerCount()).isOne();
}
@Test
public void getWorkerMaxCount_returns_1_when_there_is_no_WorkerCountProvider() {
- assertThat(new CeConfigurationImpl(EMPTY_CONFIGURATION).getWorkerMaxCount()).isEqualTo(1);
+ assertThat(new CeConfigurationImpl(EMPTY_CONFIGURATION).getWorkerMaxCount()).isOne();
}
@Test
@@ -95,10 +95,10 @@ public class CeConfigurationImplTest {
@Test
public void getCleanCeTasksInitialDelay_returns_0() {
assertThat(new CeConfigurationImpl(EMPTY_CONFIGURATION).getCleanTasksInitialDelay())
- .isEqualTo(0L);
+ .isZero();
workerCountProvider.set(1);
assertThat(new CeConfigurationImpl(EMPTY_CONFIGURATION, workerCountProvider).getCleanTasksInitialDelay())
- .isEqualTo(0L);
+ .isZero();
}
@Test
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CEQueueStatusImplConcurrentTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CEQueueStatusImplConcurrentTest.java
index 12895e24d9d..e21e063cbda 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CEQueueStatusImplConcurrentTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CEQueueStatusImplConcurrentTest.java
@@ -58,7 +58,7 @@ public class CEQueueStatusImplConcurrentTest {
executorService.awaitTermination(1, TimeUnit.SECONDS);
- assertThat(underTest.getInProgressCount()).isEqualTo(1);
+ assertThat(underTest.getInProgressCount()).isOne();
assertThat(underTest.getErrorCount()).isEqualTo(17);
assertThat(underTest.getSuccessCount()).isEqualTo(80);
assertThat(underTest.getProcessingTime()).isEqualTo(177);
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CommonCEQueueStatusImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CommonCEQueueStatusImplTest.java
index e8680d4bddf..1439a8e2982 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CommonCEQueueStatusImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CommonCEQueueStatusImplTest.java
@@ -58,7 +58,7 @@ public abstract class CommonCEQueueStatusImplTest {
public void addInProgress_increases_InProgress() {
getUnderTest().addInProgress();
- assertThat(getUnderTest().getInProgressCount()).isEqualTo(1);
+ assertThat(getUnderTest().getInProgressCount()).isOne();
assertThat(getUnderTest().getErrorCount()).isZero();
assertThat(getUnderTest().getSuccessCount()).isZero();
assertThat(getUnderTest().getProcessingTime()).isZero();
@@ -87,7 +87,7 @@ public abstract class CommonCEQueueStatusImplTest {
getUnderTest().addError(SOME_PROCESSING_TIME);
assertThat(getUnderTest().getInProgressCount()).isEqualTo(-1);
- assertThat(getUnderTest().getErrorCount()).isEqualTo(1);
+ assertThat(getUnderTest().getErrorCount()).isOne();
assertThat(getUnderTest().getSuccessCount()).isZero();
assertThat(getUnderTest().getProcessingTime()).isEqualTo(SOME_PROCESSING_TIME);
}
@@ -117,7 +117,7 @@ public abstract class CommonCEQueueStatusImplTest {
assertThat(getUnderTest().getInProgressCount()).isEqualTo(-1);
assertThat(getUnderTest().getErrorCount()).isZero();
- assertThat(getUnderTest().getSuccessCount()).isEqualTo(1);
+ assertThat(getUnderTest().getSuccessCount()).isOne();
assertThat(getUnderTest().getProcessingTime()).isEqualTo(SOME_PROCESSING_TIME);
}
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java
index 310533c50c4..517f38139ee 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java
@@ -159,7 +159,7 @@ public class InternalCeQueueImplTest {
// available in history
Optional<CeActivityDto> history = db.getDbClient().ceActivityDao().selectByUuid(db.getSession(), task.getUuid());
- assertThat(history.isPresent()).isTrue();
+ assertThat(history).isPresent();
assertThat(history.get().getStatus()).isEqualTo(CeActivityDto.Status.SUCCESS);
assertThat(history.get().getIsLast()).isTrue();
assertThat(history.get().getAnalysisUuid()).isNull();
@@ -187,7 +187,7 @@ public class InternalCeQueueImplTest {
// available in history
Optional<CeActivityDto> history = db.getDbClient().ceActivityDao().selectByUuid(db.getSession(), task.getUuid());
- assertThat(history.isPresent()).isTrue();
+ assertThat(history).isPresent();
assertThat(history.get().getAnalysisUuid()).isNull();
}
@@ -200,7 +200,7 @@ public class InternalCeQueueImplTest {
// available in history
Optional<CeActivityDto> history = db.getDbClient().ceActivityDao().selectByUuid(db.getSession(), task.getUuid());
- assertThat(history.isPresent()).isTrue();
+ assertThat(history).isPresent();
assertThat(history.get().getAnalysisUuid()).isEqualTo("U1");
}
@@ -330,7 +330,7 @@ public class InternalCeQueueImplTest {
CeTask task = submit(CeTaskTypes.REPORT, newProjectDto("PROJECT_1"));
Optional<CeTask> peek = underTest.peek(WORKER_UUID_1, true);
- assertThat(peek.isPresent()).isTrue();
+ assertThat(peek).isPresent();
assertThat(peek.get().getUuid()).isEqualTo(task.getUuid());
assertThat(peek.get().getType()).isEqualTo(CeTaskTypes.REPORT);
assertThat(peek.get().getComponent()).contains(new CeTask.Component("PROJECT_1", null, null));
@@ -338,7 +338,7 @@ public class InternalCeQueueImplTest {
// no more pending tasks
peek = underTest.peek(WORKER_UUID_2, true);
- assertThat(peek.isPresent()).isFalse();
+ assertThat(peek).isEmpty();
}
@Test
@@ -348,7 +348,7 @@ public class InternalCeQueueImplTest {
CeTask task = submit(CeTaskTypes.REPORT, branch);
Optional<CeTask> peek = underTest.peek(WORKER_UUID_1, true);
- assertThat(peek.isPresent()).isTrue();
+ assertThat(peek).isPresent();
assertThat(peek.get().getUuid()).isEqualTo(task.getUuid());
assertThat(peek.get().getType()).isEqualTo(CeTaskTypes.REPORT);
assertThat(peek.get().getComponent()).contains(new CeTask.Component(branch.uuid(), branch.getDbKey(), branch.name()));
@@ -356,7 +356,7 @@ public class InternalCeQueueImplTest {
// no more pending tasks
peek = underTest.peek(WORKER_UUID_2, true);
- assertThat(peek.isPresent()).isFalse();
+ assertThat(peek).isEmpty();
}
@Test
@@ -391,7 +391,7 @@ public class InternalCeQueueImplTest {
when(computeEngineStatus.getStatus()).thenReturn(STOPPING);
Optional<CeTask> peek = underTest.peek(WORKER_UUID_1, true);
- assertThat(peek.isPresent()).isFalse();
+ assertThat(peek).isEmpty();
}
@Test
@@ -476,7 +476,7 @@ public class InternalCeQueueImplTest {
underTest.cancel(db.getSession(), queueDto);
Optional<CeActivityDto> activity = db.getDbClient().ceActivityDao().selectByUuid(db.getSession(), task.getUuid());
- assertThat(activity.isPresent()).isTrue();
+ assertThat(activity).isPresent();
assertThat(activity.get().getStatus()).isEqualTo(CeActivityDto.Status.CANCELED);
}
@@ -506,7 +506,7 @@ public class InternalCeQueueImplTest {
history = db.getDbClient().ceActivityDao().selectByUuid(db.getSession(), pendingTask2.getUuid());
assertThat(history.get().getStatus()).isEqualTo(CeActivityDto.Status.CANCELED);
history = db.getDbClient().ceActivityDao().selectByUuid(db.getSession(), inProgressTask.getUuid());
- assertThat(history.isPresent()).isFalse();
+ assertThat(history).isEmpty();
}
@Test
@@ -628,7 +628,7 @@ public class InternalCeQueueImplTest {
private void verifyCeQueueDtoForTaskSubmit(CeTaskSubmit taskSubmit) {
Optional<CeQueueDto> queueDto = db.getDbClient().ceQueueDao().selectByUuid(db.getSession(), taskSubmit.getUuid());
- assertThat(queueDto.isPresent()).isTrue();
+ assertThat(queueDto).isPresent();
CeQueueDto dto = queueDto.get();
assertThat(dto.getTaskType()).isEqualTo(taskSubmit.getType());
Optional<CeTaskSubmit.Component> component = taskSubmit.getComponent();
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java
index 9354eb186cd..86fadf966c2 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java
@@ -193,7 +193,7 @@ public class CeProcessingSchedulerImplTest {
i++;
}
- assertThat(cancelledTaskFutureCount).isEqualTo(1);
+ assertThat(cancelledTaskFutureCount).isOne();
assertThat(processingExecutorService.getSchedulerCalls()).containsExactly(
regularDelayedPoll,
regularDelayedPoll,
@@ -231,7 +231,7 @@ public class CeProcessingSchedulerImplTest {
i++;
}
- assertThat(cancelledTaskFutureCount).isEqualTo(1);
+ assertThat(cancelledTaskFutureCount).isOne();
assertThat(processingExecutorService.getSchedulerCalls()).containsExactly(
regularDelayedPoll,
regularDelayedPoll,