Add locked Distribution Set delete tests (#1729)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-05-07 11:22:32 +03:00
committed by GitHub
parent f66da8e723
commit 9b5c4851c5

View File

@@ -1016,6 +1016,37 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
.orElseThrow().forEach(module -> assertThat(module.isLocked()).isTrue());
}
@Test
@Description("Locked a DS could be hard deleted.")
void deleteUnassignedLockedDistributionSet() {
final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1");
distributionSetManagement.lock(distributionSet.getId());
assertThat(
distributionSetManagement.get(distributionSet.getId()).map(DistributionSet::isLocked)
.orElse(false))
.isTrue();
distributionSetManagement.delete(distributionSet.getId());
assertThat(distributionSetManagement.get(distributionSet.getId())).isEmpty();
}
@Test
@Description("Locked an assigned DS could be soft deleted.")
void deleteAssignedLockedDistributionSet() {
final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1");
distributionSetManagement.lock(distributionSet.getId());
assertThat(
distributionSetManagement.get(distributionSet.getId()).map(DistributionSet::isLocked)
.orElse(false))
.isTrue();
final Target target = testdataFactory.createTarget();
assignDistributionSet(distributionSet.getId(), target.getControllerId());
distributionSetManagement.delete(distributionSet.getId());
assertThat(distributionSetManagement.getOrElseThrowException(distributionSet.getId()).isDeleted()).isTrue();
}
@Test
@Description("Unlocks a DS.")
void unlockDistributionSet() {