From 9b5c4851c58c729f3facbfa8788b4eea8d930dd2 Mon Sep 17 00:00:00 2001 From: Avgustin Marinov Date: Tue, 7 May 2024 11:22:32 +0300 Subject: [PATCH] Add locked Distribution Set delete tests (#1729) Signed-off-by: Marinov Avgustin --- .../DistributionSetManagementTest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) 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() {