Fix sonar findings (#2572)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-07-30 10:13:23 +03:00
committed by GitHub
parent d6978e5270
commit 10da0288d9
48 changed files with 97 additions and 152 deletions

View File

@@ -103,6 +103,8 @@ import org.eclipse.hawkbit.repository.jpa.rollout.condition.StartNextGroupRollou
import org.eclipse.hawkbit.repository.jpa.rollout.condition.ThresholdRolloutGroupErrorCondition;
import org.eclipse.hawkbit.repository.jpa.rollout.condition.ThresholdRolloutGroupSuccessCondition;
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlUtility;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
@@ -148,8 +150,6 @@ import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
;
/**
* General configuration for hawkBit's Repository.
*/
@@ -319,7 +319,7 @@ public class JpaRepositoryConfiguration {
* @return TargetTypeBuilder bean
*/
@Bean
TargetTypeBuilder targetTypeBuilder(final DistributionSetTypeManagement dsTypeManagement) {
TargetTypeBuilder targetTypeBuilder(final DistributionSetTypeManagement<? extends DistributionSetType> dsTypeManagement) {
return new JpaTargetTypeBuilder(dsTypeManagement);
}
@@ -334,7 +334,7 @@ public class JpaRepositoryConfiguration {
* @return RolloutBuilder bean
*/
@Bean
RolloutBuilder rolloutBuilder(final DistributionSetManagement distributionSetManagement) {
RolloutBuilder rolloutBuilder(final DistributionSetManagement<? extends DistributionSet> distributionSetManagement) {
return new JpaRolloutBuilder(distributionSetManagement);
}
@@ -344,7 +344,7 @@ public class JpaRepositoryConfiguration {
* @return TargetFilterQueryBuilder bean
*/
@Bean
TargetFilterQueryBuilder targetFilterQueryBuilder(final DistributionSetManagement distributionSetManagement) {
TargetFilterQueryBuilder targetFilterQueryBuilder(final DistributionSetManagement<? extends DistributionSet> distributionSetManagement) {
return new JpaTargetFilterQueryBuilder(distributionSetManagement);
}

View File

@@ -78,7 +78,7 @@ public class SystemManagementCacheKeyGenerator implements CurrentTenantCacheKeyG
@Override
public Object generate(final Object target, final Method method, final Object... params) {
String tenant = getTenantInCreation().orElseGet(() -> tenantAware.getCurrentTenant()).toUpperCase();
String tenant = getTenantInCreation().orElseGet(tenantAware::getCurrentTenant).toUpperCase();
return SimpleKeyGenerator.generateKey(tenant, tenant);
}
}

View File

@@ -14,6 +14,7 @@ import org.eclipse.hawkbit.repository.builder.GenericRolloutUpdate;
import org.eclipse.hawkbit.repository.builder.RolloutBuilder;
import org.eclipse.hawkbit.repository.builder.RolloutCreate;
import org.eclipse.hawkbit.repository.builder.RolloutUpdate;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Rollout;
/**
@@ -21,9 +22,9 @@ import org.eclipse.hawkbit.repository.model.Rollout;
*/
public class JpaRolloutBuilder implements RolloutBuilder {
private final DistributionSetManagement distributionSetManagement;
private final DistributionSetManagement<? extends DistributionSet> distributionSetManagement;
public JpaRolloutBuilder(final DistributionSetManagement distributionSetManagement) {
public JpaRolloutBuilder(final DistributionSetManagement<? extends DistributionSet> distributionSetManagement) {
this.distributionSetManagement = distributionSetManagement;
}

View File

@@ -33,19 +33,13 @@ public class JpaRolloutCreate extends AbstractNamedEntityBuilder<RolloutCreate>
@Min(Action.WEIGHT_MIN)
@Max(Action.WEIGHT_MAX)
protected Integer weight;
private final DistributionSetManagement distributionSetManagement;
private final DistributionSetManagement<? extends DistributionSet> distributionSetManagement;
private boolean dynamic;
JpaRolloutCreate(final DistributionSetManagement distributionSetManagement) {
JpaRolloutCreate(final DistributionSetManagement<? extends DistributionSet> distributionSetManagement) {
this.distributionSetManagement = distributionSetManagement;
}
/**
* {@link DistributionSet} of rollout
*
* @param distributionSetId ID of the distributionSetId
* @return this builder
*/
public RolloutCreate distributionSetId(final long distributionSetId) {
this.distributionSetId = distributionSetId;
return this;

View File

@@ -21,8 +21,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
* Create/build implementation.
*/
public class JpaSoftwareModuleMetadataCreate
extends AbstractSoftwareModuleMetadataUpdateCreate<SoftwareModuleMetadataCreate>
implements SoftwareModuleMetadataCreate {
extends AbstractSoftwareModuleMetadataUpdateCreate<SoftwareModuleMetadataCreate> implements SoftwareModuleMetadataCreate {
private final JpaSoftwareModuleManagement softwareModuleManagement;

View File

@@ -22,9 +22,6 @@ public class JpaTargetBuilder implements TargetBuilder {
private final TargetTypeManagement targetTypeManagement;
/**
* @param targetTypeManagement Target type management
*/
public JpaTargetBuilder(TargetTypeManagement targetTypeManagement) {
this.targetTypeManagement = targetTypeManagement;
}

View File

@@ -25,11 +25,6 @@ public class JpaTargetCreate extends AbstractTargetUpdateCreate<TargetCreate> im
private final TargetTypeManagement targetTypeManagement;
/**
* Constructor
*
* @param targetTypeManagement Target type management
*/
JpaTargetCreate(final TargetTypeManagement targetTypeManagement) {
super(null);
this.targetTypeManagement = targetTypeManagement;

View File

@@ -15,6 +15,7 @@ import org.eclipse.hawkbit.repository.builder.GenericTargetFilterQueryUpdate;
import org.eclipse.hawkbit.repository.builder.TargetFilterQueryBuilder;
import org.eclipse.hawkbit.repository.builder.TargetFilterQueryCreate;
import org.eclipse.hawkbit.repository.builder.TargetFilterQueryUpdate;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
/**
@@ -22,9 +23,9 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
*/
public class JpaTargetFilterQueryBuilder implements TargetFilterQueryBuilder {
private final DistributionSetManagement distributionSetManagement;
private final DistributionSetManagement<? extends DistributionSet> distributionSetManagement;
public JpaTargetFilterQueryBuilder(final DistributionSetManagement distributionSetManagement) {
public JpaTargetFilterQueryBuilder(final DistributionSetManagement<? extends DistributionSet> distributionSetManagement) {
this.distributionSetManagement = distributionSetManagement;
}

View File

@@ -15,6 +15,7 @@ import org.eclipse.hawkbit.repository.builder.TargetFilterQueryCreate;
import org.eclipse.hawkbit.repository.exception.InvalidAutoAssignActionTypeException;
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetFilterQuery;
import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
/**
@@ -23,9 +24,9 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
public class JpaTargetFilterQueryCreate extends AbstractTargetFilterQueryUpdateCreate<TargetFilterQueryCreate>
implements TargetFilterQueryCreate {
private final DistributionSetManagement distributionSetManagement;
private final DistributionSetManagement<? extends DistributionSet> distributionSetManagement;
JpaTargetFilterQueryCreate(final DistributionSetManagement distributionSetManagement) {
JpaTargetFilterQueryCreate(final DistributionSetManagement<? extends DistributionSet> distributionSetManagement) {
this.distributionSetManagement = distributionSetManagement;
}

View File

@@ -14,6 +14,7 @@ import org.eclipse.hawkbit.repository.builder.GenericTargetTypeUpdate;
import org.eclipse.hawkbit.repository.builder.TargetTypeBuilder;
import org.eclipse.hawkbit.repository.builder.TargetTypeCreate;
import org.eclipse.hawkbit.repository.builder.TargetTypeUpdate;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.TargetType;
/**
@@ -21,14 +22,9 @@ import org.eclipse.hawkbit.repository.model.TargetType;
*/
public class JpaTargetTypeBuilder implements TargetTypeBuilder {
private final DistributionSetTypeManagement distributionSetTypeManagement;
private final DistributionSetTypeManagement<? extends DistributionSetType> distributionSetTypeManagement;
/**
* Constructor
*
* @param distributionSetTypeManagement Distribution set type management
*/
public JpaTargetTypeBuilder(DistributionSetTypeManagement distributionSetTypeManagement) {
public JpaTargetTypeBuilder(DistributionSetTypeManagement<? extends DistributionSetType> distributionSetTypeManagement) {
this.distributionSetTypeManagement = distributionSetTypeManagement;
}

View File

@@ -27,14 +27,9 @@ import org.springframework.util.CollectionUtils;
*/
public class JpaTargetTypeCreate extends AbstractTargetTypeUpdateCreate<TargetTypeCreate> implements TargetTypeCreate {
private final DistributionSetTypeManagement distributionSetTypeManagement;
private final DistributionSetTypeManagement<? extends DistributionSetType> distributionSetTypeManagement;
/**
* Constructor
*
* @param distributionSetTypeManagement Distribution set type management
*/
JpaTargetTypeCreate(final DistributionSetTypeManagement distributionSetTypeManagement) {
JpaTargetTypeCreate(final DistributionSetTypeManagement<? extends DistributionSetType> distributionSetTypeManagement) {
this.distributionSetTypeManagement = distributionSetTypeManagement;
}
@@ -49,13 +44,13 @@ public class JpaTargetTypeCreate extends AbstractTargetTypeUpdateCreate<TargetTy
return result;
}
private Collection<DistributionSetType> findDistributionSetTypeWithExceptionIfNotFound(
private Collection<? extends DistributionSetType> findDistributionSetTypeWithExceptionIfNotFound(
final Collection<Long> distributionSetTypeId) {
if (CollectionUtils.isEmpty(distributionSetTypeId)) {
return Collections.emptyList();
}
final Collection<DistributionSetType> type = distributionSetTypeManagement.get(distributionSetTypeId);
final Collection<? extends DistributionSetType> type = distributionSetTypeManagement.get(distributionSetTypeId);
if (type.size() < distributionSetTypeId.size()) {
throw new EntityNotFoundException(SoftwareModuleType.class, distributionSetTypeId);
}

View File

@@ -780,9 +780,9 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
final String initiatedBy, final Long dsId,
final Collection<TargetWithActionType> targetsWithActionType, final String actionMessage,
final AbstractDsAssignmentStrategy assignmentStrategy) {
final JpaDistributionSet distributionSet = (JpaDistributionSet) distributionSetManagement.getValidAndComplete(dsId);
final JpaDistributionSet distributionSet = distributionSetManagement.getValidAndComplete(dsId);
if (((JpaDistributionSetManagement) distributionSetManagement).isImplicitLockApplicable(distributionSet)) {
if (distributionSetManagement.isImplicitLockApplicable(distributionSet)) {
// without new transaction DS changed event is not thrown
DeploymentHelper.runInNewTransaction(txManager, "Implicit lock", status -> {
distributionSetManagement.lock(distributionSet.getId());
@@ -951,7 +951,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
return action;
}
final JpaTarget target = (JpaTarget) action.getTarget();
final JpaTarget target = action.getTarget();
if (target.getAssignedDistributionSet() != null
&& action.getDistributionSet().getId().equals(target.getAssignedDistributionSet().getId())) {
// the target has already the distribution set assigned, we don't
@@ -1003,8 +1003,8 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
private void setAssignmentOnTargets(final List<JpaAction> actions) {
final List<JpaTarget> assignedDsTargets = actions.stream().map(savedAction -> {
final JpaTarget mergedTarget = (JpaTarget) entityManager.merge(savedAction.getTarget());
mergedTarget.setAssignedDistributionSet((JpaDistributionSet) savedAction.getDistributionSet());
final JpaTarget mergedTarget = entityManager.merge(savedAction.getTarget());
mergedTarget.setAssignedDistributionSet(savedAction.getDistributionSet());
mergedTarget.setUpdateStatus(TargetUpdateStatus.PENDING);
return mergedTarget;
}).toList();

View File

@@ -132,6 +132,7 @@ public class JpaDistributionSetManagement
this.repositoryProperties = repositoryProperties;
}
@SuppressWarnings("java:S1066") // java:S1066 better readable without merging the if statements
@Override
public JpaDistributionSet update(final Update update) {
final JpaDistributionSet distributionSet = getValid0(update.getId());
@@ -164,6 +165,7 @@ public class JpaDistributionSetManagement
return toDelete.stream().filter(distributionSet -> assigned.contains(distributionSet.getId())).toList();
}
@Override
protected void delete0(final Collection<Long> distributionSetIDs) {
if (ObjectUtils.isEmpty(distributionSetIDs)) {
return; // super checks but if empty we don't want to unassign from target filters

View File

@@ -119,7 +119,7 @@ public class JpaRolloutManagement implements RolloutManagement {
private final RolloutStatusCache rolloutStatusCache;
private final ActionRepository actionRepository;
private final TargetManagement targetManagement;
private final DistributionSetManagement distributionSetManagement;
private final DistributionSetManagement<? extends DistributionSet> distributionSetManagement;
private final TenantConfigurationManagement tenantConfigurationManagement;
private final QuotaManagement quotaManagement;
private final AfterTransactionCommitExecutor afterCommit;
@@ -135,7 +135,7 @@ public class JpaRolloutManagement implements RolloutManagement {
final RolloutStatusCache rolloutStatusCache,
final ActionRepository actionRepository,
final TargetManagement targetManagement,
final DistributionSetManagement distributionSetManagement,
final DistributionSetManagement<? extends DistributionSet> distributionSetManagement,
final TenantConfigurationManagement tenantConfigurationManagement,
final QuotaManagement quotaManagement,
final AfterTransactionCommitExecutor afterCommit,

View File

@@ -28,7 +28,6 @@ import org.eclipse.hawkbit.repository.QuotaManagement;
import org.eclipse.hawkbit.repository.RepositoryConstants;
import org.eclipse.hawkbit.repository.SoftwareModuleFields;
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
import org.eclipse.hawkbit.repository.artifact.encryption.ArtifactEncryptionService;
import org.eclipse.hawkbit.repository.builder.GenericSoftwareModuleMetadataUpdate;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleMetadataCreate;
@@ -77,7 +76,6 @@ public class JpaSoftwareModuleManagement
protected static final String SOFTWARE_MODULE_METADATA = "SoftwareModuleMetadata";
private final SoftwareModuleTypeManagement<? extends SoftwareModuleType> softwareModuleTypeManagement;
private final DistributionSetRepository distributionSetRepository;
private final SoftwareModuleMetadataRepository softwareModuleMetadataRepository;
private final SoftwareModuleTypeRepository softwareModuleTypeRepository;
@@ -87,13 +85,11 @@ public class JpaSoftwareModuleManagement
protected JpaSoftwareModuleManagement(
final SoftwareModuleRepository softwareModuleRepository,
final EntityManager entityManager,
final SoftwareModuleTypeManagement<? extends SoftwareModuleType> softwareModuleTypeManagement,
final DistributionSetRepository distributionSetRepository,
final SoftwareModuleMetadataRepository softwareModuleMetadataRepository,
final SoftwareModuleTypeRepository softwareModuleTypeRepository,
final ArtifactManagement artifactManagement, final QuotaManagement quotaManagement) {
super(softwareModuleRepository, entityManager);
this.softwareModuleTypeManagement = softwareModuleTypeManagement;
this.distributionSetRepository = distributionSetRepository;
this.softwareModuleMetadataRepository = softwareModuleMetadataRepository;
this.softwareModuleTypeRepository = softwareModuleTypeRepository;

View File

@@ -20,7 +20,6 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTypeRepository;
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleRepository;
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleTypeRepository;
import org.eclipse.hawkbit.repository.jpa.utils.ExceptionMapper;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
import org.springframework.stereotype.Service;

View File

@@ -36,7 +36,6 @@ import jakarta.persistence.metamodel.MapAttribute;
import jakarta.validation.constraints.NotEmpty;
import org.apache.commons.collections4.ListUtils;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.FilterParams;
import org.eclipse.hawkbit.repository.QuotaManagement;
import org.eclipse.hawkbit.repository.TargetFields;

View File

@@ -52,7 +52,7 @@ public class JpaTargetTagManagement implements TargetTagManagement {
private final TargetTagRepository targetTagRepository;
protected JpaTargetTagManagement(final TargetTagRepository targetTagRepository) {
this.targetTagRepository = targetTagRepository;;
this.targetTagRepository = targetTagRepository;
}
@Override

View File

@@ -204,9 +204,7 @@ public class JpaTenantConfigurationManagement implements TenantConfigurationMana
return;
}
event.getEntity().ifPresent(tenantConfiguration -> {
evictCacheEntryByKeyIfPresent(tenantConfiguration.getKey());
});
event.getEntity().ifPresent(tenantConfiguration -> evictCacheEntryByKeyIfPresent(tenantConfiguration.getKey()));
}
@Override

View File

@@ -13,7 +13,6 @@ import jakarta.persistence.criteria.Predicate;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.eclipse.hawkbit.repository.jpa.model.AbstractJpaNamedEntity_;
import org.eclipse.hawkbit.repository.jpa.model.JpaRollout;
import org.eclipse.hawkbit.repository.jpa.model.JpaRollout_;
import org.eclipse.hawkbit.repository.model.Rollout;

View File

@@ -57,7 +57,7 @@ public final class DeploymentHelper {
action.setActive(false);
action.setStatus(Status.CANCELED);
final JpaTarget target = (JpaTarget) action.getTarget();
final JpaTarget target = action.getTarget();
final List<Action> nextActiveActions = actionRepository
.findAll(ActionSpecifications.byTargetIdAndIsActive(target.getId()), Sort.by(Sort.Order.asc(AbstractJpaBaseEntity_.ID)))
.stream()

View File

@@ -102,7 +102,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2) })
void updateTargetAttributesFailsIfTooManyEntries() throws Exception {
void updateTargetAttributesFailsIfTooManyEntries() {
final String controllerId = "test123";
final int allowedAttributes = quotaManagement.getMaxAttributeEntriesPerTarget();
testdataFactory.createTarget(controllerId);
@@ -178,7 +178,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
void controllerProvidesIntermediateFeedbackFailsIfQuotaHit() throws Exception {
void controllerProvidesIntermediateFeedbackFailsIfQuotaHit() {
final int allowStatusEntries = 10;
final Long actionId = createTargetAndAssignDs();
@@ -1154,7 +1154,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 3) })
void updateTargetAttributes() throws Exception {
void updateTargetAttributes() {
final String controllerId = "test123";
final Target target = testdataFactory.createTarget(controllerId);

View File

@@ -17,6 +17,7 @@ import java.util.List;
import jakarta.validation.ConstraintViolationException;
import org.assertj.core.api.Assertions;
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
@@ -27,7 +28,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.test.matcher.Expect;
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
import org.junit.jupiter.api.Test;
import org.springframework.data.domain.Slice;
/**
* Feature: Component Tests - Repository<br/>
@@ -40,7 +40,7 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
* of Optional not present.
*/
@Test
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 0) })
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class) })
void nonExistingEntityAccessReturnsNotPresent() {
assertThat(softwareModuleTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
@@ -53,7 +53,7 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
* by means of throwing EntityNotFoundException.
*/
@Test
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 0) })
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class) })
void entityQueriesReferringToNotExistingEntitiesThrowsException() {
verifyThrownExceptionBy(() -> softwareModuleTypeManagement.delete(NOT_EXIST_IDL), "SoftwareModuleType");
@@ -114,35 +114,35 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
*/
@Test
void deleteAssignedAndUnassignedSoftwareModuleTypes() {
assertThat((Slice) softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
Assertions.<SoftwareModuleType>assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
SoftwareModuleType type = softwareModuleTypeManagement
.create(SoftwareModuleTypeManagement.Create.builder().key("bundle").name("OSGi Bundle").build());
assertThat((Slice) softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType, runtimeType, appType, type);
Assertions.<SoftwareModuleType>assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType, runtimeType, appType, type);
// delete unassigned
softwareModuleTypeManagement.delete(type.getId());
assertThat((Slice) softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
assertThat((List) softwareModuleTypeRepository.findAll()).hasSize(3).contains(osType, runtimeType, appType);
Assertions.<SoftwareModuleType>assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
Assertions.<SoftwareModuleType>assertThat(softwareModuleTypeRepository.findAll()).hasSize(3).contains(osType, runtimeType, appType);
type = softwareModuleTypeManagement
.create(SoftwareModuleTypeManagement.Create.builder().key("bundle2").name("OSGi Bundle2").build());
assertThat((Slice) softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType, runtimeType, appType, type);
Assertions.<SoftwareModuleType>assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType, runtimeType, appType, type);
softwareModuleManagement
.create(SoftwareModuleManagement.Create.builder().type(type).name("Test SM").version("1.0").build());
// delete assigned
softwareModuleTypeManagement.delete(type.getId());
assertThat((Slice) softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
assertThat((Slice) softwareModuleTypeManagement.findByRsql("name==*", PAGE)).hasSize(3).contains(osType, runtimeType, appType);
Assertions.<SoftwareModuleType>assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
Assertions.<SoftwareModuleType>assertThat(softwareModuleTypeManagement.findByRsql("name==*", PAGE)).hasSize(3).contains(osType, runtimeType, appType);
assertThat(softwareModuleTypeManagement.count()).isEqualTo(3);
assertThat(softwareModuleTypeRepository.findAll()).hasSize(4).contains((JpaSoftwareModuleType) osType,
(JpaSoftwareModuleType) runtimeType, (JpaSoftwareModuleType) appType,
softwareModuleTypeRepository.findById(type.getId()).get());
softwareModuleTypeRepository.findById(type.getId()).orElseThrow());
}
/**
@@ -156,8 +156,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
softwareModuleTypeManagement
.create(SoftwareModuleTypeManagement.Create.builder().key("thetype2").name("anothername").build());
assertThat((((SoftwareModuleTypeManagement<SoftwareModuleType>) softwareModuleTypeManagement)).findByName("thename")).as(
"Type with given name").contains(found);
Assertions.<SoftwareModuleType>assertThat(((SoftwareModuleTypeManagement<SoftwareModuleType>) softwareModuleTypeManagement).findByName("thename"))
.as("Type with given name").contains(found);
}
/**

View File

@@ -129,8 +129,7 @@ class SystemManagementTest extends AbstractJpaIntegrationTest {
assertThat(tenants).containsOnly(new TenantUsage("DEFAULT"), tenantUsage0, tenantUsage1);
}
private byte[] createTestTenantsForSystemStatistics(final int tenants, final int artifactSize, final int targets,
final int updates) throws Exception {
private byte[] createTestTenantsForSystemStatistics(final int tenants, final int artifactSize, final int targets, final int updates) {
final Random randomgen = new Random();
final byte[] random = new byte[artifactSize];
randomgen.nextBytes(random);