Sonar Fixes (#2233)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import jakarta.validation.Validation;
|
||||
|
||||
import org.eclipse.hawkbit.ContextAware;
|
||||
import org.eclipse.hawkbit.artifact.repository.ArtifactRepository;
|
||||
import org.eclipse.hawkbit.cache.TenancyCacheManager;
|
||||
import org.eclipse.hawkbit.repository.ArtifactEncryption;
|
||||
import org.eclipse.hawkbit.repository.ArtifactEncryptionSecretsStore;
|
||||
import org.eclipse.hawkbit.repository.ArtifactEncryptionService;
|
||||
@@ -130,6 +131,8 @@ import org.eclipse.hawkbit.repository.jpa.repository.TargetMetadataRepository;
|
||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
|
||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetTagRepository;
|
||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetTypeRepository;
|
||||
import org.eclipse.hawkbit.repository.jpa.repository.TenantConfigurationRepository;
|
||||
import org.eclipse.hawkbit.repository.jpa.repository.TenantMetaDataRepository;
|
||||
import org.eclipse.hawkbit.repository.jpa.rollout.RolloutScheduler;
|
||||
import org.eclipse.hawkbit.repository.jpa.rollout.condition.PauseRolloutGroupAction;
|
||||
import org.eclipse.hawkbit.repository.jpa.rollout.condition.RolloutGroupActionEvaluator;
|
||||
@@ -160,6 +163,7 @@ import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||
import org.eclipse.hawkbit.tenancy.UserAuthoritiesResolver;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
|
||||
import org.eclipse.hawkbit.utils.TenantConfigHelper;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -170,6 +174,8 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
@@ -476,8 +482,23 @@ public class RepositoryApplicationConfiguration {
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
SystemManagement systemManagement(final JpaProperties properties) {
|
||||
return new JpaSystemManagement(properties);
|
||||
SystemManagement systemManagement(
|
||||
final TargetRepository targetRepository, final TargetTypeRepository targetTypeRepository,
|
||||
final TargetTagRepository targetTagRepository, final TargetFilterQueryRepository targetFilterQueryRepository,
|
||||
final SoftwareModuleRepository softwareModuleRepository, final SoftwareModuleTypeRepository softwareModuleTypeRepository,
|
||||
final DistributionSetRepository distributionSetRepository, final DistributionSetTypeRepository distributionSetTypeRepository,
|
||||
final DistributionSetTagRepository distributionSetTagRepository, final RolloutRepository rolloutRepository,
|
||||
final TenantConfigurationRepository tenantConfigurationRepository, final TenantMetaDataRepository tenantMetaDataRepository,
|
||||
final TenantStatsManagement systemStatsManagement, final SystemManagementCacheKeyGenerator currentTenantCacheKeyGenerator,
|
||||
final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware, final PlatformTransactionManager txManager,
|
||||
final TenancyCacheManager cacheManager, final RolloutStatusCache rolloutStatusCache,
|
||||
final EntityManager entityManager, final RepositoryProperties repositoryProperties,
|
||||
final JpaProperties properties) {
|
||||
return new JpaSystemManagement(targetRepository, targetTypeRepository, targetTagRepository,
|
||||
targetFilterQueryRepository, softwareModuleRepository, softwareModuleTypeRepository, distributionSetRepository,
|
||||
distributionSetTypeRepository, distributionSetTagRepository, rolloutRepository, tenantConfigurationRepository,
|
||||
tenantMetaDataRepository, systemStatsManagement, currentTenantCacheKeyGenerator, systemSecurityContext,
|
||||
tenantAware, txManager, cacheManager, rolloutStatusCache, entityManager, repositoryProperties, properties);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -547,8 +568,10 @@ public class RepositoryApplicationConfiguration {
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
TenantStatsManagement tenantStatsManagement() {
|
||||
return new JpaTenantStatsManagement();
|
||||
TenantStatsManagement tenantStatsManagement(
|
||||
final TargetRepository targetRepository, final LocalArtifactRepository artifactRepository, final ActionRepository actionRepository,
|
||||
final TenantAware tenantAware) {
|
||||
return new JpaTenantStatsManagement(targetRepository, artifactRepository, actionRepository, tenantAware);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -558,8 +581,13 @@ public class RepositoryApplicationConfiguration {
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
TenantConfigurationManagement tenantConfigurationManagement() {
|
||||
return new JpaTenantConfigurationManagement();
|
||||
TenantConfigurationManagement tenantConfigurationManagement(
|
||||
final TenantConfigurationRepository tenantConfigurationRepository,
|
||||
final TenantConfigurationProperties tenantConfigurationProperties,
|
||||
final CacheManager cacheManager, final AfterTransactionCommitExecutor afterCommitExecutor,
|
||||
final ApplicationContext applicationContext) {
|
||||
return new JpaTenantConfigurationManagement(tenantConfigurationRepository, tenantConfigurationProperties,
|
||||
cacheManager, afterCommitExecutor, applicationContext);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -587,6 +587,7 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
return rollout;
|
||||
}
|
||||
|
||||
@SuppressWarnings("java:S2259") // java:S2259 - false positive, see the java:S2259 comment in code
|
||||
private Rollout createRolloutGroups(
|
||||
final int amountOfGroups, final RolloutGroupConditions conditions,
|
||||
final JpaRollout rollout, final boolean isConfirmationRequired, final DynamicRolloutGroupTemplate dynamicRolloutGroupTemplate) {
|
||||
@@ -651,7 +652,7 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
publishRolloutGroupCreatedEventAfterCommit(lastGroup, rollout);
|
||||
}
|
||||
|
||||
// lastSavedGroup is never null! amountOfGroups > 0 (and has static groups) or dynamicRolloutGroupTemplate is
|
||||
// java:S2259 - lastSavedGroup is never null! amountOfGroups > 0 (and has static groups) or dynamicRolloutGroupTemplate is
|
||||
// not null (validated) and (validated) the rollout is dynamic, so has dynamic group
|
||||
rollout.setRolloutGroupsCreated(lastGroup.isDynamic() ? amountOfGroups + 1 : amountOfGroups);
|
||||
final JpaRollout savedRollout = rolloutRepository.save(rollout);
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.springframework.dao.ConcurrencyFailureException;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.orm.jpa.vendor.Database;
|
||||
import org.springframework.retry.annotation.Backoff;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
@@ -75,62 +76,76 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst
|
||||
private final String countArtifactQuery;
|
||||
private final String countSoftwareModulesQuery;
|
||||
|
||||
@Autowired
|
||||
private EntityManager entityManager;
|
||||
@Autowired
|
||||
private TargetRepository targetRepository;
|
||||
@Autowired
|
||||
private TargetFilterQueryRepository targetFilterQueryRepository;
|
||||
@Autowired
|
||||
private DistributionSetRepository distributionSetRepository;
|
||||
@Autowired
|
||||
private SoftwareModuleRepository softwareModuleRepository;
|
||||
@Autowired
|
||||
private TenantMetaDataRepository tenantMetaDataRepository;
|
||||
@Autowired
|
||||
private DistributionSetTypeRepository distributionSetTypeRepository;
|
||||
@Autowired
|
||||
private SoftwareModuleTypeRepository softwareModuleTypeRepository;
|
||||
@Autowired
|
||||
private TargetTagRepository targetTagRepository;
|
||||
@Autowired
|
||||
private TargetTypeRepository targetTypeRepository;
|
||||
@Autowired
|
||||
private DistributionSetTagRepository distributionSetTagRepository;
|
||||
@Autowired
|
||||
private TenantConfigurationRepository tenantConfigurationRepository;
|
||||
@Autowired
|
||||
private RolloutRepository rolloutRepository;
|
||||
@Autowired
|
||||
private TenantAware tenantAware;
|
||||
@Autowired
|
||||
private TenantStatsManagement systemStatsManagement;
|
||||
@Autowired
|
||||
private TenancyCacheManager cacheManager;
|
||||
@Autowired
|
||||
private SystemManagementCacheKeyGenerator currentTenantCacheKeyGenerator;
|
||||
@Autowired
|
||||
private SystemSecurityContext systemSecurityContext;
|
||||
@Autowired
|
||||
private PlatformTransactionManager txManager;
|
||||
@Autowired
|
||||
private RolloutStatusCache rolloutStatusCache;
|
||||
@Autowired(required = false) // it's not required on dmf/ddi only instances
|
||||
private ArtifactRepository artifactRepository;
|
||||
@Autowired
|
||||
private RepositoryProperties repositoryProperties;
|
||||
private final TargetRepository targetRepository;
|
||||
private final TargetTypeRepository targetTypeRepository;
|
||||
private final TargetTagRepository targetTagRepository;
|
||||
private final TargetFilterQueryRepository targetFilterQueryRepository;
|
||||
private final SoftwareModuleRepository softwareModuleRepository;
|
||||
private final SoftwareModuleTypeRepository softwareModuleTypeRepository;
|
||||
private final DistributionSetRepository distributionSetRepository;
|
||||
private final DistributionSetTypeRepository distributionSetTypeRepository;
|
||||
private final DistributionSetTagRepository distributionSetTagRepository;
|
||||
private final RolloutRepository rolloutRepository;
|
||||
private final TenantConfigurationRepository tenantConfigurationRepository;
|
||||
private final TenantMetaDataRepository tenantMetaDataRepository;
|
||||
private final TenantStatsManagement systemStatsManagement;
|
||||
private final SystemManagementCacheKeyGenerator currentTenantCacheKeyGenerator;
|
||||
private final SystemSecurityContext systemSecurityContext;
|
||||
private final TenantAware tenantAware;
|
||||
private final PlatformTransactionManager txManager;
|
||||
private final TenancyCacheManager cacheManager;
|
||||
private final RolloutStatusCache rolloutStatusCache;
|
||||
private final EntityManager entityManager;
|
||||
private final RepositoryProperties repositoryProperties;
|
||||
|
||||
@Nullable
|
||||
private ArtifactRepository artifactRepository;
|
||||
|
||||
@SuppressWarnings("squid:S00107")
|
||||
public JpaSystemManagement(
|
||||
final TargetRepository targetRepository, final TargetTypeRepository targetTypeRepository,
|
||||
final TargetTagRepository targetTagRepository, final TargetFilterQueryRepository targetFilterQueryRepository,
|
||||
final SoftwareModuleRepository softwareModuleRepository, final SoftwareModuleTypeRepository softwareModuleTypeRepository,
|
||||
final DistributionSetRepository distributionSetRepository, final DistributionSetTypeRepository distributionSetTypeRepository,
|
||||
final DistributionSetTagRepository distributionSetTagRepository, final RolloutRepository rolloutRepository,
|
||||
final TenantConfigurationRepository tenantConfigurationRepository, final TenantMetaDataRepository tenantMetaDataRepository,
|
||||
final TenantStatsManagement systemStatsManagement, final SystemManagementCacheKeyGenerator currentTenantCacheKeyGenerator,
|
||||
final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware, final PlatformTransactionManager txManager,
|
||||
final TenancyCacheManager cacheManager, final RolloutStatusCache rolloutStatusCache,
|
||||
final EntityManager entityManager, final RepositoryProperties repositoryProperties,
|
||||
final JpaProperties properties) {
|
||||
this.targetRepository = targetRepository;
|
||||
this.targetTypeRepository = targetTypeRepository;
|
||||
this.targetTagRepository = targetTagRepository;
|
||||
this.targetFilterQueryRepository = targetFilterQueryRepository;
|
||||
this.softwareModuleRepository = softwareModuleRepository;
|
||||
this.softwareModuleTypeRepository = softwareModuleTypeRepository;
|
||||
this.distributionSetRepository = distributionSetRepository;
|
||||
this.distributionSetTypeRepository = distributionSetTypeRepository;
|
||||
this.distributionSetTagRepository = distributionSetTagRepository;
|
||||
this.rolloutRepository = rolloutRepository;
|
||||
this.tenantConfigurationRepository = tenantConfigurationRepository;
|
||||
this.tenantMetaDataRepository = tenantMetaDataRepository;
|
||||
this.systemStatsManagement = systemStatsManagement;
|
||||
this.currentTenantCacheKeyGenerator = currentTenantCacheKeyGenerator;
|
||||
this.systemSecurityContext = systemSecurityContext;
|
||||
this.tenantAware = tenantAware;
|
||||
this.txManager = txManager;
|
||||
this.cacheManager = cacheManager;
|
||||
this.rolloutStatusCache = rolloutStatusCache;
|
||||
this.entityManager = entityManager;
|
||||
this.repositoryProperties = repositoryProperties;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param properties properties to get the underlying database
|
||||
*/
|
||||
public JpaSystemManagement(final JpaProperties properties) {
|
||||
final String isDeleted = isPostgreSql(properties) ? "false" : "0";
|
||||
countArtifactQuery = "SELECT COUNT(a.id) FROM sp_artifact a INNER JOIN sp_base_software_module sm ON a.software_module = sm.id WHERE sm.deleted = " + isDeleted;
|
||||
countSoftwareModulesQuery = "select SUM(file_size) from sp_artifact a INNER JOIN sp_base_software_module sm ON a.software_module = sm.id WHERE sm.deleted = " + isDeleted;
|
||||
}
|
||||
|
||||
@Autowired(required = false) // it's not required on dmf/ddi only instances
|
||||
public void setArtifactRepository(ArtifactRepository artifactRepository) {
|
||||
this.artifactRepository = artifactRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public KeyGenerator currentTenantKeyGenerator() {
|
||||
|
||||
@@ -44,7 +44,6 @@ import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -68,16 +67,23 @@ public class JpaTenantConfigurationManagement implements TenantConfigurationMana
|
||||
|
||||
private static final ConfigurableConversionService CONVERSION_SERVICE = new DefaultConversionService();
|
||||
|
||||
@Autowired
|
||||
private TenantConfigurationRepository tenantConfigurationRepository;
|
||||
@Autowired
|
||||
private TenantConfigurationProperties tenantConfigurationProperties;
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
@Autowired
|
||||
private CacheManager cacheManager;
|
||||
@Autowired
|
||||
private AfterTransactionCommitExecutor afterCommitExecutor;
|
||||
private final TenantConfigurationRepository tenantConfigurationRepository;
|
||||
private final TenantConfigurationProperties tenantConfigurationProperties;
|
||||
private final ApplicationContext applicationContext;
|
||||
private final CacheManager cacheManager;
|
||||
private final AfterTransactionCommitExecutor afterCommitExecutor;
|
||||
|
||||
public JpaTenantConfigurationManagement(
|
||||
final TenantConfigurationRepository tenantConfigurationRepository,
|
||||
final TenantConfigurationProperties tenantConfigurationProperties,
|
||||
final CacheManager cacheManager, final AfterTransactionCommitExecutor afterCommitExecutor,
|
||||
final ApplicationContext applicationContext) {
|
||||
this.tenantConfigurationRepository = tenantConfigurationRepository;
|
||||
this.tenantConfigurationProperties = tenantConfigurationProperties;
|
||||
this.cacheManager = cacheManager;
|
||||
this.afterCommitExecutor = afterCommitExecutor;
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = "tenantConfiguration", key = "#configurationKeyName")
|
||||
|
||||
@@ -26,14 +26,19 @@ import org.springframework.validation.annotation.Validated;
|
||||
@Validated
|
||||
public class JpaTenantStatsManagement implements TenantStatsManagement {
|
||||
|
||||
@Autowired
|
||||
private TargetRepository targetRepository;
|
||||
@Autowired
|
||||
private LocalArtifactRepository artifactRepository;
|
||||
@Autowired
|
||||
private ActionRepository actionRepository;
|
||||
@Autowired
|
||||
private TenantAware tenantAware;
|
||||
private final TargetRepository targetRepository;
|
||||
private final LocalArtifactRepository artifactRepository;
|
||||
private final ActionRepository actionRepository;
|
||||
private final TenantAware tenantAware;
|
||||
|
||||
public JpaTenantStatsManagement(
|
||||
final TargetRepository targetRepository, final LocalArtifactRepository artifactRepository, final ActionRepository actionRepository,
|
||||
final TenantAware tenantAware) {
|
||||
this.targetRepository = targetRepository;
|
||||
this.artifactRepository = artifactRepository;
|
||||
this.actionRepository = actionRepository;
|
||||
this.tenantAware = tenantAware;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
|
||||
@@ -15,7 +15,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.eclipse.hawkbit.repository.QuotaManagement;
|
||||
@@ -87,7 +86,7 @@ public class OfflineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
|
||||
TargetSpecifications.notEqualToTargetUpdateStatus(TargetUpdateStatus.PENDING))));
|
||||
}
|
||||
return ListUtils.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT).stream().map(mapper)
|
||||
.flatMap(List::stream).collect(Collectors.toList());
|
||||
.flatMap(List::stream).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -112,7 +112,7 @@ public class OnlineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
|
||||
.findAll(TargetSpecifications.hasControllerIdAndAssignedDistributionSetIdNot(ids, setId));
|
||||
}
|
||||
return ListUtils.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT).stream().map(mapper)
|
||||
.flatMap(List::stream).collect(Collectors.toList());
|
||||
.flatMap(List::stream).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,8 +170,7 @@ public class OnlineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
|
||||
@Override
|
||||
public void sendDeploymentEvents(final List<DistributionSetAssignmentResult> assignmentResults) {
|
||||
if (isMultiAssignmentsEnabled()) {
|
||||
sendDeploymentEvent(assignmentResults.stream().flatMap(result -> result.getAssignedEntity().stream())
|
||||
.collect(Collectors.toList()));
|
||||
sendDeploymentEvent(assignmentResults.stream().flatMap(result -> result.getAssignedEntity().stream()).toList());
|
||||
} else {
|
||||
assignmentResults.forEach(this::sendDistributionSetAssignedEvent);
|
||||
}
|
||||
@@ -196,7 +195,7 @@ public class OnlineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
|
||||
if (actions == null || actions.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return filterCancellations(actions).collect(Collectors.toList());
|
||||
return filterCancellations(actions).toList();
|
||||
}
|
||||
|
||||
private void sendMultiActionCancelEvent(final Action action) {
|
||||
@@ -214,8 +213,7 @@ public class OnlineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
|
||||
|
||||
private DistributionSetAssignmentResult sendDistributionSetAssignedEvent(
|
||||
final DistributionSetAssignmentResult assignmentResult) {
|
||||
final List<Action> filteredActions = filterCancellations(assignmentResult.getAssignedEntity())
|
||||
.collect(Collectors.toList());
|
||||
final List<Action> filteredActions = filterCancellations(assignmentResult.getAssignedEntity()).toList();
|
||||
final DistributionSet set = assignmentResult.getDistributionSet();
|
||||
sendTargetAssignDistributionSetEvent(set.getTenant(), set.getId(), filteredActions);
|
||||
return assignmentResult;
|
||||
|
||||
@@ -96,7 +96,8 @@ import org.springframework.util.ObjectUtils;
|
||||
@NamedEntityGraph(name = "Target.actions", attributeNodes = { @NamedAttributeNode("actions") }),
|
||||
})
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
// java:S1710 - not possible to use without group annotation
|
||||
@SuppressWarnings({ "squid:S2160", "java:S1710" })
|
||||
public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAwareEntity {
|
||||
|
||||
@Serial
|
||||
|
||||
@@ -20,12 +20,11 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
@Feature("Unit Tests - Repository")
|
||||
@Story("Repository Model")
|
||||
public class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Verifies that different objects even with identical primary key, version and tenant "
|
||||
+ "return different hash codes.")
|
||||
public void differentEntitiesReturnDifferentHashCodes() {
|
||||
@Description("Verifies that different objects even with identical primary key, version and tenant return different hash codes.")
|
||||
void differentEntitiesReturnDifferentHashCodes() {
|
||||
assertThat(new JpaAction().hashCode()).as("action should have different hashcode than action status")
|
||||
.isNotEqualTo(new JpaActionStatus().hashCode());
|
||||
assertThat(new JpaDistributionSet().hashCode())
|
||||
@@ -40,9 +39,8 @@ public class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that different object even with identical primary key, version and tenant "
|
||||
+ "are not equal.")
|
||||
public void differentEntitiesAreNotEqual() {
|
||||
@Description("Verifies that different object even with identical primary key, version and tenant are not equal.")
|
||||
void differentEntitiesAreNotEqual() {
|
||||
assertThat(new JpaAction().equals(new JpaActionStatus())).as("action equals action status").isFalse();
|
||||
assertThat(new JpaDistributionSet().equals(new JpaSoftwareModule()))
|
||||
.as("Distribution set equals software module").isFalse();
|
||||
@@ -54,7 +52,7 @@ public class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Verifies that updated entities are not equal.")
|
||||
public void changedEntitiesAreNotEqual() {
|
||||
void changedEntitiesAreNotEqual() {
|
||||
final SoftwareModuleType type = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("test").name("test"));
|
||||
assertThat(type).as("persited entity is not equal to regular object")
|
||||
@@ -67,7 +65,7 @@ public class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Verify that no proxy of the entity manager has an influence on the equals or hashcode result.")
|
||||
public void managedEntityIsEqualToUnamangedObjectWithSameKey() {
|
||||
void managedEntityIsEqualToUnamangedObjectWithSameKey() {
|
||||
final SoftwareModuleType type = softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("test").name("test").description("test"));
|
||||
|
||||
@@ -77,8 +75,9 @@ public class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
mock.setTenant(type.getTenant());
|
||||
|
||||
assertThat(type).as("managed entity is equal to regular object with same content").isEqualTo(mock);
|
||||
assertThat(type.hashCode()).as("managed entity has same hash code as regular object with same content")
|
||||
.isEqualTo(mock.hashCode());
|
||||
assertThat(type)
|
||||
.as("managed entity has same hash code as regular object with same content")
|
||||
.hasSameHashCodeAs(mock.hashCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
@@ -32,13 +32,13 @@ import org.springframework.orm.jpa.vendor.Database;
|
||||
|
||||
@Feature("Component Tests - Repository")
|
||||
@Story("RSQL filter actions")
|
||||
public class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
|
||||
class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private JpaTarget target;
|
||||
private JpaAction action;
|
||||
|
||||
@BeforeEach
|
||||
public void setupBeforeTest() {
|
||||
void setupBeforeTest() {
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("daA");
|
||||
target = (JpaTarget) targetManagement
|
||||
.create(entityFactory.target().create().controllerId("targetId123").description("targetId123"));
|
||||
@@ -51,7 +51,7 @@ public class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter action by id")
|
||||
public void testFilterByParameterId() {
|
||||
void testFilterByParameterId() {
|
||||
assertRSQLQuery(ActionFields.ID.name() + "==" + action.getId(), 1);
|
||||
assertRSQLQuery(ActionFields.ID.name() + "!=" + action.getId(), 10);
|
||||
assertRSQLQuery(ActionFields.ID.name() + "==" + -1, 0);
|
||||
@@ -68,23 +68,21 @@ public class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test action by status")
|
||||
public void testFilterByParameterStatus() {
|
||||
void testFilterByParameterStatus() {
|
||||
assertRSQLQuery(ActionFields.STATUS.name() + "==pending", 5);
|
||||
assertRSQLQuery(ActionFields.STATUS.name() + "!=pending", 6);
|
||||
assertRSQLQuery(ActionFields.STATUS.name() + "=in=(pending)", 5);
|
||||
assertRSQLQuery(ActionFields.STATUS.name() + "=out=(pending)", 6);
|
||||
|
||||
try {
|
||||
assertRSQLQuery(ActionFields.STATUS.name() + "==true", 5);
|
||||
fail("Missing expected RSQLParameterUnsupportedFieldException because status cannot be compared with 'true'");
|
||||
} catch (final RSQLParameterUnsupportedFieldException e) {
|
||||
}
|
||||
|
||||
final String rsql = ActionFields.STATUS.name() + "==true";
|
||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||
.as("RSQLParameterUnsupportedFieldException because status cannot be compared with 'true'")
|
||||
.isThrownBy(() -> assertRSQLQuery(rsql, 5));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Test action by status")
|
||||
public void testFilterByParameterExtRef() {
|
||||
void testFilterByParameterExtRef() {
|
||||
assertRSQLQuery(ActionFields.EXTERNALREF.name() + "==extRef", 5);
|
||||
assertRSQLQuery(ActionFields.EXTERNALREF.name() + "!=extRef", 6);
|
||||
assertRSQLQuery(ActionFields.EXTERNALREF.name() + "==extRef*", 10);
|
||||
@@ -114,7 +112,7 @@ public class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
|
||||
PageRequest.of(0, 100));
|
||||
final long countAllEntities = deploymentManagement.countActionsByTarget(rsqlParam, target.getControllerId());
|
||||
assertThat(findEntity).isNotNull();
|
||||
assertThat(findEntity.getContent().size()).isEqualTo(expectedEntities);
|
||||
assertThat(findEntity.getContent()).hasSize((int)expectedEntities);
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -134,11 +133,9 @@ class RSQLDistributionSetFieldTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Test filter distribution set by complete property")
|
||||
void testFilterByAttributeComplete() {
|
||||
assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "==true", 3);
|
||||
try {
|
||||
assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "==noExist*", 0);
|
||||
fail("Expected RSQLParameterSyntaxException");
|
||||
} catch (final RSQLParameterSyntaxException e) {
|
||||
}
|
||||
final String noExistStar = DistributionSetFields.COMPLETE.name() + "==noExist*";
|
||||
assertThatExceptionOfType(RSQLParameterSyntaxException.class)
|
||||
.isThrownBy(() -> assertRSQLQuery(noExistStar, 0));
|
||||
assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "=in=(true)", 3);
|
||||
assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "=out=(true)", 2);
|
||||
}
|
||||
@@ -148,8 +145,9 @@ class RSQLDistributionSetFieldTest extends AbstractJpaIntegrationTest {
|
||||
void testFilterByAttributeValid() {
|
||||
assertRSQLQuery(DistributionSetFields.VALID.name() + "==true", 4);
|
||||
assertRSQLQuery(DistributionSetFields.VALID.name() + "==false", 1);
|
||||
final String rsqlNoExistStar = DistributionSetFields.VALID.name() + "==noExist*";
|
||||
assertThatExceptionOfType(RSQLParameterSyntaxException.class)
|
||||
.isThrownBy(() -> assertRSQLQuery(DistributionSetFields.VALID.name() + "==noExist*", 0));
|
||||
.isThrownBy(() -> assertRSQLQuery(rsqlNoExistStar, 0));
|
||||
assertRSQLQuery(DistributionSetFields.VALID.name() + "=in=(true)", 4);
|
||||
assertRSQLQuery(DistributionSetFields.VALID.name() + "=out=(true)", 1);
|
||||
}
|
||||
|
||||
@@ -30,12 +30,12 @@ import org.springframework.data.domain.PageRequest;
|
||||
|
||||
@Feature("Component Tests - Repository")
|
||||
@Story("RSQL filter distribution set metadata")
|
||||
public class RSQLDistributionSetMetadataFieldsTest extends AbstractJpaIntegrationTest {
|
||||
class RSQLDistributionSetMetadataFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private Long distributionSetId;
|
||||
|
||||
@BeforeEach
|
||||
public void setupBeforeTest() {
|
||||
void setupBeforeTest() {
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("DS");
|
||||
distributionSetId = distributionSet.getId();
|
||||
|
||||
@@ -52,7 +52,7 @@ public class RSQLDistributionSetMetadataFieldsTest extends AbstractJpaIntegratio
|
||||
|
||||
@Test
|
||||
@Description("Test filter distribution set metadata by key")
|
||||
public void testFilterByParameterKey() {
|
||||
void testFilterByParameterKey() {
|
||||
assertRSQLQuery(DistributionSetMetadataFields.KEY.name() + "==1", 1);
|
||||
assertRSQLQuery(DistributionSetMetadataFields.KEY.name() + "!=1", 5);
|
||||
assertRSQLQuery(DistributionSetMetadataFields.KEY.name() + "=in=(1,2)", 2);
|
||||
@@ -61,7 +61,7 @@ public class RSQLDistributionSetMetadataFieldsTest extends AbstractJpaIntegratio
|
||||
|
||||
@Test
|
||||
@Description("Test filter distribution set metadata by value")
|
||||
public void testFilterByParameterValue() {
|
||||
void testFilterByParameterValue() {
|
||||
assertRSQLQuery(DistributionSetMetadataFields.VALUE.name() + "==''", 1);
|
||||
assertRSQLQuery(DistributionSetMetadataFields.VALUE.name() + "!=''", 5);
|
||||
assertRSQLQuery(DistributionSetMetadataFields.VALUE.name() + "==1", 1);
|
||||
|
||||
@@ -13,7 +13,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
@@ -28,7 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
@Feature("Component Tests - Repository")
|
||||
@Story("RSQL filter suggestion")
|
||||
@SuppressWarnings("java:S6813") // constructor injects are not possible for test classes
|
||||
public class RSQLParserValidationOracleTest extends AbstractJpaIntegrationTest {
|
||||
class RSQLParserValidationOracleTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private static final String[] OP_SUGGESTIONS = new String[] { "==", "!=", "=ge=", "=le=", "=gt=", "=lt=", "=in=",
|
||||
"=out=" };
|
||||
@@ -42,7 +41,7 @@ public class RSQLParserValidationOracleTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Verifies that suggestions contains all possible field names")
|
||||
public void suggestionContainsAllFieldNames() {
|
||||
void suggestionContainsAllFieldNames() {
|
||||
final String rsqlQuery = "na";
|
||||
final List<String> currentSuggestions = getSuggestions(rsqlQuery);
|
||||
assertThat(currentSuggestions).containsOnly(FIELD_SUGGESTIONS);
|
||||
@@ -50,7 +49,7 @@ public class RSQLParserValidationOracleTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Verifies that suggestions only contains the allowed operators")
|
||||
public void suggestionContainsOnlyOperators() {
|
||||
void suggestionContainsOnlyOperators() {
|
||||
final String rsqlQuery = "name";
|
||||
final List<String> currentSuggestions = getSuggestions(rsqlQuery);
|
||||
assertThat(currentSuggestions).containsOnly(OP_SUGGESTIONS);
|
||||
@@ -58,7 +57,7 @@ public class RSQLParserValidationOracleTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Verifies that suggestions only contains operator to combine RSQL filters (and, or)")
|
||||
public void suggestionContainsOnlyAndOrOperator() {
|
||||
void suggestionContainsOnlyAndOrOperator() {
|
||||
final String rsqlQuery = "name==a ";
|
||||
final List<String> currentSuggestions = getSuggestions(rsqlQuery);
|
||||
assertThat(currentSuggestions).containsOnly(AND_OR_SUGGESTIONS);
|
||||
@@ -66,7 +65,7 @@ public class RSQLParserValidationOracleTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Verifies that sub suggestions are shown")
|
||||
public void suggestionContainsSubFieldSuggestions() {
|
||||
void suggestionContainsSubFieldSuggestions() {
|
||||
final String rsqlQuery = "assignedds.";
|
||||
final List<String> currentSuggestions = getSuggestions(rsqlQuery);
|
||||
assertThat(currentSuggestions).containsOnly(NAME_VERSION_SUGGESTIONS);
|
||||
@@ -76,6 +75,6 @@ public class RSQLParserValidationOracleTest extends AbstractJpaIntegrationTest {
|
||||
return rsqlValidationOracle
|
||||
.suggest(rsqlQuery, -1).getSuggestionContext().getSuggestions().stream()
|
||||
.map(SuggestToken::getSuggestion)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -29,13 +29,13 @@ import org.springframework.orm.jpa.vendor.Database;
|
||||
|
||||
@Feature("Component Tests - Repository")
|
||||
@Story("RSQL filter rollout group")
|
||||
public class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest {
|
||||
class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private Long rolloutGroupId;
|
||||
private Rollout rollout;
|
||||
|
||||
@BeforeEach
|
||||
public void setupBeforeTest() {
|
||||
void setupBeforeTest() {
|
||||
final int amountTargets = 20;
|
||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
@@ -47,7 +47,7 @@ public class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter rollout group by id")
|
||||
public void testFilterByParameterId() {
|
||||
void testFilterByParameterId() {
|
||||
assertRSQLQuery(RolloutGroupFields.ID.name() + "==" + rolloutGroupId, 1);
|
||||
assertRSQLQuery(RolloutGroupFields.ID.name() + "!=" + rolloutGroupId, 3);
|
||||
assertRSQLQuery(RolloutGroupFields.ID.name() + "==" + -1, 0);
|
||||
@@ -64,7 +64,7 @@ public class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter rollout group by name")
|
||||
public void testFilterByParameterName() {
|
||||
void testFilterByParameterName() {
|
||||
assertRSQLQuery(RolloutGroupFields.NAME.name() + "==group-1", 1);
|
||||
assertRSQLQuery(RolloutGroupFields.NAME.name() + "!=group-1", 3);
|
||||
assertRSQLQuery(RolloutGroupFields.NAME.name() + "==*", 4);
|
||||
@@ -75,7 +75,7 @@ public class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter rollout group by description")
|
||||
public void testFilterByParameterDescription() {
|
||||
void testFilterByParameterDescription() {
|
||||
assertRSQLQuery(RolloutGroupFields.DESCRIPTION.name() + "==group-1", 1);
|
||||
assertRSQLQuery(RolloutGroupFields.DESCRIPTION.name() + "!=group-1", 3);
|
||||
assertRSQLQuery(RolloutGroupFields.DESCRIPTION.name() + "==group*", 4);
|
||||
|
||||
@@ -28,12 +28,12 @@ import org.springframework.orm.jpa.vendor.Database;
|
||||
|
||||
@Feature("Component Tests - Repository")
|
||||
@Story("RSQL filter software module")
|
||||
public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private SoftwareModule ah;
|
||||
|
||||
@BeforeEach
|
||||
public void setupBeforeTest() {
|
||||
void setupBeforeTest() {
|
||||
ah = softwareModuleManagement.create(entityFactory.softwareModule().create().type(appType).name("agent-hub")
|
||||
.version("1.0.1").description("agent-hub"));
|
||||
softwareModuleManagement.create(entityFactory.softwareModule().create().type(runtimeType).name("oracle-jre")
|
||||
@@ -60,7 +60,7 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter software module by id")
|
||||
public void testFilterByParameterId() {
|
||||
void testFilterByParameterId() {
|
||||
assertRSQLQuery(SoftwareModuleFields.ID.name() + "==" + ah.getId(), 1);
|
||||
assertRSQLQuery(SoftwareModuleFields.ID.name() + "!=" + ah.getId(), 5);
|
||||
assertRSQLQuery(SoftwareModuleFields.ID.name() + "==" + -1, 0);
|
||||
@@ -77,7 +77,7 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter software module by name")
|
||||
public void testFilterByParameterName() {
|
||||
void testFilterByParameterName() {
|
||||
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==agent-hub", 1);
|
||||
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "!=agent-hub", 5);
|
||||
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==agent-hub*", 2);
|
||||
@@ -98,7 +98,7 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter software module by name which contain mutated vowels ")
|
||||
public void testFilterByParameterNameWithUmlaut() {
|
||||
void testFilterByParameterNameWithUmlaut() {
|
||||
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==*Ö*", 1);
|
||||
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==*Ä*", 1);
|
||||
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==*Ü*", 1);
|
||||
@@ -106,7 +106,7 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter software module by description")
|
||||
public void testFilterByParameterDescription() {
|
||||
void testFilterByParameterDescription() {
|
||||
assertRSQLQuery(SoftwareModuleFields.DESCRIPTION.name() + "==''", 1);
|
||||
assertRSQLQuery(SoftwareModuleFields.DESCRIPTION.name() + "!=''", 5);
|
||||
assertRSQLQuery(SoftwareModuleFields.DESCRIPTION.name() + "==agent-hub", 1);
|
||||
@@ -118,7 +118,7 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter software module by version")
|
||||
public void testFilterByParameterVersion() {
|
||||
void testFilterByParameterVersion() {
|
||||
assertRSQLQuery(SoftwareModuleFields.VERSION.name() + "==1.0.1", 2);
|
||||
assertRSQLQuery(SoftwareModuleFields.VERSION.name() + "!=v1.0", 6);
|
||||
assertRSQLQuery(SoftwareModuleFields.VERSION.name() + "=in=(1.0.1,1.0.2)", 2);
|
||||
@@ -127,7 +127,7 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter software module by type key")
|
||||
public void testFilterByType() {
|
||||
void testFilterByType() {
|
||||
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "==" + TestdataFactory.SM_TYPE_APP, 2);
|
||||
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "!=" + TestdataFactory.SM_TYPE_APP, 4);
|
||||
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "==noExist*", 0);
|
||||
@@ -137,7 +137,7 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter software module by metadata")
|
||||
public void testFilterByMetadata() {
|
||||
void testFilterByMetadata() {
|
||||
assertRSQLQuery(SoftwareModuleFields.METADATA.name() + ".metaKey==metaValue", 1);
|
||||
assertRSQLQuery(SoftwareModuleFields.METADATA.name() + ".metaKey!=metaValue", 1);
|
||||
assertRSQLQuery(SoftwareModuleFields.METADATA.name() + ".metaKey!=notexist", 2);
|
||||
|
||||
@@ -30,12 +30,12 @@ import org.springframework.data.domain.PageRequest;
|
||||
|
||||
@Feature("Component Tests - Repository")
|
||||
@Story("RSQL filter software module metadata")
|
||||
public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractJpaIntegrationTest {
|
||||
class RSQLSoftwareModuleMetadataFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private Long softwareModuleId;
|
||||
|
||||
@BeforeEach
|
||||
public void setupBeforeTest() {
|
||||
void setupBeforeTest() {
|
||||
final SoftwareModule softwareModule = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_APP);
|
||||
|
||||
softwareModuleId = softwareModule.getId();
|
||||
@@ -57,7 +57,7 @@ public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractJpaIntegration
|
||||
|
||||
@Test
|
||||
@Description("Test filter software module metadata by key")
|
||||
public void testFilterByParameterKey() {
|
||||
void testFilterByParameterKey() {
|
||||
assertRSQLQuery(SoftwareModuleMetadataFields.KEY.name() + "==1", 1);
|
||||
assertRSQLQuery(SoftwareModuleMetadataFields.KEY.name() + "!=1", 6);
|
||||
assertRSQLQuery(SoftwareModuleMetadataFields.KEY.name() + "=in=(1,2)", 2);
|
||||
@@ -66,7 +66,7 @@ public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractJpaIntegration
|
||||
|
||||
@Test
|
||||
@Description("Test fitler software module metadata by value")
|
||||
public void testFilterByParameterValue() {
|
||||
void testFilterByParameterValue() {
|
||||
assertRSQLQuery(SoftwareModuleMetadataFields.VALUE.name() + "==''", 1);
|
||||
assertRSQLQuery(SoftwareModuleMetadataFields.VALUE.name() + "!=''", 6);
|
||||
assertRSQLQuery(SoftwareModuleMetadataFields.VALUE.name() + "==1", 1);
|
||||
@@ -77,7 +77,7 @@ public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractJpaIntegration
|
||||
|
||||
@Test
|
||||
@Description("Test fitler software module metadata by target visible")
|
||||
public void testFilterByParameterTargetVisible() {
|
||||
void testFilterByParameterTargetVisible() {
|
||||
assertRSQLQuery(SoftwareModuleMetadataFields.TARGETVISIBLE.name() + "==true", 2);
|
||||
assertRSQLQuery(SoftwareModuleMetadataFields.TARGETVISIBLE.name() + "==false", 5);
|
||||
assertRSQLQuery(SoftwareModuleMetadataFields.TARGETVISIBLE.name() + "!=false", 2);
|
||||
|
||||
@@ -25,11 +25,11 @@ import org.springframework.orm.jpa.vendor.Database;
|
||||
|
||||
@Feature("Component Tests - Repository")
|
||||
@Story("RSQL filter software module test type")
|
||||
public class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest {
|
||||
class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter software module test type by id")
|
||||
public void testFilterByParameterId() {
|
||||
void testFilterByParameterId() {
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.ID.name() + "==" + osType.getId(), 1);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.ID.name() + "!=" + osType.getId(), 2);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.ID.name() + "==" + -1, 0);
|
||||
@@ -46,14 +46,14 @@ public class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest
|
||||
|
||||
@Test
|
||||
@Description("Test filter software module test type by name")
|
||||
public void testFilterByParameterName() {
|
||||
void testFilterByParameterName() {
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.NAME.name() + "==" + Constants.SMT_DEFAULT_OS_NAME, 1);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.NAME.name() + "!=" + Constants.SMT_DEFAULT_OS_NAME, 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Test filter software module test type by description")
|
||||
public void testFilterByParameterDescription() {
|
||||
void testFilterByParameterDescription() {
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.DESCRIPTION.name() + "==''", 0);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.DESCRIPTION.name() + "!=''", 3);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.DESCRIPTION.name() + "==Updated*", 3);
|
||||
@@ -63,7 +63,7 @@ public class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest
|
||||
|
||||
@Test
|
||||
@Description("Test filter software module test type by key")
|
||||
public void testFilterByParameterKey() {
|
||||
void testFilterByParameterKey() {
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.KEY.name() + "==os", 1);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.KEY.name() + "!=os", 2);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.KEY.name() + "=in=(os)", 1);
|
||||
@@ -72,7 +72,7 @@ public class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest
|
||||
|
||||
@Test
|
||||
@Description("Test filter software module test type by max")
|
||||
public void testFilterByMaxAssignment() {
|
||||
void testFilterByMaxAssignment() {
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.MAXASSIGNMENTS.name() + "==1", 2);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.MAXASSIGNMENTS.name() + "!=1", 1);
|
||||
}
|
||||
|
||||
@@ -26,14 +26,14 @@ import org.springframework.data.domain.PageRequest;
|
||||
|
||||
@Feature("Component Tests - Repository")
|
||||
@Story("RSQL filter target and distribution set tags")
|
||||
public class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@BeforeEach
|
||||
public void seuptBeforeTest() {
|
||||
void seuptBeforeTest() {
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
final TagCreate targetTag = entityFactory.tag().create().name(Integer.toString(i))
|
||||
.description(Integer.toString(i)).colour(i % 2 == 0 ? "red" : "blue");
|
||||
final TagCreate targetTag = entityFactory.tag().create()
|
||||
.name(Integer.toString(i)).description(Integer.toString(i)).colour(i % 2 == 0 ? "red" : "blue");
|
||||
targetTagManagement.create(targetTag);
|
||||
distributionSetTagManagement.create(targetTag);
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter target tag by name")
|
||||
public void testFilterTargetTagByParameterName() {
|
||||
void testFilterTargetTagByParameterName() {
|
||||
assertRSQLQueryTarget(TagFields.NAME.name() + "==''", 0);
|
||||
assertRSQLQueryTarget(TagFields.NAME.name() + "!=''", 5);
|
||||
assertRSQLQueryTarget(TagFields.NAME.name() + "==1", 1);
|
||||
@@ -54,7 +54,7 @@ public class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter target tag by description")
|
||||
public void testFilterTargetTagByParameterDescription() {
|
||||
void testFilterTargetTagByParameterDescription() {
|
||||
assertRSQLQueryTarget(TagFields.DESCRIPTION.name() + "==''", 0);
|
||||
assertRSQLQueryTarget(TagFields.DESCRIPTION.name() + "!=''", 5);
|
||||
assertRSQLQueryTarget(TagFields.DESCRIPTION.name() + "==1", 1);
|
||||
@@ -67,7 +67,7 @@ public class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter target tag by colour")
|
||||
public void testFilterTargetTagByParameterColour() {
|
||||
void testFilterTargetTagByParameterColour() {
|
||||
assertRSQLQueryTarget(TagFields.COLOUR.name() + "==''", 0);
|
||||
assertRSQLQueryTarget(TagFields.COLOUR.name() + "!=''", 5);
|
||||
assertRSQLQueryTarget(TagFields.COLOUR.name() + "==red", 3);
|
||||
@@ -80,7 +80,7 @@ public class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter distribution set tag by name")
|
||||
public void testFilterDistributionSetTagByParameterName() {
|
||||
void testFilterDistributionSetTagByParameterName() {
|
||||
assertRSQLQueryDistributionSet(TagFields.NAME.name() + "==''", 0);
|
||||
assertRSQLQueryDistributionSet(TagFields.NAME.name() + "!=''", 5);
|
||||
assertRSQLQueryDistributionSet(TagFields.NAME.name() + "==1", 1);
|
||||
@@ -93,7 +93,7 @@ public class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter distribution set by description")
|
||||
public void testFilterDistributionSetTagByParameterDescription() {
|
||||
void testFilterDistributionSetTagByParameterDescription() {
|
||||
assertRSQLQueryDistributionSet(TagFields.DESCRIPTION.name() + "==''", 0);
|
||||
assertRSQLQueryDistributionSet(TagFields.DESCRIPTION.name() + "!=''", 5);
|
||||
assertRSQLQueryDistributionSet(TagFields.DESCRIPTION.name() + "==1", 1);
|
||||
@@ -106,7 +106,7 @@ public class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter distribution set by colour")
|
||||
public void testFilterDistributionSetTagByParameterColour() {
|
||||
void testFilterDistributionSetTagByParameterColour() {
|
||||
assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "==''", 0);
|
||||
assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "!=''", 5);
|
||||
assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "==red", 3);
|
||||
|
||||
@@ -149,12 +149,10 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
void testFilterByParameterUpdateStatus() {
|
||||
assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "==pending", 1);
|
||||
assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "!=pending", 4);
|
||||
try {
|
||||
assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "==noExist*", 0);
|
||||
fail("RSQLParameterUnsupportedFieldException was expected since update status unknown");
|
||||
} catch (final RSQLParameterUnsupportedFieldException e) {
|
||||
// test ok - exception was excepted
|
||||
}
|
||||
final String rsqlNoExistStar = TargetFields.UPDATESTATUS.name() + "==noExist*";
|
||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||
.as("update status unknown")
|
||||
.isThrownBy(() -> assertRSQLQuery(rsqlNoExistStar, 0));
|
||||
assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "=in=(pending,error)", 1);
|
||||
assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "=out=(pending,error)", 4);
|
||||
}
|
||||
|
||||
@@ -28,13 +28,13 @@ import org.springframework.orm.jpa.vendor.Database;
|
||||
|
||||
@Feature("Component Tests - Repository")
|
||||
@Story("RSQL filter target filter query")
|
||||
public class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest {
|
||||
class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private TargetFilterQuery filter1;
|
||||
private TargetFilterQuery filter2;
|
||||
|
||||
@BeforeEach
|
||||
public void setupBeforeTest() {
|
||||
void setupBeforeTest() {
|
||||
final String filterName1 = "filter_a";
|
||||
final String filterName2 = "filter_b";
|
||||
final String filterName3 = "filter_c";
|
||||
@@ -54,7 +54,7 @@ public class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest
|
||||
|
||||
@Test
|
||||
@Description("Test filter target filter query by id")
|
||||
public void testFilterByParameterId() {
|
||||
void testFilterByParameterId() {
|
||||
assertRSQLQuery(TargetFilterQueryFields.ID.name() + "==" + filter1.getId(), 1);
|
||||
assertRSQLQuery(TargetFilterQueryFields.ID.name() + "!=" + filter1.getId(), 2);
|
||||
assertRSQLQuery(TargetFilterQueryFields.ID.name() + "==" + -1, 0);
|
||||
@@ -72,7 +72,7 @@ public class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest
|
||||
|
||||
@Test
|
||||
@Description("Test filter target filter query by name")
|
||||
public void testFilterByParameterName() {
|
||||
void testFilterByParameterName() {
|
||||
assertRSQLQuery(TargetFilterQueryFields.NAME.name() + "==" + filter1.getName(), 1);
|
||||
assertRSQLQuery(TargetFilterQueryFields.NAME.name() + "==" + filter2.getName(), 1);
|
||||
assertRSQLQuery(TargetFilterQueryFields.NAME.name() + "==filter_*", 3);
|
||||
@@ -83,7 +83,7 @@ public class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest
|
||||
|
||||
@Test
|
||||
@Description("Test filter target filter query by auto assigned ds name")
|
||||
public void testFilterByAutoAssignedDsName() {
|
||||
void testFilterByAutoAssignedDsName() {
|
||||
assertRSQLQuery(TargetFilterQueryFields.AUTOASSIGNDISTRIBUTIONSET.name() + ".name=="
|
||||
+ filter1.getAutoAssignDistributionSet().getName(), 1);
|
||||
assertRSQLQuery(TargetFilterQueryFields.AUTOASSIGNDISTRIBUTIONSET.name() + ".name=="
|
||||
@@ -98,7 +98,7 @@ public class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest
|
||||
|
||||
@Test
|
||||
@Description("Test filter target filter query by auto assigned ds version")
|
||||
public void testFilterByAutoAssignedDsVersion() {
|
||||
void testFilterByAutoAssignedDsVersion() {
|
||||
assertRSQLQuery(TargetFilterQueryFields.AUTOASSIGNDISTRIBUTIONSET.name() + ".version=="
|
||||
+ TestdataFactory.DEFAULT_VERSION, 2);
|
||||
assertRSQLQuery(TargetFilterQueryFields.AUTOASSIGNDISTRIBUTIONSET.name() + ".version==*1*", 2);
|
||||
|
||||
@@ -30,12 +30,12 @@ import org.springframework.data.domain.PageRequest;
|
||||
|
||||
@Feature("Component Tests - Repository")
|
||||
@Story("RSQL filter target metadata")
|
||||
public class RSQLTargetMetadataFieldsTest extends AbstractJpaIntegrationTest {
|
||||
class RSQLTargetMetadataFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private String controllerId;
|
||||
|
||||
@BeforeEach
|
||||
public void setupBeforeTest() {
|
||||
void setupBeforeTest() {
|
||||
final Target target = testdataFactory.createTarget("target");
|
||||
controllerId = target.getControllerId();
|
||||
|
||||
@@ -52,7 +52,7 @@ public class RSQLTargetMetadataFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter target metadata by key")
|
||||
public void testFilterByParameterKey() {
|
||||
void testFilterByParameterKey() {
|
||||
assertRSQLQuery(TargetMetadataFields.KEY.name() + "==1", 1);
|
||||
assertRSQLQuery(TargetMetadataFields.KEY.name() + "!=1", 5);
|
||||
assertRSQLQuery(TargetMetadataFields.KEY.name() + "=in=(1,2)", 2);
|
||||
@@ -61,7 +61,7 @@ public class RSQLTargetMetadataFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Test filter target metadata by value")
|
||||
public void testFilterByParameterValue() {
|
||||
void testFilterByParameterValue() {
|
||||
assertRSQLQuery(TargetMetadataFields.VALUE.name() + "==''", 1);
|
||||
assertRSQLQuery(TargetMetadataFields.VALUE.name() + "!=''", 5);
|
||||
assertRSQLQuery(TargetMetadataFields.VALUE.name() + "==1", 1);
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
@ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, TestConfiguration.class })
|
||||
@Import(TestChannelBinderConfiguration.class)
|
||||
@Disabled("For manual run only, while playing around with RSQL to SQL")
|
||||
@SuppressWarnings("java:S2699") // java:S2699 - manual test, don't actually does assertions
|
||||
class RSQLToSQLTest {
|
||||
|
||||
private RSQLToSQL rsqlToSQL;
|
||||
|
||||
@@ -12,8 +12,8 @@ package org.eclipse.hawkbit.repository.jpa.tenancy;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
@@ -75,7 +75,7 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
// find all targets for current tenant "mytenant"
|
||||
final Slice<Target> findTargetsAll = targetManagement.findAll(PAGE);
|
||||
// no target has been created for "mytenant"
|
||||
assertThat(findTargetsAll).hasSize(0);
|
||||
assertThat(findTargetsAll).isEmpty();
|
||||
|
||||
// find all targets for anotherTenant
|
||||
final Slice<Target> findTargetsForTenant = findTargetsForTenant(anotherTenant);
|
||||
@@ -126,11 +126,11 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
// create target for another tenant
|
||||
final String anotherTenant = "anotherTenant";
|
||||
final String controllerAnotherTenant = "anotherController";
|
||||
final Target createTargetForTenant = createTargetForTenant(controllerAnotherTenant, anotherTenant);
|
||||
final List<Long> createTargetForTenant = List.of(createTargetForTenant(controllerAnotherTenant, anotherTenant).getId());
|
||||
|
||||
// ensure target cannot be deleted by 'mytenant'
|
||||
try {
|
||||
targetManagement.delete(Arrays.asList(createTargetForTenant.getId()));
|
||||
targetManagement.delete(createTargetForTenant);
|
||||
fail("mytenant should not have been able to delete target of anotherTenant");
|
||||
} catch (final EntityNotFoundException ex) {
|
||||
// ok
|
||||
@@ -140,9 +140,9 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(targetsForAnotherTenant).hasSize(1);
|
||||
|
||||
// ensure another tenant can delete the target
|
||||
deleteTargetsForTenant(anotherTenant, Arrays.asList(createTargetForTenant.getId()));
|
||||
deleteTargetsForTenant(anotherTenant, createTargetForTenant);
|
||||
targetsForAnotherTenant = findTargetsForTenant(anotherTenant);
|
||||
assertThat(targetsForAnotherTenant).hasSize(0);
|
||||
assertThat(targetsForAnotherTenant).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user