Fix SonarQube issues (2) (#2205)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-01-20 16:29:45 +02:00
committed by GitHub
parent 385023d8b6
commit 5dabe9117a
33 changed files with 162 additions and 185 deletions

View File

@@ -116,6 +116,8 @@ public abstract class AbstractIntegrationTest {
protected static final URI LOCALHOST = URI.create("http://127.0.0.1");
protected static final int DEFAULT_TEST_WEIGHT = 500;
protected static final RandomStringUtils RANDOM_STRING_UTILS = RandomStringUtils.secure();
/**
* Number of {@link DistributionSetType}s that exist in every test case. One
* generated by using
@@ -292,6 +294,14 @@ public abstract class AbstractIntegrationTest {
return Comparator.comparing(Target::getControllerId);
}
protected static String randomString(final int len) {
return RANDOM_STRING_UTILS.next(len, true, false);
}
protected static byte[] randomBytes(final int len) {
return randomString(len).getBytes();
}
protected DistributionSetAssignmentResult assignDistributionSet(final long dsID, final String controllerId) {
return assignDistributionSet(dsID, controllerId, ActionType.FORCED);
}
@@ -477,7 +487,7 @@ public abstract class AbstractIntegrationTest {
private static String createTempDir() {
try {
return Files.createTempDirectory(null).toString() + "/" + RandomStringUtils.randomAlphanumeric(20);
return Files.createTempDirectory(null).toString() + "/" + randomString(20);
} catch (final IOException e) {
throw new IllegalStateException("Failed to create temp directory");
}

View File

@@ -31,7 +31,7 @@ public abstract class AbstractSqlTestDatabase extends AbstractTestExecutionListe
protected final DatasourceContext context;
public AbstractSqlTestDatabase(final DatasourceContext context) {
protected AbstractSqlTestDatabase(final DatasourceContext context) {
this.context = context;
}