Exclude soft deleted entities from findByRsql result for all entities (#1297)
* exclude soft deleted SMs and SM types from findByRsql result Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io> * add tests Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io> * clean up code Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io> Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io>
This commit is contained in:
@@ -678,8 +678,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
// correct
|
||||
final List<DistributionSet> tSecondPinOrderedByName = distributionSetManagement
|
||||
.findByDistributionSetFilterOrderByLinkedTarget(
|
||||
PageRequest.of(0, 500, Sort.by(Direction.DESC, "version")),
|
||||
distributionSetFilter, tSecond.getControllerId())
|
||||
PageRequest.of(0, 500, Sort.by(Direction.DESC, "version")), distributionSetFilter,
|
||||
tSecond.getControllerId())
|
||||
.getContent();
|
||||
assertThat(tSecondPinOrderedByName).hasSize(10);
|
||||
// installed
|
||||
@@ -1081,6 +1081,9 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
// not assigned so not marked as deleted
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
||||
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(2);
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).hasSize(2);
|
||||
assertThat(distributionSetManagement.findByRsql(PAGE, "name==*")).hasSize(2);
|
||||
assertThat(distributionSetManagement.count()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -115,9 +115,8 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set invalid description text should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name("a").version("a")
|
||||
.description(INVALID_TEXT_HTML)));
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a")
|
||||
.version("a").description(INVALID_TEXT_HTML)));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with too long description should not be updated")
|
||||
@@ -334,6 +333,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
@Test
|
||||
@Description("Tests the successfull deletion of used (soft delete) distribution set types.")
|
||||
public void deleteAssignedDistributionSetType() {
|
||||
final int existing = (int) distributionSetTypeManagement.count();
|
||||
final JpaDistributionSetType toBeDeleted = (JpaDistributionSetType) distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("softdeleted").name("to be deleted"));
|
||||
|
||||
@@ -345,6 +345,9 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
final Optional<DistributionSetType> softdeleted = distributionSetTypeManagement.getByKey("softdeleted");
|
||||
assertThat(softdeleted).isPresent();
|
||||
assertThat(softdeleted.get().isDeleted()).isTrue();
|
||||
assertThat(distributionSetTypeManagement.findAll(PAGE)).hasSize(existing);
|
||||
assertThat(distributionSetTypeManagement.findByRsql(PAGE, "name==*")).hasSize(existing);
|
||||
assertThat(distributionSetTypeManagement.count()).isEqualTo(existing);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1752,6 +1752,9 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
assertThat(rolloutManagement.findAll(PAGE, true).getContent()).hasSize(1);
|
||||
assertThat(rolloutManagement.findAll(PAGE, false).getContent()).isEmpty();
|
||||
assertThat(rolloutManagement.findByRsql(PAGE, "name==*", true).getContent()).hasSize(1);
|
||||
assertThat(rolloutManagement.findByRsql(PAGE, "name==*", false).getContent()).isEmpty();
|
||||
assertThat(rolloutManagement.count()).isZero();
|
||||
assertThat(rolloutGroupManagement.findByRolloutWithDetailedStatus(PAGE, createdRollout.getId()).getContent())
|
||||
.hasSize(amountGroups);
|
||||
|
||||
@@ -1787,8 +1790,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final String prefixRolloutReady = randomString + "2";
|
||||
final RolloutCreate rolloutReadyCreate = entityFactory.rollout().create()
|
||||
.name(prefixRolloutReady + "-testRollout").targetFilterQuery("name==" + randomString + "*")
|
||||
.set(testDs);
|
||||
.name(prefixRolloutReady + "-testRollout").targetFilterQuery("name==" + randomString + "*").set(testDs);
|
||||
Rollout rolloutReady = rolloutManagement.create(rolloutReadyCreate, 1, conditions);
|
||||
// Let the executor handle created Rollout
|
||||
rolloutManagement.handleRollouts();
|
||||
@@ -1803,7 +1805,6 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(rolloutsOrderedByName).containsSubsequence(List.of(rolloutRunning, rolloutReady));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Description("Creating a rollout without weight value when multi assignment in enabled.")
|
||||
void weightNotRequiredInMultiAssignmentMode() {
|
||||
|
||||
@@ -308,6 +308,8 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
assignedModule = softwareModuleManagement.get(assignedModule.getId()).get();
|
||||
assertTrue(assignedModule.isDeleted(), "The module should be flagged as deleted");
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).isEmpty();
|
||||
assertThat(softwareModuleManagement.findByRsql(PAGE, "name==*")).isEmpty();
|
||||
assertThat(softwareModuleManagement.count()).isZero();
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(1);
|
||||
|
||||
// verify: binary data is deleted
|
||||
|
||||
@@ -128,6 +128,9 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
// delete assigned
|
||||
softwareModuleTypeManagement.delete(type.getId());
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
|
||||
assertThat(softwareModuleTypeManagement.findByRsql(PAGE, "name==*")).hasSize(3).contains(osType, runtimeType,
|
||||
appType);
|
||||
assertThat(softwareModuleTypeManagement.count()).isEqualTo(3);
|
||||
|
||||
assertThat(softwareModuleTypeRepository.findAll()).hasSize(4).contains((JpaSoftwareModuleType) osType,
|
||||
(JpaSoftwareModuleType) runtimeType, (JpaSoftwareModuleType) appType,
|
||||
|
||||
Reference in New Issue
Block a user