Sonar fixes (#2114)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -71,7 +71,7 @@ class ArtifactFilesystemRepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verifies that an artifact can be successfully stored in the file-system repository")
|
@Description("Verifies that an artifact can be successfully stored in the file-system repository")
|
||||||
void getStoredArtifactBasedOnSHA1Hash() {
|
void getStoredArtifactBasedOnSHA1Hash() throws IOException {
|
||||||
final byte[] fileContent = randomBytes();
|
final byte[] fileContent = randomBytes();
|
||||||
final AbstractDbArtifact artifact = storeRandomArtifact(fileContent);
|
final AbstractDbArtifact artifact = storeRandomArtifact(fileContent);
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ class ArtifactFilesystemRepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verifies that an artifact can be deleted in the file-system repository")
|
@Description("Verifies that an artifact can be deleted in the file-system repository")
|
||||||
void deleteStoredArtifactBySHA1Hash() {
|
void deleteStoredArtifactBySHA1Hash() throws IOException {
|
||||||
final AbstractDbArtifact artifact = storeRandomArtifact(randomBytes());
|
final AbstractDbArtifact artifact = storeRandomArtifact(randomBytes());
|
||||||
artifactFilesystemRepository.deleteBySha1(TENANT, artifact.getHashes().getSha1());
|
artifactFilesystemRepository.deleteBySha1(TENANT, artifact.getHashes().getSha1());
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ class ArtifactFilesystemRepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verifies that all artifacts of a tenant can be deleted in the file-system repository")
|
@Description("Verifies that all artifacts of a tenant can be deleted in the file-system repository")
|
||||||
void deleteStoredArtifactOfTenant() {
|
void deleteStoredArtifactOfTenant() throws IOException {
|
||||||
final AbstractDbArtifact artifact = storeRandomArtifact(randomBytes());
|
final AbstractDbArtifact artifact = storeRandomArtifact(randomBytes());
|
||||||
artifactFilesystemRepository.deleteByTenant(TENANT);
|
artifactFilesystemRepository.deleteByTenant(TENANT);
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ class ArtifactFilesystemRepositoryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verfies that an artifact which does not exists is deleted quietly in the file-system repository")
|
@Description("Verfies that an artifact which does not exists is deleted quietly in the file-system repository")
|
||||||
void deleteArtifactWhichDoesNotExistsBySHA1HashWithoutException() {
|
void deleteArtifactWhichDoesNotExistsBySHA1HashWithoutException() throws IOException {
|
||||||
try {
|
try {
|
||||||
artifactFilesystemRepository.deleteBySha1(TENANT, "sha1HashWhichDoesNotExists");
|
artifactFilesystemRepository.deleteBySha1(TENANT, "sha1HashWhichDoesNotExists");
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
@@ -119,17 +119,9 @@ class ArtifactFilesystemRepositoryTest {
|
|||||||
return randomBytes;
|
return randomBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AbstractDbArtifact storeRandomArtifact(final byte[] fileContent) {
|
private AbstractDbArtifact storeRandomArtifact(final byte[] fileContent) throws IOException {
|
||||||
final ByteArrayInputStream inputStream = new ByteArrayInputStream(fileContent);
|
try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(fileContent)) {
|
||||||
try {
|
|
||||||
return artifactFilesystemRepository.store(TENANT, inputStream, "filename.tmp", "application/txt", null);
|
return artifactFilesystemRepository.store(TENANT, inputStream, "filename.tmp", "application/txt", null);
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
inputStream.close();
|
|
||||||
} catch (final IOException e) {
|
|
||||||
// do nothing
|
|
||||||
// still return the artifact
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,17 +345,6 @@ public class BaseEntityRepositoryACM<T extends AbstractJpaTenantAwareBaseEntity>
|
|||||||
return acmProxy;
|
return acmProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> boolean isOperationAllowed(
|
|
||||||
final AccessController.Operation operation, T entity,
|
|
||||||
final AccessController<T> accessController) {
|
|
||||||
try {
|
|
||||||
accessController.assertOperationAllowed(operation, entity);
|
|
||||||
return true;
|
|
||||||
} catch (final InsufficientPermissionException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
private static <T extends Long> Set<Long> toSetDistinct(final Iterable<T> i) {
|
private static <T extends Long> Set<Long> toSetDistinct(final Iterable<T> i) {
|
||||||
final Set<Long> set = new HashSet<>();
|
final Set<Long> set = new HashSet<>();
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
|||||||
import org.eclipse.hawkbit.repository.exception.InvalidTargetAddressException;
|
import org.eclipse.hawkbit.repository.exception.InvalidTargetAddressException;
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||||
import org.eclipse.hawkbit.repository.exception.TenantNotExistException;
|
|
||||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||||
@@ -791,8 +790,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
@Description("Verifies the enforcement of the metadata quota per target.")
|
@Description("Verifies the enforcement of the metadata quota per target.")
|
||||||
void createTargetMetadataUntilQuotaIsExceeded() {
|
void createTargetMetadataUntilQuotaIsExceeded() {
|
||||||
|
// add meta-data one by one
|
||||||
// add meta data one by one
|
|
||||||
final Target target1 = testdataFactory.createTarget("target1");
|
final Target target1 = testdataFactory.createTarget("target1");
|
||||||
final int maxMetaData = quotaManagement.getMaxMetaDataEntriesPerTarget();
|
final int maxMetaData = quotaManagement.getMaxMetaDataEntriesPerTarget();
|
||||||
for (int i = 0; i < maxMetaData; ++i) {
|
for (int i = 0; i < maxMetaData; ++i) {
|
||||||
@@ -815,7 +813,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
// add some meta data entries
|
// add some meta data entries
|
||||||
final Target target3 = testdataFactory.createTarget("target3");
|
final Target target3 = testdataFactory.createTarget("target3");
|
||||||
final int firstHalf = Math.round(maxMetaData / 2);
|
final int firstHalf = maxMetaData / 2;
|
||||||
for (int i = 0; i < firstHalf; ++i) {
|
for (int i = 0; i < firstHalf; ++i) {
|
||||||
insertTargetMetadata("k" + i, "v" + i, target3);
|
insertTargetMetadata("k" + i, "v" + i, target3);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user