Refactor management api style (#2445)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -648,10 +648,10 @@ public class JpaRolloutExecutor implements RolloutExecutor {
|
||||
final Slice<Target> targets;
|
||||
if (!RolloutHelper.isRolloutRetried(rollout.getTargetFilterQuery())) {
|
||||
targets = targetManagement.findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable(
|
||||
pageRequest, readyGroups, targetFilter, rollout.getDistributionSet().getType());
|
||||
readyGroups, targetFilter, rollout.getDistributionSet().getType(), pageRequest);
|
||||
} else {
|
||||
targets = targetManagement.findByFailedRolloutAndNotInRolloutGroups(
|
||||
pageRequest, readyGroups, RolloutHelper.getIdFromRetriedTargetFilter(rollout.getTargetFilterQuery()));
|
||||
RolloutHelper.getIdFromRetriedTargetFilter(rollout.getTargetFilterQuery()), readyGroups, pageRequest);
|
||||
}
|
||||
|
||||
rolloutTargetGroupRepository.saveAll(targets.stream().map(target -> new RolloutTargetGroup(group, target)).toList());
|
||||
@@ -772,10 +772,10 @@ public class JpaRolloutExecutor implements RolloutExecutor {
|
||||
return DeploymentHelper.runInNewTransaction(txManager, "createActionsForRolloutDynamicGroup", status -> {
|
||||
final PageRequest pageRequest = PageRequest.of(0, Math.toIntExact(limit));
|
||||
final Slice<Target> targets = targetManagement.findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable(
|
||||
pageRequest,
|
||||
rollout.getId(), rollout.getWeight().orElse(1000), // Dynamic rollouts shall always have weight!
|
||||
rolloutGroupRepository.findByRolloutOrderByIdAsc(rollout).get(0).getId(),
|
||||
targetFilter, rollout.getDistributionSet().getType());
|
||||
rollout.getId(), rollout.getWeight().orElse(1000), rolloutGroupRepository.findByRolloutOrderByIdAsc(rollout).get(0).getId(),
|
||||
targetFilter, rollout.getDistributionSet().getType(), pageRequest
|
||||
// Dynamic rollouts shall always have weight!
|
||||
);
|
||||
|
||||
if (targets.getNumberOfElements() == 0) {
|
||||
return 0;
|
||||
@@ -835,7 +835,7 @@ public class JpaRolloutExecutor implements RolloutExecutor {
|
||||
private Long createActionsForTargetsInNewTransaction(final Rollout rollout, final RolloutGroup group) {
|
||||
return DeploymentHelper.runInNewTransaction(txManager, "createActionsForTargets", status -> {
|
||||
final Slice<Target> targets = targetManagement.findByInRolloutGroupWithoutAction(
|
||||
PageRequest.of(0, JpaRolloutExecutor.TRANSACTION_TARGETS), group.getId());
|
||||
group.getId(), PageRequest.of(0, JpaRolloutExecutor.TRANSACTION_TARGETS));
|
||||
|
||||
if (targets.getNumberOfElements() > 0) {
|
||||
final DistributionSet distributionSet = rollout.getDistributionSet();
|
||||
|
||||
@@ -86,8 +86,9 @@ public class AutoAssignChecker extends AbstractAutoAssignExecutor {
|
||||
do {
|
||||
final List<String> controllerIds = targetManagement
|
||||
.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(
|
||||
PageRequest.of(0, Constants.MAX_ENTRIES_IN_STATEMENT),
|
||||
targetFilterQuery.getAutoAssignDistributionSet().getId(), targetFilterQuery.getQuery())
|
||||
targetFilterQuery.getAutoAssignDistributionSet().getId(), targetFilterQuery.getQuery(),
|
||||
PageRequest.of(0, Constants.MAX_ENTRIES_IN_STATEMENT)
|
||||
)
|
||||
.getContent().stream().map(Target::getControllerId).toList();
|
||||
log.debug(
|
||||
"Retrieved {} auto assign targets for tenant {} and target filter query id {}, starting with assignment",
|
||||
|
||||
@@ -178,11 +178,11 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Artifact> findBySoftwareModule(final Pageable pageReq, final long softwareModuleId) {
|
||||
public Page<Artifact> findBySoftwareModule(final long softwareModuleId, final Pageable pageable) {
|
||||
assertSoftwareModuleExists(softwareModuleId);
|
||||
|
||||
return localArtifactRepository
|
||||
.findAll(ArtifactSpecifications.bySoftwareModuleId(softwareModuleId), pageReq)
|
||||
.findAll(ArtifactSpecifications.bySoftwareModuleId(softwareModuleId), pageable)
|
||||
.map(Artifact.class::cast);
|
||||
}
|
||||
|
||||
|
||||
@@ -326,12 +326,12 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ActionStatus> findActionStatusByAction(final Pageable pageReq, final long actionId) {
|
||||
public Page<ActionStatus> findActionStatusByAction(final long actionId, final Pageable pageable) {
|
||||
if (!actionRepository.existsById(actionId)) {
|
||||
throw new EntityNotFoundException(Action.class, actionId);
|
||||
}
|
||||
|
||||
return actionStatusRepository.findByActionId(pageReq, actionId);
|
||||
return actionStatusRepository.findByActionId(pageable, actionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -271,11 +271,11 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countActionsByTarget(final String rsqlParam, final String controllerId) {
|
||||
public long countActionsByTarget(final String rsql, final String controllerId) {
|
||||
assertTargetReadAllowed(controllerId);
|
||||
|
||||
final List<Specification<JpaAction>> specList = Arrays.asList(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, ActionFields.class, virtualPropertyReplacer, database),
|
||||
RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database),
|
||||
ActionSpecifications.byTargetControllerId(controllerId));
|
||||
|
||||
return JpaManagementHelper.countBySpec(actionRepository, specList);
|
||||
@@ -287,9 +287,9 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countActions(final String rsqlParam) {
|
||||
public long countActions(final String rsql) {
|
||||
final List<Specification<JpaAction>> specList = List.of(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, ActionFields.class, virtualPropertyReplacer, database));
|
||||
RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database));
|
||||
return JpaManagementHelper.countBySpec(actionRepository, specList);
|
||||
}
|
||||
|
||||
@@ -312,19 +312,18 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Action> findActions(final String rsqlParam, final Pageable pageable) {
|
||||
public Slice<Action> findActions(final String rsql, final Pageable pageable) {
|
||||
final List<Specification<JpaAction>> specList = List.of(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, ActionFields.class, virtualPropertyReplacer, database));
|
||||
RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database));
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(actionRepository, specList, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Action> findActionsByTarget(final String rsqlParam, final String controllerId,
|
||||
final Pageable pageable) {
|
||||
public Page<Action> findActionsByTarget(final String rsql, final String controllerId, final Pageable pageable) {
|
||||
assertTargetReadAllowed(controllerId);
|
||||
|
||||
final List<Specification<JpaAction>> specList = Arrays.asList(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, ActionFields.class, virtualPropertyReplacer, database),
|
||||
RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database),
|
||||
ActionSpecifications.byTargetControllerId(controllerId));
|
||||
|
||||
return JpaManagementHelper.findAllWithCountBySpec(actionRepository, specList, pageable);
|
||||
@@ -338,10 +337,10 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ActionStatus> findActionStatusByAction(final Pageable pageReq, final long actionId) {
|
||||
public Page<ActionStatus> findActionStatusByAction(final long actionId, final Pageable pageable) {
|
||||
assertActionExistsAndAccessible(actionId);
|
||||
|
||||
return actionStatusRepository.findByActionId(pageReq, actionId);
|
||||
return actionStatusRepository.findByActionId(pageable, actionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -355,7 +354,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
// permissions
|
||||
// and UI which is to be removed
|
||||
@Override
|
||||
public Page<String> findMessagesByActionStatusId(final Pageable pageable, final long actionStatusId) {
|
||||
public Page<String> findMessagesByActionStatusId(final long actionStatusId, final Pageable pageable) {
|
||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
|
||||
final CriteriaQuery<String> msgQuery = cb.createQuery(String.class);
|
||||
@@ -377,7 +376,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Action> findActiveActionsByTarget(final Pageable pageable, final String controllerId) {
|
||||
public Page<Action> findActiveActionsByTarget(final String controllerId, final Pageable pageable) {
|
||||
assertTargetReadAllowed(controllerId);
|
||||
return actionRepository
|
||||
.findAll(ActionSpecifications.byTargetControllerIdAndActive(controllerId, true), pageable)
|
||||
@@ -385,7 +384,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Action> findInActiveActionsByTarget(final Pageable pageable, final String controllerId) {
|
||||
public Page<Action> findInActiveActionsByTarget(final String controllerId, final Pageable pageable) {
|
||||
assertTargetReadAllowed(controllerId);
|
||||
return actionRepository
|
||||
.findAll(ActionSpecifications.byTargetControllerIdAndActive(controllerId, false), pageable)
|
||||
|
||||
@@ -280,9 +280,9 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSet> findByRsql(final String rsqlParam, final Pageable pageable) {
|
||||
public Page<DistributionSet> findByRsql(final String rsql, final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, List.of(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetFields.class, virtualPropertyReplacer, database),
|
||||
RSQLUtility.buildRsqlSpecification(rsql, DistributionSetFields.class, virtualPropertyReplacer, database),
|
||||
DistributionSetSpecification.isNotDeleted()), pageable);
|
||||
}
|
||||
|
||||
@@ -511,7 +511,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<DistributionSet> findByCompleted(final Pageable pageReq, final Boolean complete) {
|
||||
public Slice<DistributionSet> findByCompleted(final Boolean complete, final Pageable pageReq) {
|
||||
final List<Specification<JpaDistributionSet>> specifications = buildSpecsByComplete(complete);
|
||||
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetRepository, specifications, pageReq);
|
||||
@@ -547,11 +547,11 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSet> findByRsqlAndTag(final String rsqlParam, final long tagId, final Pageable pageable) {
|
||||
public Page<DistributionSet> findByRsqlAndTag(final String rsql, final long tagId, final Pageable pageable) {
|
||||
assertDsTagExists(tagId);
|
||||
|
||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, List.of(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetFields.class, virtualPropertyReplacer,
|
||||
RSQLUtility.buildRsqlSpecification(rsql, DistributionSetFields.class, virtualPropertyReplacer,
|
||||
database),
|
||||
DistributionSetSpecification.hasTag(tagId), DistributionSetSpecification.isNotDeleted()), pageable);
|
||||
}
|
||||
|
||||
@@ -154,9 +154,9 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSetTag> findByRsql(final String rsqlParam, final Pageable pageable) {
|
||||
public Page<DistributionSetTag> findByRsql(final String rsql, final Pageable pageable) {
|
||||
final Specification<JpaDistributionSetTag> spec = RSQLUtility.buildRsqlSpecification(
|
||||
rsqlParam, DistributionSetTagFields.class, virtualPropertyReplacer, database);
|
||||
rsql, DistributionSetTagFields.class, virtualPropertyReplacer, database);
|
||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTagRepository, Collections.singletonList(spec), pageable);
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSetTag> findByDistributionSet(final Pageable pageable, final long distributionSetId) {
|
||||
public Page<DistributionSetTag> findByDistributionSet(final long distributionSetId, final Pageable pageable) {
|
||||
if (!distributionSetRepository.existsById(distributionSetId)) {
|
||||
throw new EntityNotFoundException(DistributionSet.class, distributionSetId);
|
||||
}
|
||||
|
||||
@@ -196,9 +196,9 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSetType> findByRsql(final String rsqlParam, final Pageable pageable) {
|
||||
public Page<DistributionSetType> findByRsql(final String rsql, final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTypeRepository, List.of(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetTypeFields.class, virtualPropertyReplacer, database),
|
||||
RSQLUtility.buildRsqlSpecification(rsql, DistributionSetTypeFields.class, virtualPropertyReplacer, database),
|
||||
DistributionSetTypeSpecification.isNotDeleted()), pageable);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,11 +118,11 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<RolloutGroup> findByRolloutAndRsql(final long rolloutId, final String rsqlParam, final Pageable pageable) {
|
||||
public Page<RolloutGroup> findByRolloutAndRsql(final long rolloutId, final String rsql, final Pageable pageable) {
|
||||
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
||||
|
||||
final List<Specification<JpaRolloutGroup>> specList = Arrays.asList(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, RolloutGroupFields.class, virtualPropertyReplacer,
|
||||
RSQLUtility.buildRsqlSpecification(rsql, RolloutGroupFields.class, virtualPropertyReplacer,
|
||||
database),
|
||||
(root, query, cb) -> cb.equal(root.get(JpaRolloutGroup_.rollout).get(AbstractJpaBaseEntity_.id), rolloutId));
|
||||
|
||||
@@ -130,10 +130,10 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<RolloutGroup> findByRolloutAndRsqlWithDetailedStatus(final long rolloutId, final String rsqlParam, final Pageable pageable) {
|
||||
public Page<RolloutGroup> findByRolloutAndRsqlWithDetailedStatus(final long rolloutId, final String rsql, final Pageable pageable) {
|
||||
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
||||
|
||||
final Page<RolloutGroup> rolloutGroups = findByRolloutAndRsql(rolloutId, rsqlParam, pageable);
|
||||
final Page<RolloutGroup> rolloutGroups = findByRolloutAndRsql(rolloutId, rsql, pageable);
|
||||
final List<Long> rolloutGroupIds = rolloutGroups.getContent().stream().map(RolloutGroup::getId).toList();
|
||||
if (rolloutGroupIds.isEmpty()) {
|
||||
// groups might already have been deleted, so return empty list.
|
||||
@@ -185,11 +185,11 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findTargetsOfRolloutGroupByRsql(final Pageable pageable, final long rolloutGroupId, final String rsqlParam) {
|
||||
public Page<Target> findTargetsOfRolloutGroupByRsql(final long rolloutGroupId, final String rsql, final Pageable pageable) {
|
||||
throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId);
|
||||
|
||||
final List<Specification<JpaTarget>> specList = Arrays.asList(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database),
|
||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||
(root, query, cb) -> {
|
||||
final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = root.join(JpaTarget_.rolloutTargetGroup);
|
||||
return cb.equal(rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup).get(AbstractJpaBaseEntity_.id), rolloutGroupId);
|
||||
|
||||
@@ -260,20 +260,20 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Rollout> findAll(final Pageable pageable, final boolean deleted) {
|
||||
public Page<Rollout> findAll(final boolean deleted, final Pageable pageable) {
|
||||
return JpaManagementHelper.convertPage(
|
||||
rolloutRepository.findAll(RolloutSpecification.isDeleted(deleted, pageable.getSort()), pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Rollout> findAllWithDetailedStatus(final Pageable pageable, final boolean deleted) {
|
||||
public Page<Rollout> findAllWithDetailedStatus(final boolean deleted, final Pageable pageable) {
|
||||
return appendStatusDetails(JpaManagementHelper.convertPage(
|
||||
rolloutRepository.findAll(RolloutSpecification.isDeleted(deleted, pageable.getSort()), JpaRollout_.GRAPH_ROLLOUT_DS, pageable),
|
||||
pageable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Rollout> findByRsql(final Pageable pageable, final String rsql, final boolean deleted) {
|
||||
public Page<Rollout> findByRsql(final String rsql, final boolean deleted, final Pageable pageable) {
|
||||
final List<Specification<JpaRollout>> specList = List.of(
|
||||
RSQLUtility.buildRsqlSpecification(rsql, RolloutFields.class, virtualPropertyReplacer, database),
|
||||
RolloutSpecification.isDeleted(deleted, pageable.getSort()));
|
||||
@@ -281,7 +281,7 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Rollout> findByRsqlWithDetailedStatus(final Pageable pageable, final String rsql, final boolean deleted) {
|
||||
public Page<Rollout> findByRsqlWithDetailedStatus(final String rsql, final boolean deleted, final Pageable pageable) {
|
||||
final List<Specification<JpaRollout>> specList = List.of(
|
||||
RSQLUtility.buildRsqlSpecification(rsql, RolloutFields.class, virtualPropertyReplacer, database),
|
||||
RolloutSpecification.isDeleted(deleted, pageable.getSort()));
|
||||
|
||||
@@ -259,9 +259,9 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SoftwareModule> findByRsql(final String rsqlParam, final Pageable pageable) {
|
||||
public Page<SoftwareModule> findByRsql(final String rsql, final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleRepository, List.of(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, SoftwareModuleFields.class, virtualPropertyReplacer,
|
||||
RSQLUtility.buildRsqlSpecification(rsql, SoftwareModuleFields.class, virtualPropertyReplacer,
|
||||
database),
|
||||
SoftwareModuleSpecification.isNotDeleted()), pageable);
|
||||
}
|
||||
@@ -303,7 +303,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleIdAndTargetVisible(final Pageable pageable, final long id) {
|
||||
public Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleIdAndTargetVisible(final long id, final Pageable pageable) {
|
||||
assertSoftwareModuleExists(id);
|
||||
|
||||
return JpaManagementHelper.convertPage(softwareModuleMetadataRepository.findBySoftwareModuleIdAndTargetVisible(
|
||||
|
||||
@@ -142,9 +142,9 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SoftwareModuleType> findByRsql(final String rsqlParam, final Pageable pageable) {
|
||||
public Page<SoftwareModuleType> findByRsql(final String rsql, final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleTypeRepository, List.of(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, SoftwareModuleTypeFields.class,
|
||||
RSQLUtility.buildRsqlSpecification(rsql, SoftwareModuleTypeFields.class,
|
||||
virtualPropertyReplacer, database),
|
||||
SoftwareModuleTypeSpecification.isNotDeleted()), pageable
|
||||
);
|
||||
|
||||
@@ -172,7 +172,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<TargetFilterQuery> findByName(final Pageable pageable, final String name) {
|
||||
public Slice<TargetFilterQuery> findByName(final String name, final Pageable pageable) {
|
||||
if (ObjectUtils.isEmpty(name)) {
|
||||
return findAll(pageable);
|
||||
}
|
||||
@@ -193,7 +193,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetFilterQuery> findByRsql(final Pageable pageable, final String rsqlFilter) {
|
||||
public Page<TargetFilterQuery> findByRsql(final String rsqlFilter, final Pageable pageable) {
|
||||
final List<Specification<JpaTargetFilterQuery>> specList = !ObjectUtils.isEmpty(rsqlFilter)
|
||||
? Collections.singletonList(RSQLUtility.buildRsqlSpecification(rsqlFilter,
|
||||
TargetFilterQueryFields.class, virtualPropertyReplacer, database))
|
||||
@@ -203,7 +203,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<TargetFilterQuery> findByQuery(final Pageable pageable, final String query) {
|
||||
public Slice<TargetFilterQuery> findByQuery(final String query, final Pageable pageable) {
|
||||
final List<Specification<JpaTargetFilterQuery>> specList = !ObjectUtils.isEmpty(query)
|
||||
? Collections.singletonList(TargetFilterQuerySpecification.equalsQuery(query))
|
||||
: Collections.emptyList();
|
||||
@@ -212,8 +212,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<TargetFilterQuery> findByAutoAssignDistributionSetId(@NotNull final Pageable pageable,
|
||||
final long setId) {
|
||||
public Slice<TargetFilterQuery> findByAutoAssignDistributionSetId(final long setId, @NotNull final Pageable pageable) {
|
||||
final DistributionSet distributionSet = distributionSetManagement.getOrElseThrowException(setId);
|
||||
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetFilterQueryRepository,
|
||||
@@ -222,14 +221,13 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetFilterQuery> findByAutoAssignDSAndRsql(final Pageable pageable, final long setId,
|
||||
final String rsqlFilter) {
|
||||
public Page<TargetFilterQuery> findByAutoAssignDSAndRsql(final long setId, final String rsql, final Pageable pageable) {
|
||||
final DistributionSet distributionSet = distributionSetManagement.getOrElseThrowException(setId);
|
||||
|
||||
final List<Specification<JpaTargetFilterQuery>> specList = new ArrayList<>(2);
|
||||
specList.add(TargetFilterQuerySpecification.byAutoAssignDS(distributionSet));
|
||||
if (!ObjectUtils.isEmpty(rsqlFilter)) {
|
||||
specList.add(RSQLUtility.buildRsqlSpecification(rsqlFilter, TargetFilterQueryFields.class,
|
||||
if (!ObjectUtils.isEmpty(rsql)) {
|
||||
specList.add(RSQLUtility.buildRsqlSpecification(rsql, TargetFilterQueryFields.class,
|
||||
virtualPropertyReplacer, database));
|
||||
}
|
||||
|
||||
|
||||
@@ -156,33 +156,33 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countByRsql(final String targetFilterQuery) {
|
||||
public long countByRsql(final String rsql) {
|
||||
return JpaManagementHelper.countBySpec(
|
||||
targetRepository,
|
||||
List.of(RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database)));
|
||||
List.of(RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countByRsqlAndUpdatable(String targetFilterQuery) {
|
||||
public long countByRsqlAndUpdatable(String rsql) {
|
||||
final List<Specification<JpaTarget>> specList = List.of(
|
||||
RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database));
|
||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database));
|
||||
return targetRepository.count(
|
||||
AccessController.Operation.UPDATE,
|
||||
combineWithAnd(specList));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countByRsqlAndCompatible(final String targetFilterQuery, final Long distributionSetIdTypeId) {
|
||||
public long countByRsqlAndCompatible(final String rsql, final Long distributionSetIdTypeId) {
|
||||
final List<Specification<JpaTarget>> specList = List.of(
|
||||
RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database),
|
||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||
TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetIdTypeId));
|
||||
return JpaManagementHelper.countBySpec(targetRepository, specList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countByRsqlAndCompatibleAndUpdatable(String targetFilterQuery, Long distributionSetIdTypeId) {
|
||||
public long countByRsqlAndCompatibleAndUpdatable(String rsql, Long distributionSetIdTypeId) {
|
||||
final List<Specification<JpaTarget>> specList = List.of(
|
||||
RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database),
|
||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||
TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetIdTypeId));
|
||||
return targetRepository.count(AccessController.Operation.UPDATE, combineWithAnd(specList));
|
||||
}
|
||||
@@ -246,8 +246,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Target> findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(final Pageable pageRequest,
|
||||
final long distributionSetId, final String targetFilterQuery) {
|
||||
public Slice<Target> findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(final long distributionSetId, final String rsql,
|
||||
final Pageable pageable) {
|
||||
final DistributionSet jpaDistributionSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
|
||||
final Long distSetTypeId = jpaDistributionSet.getType().getId();
|
||||
|
||||
@@ -255,15 +255,15 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
.findAllWithoutCount(
|
||||
AccessController.Operation.UPDATE,
|
||||
combineWithAnd(List.of(
|
||||
RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database),
|
||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||
TargetSpecifications.hasNotDistributionSetInActions(distributionSetId),
|
||||
TargetSpecifications.isCompatibleWithDistributionSetType(distSetTypeId))),
|
||||
pageRequest)
|
||||
pageable)
|
||||
.map(Target.class::cast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countByRsqlAndNonDSAndCompatibleAndUpdatable(final long distributionSetId, final String targetFilterQuery) {
|
||||
public long countByRsqlAndNonDSAndCompatibleAndUpdatable(final long distributionSetId, final String rsql) {
|
||||
final DistributionSet jpaDistributionSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
|
||||
final Long distSetTypeId = jpaDistributionSet.getType().getId();
|
||||
|
||||
@@ -271,35 +271,35 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
AccessController.Operation.UPDATE,
|
||||
combineWithAnd(List.of(
|
||||
RSQLUtility.buildRsqlSpecification(
|
||||
targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database),
|
||||
rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||
TargetSpecifications.hasNotDistributionSetInActions(distributionSetId),
|
||||
TargetSpecifications.isCompatibleWithDistributionSetType(distSetTypeId))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Target> findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable(
|
||||
final Pageable pageRequest, final Collection<Long> groups, final String targetFilterQuery, final DistributionSetType dsType) {
|
||||
final Collection<Long> groups, final String targetFilterQuery, final DistributionSetType dsType, final Pageable pageable) {
|
||||
return targetRepository
|
||||
.findAllWithoutCount(AccessController.Operation.UPDATE,
|
||||
combineWithAnd(List.of(
|
||||
RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database),
|
||||
TargetSpecifications.isNotInRolloutGroups(groups),
|
||||
TargetSpecifications.isCompatibleWithDistributionSetType(dsType.getId()))),
|
||||
pageRequest)
|
||||
pageable)
|
||||
.map(Target.class::cast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Target> findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable(
|
||||
final Pageable pageRequest, final long rolloutId, final int weight, final long firstGroupId, final String targetFilterQuery,
|
||||
final DistributionSetType distributionSetType) {
|
||||
final long rolloutId, final int weight, final long firstGroupId, final String targetFilterQuery,
|
||||
final DistributionSetType distributionSetType, final Pageable pageable) {
|
||||
return targetRepository
|
||||
.findAllWithoutCount(AccessController.Operation.UPDATE,
|
||||
combineWithAnd(List.of(
|
||||
RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database),
|
||||
TargetSpecifications.hasNoOverridingActionsAndNotInRollout(weight, rolloutId),
|
||||
TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetType.getId()))),
|
||||
pageRequest)
|
||||
pageable)
|
||||
.map(Target.class::cast);
|
||||
}
|
||||
|
||||
@@ -309,21 +309,20 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Target> findByFailedRolloutAndNotInRolloutGroups(Pageable pageRequest, Collection<Long> groups,
|
||||
String rolloutId) {
|
||||
public Slice<Target> findByFailedRolloutAndNotInRolloutGroups(String rolloutId, Collection<Long> groups, Pageable pageable) {
|
||||
final List<Specification<JpaTarget>> specList = List.of(
|
||||
TargetSpecifications.failedActionsForRollout(rolloutId),
|
||||
TargetSpecifications.isNotInRolloutGroups(groups));
|
||||
|
||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageRequest);
|
||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable(
|
||||
final String targetFilterQuery, final Collection<Long> groups, final DistributionSetType dsType) {
|
||||
final String rsql, final Collection<Long> groups, final DistributionSetType dsType) {
|
||||
return targetRepository.count(AccessController.Operation.UPDATE,
|
||||
combineWithAnd(List.of(
|
||||
RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database),
|
||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||
TargetSpecifications.isNotInRolloutGroups(groups),
|
||||
TargetSpecifications.isCompatibleWithDistributionSetType(dsType.getId()))));
|
||||
}
|
||||
@@ -337,33 +336,33 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Target> findByInRolloutGroupWithoutAction(final Pageable pageRequest, final long group) {
|
||||
public Slice<Target> findByInRolloutGroupWithoutAction(final long group, final Pageable pageable) {
|
||||
if (!rolloutGroupRepository.existsById(group)) {
|
||||
throw new EntityNotFoundException(RolloutGroup.class, group);
|
||||
}
|
||||
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(
|
||||
targetRepository, List.of(TargetSpecifications.hasNoActionInRolloutGroup(group)), pageRequest);
|
||||
targetRepository, List.of(TargetSpecifications.hasNoActionInRolloutGroup(group)), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findByAssignedDistributionSet(final Pageable pageReq, final long distributionSetId) {
|
||||
public Page<Target> findByAssignedDistributionSet(final long distributionSetId, final Pageable pageable) {
|
||||
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
|
||||
|
||||
return JpaManagementHelper.findAllWithCountBySpec(
|
||||
targetRepository,
|
||||
List.of(TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId())), pageReq);
|
||||
List.of(TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId())), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findByAssignedDistributionSetAndRsql(final Pageable pageReq, final long distributionSetId, final String rsqlParam) {
|
||||
public Page<Target> findByAssignedDistributionSetAndRsql(final long distributionSetId, final String rsql, final Pageable pageable) {
|
||||
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
|
||||
|
||||
final List<Specification<JpaTarget>> specList = List.of(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database),
|
||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||
TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId()));
|
||||
|
||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageReq);
|
||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -382,13 +381,13 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Target> findByFilters(final Pageable pageable, final FilterParams filterParams) {
|
||||
public Slice<Target> findByFilters(final FilterParams filterParams, final Pageable pageable) {
|
||||
final List<Specification<JpaTarget>> specList = buildSpecificationList(filterParams);
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetRepository, specList, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findByInstalledDistributionSet(final Pageable pageReq, final long distributionSetId) {
|
||||
public Page<Target> findByInstalledDistributionSet(final long distributionSetId, final Pageable pageReq) {
|
||||
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
|
||||
|
||||
return JpaManagementHelper.findAllWithCountBySpec(
|
||||
@@ -396,18 +395,18 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findByInstalledDistributionSetAndRsql(final Pageable pageable, final long distributionSetId, final String rsqlParam) {
|
||||
public Page<Target> findByInstalledDistributionSetAndRsql(final long distributionSetId, final String rsql, final Pageable pageable) {
|
||||
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
|
||||
|
||||
final List<Specification<JpaTarget>> specList = List.of(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database),
|
||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||
TargetSpecifications.hasInstalledDistributionSet(validDistSet.getId()));
|
||||
|
||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findByUpdateStatus(final Pageable pageable, final TargetUpdateStatus status) {
|
||||
public Page<Target> findByUpdateStatus(final TargetUpdateStatus status, final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithCountBySpec(
|
||||
targetRepository, List.of(TargetSpecifications.hasTargetUpdateStatus(status)), pageable);
|
||||
}
|
||||
@@ -418,15 +417,15 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Target> findByRsql(final Pageable pageable, final String targetFilterQuery) {
|
||||
public Slice<Target> findByRsql(final String rsql, final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(
|
||||
targetRepository,
|
||||
List.of(RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database)), pageable
|
||||
List.of(RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database)), pageable
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Target> findByTargetFilterQuery(final Pageable pageable, final long targetFilterQueryId) {
|
||||
public Slice<Target> findByTargetFilterQuery(final long targetFilterQueryId, final Pageable pageable) {
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryRepository.findById(targetFilterQueryId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId));
|
||||
|
||||
@@ -437,17 +436,17 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findByTag(final Pageable pageable, final long tagId) {
|
||||
public Page<Target> findByTag(final long tagId, final Pageable pageable) {
|
||||
throwEntityNotFoundExceptionIfTagDoesNotExist(tagId);
|
||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, List.of(TargetSpecifications.hasTag(tagId)), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findByRsqlAndTag(final Pageable pageable, final String rsqlParam, final long tagId) {
|
||||
public Page<Target> findByRsqlAndTag(final String rsql, final long tagId, final Pageable pageable) {
|
||||
throwEntityNotFoundExceptionIfTagDoesNotExist(tagId);
|
||||
|
||||
final List<Specification<JpaTarget>> specList = List.of(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database),
|
||||
RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
|
||||
TargetSpecifications.hasTag(tagId));
|
||||
|
||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
|
||||
@@ -665,9 +664,9 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findByControllerAttributesRequested(final Pageable pageReq) {
|
||||
public Page<Target> findByControllerAttributesRequested(final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithCountBySpec(
|
||||
targetRepository, List.of(TargetSpecifications.hasRequestControllerAttributesTrue()), pageReq);
|
||||
targetRepository, List.of(TargetSpecifications.hasRequestControllerAttributesTrue()), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -103,9 +103,9 @@ public class JpaTargetTagManagement implements TargetTagManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetTag> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||
public Page<TargetTag> findByRsql(final String rsql, final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithCountBySpec(targetTagRepository, Collections.singletonList(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetTagFields.class, virtualPropertyReplacer, database)), pageable);
|
||||
RSQLUtility.buildRsqlSpecification(rsql, TargetTagFields.class, virtualPropertyReplacer, database)), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -144,15 +144,15 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetType> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||
public Page<TargetType> findByRsql(final String rsql, final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithCountBySpec(targetTypeRepository, List.of(
|
||||
RSQLUtility.buildRsqlSpecification(
|
||||
rsqlParam, TargetTypeFields.class, virtualPropertyReplacer, database)), pageable
|
||||
rsql, TargetTypeFields.class, virtualPropertyReplacer, database)), pageable
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<TargetType> findByName(final Pageable pageable, final String name) {
|
||||
public Slice<TargetType> findByName(final String name, final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetTypeRepository, List.of(TargetTypeSpecification.likeName(name)), pageable
|
||||
);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
.toList()).containsOnly(permittedActionId);
|
||||
|
||||
// verify distributionSetManagement#findByCompleted
|
||||
assertThat(distributionSetManagement.findByCompleted(Pageable.unpaged(), true).get().map(Identifiable::getId)
|
||||
assertThat(distributionSetManagement.findByCompleted(true, Pageable.unpaged()).get().map(Identifiable::getId)
|
||||
.toList()).containsOnly(permittedActionId);
|
||||
|
||||
// verify distributionSetManagement#findByDistributionSetFilter
|
||||
|
||||
@@ -68,11 +68,11 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
.containsOnly(permittedTarget.getId());
|
||||
|
||||
// verify targetManagement#findByRsql
|
||||
assertThat(targetManagement.findByRsql(Pageable.unpaged(), "id==*").get().map(Identifiable::getId).toList())
|
||||
assertThat(targetManagement.findByRsql("id==*", Pageable.unpaged()).get().map(Identifiable::getId).toList())
|
||||
.containsOnly(permittedTarget.getId());
|
||||
|
||||
// verify targetManagement#findByUpdateStatus
|
||||
assertThat(targetManagement.findByUpdateStatus(Pageable.unpaged(), TargetUpdateStatus.REGISTERED).get()
|
||||
assertThat(targetManagement.findByUpdateStatus(TargetUpdateStatus.REGISTERED, Pageable.unpaged()).get()
|
||||
.map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId());
|
||||
|
||||
// verify targetManagement#getByControllerID
|
||||
@@ -105,11 +105,11 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
.create(entityFactory.targetFilterQuery().create().name("test").query("id==*"));
|
||||
|
||||
// verify targetManagement#findByTargetFilterQuery
|
||||
assertThat(targetManagement.findByTargetFilterQuery(Pageable.unpaged(), targetFilterQuery.getId()).get()
|
||||
assertThat(targetManagement.findByTargetFilterQuery(targetFilterQuery.getId(), Pageable.unpaged()).get()
|
||||
.map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId());
|
||||
|
||||
// verify targetManagement#findByTargetFilterQuery (used by UI)
|
||||
assertThat(targetManagement.findByFilters(Pageable.unpaged(), new FilterParams(null, null, null, null)).get()
|
||||
assertThat(targetManagement.findByFilters(new FilterParams(null, null, null, null), Pageable.unpaged()).get()
|
||||
.map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId());
|
||||
}
|
||||
|
||||
@@ -145,11 +145,11 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
|
||||
// verify targetManagement#findByTag
|
||||
assertThat(
|
||||
targetManagement.findByTag(Pageable.unpaged(), myTagId).get().map(Identifiable::getId).toList())
|
||||
targetManagement.findByTag(myTagId, Pageable.unpaged()).get().map(Identifiable::getId).toList())
|
||||
.containsOnly(permittedTarget.getId(), readOnlyTarget.getId());
|
||||
|
||||
// verify targetManagement#findByRsqlAndTag
|
||||
assertThat(targetManagement.findByRsqlAndTag(Pageable.unpaged(), "id==*", myTagId).get()
|
||||
assertThat(targetManagement.findByRsqlAndTag("id==*", myTagId, Pageable.unpaged()).get()
|
||||
.map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId(), readOnlyTarget.getId());
|
||||
|
||||
// verify targetManagement#assignTag on permitted target
|
||||
@@ -228,7 +228,7 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
overwriteAccess(AccessController.Operation.READ, permittedTarget);
|
||||
|
||||
// verify targetManagement#findByUpdateStatus before assignment
|
||||
assertThat(targetManagement.findByUpdateStatus(Pageable.unpaged(), TargetUpdateStatus.REGISTERED).get()
|
||||
assertThat(targetManagement.findByUpdateStatus(TargetUpdateStatus.REGISTERED, Pageable.unpaged()).get()
|
||||
.map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId());
|
||||
|
||||
testAccessControlManger.defineAccessRule(
|
||||
@@ -241,11 +241,11 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
assertThatThrownBy(() -> assignDistributionSet(dsId, hiddenTargetControllerId)).isInstanceOf(AssertionError.class);
|
||||
|
||||
// verify targetManagement#findByUpdateStatus(REGISTERED) after assignment
|
||||
assertThat(targetManagement.findByUpdateStatus(Pageable.unpaged(), TargetUpdateStatus.REGISTERED)
|
||||
assertThat(targetManagement.findByUpdateStatus(TargetUpdateStatus.REGISTERED, Pageable.unpaged())
|
||||
.getTotalElements()).isZero();
|
||||
|
||||
// verify targetManagement#findByUpdateStatus(PENDING) after assignment
|
||||
assertThat(targetManagement.findByUpdateStatus(Pageable.unpaged(), TargetUpdateStatus.PENDING).get()
|
||||
assertThat(targetManagement.findByUpdateStatus(TargetUpdateStatus.PENDING, Pageable.unpaged()).get()
|
||||
.map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId());
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
|
||||
autoAssignChecker.checkAllTargets();
|
||||
|
||||
assertThat(targetManagement.findByAssignedDistributionSet(Pageable.unpaged(), distributionSet.getId())
|
||||
assertThat(targetManagement.findByAssignedDistributionSet(distributionSet.getId(), Pageable.unpaged())
|
||||
.getContent())
|
||||
.hasSize(updateTargets.size())
|
||||
.allMatch(assignedTarget -> updateTargets.stream()
|
||||
|
||||
@@ -50,14 +50,14 @@ class TargetTypeAccessControllerTest extends AbstractAccessControllerTest {
|
||||
.containsOnly(permittedTargetType.getId());
|
||||
|
||||
// verify targetTypeManagement#findByRsql
|
||||
assertThat(targetTypeManagement.findByRsql(Pageable.unpaged(), "name==*").get().map(Identifiable::getId).toList())
|
||||
assertThat(targetTypeManagement.findByRsql("name==*", Pageable.unpaged()).get().map(Identifiable::getId).toList())
|
||||
.containsOnly(permittedTargetType.getId());
|
||||
|
||||
// verify targetTypeManagement#findByName
|
||||
assertThat(targetTypeManagement.findByName(Pageable.unpaged(), permittedTargetType.getName()).getContent())
|
||||
assertThat(targetTypeManagement.findByName(permittedTargetType.getName(), Pageable.unpaged()).getContent())
|
||||
.hasSize(1).satisfies(results ->
|
||||
assertThat(results.get(0).getId()).isEqualTo(permittedTargetType.getId()));
|
||||
assertThat(targetTypeManagement.findByName(Pageable.unpaged(), hiddenTargetType.getName())).isEmpty();
|
||||
assertThat(targetTypeManagement.findByName(hiddenTargetType.getName(), Pageable.unpaged())).isEmpty();
|
||||
|
||||
// verify targetTypeManagement#count
|
||||
assertThat(targetTypeManagement.count()).isEqualTo(1);
|
||||
|
||||
@@ -434,7 +434,7 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
|
||||
private void verifyThatTargetsHaveDistributionSetAssignedAndActionStatus(final DistributionSet set,
|
||||
final List<Target> targets, final Action.Status status) {
|
||||
final List<String> targetIds = targets.stream().map(Target::getControllerId).toList();
|
||||
final List<Target> targetsWithAssignedDS = targetManagement.findByAssignedDistributionSet(PAGE, set.getId()).getContent();
|
||||
final List<Target> targetsWithAssignedDS = targetManagement.findByAssignedDistributionSet(set.getId(), PAGE).getContent();
|
||||
assertThat(targetsWithAssignedDS).isNotEmpty();
|
||||
assertThat(targetsWithAssignedDS).allMatch(target -> targetIds.contains(target.getControllerId()));
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests ArtifactManagement#findBySoftwareModule() method")
|
||||
void findBySoftwareModulePermissionCheck() {
|
||||
assertPermissions(() -> artifactManagement.findBySoftwareModule(PAGE, 1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> artifactManagement.findBySoftwareModule(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -94,7 +94,7 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
verifyThrownExceptionBy(() -> artifactManagement.delete(NOT_EXIST_IDL), "Artifact");
|
||||
|
||||
verifyThrownExceptionBy(() -> artifactManagement.findBySoftwareModule(PAGE, NOT_EXIST_IDL), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> artifactManagement.findBySoftwareModule(NOT_EXIST_IDL, PAGE), "SoftwareModule");
|
||||
assertThat(artifactManagement.getByFilename(NOT_EXIST_ID)).isEmpty();
|
||||
|
||||
verifyThrownExceptionBy(() -> artifactManagement.getByFilenameAndSoftwareModule("xxx", NOT_EXIST_IDL), "SoftwareModule");
|
||||
@@ -170,7 +170,7 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
for (int i = 0; i < maxArtifacts; ++i) {
|
||||
artifactIds.add(createArtifactForSoftwareModule("file" + i, smId, artifactSize).getId());
|
||||
}
|
||||
assertThat(artifactManagement.findBySoftwareModule(PAGE, smId).getTotalElements()).isEqualTo(maxArtifacts);
|
||||
assertThat(artifactManagement.findBySoftwareModule(smId, PAGE).getTotalElements()).isEqualTo(maxArtifacts);
|
||||
|
||||
// create one mode to trigger the quota exceeded error
|
||||
assertThatExceptionOfType(AssignmentQuotaExceededException.class)
|
||||
@@ -178,12 +178,12 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// delete one of the artifacts
|
||||
artifactManagement.delete(artifactIds.get(0));
|
||||
assertThat(artifactManagement.findBySoftwareModule(PAGE, smId).getTotalElements())
|
||||
assertThat(artifactManagement.findBySoftwareModule(smId, PAGE).getTotalElements())
|
||||
.isEqualTo(maxArtifacts - 1);
|
||||
|
||||
// now we should be able to create an artifact again
|
||||
createArtifactForSoftwareModule("fileXYZ", smId, artifactSize);
|
||||
assertThat(artifactManagement.findBySoftwareModule(PAGE, smId).getTotalElements()).isEqualTo(maxArtifacts);
|
||||
assertThat(artifactManagement.findBySoftwareModule(smId, PAGE).getTotalElements()).isEqualTo(maxArtifacts);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -410,12 +410,12 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Searches an artifact through the relations of a software module.")
|
||||
void findArtifactBySoftwareModule() throws IOException {
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
assertThat(artifactManagement.findBySoftwareModule(PAGE, sm.getId())).isEmpty();
|
||||
assertThat(artifactManagement.findBySoftwareModule(sm.getId(), PAGE)).isEmpty();
|
||||
|
||||
final int artifactSize = 5 * 1024;
|
||||
try (final InputStream input = new RandomGeneratedInputStream(artifactSize)) {
|
||||
createArtifactForSoftwareModule("file1", sm.getId(), artifactSize, input);
|
||||
assertThat(artifactManagement.findBySoftwareModule(PAGE, sm.getId())).hasSize(1);
|
||||
assertThat(artifactManagement.findBySoftwareModule(sm.getId(), PAGE)).hasSize(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
assertThat(confirmationManagement.findActiveActionsWaitingConfirmation(controllerId)).hasSize(1)
|
||||
.allMatch(action -> action.getStatus() == Status.WAIT_FOR_CONFIRMATION);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actions.get(0).getId())).hasSize(1)
|
||||
assertThat(controllerManagement.findActionStatusByAction(actions.get(0).getId(), PAGE)).hasSize(1)
|
||||
.allMatch(status -> status.getStatus() == Status.WAIT_FOR_CONFIRMATION);
|
||||
|
||||
final Action newAction = confirmationManagement.confirmAction(actions.get(0).getId(), null, null);
|
||||
@@ -118,7 +118,7 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(newAction.getStatus()).isEqualTo(Status.RUNNING);
|
||||
|
||||
// status entry RUNNING should be present in status history
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, newAction.getId())).hasSize(2)
|
||||
assertThat(controllerManagement.findActionStatusByAction(newAction.getId(), PAGE)).hasSize(2)
|
||||
.anyMatch(status -> status.getStatus() == Status.RUNNING);
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(actions).hasSize(1).allMatch(action -> action.getStatus() == Status.WAIT_FOR_CONFIRMATION);
|
||||
assertThat(confirmationManagement.findActiveActionsWaitingConfirmation(controllerId)).hasSize(1)
|
||||
.allMatch(action -> action.getStatus() == Status.WAIT_FOR_CONFIRMATION);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actions.get(0).getId())).hasSize(1)
|
||||
assertThat(controllerManagement.findActionStatusByAction(actions.get(0).getId(), PAGE)).hasSize(1)
|
||||
.allMatch(status -> status.getStatus() == Status.WAIT_FOR_CONFIRMATION);
|
||||
|
||||
final Action newAction = confirmationManagement.denyAction(actions.get(0).getId(), null, null);
|
||||
@@ -178,7 +178,7 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(newAction.getStatus()).isEqualTo(Status.WAIT_FOR_CONFIRMATION);
|
||||
|
||||
// no status entry RUNNING should be present in status history
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, newAction.getId())).hasSize(2)
|
||||
assertThat(controllerManagement.findActionStatusByAction(newAction.getId(), PAGE)).hasSize(2)
|
||||
.noneMatch(status -> status.getStatus() == Status.RUNNING);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,8 @@ import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -87,7 +85,7 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests ControllerManagement#findActionStatusByAction() method")
|
||||
void findActionStatusByActionPermissionsCheck() {
|
||||
assertPermissions(() -> controllerManagement.findActionStatusByAction(Pageable.unpaged(), 1L),
|
||||
assertPermissions(() -> controllerManagement.findActionStatusByAction(1L, Pageable.unpaged()),
|
||||
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
|
||||
}
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final List<String> messages = controllerManagement.getActionHistoryMessages(actionId, 2);
|
||||
|
||||
assertThat(deploymentManagement.findActionStatusByAction(PAGE, actionId).getTotalElements())
|
||||
assertThat(deploymentManagement.findActionStatusByAction(actionId, PAGE).getTotalElements())
|
||||
.as("Two action-states in total").isEqualTo(3L);
|
||||
assertThat(messages.get(0)).as("Message of action-status").isEqualTo("proceeding message 2");
|
||||
assertThat(messages.get(1)).as("Message of action-status").isEqualTo("proceeding message 1");
|
||||
@@ -304,7 +304,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
Action.Status.DOWNLOAD, true);
|
||||
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(2);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(2);
|
||||
assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(2);
|
||||
assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isTrue();
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
() -> controllerManagement.getActionForDownloadByTargetAndSoftwareModule(NOT_EXIST_ID, module.getId()),
|
||||
"Target");
|
||||
|
||||
verifyThrownExceptionBy(() -> controllerManagement.findActionStatusByAction(PAGE, NOT_EXIST_IDL), "Action");
|
||||
verifyThrownExceptionBy(() -> controllerManagement.findActionStatusByAction(NOT_EXIST_IDL, PAGE), "Action");
|
||||
verifyThrownExceptionBy(() -> controllerManagement.hasTargetArtifactAssigned(NOT_EXIST_IDL, "XXX"), "Target");
|
||||
|
||||
verifyThrownExceptionBy(() -> controllerManagement.hasTargetArtifactAssigned(NOT_EXIST_ID, "XXX"), "Target");
|
||||
@@ -392,7 +392,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
Action.Status.FINISHED, false);
|
||||
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(7);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(7);
|
||||
assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(7);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -424,7 +424,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
.isThrownBy(() -> controllerManagement.addUpdateActionStatus(statusMulipleMessages));
|
||||
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(6);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(6);
|
||||
assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(6);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -452,7 +452,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
Action.Status.FINISHED, false);
|
||||
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(3);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(3);
|
||||
assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -477,7 +477,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertActionStatus(actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING, Action.Status.RUNNING, Action.Status.RUNNING, true);
|
||||
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(1);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(1);
|
||||
assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -508,7 +508,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
Action.Status.FINISHED, false);
|
||||
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(8);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8);
|
||||
assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(8);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -539,7 +539,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
Action.Status.CANCELED, false);
|
||||
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(8);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8);
|
||||
assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(8);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -571,7 +571,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
Action.Status.CANCEL_REJECTED, true);
|
||||
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(8);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8);
|
||||
assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(8);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -603,7 +603,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
Action.Status.ERROR, true);
|
||||
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(8);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8);
|
||||
assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(8);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -985,7 +985,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertActionStatus(actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.ERROR, Action.Status.ERROR, Action.Status.ERROR, false);
|
||||
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(3);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(3);
|
||||
assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1018,7 +1018,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertActionStatus(
|
||||
actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC, Action.Status.FINISHED, Action.Status.FINISHED, false);
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(3);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(3);
|
||||
assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1047,7 +1047,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(actionRepository.findById(action.getId()))
|
||||
.hasValueSatisfying(a -> assertThat(a.getStatus()).isEqualTo(Status.FINISHED));
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(3);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, action.getId()).getNumberOfElements())
|
||||
assertThat(controllerManagement.findActionStatusByAction(action.getId(), PAGE).getNumberOfElements())
|
||||
.isEqualTo(3);
|
||||
}
|
||||
|
||||
@@ -1075,7 +1075,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(targetManagement.getByControllerID(DEFAULT_CONTROLLER_ID).get().getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
// however, additional action status has been stored
|
||||
assertThat(actionStatusRepository.findAll(PAGE).getNumberOfElements()).isEqualTo(4);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, action.getId()).getNumberOfElements()).isEqualTo(4);
|
||||
assertThat(controllerManagement.findActionStatusByAction(action.getId(), PAGE).getNumberOfElements()).isEqualTo(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1148,7 +1148,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC, Action.Status.DOWNLOADED, Action.Status.DOWNLOADED, false);
|
||||
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(2);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(2);
|
||||
assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(2);
|
||||
assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isFalse();
|
||||
}
|
||||
|
||||
@@ -1175,7 +1175,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
Action.Status.FINISHED, false);
|
||||
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(3);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(3);
|
||||
assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(3);
|
||||
assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isFalse();
|
||||
}
|
||||
|
||||
@@ -1203,7 +1203,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
Status.DOWNLOADED, false);
|
||||
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(4);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(4);
|
||||
assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(4);
|
||||
assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isFalse();
|
||||
}
|
||||
|
||||
@@ -1627,7 +1627,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(targetManagement.getByControllerID(DEFAULT_CONTROLLER_ID).get().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
return deploymentManagement.findActiveActionsByTarget(PAGE, DEFAULT_CONTROLLER_ID).getContent().get(0).getId();
|
||||
return deploymentManagement.findActiveActionsByTarget(DEFAULT_CONTROLLER_ID, PAGE).getContent().get(0).getId();
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -1637,7 +1637,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
assignDistributionSet(dsId, defaultControllerId, DOWNLOAD_ONLY);
|
||||
assertThat(targetManagement.getByControllerID(defaultControllerId).get().getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
final Long id = deploymentManagement.findActiveActionsByTarget(PAGE, defaultControllerId).getContent().get(0).getId();
|
||||
final Long id = deploymentManagement.findActiveActionsByTarget(defaultControllerId, PAGE).getContent().get(0).getId();
|
||||
assertThat(id).isNotNull();
|
||||
return id;
|
||||
}
|
||||
@@ -1648,7 +1648,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(targetManagement.getByControllerID(defaultControllerId).get().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
final Long id = deploymentManagement.findActiveActionsByTarget(PAGE, defaultControllerId).getContent().get(0)
|
||||
final Long id = deploymentManagement.findActiveActionsByTarget(defaultControllerId, PAGE).getContent().get(0)
|
||||
.getId();
|
||||
assertThat(id).isNotNull();
|
||||
return id;
|
||||
@@ -1720,7 +1720,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Action action = deploymentManagement.findAction(actionId).get();
|
||||
assertThat(action.getStatus()).isEqualTo(expectedActionActionStatus);
|
||||
assertThat(action.isActive()).isEqualTo(actionActive);
|
||||
final List<ActionStatus> actionStatusList = controllerManagement.findActionStatusByAction(PAGE, actionId).getContent();
|
||||
final List<ActionStatus> actionStatusList = controllerManagement.findActionStatusByAction(actionId, PAGE).getContent();
|
||||
assertThat(actionStatusList.get(actionStatusList.size() - 1).getStatus()).isEqualTo(expectedActionStatus);
|
||||
if (actionActive) {
|
||||
assertThat(controllerManagement.findActiveActionWithHighestWeight(controllerId).get().getId()).isEqualTo(actionId);
|
||||
|
||||
@@ -122,7 +122,7 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findActionStatusByActionPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.findActionStatusByAction(Pageable.unpaged(), 1L), List.of(SpPermission.READ_TARGET));
|
||||
assertPermissions(() -> deploymentManagement.findActionStatusByAction(1L, Pageable.unpaged()), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -134,7 +134,7 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findMessagesByActionStatusIdPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.findMessagesByActionStatusId(PAGE, 1L), List.of(SpPermission.READ_TARGET));
|
||||
assertPermissions(() -> deploymentManagement.findMessagesByActionStatusId(1L, PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -146,14 +146,14 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findActiveActionsByTargetPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.findActiveActionsByTarget(Pageable.unpaged(), "controllerId"),
|
||||
assertPermissions(() -> deploymentManagement.findActiveActionsByTarget("controllerId", Pageable.unpaged()),
|
||||
List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findInActiveActionsByTargetPermissionsCheck() {
|
||||
assertPermissions(() -> deploymentManagement.findInActiveActionsByTarget(Pageable.unpaged(), "controllerId"),
|
||||
assertPermissions(() -> deploymentManagement.findInActiveActionsByTarget("controllerId", Pageable.unpaged()),
|
||||
List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,6 @@ import org.eclipse.hawkbit.repository.model.DeploymentRequest;
|
||||
import org.eclipse.hawkbit.repository.model.DeploymentRequestBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
@@ -155,8 +154,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
verifyThrownExceptionBy(() -> deploymentManagement.findActionsByTarget(NOT_EXIST_ID, PAGE), "Target");
|
||||
verifyThrownExceptionBy(() -> deploymentManagement.findActionsByTarget("id==*", NOT_EXIST_ID, PAGE), "Target");
|
||||
|
||||
verifyThrownExceptionBy(() -> deploymentManagement.findActiveActionsByTarget(PAGE, NOT_EXIST_ID), "Target");
|
||||
verifyThrownExceptionBy(() -> deploymentManagement.findInActiveActionsByTarget(PAGE, NOT_EXIST_ID), "Target");
|
||||
verifyThrownExceptionBy(() -> deploymentManagement.findActiveActionsByTarget(NOT_EXIST_ID, PAGE), "Target");
|
||||
verifyThrownExceptionBy(() -> deploymentManagement.findInActiveActionsByTarget(NOT_EXIST_ID, PAGE), "Target");
|
||||
verifyThrownExceptionBy(() -> deploymentManagement.forceQuitAction(NOT_EXIST_IDL), "Action");
|
||||
verifyThrownExceptionBy(() -> deploymentManagement.forceTargetAction(NOT_EXIST_IDL), "Action");
|
||||
}
|
||||
@@ -237,7 +236,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final ActionStatus expectedActionStatus = ((JpaAction) actions.getContent().get(0)).getActionStatus().get(0);
|
||||
|
||||
// act
|
||||
final Page<ActionStatus> actionStates = deploymentManagement.findActionStatusByAction(PAGE, actionId);
|
||||
final Page<ActionStatus> actionStates = deploymentManagement.findActionStatusByAction(actionId, PAGE);
|
||||
|
||||
assertThat(actionStates.getContent()).hasSize(1);
|
||||
assertThat(actionStates.getContent().get(0)).as("Action-status of action").isEqualTo(expectedActionStatus);
|
||||
@@ -253,7 +252,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
// create action-status entry with one message
|
||||
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId)
|
||||
.status(Action.Status.FINISHED).messages(Collections.singletonList("finished message")));
|
||||
final Page<ActionStatus> actionStates = deploymentManagement.findActionStatusByAction(PAGE, actionId);
|
||||
final Page<ActionStatus> actionStates = deploymentManagement.findActionStatusByAction(actionId, PAGE);
|
||||
|
||||
// find newly created action-status entry with message
|
||||
final JpaActionStatus actionStatusWithMessage = actionStates.getContent().stream()
|
||||
@@ -263,7 +262,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final String expectedMsg = actionStatusWithMessage.getMessages().get(0);
|
||||
|
||||
// act
|
||||
final Page<String> messages = deploymentManagement.findMessagesByActionStatusId(PAGE, actionStatusWithMessage.getId());
|
||||
final Page<String> messages = deploymentManagement.findMessagesByActionStatusId(actionStatusWithMessage.getId(), PAGE);
|
||||
|
||||
assertThat(actionStates.getTotalElements()).as("Two action-states in total").isEqualTo(2L);
|
||||
assertThat(messages.getContent().get(0)).as("Message of action-status").isEqualTo(expectedMsg);
|
||||
@@ -503,9 +502,9 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
.allMatch(action -> !action.isActive()).as("Actions should be initiated by current user")
|
||||
.allMatch(a -> a.getInitiatedBy().equals(tenantAware.getCurrentUsername()));
|
||||
|
||||
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, ds.getId()).getContent())
|
||||
assertThat(targetManagement.findByInstalledDistributionSet(ds.getId(), PAGE).getContent())
|
||||
.usingElementComparator(controllerIdComparator()).containsAll(targets).hasSize(10)
|
||||
.containsAll(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId()))
|
||||
.containsAll(targetManagement.findByAssignedDistributionSet(ds.getId(), PAGE))
|
||||
.as("InstallationDate set").allMatch(target -> target.getInstallationDate() >= current)
|
||||
.as("TargetUpdateStatus IN_SYNC")
|
||||
.allMatch(target -> TargetUpdateStatus.IN_SYNC.equals(target.getUpdateStatus()))
|
||||
@@ -583,7 +582,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertDsExclusivelyAssignedToTargets(targets, ds2.getId(), STATE_ACTIVE, RUNNING);
|
||||
assertDsExclusivelyAssignedToTargets(targets, ds1.getId(), STATE_INACTIVE, Status.CANCELED);
|
||||
|
||||
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, ds2.getId()).getContent()).hasSize(10)
|
||||
assertThat(targetManagement.findByAssignedDistributionSet(ds2.getId(), PAGE).getContent()).hasSize(10)
|
||||
.as("InstallationDate not set").allMatch(target -> (target.getInstallationDate() == null));
|
||||
|
||||
} finally {
|
||||
@@ -1050,7 +1049,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
for (final Target myt : savedDeployedTargets) {
|
||||
final Target t = targetManagement.getByControllerID(myt.getControllerId()).get();
|
||||
final List<Action> activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(PAGE, t.getControllerId()).getContent();
|
||||
final List<Action> activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(t.getControllerId(), PAGE).getContent();
|
||||
assertThat(activeActionsByTarget).as("action should not be empty").isNotEmpty();
|
||||
assertThat(t.getUpdateStatus()).as("wrong target update status").isEqualTo(TargetUpdateStatus.PENDING);
|
||||
for (final Action ua : activeActionsByTarget) {
|
||||
@@ -1211,7 +1210,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
.as("installed ds is wrong").contains(dsA);
|
||||
assertThat(targetManagement.getByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, t.getControllerId()))
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(t.getControllerId(), PAGE))
|
||||
.as("no actions should be active").isEmpty();
|
||||
}
|
||||
|
||||
@@ -1281,7 +1280,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
// verify that deleted attribute is used correctly
|
||||
List<DistributionSet> allFoundDS = distributionSetManagement.findByCompleted(PAGE, true).getContent();
|
||||
List<DistributionSet> allFoundDS = distributionSetManagement.findByCompleted(true, PAGE).getContent();
|
||||
assertThat(allFoundDS).as("no ds should be founded").isEmpty();
|
||||
|
||||
assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays
|
||||
@@ -1297,7 +1296,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
// has been installed
|
||||
// successfully and no activeAction is referring to created distribution
|
||||
// sets
|
||||
allFoundDS = distributionSetManagement.findByCompleted(pageRequest, true).getContent();
|
||||
allFoundDS = distributionSetManagement.findByCompleted(true, pageRequest).getContent();
|
||||
assertThat(allFoundDS).as("no ds should be founded").isEmpty();
|
||||
assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays
|
||||
.asList(DistributionSetSpecification.isDeleted(true), DistributionSetSpecification.isCompleted(true))),
|
||||
@@ -1353,16 +1352,16 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
.isEqualTo(distributionSetManagement.getWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||
|
||||
// verifying that the assignment is correct
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements())
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(targ.getControllerId(), PAGE).getTotalElements())
|
||||
.as("Active target actions are wrong").isEqualTo(1);
|
||||
assertThat(deploymentManagement.countActionsByTarget(targ.getControllerId())).as("Target actions are wrong")
|
||||
.isEqualTo(1);
|
||||
assertThat(targ.getUpdateStatus()).as("UpdateStatus of target is wrong").isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet(targ.getControllerId()))
|
||||
.as("Assigned distribution set of target is wrong").contains(dsA);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getContent().get(0)
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(targ.getControllerId(), PAGE).getContent().get(0)
|
||||
.getDistributionSet()).as("Distribution set of action is wrong").isEqualTo(dsA);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getContent().get(0)
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(targ.getControllerId(), PAGE).getContent().get(0)
|
||||
.getDistributionSet()).as("Installed distribution set of action should be null").isNotNull();
|
||||
|
||||
final Slice<Action> updAct = findActionsByDistributionSet(PAGE, dsA.getId());
|
||||
@@ -1371,10 +1370,10 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
targ = targetManagement.getByControllerID(targ.getControllerId()).get();
|
||||
|
||||
assertEquals(0, deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements(),
|
||||
assertEquals(0, deploymentManagement.findActiveActionsByTarget(targ.getControllerId(), PAGE).getTotalElements(),
|
||||
"active target actions are wrong");
|
||||
assertEquals(1,
|
||||
deploymentManagement.findInActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements(),
|
||||
deploymentManagement.findInActiveActionsByTarget(targ.getControllerId(), PAGE).getTotalElements(),
|
||||
"active actions are wrong");
|
||||
|
||||
assertEquals(TargetUpdateStatus.IN_SYNC, targ.getUpdateStatus(), "tagret update status is not correct");
|
||||
@@ -1389,7 +1388,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
targ = targs.iterator().next();
|
||||
|
||||
assertEquals(1, deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements(),
|
||||
assertEquals(1, deploymentManagement.findActiveActionsByTarget(targ.getControllerId(), PAGE).getTotalElements(),
|
||||
"active actions are wrong");
|
||||
assertEquals(TargetUpdateStatus.PENDING,
|
||||
targetManagement.getByControllerID(targ.getControllerId()).get().getUpdateStatus(),
|
||||
@@ -1399,7 +1398,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertEquals(dsA.getId(),
|
||||
deploymentManagement.getInstalledDistributionSet(targ.getControllerId()).get().getId(),
|
||||
"Installed ds is wrong");
|
||||
assertEquals(dsB, deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getContent()
|
||||
assertEquals(dsB, deploymentManagement.findActiveActionsByTarget(targ.getControllerId(), PAGE).getContent()
|
||||
.get(0).getDistributionSet(), "Active ds is wrong");
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ class DistributionSetManagementSecurityTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByCompletedPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.findByCompleted(PAGE, true), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> distributionSetManagement.findByCompleted(true, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -579,7 +579,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
void findDistributionSetsWithoutLazy() {
|
||||
testdataFactory.createDistributionSets(20);
|
||||
|
||||
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(20);
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(20);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -729,7 +729,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
distributionSetManagement.delete(ds1.getId());
|
||||
// not assigned so not marked as deleted but fully deleted
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(1);
|
||||
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1);
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -791,7 +791,7 @@ 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.findByCompleted(true, PAGE)).hasSize(2);
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).hasSize(2);
|
||||
assertThat(distributionSetManagement.findByRsql("name==*", PAGE)).hasSize(2);
|
||||
assertThat(distributionSetManagement.count()).isEqualTo(2);
|
||||
|
||||
@@ -52,7 +52,7 @@ class DistributionSetTagManagementSecurityTest extends AbstractRepositoryManagem
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetTagManagement.findByDistributionSet(Pageable.unpaged(), 1L),
|
||||
assertPermissions(() -> distributionSetTagManagement.findByDistributionSet(1L, Pageable.unpaged()),
|
||||
List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = TargetTagUpdatedEvent.class, count = 0) })
|
||||
void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
verifyThrownExceptionBy(() -> distributionSetTagManagement.delete(NOT_EXIST_ID), "DistributionSetTag");
|
||||
verifyThrownExceptionBy(() -> distributionSetTagManagement.findByDistributionSet(PAGE, NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> distributionSetTagManagement.findByDistributionSet(NOT_EXIST_IDL, PAGE),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(() -> distributionSetTagManagement.update(entityFactory.tag().update(NOT_EXIST_IDL)),
|
||||
"DistributionSetTag");
|
||||
|
||||
@@ -68,7 +68,7 @@ class RolloutGroupManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findTargetsOfRolloutGroupByRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(PAGE, 1L, "name==*"),
|
||||
assertPermissions(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(1L, "name==*", PAGE),
|
||||
List.of(SpPermission.READ_ROLLOUT, SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findByRolloutAndRsql(NOT_EXIST_IDL, "name==*", PAGE), "Rollout");
|
||||
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findTargetsOfRolloutGroup(NOT_EXIST_IDL, PAGE), "RolloutGroup");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(PAGE, NOT_EXIST_IDL, "name==*"), "RolloutGroup");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(NOT_EXIST_IDL, "name==*", PAGE), "RolloutGroup");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
|
||||
@Slf4j
|
||||
@Feature("SecurityTests - RolloutManagement")
|
||||
@@ -127,26 +126,26 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findAllPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.findAll(PAGE, false), List.of(SpPermission.READ_ROLLOUT));
|
||||
assertPermissions(() -> rolloutManagement.findAll(false, PAGE), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.findByRsql(PAGE, "id==1", false), List.of(SpPermission.READ_ROLLOUT));
|
||||
assertPermissions(() -> rolloutManagement.findByRsql("id==1", false, PAGE), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findAllWithDetailedStatusPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.findAllWithDetailedStatus(PAGE, false), List.of(SpPermission.READ_ROLLOUT));
|
||||
assertPermissions(() -> rolloutManagement.findAllWithDetailedStatus(false, PAGE), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByRsqlWithDetailedStatusPermissionsCheck() {
|
||||
assertPermissions(() ->
|
||||
rolloutManagement.findByRsqlWithDetailedStatus(PAGE, "name==*", false), List.of(SpPermission.READ_ROLLOUT));
|
||||
rolloutManagement.findByRsqlWithDetailedStatus("name==*", false, PAGE), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -922,7 +922,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.FINISHED, 9L);
|
||||
validateRolloutActionStatus(rolloutTwo.getId(), expectedTargetCountStatus);
|
||||
changeStatusForAllRunningActions(rolloutTwo, Status.FINISHED);
|
||||
final Page<Target> targetPage = targetManagement.findByUpdateStatus(PAGE, TargetUpdateStatus.IN_SYNC);
|
||||
final Page<Target> targetPage = targetManagement.findByUpdateStatus(TargetUpdateStatus.IN_SYNC, PAGE);
|
||||
final List<Target> targetList = targetPage.getContent();
|
||||
// 15 targets in finished/IN_SYNC status and same DS assigned
|
||||
assertThat(targetList).hasSize(amountTargetsForRollout);
|
||||
@@ -1050,7 +1050,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutHandler.handleAll();
|
||||
|
||||
final Slice<Rollout> rolloutPage = rolloutManagement
|
||||
.findAllWithDetailedStatus(new OffsetBasedPageRequest(0, 100, Sort.by(Direction.ASC, "name")), false);
|
||||
.findAllWithDetailedStatus(false, new OffsetBasedPageRequest(0, 100, Sort.by(Direction.ASC, "name")));
|
||||
final List<Rollout> rolloutList = rolloutPage.getContent();
|
||||
|
||||
// validate rolloutA -> 6 running and 6 ready
|
||||
@@ -1113,7 +1113,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
final Slice<Rollout> rollout = rolloutManagement.findByRsqlWithDetailedStatus(
|
||||
new OffsetBasedPageRequest(0, 100, Sort.by(Direction.ASC, "name")), "name==Rollout*", false);
|
||||
"name==Rollout*", false, new OffsetBasedPageRequest(0, 100, Sort.by(Direction.ASC, "name")));
|
||||
final List<Rollout> rolloutList = rollout.getContent();
|
||||
assertThat(rolloutList).hasSize(5);
|
||||
int i = 1;
|
||||
@@ -1196,41 +1196,41 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final String successCondition = "50";
|
||||
final String errorCondition = "80";
|
||||
final String rolloutName = "MyRollout";
|
||||
Rollout myRollout = createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout, amountGroups,
|
||||
successCondition, errorCondition, rolloutName, rolloutName);
|
||||
Rollout myRollout = createTestRolloutWithTargetsAndDistributionSet(
|
||||
amountTargetsForRollout, amountGroups, successCondition, errorCondition, rolloutName, rolloutName);
|
||||
|
||||
testdataFactory.createTargets(amountOtherTargets, "others-", "rollout");
|
||||
|
||||
final String rsqlParam = "controllerId==*MyRoll*";
|
||||
final String rsql = "controllerId==*MyRoll*";
|
||||
|
||||
rolloutManagement.start(myRollout.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutHandler.handleAll();
|
||||
|
||||
final Condition<String> targetBelongsInRollout = new Condition<>(s -> s.startsWith(rolloutName),
|
||||
"Target belongs into rollout");
|
||||
final Condition<String> targetBelongsInRollout = new Condition<>(s -> s.startsWith(rolloutName), "Target belongs into rollout");
|
||||
|
||||
myRollout = reloadRollout(myRollout);
|
||||
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement.findByRollout(myRollout.getId(), PAGE)
|
||||
.getContent();
|
||||
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement.findByRollout(myRollout.getId(), PAGE).getContent();
|
||||
|
||||
Page<Target> targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(
|
||||
new OffsetBasedPageRequest(0, 100), rolloutGroups.get(0).getId(), rsqlParam);
|
||||
rolloutGroups.get(0).getId(), rsql, new OffsetBasedPageRequest(0, 100));
|
||||
final List<Target> targetlistGroup1 = targetPage.getContent();
|
||||
assertThat(targetlistGroup1).hasSize(5);
|
||||
assertThat(targetlistGroup1.stream().map(Target::getControllerId).toList())
|
||||
.are(targetBelongsInRollout);
|
||||
|
||||
targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(new OffsetBasedPageRequest(0, 100),
|
||||
rolloutGroups.get(1).getId(), rsqlParam);
|
||||
targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(rolloutGroups.get(1).getId(), rsql,
|
||||
new OffsetBasedPageRequest(0, 100)
|
||||
);
|
||||
final List<Target> targetlistGroup2 = targetPage.getContent();
|
||||
assertThat(targetlistGroup2).hasSize(5);
|
||||
assertThat(targetlistGroup2.stream().map(Target::getControllerId).toList())
|
||||
.are(targetBelongsInRollout);
|
||||
|
||||
targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(new OffsetBasedPageRequest(0, 100),
|
||||
rolloutGroups.get(2).getId(), rsqlParam);
|
||||
targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(rolloutGroups.get(2).getId(), rsql,
|
||||
new OffsetBasedPageRequest(0, 100)
|
||||
);
|
||||
final List<Target> targetlistGroup3 = targetPage.getContent();
|
||||
assertThat(targetlistGroup3).hasSize(5);
|
||||
assertThat(targetlistGroup3.stream().map(Target::getControllerId).toList()).are(targetBelongsInRollout);
|
||||
@@ -1399,6 +1399,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
userWithoutHandleRollout,
|
||||
() -> createRolloutWithStartAt(rolloutName + "_withLongMax", filter, distributionSet, Long.MAX_VALUE));
|
||||
}
|
||||
|
||||
private Rollout createRolloutWithStartAt(final String rolloutName, final String filter, final DistributionSet distributionSet,
|
||||
final Long startAt) {
|
||||
return rolloutManagement.create(
|
||||
@@ -1877,10 +1878,10 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
.isThrownBy(() -> rolloutManagement.update(rolloutUpdate))
|
||||
.withMessageContaining("" + createdRollout.getId());
|
||||
|
||||
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.findAll(true, PAGE).getContent()).hasSize(1);
|
||||
assertThat(rolloutManagement.findAll(false, PAGE).getContent()).isEmpty();
|
||||
assertThat(rolloutManagement.findByRsql("name==*", true, PAGE).getContent()).hasSize(1);
|
||||
assertThat(rolloutManagement.findByRsql("name==*", false, PAGE).getContent()).isEmpty();
|
||||
assertThat(rolloutManagement.count()).isZero();
|
||||
assertThat(rolloutGroupManagement.findByRolloutWithDetailedStatus(createdRollout.getId(), PAGE).getContent()).hasSize(amountGroups);
|
||||
|
||||
@@ -1923,11 +1924,11 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutReady = reloadRollout(rolloutReady);
|
||||
|
||||
final List<Rollout> rolloutsOrderedByStatus = rolloutManagement
|
||||
.findAll(PageRequest.of(0, 500, Sort.by(Direction.ASC, "status")), false).getContent();
|
||||
.findAll(false, PageRequest.of(0, 500, Sort.by(Direction.ASC, "status"))).getContent();
|
||||
assertThat(rolloutsOrderedByStatus).containsSubsequence(List.of(rolloutReady, rolloutRunning));
|
||||
|
||||
final List<Rollout> rolloutsOrderedByName = rolloutManagement
|
||||
.findAll(PageRequest.of(0, 500, Sort.by(Direction.ASC, "name")), false).getContent();
|
||||
.findAll(false, PageRequest.of(0, 500, Sort.by(Direction.ASC, "name"))).getContent();
|
||||
assertThat(rolloutsOrderedByName).containsSubsequence(List.of(rolloutRunning, rolloutReady));
|
||||
}
|
||||
|
||||
@@ -2298,7 +2299,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final List<Target> targets = rolloutGroupManagement.findTargetsOfRolloutGroup(rolloutGroupId, PAGE)
|
||||
.getContent();
|
||||
targets.forEach(target -> {
|
||||
deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId()).getContent().stream().map(Identifiable::getId)
|
||||
deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE).getContent().stream().map(Identifiable::getId)
|
||||
.forEach(actionId -> {
|
||||
deploymentManagement.cancelAction(actionId);
|
||||
deploymentManagement.forceQuitAction(actionId);
|
||||
|
||||
@@ -103,7 +103,7 @@ class SoftwareManagementSecurityTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findMetaDataBySoftwareModuleIdAndTargetVisiblePermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(PAGE, 1L),
|
||||
assertPermissions(() -> softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(1L, PAGE),
|
||||
List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
|
||||
@@ -694,9 +694,9 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(metadataSw2).hasSize(metadataCountSw2);
|
||||
|
||||
final Page<SoftwareModuleMetadata> metadataSw1V = softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(
|
||||
PAGE_REQUEST_100, sw1.getId());
|
||||
sw1.getId(), PAGE_REQUEST_100);
|
||||
final Page<SoftwareModuleMetadata> metadataSw2V = softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(
|
||||
PAGE_REQUEST_100, sw2.getId());
|
||||
sw2.getId(), PAGE_REQUEST_100);
|
||||
assertThat(metadataSw1V.getNumberOfElements()).isEqualTo(metadataCountSw1);
|
||||
assertThat(metadataSw1V.getTotalElements()).isEqualTo(metadataCountSw1);
|
||||
assertThat(metadataSw2V.getNumberOfElements()).isZero();
|
||||
|
||||
@@ -68,7 +68,7 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByNamePermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.findByName(PAGE, "filterName"), List.of(SpPermission.READ_TARGET));
|
||||
assertPermissions(() -> targetFilterQueryManagement.findByName("filterName", PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,26 +80,26 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.findByRsql(PAGE, "name==id"), List.of(SpPermission.READ_TARGET));
|
||||
assertPermissions(() -> targetFilterQueryManagement.findByRsql("name==id", PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByQueryPermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.findByQuery(PAGE, "controllerId==id"), List.of(SpPermission.READ_TARGET));
|
||||
assertPermissions(() -> targetFilterQueryManagement.findByQuery("controllerId==id", PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByAutoAssignDistributionSetIdPermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDistributionSetId(PAGE, 1L),
|
||||
assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDistributionSetId(1L, PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByAutoAssignDSAndRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(PAGE, 1L, "rsqlParam"),
|
||||
assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(1L, "rsqlParam", PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement.delete(NOT_EXIST_IDL), "TargetFilterQuery");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
() -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(NOT_EXIST_IDL, "name==*", PAGE),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
@@ -145,7 +145,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
entityFactory.targetFilterQuery().create().name("someOtherFilter").query("name==PendingTargets002"));
|
||||
|
||||
final List<TargetFilterQuery> results = targetFilterQueryManagement
|
||||
.findByRsql(PageRequest.of(0, 10), "name==" + filterName).getContent();
|
||||
.findByRsql("name==" + filterName, PageRequest.of(0, 10)).getContent();
|
||||
assertEquals(1, results.size(), "Search result should have 1 result");
|
||||
assertEquals(targetFilterQuery, results.get(0), "Retrieved newly created custom target filter");
|
||||
}
|
||||
@@ -155,7 +155,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
void searchTargetFilterQueryInvalidField() {
|
||||
final PageRequest pageRequest = PageRequest.of(0, 10);
|
||||
Assertions.assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||
.isThrownBy(() -> targetFilterQueryManagement.findByRsql(pageRequest, "unknownField==testValue"));
|
||||
.isThrownBy(() -> targetFilterQueryManagement.findByRsql("unknownField==testValue", pageRequest));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -573,7 +573,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void verifyFindByDistributionSetAndRsql(final DistributionSet distributionSet, final String rsql,
|
||||
final TargetFilterQuery... expectedFilterQueries) {
|
||||
final Page<TargetFilterQuery> tfqList = targetFilterQueryManagement
|
||||
.findByAutoAssignDSAndRsql(PageRequest.of(0, 500), distributionSet.getId(), rsql);
|
||||
.findByAutoAssignDSAndRsql(distributionSet.getId(), rsql, PageRequest.of(0, 500));
|
||||
|
||||
assertThat(tfqList.getTotalElements()).isEqualTo(expectedFilterQueries.length);
|
||||
verifyExpectedFilterQueriesInList(tfqList, expectedFilterQueries);
|
||||
|
||||
@@ -47,13 +47,13 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final List<Target> unassigned = testdataFactory.createTargets(9, "unassigned");
|
||||
final List<Target> assigned = testdataFactory.createTargetsWithType(11, "assigned", testType);
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, new FilterParams(null, null, false, testType.getId())))
|
||||
assertThat(targetManagement.findByFilters(new FilterParams(null, null, false, testType.getId()), PAGE))
|
||||
.as("Contains the targets with set type").containsAll(assigned)
|
||||
.as("and that means the following expected amount").hasSize(11);
|
||||
assertThat(targetManagement.countByFilters(new FilterParams(null, null, false, testType.getId())))
|
||||
.as("Count the targets with set type").isEqualTo(11);
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, new FilterParams(null, null, true, null)))
|
||||
assertThat(targetManagement.findByFilters(new FilterParams(null, null, true, null), PAGE))
|
||||
.as("Contains the targets without a type").containsAll(unassigned)
|
||||
.as("and that means the following expected amount").hasSize(9);
|
||||
assertThat(targetManagement.countByFilters(new FilterParams(null, null, true, null)))
|
||||
@@ -199,7 +199,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
// get final updated version of targets
|
||||
assignedtargets = targetManagement.getByControllerID(assignedtargets.stream().map(Target::getControllerId).toList());
|
||||
|
||||
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, assignedSet.getId()))
|
||||
assertThat(targetManagement.findByAssignedDistributionSet(assignedSet.getId(), PAGE))
|
||||
.as("Contains the assigned targets").containsAll(assignedtargets)
|
||||
.as("and that means the following expected amount").hasSize(10);
|
||||
|
||||
@@ -217,7 +217,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
assignDistributionSet(assignedSet, assignedTargets);
|
||||
|
||||
final List<Target> result = targetManagement
|
||||
.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(PAGE, assignedSet.getId(), tfq.getQuery()).getContent();
|
||||
.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(assignedSet.getId(), tfq.getQuery(), PAGE).getContent();
|
||||
assertThat(result).as("count of targets").hasSize(unassignedTargets.size()).as("contains all targets")
|
||||
.containsAll(unassignedTargets);
|
||||
|
||||
@@ -239,7 +239,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
// get final updated version of targets
|
||||
installedtargets = targetManagement.getByControllerID(installedtargets.stream().map(Target::getControllerId).toList());
|
||||
|
||||
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, installedSet.getId()))
|
||||
assertThat(targetManagement.findByInstalledDistributionSet(installedSet.getId(), PAGE))
|
||||
.as("Contains the assigned targets").containsAll(installedtargets)
|
||||
.as("and that means the following expected amount").hasSize(10);
|
||||
|
||||
@@ -258,7 +258,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
targetType);
|
||||
|
||||
final List<Target> result = targetManagement
|
||||
.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(PAGE, testDs.getId(), tfq.getQuery()).getContent();
|
||||
.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(testDs.getId(), tfq.getQuery(), PAGE).getContent();
|
||||
|
||||
assertThat(result).as("count of targets").hasSize(targets.size() + targetWithCompatibleTypes.size())
|
||||
.as("contains all targets").containsAll(targetWithCompatibleTypes).containsAll(targets);
|
||||
@@ -288,7 +288,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
testTargets.addAll(targetsWithCompatibleType);
|
||||
|
||||
final List<Target> result = targetManagement
|
||||
.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(PAGE, testDs.getId(), tfq.getQuery()).getContent();
|
||||
.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(testDs.getId(), tfq.getQuery(), PAGE).getContent();
|
||||
|
||||
assertThat(result).as("count of targets").hasSize(testTargets.size()).as("contains all compatible targets")
|
||||
.containsExactlyInAnyOrderElementsOf(testTargets).as("does not contain incompatible targets")
|
||||
@@ -300,12 +300,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final List<TargetUpdateStatus> pending, final Target expected) {
|
||||
final FilterParams filterParams = new FilterParams(pending, null, null, installedSet.getId(), Boolean.FALSE);
|
||||
final String query = "updatestatus==pending and installedds.name==" + installedSet.getName();
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(1).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsExactly(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -314,12 +314,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final FilterParams filterParams = new FilterParams(both, null, null, null, Boolean.FALSE, targTagW.getName());
|
||||
final String query = "(updatestatus==pending or updatestatus==unknown) and tag==" + targTagW.getName();
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(200).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -329,12 +329,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
targTagW.getName());
|
||||
final String query = "updatestatus==pending and tag==" + targTagW.getName();
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(2).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -345,12 +345,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
|
||||
+ setA.getName() + ") and tag==" + targTagW.getName();
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(2).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -361,12 +361,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
|
||||
+ setA.getName() + ") and (name==*targ-B* or description==*targ-B*) and tag==" + targTagW.getName();
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(1).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsExactly(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -376,12 +376,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
|
||||
+ setA.getName() + ") and (name==*targ-A* or description==*targ-A*)";
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(1).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsExactly(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -391,12 +391,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
|
||||
+ setA.getName() + ")";
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(3).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -405,12 +405,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final FilterParams filterParams = new FilterParams(pending, null, null, null, Boolean.FALSE);
|
||||
final String query = "updatestatus==pending";
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(4).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -421,12 +421,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==unknown and (name==*targ-B* or description==*targ-B*) and tag=="
|
||||
+ targTagW.getName();
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(99).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -435,12 +435,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final FilterParams filterParams = new FilterParams(unknown, null, "%targ-A%", null, Boolean.FALSE);
|
||||
final String query = "updatestatus==unknown and (name==*targ-A* or description==*targ-A*)";
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(99).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -450,11 +450,11 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==unknown and (assignedds.name==" + setA.getName() + " or installedds.name=="
|
||||
+ setA.getName() + ")";
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent())
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent())
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and filter query returns the same result")
|
||||
.hasSize(targetManagement.findByRsql(PAGE, query).getContent().size())
|
||||
.hasSize(targetManagement.findByRsql(query, PAGE).getContent().size())
|
||||
.as("has number of elements")
|
||||
.isEmpty();
|
||||
}
|
||||
@@ -467,12 +467,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==unknown and (tag==" + targTagY.getName() + " or tag==" + targTagW.getName()
|
||||
+ ")";
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(198).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -481,12 +481,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final FilterParams filterParams = new FilterParams(unknown, null, null, null, Boolean.FALSE);
|
||||
final String query = "updatestatus==unknown";
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(496).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -496,12 +496,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
// be careful: simple filters are concatenated using AND-gating
|
||||
final String query = "lastcontrollerrequestat=le=${overdue_ts};updatestatus==UNKNOWN";
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(198).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -510,12 +510,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "(name==*targ-A* or description==*targ-A*) and (assignedds.name==" + setA.getName()
|
||||
+ " or installedds.name==" + setA.getName() + ")";
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(1).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsExactly(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -523,12 +523,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final FilterParams filterParams = new FilterParams(null, null, null, setA.getId(), Boolean.FALSE);
|
||||
final String query = "assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName();
|
||||
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(3).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -537,11 +537,11 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
targTagX.getName());
|
||||
final String query = "(name==*targ-C* or description==*targ-C*) and tag==" + targTagX.getName()
|
||||
+ " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")";
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent())
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent())
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and filter query returns the same result")
|
||||
.hasSize(targetManagement.findByRsql(PAGE, query).getContent().size())
|
||||
.hasSize(targetManagement.findByRsql(query, PAGE).getContent().size())
|
||||
.as("has number of elements")
|
||||
.isEmpty();
|
||||
}
|
||||
@@ -552,10 +552,10 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
targTagW.getName());
|
||||
final String query = "(name==*targ-A* or description==*targ-A*) and tag==" + targTagW.getName()
|
||||
+ " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")";
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent())
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent())
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and filter query returns the same result")
|
||||
.hasSize(targetManagement.findByRsql(PAGE, query).getContent().size())
|
||||
.hasSize(targetManagement.findByRsql(query, PAGE).getContent().size())
|
||||
.as("has number of elements")
|
||||
.isEmpty();
|
||||
}
|
||||
@@ -567,23 +567,23 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
targTagW.getName());
|
||||
final String query = "(name==*targ-c* or description==*targ-C*) and tag==" + targTagW.getName()
|
||||
+ " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")";
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(1).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsExactly(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
private void verifyThat1TargetHasNameAndId(final String name, final String controllerId) {
|
||||
final FilterParams filterParamsByName = new FilterParams(null, null, name, null, Boolean.FALSE);
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParamsByName).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParamsByName, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(1).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParamsByName));
|
||||
|
||||
final FilterParams filterParamsByControllerId = new FilterParams(null, null, controllerId, null, Boolean.FALSE);
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParamsByControllerId).getContent())
|
||||
assertThat(targetManagement.findByFilters(filterParamsByControllerId, PAGE).getContent())
|
||||
.as("has number of elements").hasSize(1).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParamsByControllerId));
|
||||
}
|
||||
@@ -595,12 +595,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
targTagY.getName(), targTagW.getName());
|
||||
final String query = "(name==*targ-B* or description==*targ-B*) and (tag==" + targTagY.getName() + " or tag=="
|
||||
+ targTagW.getName() + ")";
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(100).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
@@ -614,18 +614,18 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
private void verifyThat200TargetsHaveTagD(final TargetTag targTagD, final List<Target> expected) {
|
||||
final FilterParams filterParams = new FilterParams(null, null, null, null, Boolean.FALSE, targTagD.getName());
|
||||
final String query = "tag==" + targTagD.getName();
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("Expected number of results is")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("Expected number of results is")
|
||||
.hasSize(200).as("and is expected number of results is equal to ")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
.containsAll(targetManagement.findByRsql(query, PAGE).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
private void verifyThatRepositoryContains500Targets() {
|
||||
final FilterParams filterParams = new FilterParams(null, null, null, null, null);
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent())
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent())
|
||||
.as("Overall we expect that many targets in the repository").hasSize(500)
|
||||
.as("which is also reflected by repository count").hasSize((int) targetManagement.count())
|
||||
.as("which is also reflected by call without specification")
|
||||
@@ -636,7 +636,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
private void verifyThat1TargetHasTypeAndDSAssigned(final TargetType type, final DistributionSet set,
|
||||
final Target expected) {
|
||||
final FilterParams filterParams = new FilterParams(null, set.getId(), Boolean.FALSE, type.getId());
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(1).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsExactly(expected);
|
||||
@@ -646,7 +646,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
private void verifyThatTargetsHasNoTypeAndDSAssignedOrInstalled(final DistributionSet set,
|
||||
final List<Target> expected) {
|
||||
final FilterParams filterParams = new FilterParams(null, set.getId(), Boolean.TRUE, null);
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(expected.size()).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected);
|
||||
@@ -656,7 +656,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
private void verifyThat100TargetsContainsGivenTextAndHaveTypeAssigned(final TargetType targetType,
|
||||
final List<Target> expected) {
|
||||
final FilterParams filterParams = new FilterParams("%targ-E%", null, Boolean.FALSE, targetType.getId());
|
||||
final List<Target> filteredTargets = targetManagement.findByFilters(PAGE, filterParams).getContent();
|
||||
final List<Target> filteredTargets = targetManagement.findByFilters(filterParams, PAGE).getContent();
|
||||
assertThat(filteredTargets).as("has number of elements").hasSize(100)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams));
|
||||
@@ -670,7 +670,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
@Step
|
||||
private void verifyThat400TargetsContainsGivenTextAndHaveNoTypeAssigned(final List<Target> expected) {
|
||||
final FilterParams filterParams = new FilterParams("%targ-%", null, Boolean.TRUE, null);
|
||||
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements")
|
||||
assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
|
||||
.hasSize(400).as("that number is also returned by count query")
|
||||
.hasSize((int) targetManagement.countByFilters(filterParams))
|
||||
.as("and contains the following elements").containsAll(expected);
|
||||
|
||||
@@ -134,7 +134,7 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(PAGE, 1L, "controllerId==id"),
|
||||
assertPermissions(() -> targetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(1L, "controllerId==id", PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@@ -149,9 +149,9 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatablePermissionsCheck() {
|
||||
assertPermissions(
|
||||
() -> targetManagement.findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable(PAGE, List.of(1L),
|
||||
"controllerId==id",
|
||||
entityFactory.distributionSetType().create().build()), List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
|
||||
() -> targetManagement.findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable(List.of(1L), "controllerId==id",
|
||||
entityFactory.distributionSetType().create().build(), PAGE
|
||||
), List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -171,7 +171,7 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByFailedRolloutAndNotInRolloutGroupsPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByFailedRolloutAndNotInRolloutGroups(PAGE, List.of(1L), "1"),
|
||||
assertPermissions(() -> targetManagement.findByFailedRolloutAndNotInRolloutGroups("1", List.of(1L), PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
@@ -185,20 +185,20 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByInRolloutGroupWithoutActionPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByInRolloutGroupWithoutAction(PAGE, 1L), List.of(SpPermission.READ_TARGET));
|
||||
assertPermissions(() -> targetManagement.findByInRolloutGroupWithoutAction(1L, PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByAssignedDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByAssignedDistributionSet(PAGE, 1L),
|
||||
assertPermissions(() -> targetManagement.findByAssignedDistributionSet(1L, PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByAssignedDistributionSetAndRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByAssignedDistributionSetAndRsql(PAGE, 1L, "controllerId==id"),
|
||||
assertPermissions(() -> targetManagement.findByAssignedDistributionSetAndRsql(1L, "controllerId==id", PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@@ -217,28 +217,28 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByFiltersPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByFilters(PAGE, new FilterParams(null, null, null, null, null, null)),
|
||||
assertPermissions(() -> targetManagement.findByFilters(new FilterParams(null, null, null, null, null, null), PAGE),
|
||||
List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByInstalledDistributionSetPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByInstalledDistributionSet(PAGE, 1L),
|
||||
assertPermissions(() -> targetManagement.findByInstalledDistributionSet(1L, PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByInstalledDistributionSetAndRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByInstalledDistributionSetAndRsql(PAGE, 1L, "controllerId==id"),
|
||||
assertPermissions(() -> targetManagement.findByInstalledDistributionSetAndRsql(1L, "controllerId==id", PAGE),
|
||||
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByUpdateStatusPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByUpdateStatus(PAGE, TargetUpdateStatus.IN_SYNC), List.of(SpPermission.READ_TARGET));
|
||||
assertPermissions(() -> targetManagement.findByUpdateStatus(TargetUpdateStatus.IN_SYNC, PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -250,25 +250,25 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByRsql(PAGE, "controllerId==id"), List.of(SpPermission.READ_TARGET));
|
||||
assertPermissions(() -> targetManagement.findByRsql("controllerId==id", PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByTargetFilterQueryPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByTargetFilterQuery(PAGE, 1L), List.of(SpPermission.READ_TARGET));
|
||||
assertPermissions(() -> targetManagement.findByTargetFilterQuery(1L, PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByTagPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByTag(PAGE, 1L), List.of(SpPermission.READ_TARGET));
|
||||
assertPermissions(() -> targetManagement.findByTag(1L, PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByRsqlAndTagPermissionsCheck() {
|
||||
assertPermissions(() -> targetManagement.findByRsqlAndTag(PAGE, "controllerId==id", 1L), List.of(SpPermission.READ_TARGET));
|
||||
assertPermissions(() -> targetManagement.findByRsqlAndTag("controllerId==id", 1L, PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -113,8 +113,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
() -> targetManagement.assignTag(Collections.singletonList(target.getControllerId()), NOT_EXIST_IDL), "TargetTag");
|
||||
verifyThrownExceptionBy(() -> targetManagement.assignTag(Collections.singletonList(NOT_EXIST_ID), tag.getId()), "Target");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByTag(PAGE, NOT_EXIST_IDL), "TargetTag");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByRsqlAndTag(PAGE, "name==*", NOT_EXIST_IDL), "TargetTag");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByTag(NOT_EXIST_IDL, PAGE), "TargetTag");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByRsqlAndTag("name==*", NOT_EXIST_IDL, PAGE), "TargetTag");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetManagement.countByAssignedDistributionSet(NOT_EXIST_IDL), "DistributionSet");
|
||||
verifyThrownExceptionBy(() -> targetManagement.countByInstalledDistributionSet(NOT_EXIST_IDL), "DistributionSet");
|
||||
@@ -128,16 +128,16 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
verifyThrownExceptionBy(() -> targetManagement.delete(Collections.singletonList(NOT_EXIST_IDL)), "Target");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
() -> targetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(NOT_EXIST_IDL, "name==*", PAGE),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByInRolloutGroupWithoutAction(PAGE, NOT_EXIST_IDL), "RolloutGroup");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByAssignedDistributionSet(PAGE, NOT_EXIST_IDL), "DistributionSet");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByInRolloutGroupWithoutAction(NOT_EXIST_IDL, PAGE), "RolloutGroup");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByAssignedDistributionSet(NOT_EXIST_IDL, PAGE), "DistributionSet");
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetManagement.findByAssignedDistributionSetAndRsql(PAGE, NOT_EXIST_IDL, "name==*"), "DistributionSet");
|
||||
() -> targetManagement.findByAssignedDistributionSetAndRsql(NOT_EXIST_IDL, "name==*", PAGE), "DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByInstalledDistributionSet(PAGE, NOT_EXIST_IDL), "DistributionSet");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByInstalledDistributionSet(NOT_EXIST_IDL, PAGE), "DistributionSet");
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetManagement.findByInstalledDistributionSetAndRsql(PAGE, NOT_EXIST_IDL, "name==*"), "DistributionSet");
|
||||
() -> targetManagement.findByInstalledDistributionSetAndRsql(NOT_EXIST_IDL, "name==*", PAGE), "DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetManagement
|
||||
.assignTag(Collections.singletonList(target.getControllerId()), Long.parseLong(NOT_EXIST_ID)), "TargetTag");
|
||||
@@ -238,17 +238,17 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final TargetTag findTargetTag = targetTagManagement.getByName("Tag1").orElseThrow(IllegalStateException::new);
|
||||
assertThat(assignedTargets).as("Assigned targets are wrong")
|
||||
.hasSize(targetManagement.findByTag(PAGE, targetTag.getId()).getNumberOfElements());
|
||||
.hasSize(targetManagement.findByTag(targetTag.getId(), PAGE).getNumberOfElements());
|
||||
|
||||
final Target unAssignTarget = targetManagement.unassignTag(List.of("targetId123"), findTargetTag.getId()).get(0);
|
||||
assertThat(unAssignTarget.getControllerId()).as("Controller id is wrong").isEqualTo("targetId123");
|
||||
assertThat(getTargetTags(unAssignTarget.getControllerId())).as("Tag size is wrong")
|
||||
.isEmpty();
|
||||
targetTagManagement.getByName("Tag1").orElseThrow(NoSuchElementException::new);
|
||||
assertThat(targetManagement.findByTag(PAGE, targetTag.getId())).as("Assigned targets are wrong").hasSize(3);
|
||||
assertThat(targetManagement.findByRsqlAndTag(PAGE, "controllerId==targetId123", targetTag.getId()))
|
||||
assertThat(targetManagement.findByTag(targetTag.getId(), PAGE)).as("Assigned targets are wrong").hasSize(3);
|
||||
assertThat(targetManagement.findByRsqlAndTag("controllerId==targetId123", targetTag.getId(), PAGE))
|
||||
.as("Assigned targets are wrong").isEmpty();
|
||||
assertThat(targetManagement.findByRsqlAndTag(PAGE, "controllerId==targetId1234", targetTag.getId()))
|
||||
assertThat(targetManagement.findByRsqlAndTag("controllerId==targetId1234", targetTag.getId(), PAGE))
|
||||
.as("Assigned targets are wrong").hasSize(1);
|
||||
|
||||
}
|
||||
@@ -657,7 +657,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final String[] tagNames = null;
|
||||
final List<Target> targetsListWithNoTag = targetManagement
|
||||
.findByFilters(PAGE, new FilterParams(null, null, null, null, Boolean.TRUE, tagNames)).getContent();
|
||||
.findByFilters(new FilterParams(null, null, null, null, Boolean.TRUE, tagNames), PAGE).getContent();
|
||||
|
||||
assertThat(targetManagement.count()).as("Total targets").isEqualTo(50L);
|
||||
assertThat(targetsListWithNoTag).as("Targets with no tag").hasSize(25);
|
||||
@@ -694,7 +694,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
testdataFactory.createTargets(25, "target-id-B", "first description");
|
||||
|
||||
final Slice<Target> foundTargets = targetManagement.findByRsql(PAGE, rsqlFilter);
|
||||
final Slice<Target> foundTargets = targetManagement.findByRsql(rsqlFilter, PAGE);
|
||||
final long foundTargetsCount = targetManagement.countByRsql(rsqlFilter);
|
||||
|
||||
assertThat(targetManagement.count()).as("Total targets").isEqualTo(50L);
|
||||
@@ -1159,7 +1159,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final Slice<Target> matching =
|
||||
targetManagement.findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable(
|
||||
PAGE, rollout.getId(), 10, Long.MAX_VALUE, "controllerid==dyn_action_filter_*", distributionSet.getType());
|
||||
rollout.getId(), 10, Long.MAX_VALUE, "controllerid==dyn_action_filter_*", distributionSet.getType(), PAGE);
|
||||
|
||||
assertThat(matching.getNumberOfElements()).isEqualTo(expected.size());
|
||||
assertThat(matching.stream()
|
||||
@@ -1449,7 +1449,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void validateFoundTargetsByRsql(final String rsqlFilter, final String... controllerIds) {
|
||||
final Slice<Target> foundTargetsByMetadataAndControllerId = targetManagement.findByRsql(PAGE, rsqlFilter);
|
||||
final Slice<Target> foundTargetsByMetadataAndControllerId = targetManagement.findByRsql(rsqlFilter, PAGE);
|
||||
final long foundTargetsByMetadataAndControllerIdCount = targetManagement.countByRsql(rsqlFilter);
|
||||
|
||||
assertThat(foundTargetsByMetadataAndControllerId.getNumberOfElements())
|
||||
|
||||
@@ -61,7 +61,7 @@ class TargetTagManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> targetTagManagement.findByRsql(PAGE, "name==tag"), List.of(SpPermission.READ_TARGET));
|
||||
assertPermissions(() -> targetTagManagement.findByRsql("name==tag", PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -129,7 +129,7 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
.containsAll(
|
||||
targetManagement.getByControllerID(groupA.stream().map(Target::getControllerId).toList()))
|
||||
.size().isEqualTo(20);
|
||||
assertThat(targetManagement.findByTag(Pageable.unpaged(), tag.getId()).getContent().stream().map(Target::getControllerId).sorted()
|
||||
assertThat(targetManagement.findByTag(tag.getId(), Pageable.unpaged()).getContent().stream().map(Target::getControllerId).sorted()
|
||||
.toList())
|
||||
.isEqualTo(groupA.stream().map(Target::getControllerId).sorted().toList());
|
||||
|
||||
@@ -140,7 +140,7 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
.containsAll(
|
||||
targetManagement.getByControllerID(groupAB.stream().map(Target::getControllerId).toList()))
|
||||
.size().isEqualTo(40);
|
||||
assertThat(targetManagement.findByTag(Pageable.unpaged(), tag.getId()).getContent().stream().map(Target::getControllerId).sorted()
|
||||
assertThat(targetManagement.findByTag(tag.getId(), Pageable.unpaged()).getContent().stream().map(Target::getControllerId).sorted()
|
||||
.toList())
|
||||
.isEqualTo(groupAB.stream().map(Target::getControllerId).sorted().toList());
|
||||
|
||||
@@ -149,7 +149,7 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(result)
|
||||
.containsAll(targetManagement.getByControllerID(groupAB.stream().map(Target::getControllerId).toList()))
|
||||
.size().isEqualTo(40);
|
||||
assertThat(targetManagement.findByTag(Pageable.unpaged(), tag.getId()).getContent()).isEmpty();
|
||||
assertThat(targetManagement.findByTag(tag.getId(), Pageable.unpaged()).getContent()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -81,13 +81,13 @@ class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.findByRsql(PAGE, "name==tag"), List.of(SpPermission.READ_TARGET));
|
||||
assertPermissions(() -> targetTypeManagement.findByRsql("name==tag", PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByNamePermissionsCheck() {
|
||||
assertPermissions(() -> targetTypeManagement.findByName(PAGE, "name"), List.of(SpPermission.READ_TARGET));
|
||||
assertPermissions(() -> targetTypeManagement.findByName("name", PAGE), List.of(SpPermission.READ_TARGET));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -107,10 +107,10 @@ class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
|
||||
return newAction;
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
|
||||
final Slice<Action> findEntity = deploymentManagement.findActionsByTarget(rsqlParam, target.getControllerId(),
|
||||
private void assertRSQLQuery(final String rsql, final long expectedEntities) {
|
||||
final Slice<Action> findEntity = deploymentManagement.findActionsByTarget(rsql, target.getControllerId(),
|
||||
PageRequest.of(0, 100));
|
||||
final long countAllEntities = deploymentManagement.countActionsByTarget(rsqlParam, target.getControllerId());
|
||||
final long countAllEntities = deploymentManagement.countActionsByTarget(rsql, target.getControllerId());
|
||||
assertThat(findEntity).isNotNull();
|
||||
assertThat(findEntity.getContent()).hasSize((int)expectedEntities);
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
|
||||
@@ -84,8 +84,8 @@ class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest {
|
||||
assertRSQLQuery(RolloutGroupFields.DESCRIPTION.name() + "=out=(group-1,notexist)", 3);
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expectedTargets) {
|
||||
final Page<RolloutGroup> findTargetPage = rolloutGroupManagement.findByRolloutAndRsql(rollout.getId(), rsqlParam, PageRequest.of(0, 100)
|
||||
private void assertRSQLQuery(final String rsql, final long expectedTargets) {
|
||||
final Page<RolloutGroup> findTargetPage = rolloutGroupManagement.findByRolloutAndRsql(rollout.getId(), rsql, PageRequest.of(0, 100)
|
||||
);
|
||||
final long countTargetsAll = findTargetPage.getTotalElements();
|
||||
assertThat(findTargetPage).isNotNull();
|
||||
|
||||
@@ -149,10 +149,10 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expectedEntity) {
|
||||
final Page<SoftwareModule> find = softwareModuleManagement.findByRsql(rsqlParam, PageRequest.of(0, 100));
|
||||
private void assertRSQLQuery(final String rsql, final long expectedEntity) {
|
||||
final Page<SoftwareModule> find = softwareModuleManagement.findByRsql(rsql, PageRequest.of(0, 100));
|
||||
final long countAll = find.getTotalElements();
|
||||
assertThat(find).isNotNull();
|
||||
assertThat(countAll).isEqualTo(expectedEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,11 +77,10 @@ class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest {
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.MAXASSIGNMENTS.name() + "!=1", 1);
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {
|
||||
final Page<SoftwareModuleType> find = softwareModuleTypeManagement.findByRsql(rsqlParam, PageRequest.of(0, 100)
|
||||
);
|
||||
private void assertRSQLQuery(final String rsql, final long expectedEntity) {
|
||||
final Page<SoftwareModuleType> find = softwareModuleTypeManagement.findByRsql(rsql, PageRequest.of(0, 100));
|
||||
final long countAll = find.getTotalElements();
|
||||
assertThat(find).isNotNull();
|
||||
assertThat(countAll).isEqualTo(excpectedEntity);
|
||||
assertThat(countAll).isEqualTo(expectedEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,20 +117,17 @@ class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "=out=(red,notexist)", 2);
|
||||
}
|
||||
|
||||
private void assertRSQLQueryDistributionSet(final String rsqlParam, final long expectedEntities) {
|
||||
|
||||
final Page<DistributionSetTag> findEnitity = distributionSetTagManagement.findByRsql(rsqlParam, PageRequest.of(0, 100)
|
||||
);
|
||||
private void assertRSQLQueryDistributionSet(final String rsql, final long expectedEntities) {
|
||||
final Page<DistributionSetTag> findEnitity = distributionSetTagManagement.findByRsql(rsql, PageRequest.of(0, 100));
|
||||
final long countAllEntities = findEnitity.getTotalElements();
|
||||
assertThat(findEnitity).isNotNull();
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
}
|
||||
|
||||
private void assertRSQLQueryTarget(final String rsqlParam, final long expectedEntities) {
|
||||
|
||||
final Page<TargetTag> findEnitity = targetTagManagement.findByRsql(PageRequest.of(0, 100), rsqlParam);
|
||||
final long countAllEntities = findEnitity.getTotalElements();
|
||||
assertThat(findEnitity).isNotNull();
|
||||
private void assertRSQLQueryTarget(final String rsql, final long expectedEntities) {
|
||||
final Page<TargetTag> findEntity = targetTagManagement.findByRsql(rsql, PageRequest.of(0, 100));
|
||||
final long countAllEntities = findEntity.getTotalElements();
|
||||
assertThat(findEntity).isNotNull();
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -413,16 +413,16 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
.isThrownBy(() -> assertRSQLQuery("targettype.description==Description", 0));
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expectedTargets) {
|
||||
final Slice<Target> findTargetPage = targetManagement.findByRsql(PAGE, rsqlParam);
|
||||
private void assertRSQLQuery(final String rsql, final long expectedTargets) {
|
||||
final Slice<Target> findTargetPage = targetManagement.findByRsql(rsql, PAGE);
|
||||
assertThat(findTargetPage).isNotNull();
|
||||
assertThat(findTargetPage.getNumberOfElements()).isEqualTo(expectedTargets);
|
||||
assertThat(targetManagement.countByRsql(rsqlParam)).isEqualTo(expectedTargets);
|
||||
assertThat(targetManagement.countByRsql(rsql)).isEqualTo(expectedTargets);
|
||||
}
|
||||
|
||||
private void assertRSQLQueryThrowsException(final String rsqlParam) {
|
||||
private void assertRSQLQueryThrowsException(final String rsql) {
|
||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||
.isThrownBy(() -> RSQLUtility.validateRsqlFor(
|
||||
rsqlParam, TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager));
|
||||
rsql, TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager));
|
||||
}
|
||||
}
|
||||
@@ -109,10 +109,9 @@ class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest {
|
||||
+ TestdataFactory.DEFAULT_VERSION + ",notexist)", 1);
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expectedFilterQueriesSize) {
|
||||
final Page<TargetFilterQuery> findTargetFilterQueryPage = targetFilterQueryManagement.findByRsql(PAGE,
|
||||
rsqlParam);
|
||||
private void assertRSQLQuery(final String rsql, final long expectedFilterQueriesSize) {
|
||||
final Page<TargetFilterQuery> findTargetFilterQueryPage = targetFilterQueryManagement.findByRsql(rsql, PAGE);
|
||||
assertThat(findTargetFilterQueryPage).isNotNull();
|
||||
assertThat(findTargetFilterQueryPage.getTotalElements()).isEqualTo(expectedFilterQueriesSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,6 +191,6 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private Slice<DistributionSet> findDistributionSetForTenant(final String tenant) throws Exception {
|
||||
return runAsTenant(tenant, () -> distributionSetManagement.findByCompleted(PAGE, true));
|
||||
return runAsTenant(tenant, () -> distributionSetManagement.findByCompleted(true, PAGE));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user