Reapplied hawkBit code formatter.
It seems that from Luna to Mars Eclipse changed how the code formatter handles lines breaks in certain cases. This is now the “Mars” variant.
This commit is contained in:
@@ -96,8 +96,8 @@ public class ExceptionMappingAspectHandler implements Ordered {
|
||||
|
||||
if (translatedAccessException == null && ex instanceof TransactionSystemException) {
|
||||
final TransactionSystemException systemException = (TransactionSystemException) ex;
|
||||
translatedAccessException = translateEclipseLinkExceptionIfPossible((Exception) systemException
|
||||
.getOriginalException());
|
||||
translatedAccessException = translateEclipseLinkExceptionIfPossible(
|
||||
(Exception) systemException.getOriginalException());
|
||||
}
|
||||
|
||||
if (translatedAccessException == null) {
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
||||
* successful spring transaction commit.The class is thread safe.
|
||||
*/
|
||||
@Service
|
||||
public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSynchronizationAdapter implements
|
||||
AfterTransactionCommitExecutor {
|
||||
public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSynchronizationAdapter
|
||||
implements AfterTransactionCommitExecutor {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AfterTransactionCommitDefaultServiceExecutor.class);
|
||||
private static final ThreadLocal<List<Runnable>> THREAD_LOCAL_RUNNABLES = new ThreadLocal<>();
|
||||
|
||||
|
||||
@@ -198,10 +198,8 @@ public class DeploymentManagement {
|
||||
@CacheEvict(value = { "distributionUsageAssigned" }, allEntries = true)
|
||||
public DistributionSetAssignmentResult assignDistributionSet(@NotNull final Long dsID, final ActionType actionType,
|
||||
final long forcedTimestamp, @NotEmpty final String... targetIDs) {
|
||||
return assignDistributionSet(
|
||||
dsID,
|
||||
Arrays.stream(targetIDs).map(t -> new TargetWithActionType(t, actionType, forcedTimestamp))
|
||||
.collect(Collectors.toList()));
|
||||
return assignDistributionSet(dsID, Arrays.stream(targetIDs)
|
||||
.map(t -> new TargetWithActionType(t, actionType, forcedTimestamp)).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,8 +224,8 @@ public class DeploymentManagement {
|
||||
final List<TargetWithActionType> targets) {
|
||||
final DistributionSet set = distributoinSetRepository.findOne(dsID);
|
||||
if (set == null) {
|
||||
throw new EntityNotFoundException(String.format("no %s with id %d found",
|
||||
DistributionSet.class.getSimpleName(), dsID));
|
||||
throw new EntityNotFoundException(
|
||||
String.format("no %s with id %d found", DistributionSet.class.getSimpleName(), dsID));
|
||||
}
|
||||
|
||||
return assignDistributionSetToTargets(set, targets);
|
||||
@@ -251,8 +249,8 @@ public class DeploymentManagement {
|
||||
final List<TargetWithActionType> targetsWithActionType) {
|
||||
|
||||
if (!set.isComplete()) {
|
||||
throw new IncompleteDistributionSetException("Distribution set of type " + set.getType().getKey()
|
||||
+ " is incomplete: " + set.getId());
|
||||
throw new IncompleteDistributionSetException(
|
||||
"Distribution set of type " + set.getType().getKey() + " is incomplete: " + set.getId());
|
||||
}
|
||||
|
||||
final List<String> controllerIDs = targetsWithActionType.stream().map(TargetWithActionType::getTargetId)
|
||||
@@ -260,8 +258,8 @@ public class DeploymentManagement {
|
||||
|
||||
LOG.debug("assignDistribution({}) to {} targets", set, controllerIDs.size());
|
||||
|
||||
final Map<String, TargetWithActionType> targetsWithActionMap = targetsWithActionType.stream().collect(
|
||||
Collectors.toMap(TargetWithActionType::getTargetId, Function.identity()));
|
||||
final Map<String, TargetWithActionType> targetsWithActionMap = targetsWithActionType.stream()
|
||||
.collect(Collectors.toMap(TargetWithActionType::getTargetId, Function.identity()));
|
||||
|
||||
// split tIDs length into max entries in-statement because many database
|
||||
// have constraint of
|
||||
@@ -271,12 +269,10 @@ public class DeploymentManagement {
|
||||
// we take the target only into account if the requested operation is no
|
||||
// duplicate of a
|
||||
// previous one
|
||||
final List<Target> targets = Lists
|
||||
.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT)
|
||||
.stream()
|
||||
.map(ids -> targetRepository.findAll(TargetSpecifications
|
||||
.hasControllerIdAndAssignedDistributionSetIdNot(ids, set.getId()))).flatMap(t -> t.stream())
|
||||
.collect(Collectors.toList());
|
||||
final List<Target> targets = Lists.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT).stream()
|
||||
.map(ids -> targetRepository
|
||||
.findAll(TargetSpecifications.hasControllerIdAndAssignedDistributionSetIdNot(ids, set.getId())))
|
||||
.flatMap(t -> t.stream()).collect(Collectors.toList());
|
||||
|
||||
if (targets.isEmpty()) {
|
||||
// detaching as it is not necessary to persist the set itself
|
||||
@@ -339,8 +335,8 @@ public class DeploymentManagement {
|
||||
});
|
||||
|
||||
// select updated targets in order to return them
|
||||
final DistributionSetAssignmentResult result = new DistributionSetAssignmentResult(targets.stream()
|
||||
.map(target -> target.getControllerId()).collect(Collectors.toList()), targets.size(),
|
||||
final DistributionSetAssignmentResult result = new DistributionSetAssignmentResult(
|
||||
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), targets.size(),
|
||||
controllerIDs.size() - targets.size(), Lists.newArrayList(targetIdsToActions.values()),
|
||||
targetManagement);
|
||||
|
||||
@@ -353,11 +349,9 @@ public class DeploymentManagement {
|
||||
|
||||
// send distribution set assignment event
|
||||
|
||||
targets.stream()
|
||||
.filter(t -> !!!targetIdsCancellList.contains(t.getId()))
|
||||
.forEach(
|
||||
t -> assignDistributionSetEvent(t, targetIdsToActions.get(t.getControllerId()).getId(),
|
||||
softwareModules));
|
||||
targets.stream().filter(t -> !!!targetIdsCancellList.contains(t.getId()))
|
||||
.forEach(t -> assignDistributionSetEvent(t, targetIdsToActions.get(t.getControllerId()).getId(),
|
||||
softwareModules));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -403,13 +397,13 @@ public class DeploymentManagement {
|
||||
activeActions.forEach(action -> {
|
||||
action.setStatus(Status.CANCELING);
|
||||
// document that the status has been retrieved
|
||||
actionStatusRepository.save(new ActionStatus(action, Status.CANCELING, System.currentTimeMillis(),
|
||||
"manual cancelation requested"));
|
||||
actionStatusRepository.save(new ActionStatus(action, Status.CANCELING, System.currentTimeMillis(),
|
||||
"manual cancelation requested"));
|
||||
|
||||
cancelAssignDistributionSetEvent(action.getTarget(), action.getId());
|
||||
cancelAssignDistributionSetEvent(action.getTarget(), action.getId());
|
||||
|
||||
cancelledTargetIds.add(action.getTarget().getId());
|
||||
});
|
||||
cancelledTargetIds.add(action.getTarget().getId());
|
||||
});
|
||||
actionRepository.save(activeActions);
|
||||
|
||||
return cancelledTargetIds;
|
||||
@@ -417,9 +411,8 @@ public class DeploymentManagement {
|
||||
|
||||
private DistributionSetAssignmentResult assignDistributionSetByTargetId(@NotNull final DistributionSet set,
|
||||
@NotEmpty final List<String> tIDs, final ActionType actionType, final long forcedTime) {
|
||||
return assignDistributionSetToTargets(set,
|
||||
tIDs.stream().map(t -> new TargetWithActionType(t, actionType, forcedTime))
|
||||
.collect(Collectors.toList()));
|
||||
return assignDistributionSetToTargets(set, tIDs.stream()
|
||||
.map(t -> new TargetWithActionType(t, actionType, forcedTime)).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,8 +480,8 @@ public class DeploymentManagement {
|
||||
|
||||
return saveAction;
|
||||
} else {
|
||||
throw new CancelActionNotAllowedException("Action [id: " + action.getId()
|
||||
+ "] is not active and cannot be canceled");
|
||||
throw new CancelActionNotAllowedException(
|
||||
"Action [id: " + action.getId() + "] is not active and cannot be canceled");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,13 +522,13 @@ public class DeploymentManagement {
|
||||
final Action mergedAction = entityManager.merge(action);
|
||||
|
||||
if (!mergedAction.isCancelingOrCanceled()) {
|
||||
throw new ForceQuitActionNotAllowedException("Action [id: " + action.getId()
|
||||
+ "] is not canceled yet and cannot be force quit");
|
||||
throw new ForceQuitActionNotAllowedException(
|
||||
"Action [id: " + action.getId() + "] is not canceled yet and cannot be force quit");
|
||||
}
|
||||
|
||||
if (!mergedAction.isActive()) {
|
||||
throw new ForceQuitActionNotAllowedException("Action [id: " + action.getId()
|
||||
+ "] is not active and cannot be force quit");
|
||||
throw new ForceQuitActionNotAllowedException(
|
||||
"Action [id: " + action.getId() + "] is not active and cannot be force quit");
|
||||
}
|
||||
|
||||
LOG.warn("action ({}) was still activ and has been force quite.", action);
|
||||
@@ -650,7 +643,8 @@ public class DeploymentManagement {
|
||||
return actionRepository.findAll(new Specification<Action>() {
|
||||
|
||||
@Override
|
||||
public Predicate toPredicate(final Root<Action> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
|
||||
public Predicate toPredicate(final Root<Action> root, final CriteriaQuery<?> query,
|
||||
final CriteriaBuilder cb) {
|
||||
return cb.and(specifiction.toPredicate(root, query, cb), cb.equal(root.get(Action_.target), target));
|
||||
}
|
||||
}, pageable);
|
||||
@@ -752,7 +746,8 @@ public class DeploymentManagement {
|
||||
public Long countActionsByTarget(@NotNull final Specification<Action> spec, @NotNull final Target target) {
|
||||
return actionRepository.count(new Specification<Action>() {
|
||||
@Override
|
||||
public Predicate toPredicate(final Root<Action> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
|
||||
public Predicate toPredicate(final Root<Action> root, final CriteriaQuery<?> query,
|
||||
final CriteriaBuilder cb) {
|
||||
return cb.and(spec.toPredicate(root, query, cb), cb.equal(root.get(Action_.target), target));
|
||||
}
|
||||
});
|
||||
@@ -818,8 +813,8 @@ public class DeploymentManagement {
|
||||
action.setStatus(Status.CANCELED);
|
||||
|
||||
final Target target = action.getTarget();
|
||||
final List<Action> nextActiveActions = actionRepository.findByTargetAndActiveOrderByIdAsc(target, true)
|
||||
.stream().filter(a -> !a.getId().equals(action.getId())).collect(Collectors.toList());
|
||||
final List<Action> nextActiveActions = actionRepository.findByTargetAndActiveOrderByIdAsc(target, true).stream()
|
||||
.filter(a -> !a.getId().equals(action.getId())).collect(Collectors.toList());
|
||||
|
||||
if (nextActiveActions.isEmpty()) {
|
||||
target.setAssignedDistributionSet(target.getTargetInfo().getInstalledDistributionSet());
|
||||
|
||||
@@ -219,7 +219,8 @@ public class DistributionSetManagement {
|
||||
* @return the found {@link DistributionSet}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
public List<DistributionSet> findDistributionSetListWithDetails(@NotEmpty final Collection<Long> distributionIdSet) {
|
||||
public List<DistributionSet> findDistributionSetListWithDetails(
|
||||
@NotEmpty final Collection<Long> distributionIdSet) {
|
||||
return distributionSetRepository.findAll(DistributionSetSpecification.byIds(distributionIdSet));
|
||||
}
|
||||
|
||||
@@ -397,7 +398,8 @@ public class DistributionSetManagement {
|
||||
@Modifying
|
||||
@Transactional
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
public DistributionSet unassignSoftwareModule(@NotNull final DistributionSet ds, final SoftwareModule softwareModule) {
|
||||
public DistributionSet unassignSoftwareModule(@NotNull final DistributionSet ds,
|
||||
final SoftwareModule softwareModule) {
|
||||
final Set<SoftwareModule> softwareModules = new HashSet<SoftwareModule>();
|
||||
softwareModules.add(softwareModule);
|
||||
ds.removeModule(softwareModule);
|
||||
@@ -429,9 +431,9 @@ public class DistributionSetManagement {
|
||||
// throw exception if user tries to update a DS type that is already in
|
||||
// use
|
||||
if (!persisted.areModuleEntriesIdentical(dsType) && distributionSetRepository.countByType(persisted) > 0) {
|
||||
throw new EntityReadOnlyException(String.format(
|
||||
"distribution set type %s set is already assigned to targets and cannot be changed",
|
||||
dsType.getName()));
|
||||
throw new EntityReadOnlyException(
|
||||
String.format("distribution set type %s set is already assigned to targets and cannot be changed",
|
||||
dsType.getName()));
|
||||
}
|
||||
|
||||
return distributionSetTypeRepository.save(dsType);
|
||||
@@ -597,14 +599,16 @@ public class DistributionSetManagement {
|
||||
|
||||
final DistributionSetFilter filterWithInstalledTargets = distributionSetFilterBuilder
|
||||
.setInstalledTargetId(assignedOrInstalled).setAssignedTargetId(null).build();
|
||||
final DistributionSet installedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget(filterWithInstalledTargets);
|
||||
final DistributionSet installedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget(
|
||||
filterWithInstalledTargets);
|
||||
|
||||
final DistributionSetFilter filterWithAssignedTargets = distributionSetFilterBuilder.setInstalledTargetId(null)
|
||||
.setAssignedTargetId(assignedOrInstalled).build();
|
||||
final DistributionSet assignedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget(filterWithAssignedTargets);
|
||||
final DistributionSet assignedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget(
|
||||
filterWithAssignedTargets);
|
||||
|
||||
final DistributionSetFilter dsFilterWithNoTargetLinked = distributionSetFilterBuilder
|
||||
.setInstalledTargetId(null).setAssignedTargetId(null).build();
|
||||
final DistributionSetFilter dsFilterWithNoTargetLinked = distributionSetFilterBuilder.setInstalledTargetId(null)
|
||||
.setAssignedTargetId(null).build();
|
||||
// first fine the distribution sets filtered by the given filter
|
||||
// parameters
|
||||
final Page<DistributionSet> findDistributionSetsByFilters = findDistributionSetsByFilters(pageable,
|
||||
@@ -654,8 +658,8 @@ public class DistributionSetManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
public DistributionSet findDistributionSetByNameAndVersion(@NotEmpty final String distributionName,
|
||||
@NotEmpty final String version) {
|
||||
final Specification<DistributionSet> spec = DistributionSetSpecification.equalsNameAndVersionIgnoreCase(
|
||||
distributionName, version);
|
||||
final Specification<DistributionSet> spec = DistributionSetSpecification
|
||||
.equalsNameAndVersionIgnoreCase(distributionName, version);
|
||||
return distributionSetRepository.findOne(spec);
|
||||
|
||||
}
|
||||
@@ -1009,17 +1013,17 @@ public class DistributionSetManagement {
|
||||
final Set<SoftwareModule> softwareModules) {
|
||||
if (!new HashSet<SoftwareModule>(distributionSet.getModules()).equals(softwareModules)
|
||||
&& actionRepository.countByDistributionSet(distributionSet) > 0) {
|
||||
throw new EntityLockedException(String.format(
|
||||
"distribution set %s:%s is already assigned to targets and cannot be changed",
|
||||
distributionSet.getName(), distributionSet.getVersion()));
|
||||
throw new EntityLockedException(
|
||||
String.format("distribution set %s:%s is already assigned to targets and cannot be changed",
|
||||
distributionSet.getName(), distributionSet.getVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDistributionSetSoftwareModulesIsAllowedToModify(final DistributionSet distributionSet) {
|
||||
if (actionRepository.countByDistributionSet(distributionSet) > 0) {
|
||||
throw new EntityLockedException(String.format(
|
||||
"distribution set %s:%s is already assigned to targets and cannot be changed",
|
||||
distributionSet.getName(), distributionSet.getVersion()));
|
||||
throw new EntityLockedException(
|
||||
String.format("distribution set %s:%s is already assigned to targets and cannot be changed",
|
||||
distributionSet.getName(), distributionSet.getVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1068,8 +1072,8 @@ public class DistributionSetManagement {
|
||||
|
||||
private void checkAndThrowAlreadyIfDistributionSetMetadataExists(final DsMetadataCompositeKey metadataId) {
|
||||
if (distributionSetMetadataRepository.exists(metadataId)) {
|
||||
throw new EntityAlreadyExistsException("Metadata entry with key '" + metadataId.getKey()
|
||||
+ "' already exists");
|
||||
throw new EntityAlreadyExistsException(
|
||||
"Metadata entry with key '" + metadataId.getKey() + "' already exists");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1091,7 +1095,8 @@ public class DistributionSetManagement {
|
||||
@Transactional
|
||||
@NotNull
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
public List<DistributionSet> assignTag(@NotEmpty final Collection<Long> dsIds, @NotNull final DistributionSetTag tag) {
|
||||
public List<DistributionSet> assignTag(@NotEmpty final Collection<Long> dsIds,
|
||||
@NotNull final DistributionSetTag tag) {
|
||||
final List<DistributionSet> allDs = findDistributionSetListWithDetails(dsIds);
|
||||
|
||||
allDs.forEach(ds -> ds.getTags().add(tag));
|
||||
|
||||
@@ -24,8 +24,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public interface DistributionSetTagRepository extends BaseEntityRepository<DistributionSetTag, Long>,
|
||||
JpaSpecificationExecutor<DistributionSetTag> {
|
||||
public interface DistributionSetTagRepository
|
||||
extends BaseEntityRepository<DistributionSetTag, Long>, JpaSpecificationExecutor<DistributionSetTag> {
|
||||
/**
|
||||
* deletes the {@link DistributionSet} with the given name.
|
||||
*
|
||||
|
||||
@@ -267,8 +267,8 @@ public class TagManagement {
|
||||
|
||||
final DistributionSetTag save = distributionSetTagRepository.save(distributionSetTag);
|
||||
|
||||
afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware
|
||||
.getCurrentTenant(), save)));
|
||||
afterCommit.afterCommit(
|
||||
() -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware.getCurrentTenant(), save)));
|
||||
return save;
|
||||
}
|
||||
|
||||
@@ -292,8 +292,8 @@ public class TagManagement {
|
||||
}
|
||||
}
|
||||
final List<DistributionSetTag> save = distributionSetTagRepository.save(distributionSetTags);
|
||||
afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware
|
||||
.getCurrentTenant(), save)));
|
||||
afterCommit.afterCommit(
|
||||
() -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware.getCurrentTenant(), save)));
|
||||
|
||||
return save;
|
||||
}
|
||||
|
||||
@@ -19,27 +19,26 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public interface TargetFilterQueryRepository extends
|
||||
BaseEntityRepository<TargetFilterQuery, Long>,
|
||||
JpaSpecificationExecutor<TargetFilterQuery> {
|
||||
public interface TargetFilterQueryRepository
|
||||
extends BaseEntityRepository<TargetFilterQuery, Long>, JpaSpecificationExecutor<TargetFilterQuery> {
|
||||
|
||||
/**
|
||||
* Find customer target filter by name
|
||||
*
|
||||
* @param name
|
||||
* @return custom target filter
|
||||
*/
|
||||
TargetFilterQuery findByName(final String name);
|
||||
/**
|
||||
* Find customer target filter by name
|
||||
*
|
||||
* @param name
|
||||
* @return custom target filter
|
||||
*/
|
||||
TargetFilterQuery findByName(final String name);
|
||||
|
||||
/**
|
||||
* Find list of all custom target filters.
|
||||
*/
|
||||
@Override
|
||||
Page<TargetFilterQuery> findAll();
|
||||
/**
|
||||
* Find list of all custom target filters.
|
||||
*/
|
||||
@Override
|
||||
Page<TargetFilterQuery> findAll();
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional
|
||||
<S extends TargetFilterQuery> S save(S entity);
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional
|
||||
<S extends TargetFilterQuery> S save(S entity);
|
||||
|
||||
}
|
||||
|
||||
@@ -350,9 +350,9 @@ public class TargetManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
||||
public Page<Target> findTargetByAssignedDistributionSet(@NotNull final Long distributionSetID,
|
||||
final Specification<Target> spec, @NotNull final Pageable pageReq) {
|
||||
return targetRepository.findAll((Specification<Target>) (root, query, cb) -> cb.and(TargetSpecifications
|
||||
.hasAssignedDistributionSet(distributionSetID).toPredicate(root, query, cb), spec.toPredicate(root,
|
||||
query, cb)), pageReq);
|
||||
return targetRepository.findAll((Specification<Target>) (root, query, cb) -> cb.and(
|
||||
TargetSpecifications.hasAssignedDistributionSet(distributionSetID).toPredicate(root, query, cb),
|
||||
spec.toPredicate(root, query, cb)), pageReq);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -389,9 +389,9 @@ public class TargetManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
||||
public Page<Target> findTargetByInstalledDistributionSet(final Long distributionSetId,
|
||||
final Specification<Target> spec, final Pageable pageable) {
|
||||
return targetRepository.findAll((Specification<Target>) (root, query, cb) -> cb.and(TargetSpecifications
|
||||
.hasInstalledDistributionSet(distributionSetId).toPredicate(root, query, cb), spec.toPredicate(root,
|
||||
query, cb)), pageable);
|
||||
return targetRepository.findAll((Specification<Target>) (root, query, cb) -> cb.and(
|
||||
TargetSpecifications.hasInstalledDistributionSet(distributionSetId).toPredicate(root, query, cb),
|
||||
spec.toPredicate(root, query, cb)), pageable);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -486,8 +486,8 @@ public class TargetManagement {
|
||||
specList.add(TargetSpecifications.hasTargetUpdateStatus(status, fetch));
|
||||
}
|
||||
if (installedOrAssignedDistributionSetId != null) {
|
||||
specList.add(TargetSpecifications
|
||||
.hasInstalledOrAssignedDistributionSet(installedOrAssignedDistributionSetId));
|
||||
specList.add(
|
||||
TargetSpecifications.hasInstalledOrAssignedDistributionSet(installedOrAssignedDistributionSetId));
|
||||
}
|
||||
if (!Strings.isNullOrEmpty(searchText)) {
|
||||
specList.add(TargetSpecifications.likeNameOrDescriptionOrIp(searchText));
|
||||
@@ -559,8 +559,8 @@ public class TargetManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
public TargetTagAssigmentResult toggleTagAssignment(@NotEmpty final List<Target> targets,
|
||||
@NotNull final TargetTag tag) {
|
||||
return toggleTagAssignment(targets.stream().map(target -> target.getControllerId())
|
||||
.collect(Collectors.toList()), tag.getName());
|
||||
return toggleTagAssignment(
|
||||
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), tag.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -583,8 +583,8 @@ public class TargetManagement {
|
||||
@NotNull final String tagName) {
|
||||
final TargetTag tag = targetTagRepository.findByNameEquals(tagName);
|
||||
final List<Target> alreadyAssignedTargets = targetRepository.findByTagNameAndControllerIdIn(tagName, targetIds);
|
||||
final List<Target> allTargets = targetRepository.findAll(TargetSpecifications
|
||||
.byControllerIdWithStatusAndTagsInJoin(targetIds));
|
||||
final List<Target> allTargets = targetRepository
|
||||
.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(targetIds));
|
||||
|
||||
// all are already assigned -> unassign
|
||||
if (alreadyAssignedTargets.size() == allTargets.size()) {
|
||||
@@ -623,8 +623,8 @@ public class TargetManagement {
|
||||
@NotNull
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
public List<Target> assignTag(@NotEmpty final Collection<String> targetIds, @NotNull final TargetTag tag) {
|
||||
final List<Target> allTargets = targetRepository.findAll(TargetSpecifications
|
||||
.byControllerIdWithStatusAndTagsInJoin(targetIds));
|
||||
final List<Target> allTargets = targetRepository
|
||||
.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(targetIds));
|
||||
|
||||
allTargets.forEach(target -> target.getTags().add(tag));
|
||||
final List<Target> save = targetRepository.save(allTargets);
|
||||
@@ -678,8 +678,8 @@ public class TargetManagement {
|
||||
@Transactional
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
public Target unAssignTag(@NotNull final String controllerID, @NotNull final TargetTag targetTag) {
|
||||
final List<Target> allTargets = targetRepository.findAll(TargetSpecifications
|
||||
.byControllerIdWithStatusAndTagsInJoin(Arrays.asList(controllerID)));
|
||||
final List<Target> allTargets = targetRepository
|
||||
.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(Arrays.asList(controllerID)));
|
||||
final List<Target> unAssignTag = unAssignTag(allTargets, targetTag);
|
||||
return unAssignTag.isEmpty() ? null : unAssignTag.get(0);
|
||||
}
|
||||
@@ -740,19 +740,20 @@ public class TargetManagement {
|
||||
// select case expression to retrieve the case value as a column to be
|
||||
// able to order based on
|
||||
// this column, installed first,...
|
||||
final Expression<Object> selectCase = cb
|
||||
.selectCase()
|
||||
final Expression<Object> selectCase = cb.selectCase()
|
||||
.when(cb.equal(targetInfo.get(TargetInfo_.installedDistributionSet).get(DistributionSet_.id),
|
||||
orderByDistributionId), 1)
|
||||
.when(cb.equal(targetRoot.get(Target_.assignedDistributionSet).get(DistributionSet_.id),
|
||||
orderByDistributionId), 2).otherwise(100);
|
||||
orderByDistributionId), 2)
|
||||
.otherwise(100);
|
||||
// multiselect statement order by the select case and controllerId
|
||||
query.distinct(true);
|
||||
// build the specifications and then to predicates necessary by the
|
||||
// given filters
|
||||
final Predicate[] specificationsForMultiSelect = specificationsToPredicate(
|
||||
buildSpecificationList(filterByStatus, filterBySearchText, filterByDistributionId,
|
||||
selectTargetWithNoTag, true, filterByTagNames), targetRoot, query, cb);
|
||||
selectTargetWithNoTag, true, filterByTagNames),
|
||||
targetRoot, query, cb);
|
||||
|
||||
// if we have some predicates then add it to the where clause of the
|
||||
// multiselect
|
||||
@@ -826,9 +827,8 @@ public class TargetManagement {
|
||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
final CriteriaQuery<TargetIdName> query = cb.createQuery(TargetIdName.class);
|
||||
final Root<Target> targetRoot = query.from(Target.class);
|
||||
return entityManager.createQuery(
|
||||
query.multiselect(targetRoot.get(Target_.id), targetRoot.get(Target_.controllerId),
|
||||
targetRoot.get(Target_.name))).getResultList();
|
||||
return entityManager.createQuery(query.multiselect(targetRoot.get(Target_.id),
|
||||
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name))).getResultList();
|
||||
|
||||
}
|
||||
|
||||
@@ -870,7 +870,8 @@ public class TargetManagement {
|
||||
|
||||
final Predicate[] specificationsForMultiSelect = specificationsToPredicate(
|
||||
buildSpecificationList(filterByStatus, filterBySearchText, filterByDistributionId,
|
||||
selectTargetWithNoTag, false, filterByTagNames), targetRoot, multiselect, cb);
|
||||
selectTargetWithNoTag, false, filterByTagNames),
|
||||
targetRoot, multiselect, cb);
|
||||
|
||||
// if we have some predicates then add it to the where clause of the
|
||||
// multiselect
|
||||
@@ -1000,16 +1001,17 @@ public class TargetManagement {
|
||||
* to be created.
|
||||
* @return the created {@link Target}s
|
||||
*
|
||||
* @throws {@link EntityAlreadyExistsException} of one of the given targets
|
||||
* already exist.
|
||||
* @throws {@link
|
||||
* EntityAlreadyExistsException} of one of the given targets
|
||||
* already exist.
|
||||
*/
|
||||
@Modifying
|
||||
@Transactional
|
||||
@NotNull
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
public List<Target> createTargets(@NotNull final List<Target> targets) {
|
||||
if (targetRepository.countByControllerIdIn(targets.stream().map(target -> target.getControllerId())
|
||||
.collect(Collectors.toList())) > 0) {
|
||||
if (targetRepository.countByControllerIdIn(
|
||||
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList())) > 0) {
|
||||
throw new EntityAlreadyExistsException();
|
||||
}
|
||||
final List<Target> savedTargets = new ArrayList<>();
|
||||
@@ -1041,8 +1043,8 @@ public class TargetManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
public List<Target> createTargets(@NotNull final Collection<Target> targets,
|
||||
@NotNull final TargetUpdateStatus status, final long lastTargetQuery, final URI address) {
|
||||
if (targetRepository.countByControllerIdIn(targets.stream().map(target -> target.getControllerId())
|
||||
.collect(Collectors.toList())) > 0) {
|
||||
if (targetRepository.countByControllerIdIn(
|
||||
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList())) > 0) {
|
||||
throw new EntityAlreadyExistsException();
|
||||
}
|
||||
final List<Target> savedTargets = new ArrayList<>();
|
||||
|
||||
@@ -22,11 +22,12 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public interface TargetTagRepository extends BaseEntityRepository<TargetTag, Long>, JpaSpecificationExecutor<TargetTag> {
|
||||
public interface TargetTagRepository
|
||||
extends BaseEntityRepository<TargetTag, Long>, JpaSpecificationExecutor<TargetTag> {
|
||||
|
||||
/**
|
||||
* deletes the {@link TargetTag}s with the given tag names.
|
||||
*
|
||||
*
|
||||
* @param tagNames
|
||||
* to be deleted
|
||||
* @return 1 if tag was deleted
|
||||
@@ -37,7 +38,7 @@ public interface TargetTagRepository extends BaseEntityRepository<TargetTag, Lon
|
||||
|
||||
/**
|
||||
* find {@link TargetTag} by its name.
|
||||
*
|
||||
*
|
||||
* @param tagName
|
||||
* to filter on
|
||||
* @return the {@link TargetTag} if found, otherwise null
|
||||
|
||||
@@ -28,8 +28,9 @@ import javax.persistence.UniqueConstraint;
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "sp_distributionset_tag", indexes = { @Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||
"name", "tenant" }, name = "uk_ds_tag"))
|
||||
@Table(name = "sp_distributionset_tag", indexes = {
|
||||
@Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||
"name", "tenant" }, name = "uk_ds_tag") )
|
||||
public class DistributionSetTag extends Tag {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class DistributionSetType extends NamedEntity {
|
||||
private boolean deleted = false;
|
||||
|
||||
public DistributionSetType() {
|
||||
//default public constructor
|
||||
// default public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -156,8 +156,8 @@ public final class RSQLUtility {
|
||||
* @param <T>
|
||||
* the entity type referenced by the root
|
||||
*/
|
||||
private static final class JpqQueryRSQLVisitor<A extends Enum<A> & FieldNameProvider, T> implements
|
||||
RSQLVisitor<List<Predicate>, String> {
|
||||
private static final class JpqQueryRSQLVisitor<A extends Enum<A> & FieldNameProvider, T>
|
||||
implements RSQLVisitor<List<Predicate>, String> {
|
||||
public static final Character LIKE_WILDCARD = '*';
|
||||
|
||||
private final Root<T> root;
|
||||
@@ -239,9 +239,11 @@ public final class RSQLUtility {
|
||||
}
|
||||
}
|
||||
|
||||
private RSQLParameterUnsupportedFieldException createRSQLParameterUnsupportedException(final ComparisonNode node) {
|
||||
return new RSQLParameterUnsupportedFieldException("The given search parameter field {" + node.getSelector()
|
||||
+ "} does not exist, must be one of the following fields {" + getExpectedFieldList() + "}",
|
||||
private RSQLParameterUnsupportedFieldException createRSQLParameterUnsupportedException(
|
||||
final ComparisonNode node) {
|
||||
return new RSQLParameterUnsupportedFieldException(
|
||||
"The given search parameter field {" + node.getSelector()
|
||||
+ "} does not exist, must be one of the following fields {" + getExpectedFieldList() + "}",
|
||||
new Exception());
|
||||
}
|
||||
|
||||
@@ -271,10 +273,10 @@ public final class RSQLUtility {
|
||||
fieldName = getFieldEnumByName(node);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
throw new RSQLParameterUnsupportedFieldException("The given search parameter field {"
|
||||
+ node.getSelector()
|
||||
+ "} does not exist, must be one of the following fields {"
|
||||
+ node.getSelector() + "} does not exist, must be one of the following fields {"
|
||||
+ Arrays.stream(enumType.getEnumConstants()).map(v -> v.name().toLowerCase())
|
||||
.collect(Collectors.toList()) + "}", e);
|
||||
.collect(Collectors.toList())
|
||||
+ "}", e);
|
||||
|
||||
}
|
||||
final String finalProperty = getAndValidatePropertyFieldName(fieldName, node);
|
||||
@@ -302,20 +304,15 @@ public final class RSQLUtility {
|
||||
return enumFieldName;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
final List<String> expectedSubFieldList = Arrays
|
||||
.stream(enumType.getEnumConstants())
|
||||
.filter(enumField -> !enumField.getSubEntityAttributes().isEmpty())
|
||||
.flatMap(
|
||||
enumField -> {
|
||||
final List<String> subEntity = enumField
|
||||
.getSubEntityAttributes()
|
||||
.stream()
|
||||
.map(fieldName -> enumField.name().toLowerCase()
|
||||
+ FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR + fieldName)
|
||||
.collect(Collectors.toList());
|
||||
final List<String> expectedSubFieldList = Arrays.stream(enumType.getEnumConstants())
|
||||
.filter(enumField -> !enumField.getSubEntityAttributes().isEmpty()).flatMap(enumField -> {
|
||||
final List<String> subEntity = enumField.getSubEntityAttributes().stream()
|
||||
.map(fieldName -> enumField.name().toLowerCase()
|
||||
+ FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR + fieldName)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return subEntity.stream();
|
||||
}).collect(Collectors.toList());
|
||||
return subEntity.stream();
|
||||
}).collect(Collectors.toList());
|
||||
expectedFieldList.addAll(expectedSubFieldList);
|
||||
return expectedFieldList;
|
||||
}
|
||||
@@ -373,11 +370,10 @@ public final class RSQLUtility {
|
||||
javaType);
|
||||
LOGGER.debug("value cannot be transformed to an enum", e);
|
||||
|
||||
throw new RSQLParameterUnsupportedFieldException("field {"
|
||||
+ node.getSelector()
|
||||
+ "} must be one of the following values {"
|
||||
+ Arrays.stream(tmpEnumType.getEnumConstants()).map(v -> v.name().toLowerCase())
|
||||
.collect(Collectors.toList()) + "}", e);
|
||||
throw new RSQLParameterUnsupportedFieldException("field {" + node.getSelector()
|
||||
+ "} must be one of the following values {" + Arrays.stream(tmpEnumType.getEnumConstants())
|
||||
.map(v -> v.name().toLowerCase()).collect(Collectors.toList())
|
||||
+ "}", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,7 +438,8 @@ public final class RSQLUtility {
|
||||
return fieldPath.get(enumField.getValueFieldName());
|
||||
}
|
||||
|
||||
private Predicate mapToMapPredicate(final ComparisonNode node, final Path<Object> fieldPath, final A enumField) {
|
||||
private Predicate mapToMapPredicate(final ComparisonNode node, final Path<Object> fieldPath,
|
||||
final A enumField) {
|
||||
if (!enumField.isMap()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -151,9 +151,10 @@ public final class DistributionSetSpecification {
|
||||
@Override
|
||||
public Predicate toPredicate(final Root<DistributionSet> targetRoot, final CriteriaQuery<?> query,
|
||||
final CriteriaBuilder cb) {
|
||||
final Predicate predicate = cb.or(
|
||||
cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.name)), subString.toLowerCase()),
|
||||
cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.version)), subString.toLowerCase()),
|
||||
final Predicate predicate = cb
|
||||
.or(cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.name)), subString.toLowerCase()),
|
||||
cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.version)),
|
||||
subString.toLowerCase()),
|
||||
cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.description)),
|
||||
subString.toLowerCase()));
|
||||
return predicate;
|
||||
@@ -215,7 +216,8 @@ public final class DistributionSetSpecification {
|
||||
* to be filtered on
|
||||
* @return the {@link Specification}
|
||||
*/
|
||||
public static Specification<DistributionSet> equalsNameAndVersionIgnoreCase(final String name, final String version) {
|
||||
public static Specification<DistributionSet> equalsNameAndVersionIgnoreCase(final String name,
|
||||
final String version) {
|
||||
final Specification<DistributionSet> spec = new Specification<DistributionSet>() {
|
||||
@Override
|
||||
public Predicate toPredicate(final Root<DistributionSet> targetRoot, final CriteriaQuery<?> query,
|
||||
@@ -265,8 +267,8 @@ public final class DistributionSetSpecification {
|
||||
@Override
|
||||
public Predicate toPredicate(final Root<DistributionSet> dsRoot, final CriteriaQuery<?> query,
|
||||
final CriteriaBuilder cb) {
|
||||
final ListJoin<DistributionSet, TargetInfo> installedTargetJoin = dsRoot.join(
|
||||
DistributionSet_.installedAtTargets, JoinType.INNER);
|
||||
final ListJoin<DistributionSet, TargetInfo> installedTargetJoin = dsRoot
|
||||
.join(DistributionSet_.installedAtTargets, JoinType.INNER);
|
||||
final Join<TargetInfo, Target> targetJoin = installedTargetJoin.join(TargetInfo_.target);
|
||||
return cb.equal(targetJoin.get(Target_.controllerId), installedTargetId);
|
||||
}
|
||||
@@ -287,8 +289,8 @@ public final class DistributionSetSpecification {
|
||||
@Override
|
||||
public Predicate toPredicate(final Root<DistributionSet> dsRoot, final CriteriaQuery<?> query,
|
||||
final CriteriaBuilder cb) {
|
||||
final ListJoin<DistributionSet, Target> assignedTargetJoin = dsRoot.join(
|
||||
DistributionSet_.assignedToTargets, JoinType.INNER);
|
||||
final ListJoin<DistributionSet, Target> assignedTargetJoin = dsRoot
|
||||
.join(DistributionSet_.assignedToTargets, JoinType.INNER);
|
||||
return cb.equal(assignedTargetJoin.get(Target_.controllerId), assignedTargetId);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -77,7 +77,8 @@ public final class TargetSpecifications {
|
||||
*
|
||||
* @return the {@link Target} {@link Specification}
|
||||
*/
|
||||
public static Specification<Target> byControllerIdWithStatusAndAssignedInJoin(final Collection<String> controllerIDs) {
|
||||
public static Specification<Target> byControllerIdWithStatusAndAssignedInJoin(
|
||||
final Collection<String> controllerIDs) {
|
||||
final Specification<Target> spec = new Specification<Target>() {
|
||||
@Override
|
||||
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
||||
@@ -162,10 +163,11 @@ public final class TargetSpecifications {
|
||||
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
||||
final CriteriaBuilder cb) {
|
||||
final Join<Target, TargetInfo> targetInfoJoin = targetRoot.join(Target_.targetInfo);
|
||||
final Predicate predicate = cb.or(cb.equal(targetInfoJoin.get(TargetInfo_.installedDistributionSet)
|
||||
.get(DistributionSet_.id), distributionId), cb.equal(
|
||||
targetRoot.<DistributionSet> get(Target_.assignedDistributionSet).get(DistributionSet_.id),
|
||||
distributionId));
|
||||
final Predicate predicate = cb.or(
|
||||
cb.equal(targetInfoJoin.get(TargetInfo_.installedDistributionSet).get(DistributionSet_.id),
|
||||
distributionId),
|
||||
cb.equal(targetRoot.<DistributionSet> get(Target_.assignedDistributionSet)
|
||||
.get(DistributionSet_.id), distributionId));
|
||||
return predicate;
|
||||
}
|
||||
};
|
||||
@@ -189,12 +191,10 @@ public final class TargetSpecifications {
|
||||
@Override
|
||||
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
||||
final CriteriaBuilder cb) {
|
||||
final Predicate predicate = cb.and(
|
||||
targetRoot.get(Target_.controllerId).in(tIDs),
|
||||
cb.or(cb.notEqual(
|
||||
targetRoot.<DistributionSet> get(Target_.assignedDistributionSet).get(
|
||||
DistributionSet_.id), distributionId),
|
||||
cb.isNull(targetRoot.<DistributionSet> get(Target_.assignedDistributionSet))));
|
||||
final Predicate predicate = cb.and(targetRoot.get(Target_.controllerId).in(tIDs),
|
||||
cb.or(cb.notEqual(targetRoot.<DistributionSet> get(Target_.assignedDistributionSet)
|
||||
.get(DistributionSet_.id), distributionId),
|
||||
cb.isNull(targetRoot.<DistributionSet> get(Target_.assignedDistributionSet))));
|
||||
return predicate;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -44,16 +44,16 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Issue;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Issue;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
/**
|
||||
* Test class testing the functionality of triggering a deployment of
|
||||
* {@link DistributionSet}s to {@link Target}s.
|
||||
@@ -129,21 +129,19 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
final DistributionSet cancelDs = TestDataUtil.generateDistributionSet("Canceled DS", "1.0", softwareManagement,
|
||||
distributionSetManagement, new ArrayList<DistributionSetTag>());
|
||||
|
||||
final DistributionSet cancelDs2 = TestDataUtil.generateDistributionSet("Canceled DS", "1.2",
|
||||
softwareManagement, distributionSetManagement, new ArrayList<DistributionSetTag>());
|
||||
final DistributionSet cancelDs2 = TestDataUtil.generateDistributionSet("Canceled DS", "1.2", softwareManagement,
|
||||
distributionSetManagement, new ArrayList<DistributionSetTag>());
|
||||
|
||||
List<Target> targets = targetManagement.createTargets(TestDataUtil
|
||||
.generateTargets(Constants.MAX_ENTRIES_IN_STATEMENT + 10));
|
||||
List<Target> targets = targetManagement
|
||||
.createTargets(TestDataUtil.generateTargets(Constants.MAX_ENTRIES_IN_STATEMENT + 10));
|
||||
|
||||
targets = deploymentManagement.assignDistributionSet(cancelDs, targets).getAssignedTargets();
|
||||
targets = deploymentManagement.assignDistributionSet(cancelDs2, targets).getAssignedTargets();
|
||||
|
||||
targetManagement.findAllTargetIds().forEach(
|
||||
targetIdName -> {
|
||||
assertThat(
|
||||
deploymentManagement.findActiveActionsByTarget(targetManagement
|
||||
.findTargetByControllerID(targetIdName.getControllerId()))).hasSize(2);
|
||||
});
|
||||
targetManagement.findAllTargetIds().forEach(targetIdName -> {
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(
|
||||
targetManagement.findTargetByControllerID(targetIdName.getControllerId()))).hasSize(2);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -164,8 +162,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
target = targetManagement.createTarget(target);
|
||||
|
||||
// check initial status
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
||||
TargetUpdateStatus.UNKNOWN);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||
|
||||
// assign the two sets in a row
|
||||
Action firstAction = assignSet(target, dsFirst);
|
||||
@@ -184,8 +182,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
new ActionStatus(secondAction, Status.CANCELED, System.currentTimeMillis()), secondAction);
|
||||
assertThat(actionStatusRepository.findAll()).hasSize(4);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsFirst);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
||||
TargetUpdateStatus.PENDING);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
// we cancel first -> back to installed
|
||||
deploymentManagement.cancelAction(firstAction,
|
||||
@@ -196,10 +194,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
controllerManagement.addCancelActionStatus(
|
||||
new ActionStatus(firstAction, Status.CANCELED, System.currentTimeMillis()), firstAction);
|
||||
assertThat(actionStatusRepository.findAll()).hasSize(6);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(
|
||||
dsInstalled);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
||||
TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet())
|
||||
.isEqualTo(dsInstalled);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -220,8 +218,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
target = targetManagement.createTarget(target);
|
||||
|
||||
// check initial status
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
||||
TargetUpdateStatus.UNKNOWN);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||
|
||||
// assign the two sets in a row
|
||||
Action firstAction = assignSet(target, dsFirst);
|
||||
@@ -240,8 +238,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
new ActionStatus(firstAction, Status.CANCELED, System.currentTimeMillis()), firstAction);
|
||||
assertThat(actionStatusRepository.findAll()).hasSize(4);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsSecond);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
||||
TargetUpdateStatus.PENDING);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
// we cancel second -> remain assigned until finished cancellation
|
||||
deploymentManagement.cancelAction(secondAction,
|
||||
@@ -254,10 +252,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
controllerManagement.addCancelActionStatus(
|
||||
new ActionStatus(secondAction, Status.CANCELED, System.currentTimeMillis()), secondAction);
|
||||
// cancelled success -> back to dsInstalled
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(
|
||||
dsInstalled);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
||||
TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet())
|
||||
.isEqualTo(dsInstalled);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -270,12 +268,13 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
target.getTargetInfo().setInstalledDistributionSet(dsInstalled);
|
||||
target = targetManagement.createTarget(target);
|
||||
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("newDS", softwareManagement,
|
||||
distributionSetManagement, true).setRequiredMigrationStep(true);
|
||||
final DistributionSet ds = TestDataUtil
|
||||
.generateDistributionSet("newDS", softwareManagement, distributionSetManagement, true)
|
||||
.setRequiredMigrationStep(true);
|
||||
|
||||
// verify initial status
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
||||
TargetUpdateStatus.UNKNOWN);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||
|
||||
Action assigningAction = assignSet(target, ds);
|
||||
|
||||
@@ -295,10 +294,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
// verify
|
||||
assertThat(assigningAction.getStatus()).isEqualTo(Status.CANCELED);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(
|
||||
dsInstalled);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
||||
TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet())
|
||||
.isEqualTo(dsInstalled);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -311,12 +310,13 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
target.getTargetInfo().setInstalledDistributionSet(dsInstalled);
|
||||
target = targetManagement.createTarget(target);
|
||||
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("newDS", softwareManagement,
|
||||
distributionSetManagement, true).setRequiredMigrationStep(true);
|
||||
final DistributionSet ds = TestDataUtil
|
||||
.generateDistributionSet("newDS", softwareManagement, distributionSetManagement, true)
|
||||
.setRequiredMigrationStep(true);
|
||||
|
||||
// verify initial status
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
||||
TargetUpdateStatus.UNKNOWN);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||
|
||||
final Action assigningAction = assignSet(target, ds);
|
||||
|
||||
@@ -337,7 +337,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
deploymentManagement.assignDistributionSet(ds.getId(), new String[] { target.getControllerId() });
|
||||
assertThat(
|
||||
targetManagement.findTargetByControllerID(target.getControllerId()).getTargetInfo().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getAssignedDistributionSet())
|
||||
.isEqualTo(ds);
|
||||
final Action action = actionRepository.findByTargetAndDistributionSet(pageReq, target, ds).getContent().get(0);
|
||||
@@ -360,12 +360,12 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
eventBus.register(eventHandlerMock);
|
||||
|
||||
final String myCtrlIDPref = "myCtrlID";
|
||||
final Iterable<Target> savedNakedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10,
|
||||
myCtrlIDPref, "first description"));
|
||||
final Iterable<Target> savedNakedTargets = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(10, myCtrlIDPref, "first description"));
|
||||
|
||||
final String myDeployedCtrlIDPref = "myDeployedCtrlID";
|
||||
final List<Target> savedDeployedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(20,
|
||||
myDeployedCtrlIDPref, "first description"));
|
||||
final List<Target> savedDeployedTargets = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(20, myDeployedCtrlIDPref, "first description"));
|
||||
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement);
|
||||
@@ -409,15 +409,15 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
final List<Target> targets = targetManagement.createTargets(TestDataUtil.generateTargets(10));
|
||||
|
||||
final SoftwareModule ah = softwareManagement.createSoftwareModule(new SoftwareModule(appType, "agent-hub",
|
||||
"1.0.1", null, ""));
|
||||
final SoftwareModule jvm = softwareManagement.createSoftwareModule(new SoftwareModule(runtimeType,
|
||||
"oracle-jre", "1.7.2", null, ""));
|
||||
final SoftwareModule os = softwareManagement.createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2",
|
||||
null, ""));
|
||||
final SoftwareModule ah = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||
final SoftwareModule jvm = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, ""));
|
||||
final SoftwareModule os = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2", null, ""));
|
||||
|
||||
final DistributionSet incomplete = distributionSetManagement.createDistributionSet(new DistributionSet(
|
||||
"incomplete", "v1", "", standardDsType, Lists.newArrayList(ah, jvm)));
|
||||
final DistributionSet incomplete = distributionSetManagement.createDistributionSet(
|
||||
new DistributionSet("incomplete", "v1", "", standardDsType, Lists.newArrayList(ah, jvm)));
|
||||
|
||||
try {
|
||||
deploymentManagement.assignDistributionSet(incomplete, targets);
|
||||
@@ -487,18 +487,18 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
final Iterable<Target> undeployedTargetsFromDB = targetRepository.findAll(undeployedTargetIDs);
|
||||
|
||||
// test that number of Targets
|
||||
assertThat(allFoundTargets.spliterator().getExactSizeIfKnown()).isEqualTo(
|
||||
deployedTargetsFromDB.spliterator().getExactSizeIfKnown()
|
||||
assertThat(allFoundTargets.spliterator().getExactSizeIfKnown())
|
||||
.isEqualTo(deployedTargetsFromDB.spliterator().getExactSizeIfKnown()
|
||||
+ undeployedTargetsFromDB.spliterator().getExactSizeIfKnown());
|
||||
assertThat(deployedTargetsFromDB.spliterator().getExactSizeIfKnown()).isEqualTo(noOfDeployedTargets);
|
||||
assertThat(undeployedTargetsFromDB.spliterator().getExactSizeIfKnown()).isEqualTo(noOfUndeployedTargets);
|
||||
|
||||
// test the content of different lists
|
||||
assertThat(allFoundTargets).containsAll(deployedTargetsFromDB).containsAll(undeployedTargetsFromDB);
|
||||
assertThat(deployedTargetsFromDB).containsAll(savedDeployedTargets).doesNotContain(
|
||||
Iterables.toArray(undeployedTargetsFromDB, Target.class));
|
||||
assertThat(undeployedTargetsFromDB).containsAll(savedNakedTargets).doesNotContain(
|
||||
Iterables.toArray(deployedTargetsFromDB, Target.class));
|
||||
assertThat(deployedTargetsFromDB).containsAll(savedDeployedTargets)
|
||||
.doesNotContain(Iterables.toArray(undeployedTargetsFromDB, Target.class));
|
||||
assertThat(undeployedTargetsFromDB).containsAll(savedNakedTargets)
|
||||
.doesNotContain(Iterables.toArray(deployedTargetsFromDB, Target.class));
|
||||
|
||||
// For each of the 4 targets 1 distribution sets gets assigned
|
||||
eventHandlerMock.getEvents(10, TimeUnit.SECONDS);
|
||||
@@ -532,21 +532,18 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
// verifying the correctness of the assignments
|
||||
for (final Target t : deployResWithDsA.getDeployedTargets()) {
|
||||
assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsA.getId());
|
||||
assertThat(
|
||||
targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
||||
.getInstalledDistributionSet()).isNull();
|
||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
||||
.getInstalledDistributionSet()).isNull();
|
||||
}
|
||||
for (final Target t : deployResWithDsB.getDeployedTargets()) {
|
||||
assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsB.getId());
|
||||
assertThat(
|
||||
targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
||||
.getInstalledDistributionSet()).isNull();
|
||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
||||
.getInstalledDistributionSet()).isNull();
|
||||
}
|
||||
for (final Target t : deployResWithDsC.getDeployedTargets()) {
|
||||
assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsC.getId());
|
||||
assertThat(
|
||||
targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
||||
.getInstalledDistributionSet()).isNull();
|
||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
||||
.getInstalledDistributionSet()).isNull();
|
||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
}
|
||||
@@ -559,9 +556,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
for (final Target t_ : updatedTsDsA) {
|
||||
final Target t = targetManagement.findTargetByControllerID(t_.getControllerId());
|
||||
assertThat(t.getAssignedDistributionSet()).isEqualTo(dsA);
|
||||
assertThat(
|
||||
targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
||||
.getInstalledDistributionSet()).isEqualTo(dsA);
|
||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
||||
.getInstalledDistributionSet()).isEqualTo(dsA);
|
||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(t)).hasSize(0);
|
||||
@@ -571,8 +567,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
// remove updActB from
|
||||
// activeActions, add a corresponding cancelAction and another
|
||||
// UpdateAction for dsA
|
||||
final Iterable<Target> deployed2DS = deploymentManagement.assignDistributionSet(dsA,
|
||||
deployResWithDsB.getDeployedTargets()).getAssignedTargets();
|
||||
final Iterable<Target> deployed2DS = deploymentManagement
|
||||
.assignDistributionSet(dsA, deployResWithDsB.getDeployedTargets()).getAssignedTargets();
|
||||
final Action updActA2 = actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(1);
|
||||
|
||||
assertThat(deployed2DS).containsAll(deployResWithDsB.getDeployedTargets());
|
||||
@@ -581,9 +577,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
for (final Target t_ : deployed2DS) {
|
||||
final Target t = targetManagement.findTargetByControllerID(t_.getControllerId());
|
||||
assertThat(t.getAssignedDistributionSet()).isEqualTo(dsA);
|
||||
assertThat(
|
||||
targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
||||
.getInstalledDistributionSet()).isNull();
|
||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
||||
.getInstalledDistributionSet()).isNull();
|
||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
@@ -640,8 +635,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
"blabla alles gut");
|
||||
}
|
||||
// try to delete again
|
||||
distributionSetManagement.deleteDistributionSet(deploymentResult.getDistributionSetIDs().toArray(
|
||||
new Long[deploymentResult.getDistributionSetIDs().size()]));
|
||||
distributionSetManagement.deleteDistributionSet(deploymentResult.getDistributionSetIDs()
|
||||
.toArray(new Long[deploymentResult.getDistributionSetIDs().size()]));
|
||||
// verify that the result is the same, even though distributionSet dsA
|
||||
// has been installed
|
||||
// successfully and no activeAction is referring to created distribution
|
||||
@@ -676,8 +671,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
assertThat(targetManagement.countTargetsAll()).isNotZero();
|
||||
assertThat(actionStatusRepository.count()).isNotZero();
|
||||
|
||||
targetManagement.deleteTargets(deploymentResult.getUndeployedTargetIDs().toArray(
|
||||
new Long[noOfUndeployedTargets]));
|
||||
targetManagement
|
||||
.deleteTargets(deploymentResult.getUndeployedTargetIDs().toArray(new Long[noOfUndeployedTargets]));
|
||||
targetManagement.deleteTargets(deploymentResult.getDeployedTargetIDs().toArray(new Long[noOfDeployedTargets]));
|
||||
|
||||
assertThat(targetManagement.countTargetsAll()).isZero();
|
||||
@@ -768,8 +763,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
targ = targs.iterator().next();
|
||||
|
||||
assertEquals(1, deploymentManagement.findActiveActionsByTarget(targ).size());
|
||||
assertEquals(TargetUpdateStatus.PENDING, targetManagement.findTargetByControllerID(targ.getControllerId())
|
||||
.getTargetInfo().getUpdateStatus());
|
||||
assertEquals(TargetUpdateStatus.PENDING,
|
||||
targetManagement.findTargetByControllerID(targ.getControllerId()).getTargetInfo().getUpdateStatus());
|
||||
assertEquals(dsB, targ.getAssignedDistributionSet());
|
||||
assertEquals(dsA.getId(), targetManagement.findTargetByControllerIDWithDetails(targ.getControllerId())
|
||||
.getTargetInfo().getInstalledDistributionSet().getId());
|
||||
@@ -808,8 +803,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("a", softwareManagement,
|
||||
distributionSetManagement);
|
||||
// assign ds to create an action
|
||||
final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement.assignDistributionSet(
|
||||
ds.getId(), ActionType.SOFT, Action.NO_FORCE_TIME, target.getControllerId());
|
||||
final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement
|
||||
.assignDistributionSet(ds.getId(), ActionType.SOFT, Action.NO_FORCE_TIME, target.getControllerId());
|
||||
final Action action = assignDistributionSet.getActions().get(0);
|
||||
// verify preparation
|
||||
Action findAction = deploymentManagement.findAction(action.getId());
|
||||
@@ -831,8 +826,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("a", softwareManagement,
|
||||
distributionSetManagement);
|
||||
// assign ds to create an action
|
||||
final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement.assignDistributionSet(
|
||||
ds.getId(), ActionType.FORCED, Action.NO_FORCE_TIME, target.getControllerId());
|
||||
final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement
|
||||
.assignDistributionSet(ds.getId(), ActionType.FORCED, Action.NO_FORCE_TIME, target.getControllerId());
|
||||
final Action action = assignDistributionSet.getActions().get(0);
|
||||
// verify perparation
|
||||
Action findAction = deploymentManagement.findAction(action.getId());
|
||||
@@ -874,11 +869,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
private DeploymentResult prepareComplexRepo(final String undeployedTargetPrefix, final int noOfUndeployedTargets,
|
||||
final String deployedTargetPrefix, final int noOfDeployedTargets, final int noOfDistributionSets,
|
||||
final String distributionSetPrefix) {
|
||||
final Iterable<Target> nakedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(
|
||||
noOfUndeployedTargets, undeployedTargetPrefix, "first description"));
|
||||
final Iterable<Target> nakedTargets = targetManagement.createTargets(
|
||||
TestDataUtil.buildTargetFixtures(noOfUndeployedTargets, undeployedTargetPrefix, "first description"));
|
||||
|
||||
List<Target> deployedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(
|
||||
noOfDeployedTargets, deployedTargetPrefix, "first description"));
|
||||
List<Target> deployedTargets = targetManagement.createTargets(
|
||||
TestDataUtil.buildTargetFixtures(noOfDeployedTargets, deployedTargetPrefix, "first description"));
|
||||
|
||||
// creating 10 DistributionSets
|
||||
final List<DistributionSet> dsList = TestDataUtil.generateDistributionSets(distributionSetPrefix,
|
||||
@@ -907,10 +902,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
found = true;
|
||||
final List<Action> activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(myt);
|
||||
assertThat(activeActionsByTarget).isNotEmpty();
|
||||
assertThat(event.getActionId()).isEqualTo(activeActionsByTarget.get(0).getId()).as(
|
||||
"Action id in database and event do not match");
|
||||
assertThat(event.getSoftwareModules()).containsOnly(
|
||||
ds.getModules().toArray(new SoftwareModule[ds.getModules().size()]));
|
||||
assertThat(event.getActionId()).isEqualTo(activeActionsByTarget.get(0).getId())
|
||||
.as("Action id in database and event do not match");
|
||||
assertThat(event.getSoftwareModules())
|
||||
.containsOnly(ds.getModules().toArray(new SoftwareModule[ds.getModules().size()]));
|
||||
}
|
||||
}
|
||||
assertThat(found).isTrue().as("No event found for controller " + myt.getControllerId());
|
||||
@@ -1078,8 +1073,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
latch.await(timeout, unit);
|
||||
final List<TargetAssignDistributionSetEvent> handledEvents = new LinkedList<TargetAssignDistributionSetEvent>(
|
||||
events);
|
||||
assertThat(handledEvents).hasSize(expectedNumberOfEvents).as(
|
||||
"Did not receive the expected amount of events (" + expectedNumberOfEvents
|
||||
assertThat(handledEvents).hasSize(expectedNumberOfEvents)
|
||||
.as("Did not receive the expected amount of events (" + expectedNumberOfEvents
|
||||
+ ") within timeout. Received events are " + handledEvents);
|
||||
return handledEvents;
|
||||
}
|
||||
@@ -1106,8 +1101,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
throws InterruptedException {
|
||||
latch.await(timeout, unit);
|
||||
final List<CancelTargetAssignmentEvent> handledEvents = new LinkedList<CancelTargetAssignmentEvent>(events);
|
||||
assertThat(handledEvents).hasSize(expectedNumberOfEvents).as(
|
||||
"Did not receive the expected amount of events (" + expectedNumberOfEvents
|
||||
assertThat(handledEvents).hasSize(expectedNumberOfEvents)
|
||||
.as("Did not receive the expected amount of events (" + expectedNumberOfEvents
|
||||
+ ") within timeout. Received events are " + handledEvents);
|
||||
return handledEvents;
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ public class SystemManagementTest extends AbstractIntegrationTestWithMongoDB {
|
||||
new TenantUsage("tenant1").setTargets(100).setActions(200));
|
||||
}
|
||||
|
||||
private byte[] createTestTenantsForSystemStatistics(final int tenants, final int artifactSize, final int targets, final int updates)
|
||||
throws Exception {
|
||||
private byte[] createTestTenantsForSystemStatistics(final int tenants, final int artifactSize, final int targets,
|
||||
final int updates) throws Exception {
|
||||
final Random randomgen = new Random();
|
||||
final byte random[] = new byte[artifactSize];
|
||||
randomgen.nextBytes(random);
|
||||
|
||||
@@ -25,12 +25,12 @@ import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Test class for {@link TagManagement}.
|
||||
*
|
||||
@@ -90,32 +90,34 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
||||
DistributionSetFilterBuilder distributionSetFilterBuilder;
|
||||
|
||||
// search for not deleted
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames(
|
||||
Lists.newArrayList(tagA.getName()));
|
||||
assertEquals(dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
.setTagNames(Lists.newArrayList(tagA.getName()));
|
||||
assertEquals(
|
||||
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames(
|
||||
Lists.newArrayList(tagB.getName()));
|
||||
assertEquals(dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
.setTagNames(Lists.newArrayList(tagB.getName()));
|
||||
assertEquals(
|
||||
dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames(
|
||||
Lists.newArrayList(tagC.getName()));
|
||||
assertEquals(dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
.setTagNames(Lists.newArrayList(tagC.getName()));
|
||||
assertEquals(
|
||||
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames(
|
||||
Lists.newArrayList(tagX.getName()));
|
||||
assertEquals(0,
|
||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
.setTagNames(Lists.newArrayList(tagX.getName()));
|
||||
assertEquals(0, distributionSetManagement
|
||||
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements());
|
||||
|
||||
assertEquals(5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
|
||||
@@ -127,23 +129,24 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
||||
tagManagement.deleteDistributionSetTag(tagB.getName());
|
||||
assertEquals(2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setTagNames(
|
||||
Lists.newArrayList(tagA.getName()));
|
||||
assertEquals(dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setTagNames(Lists.newArrayList(tagA.getName()));
|
||||
assertEquals(
|
||||
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setTagNames(
|
||||
Lists.newArrayList(tagB.getName()));
|
||||
assertEquals(0,
|
||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setTagNames(Lists.newArrayList(tagB.getName()));
|
||||
assertEquals(0, distributionSetManagement
|
||||
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setTagNames(
|
||||
Lists.newArrayList(tagC.getName()));
|
||||
assertEquals(dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setTagNames(Lists.newArrayList(tagC.getName()));
|
||||
assertEquals(
|
||||
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
}
|
||||
@@ -206,8 +209,8 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
// check
|
||||
for (final Target target : targetRepository.findAll()) {
|
||||
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getTags()).doesNotContain(
|
||||
toDelete);
|
||||
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getTags())
|
||||
.doesNotContain(toDelete);
|
||||
}
|
||||
assertThat(targetTagRepository.findOne(toDelete.getId())).isNull();
|
||||
assertThat(tagManagement.findAllTargetTags()).hasSize(19);
|
||||
@@ -278,8 +281,8 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
||||
final DistributionSetTag toDelete = tags.iterator().next();
|
||||
|
||||
for (final DistributionSet set : distributionSetRepository.findAll()) {
|
||||
assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags()).contains(
|
||||
toDelete);
|
||||
assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags())
|
||||
.contains(toDelete);
|
||||
}
|
||||
|
||||
// delete
|
||||
@@ -359,8 +362,8 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
final List<DistributionSet> sets = TestDataUtil.generateDistributionSets(20, softwareManagement,
|
||||
distributionSetManagement);
|
||||
final Iterable<DistributionSetTag> tags = tagManagement.createDistributionSetTags(TestDataUtil
|
||||
.generateDistributionSetTags(20));
|
||||
final Iterable<DistributionSetTag> tags = tagManagement
|
||||
.createDistributionSetTags(TestDataUtil.generateDistributionSetTags(20));
|
||||
|
||||
tags.forEach(tag -> distributionSetManagement.toggleTagAssignment(sets, tag));
|
||||
|
||||
|
||||
@@ -73,8 +73,8 @@ public class TargetFilterQueryManagenmentTest extends AbstractIntegrationTest {
|
||||
final String newQuery = "status==UNKNOWN";
|
||||
targetFilterQuery.setQuery(newQuery);
|
||||
targetFilterQueryManagement.updateTargetFilterQuery(targetFilterQuery);
|
||||
assertEquals("Returns updated target filter query", newQuery, targetFilterQueryManagement
|
||||
.findTargetFilterQueryByName(filterName).getQuery());
|
||||
assertEquals("Returns updated target filter query", newQuery,
|
||||
targetFilterQueryManagement.findTargetFilterQueryByName(filterName).getQuery());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -44,12 +44,12 @@ import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
@Features("Component Tests - Repository")
|
||||
@Stories("Target Management")
|
||||
public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
@@ -158,8 +158,8 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
final Action action = result.getActions().get(0);
|
||||
action.setStatus(Status.FINISHED);
|
||||
controllerManagament.addUpdateActionStatus(new ActionStatus(action, Status.FINISHED,
|
||||
System.currentTimeMillis(), "message"), action);
|
||||
controllerManagament.addUpdateActionStatus(
|
||||
new ActionStatus(action, Status.FINISHED, System.currentTimeMillis(), "message"), action);
|
||||
deploymentManagement.assignDistributionSet(set2.getId(), "4711");
|
||||
|
||||
target = targetManagement.findTargetByControllerIDWithDetails("4711");
|
||||
@@ -341,8 +341,8 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
targetManagement.deleteTargets(deletedTargetIDs);
|
||||
|
||||
allFound = targetManagement.findTargetsAll(new PageRequest(0, 200)).getContent();
|
||||
assertEquals(firstSaved.spliterator().getExactSizeIfKnown() - nr2Del, allFound.spliterator()
|
||||
.getExactSizeIfKnown());
|
||||
assertEquals(firstSaved.spliterator().getExactSizeIfKnown() - nr2Del,
|
||||
allFound.spliterator().getExactSizeIfKnown());
|
||||
|
||||
// verify that all undeleted are still found
|
||||
assertThat(allFound).doesNotContain(deletedTargets);
|
||||
@@ -351,8 +351,8 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
@Test
|
||||
@Description("Stores target attributes and verfies existence in the repository.")
|
||||
public void savingTargetControllerAttributes() {
|
||||
Iterable<Target> ts = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(100, "myCtrlID",
|
||||
"first description"));
|
||||
Iterable<Target> ts = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(100, "myCtrlID", "first description"));
|
||||
|
||||
final Map<String, String> attribs = new HashMap<String, String>();
|
||||
attribs.put("a.b.c", "abc");
|
||||
@@ -438,8 +438,8 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
final Target tNoAttrib = targetManagement.findTargetByControllerID(tNoAttribl.getControllerId());
|
||||
|
||||
if (tNoAttrib.getControllerId().equals(target.getControllerId())) {
|
||||
assertThat(target.getTargetInfo().getControllerAttributes().keySet().toArray()).doesNotContain(
|
||||
attribs2Del.toArray());
|
||||
assertThat(target.getTargetInfo().getControllerAttributes().keySet().toArray())
|
||||
.doesNotContain(attribs2Del.toArray());
|
||||
continue restTarget_;
|
||||
}
|
||||
}
|
||||
@@ -452,14 +452,14 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
Target t1 = TestDataUtil.buildTargetFixture("id-1", "blablub");
|
||||
final int noT2Tags = 4;
|
||||
final int noT1Tags = 3;
|
||||
final List<TargetTag> t1Tags = tagManagement.createTargetTags(TestDataUtil.buildTargetTagFixtures(noT1Tags,
|
||||
"tag1"));
|
||||
final List<TargetTag> t1Tags = tagManagement
|
||||
.createTargetTags(TestDataUtil.buildTargetTagFixtures(noT1Tags, "tag1"));
|
||||
t1.getTags().addAll(t1Tags);
|
||||
t1 = targetManagement.createTarget(t1);
|
||||
|
||||
Target t2 = TestDataUtil.buildTargetFixture("id-2", "blablub");
|
||||
final List<TargetTag> t2Tags = tagManagement.createTargetTags(TestDataUtil.buildTargetTagFixtures(noT2Tags,
|
||||
"tag2"));
|
||||
final List<TargetTag> t2Tags = tagManagement
|
||||
.createTargetTags(TestDataUtil.buildTargetTagFixtures(noT2Tags, "tag2"));
|
||||
t2.getTags().addAll(t2Tags);
|
||||
t2 = targetManagement.createTarget(t2);
|
||||
|
||||
@@ -475,18 +475,18 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests the assigment of tags to multiple targets.")
|
||||
public void targetTagBulkAssignments() {
|
||||
final List<Target> tagATargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10,
|
||||
"tagATargets", "first description"));
|
||||
final List<Target> tagBTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10,
|
||||
"tagBTargets", "first description"));
|
||||
final List<Target> tagCTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10,
|
||||
"tagCTargets", "first description"));
|
||||
final List<Target> tagATargets = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(10, "tagATargets", "first description"));
|
||||
final List<Target> tagBTargets = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(10, "tagBTargets", "first description"));
|
||||
final List<Target> tagCTargets = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(10, "tagCTargets", "first description"));
|
||||
|
||||
final List<Target> tagABTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10,
|
||||
"tagABTargets", "first description"));
|
||||
final List<Target> tagABTargets = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(10, "tagABTargets", "first description"));
|
||||
|
||||
final List<Target> tagABCTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10,
|
||||
"tagABCTargets", "first description"));
|
||||
final List<Target> tagABCTargets = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(10, "tagABCTargets", "first description"));
|
||||
|
||||
final TargetTag tagA = tagManagement.createTargetTag(new TargetTag("A"));
|
||||
final TargetTag tagB = tagManagement.createTargetTag(new TargetTag("B"));
|
||||
@@ -534,12 +534,12 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
checkTargetHasNotTags(tagCTargets, tagA, tagB);
|
||||
|
||||
// check again target lists refreshed from DB
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "A")).isEqualTo(
|
||||
targetWithTagA.size());
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "B")).isEqualTo(
|
||||
targetWithTagB.size());
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "C")).isEqualTo(
|
||||
targetWithTagC.size());
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "A"))
|
||||
.isEqualTo(targetWithTagA.size());
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "B"))
|
||||
.isEqualTo(targetWithTagB.size());
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "C"))
|
||||
.isEqualTo(targetWithTagC.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -549,21 +549,21 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
final TargetTag targTagB = tagManagement.createTargetTag(new TargetTag("Targ-B-Tag"));
|
||||
final TargetTag targTagC = tagManagement.createTargetTag(new TargetTag("Targ-C-Tag"));
|
||||
|
||||
final List<Target> targAs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A",
|
||||
"first description"));
|
||||
final List<Target> targBs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(20, "target-id-B",
|
||||
"first description"));
|
||||
final List<Target> targCs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(15, "target-id-C",
|
||||
"first description"));
|
||||
final List<Target> targAs = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", "first description"));
|
||||
final List<Target> targBs = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(20, "target-id-B", "first description"));
|
||||
final List<Target> targCs = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(15, "target-id-C", "first description"));
|
||||
|
||||
final List<Target> targABs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(12,
|
||||
"target-id-AB", "first description"));
|
||||
final List<Target> targACs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(13,
|
||||
"target-id-AC", "first description"));
|
||||
final List<Target> targBCs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(7, "target-id-BC",
|
||||
"first description"));
|
||||
final List<Target> targABCs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(17,
|
||||
"target-id-ABC", "first description"));
|
||||
final List<Target> targABs = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(12, "target-id-AB", "first description"));
|
||||
final List<Target> targACs = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(13, "target-id-AC", "first description"));
|
||||
final List<Target> targBCs = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(7, "target-id-BC", "first description"));
|
||||
final List<Target> targABCs = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(17, "target-id-ABC", "first description"));
|
||||
|
||||
targetManagement.toggleTagAssignment(targAs, targTagA);
|
||||
targetManagement.toggleTagAssignment(targABs, targTagA);
|
||||
@@ -610,29 +610,27 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
public void findTargetsByControllerIDsWithTags() {
|
||||
final TargetTag targTagA = tagManagement.createTargetTag(new TargetTag("Targ-A-Tag"));
|
||||
|
||||
final List<Target> targAs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A",
|
||||
"first description"));
|
||||
final List<Target> targAs = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", "first description"));
|
||||
|
||||
targetManagement.toggleTagAssignment(targAs, targTagA);
|
||||
|
||||
assertThat(
|
||||
targetManagement.findTargetsByControllerIDsWithTags(targAs.stream()
|
||||
.map(target -> target.getControllerId()).collect(Collectors.toList()))).hasSize(25);
|
||||
assertThat(targetManagement.findTargetsByControllerIDsWithTags(
|
||||
targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList()))).hasSize(25);
|
||||
|
||||
// no lazy loading exception and tag correctly assigned
|
||||
assertThat(
|
||||
targetManagement
|
||||
.findTargetsByControllerIDsWithTags(
|
||||
targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList()))
|
||||
.stream().map(target -> target.getTags().contains(targTagA)).collect(Collectors.toList()))
|
||||
.containsOnly(true);
|
||||
assertThat(targetManagement
|
||||
.findTargetsByControllerIDsWithTags(
|
||||
targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList()))
|
||||
.stream().map(target -> target.getTags().contains(targTagA)).collect(Collectors.toList()))
|
||||
.containsOnly(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Test the optimized quere for retrieving all ID/name pairs of targets.")
|
||||
public void findAllTargetIdNamePaiss() {
|
||||
final List<Target> targAs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A",
|
||||
"first description"));
|
||||
final List<Target> targAs = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", "first description"));
|
||||
final String[] createdTargetIds = targAs.stream().map(t -> t.getControllerId())
|
||||
.toArray(size -> new String[size]);
|
||||
|
||||
@@ -648,15 +646,15 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
public void findTargetsWithNoTag() {
|
||||
|
||||
final TargetTag targTagA = tagManagement.createTargetTag(new TargetTag("Targ-A-Tag"));
|
||||
final List<Target> targAs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A",
|
||||
"first description"));
|
||||
final List<Target> targAs = targetManagement
|
||||
.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", "first description"));
|
||||
targetManagement.toggleTagAssignment(targAs, targTagA);
|
||||
|
||||
targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-B", "first description"));
|
||||
|
||||
final String[] tagNames = null;
|
||||
final List<Target> targetsListWithNoTag = targetManagement.findTargetByFilters(new PageRequest(0, 500), null,
|
||||
null, null, Boolean.TRUE, tagNames).getContent();
|
||||
final List<Target> targetsListWithNoTag = targetManagement
|
||||
.findTargetByFilters(new PageRequest(0, 500), null, null, null, Boolean.TRUE, tagNames).getContent();
|
||||
|
||||
// Total targets
|
||||
assertEquals(50, targetManagement.findAllTargetIds().size());
|
||||
|
||||
Reference in New Issue
Block a user