diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementTest.java index 2468e89e2..daa1b27d6 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementTest.java @@ -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() {