aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce/src/it
diff options
context:
space:
mode:
authorMatteo Mara <matteo.mara@sonarsource.com>2024-10-07 18:13:33 +0200
committersonartech <sonartech@sonarsource.com>2024-10-14 20:03:03 +0000
commit1ad3667d30dd82213ae47bea2c267188f003b2c7 (patch)
tree422f1f66b48114de0e79de9f7bd53aceff3f7c91 /server/sonar-ce/src/it
parentce2e686a3e269f937ffb51635928cd1a597b2d07 (diff)
downloadsonarqube-1ad3667d30dd82213ae47bea2c267188f003b2c7.tar.gz
sonarqube-1ad3667d30dd82213ae47bea2c267188f003b2c7.zip
NO-JIRA Stop using deprecated methods from RandomStringUtils
Diffstat (limited to 'server/sonar-ce/src/it')
-rw-r--r--server/sonar-ce/src/it/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerIT.java28
-rw-r--r--server/sonar-ce/src/it/java/org/sonar/ce/taskprocessor/CeWorkerImplIT.java14
2 files changed, 21 insertions, 21 deletions
diff --git a/server/sonar-ce/src/it/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerIT.java b/server/sonar-ce/src/it/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerIT.java
index 74bb003acf6..a462fe431f0 100644
--- a/server/sonar-ce/src/it/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerIT.java
+++ b/server/sonar-ce/src/it/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerIT.java
@@ -51,7 +51,7 @@ import org.sonar.db.project.ProjectDto;
import org.sonar.server.notification.NotificationService;
import static java.util.Collections.singleton;
-import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric;
+import static org.apache.commons.lang3.RandomStringUtils.secure;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.fail;
@@ -99,7 +99,7 @@ public class ReportAnalysisFailureNotificationExecutionListenerIT {
@Test
public void onEnd_has_no_effect_if_CeTask_type_is_not_report() {
- when(ceTaskMock.getType()).thenReturn(randomAlphanumeric(12));
+ when(ceTaskMock.getType()).thenReturn(secure().nextAlphanumeric(12));
fullMockedUnderTest.onEnd(ceTaskMock, CeActivityDto.Status.FAILED, randomDuration(), ceTaskResultMock, throwableMock);
@@ -145,8 +145,8 @@ public class ReportAnalysisFailureNotificationExecutionListenerIT {
@Test
public void onEnd_fails_with_ISE_if_branch_does_not_exist_in_DB() {
- String componentUuid = randomAlphanumeric(6);
- ProjectDto project = new ProjectDto().setUuid(componentUuid).setKey(randomAlphanumeric(5)).setQualifier(Qualifiers.PROJECT).setCreationMethod(CreationMethod.LOCAL_API);
+ String componentUuid = secure().nextAlphanumeric(6);
+ ProjectDto project = new ProjectDto().setUuid(componentUuid).setKey(secure().nextAlphanumeric(5)).setQualifier(Qualifiers.PROJECT).setCreationMethod(CreationMethod.LOCAL_API);
dbTester.getDbClient().projectDao().insert(dbTester.getSession(), project);
dbTester.getSession().commit();
when(ceTaskMock.getType()).thenReturn(CeTaskTypes.REPORT);
@@ -164,7 +164,7 @@ public class ReportAnalysisFailureNotificationExecutionListenerIT {
public void onEnd_fails_with_IAE_if_component_is_not_a_branch() {
when(ceTaskMock.getType()).thenReturn(CeTaskTypes.REPORT);
ComponentDto mainBranch = dbTester.components().insertPrivateProject().getMainBranchComponent();
- ComponentDto directory = dbTester.components().insertComponent(newDirectory(mainBranch, randomAlphanumeric(12)));
+ ComponentDto directory = dbTester.components().insertComponent(newDirectory(mainBranch, secure().nextAlphanumeric(12)));
ComponentDto file = dbTester.components().insertComponent(ComponentTesting.newFileDto(mainBranch));
ComponentDto view = dbTester.components().insertComponent(ComponentTesting.newPortfolio());
ComponentDto subView = dbTester.components().insertComponent(ComponentTesting.newSubPortfolio(view));
@@ -193,7 +193,7 @@ public class ReportAnalysisFailureNotificationExecutionListenerIT {
public void onEnd_fails_with_RowNotFoundException_if_activity_for_task_does_not_exist_in_DB() {
ProjectData projectData = dbTester.components().insertPrivateProject();
ComponentDto mainBranch = projectData.getMainBranchComponent();
- String taskUuid = randomAlphanumeric(6);
+ String taskUuid = secure().nextAlphanumeric(6);
when(ceTaskMock.getType()).thenReturn(CeTaskTypes.REPORT);
when(ceTaskMock.getUuid()).thenReturn(taskUuid);
when(ceTaskMock.getComponent()).thenReturn(Optional.of(new CeTask.Component(mainBranch.uuid(), null, null)));
@@ -208,7 +208,7 @@ public class ReportAnalysisFailureNotificationExecutionListenerIT {
@Test
public void onEnd_creates_notification_with_data_from_activity_and_project_and_deliver_it() {
- String taskUuid = randomAlphanumeric(12);
+ String taskUuid = secure().nextAlphanumeric(12);
int createdAt = random.nextInt(999_999);
long executedAt = random.nextInt(999_999);
ProjectData project = initMocksToPassConditions(taskUuid, createdAt, executedAt);
@@ -234,7 +234,7 @@ public class ReportAnalysisFailureNotificationExecutionListenerIT {
@Test
public void onEnd_shouldCreateNotificationWithDataFromActivity_whenNonMainBranchIsFailing() {
- String taskUuid = randomAlphanumeric(12);
+ String taskUuid = secure().nextAlphanumeric(12);
int createdAt = random.nextInt(999_999);
long executedAt = random.nextInt(999_999);
@@ -264,8 +264,8 @@ public class ReportAnalysisFailureNotificationExecutionListenerIT {
@Test
public void onEnd_creates_notification_with_error_message_from_Throwable_argument_message() {
- initMocksToPassConditions(randomAlphanumeric(12), random.nextInt(999_999), (long) random.nextInt(999_999));
- String message = randomAlphanumeric(66);
+ initMocksToPassConditions(secure().nextAlphanumeric(12), random.nextInt(999_999), (long) random.nextInt(999_999));
+ String message = secure().nextAlphanumeric(66);
when(throwableMock.getMessage()).thenReturn(message);
underTest.onEnd(ceTaskMock, CeActivityDto.Status.FAILED, randomDuration(), ceTaskResultMock, throwableMock);
@@ -278,7 +278,7 @@ public class ReportAnalysisFailureNotificationExecutionListenerIT {
@Test
public void onEnd_creates_notification_with_null_error_message_if_Throwable_is_null() {
- String taskUuid = randomAlphanumeric(12);
+ String taskUuid = secure().nextAlphanumeric(12);
initMocksToPassConditions(taskUuid, random.nextInt(999_999), (long) random.nextInt(999_999));
Notification notificationMock = mockSerializer();
@@ -293,7 +293,7 @@ public class ReportAnalysisFailureNotificationExecutionListenerIT {
@Test
public void onEnd_ignores_null_CeTaskResult_argument() {
- String taskUuid = randomAlphanumeric(12);
+ String taskUuid = secure().nextAlphanumeric(12);
initMocksToPassConditions(taskUuid, random.nextInt(999_999), (long) random.nextInt(999_999));
Notification notificationMock = mockSerializer();
@@ -304,7 +304,7 @@ public class ReportAnalysisFailureNotificationExecutionListenerIT {
@Test
public void onEnd_ignores_CeTaskResult_argument() {
- String taskUuid = randomAlphanumeric(12);
+ String taskUuid = secure().nextAlphanumeric(12);
initMocksToPassConditions(taskUuid, random.nextInt(999_999), (long) random.nextInt(999_999));
Notification notificationMock = mockSerializer();
@@ -316,7 +316,7 @@ public class ReportAnalysisFailureNotificationExecutionListenerIT {
@Test
public void onEnd_uses_system_data_as_failedAt_if_task_has_no_executedAt() {
- String taskUuid = randomAlphanumeric(12);
+ String taskUuid = secure().nextAlphanumeric(12);
initMocksToPassConditions(taskUuid, random.nextInt(999_999), null);
long now = random.nextInt(999_999);
when(system2.now()).thenReturn(now);
diff --git a/server/sonar-ce/src/it/java/org/sonar/ce/taskprocessor/CeWorkerImplIT.java b/server/sonar-ce/src/it/java/org/sonar/ce/taskprocessor/CeWorkerImplIT.java
index 0387d7ec429..2569c97e571 100644
--- a/server/sonar-ce/src/it/java/org/sonar/ce/taskprocessor/CeWorkerImplIT.java
+++ b/server/sonar-ce/src/it/java/org/sonar/ce/taskprocessor/CeWorkerImplIT.java
@@ -53,7 +53,7 @@ import org.sonar.db.ce.CeTaskTypes;
import org.sonar.db.user.UserDto;
import org.sonar.db.user.UserTesting;
-import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
+import static org.apache.commons.lang3.RandomStringUtils.secure;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
@@ -397,7 +397,7 @@ class CeWorkerImplIT {
@Test
void call_sets_and_restores_thread_name_with_information_of_worker_when_there_is_no_task_to_process() throws Exception {
- String threadName = randomAlphabetic(3);
+ String threadName = secure().nextAlphabetic(3);
when(queue.peek(anyString(), anyBoolean())).thenAnswer(invocation -> {
assertThat(Thread.currentThread().getName())
.isEqualTo("Worker " + ordinal + " (UUID=" + workerUuid + ") on " + threadName);
@@ -411,7 +411,7 @@ class CeWorkerImplIT {
@Test
void call_sets_and_restores_thread_name_with_information_of_worker_when_a_task_is_processed() throws Exception {
- String threadName = randomAlphabetic(3);
+ String threadName = secure().nextAlphabetic(3);
when(queue.peek(anyString(), anyBoolean())).thenAnswer(invocation -> {
assertThat(Thread.currentThread().getName())
.isEqualTo("Worker " + ordinal + " (UUID=" + workerUuid + ") on " + threadName);
@@ -426,7 +426,7 @@ class CeWorkerImplIT {
@Test
void call_sets_and_restores_thread_name_with_information_of_worker_when_an_error_occurs() throws Exception {
- String threadName = randomAlphabetic(3);
+ String threadName = secure().nextAlphabetic(3);
CeTask ceTask = createCeTask(submitter);
when(queue.peek(anyString(), anyBoolean())).thenAnswer(invocation -> {
assertThat(Thread.currentThread().getName())
@@ -446,7 +446,7 @@ class CeWorkerImplIT {
reset(ceWorkerController);
when(ceWorkerController.isEnabled(underTest)).thenReturn(false);
- String threadName = randomAlphabetic(3);
+ String threadName = secure().nextAlphabetic(3);
Thread newThread = createThreadNameVerifyingThread(threadName);
newThread.start();
@@ -587,7 +587,7 @@ class CeWorkerImplIT {
void isExecutedBy_returns_false_unless_a_thread_is_currently_executing_a_task() throws InterruptedException {
CountDownLatch inCallLatch = new CountDownLatch(1);
CountDownLatch assertionsDoneLatch = new CountDownLatch(1);
- String taskType = randomAlphabetic(12);
+ String taskType = secure().nextAlphabetic(12);
CeTask ceTask = mock(CeTask.class);
when(ceTask.getType()).thenReturn(taskType);
when(queue.peek(anyString(), anyBoolean())).thenReturn(Optional.of(ceTask));
@@ -673,7 +673,7 @@ class CeWorkerImplIT {
void getCurrentTask_returns_empty_unless_a_thread_is_currently_executing_a_task() throws InterruptedException {
CountDownLatch inCallLatch = new CountDownLatch(1);
CountDownLatch assertionsDoneLatch = new CountDownLatch(1);
- String taskType = randomAlphabetic(12);
+ String taskType = secure().nextAlphabetic(12);
CeTask ceTask = mock(CeTask.class);
when(ceTask.getType()).thenReturn(taskType);
when(queue.peek(anyString(), anyBoolean())).thenReturn(Optional.of(ceTask));