Fix sonar findings (#2742)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -96,7 +96,8 @@ class DistributionSetTypeManagementTest extends AbstractAccessControllerManageme
|
|||||||
final DistributionSetType dsType2 = testdataFactory.findOrCreateDistributionSetType(
|
final DistributionSetType dsType2 = testdataFactory.findOrCreateDistributionSetType(
|
||||||
"DsType2_override", "DistributionSetType-2-override", List.of(smType2), List.of(smType1));
|
"DsType2_override", "DistributionSetType-2-override", List.of(smType2), List.of(smType1));
|
||||||
runAs(withAuthorities(READ_PREFIX + DISTRIBUTION_SET_TYPE, UPDATE_PREFIX + DISTRIBUTION_SET_TYPE + "/id==" + dsType1.getId()), () -> {
|
runAs(withAuthorities(READ_PREFIX + DISTRIBUTION_SET_TYPE, UPDATE_PREFIX + DISTRIBUTION_SET_TYPE + "/id==" + dsType1.getId()), () -> {
|
||||||
final List<Long> osAndAppTypeIds = List.of(osType.getId(), appType.getId());
|
final Long osTypeId = osType.getId();
|
||||||
|
final List<Long> osAndAppTypeIds = List.of(osTypeId, appType.getId());
|
||||||
// verify distributionSetTypeManagement#assignCompatibleDistributionSetTypes
|
// verify distributionSetTypeManagement#assignCompatibleDistributionSetTypes
|
||||||
DistributionSetType dsType1Up = distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(dsType1.getId(), osAndAppTypeIds);
|
DistributionSetType dsType1Up = distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(dsType1.getId(), osAndAppTypeIds);
|
||||||
assertThat(dsType1Up).satisfies(
|
assertThat(dsType1Up).satisfies(
|
||||||
@@ -108,10 +109,10 @@ class DistributionSetTypeManagementTest extends AbstractAccessControllerManageme
|
|||||||
.isInstanceOf(InsufficientPermissionException.class);
|
.isInstanceOf(InsufficientPermissionException.class);
|
||||||
|
|
||||||
assertThat(distributionSetTypeManagement
|
assertThat(distributionSetTypeManagement
|
||||||
.unassignSoftwareModuleType(dsType1.getId(), osType.getId()))
|
.unassignSoftwareModuleType(dsType1.getId(), osTypeId))
|
||||||
.satisfies(updatedType -> assertThat(updatedType.containsModuleType(osType)).isFalse());
|
.satisfies(updatedType -> assertThat(updatedType.containsModuleType(osType)).isFalse());
|
||||||
assertThatThrownBy(
|
assertThatThrownBy(
|
||||||
() -> distributionSetTypeManagement.unassignSoftwareModuleType(dsType2Id, osType.getId()))
|
() -> distributionSetTypeManagement.unassignSoftwareModuleType(dsType2Id, osTypeId))
|
||||||
.isInstanceOf(InsufficientPermissionException.class);
|
.isInstanceOf(InsufficientPermissionException.class);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class TargetManagementTest extends AbstractAccessControllerManagementTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked", "java:S5961" }) // better to keep together
|
||||||
@Test
|
@Test
|
||||||
void verifyRead() {
|
void verifyRead() {
|
||||||
assertThat(assignDistributionSet(ds2Type2, List.of(target1Type1, target2Type2, target3Type2)).getAssigned()).isEqualTo(3);
|
assertThat(assignDistributionSet(ds2Type2, List.of(target1Type1, target2Type2, target3Type2)).getAssigned()).isEqualTo(3);
|
||||||
@@ -128,7 +128,6 @@ class TargetManagementTest extends AbstractAccessControllerManagementTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void verifyReadCompatibleRelated() {
|
void verifyReadCompatibleRelated() {
|
||||||
// assertThat(assignDistributionSet(ds2Type2, List.of(target1Type1, target2Type2, target3Type2)).getAssigned()).isEqualTo(3);
|
|
||||||
prepareFinishedUpdates(ds2Type2, target1Type1, target2Type2);
|
prepareFinishedUpdates(ds2Type2, target1Type1, target2Type2);
|
||||||
final Target target1Type1 = targetManagement.get(super.target1Type1.getId());
|
final Target target1Type1 = targetManagement.get(super.target1Type1.getId());
|
||||||
runAs(withAuthorities(
|
runAs(withAuthorities(
|
||||||
@@ -250,9 +249,9 @@ class TargetManagementTest extends AbstractAccessControllerManagementTest {
|
|||||||
assertThatThrownBy(() -> targetManagement.unassignType(noPermissionsTestDataControllerId))
|
assertThatThrownBy(() -> targetManagement.unassignType(noPermissionsTestDataControllerId))
|
||||||
.isInstanceOf(InsufficientPermissionException.class);
|
.isInstanceOf(InsufficientPermissionException.class);
|
||||||
|
|
||||||
assertThat(assignDistributionSet(ds2Type2.getId(), target1Type1.getControllerId()).getAssigned()).isEqualTo(1);
|
final Long ds2Type2Id = ds2Type2.getId();
|
||||||
assertThatThrownBy(() -> assignDistributionSet(ds2Type2.getId(), target2Type2ControllerId)).isInstanceOf(
|
assertThat(assignDistributionSet(ds2Type2Id, target1Type1.getControllerId()).getAssigned()).isEqualTo(1);
|
||||||
AssertionError.class);
|
assertThatThrownBy(() -> assignDistributionSet(ds2Type2Id, target2Type2ControllerId)).isInstanceOf(AssertionError.class);
|
||||||
// bunch assignment skips denied since at least one target without update permissions is present
|
// bunch assignment skips denied since at least one target without update permissions is present
|
||||||
assertThat(assignDistributionSet(
|
assertThat(assignDistributionSet(
|
||||||
ds3Type2.getId(), List.of(target1Type1.getControllerId(), target2Type2ControllerId), Action.ActionType.FORCED)
|
ds3Type2.getId(), List.of(target1Type1.getControllerId(), target2Type2ControllerId), Action.ActionType.FORCED)
|
||||||
|
|||||||
@@ -76,14 +76,16 @@ class TargetTypeManagementTest extends AbstractAccessControllerManagementTest {
|
|||||||
final Update targetTypeUpdate = Update.builder().id(targetType2.getId()).description("anotherDesc").build();
|
final Update targetTypeUpdate = Update.builder().id(targetType2.getId()).description("anotherDesc").build();
|
||||||
assertThatThrownBy(() -> targetTypeManagement.update(targetTypeUpdate)).isInstanceOf(InsufficientPermissionException.class);
|
assertThatThrownBy(() -> targetTypeManagement.update(targetTypeUpdate)).isInstanceOf(InsufficientPermissionException.class);
|
||||||
|
|
||||||
targetTypeManagement.assignCompatibleDistributionSetTypes(targetType1.getId(), List.of(dsType2.getId()));
|
final Long dsType2Id = dsType2.getId();
|
||||||
|
final List<Long> dsType2IdList = List.of(dsType2Id);
|
||||||
|
targetTypeManagement.assignCompatibleDistributionSetTypes(targetType1.getId(), dsType2IdList);
|
||||||
final Long targetType2Id = targetType2.getId();
|
final Long targetType2Id = targetType2.getId();
|
||||||
assertThatThrownBy(
|
assertThatThrownBy(
|
||||||
() -> targetTypeManagement.assignCompatibleDistributionSetTypes(targetType2Id, List.of(dsType2.getId())))
|
() -> targetTypeManagement.assignCompatibleDistributionSetTypes(targetType2Id, dsType2IdList))
|
||||||
.isInstanceOf(InsufficientPermissionException.class);
|
.isInstanceOf(InsufficientPermissionException.class);
|
||||||
|
|
||||||
targetTypeManagement.unassignDistributionSetType(targetType1.getId(), dsType2.getId());
|
targetTypeManagement.unassignDistributionSetType(targetType1.getId(), dsType2Id);
|
||||||
assertThatThrownBy(() -> targetTypeManagement.unassignDistributionSetType(targetType2Id, dsType2.getId()))
|
assertThatThrownBy(() -> targetTypeManagement.unassignDistributionSetType(targetType2Id, dsType2Id))
|
||||||
.isInstanceOf(InsufficientPermissionException.class);
|
.isInstanceOf(InsufficientPermissionException.class);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user