Complete repository refactoring - method renaming (#575)
* Split Tag management Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Repo method naming schame applied. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * findAll returns slice instead of page. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Complete javadoc. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Allow null values again. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Readability improvements. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Forgot a method. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fixed broken completed filter. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -3,4 +3,48 @@
|
||||
API for repository access. Contains:
|
||||
|
||||
- Entity Model
|
||||
- Management service API
|
||||
- Management service API
|
||||
|
||||
## Method naming concept (example target management)
|
||||
|
||||
```
|
||||
// Count all targets
|
||||
Long count()
|
||||
|
||||
// Count by filter parameter (example)
|
||||
Long countByTargetFilterQuery(@NotEmpty String targetFilterQuery);
|
||||
|
||||
//Create entity
|
||||
List<Target> create(@NotEmpty Collection<TargetCreate> create)
|
||||
Target create(@NotNull TargetCreate create)
|
||||
|
||||
//Delete entities (throws EntityNotFoundException if one element does not exist (at least one not found in collection case))
|
||||
void delete(@NotEmpty Collection<Long> targetIDs);
|
||||
void delete(@NotNull Long targetID);
|
||||
void deleteByControllerId(@NotEmpty String controllerId);
|
||||
void deleteByControllerId(@NotEmpty Collection<String> controllerId);
|
||||
|
||||
//Update Target (throws EntityNotFoundException if one element does not exist (at least one not found in collection case))
|
||||
List<Target> update(@NotEmpty Collection<TargetUpdate> update);
|
||||
Target update(@NotNull TargetUpdate update);
|
||||
|
||||
//Exist
|
||||
boolean exists(@NotNull Long targetId)
|
||||
boolean existsByAssignedDistributionSet(@NotNull Long distributionSetID);
|
||||
|
||||
// Read methods
|
||||
// Find one on technical ID (Optional, no EntityNotFoundException)
|
||||
Optional<Target> get(@NotNull Long targetId);
|
||||
List<Target> get(@NotEmpty Collection<Long> targetId);
|
||||
|
||||
// Find one on non-ID but unique constraint (Optional, no EntityNotFoundException)
|
||||
Optional<Target> getByControllerID(@NotEmpty String controllerId);
|
||||
List<Target> getByControllerID(@NotEmpty Collection<String> controllerId);
|
||||
|
||||
// Find one on non-ID but and non unique constraint (Optional, no EntityNotFoundException)
|
||||
Optional<Target> findFirstByDescription(@NotEmpty String description);
|
||||
|
||||
// Query/search repository (page might be empty, no EntityNotFoundException) (note: pageReq always first in signature)
|
||||
Page<Target> findByAssignedDistributionSet(@NotNull Pageable pageReq, @NotNull Long distributionSetID);
|
||||
|
||||
```
|
||||
@@ -39,7 +39,7 @@ public interface ArtifactManagement {
|
||||
* management
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Long countArtifactsAll();
|
||||
long count();
|
||||
|
||||
/**
|
||||
* Persists artifact binary as provided by given InputStream. assign the
|
||||
@@ -63,7 +63,7 @@ public interface ArtifactManagement {
|
||||
* if given software module does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
Artifact createArtifact(@NotNull InputStream inputStream, @NotNull Long moduleId, final String filename,
|
||||
Artifact create(@NotNull InputStream inputStream, @NotNull Long moduleId, final String filename,
|
||||
final boolean overrideExisting);
|
||||
|
||||
/**
|
||||
@@ -99,7 +99,7 @@ public interface ArtifactManagement {
|
||||
* if check against provided SHA1 checksum failed
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
Artifact createArtifact(@NotNull InputStream stream, @NotNull Long moduleId, @NotEmpty String filename,
|
||||
Artifact create(@NotNull InputStream stream, @NotNull Long moduleId, @NotEmpty String filename,
|
||||
String providedMd5Sum, String providedSha1Sum, boolean overrideExisting, String contentType);
|
||||
|
||||
/**
|
||||
@@ -129,7 +129,7 @@ public interface ArtifactManagement {
|
||||
* if artifact with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteArtifact(@NotNull Long id);
|
||||
void delete(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* Searches for {@link Artifact} with given {@link Identifiable}.
|
||||
@@ -140,7 +140,7 @@ public interface ArtifactManagement {
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
Optional<Artifact> findArtifact(@NotNull Long id);
|
||||
Optional<Artifact> get(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* Find by artifact by software module id and filename.
|
||||
@@ -156,7 +156,7 @@ public interface ArtifactManagement {
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
Optional<Artifact> findByFilenameAndSoftwareModule(@NotNull String filename, @NotNull Long softwareModuleId);
|
||||
Optional<Artifact> getByFilenameAndSoftwareModule(@NotNull String filename, @NotNull Long softwareModuleId);
|
||||
|
||||
/**
|
||||
* Find all local artifact by sha1 and return the first artifact.
|
||||
@@ -167,7 +167,7 @@ public interface ArtifactManagement {
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
Optional<Artifact> findFirstArtifactBySHA1(@NotNull String sha1);
|
||||
Optional<Artifact> findFirstBySHA1(@NotNull String sha1);
|
||||
|
||||
/**
|
||||
* Searches for {@link Artifact} with given file name.
|
||||
@@ -178,13 +178,13 @@ public interface ArtifactManagement {
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
Optional<Artifact> findArtifactByFilename(@NotNull String filename);
|
||||
Optional<Artifact> getByFilename(@NotNull String filename);
|
||||
|
||||
/**
|
||||
* Get local artifact for a base software module.
|
||||
*
|
||||
* @param pageReq
|
||||
* Pageable
|
||||
* Pageable parameter
|
||||
* @param swId
|
||||
* software module id
|
||||
* @return Page<Artifact>
|
||||
@@ -193,7 +193,7 @@ public interface ArtifactManagement {
|
||||
* if software module with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<Artifact> findArtifactBySoftwareModule(@NotNull Pageable pageReq, @NotNull Long swId);
|
||||
Page<Artifact> findBySoftwareModule(@NotNull Pageable pageReq, @NotNull Long swId);
|
||||
|
||||
/**
|
||||
* Loads {@link AbstractDbArtifact} from store for given {@link Artifact}.
|
||||
|
||||
@@ -64,6 +64,16 @@ public interface ControllerManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
Action addCancelActionStatus(@NotNull ActionStatusCreate create);
|
||||
|
||||
/**
|
||||
* Retrieves assigned {@link SoftwareModule} of a target.
|
||||
*
|
||||
* @param moduleId
|
||||
* of the {@link SoftwareModule}
|
||||
* @return {@link SoftwareModule} identified by ID
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
Optional<SoftwareModule> getSoftwareModule(@NotNull final Long moduleId);
|
||||
|
||||
/**
|
||||
* Simple addition of a new {@link ActionStatus} entry to the {@link Action}
|
||||
* . No state changes.
|
||||
@@ -282,7 +292,7 @@ public interface ControllerManagement {
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
Optional<Target> findByControllerId(@NotEmpty String controllerId);
|
||||
Optional<Target> getByControllerId(@NotEmpty String controllerId);
|
||||
|
||||
/**
|
||||
* Finds {@link Target} based on given ID returns found Target without
|
||||
@@ -296,7 +306,7 @@ public interface ControllerManagement {
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
Optional<Target> findByTargetId(@NotNull Long targetId);
|
||||
Optional<Target> get(@NotNull Long targetId);
|
||||
|
||||
/**
|
||||
* Retrieves the specified number of messages from action history of the
|
||||
|
||||
@@ -187,19 +187,19 @@ public interface DeploymentManagement {
|
||||
* if target with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countActionsByTarget(@NotNull String rsqlParam, @NotEmpty String controllerId);
|
||||
long countActionsByTarget(@NotNull String rsqlParam, @NotEmpty String controllerId);
|
||||
|
||||
/**
|
||||
* @return the total amount of stored action status
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countActionStatusAll();
|
||||
long countActionStatusAll();
|
||||
|
||||
/**
|
||||
* @return the total amount of stored actions
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countActionsAll();
|
||||
long countActionsAll();
|
||||
|
||||
/**
|
||||
* counts all actions associated to a specific target.
|
||||
@@ -212,7 +212,7 @@ public interface DeploymentManagement {
|
||||
* if target with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countActionsByTarget(@NotEmpty String controllerId);
|
||||
long countActionsByTarget(@NotEmpty String controllerId);
|
||||
|
||||
/**
|
||||
* Get the {@link Action} entity for given actionId.
|
||||
|
||||
@@ -12,20 +12,17 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.DistributionSetCreationFailedMissingMandatoryModuleException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||
import org.eclipse.hawkbit.repository.exception.UnsupportedSoftwareModuleForThisDistributionSetException;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
|
||||
@@ -45,7 +42,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
* Management service for {@link DistributionSet}s.
|
||||
*
|
||||
*/
|
||||
public interface DistributionSetManagement {
|
||||
public interface DistributionSetManagement
|
||||
extends RepositoryManagement<DistributionSet, DistributionSetCreate, DistributionSetUpdate> {
|
||||
|
||||
/**
|
||||
* Assigns {@link SoftwareModule} to existing {@link DistributionSet}.
|
||||
@@ -66,8 +64,6 @@ public interface DistributionSetManagement {
|
||||
* @throws UnsupportedSoftwareModuleForThisDistributionSetException
|
||||
* is {@link SoftwareModule#getType()} is not supported by this
|
||||
* {@link DistributionSet#getType()}.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSet assignSoftwareModules(@NotNull Long setId, @NotEmpty Collection<Long> moduleIds);
|
||||
@@ -76,7 +72,7 @@ public interface DistributionSetManagement {
|
||||
* Assign a {@link DistributionSetTag} assignment to given
|
||||
* {@link DistributionSet}s.
|
||||
*
|
||||
* @param dsIds
|
||||
* @param setIds
|
||||
* to assign for
|
||||
* @param tagId
|
||||
* to assign
|
||||
@@ -87,42 +83,12 @@ public interface DistributionSetManagement {
|
||||
* distribution sets.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
List<DistributionSet> assignTag(@NotEmpty Collection<Long> dsIds, @NotNull Long tagId);
|
||||
|
||||
/**
|
||||
* Count all {@link DistributionSet}s in the repository that are not marked
|
||||
* as deleted.
|
||||
*
|
||||
* @return number of {@link DistributionSet}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Long countDistributionSetsAll();
|
||||
|
||||
/**
|
||||
* Creates a new {@link DistributionSet}.
|
||||
*
|
||||
* @param create
|
||||
* {@link DistributionSet} to be created
|
||||
* @return the new persisted {@link DistributionSet}
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if a provided linked entity does not exists (
|
||||
* {@link DistributionSet#getModules()} or
|
||||
* {@link DistributionSet#getType()})
|
||||
* @throws DistributionSetCreationFailedMissingMandatoryModuleException
|
||||
* is {@link DistributionSet} does not contain mandatory
|
||||
* {@link SoftwareModule}s.
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link DistributionSetCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
DistributionSet createDistributionSet(@NotNull DistributionSetCreate create);
|
||||
List<DistributionSet> assignTag(@NotEmpty Collection<Long> setIds, @NotNull Long tagId);
|
||||
|
||||
/**
|
||||
* creates a list of distribution set meta data entries.
|
||||
*
|
||||
* @param dsId
|
||||
* @param setId
|
||||
* if the {@link DistributionSet} the metadata has to be created
|
||||
* for
|
||||
* @param metadata
|
||||
@@ -136,69 +102,12 @@ public interface DistributionSetManagement {
|
||||
* specific key
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
List<DistributionSetMetadata> createDistributionSetMetadata(@NotNull Long dsId,
|
||||
@NotEmpty Collection<MetaData> metadata);
|
||||
|
||||
/**
|
||||
* Creates multiple {@link DistributionSet}s.
|
||||
*
|
||||
* @param creates
|
||||
* to be created
|
||||
* @return the new {@link DistributionSet}s
|
||||
* @throws EntityNotFoundException
|
||||
* if a provided linked entity does not exists (
|
||||
* {@link DistributionSet#getModules()} or
|
||||
* {@link DistributionSet#getType()})
|
||||
* @throws DistributionSetCreationFailedMissingMandatoryModuleException
|
||||
* is {@link DistributionSet} does not contain mandatory
|
||||
* {@link SoftwareModule}s.
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link DistributionSetCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
List<DistributionSet> createDistributionSets(@NotNull Collection<DistributionSetCreate> creates);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* {@link DistributionSet} can be deleted/erased from the repository if they
|
||||
* have never been assigned to any {@link Action} or {@link Target}.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* If they have been assigned that need to be marked as deleted which as a
|
||||
* result means that they cannot be assigned anymore to any targets. (define
|
||||
* e.g. findByDeletedFalse())
|
||||
* </p>
|
||||
*
|
||||
* @param setId
|
||||
* to delete
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if given {@link DistributionSet} does not exist
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteDistributionSet(@NotNull Long setId);
|
||||
|
||||
/**
|
||||
* Deleted {@link DistributionSet}s by their IDs. That is either a soft
|
||||
* delete of the entities have been linked to an {@link Action} before or a
|
||||
* hard delete if not.
|
||||
*
|
||||
* @param dsIds
|
||||
* to be deleted
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if (at least one) given distribution set does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteDistributionSet(@NotEmpty Collection<Long> dsIds);
|
||||
List<DistributionSetMetadata> createMetaData(@NotNull Long setId, @NotEmpty Collection<MetaData> metadata);
|
||||
|
||||
/**
|
||||
* deletes a distribution set meta data entry.
|
||||
*
|
||||
* @param dsId
|
||||
* @param setId
|
||||
* where meta data has to be deleted
|
||||
* @param key
|
||||
* of the meta data element
|
||||
@@ -207,7 +116,7 @@ public interface DistributionSetManagement {
|
||||
* if given set does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
void deleteDistributionSetMetadata(@NotNull final Long dsId, @NotEmpty final String key);
|
||||
void deleteMetaData(@NotNull Long setId, @NotEmpty String key);
|
||||
|
||||
/**
|
||||
* retrieves the distribution set for a given action.
|
||||
@@ -220,33 +129,21 @@ public interface DistributionSetManagement {
|
||||
* if action with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<DistributionSet> findDistributionSetByAction(@NotNull Long actionId);
|
||||
|
||||
/**
|
||||
* Find {@link DistributionSet} based on given ID without details, e.g.
|
||||
* {@link DistributionSet#getModules()}.
|
||||
*
|
||||
* @param distid
|
||||
* to look for.
|
||||
* @return {@link DistributionSet}
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<DistributionSet> findDistributionSetById(@NotNull Long distid);
|
||||
Optional<DistributionSet> getByAction(@NotNull Long actionId);
|
||||
|
||||
/**
|
||||
* Find {@link DistributionSet} based on given ID including (lazy loaded)
|
||||
* details, e.g. {@link DistributionSet#getModules()}.
|
||||
*
|
||||
* Note: for performance reasons it is recommended to use
|
||||
* {@link #findDistributionSetById(Long)} if details are not necessary.
|
||||
* Note: for performance reasons it is recommended to use {@link #get(Long)}
|
||||
* if details are not necessary.
|
||||
*
|
||||
* @param distid
|
||||
* @param setId
|
||||
* to look for.
|
||||
* @return {@link DistributionSet}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<DistributionSet> findDistributionSetByIdWithDetails(@NotNull Long distid);
|
||||
Optional<DistributionSet> getWithDetails(@NotNull Long setId);
|
||||
|
||||
/**
|
||||
* Find distribution set by name and version.
|
||||
@@ -258,16 +155,16 @@ public interface DistributionSetManagement {
|
||||
* @return the page with the found {@link DistributionSet}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<DistributionSet> findDistributionSetByNameAndVersion(@NotEmpty String distributionName,
|
||||
@NotEmpty String version);
|
||||
Optional<DistributionSet> getByNameAndVersion(@NotEmpty String distributionName, @NotEmpty String version);
|
||||
|
||||
/**
|
||||
* finds all meta data by the given distribution set id.
|
||||
*
|
||||
* @param distributionSetId
|
||||
* the distribution set id to retrieve the meta data from
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to page the result
|
||||
* @param setId
|
||||
* the distribution set id to retrieve the meta data from
|
||||
*
|
||||
* @return a paged result of all meta data entries for a given distribution
|
||||
* set id
|
||||
*
|
||||
@@ -275,18 +172,18 @@ public interface DistributionSetManagement {
|
||||
* if distribution set with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(@NotNull Long distributionSetId,
|
||||
@NotNull Pageable pageable);
|
||||
Page<DistributionSetMetadata> findMetaDataByDistributionSetId(@NotNull Pageable pageable, @NotNull Long setId);
|
||||
|
||||
/**
|
||||
* finds all meta data by the given distribution set id.
|
||||
*
|
||||
* @param distributionSetId
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to page the result
|
||||
* @param setId
|
||||
* the distribution set id to retrieve the meta data from
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param pageable
|
||||
* the page request to page the result
|
||||
*
|
||||
* @return a paged result of all meta data entries for a given distribution
|
||||
* set id
|
||||
*
|
||||
@@ -300,19 +197,14 @@ public interface DistributionSetManagement {
|
||||
* of distribution set with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(@NotNull Long distributionSetId,
|
||||
@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
Page<DistributionSetMetadata> findMetaDataByDistributionSetIdAndRsql(@NotNull Pageable pageable,
|
||||
@NotNull Long setId, @NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* finds all {@link DistributionSet}s.
|
||||
*
|
||||
* @param pageReq
|
||||
* @param pageable
|
||||
* the pagination parameter
|
||||
* @param deleted
|
||||
* if TRUE, {@link DistributionSet}s marked as deleted are
|
||||
* returned. If FALSE, on {@link DistributionSet}s with
|
||||
* {@link DistributionSet#isDeleted()} == FALSE are returned.
|
||||
* <code>null</code> if both are to be returned
|
||||
* @param complete
|
||||
* to <code>true</code> for returning only completed distribution
|
||||
* sets or <code>false</code> for only incomplete ones nor
|
||||
@@ -322,47 +214,7 @@ public interface DistributionSetManagement {
|
||||
* @return all found {@link DistributionSet}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSet> findDistributionSetsByDeletedAndOrCompleted(@NotNull Pageable pageReq, Boolean deleted,
|
||||
Boolean complete);
|
||||
|
||||
/**
|
||||
* finds all {@link DistributionSet}s.
|
||||
*
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param pageReq
|
||||
* the pagination parameter
|
||||
* @param deleted
|
||||
* if TRUE, {@link DistributionSet}s marked as deleted are
|
||||
* returned. If FALSE, on {@link DistributionSet}s not marked as
|
||||
* deleted are returned. <code>null</code> if both are to be
|
||||
* returned
|
||||
* @return all found {@link DistributionSet}s
|
||||
*
|
||||
* @throws RSQLParameterUnsupportedFieldException
|
||||
* if a field in the RSQL string is used but not provided by the
|
||||
* given {@code fieldNameProvider}
|
||||
* @throws RSQLParameterSyntaxException
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSet> findDistributionSetsAll(@NotNull String rsqlParam, @NotNull Pageable pageReq,
|
||||
Boolean deleted);
|
||||
|
||||
/**
|
||||
* finds all {@link DistributionSet}s.
|
||||
*
|
||||
* @param pageReq
|
||||
* the pagination parameter
|
||||
* @param deleted
|
||||
* if TRUE, {@link DistributionSet}s marked as deleted are
|
||||
* returned. If FALSE, on {@link DistributionSet}s not marked as
|
||||
* deleted are returned. <code>null</code> if both are to be
|
||||
* returned
|
||||
* @return all found {@link DistributionSet}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSet> findDistributionSetsAll(@NotNull Pageable pageReq, Boolean deleted);
|
||||
Page<DistributionSet> findByCompleted(@NotNull Pageable pageable, Boolean complete);
|
||||
|
||||
/**
|
||||
* method retrieves all {@link DistributionSet}s from the repository in the
|
||||
@@ -386,7 +238,7 @@ public interface DistributionSetManagement {
|
||||
* @return {@link DistributionSet}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSet> findDistributionSetsAllOrderedByLinkTarget(@NotNull Pageable pageable,
|
||||
Page<DistributionSet> findByFilterAndAssignedInstalledDsOrderedByLinkTarget(@NotNull Pageable pageable,
|
||||
@NotNull DistributionSetFilterBuilder distributionSetFilterBuilder, @NotEmpty String assignedOrInstalled);
|
||||
|
||||
/**
|
||||
@@ -399,7 +251,7 @@ public interface DistributionSetManagement {
|
||||
* @return the page of found {@link DistributionSet}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSet> findDistributionSetsByFilters(@NotNull Pageable pageable,
|
||||
Page<DistributionSet> findByDistributionSetFilter(@NotNull Pageable pageable,
|
||||
@NotNull DistributionSetFilter distributionSetFilter);
|
||||
|
||||
/**
|
||||
@@ -421,7 +273,7 @@ public interface DistributionSetManagement {
|
||||
* of distribution set tag with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSet> findDistributionSetsByTag(@NotNull final Pageable pageable, @NotNull final Long tagId);
|
||||
Page<DistributionSet> findByTag(@NotNull Pageable pageable, @NotNull Long tagId);
|
||||
|
||||
/**
|
||||
* retrieves {@link DistributionSet}s by filtering on the given parameters.
|
||||
@@ -438,8 +290,7 @@ public interface DistributionSetManagement {
|
||||
* of distribution set tag with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSet> findDistributionSetsByTag(@NotNull final Pageable pageable, @NotNull String rsqlParam,
|
||||
@NotNull final Long tagId);
|
||||
Page<DistributionSet> findByRsqlAndTag(@NotNull Pageable pageable, @NotNull String rsqlParam, @NotNull Long tagId);
|
||||
|
||||
/**
|
||||
* finds a single distribution set meta data by its id.
|
||||
@@ -454,7 +305,7 @@ public interface DistributionSetManagement {
|
||||
* is set with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<DistributionSetMetadata> findDistributionSetMetadata(@NotNull Long setId, @NotEmpty String key);
|
||||
Optional<DistributionSetMetadata> getMetaDataByDistributionSetId(@NotNull Long setId, @NotEmpty String key);
|
||||
|
||||
/**
|
||||
* Checks if a {@link DistributionSet} is currently in use by a target in
|
||||
@@ -466,7 +317,7 @@ public interface DistributionSetManagement {
|
||||
* @return <code>true</code> if in use
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
boolean isDistributionSetInUse(@NotNull Long setId);
|
||||
boolean isInUse(@NotNull Long setId);
|
||||
|
||||
/**
|
||||
* Toggles {@link DistributionSetTag} assignment to given
|
||||
@@ -474,7 +325,7 @@ public interface DistributionSetManagement {
|
||||
* the list have the {@link Tag} not yet assigned, they will be. If all of
|
||||
* theme have the tag already assigned they will be removed instead.
|
||||
*
|
||||
* @param dsIds
|
||||
* @param setIds
|
||||
* to toggle for
|
||||
* @param tagName
|
||||
* to toggle
|
||||
@@ -485,7 +336,7 @@ public interface DistributionSetManagement {
|
||||
* if given tag does not exist or (at least one) module
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<Long> dsIds, @NotNull String tagName);
|
||||
DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<Long> setIds, @NotNull String tagName);
|
||||
|
||||
/**
|
||||
* Unassigns a {@link SoftwareModule} form an existing
|
||||
@@ -511,7 +362,7 @@ public interface DistributionSetManagement {
|
||||
* Unassign a {@link DistributionSetTag} assignment to given
|
||||
* {@link DistributionSet}.
|
||||
*
|
||||
* @param dsId
|
||||
* @param setId
|
||||
* to unassign for
|
||||
* @param tagId
|
||||
* to unassign
|
||||
@@ -521,34 +372,14 @@ public interface DistributionSetManagement {
|
||||
* if set or tag with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSet unAssignTag(@NotNull Long dsId, @NotNull Long tagId);
|
||||
|
||||
/**
|
||||
* Updates existing {@link DistributionSet}.
|
||||
*
|
||||
* @param update
|
||||
* to update
|
||||
*
|
||||
* @return the saved entity.
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if given set does not exist
|
||||
* @throws EntityReadOnlyException
|
||||
* if user tries to change requiredMigrationStep or type on a DS
|
||||
* that is already assigned to targets
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link DistributionSetUpdate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSet updateDistributionSet(@NotNull DistributionSetUpdate update);
|
||||
DistributionSet unAssignTag(@NotNull Long setId, @NotNull Long tagId);
|
||||
|
||||
/**
|
||||
* updates a distribution set meta data value if corresponding entry exists.
|
||||
*
|
||||
* @param dsId
|
||||
* @param setId
|
||||
* {@link DistributionSet} of the meta data entry to be updated
|
||||
* @param md
|
||||
* @param metadata
|
||||
* meta data entry to be updated
|
||||
* @return the updated meta data entry
|
||||
*
|
||||
@@ -557,16 +388,21 @@ public interface DistributionSetManagement {
|
||||
* updated
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSetMetadata updateDistributionSetMetadata(@NotNull Long dsId, @NotNull MetaData md);
|
||||
DistributionSetMetadata updateMetaData(@NotNull Long setId, @NotNull MetaData metadata);
|
||||
|
||||
/**
|
||||
* Retrieves all distribution set without details.
|
||||
* Count all {@link DistributionSet}s in the repository that are not marked
|
||||
* as deleted.
|
||||
*
|
||||
* @param typeId
|
||||
* to look for
|
||||
*
|
||||
* @param ids
|
||||
* the ids to for
|
||||
* @return the found {@link DistributionSet}s
|
||||
* @return number of {@link DistributionSet}s
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if type with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
List<DistributionSet> findDistributionSetsById(@NotEmpty Collection<Long> ids);
|
||||
long countByTypeId(@NotNull Long typeId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.TagUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Management service for {@link DistributionSetTag}s.
|
||||
*
|
||||
*/
|
||||
public interface DistributionSetTagManagement extends RepositoryManagement<DistributionSetTag, TagCreate, TagUpdate> {
|
||||
|
||||
/**
|
||||
* Deletes {@link DistributionSetTag} by given
|
||||
* {@link DistributionSetTag#getName()}.
|
||||
*
|
||||
* @param tagName
|
||||
* to be deleted
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if tag with given name does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void delete(@NotEmpty String tagName);
|
||||
|
||||
/**
|
||||
* Find {@link DistributionSet} based on given name.
|
||||
*
|
||||
* @param name
|
||||
* to look for.
|
||||
* @return {@link DistributionSet}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<DistributionSetTag> getByName(@NotEmpty String name);
|
||||
|
||||
/**
|
||||
* Finds all {@link TargetTag} assigned to given {@link Target}.
|
||||
*
|
||||
* @param pageable
|
||||
* information for page size, offset and sort order.
|
||||
*
|
||||
* @param setId
|
||||
* of the {@link DistributionSet}
|
||||
* @return page of the found {@link TargetTag}s
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if {@link DistributionSet} with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSetTag> findByDistributionSet(@NotNull Pageable pageable, @NotNull Long setId);
|
||||
|
||||
}
|
||||
@@ -9,10 +9,8 @@
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
@@ -20,84 +18,18 @@ import org.eclipse.hawkbit.repository.builder.DistributionSetTypeCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Management service for {@link DistributionSetType}s.
|
||||
*
|
||||
*/
|
||||
public interface DistributionSetTypeManagement {
|
||||
|
||||
/**
|
||||
* Creates new {@link DistributionSetType}.
|
||||
*
|
||||
* @param create
|
||||
* to create
|
||||
* @return created entity
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if a provided linked entity does not exists (
|
||||
* {@link DistributionSetType#getMandatoryModuleTypes()} or
|
||||
* {@link DistributionSetType#getOptionalModuleTypes()}
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link DistributionSetTypeCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
DistributionSetType createDistributionSetType(@NotNull DistributionSetTypeCreate create);
|
||||
|
||||
/**
|
||||
* Creates multiple {@link DistributionSetType}s.
|
||||
*
|
||||
* @param creates
|
||||
* to create
|
||||
* @return created entity
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if a provided linked entity does not exists (
|
||||
* {@link DistributionSetType#getMandatoryModuleTypes()} or
|
||||
* {@link DistributionSetType#getOptionalModuleTypes()}
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link DistributionSetTypeCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
List<DistributionSetType> createDistributionSetTypes(@NotNull Collection<DistributionSetTypeCreate> creates);
|
||||
|
||||
/**
|
||||
* Count all {@link DistributionSet}s in the repository that are not marked
|
||||
* as deleted.
|
||||
*
|
||||
* @param typeId
|
||||
* to look for
|
||||
*
|
||||
* @return number of {@link DistributionSet}s
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if type with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Long countDistributionSetsByType(@NotNull Long typeId);
|
||||
|
||||
/**
|
||||
* Deletes or mark as delete in case the type is in use.
|
||||
*
|
||||
* @param typeId
|
||||
* to delete
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if given set does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteDistributionSetType(@NotNull Long typeId);
|
||||
public interface DistributionSetTypeManagement
|
||||
extends RepositoryManagement<DistributionSetType, DistributionSetTypeCreate, DistributionSetTypeUpdate> {
|
||||
|
||||
/**
|
||||
* @param key
|
||||
@@ -106,7 +38,7 @@ public interface DistributionSetTypeManagement {
|
||||
*/
|
||||
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<DistributionSetType> findDistributionSetTypeByKey(@NotEmpty String key);
|
||||
Optional<DistributionSetType> getByKey(@NotEmpty String key);
|
||||
|
||||
/**
|
||||
* @param name
|
||||
@@ -114,66 +46,7 @@ public interface DistributionSetTypeManagement {
|
||||
* @return {@link DistributionSetType}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<DistributionSetType> findDistributionSetTypeByName(@NotEmpty String name);
|
||||
|
||||
/**
|
||||
* @param pageable
|
||||
* parameter
|
||||
* @return all {@link DistributionSetType}s in the repository.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSetType> findDistributionSetTypesAll(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Generic predicate based query for {@link DistributionSetType}.
|
||||
*
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param pageable
|
||||
* parameter for paging
|
||||
*
|
||||
* @return the found {@link SoftwareModuleType}s
|
||||
*
|
||||
* @throws RSQLParameterUnsupportedFieldException
|
||||
* if a field in the RSQL string is used but not provided by the
|
||||
* given {@code fieldNameProvider}
|
||||
* @throws RSQLParameterSyntaxException
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSetType> findDistributionSetTypesAll(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* as {@link DistributionSetType#getId()}
|
||||
* @return {@link DistributionSetType}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<DistributionSetType> findDistributionSetTypeById(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* Updates existing {@link DistributionSetType}. Resets assigned
|
||||
* {@link SoftwareModuleType}s as well and sets as provided.
|
||||
*
|
||||
* @param update
|
||||
* to update
|
||||
*
|
||||
* @return updated entity
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* in case the {@link DistributionSetType} does not exists and
|
||||
* cannot be updated
|
||||
*
|
||||
* @throws EntityReadOnlyException
|
||||
* if the {@link DistributionSetType} is already in use by a
|
||||
* {@link DistributionSet} and user tries to change list of
|
||||
* {@link SoftwareModuleType}s
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link DistributionSetTypeUpdate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSetType updateDistributionSetType(@NotNull DistributionSetTypeUpdate update);
|
||||
Optional<DistributionSetType> getByName(@NotEmpty String name);
|
||||
|
||||
/**
|
||||
* Assigns {@link DistributionSetType#getMandatoryModuleTypes()}.
|
||||
@@ -238,10 +111,4 @@ public interface DistributionSetTypeManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSetType unassignSoftwareModuleType(@NotNull Long dsTypeId, @NotNull Long softwareModuleId);
|
||||
|
||||
/**
|
||||
* @return number of {@link DistributionSetType}s in the repository.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Long countDistributionSetTypesAll();
|
||||
|
||||
}
|
||||
|
||||
@@ -21,17 +21,17 @@ import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
*/
|
||||
public class FilterParams {
|
||||
|
||||
private Collection<TargetUpdateStatus> filterByStatus;
|
||||
private Boolean overdueState;
|
||||
private String filterBySearchText;
|
||||
private Boolean selectTargetWithNoTag;
|
||||
private String[] filterByTagNames;
|
||||
private Long filterByDistributionId;
|
||||
private final Collection<TargetUpdateStatus> filterByStatus;
|
||||
private final Boolean overdueState;
|
||||
private final String filterBySearchText;
|
||||
private final Boolean selectTargetWithNoTag;
|
||||
private final String[] filterByTagNames;
|
||||
private final Long filterByDistributionId;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param filterByDistributionId
|
||||
* @param filterByInstalledOrAssignedDistributionSetId
|
||||
* if set, a filter is added for the given
|
||||
* {@link DistributionSet#getId()}
|
||||
* @param filterByStatus
|
||||
@@ -47,13 +47,13 @@ public class FilterParams {
|
||||
* if tag-filtering is enabled, a filter is added for the given
|
||||
* tag-names
|
||||
*/
|
||||
public FilterParams(Long filterByDistributionId, Collection<TargetUpdateStatus> filterByStatus,
|
||||
Boolean overdueState, String filterBySearchText, Boolean selectTargetWithNoTag,
|
||||
String... filterByTagNames) {
|
||||
public FilterParams(final Collection<TargetUpdateStatus> filterByStatus, final Boolean overdueState,
|
||||
final String filterBySearchText, final Long filterByInstalledOrAssignedDistributionSetId,
|
||||
final Boolean selectTargetWithNoTag, final String... filterByTagNames) {
|
||||
this.filterByStatus = filterByStatus;
|
||||
this.overdueState = overdueState;
|
||||
this.filterBySearchText = filterBySearchText;
|
||||
this.filterByDistributionId = filterByDistributionId;
|
||||
this.filterByDistributionId = filterByInstalledOrAssignedDistributionSetId;
|
||||
this.selectTargetWithNoTag = selectTargetWithNoTag;
|
||||
this.filterByTagNames = filterByTagNames;
|
||||
}
|
||||
@@ -68,16 +68,6 @@ public class FilterParams {
|
||||
return filterByDistributionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets {@link DistributionSet#getId()} to filter the result.
|
||||
*
|
||||
* @param filterByDistributionId
|
||||
* the distribution set id
|
||||
*/
|
||||
public void setFilterByDistributionId(Long filterByDistributionId) {
|
||||
this.filterByDistributionId = filterByDistributionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a collection of target states to filter for. <br>
|
||||
* If set to <code>null</code> this filter is disabled.
|
||||
@@ -88,16 +78,6 @@ public class FilterParams {
|
||||
return filterByStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the collection of target states to filter for.
|
||||
*
|
||||
* @param filterByStatus
|
||||
* collection of target update status
|
||||
*/
|
||||
public void setFilterByStatus(Collection<TargetUpdateStatus> filterByStatus) {
|
||||
this.filterByStatus = filterByStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the flag for overdue filter; if set to <code>true</code>, the
|
||||
* overdue filter is activated. Overdued targets a targets that did not
|
||||
@@ -110,17 +90,6 @@ public class FilterParams {
|
||||
return overdueState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the flag for overdue filter; if set to <code>true</code>, the
|
||||
* overdue filter is activated.
|
||||
*
|
||||
* @param overdueState
|
||||
* if the overdue filter should be activates
|
||||
*/
|
||||
public void setOverdueState(Boolean overdueState) {
|
||||
this.overdueState = overdueState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the search text to filter for. This is used to find targets having
|
||||
* the text anywhere in name or description <br>
|
||||
@@ -132,16 +101,6 @@ public class FilterParams {
|
||||
return filterBySearchText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the search text to filter for.
|
||||
*
|
||||
* @param filterBySearchText
|
||||
* search text
|
||||
*/
|
||||
public void setFilterBySearchText(String filterBySearchText) {
|
||||
this.filterBySearchText = filterBySearchText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the flag indicating if tagging filter is used. <br>
|
||||
* If set to <code>null</code> this filter is disabled.
|
||||
@@ -152,16 +111,6 @@ public class FilterParams {
|
||||
return selectTargetWithNoTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the flag indicating if tagging filter is used.
|
||||
*
|
||||
* @param selectTargetWithNoTag
|
||||
* should the tagging filter be used?
|
||||
*/
|
||||
public void setSelectTargetWithNoTag(Boolean selectTargetWithNoTag) {
|
||||
this.selectTargetWithNoTag = selectTargetWithNoTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tags that are used to filter for. The activation of this filter
|
||||
* is done by {@link #setSelectTargetWithNoTag(Boolean)}.
|
||||
@@ -171,14 +120,4 @@ public class FilterParams {
|
||||
public String[] getFilterByTagNames() {
|
||||
return filterByTagNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tags that are used to filter for.
|
||||
*
|
||||
* @param filterByTagNames
|
||||
* array of tag names
|
||||
*/
|
||||
public void setFilterByTagNames(String[] filterByTagNames) {
|
||||
this.filterByTagNames = filterByTagNames;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Generic management methods common to (software) repository content.
|
||||
*
|
||||
* @param <T>
|
||||
* type of the {@link BaseEntity}
|
||||
* @param <C>
|
||||
* entity create builder
|
||||
* @param <U>
|
||||
* entity update builder
|
||||
*/
|
||||
public interface RepositoryManagement<T, C, U> {
|
||||
|
||||
/**
|
||||
* Creates multiple {@link BaseEntity}s.
|
||||
*
|
||||
* @param creates
|
||||
* to create
|
||||
* @return created Entity
|
||||
*
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link BaseEntity} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
List<T> create(@NotNull Collection<C> creates);
|
||||
|
||||
/**
|
||||
* Creates new {@link SoftwareModuleType}.
|
||||
*
|
||||
* @param create
|
||||
* to create
|
||||
* @return created Entity
|
||||
*
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link BaseEntity} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
T create(@NotNull C create);
|
||||
|
||||
/**
|
||||
* Updates existing {@link BaseEntity}.
|
||||
*
|
||||
* @param update
|
||||
* to update
|
||||
*
|
||||
* @return updated Entity
|
||||
*
|
||||
* @throws EntityReadOnlyException
|
||||
* if the {@link BaseEntity} cannot be updated (e.g. is already
|
||||
* in use)
|
||||
* @throws EntityNotFoundException
|
||||
* in case the {@link BaseEntity} does not exists and cannot be
|
||||
* updated
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link BaseEntity} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
T update(@NotNull U update);
|
||||
|
||||
/**
|
||||
* @return number of {@link BaseEntity}s in the repository.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
long count();
|
||||
|
||||
/**
|
||||
* Deletes or marks as delete in case the {@link BaseEntity} is in use.
|
||||
*
|
||||
* @param id
|
||||
* to delete
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* BaseEntity with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void delete(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* Delete {@link BaseEntity}s by their IDs. That is either a soft delete of
|
||||
* the entities have been linked to another entity before or a hard delete
|
||||
* if not.
|
||||
*
|
||||
* @param ids
|
||||
* to be deleted
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if (at least one) given distribution set does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void delete(@NotEmpty Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link BaseEntity}s without details.
|
||||
*
|
||||
* @param ids
|
||||
* the ids to for
|
||||
* @return the found {@link BaseEntity}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
List<T> get(@NotEmpty Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* Verifies that {@link BaseEntity} with given ID exists in the repository.
|
||||
*
|
||||
* @param id
|
||||
* of entity to check existence
|
||||
* @return <code>true</code> if entity with given ID exists
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
boolean exists(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* Retrieve {@link BaseEntity}
|
||||
*
|
||||
* @param id
|
||||
* to search for
|
||||
* @return {@link BaseEntity} in the repository with given
|
||||
* {@link BaseEntity#getId()}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<T> get(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* Retrieves {@link Page} of all {@link BaseEntity} of given type.
|
||||
*
|
||||
* @param pageable
|
||||
* paging parameter
|
||||
* @return all {@link BaseEntity}s in the repository.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Slice<T> findAll(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link BaseEntity}s with a given specification.
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @param rsqlParam
|
||||
* filter definition in RSQL syntax
|
||||
*
|
||||
* @return the found {@link BaseEntity}s
|
||||
*
|
||||
* @throws RSQLParameterUnsupportedFieldException
|
||||
* if a field in the RSQL string is used but not provided by the
|
||||
* given {@code fieldNameProvider}
|
||||
* @throws RSQLParameterSyntaxException
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<T> findByRsql(@NotNull Pageable pageable, @NotNull String rsqlParam);
|
||||
}
|
||||
@@ -34,17 +34,18 @@ public interface RolloutGroupManagement {
|
||||
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
||||
* {@link Rollout} with the detailed status.
|
||||
*
|
||||
* @param rolloutId
|
||||
* the ID of the rollout to filter the {@link RolloutGroup}s
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @param rolloutId
|
||||
* the ID of the rollout to filter the {@link RolloutGroup}s
|
||||
*
|
||||
* @return a page of found {@link RolloutGroup}s
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* of rollout with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<RolloutGroup> findAllRolloutGroupsWithDetailedStatus(@NotNull Long rolloutId, @NotNull Pageable pageable);
|
||||
Page<RolloutGroup> findByRolloutWithDetailedStatus(@NotNull Pageable pageable, @NotNull Long rolloutId);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -63,7 +64,7 @@ public interface RolloutGroupManagement {
|
||||
* if rollout group with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
||||
Page<TargetWithActionStatus> findAllTargetsWithActionStatus(@NotNull Pageable pageable,
|
||||
Page<TargetWithActionStatus> findAllTargetsOfRolloutGroupWithActionStatus(@NotNull Pageable pageable,
|
||||
@NotNull Long rolloutGroupId);
|
||||
|
||||
/**
|
||||
@@ -76,19 +77,20 @@ public interface RolloutGroupManagement {
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Optional<RolloutGroup> findRolloutGroupById(@NotNull Long rolloutGroupId);
|
||||
Optional<RolloutGroup> get(@NotNull Long rolloutGroupId);
|
||||
|
||||
/**
|
||||
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
||||
* {@link Rollout} and the an rsql filter.
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @param rolloutId
|
||||
* the rollout to filter the {@link RolloutGroup}s
|
||||
* @param rsqlParam
|
||||
* the specification to filter the result set based on attributes
|
||||
* of the {@link RolloutGroup}
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
*
|
||||
* @return a page of found {@link RolloutGroup}s
|
||||
*
|
||||
* @throws RSQLParameterUnsupportedFieldException
|
||||
@@ -98,8 +100,22 @@ public interface RolloutGroupManagement {
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<RolloutGroup> findRolloutGroupsAll(@NotNull Long rolloutId, @NotNull String rsqlParam,
|
||||
@NotNull Pageable pageable);
|
||||
Page<RolloutGroup> findByRolloutAndRsql(@NotNull Pageable pageable, @NotNull Long rolloutId,
|
||||
@NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
||||
* {@link Rollout}.
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @param rolloutId
|
||||
* the ID of the rollout to filter the {@link RolloutGroup}s
|
||||
*
|
||||
* @return a page of found {@link RolloutGroup}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<RolloutGroup> findByRollout(@NotNull Pageable pageable, @NotNull Long rolloutId);
|
||||
|
||||
/**
|
||||
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
||||
@@ -112,28 +128,15 @@ public interface RolloutGroupManagement {
|
||||
* @return a page of found {@link RolloutGroup}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<RolloutGroup> findRolloutGroupsByRolloutId(@NotNull Long rolloutId, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
||||
* {@link Rollout}.
|
||||
*
|
||||
* @param rolloutId
|
||||
* the ID of the rollout to filter the {@link RolloutGroup}s
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @return a page of found {@link RolloutGroup}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
long countRolloutGroupsByRolloutId(@NotNull Long rolloutId);
|
||||
long countByRollout(@NotNull Long rolloutId);
|
||||
|
||||
/**
|
||||
* Get targets of specified rollout group.
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @param rolloutGroupId
|
||||
* rollout group
|
||||
* @param page
|
||||
* the page request to sort and limit the result
|
||||
*
|
||||
* @return Page<Target> list of targets of a rollout group
|
||||
*
|
||||
@@ -141,17 +144,17 @@ public interface RolloutGroupManagement {
|
||||
* if group with ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
||||
Page<Target> findRolloutGroupTargets(@NotNull Long rolloutGroupId, @NotNull Pageable page);
|
||||
Page<Target> findTargetsOfRolloutGroup(@NotNull Pageable pageable, @NotNull Long rolloutGroupId);
|
||||
|
||||
/**
|
||||
* Get targets of specified rollout group.
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @param rolloutGroupId
|
||||
* rollout group
|
||||
* @param rsqlParam
|
||||
* the specification for filtering the targets of a rollout group
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
*
|
||||
* @return Page<Target> list of targets of a rollout group
|
||||
*
|
||||
@@ -162,8 +165,8 @@ public interface RolloutGroupManagement {
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
||||
Page<Target> findRolloutGroupTargets(@NotNull Long rolloutGroupId, @NotNull String rsqlParam,
|
||||
@NotNull Pageable pageable);
|
||||
Page<Target> findTargetsOfRolloutGroupByRsql(@NotNull Pageable pageable, @NotNull Long rolloutGroupId,
|
||||
@NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* Get {@link RolloutGroup} by Id.
|
||||
@@ -174,7 +177,7 @@ public interface RolloutGroupManagement {
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Optional<RolloutGroup> findRolloutGroupWithDetailedStatus(@NotNull Long rolloutGroupId);
|
||||
Optional<RolloutGroup> getWithDetailedStatus(@NotNull Long rolloutGroupId);
|
||||
|
||||
/**
|
||||
* Count targets of rollout group.
|
||||
@@ -187,5 +190,5 @@ public interface RolloutGroupManagement {
|
||||
* if rollout group with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Long countTargetsOfRolloutsGroup(@NotNull Long rolloutGroupId);
|
||||
long countTargetsOfRolloutsGroup(@NotNull Long rolloutGroupId);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public interface RolloutManagement {
|
||||
* For {@link RolloutStatus#READY} that means switching to
|
||||
* {@link RolloutStatus#STARTING} if the {@link Rollout#getStartAt()} is set
|
||||
* and time of calling this method is beyond this point in time. This auto
|
||||
* start mechanism is optional. Call {@link #startRollout(Long)} otherwise.
|
||||
* start mechanism is optional. Call {@link #start(Long)} otherwise.
|
||||
*
|
||||
* For {@link RolloutStatus#STARTING} that means starting the first
|
||||
* {@link RolloutGroup}s in line and when finished switch to
|
||||
@@ -81,7 +81,7 @@ public interface RolloutManagement {
|
||||
* @return number of roll outs
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Long countRolloutsAll();
|
||||
long count();
|
||||
|
||||
/**
|
||||
* Count rollouts by given text in name or description.
|
||||
@@ -91,7 +91,7 @@ public interface RolloutManagement {
|
||||
* @return total count rollouts for specified filter text.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Long countRolloutsAllByFilters(@NotEmpty String searchText);
|
||||
long countByFilters(@NotEmpty String searchText);
|
||||
|
||||
/**
|
||||
* Persists a new rollout entity. The filter within the
|
||||
@@ -107,7 +107,7 @@ public interface RolloutManagement {
|
||||
* The RolloutScheduler will start to assign targets to the groups. Once all
|
||||
* targets have been assigned to the groups, the rollout status is changed
|
||||
* to {@link RolloutStatus#READY} so it can be started with
|
||||
* {@link #startRollout(Rollout)}.
|
||||
* {@link #start(Rollout)}.
|
||||
*
|
||||
* @param create
|
||||
* the rollout entity to create
|
||||
@@ -124,7 +124,7 @@ public interface RolloutManagement {
|
||||
* if rollout or group parameters are invalid.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
Rollout createRollout(@NotNull RolloutCreate create, int amountGroup, @NotNull RolloutGroupConditions conditions);
|
||||
Rollout create(@NotNull RolloutCreate create, int amountGroup, @NotNull RolloutGroupConditions conditions);
|
||||
|
||||
/**
|
||||
* Persists a new rollout entity. The filter within the
|
||||
@@ -140,7 +140,7 @@ public interface RolloutManagement {
|
||||
* The RolloutScheduler will start to assign targets to the groups. Once all
|
||||
* targets have been assigned to the groups, the rollout status is changed
|
||||
* to {@link RolloutStatus#READY} so it can be started with
|
||||
* {@link #startRollout(Rollout)}.
|
||||
* {@link #start(Rollout)}.
|
||||
*
|
||||
* @param rollout
|
||||
* the rollout entity to create
|
||||
@@ -158,7 +158,7 @@ public interface RolloutManagement {
|
||||
* if rollout or group parameters are invalid
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
Rollout createRollout(@NotNull RolloutCreate rollout, @NotNull List<RolloutGroupCreate> groups,
|
||||
Rollout create(@NotNull RolloutCreate rollout, @NotNull List<RolloutGroupCreate> groups,
|
||||
RolloutGroupConditions conditions);
|
||||
|
||||
/**
|
||||
@@ -205,17 +205,18 @@ public interface RolloutManagement {
|
||||
* statuses
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<Rollout> findAllRolloutsWithDetailedStatus(@NotNull Pageable pageable, boolean deleted);
|
||||
Page<Rollout> findAllWithDetailedStatus(@NotNull Pageable pageable, boolean deleted);
|
||||
|
||||
/**
|
||||
* Retrieves all rollouts found by the given specification.
|
||||
*
|
||||
* @param rsqlParam
|
||||
* the specification to filter rollouts
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @param rsqlParam
|
||||
* the specification to filter rollouts
|
||||
* @param deleted
|
||||
* flag if deleted rollouts should be included
|
||||
*
|
||||
* @return a page of found rollouts
|
||||
*
|
||||
* @throws RSQLParameterUnsupportedFieldException
|
||||
@@ -225,7 +226,7 @@ public interface RolloutManagement {
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<Rollout> findAllByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable, boolean deleted);
|
||||
Page<Rollout> findByRsql(@NotNull Pageable pageable, @NotNull String rsqlParam, boolean deleted);
|
||||
|
||||
/**
|
||||
* Finds rollouts by given text in name or description.
|
||||
@@ -240,7 +241,7 @@ public interface RolloutManagement {
|
||||
* not exists
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Slice<Rollout> findRolloutWithDetailedStatusByFilters(@NotNull Pageable pageable, @NotEmpty String searchText,
|
||||
Slice<Rollout> findByFiltersWithDetailedStatus(@NotNull Pageable pageable, @NotEmpty String searchText,
|
||||
boolean deleted);
|
||||
|
||||
/**
|
||||
@@ -252,7 +253,7 @@ public interface RolloutManagement {
|
||||
* not exists
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Optional<Rollout> findRolloutById(@NotNull Long rolloutId);
|
||||
Optional<Rollout> get(@NotNull Long rolloutId);
|
||||
|
||||
/**
|
||||
* Retrieves a specific rollout by its name.
|
||||
@@ -263,7 +264,7 @@ public interface RolloutManagement {
|
||||
* does not exists
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Optional<Rollout> findRolloutByName(@NotEmpty String rolloutName);
|
||||
Optional<Rollout> getByName(@NotEmpty String rolloutName);
|
||||
|
||||
/**
|
||||
* Get count of targets in different status in rollout.
|
||||
@@ -277,7 +278,7 @@ public interface RolloutManagement {
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Optional<Rollout> findRolloutWithDetailedStatus(@NotNull Long rolloutId);
|
||||
Optional<Rollout> getWithDetailedStatus(@NotNull Long rolloutId);
|
||||
|
||||
/**
|
||||
* Checks if rollout with given ID exists.
|
||||
@@ -350,7 +351,7 @@ public interface RolloutManagement {
|
||||
* ready rollouts can be started.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
Rollout startRollout(@NotNull Long rolloutId);
|
||||
Rollout start(@NotNull Long rolloutId);
|
||||
|
||||
/**
|
||||
* Update rollout details.
|
||||
@@ -368,7 +369,7 @@ public interface RolloutManagement {
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
Rollout updateRollout(@NotNull RolloutUpdate update);
|
||||
Rollout update(@NotNull RolloutUpdate update);
|
||||
|
||||
/**
|
||||
* Deletes a rollout. A rollout might be deleted asynchronously by
|
||||
@@ -379,6 +380,6 @@ public interface RolloutManagement {
|
||||
* the ID of the rollout to be deleted
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
void deleteRollout(long rolloutId);
|
||||
void delete(@NotNull Long rolloutId);
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
@@ -38,7 +37,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
* Service for managing {@link SoftwareModule}s.
|
||||
*
|
||||
*/
|
||||
public interface SoftwareModuleManagement {
|
||||
public interface SoftwareModuleManagement
|
||||
extends RepositoryManagement<SoftwareModule, SoftwareModuleCreate, SoftwareModuleUpdate> {
|
||||
|
||||
/**
|
||||
* Counts {@link SoftwareModule}s with given
|
||||
@@ -55,51 +55,7 @@ public interface SoftwareModuleManagement {
|
||||
* if software module type with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Long countSoftwareModuleByFilters(String searchText, Long typeId);
|
||||
|
||||
/**
|
||||
* Count all {@link SoftwareModule}s in the repository that are not marked
|
||||
* as deleted.
|
||||
*
|
||||
* @return number of {@link SoftwareModule}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Long countSoftwareModulesAll();
|
||||
|
||||
/**
|
||||
* Create {@link SoftwareModule}s in the repository.
|
||||
*
|
||||
* @param creates
|
||||
* {@link SoftwareModule}s to create
|
||||
* @return SoftwareModule
|
||||
*
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if a given entity already exists
|
||||
* @throws EntityNotFoundException
|
||||
* of given software module type does not exist
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link SoftwareModuleCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
List<SoftwareModule> createSoftwareModule(@NotNull Collection<SoftwareModuleCreate> creates);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param create
|
||||
* SoftwareModule to create
|
||||
* @return SoftwareModule
|
||||
*
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if a given entity already exists
|
||||
* @throws EntityNotFoundException
|
||||
* of given software module type does not exist
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link SoftwareModuleCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
SoftwareModule createSoftwareModule(@NotNull SoftwareModuleCreate create);
|
||||
long countByTextAndType(String searchText, Long typeId);
|
||||
|
||||
/**
|
||||
* creates a list of software module meta data entries.
|
||||
@@ -116,8 +72,7 @@ public interface SoftwareModuleManagement {
|
||||
* if software module with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
List<SoftwareModuleMetadata> createSoftwareModuleMetadata(@NotNull Long moduleId,
|
||||
@NotNull Collection<MetaData> metadata);
|
||||
List<SoftwareModuleMetadata> createMetaData(@NotNull Long moduleId, @NotNull Collection<MetaData> metadata);
|
||||
|
||||
/**
|
||||
* creates or updates a single software module meta data entry.
|
||||
@@ -134,16 +89,7 @@ public interface SoftwareModuleManagement {
|
||||
* if software module with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
SoftwareModuleMetadata createSoftwareModuleMetadata(@NotNull Long moduleId, @NotNull MetaData metadata);
|
||||
|
||||
/**
|
||||
* Deletes the given {@link SoftwareModule} Entity.
|
||||
*
|
||||
* @param moduleId
|
||||
* is the {@link SoftwareModule} to be deleted
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteSoftwareModule(@NotNull Long moduleId);
|
||||
SoftwareModuleMetadata createMetaData(@NotNull Long moduleId, @NotNull MetaData metadata);
|
||||
|
||||
/**
|
||||
* deletes a software module meta data entry.
|
||||
@@ -157,19 +103,7 @@ public interface SoftwareModuleManagement {
|
||||
* of module or metadata entry does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
void deleteSoftwareModuleMetadata(@NotNull Long moduleId, @NotEmpty String key);
|
||||
|
||||
/**
|
||||
* Deletes {@link SoftwareModule}s which is any if the given ids.
|
||||
*
|
||||
* @param moduleIds
|
||||
* of the Software Modules to be deleted
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if (at least one) module with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteSoftwareModules(@NotNull Collection<Long> moduleIds);
|
||||
void deleteMetaData(@NotNull Long moduleId, @NotEmpty String key);
|
||||
|
||||
/**
|
||||
* @param pageable
|
||||
@@ -183,7 +117,7 @@ public interface SoftwareModuleManagement {
|
||||
* if distribution set with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<SoftwareModule> findSoftwareModuleByAssignedTo(@NotNull Pageable pageable, @NotNull Long setId);
|
||||
Page<SoftwareModule> findByAssignedTo(@NotNull Pageable pageable, @NotNull Long setId);
|
||||
|
||||
/**
|
||||
* Filter {@link SoftwareModule}s with given
|
||||
@@ -202,30 +136,7 @@ public interface SoftwareModuleManagement {
|
||||
* if given software module type does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Slice<SoftwareModule> findSoftwareModuleByFilters(@NotNull Pageable pageable, String searchText, Long typeId);
|
||||
|
||||
/**
|
||||
* Finds {@link SoftwareModuleType} by given id.
|
||||
*
|
||||
* @param ids
|
||||
* to search for
|
||||
* @return the found {@link SoftwareModuleType}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
List<SoftwareModuleType> findSoftwareModuleTypesById(@NotEmpty Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* Finds {@link SoftwareModule} by given id.
|
||||
*
|
||||
* @param id
|
||||
* to search for
|
||||
* @return the found {@link SoftwareModule}s
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
Optional<SoftwareModule> findSoftwareModuleById(@NotNull Long id);
|
||||
Slice<SoftwareModule> findByTextAndType(@NotNull Pageable pageable, String searchText, Long typeId);
|
||||
|
||||
/**
|
||||
* retrieves {@link SoftwareModule} by their name AND version AND type..
|
||||
@@ -242,7 +153,7 @@ public interface SoftwareModuleManagement {
|
||||
* if software module type with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<SoftwareModule> findSoftwareModuleByNameAndVersion(@NotEmpty String name, @NotEmpty String version,
|
||||
Optional<SoftwareModule> getByNameAndVersionAndType(@NotEmpty String name, @NotEmpty String version,
|
||||
@NotNull Long typeId);
|
||||
|
||||
/**
|
||||
@@ -258,15 +169,16 @@ public interface SoftwareModuleManagement {
|
||||
* is module with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<SoftwareModuleMetadata> findSoftwareModuleMetadata(@NotNull Long moduleId, @NotEmpty String key);
|
||||
Optional<SoftwareModuleMetadata> getMetaDataBySoftwareModuleId(@NotNull Long moduleId, @NotEmpty String key);
|
||||
|
||||
/**
|
||||
* finds all meta data by the given software module id.
|
||||
*
|
||||
* @param swId
|
||||
* the software module id to retrieve the meta data from
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to page the result
|
||||
* @param moduleId
|
||||
* the software module id to retrieve the meta data from
|
||||
*
|
||||
* @return a paged result of all meta data entries for a given software
|
||||
* module id
|
||||
*
|
||||
@@ -274,18 +186,18 @@ public interface SoftwareModuleManagement {
|
||||
* if software module with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long swId,
|
||||
@NotNull Pageable pageable);
|
||||
Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleId(@NotNull Pageable pageable, @NotNull Long moduleId);
|
||||
|
||||
/**
|
||||
* finds all meta data by the given software module id.
|
||||
*
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to page the result
|
||||
* @param moduleId
|
||||
* the software module id to retrieve the meta data from
|
||||
* @param rsqlParam
|
||||
* filter definition in RSQL syntax
|
||||
* @param pageable
|
||||
* the page request to page the result
|
||||
*
|
||||
* @return a paged result of all meta data entries for a given software
|
||||
* module id
|
||||
*
|
||||
@@ -298,25 +210,8 @@ public interface SoftwareModuleManagement {
|
||||
* if software module with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long moduleId,
|
||||
@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Finds all meta data by the given software module id.
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
*
|
||||
* @param moduleId
|
||||
* the software module id to retrieve the meta data from
|
||||
* @return page with found software module metadata
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* of software module with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Pageable pageable,
|
||||
@NotNull Long moduleId);
|
||||
Page<SoftwareModuleMetadata> findMetaDataByRsql(@NotNull Pageable pageable, @NotNull Long moduleId,
|
||||
@NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* Filter {@link SoftwareModule}s with given
|
||||
@@ -342,48 +237,9 @@ public interface SoftwareModuleManagement {
|
||||
* if given software module type does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Slice<AssignedSoftwareModule> findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
|
||||
Slice<AssignedSoftwareModule> findAllOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
|
||||
@NotNull Pageable pageable, @NotNull Long orderByDistributionId, String searchText, Long typeId);
|
||||
|
||||
/**
|
||||
* Retrieves all software modules. Deleted ones are filtered.
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link SoftwareModule}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Slice<SoftwareModule> findSoftwareModulesAll(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all software modules with a given list of ids
|
||||
* {@link SoftwareModule#getId()}.
|
||||
*
|
||||
* @param ids
|
||||
* to search for
|
||||
* @return {@link List} of found {@link SoftwareModule}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
List<SoftwareModule> findSoftwareModulesById(@NotEmpty Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link SoftwareModule}s with a given specification.
|
||||
*
|
||||
* @param rsqlParam
|
||||
* filter definition in RSQL syntax
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link SoftwareModule}s
|
||||
*
|
||||
* @throws RSQLParameterUnsupportedFieldException
|
||||
* if a field in the RSQL string is used but not provided by the
|
||||
* given {@code fieldNameProvider}
|
||||
* @throws RSQLParameterSyntaxException
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<SoftwareModule> findSoftwareModulesByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* retrieves the {@link SoftwareModule}s by their {@link SoftwareModuleType}
|
||||
* .
|
||||
@@ -398,29 +254,7 @@ public interface SoftwareModuleManagement {
|
||||
* if software module type with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Slice<SoftwareModule> findSoftwareModulesByType(@NotNull Pageable pageable, @NotNull Long typeId);
|
||||
|
||||
/**
|
||||
* Updates existing {@link SoftwareModule}. Update-able values are
|
||||
* {@link SoftwareModule#getDescription()}
|
||||
* {@link SoftwareModule#getVendor()}.
|
||||
*
|
||||
* @param update
|
||||
* contains properties to update
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if given module does not exist
|
||||
*
|
||||
* @return the saved Entity.
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if given {@link SoftwareModule} does not exist
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link SoftwareModuleUpdate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
SoftwareModule updateSoftwareModule(@NotNull SoftwareModuleUpdate update);
|
||||
Slice<SoftwareModule> findByType(@NotNull Pageable pageable, @NotNull Long typeId);
|
||||
|
||||
/**
|
||||
* updates a distribution set meta data value if corresponding entry exists.
|
||||
@@ -437,5 +271,5 @@ public interface SoftwareModuleManagement {
|
||||
* updated
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
SoftwareModuleMetadata updateSoftwareModuleMetadata(@NotNull Long moduleId, @NotNull MetaData metadata);
|
||||
SoftwareModuleMetadata updateMetaData(@NotNull Long moduleId, @NotNull MetaData metadata);
|
||||
}
|
||||
|
||||
@@ -8,86 +8,21 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Service for managing {@link SoftwareModuleType}s.
|
||||
*
|
||||
*/
|
||||
public interface SoftwareModuleTypeManagement {
|
||||
|
||||
/**
|
||||
* @return number of {@link SoftwareModuleType}s in the repository.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Long countSoftwareModuleTypesAll();
|
||||
|
||||
/**
|
||||
* Creates multiple {@link SoftwareModuleType}s.
|
||||
*
|
||||
* @param creates
|
||||
* to create
|
||||
* @return created Entity
|
||||
*
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link SoftwareModuleTypeCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
List<SoftwareModuleType> createSoftwareModuleType(@NotNull Collection<SoftwareModuleTypeCreate> creates);
|
||||
|
||||
/**
|
||||
* Creates new {@link SoftwareModuleType}.
|
||||
*
|
||||
* @param create
|
||||
* to create
|
||||
* @return created Entity
|
||||
*
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link SoftwareModuleTypeCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
SoftwareModuleType createSoftwareModuleType(@NotNull SoftwareModuleTypeCreate create);
|
||||
|
||||
/**
|
||||
* Deletes or marks as delete in case the type is in use.
|
||||
*
|
||||
* @param typeId
|
||||
* to delete
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* not found is type with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteSoftwareModuleType(@NotNull Long typeId);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* to search for
|
||||
* @return {@link SoftwareModuleType} in the repository with given
|
||||
* {@link SoftwareModuleType#getId()}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<SoftwareModuleType> findSoftwareModuleTypeById(@NotNull Long id);
|
||||
public interface SoftwareModuleTypeManagement
|
||||
extends RepositoryManagement<SoftwareModuleType, SoftwareModuleTypeCreate, SoftwareModuleTypeUpdate> {
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -97,7 +32,7 @@ public interface SoftwareModuleTypeManagement {
|
||||
* {@link SoftwareModuleType#getKey()}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<SoftwareModuleType> findSoftwareModuleTypeByKey(@NotEmpty String key);
|
||||
Optional<SoftwareModuleType> getByKey(@NotEmpty String key);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -107,50 +42,5 @@ public interface SoftwareModuleTypeManagement {
|
||||
* {@link SoftwareModuleType#getName()}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<SoftwareModuleType> findSoftwareModuleTypeByName(@NotEmpty String name);
|
||||
|
||||
/**
|
||||
* @param pageable
|
||||
* parameter
|
||||
* @return all {@link SoftwareModuleType}s in the repository.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<SoftwareModuleType> findSoftwareModuleTypesAll(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link SoftwareModuleType}s with a given specification.
|
||||
*
|
||||
* @param rsqlParam
|
||||
* filter definition in RSQL syntax
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link SoftwareModuleType}s
|
||||
*
|
||||
* @throws RSQLParameterUnsupportedFieldException
|
||||
* if a field in the RSQL string is used but not provided by the
|
||||
* given {@code fieldNameProvider}
|
||||
* @throws RSQLParameterSyntaxException
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<SoftwareModuleType> findSoftwareModuleTypesAll(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Updates existing {@link SoftwareModuleType}.
|
||||
*
|
||||
* @param update
|
||||
* to update
|
||||
*
|
||||
* @return updated Entity
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* in case the {@link SoftwareModuleType} does not exists and
|
||||
* cannot be updated
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link SoftwareModuleTypeUpdate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
SoftwareModuleType updateSoftwareModuleType(@NotNull SoftwareModuleTypeUpdate update);
|
||||
|
||||
Optional<SoftwareModuleType> getByName(@NotEmpty String name);
|
||||
}
|
||||
|
||||
@@ -1,303 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.TagUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.Tag;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Management service for {@link Tag}s.
|
||||
*
|
||||
*/
|
||||
public interface TagManagement {
|
||||
|
||||
/**
|
||||
* count {@link TargetTag}s.
|
||||
*
|
||||
* @return size of {@link TargetTag}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
long countTargetTags();
|
||||
|
||||
/**
|
||||
* Creates a {@link DistributionSet}.
|
||||
*
|
||||
* @param create
|
||||
* to be created.
|
||||
* @return the new {@link DistributionSet}
|
||||
*
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if distributionSetTag already exists
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link TagCreate} for field constraints.
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
DistributionSetTag createDistributionSetTag(@NotNull TagCreate create);
|
||||
|
||||
/**
|
||||
* Creates multiple {@link DistributionSetTag}s.
|
||||
*
|
||||
* @param creates
|
||||
* to be created
|
||||
* @return the new {@link DistributionSetTag}
|
||||
*
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if a given entity already exists
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link TagCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
List<DistributionSetTag> createDistributionSetTags(@NotNull Collection<TagCreate> creates);
|
||||
|
||||
/**
|
||||
* Creates a new {@link TargetTag}.
|
||||
*
|
||||
* @param create
|
||||
* to be created
|
||||
*
|
||||
* @return the new created {@link TargetTag}
|
||||
*
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if given object already exists
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link TagCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
TargetTag createTargetTag(@NotNull TagCreate create);
|
||||
|
||||
/**
|
||||
* created multiple {@link TargetTag}s.
|
||||
*
|
||||
* @param creates
|
||||
* to be created
|
||||
* @return the new created {@link TargetTag}s
|
||||
*
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if given object has already an ID.
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link TagCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
List<TargetTag> createTargetTags(@NotNull Collection<TagCreate> creates);
|
||||
|
||||
/**
|
||||
* Deletes {@link DistributionSetTag} by given
|
||||
* {@link DistributionSetTag#getName()}.
|
||||
*
|
||||
* @param tagName
|
||||
* to be deleted
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if tag with given name does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteDistributionSetTag(@NotEmpty String tagName);
|
||||
|
||||
/**
|
||||
* Deletes {@link TargetTag} with given name.
|
||||
*
|
||||
* @param targetTagName
|
||||
* tag name of the {@link TargetTag} to be deleted
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if tag with given name does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||
void deleteTargetTag(@NotEmpty String targetTagName);
|
||||
|
||||
/**
|
||||
* returns all {@link DistributionSetTag}s.
|
||||
*
|
||||
* @param pageReq
|
||||
* page parameter
|
||||
* @return all {@link DistributionSetTag}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSetTag> findAllDistributionSetTags(@NotNull Pageable pageReq);
|
||||
|
||||
/**
|
||||
* Retrieves all DistributionSet tags based on the given specification.
|
||||
*
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link DistributionSetTag}s, never {@code null}
|
||||
*
|
||||
* @throws RSQLParameterUnsupportedFieldException
|
||||
* if a field in the RSQL string is used but not provided by the
|
||||
* given {@code fieldNameProvider}
|
||||
* @throws RSQLParameterSyntaxException
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSetTag> findAllDistributionSetTags(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* returns all {@link TargetTag}s.
|
||||
*
|
||||
* @param pageable
|
||||
* page parameter
|
||||
*
|
||||
* @return all {@link TargetTag}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetTag> findAllTargetTags(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Returns all {@link TargetTag}s assigned to {@link Target} with given ID.
|
||||
*
|
||||
* @param pageable
|
||||
* page parameter
|
||||
* @param controllerId
|
||||
*
|
||||
* @return {@link TargetTag}s assigned to {@link Target} with given ID
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if target with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetTag> findAllTargetTags(@NotNull Pageable pageable, @NotEmpty String controllerId);
|
||||
|
||||
/**
|
||||
* Retrieves all target tags based on the given specification.
|
||||
*
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link Target}s, never {@code null}
|
||||
*
|
||||
* @throws RSQLParameterUnsupportedFieldException
|
||||
* if a field in the RSQL string is used but not provided by the
|
||||
* given {@code fieldNameProvider}
|
||||
* @throws RSQLParameterSyntaxException
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetTag> findAllTargetTags(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Find {@link DistributionSet} based on given name.
|
||||
*
|
||||
* @param name
|
||||
* to look for.
|
||||
* @return {@link DistributionSet}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<DistributionSetTag> findDistributionSetTag(@NotEmpty String name);
|
||||
|
||||
/**
|
||||
* Finds {@link DistributionSetTag} by given id.
|
||||
*
|
||||
* @param id
|
||||
* to search for
|
||||
* @return the found {@link DistributionSetTag}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Optional<DistributionSetTag> findDistributionSetTagById(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* Find {@link TargetTag} based on given Name.
|
||||
*
|
||||
* @param name
|
||||
* to look for.
|
||||
* @return {@link TargetTag}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Optional<TargetTag> findTargetTag(@NotEmpty String name);
|
||||
|
||||
/**
|
||||
* Finds {@link TargetTag} by given id.
|
||||
*
|
||||
* @param id
|
||||
* to search for
|
||||
* @return the found {@link TargetTag}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Optional<TargetTag> findTargetTagById(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* Finds all {@link TargetTag} assigned to given {@link Target}.
|
||||
*
|
||||
* @param pageable
|
||||
* information for page size, offset and sort order.
|
||||
*
|
||||
* @param setId
|
||||
* of the {@link DistributionSet}
|
||||
* @return page of the found {@link TargetTag}s
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if {@link DistributionSet} with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSetTag> findDistributionSetTagsByDistributionSet(@NotNull Pageable pageable, @NotNull Long setId);
|
||||
|
||||
/**
|
||||
* Updates an existing {@link DistributionSetTag}.
|
||||
*
|
||||
* @param update
|
||||
* to be updated
|
||||
*
|
||||
* @return the updated {@link DistributionSet}
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* in case the {@link DistributionSetTag} does not exists and
|
||||
* cannot be updated
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link TagUpdate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSetTag updateDistributionSetTag(@NotNull TagUpdate update);
|
||||
|
||||
/**
|
||||
* updates the {@link TargetTag}.
|
||||
*
|
||||
* @param update
|
||||
* the {@link TargetTag} with updated values
|
||||
* @return the updated {@link TargetTag}
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* in case the {@link TargetTag} does not exists and cannot be
|
||||
* updated
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link TagUpdate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetTag updateTargetTag(@NotNull TagUpdate update);
|
||||
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public interface TargetFilterQueryManagement {
|
||||
* {@link TargetFilterQueryCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
TargetFilterQuery createTargetFilterQuery(@NotNull TargetFilterQueryCreate create);
|
||||
TargetFilterQuery create(@NotNull TargetFilterQueryCreate create);
|
||||
|
||||
/**
|
||||
* Delete target filter query.
|
||||
@@ -53,7 +53,7 @@ public interface TargetFilterQueryManagement {
|
||||
* if filter with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||
void deleteTargetFilterQuery(@NotNull Long targetFilterQueryId);
|
||||
void delete(@NotNull Long targetFilterQueryId);
|
||||
|
||||
/**
|
||||
* Verifies provided filter syntax.
|
||||
@@ -81,7 +81,7 @@ public interface TargetFilterQueryManagement {
|
||||
* @return the found {@link TargetFilterQuery}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findAllTargetFilterQuery(@NotNull Pageable pageable);
|
||||
Page<TargetFilterQuery> findAll(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Counts all target filter queries
|
||||
@@ -89,7 +89,7 @@ public interface TargetFilterQueryManagement {
|
||||
* @return the number of all target filter queries
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countAllTargetFilterQuery();
|
||||
long count();
|
||||
|
||||
/**
|
||||
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
||||
@@ -102,7 +102,7 @@ public interface TargetFilterQueryManagement {
|
||||
* @return the page with the found {@link TargetFilterQuery}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByName(@NotNull Pageable pageable, @NotNull String name);
|
||||
Page<TargetFilterQuery> findByName(@NotNull Pageable pageable, @NotNull String name);
|
||||
|
||||
/**
|
||||
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
||||
@@ -115,7 +115,7 @@ public interface TargetFilterQueryManagement {
|
||||
* @return the page with the found {@link TargetFilterQuery}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByFilter(@NotNull Pageable pageable, @NotNull String rsqlFilter);
|
||||
Page<TargetFilterQuery> findByRsql(@NotNull Pageable pageable, @NotNull String rsqlFilter);
|
||||
|
||||
/**
|
||||
* Retrieves all target filter query which have exactly the provided query.
|
||||
@@ -127,7 +127,7 @@ public interface TargetFilterQueryManagement {
|
||||
* @return the page with the found {@link TargetFilterQuery}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByQuery(@NotNull Pageable pageable, @NotNull String query);
|
||||
Page<TargetFilterQuery> findByQuery(@NotNull Pageable pageable, @NotNull String query);
|
||||
|
||||
/**
|
||||
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
||||
@@ -145,7 +145,7 @@ public interface TargetFilterQueryManagement {
|
||||
* if DS with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByAutoAssignDS(@NotNull Pageable pageable, @NotNull Long setId,
|
||||
Page<TargetFilterQuery> findByAutoAssignDSAndRsql(@NotNull Pageable pageable, @NotNull Long setId,
|
||||
String rsqlParam);
|
||||
|
||||
/**
|
||||
@@ -157,7 +157,7 @@ public interface TargetFilterQueryManagement {
|
||||
* @param pageable
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findTargetFilterQueryWithAutoAssignDS(@NotNull Pageable pageable);
|
||||
Page<TargetFilterQuery> findWithAutoAssignDS(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Find target filter query by id.
|
||||
@@ -168,7 +168,7 @@ public interface TargetFilterQueryManagement {
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Optional<TargetFilterQuery> findTargetFilterQueryById(@NotNull Long targetFilterQueryId);
|
||||
Optional<TargetFilterQuery> get(@NotNull Long targetFilterQueryId);
|
||||
|
||||
/**
|
||||
* Find target filter query by name.
|
||||
@@ -179,7 +179,7 @@ public interface TargetFilterQueryManagement {
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Optional<TargetFilterQuery> findTargetFilterQueryByName(@NotNull String targetFilterQueryName);
|
||||
Optional<TargetFilterQuery> getByName(@NotNull String targetFilterQueryName);
|
||||
|
||||
/**
|
||||
* updates the {@link TargetFilterQuery}.
|
||||
@@ -197,7 +197,7 @@ public interface TargetFilterQueryManagement {
|
||||
* {@link TargetFilterQueryUpdate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetFilterQuery updateTargetFilterQuery(@NotNull TargetFilterQueryUpdate update);
|
||||
TargetFilterQuery update(@NotNull TargetFilterQueryUpdate update);
|
||||
|
||||
/**
|
||||
* updates the {@link TargetFilterQuery#getAutoAssignDistributionSet()}.
|
||||
@@ -213,6 +213,6 @@ public interface TargetFilterQueryManagement {
|
||||
* provided but not found
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetFilterQuery updateTargetFilterQueryAutoAssignDS(@NotNull Long queryId, Long dsId);
|
||||
TargetFilterQuery updateAutoAssignDS(@NotNull Long queryId, Long dsId);
|
||||
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public interface TargetManagement {
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Long countTargetByAssignedDistributionSet(@NotNull Long distId);
|
||||
long countByAssignedDistributionSet(@NotNull Long distId);
|
||||
|
||||
/**
|
||||
* Count {@link Target}s for all the given filter parameters.
|
||||
@@ -104,7 +104,7 @@ public interface TargetManagement {
|
||||
* if distribution set with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countTargetByFilters(Collection<TargetUpdateStatus> status, Boolean overdueState, String searchText,
|
||||
long countByFilters(Collection<TargetUpdateStatus> status, Boolean overdueState, String searchText,
|
||||
Long installedOrAssignedDistributionSetId, Boolean selectTargetWithNoTag, String... tagNames);
|
||||
|
||||
/**
|
||||
@@ -120,7 +120,7 @@ public interface TargetManagement {
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Long countTargetByInstalledDistributionSet(@NotNull Long distId);
|
||||
long countByInstalledDistributionSet(@NotNull Long distId);
|
||||
|
||||
/**
|
||||
* Count {@link TargetFilterQuery}s for given target filter query.
|
||||
@@ -130,7 +130,7 @@ public interface TargetManagement {
|
||||
* @return the found number {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countTargetByTargetFilterQuery(@NotEmpty String rsqlParam);
|
||||
long countByRsql(@NotEmpty String rsqlParam);
|
||||
|
||||
/**
|
||||
* Count {@link TargetFilterQuery}s for given target filter query.
|
||||
@@ -143,7 +143,7 @@ public interface TargetManagement {
|
||||
* if {@link TargetFilterQuery} with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countTargetByTargetFilterQuery(@NotNull Long targetFilterQueryId);
|
||||
long countByTargetFilterQuery(@NotNull Long targetFilterQueryId);
|
||||
|
||||
/**
|
||||
* Counts all {@link Target}s in the repository.
|
||||
@@ -151,7 +151,7 @@ public interface TargetManagement {
|
||||
* @return number of targets
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countTargetsAll();
|
||||
long count();
|
||||
|
||||
/**
|
||||
* creating a new {@link Target}.
|
||||
@@ -167,9 +167,8 @@ public interface TargetManagement {
|
||||
* {@link TargetCreate} for field constraints.
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
Target createTarget(@NotNull TargetCreate create);
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
Target create(@NotNull TargetCreate create);
|
||||
|
||||
/**
|
||||
* creates multiple {@link Target}s. If some of the given {@link Target}s
|
||||
@@ -188,7 +187,7 @@ public interface TargetManagement {
|
||||
* {@link TargetCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
List<Target> createTargets(@NotNull Collection<TargetCreate> creates);
|
||||
List<Target> create(@NotNull Collection<TargetCreate> creates);
|
||||
|
||||
/**
|
||||
* Deletes all targets with the given IDs.
|
||||
@@ -200,7 +199,7 @@ public interface TargetManagement {
|
||||
* if (at least one) of the given target IDs does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||
void deleteTargets(@NotEmpty Collection<Long> targetIDs);
|
||||
void delete(@NotEmpty Collection<Long> targetIDs);
|
||||
|
||||
/**
|
||||
* Deletes target with the given IDs.
|
||||
@@ -212,7 +211,7 @@ public interface TargetManagement {
|
||||
* if target with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||
void deleteTarget(@NotEmpty String controllerID);
|
||||
void deleteByControllerID(@NotEmpty String controllerID);
|
||||
|
||||
/**
|
||||
* Finds all targets for all the given parameter {@link TargetFilterQuery}
|
||||
@@ -231,8 +230,8 @@ public interface TargetManagement {
|
||||
* if distribution set with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Target> findAllTargetsByTargetFilterQueryAndNonDS(@NotNull Pageable pageRequest,
|
||||
@NotNull Long distributionSetId, @NotNull String rsqlParam);
|
||||
Page<Target> findByTargetFilterQueryAndNonDS(@NotNull Pageable pageRequest, @NotNull Long distributionSetId,
|
||||
@NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* Counts all targets for all the given parameter {@link TargetFilterQuery}
|
||||
@@ -249,7 +248,7 @@ public interface TargetManagement {
|
||||
* if distribution set with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countTargetsByTargetFilterQueryAndNonDS(@NotNull Long distributionSetId, @NotNull String rsqlParam);
|
||||
long countByRsqlAndNonDS(@NotNull Long distributionSetId, @NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* Finds all targets for all the given parameter {@link TargetFilterQuery}
|
||||
@@ -264,7 +263,7 @@ public interface TargetManagement {
|
||||
* @return a page of the found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Target> findAllTargetsByTargetFilterQueryAndNotInRolloutGroups(@NotNull Pageable pageRequest,
|
||||
Page<Target> findByTargetFilterQueryAndNotInRolloutGroups(@NotNull Pageable pageRequest,
|
||||
@NotEmpty Collection<Long> groups, @NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
@@ -278,8 +277,7 @@ public interface TargetManagement {
|
||||
* @return count of the found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countAllTargetsByTargetFilterQueryAndNotInRolloutGroups(@NotEmpty Collection<Long> groups,
|
||||
@NotNull String rsqlParam);
|
||||
long countByRsqlAndNotInRolloutGroups(@NotEmpty Collection<Long> groups, @NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* Finds all targets of the provided {@link RolloutGroup} that have no
|
||||
@@ -295,37 +293,36 @@ public interface TargetManagement {
|
||||
* if rollout group with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Target> findAllTargetsInRolloutGroupWithoutAction(@NotNull Pageable pageRequest, @NotNull Long group);
|
||||
Page<Target> findByInRolloutGroupWithoutAction(@NotNull Pageable pageRequest, @NotNull Long group);
|
||||
|
||||
/**
|
||||
* retrieves {@link Target}s by the assigned {@link DistributionSet} without
|
||||
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
|
||||
* possible.
|
||||
*
|
||||
*
|
||||
* @param distributionSetID
|
||||
* the ID of the {@link DistributionSet}
|
||||
* retrieves {@link Target}s by the assigned {@link DistributionSet}.
|
||||
*
|
||||
* @param pageReq
|
||||
* page parameter
|
||||
* @param distributionSetID
|
||||
* the ID of the {@link DistributionSet}
|
||||
*
|
||||
*
|
||||
* @return the found {@link Target}s
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if distribution set with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
||||
Page<Target> findTargetByAssignedDistributionSet(@NotNull Long distributionSetID, @NotNull Pageable pageReq);
|
||||
Page<Target> findByAssignedDistributionSet(@NotNull Pageable pageReq, @NotNull Long distributionSetID);
|
||||
|
||||
/**
|
||||
* Retrieves {@link Target}s by the assigned {@link DistributionSet} without
|
||||
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
|
||||
* Retrieves {@link Target}s by the assigned {@link DistributionSet}
|
||||
* possible including additional filtering based on the given {@code spec}.
|
||||
*
|
||||
*
|
||||
* @param pageReq
|
||||
* page parameter
|
||||
* @param distributionSetID
|
||||
* the ID of the {@link DistributionSet}
|
||||
* @param rsqlParam
|
||||
* the specification to filter the result set
|
||||
* @param pageReq
|
||||
* page parameter
|
||||
*
|
||||
* @return the found {@link Target}s, never {@code null}
|
||||
* @throws RSQLParameterUnsupportedFieldException
|
||||
* if a field in the RSQL string is used but not provided by the
|
||||
@@ -336,20 +333,18 @@ public interface TargetManagement {
|
||||
* if distribution set with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
||||
Page<Target> findTargetByAssignedDistributionSet(@NotNull Long distributionSetID, @NotNull String rsqlParam,
|
||||
@NotNull Pageable pageReq);
|
||||
Page<Target> findByAssignedDistributionSetAndRsql(@NotNull Pageable pageReq, @NotNull Long distributionSetID,
|
||||
@NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* Find {@link Target}s based a given IDs. The returned target will not
|
||||
* contain details (e.g {@link Target#getTags()} and
|
||||
* {@link Target#getActions()})
|
||||
* Find {@link Target}s based a given IDs.
|
||||
*
|
||||
* @param controllerIDs
|
||||
* to look for.
|
||||
* @return List of found{@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Target> findTargetsByControllerID(@NotEmpty Collection<String> controllerIDs);
|
||||
List<Target> getByControllerID(@NotEmpty Collection<String> controllerIDs);
|
||||
|
||||
/**
|
||||
* Find a {@link Target} based a given ID.
|
||||
@@ -359,7 +354,7 @@ public interface TargetManagement {
|
||||
* @return {@link Target}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Optional<Target> findTargetByControllerID(@NotEmpty String controllerId);
|
||||
Optional<Target> getByControllerID(@NotEmpty String controllerId);
|
||||
|
||||
/**
|
||||
* Filter {@link Target}s for all the given parameters. If all parameters
|
||||
@@ -367,25 +362,9 @@ public interface TargetManagement {
|
||||
*
|
||||
* @param pageable
|
||||
* page parameters
|
||||
* @param status
|
||||
* find targets having this {@link TargetUpdateStatus}s. Set to
|
||||
* <code>null</code> in case this is not required.
|
||||
* @param overdueState
|
||||
* find targets that are overdue (targets that did not respond
|
||||
* during the configured intervals: poll_itvl + overdue_itvl).
|
||||
* @param searchText
|
||||
* to find targets having the text anywhere in name or
|
||||
* description. Set <code>null</code> in case this is not
|
||||
* required.
|
||||
* @param installedOrAssignedDistributionSetId
|
||||
* to find targets having the {@link DistributionSet} as
|
||||
* installed or assigned. Set to <code>null</code> in case this
|
||||
* is not required.
|
||||
* @param tagNames
|
||||
* to find targets which are having any one in this tag names.
|
||||
* Set <code>null</code> in case this is not required.
|
||||
* @param selectTargetWithNoTag
|
||||
* flag to select targets with no tag assigned
|
||||
* @param filterParams
|
||||
* the filters to apply; only filters are enabled that have
|
||||
* non-null value; filters are AND-gated
|
||||
*
|
||||
* @return the found {@link Target}s
|
||||
*
|
||||
@@ -393,38 +372,35 @@ public interface TargetManagement {
|
||||
* if distribution set with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Target> findTargetByFilters(@NotNull Pageable pageable, Collection<TargetUpdateStatus> status,
|
||||
Boolean overdueState, String searchText, Long installedOrAssignedDistributionSetId,
|
||||
Boolean selectTargetWithNoTag, String... tagNames);
|
||||
Slice<Target> findByFilters(@NotNull Pageable pageable, @NotNull FilterParams filterParams);
|
||||
|
||||
/**
|
||||
* retrieves {@link Target}s by the installed {@link DistributionSet}without
|
||||
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
|
||||
* possible.
|
||||
*
|
||||
* @param distributionSetID
|
||||
* the ID of the {@link DistributionSet}
|
||||
* retrieves {@link Target}s by the installed {@link DistributionSet}.
|
||||
*
|
||||
* @param pageReq
|
||||
* page parameter
|
||||
* @param distributionSetID
|
||||
* the ID of the {@link DistributionSet}
|
||||
*
|
||||
* @return the found {@link Target}s
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if distribution set with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
||||
Page<Target> findTargetByInstalledDistributionSet(@NotNull Long distributionSetID, @NotNull Pageable pageReq);
|
||||
Page<Target> findByInstalledDistributionSet(@NotNull Pageable pageReq, @NotNull Long distributionSetID);
|
||||
|
||||
/**
|
||||
* retrieves {@link Target}s by the installed {@link DistributionSet}without
|
||||
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
|
||||
* possible including additional filtering based on the given {@code spec}.
|
||||
*
|
||||
* retrieves {@link Target}s by the installed {@link DistributionSet}
|
||||
* including additional filtering based on the given {@code spec}.
|
||||
*
|
||||
* @param pageReq
|
||||
* page parameter
|
||||
* @param distributionSetId
|
||||
* the ID of the {@link DistributionSet}
|
||||
* @param rsqlParam
|
||||
* the specification to filter the result
|
||||
* @param pageReq
|
||||
* page parameter
|
||||
*
|
||||
* @return the found {@link Target}s, never {@code null}
|
||||
*
|
||||
* @throws RSQLParameterUnsupportedFieldException
|
||||
@@ -437,13 +413,12 @@ public interface TargetManagement {
|
||||
* if distribution set with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
||||
Page<Target> findTargetByInstalledDistributionSet(@NotNull Long distributionSetId, @NotNull String rsqlParam,
|
||||
@NotNull Pageable pageReq);
|
||||
Page<Target> findByInstalledDistributionSetAndRsql(@NotNull Pageable pageReq, @NotNull Long distributionSetId,
|
||||
@NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* Retrieves the {@link Target} which have a certain
|
||||
* {@link TargetUpdateStatus} without details, i.e. NO
|
||||
* {@link Target#getTags()} and {@link Target#getActions()} possible.
|
||||
* {@link TargetUpdateStatus}.
|
||||
*
|
||||
* @param pageable
|
||||
* page parameter
|
||||
@@ -452,29 +427,25 @@ public interface TargetManagement {
|
||||
* @return the found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Target> findTargetByUpdateStatus(@NotNull Pageable pageable, @NotNull TargetUpdateStatus status);
|
||||
Page<Target> findByUpdateStatus(@NotNull Pageable pageable, @NotNull TargetUpdateStatus status);
|
||||
|
||||
/**
|
||||
* Retrieves all targets without details, i.e. NO {@link Target#getTags()}
|
||||
* and {@link Target#getActions()} possible
|
||||
* Retrieves all targets.
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Target> findTargetsAll(@NotNull Pageable pageable);
|
||||
Slice<Target> findAll(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all targets without details, i.e. NO {@link Target#getTags()}
|
||||
* and {@link Target#getActions()} possible based on
|
||||
* {@link TargetFilterQuery#getQuery()}
|
||||
*
|
||||
* @param rsqlParam
|
||||
* in RSQL notation
|
||||
* Retrieves all targets.
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @param rsqlParam
|
||||
* in RSQL notation
|
||||
*
|
||||
* @return the found {@link Target}s, never {@code null}
|
||||
*
|
||||
@@ -486,17 +457,15 @@ public interface TargetManagement {
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Target> findTargetsAll(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
Page<Target> findByRsql(@NotNull Pageable pageable, @NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* Retrieves all targets without details, i.e. NO {@link Target#getTags()}
|
||||
* and {@link Target#getActions()} possible based on
|
||||
* {@link TargetFilterQuery#getQuery()}
|
||||
*
|
||||
* @param targetFilterQueryId
|
||||
* {@link TargetFilterQuery#getId()}
|
||||
* Retrieves all target based on {@link TargetFilterQuery}.
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @param targetFilterQueryId
|
||||
* {@link TargetFilterQuery#getId()}
|
||||
*
|
||||
* @return the found {@link Target}s, never {@code null}
|
||||
*
|
||||
@@ -509,7 +478,7 @@ public interface TargetManagement {
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Target> findTargetsByTargetFilterQuery(@NotNull Long targetFilterQueryId, @NotNull Pageable pageable);
|
||||
Slice<Target> findByTargetFilterQuery(@NotNull Pageable pageable, @NotNull Long targetFilterQueryId);
|
||||
|
||||
/**
|
||||
* method retrieves all {@link Target}s from the repo in the following
|
||||
@@ -538,8 +507,8 @@ public interface TargetManagement {
|
||||
* if distribution set with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Target> findTargetsAllOrderByLinkedDistributionSet(@NotNull Pageable pageable,
|
||||
@NotNull Long orderByDistributionId, FilterParams filterParams);
|
||||
Slice<Target> findByFilterOrderByLinkedDistributionSet(@NotNull Pageable pageable,
|
||||
@NotNull Long orderByDistributionId, @NotNull FilterParams filterParams);
|
||||
|
||||
/**
|
||||
* Find targets by tag name.
|
||||
@@ -554,7 +523,7 @@ public interface TargetManagement {
|
||||
* if target tag with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Target> findTargetsByTag(@NotNull Pageable pageable, @NotNull Long tagId);
|
||||
Page<Target> findByTag(@NotNull Pageable pageable, @NotNull Long tagId);
|
||||
|
||||
/**
|
||||
* Find targets by tag name.
|
||||
@@ -577,7 +546,7 @@ public interface TargetManagement {
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Target> findTargetsByTag(@NotNull Pageable pageable, @NotNull String rsqlParam, @NotNull Long tagId);
|
||||
Page<Target> findByRsqlAndTag(@NotNull Pageable pageable, @NotNull String rsqlParam, @NotNull Long tagId);
|
||||
|
||||
/**
|
||||
* Toggles {@link TargetTag} assignment to given {@link Target}s by means
|
||||
@@ -626,32 +595,28 @@ public interface TargetManagement {
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link TargetUpdate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
Target updateTarget(@NotNull TargetUpdate update);
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
Target update(@NotNull TargetUpdate update);
|
||||
|
||||
/**
|
||||
* Find a {@link Target} based a given ID. The returned target will not
|
||||
* contain details (e.g {@link Target#getTags()} and
|
||||
* {@link Target#getActions()})
|
||||
* Find a {@link Target} based a given ID.
|
||||
*
|
||||
* @param id
|
||||
* to look for
|
||||
* @return {@link Target}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Optional<Target> findTargetById(Long id);
|
||||
Optional<Target> get(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* Retrieves all targets without details, i.e. NO {@link Target#getTags()}
|
||||
* and {@link Target#getActions()} possible
|
||||
* Retrieves all targets.
|
||||
*
|
||||
* @param ids
|
||||
* the ids to for
|
||||
* @return the found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Target> findTargetsById(@NotNull Collection<Long> ids);
|
||||
List<Target> get(@NotNull Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* Get controller attributes of given {@link Target}.
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.TagUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Management service for {@link TargetTag}s.
|
||||
*
|
||||
*/
|
||||
public interface TargetTagManagement {
|
||||
|
||||
/**
|
||||
* count {@link TargetTag}s.
|
||||
*
|
||||
* @return size of {@link TargetTag}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
long count();
|
||||
|
||||
/**
|
||||
* Creates a new {@link TargetTag}.
|
||||
*
|
||||
* @param create
|
||||
* to be created
|
||||
*
|
||||
* @return the new created {@link TargetTag}
|
||||
*
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if given object already exists
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link TagCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
TargetTag create(@NotNull TagCreate create);
|
||||
|
||||
/**
|
||||
* created multiple {@link TargetTag}s.
|
||||
*
|
||||
* @param creates
|
||||
* to be created
|
||||
* @return the new created {@link TargetTag}s
|
||||
*
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if given object has already an ID.
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link TagCreate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
List<TargetTag> create(@NotNull Collection<TagCreate> creates);
|
||||
|
||||
/**
|
||||
* Deletes {@link TargetTag} with given name.
|
||||
*
|
||||
* @param targetTagName
|
||||
* tag name of the {@link TargetTag} to be deleted
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if tag with given name does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||
void delete(@NotEmpty String targetTagName);
|
||||
|
||||
/**
|
||||
* returns all {@link TargetTag}s.
|
||||
*
|
||||
* @param pageable
|
||||
* page parameter
|
||||
*
|
||||
* @return all {@link TargetTag}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetTag> findAll(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Returns all {@link TargetTag}s assigned to {@link Target} with given ID.
|
||||
*
|
||||
* @param pageable
|
||||
* page parameter
|
||||
* @param controllerId
|
||||
* of the assigned target
|
||||
*
|
||||
* @return {@link TargetTag}s assigned to {@link Target} with given ID
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if target with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetTag> findByTarget(@NotNull Pageable pageable, @NotEmpty String controllerId);
|
||||
|
||||
/**
|
||||
* Retrieves all target tags based on the given specification.
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
*
|
||||
* @return the found {@link Target}s, never {@code null}
|
||||
*
|
||||
* @throws RSQLParameterUnsupportedFieldException
|
||||
* if a field in the RSQL string is used but not provided by the
|
||||
* given {@code fieldNameProvider}
|
||||
* @throws RSQLParameterSyntaxException
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetTag> findByRsql(@NotNull Pageable pageable, @NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* Find {@link TargetTag} based on given Name.
|
||||
*
|
||||
* @param name
|
||||
* to look for.
|
||||
* @return {@link TargetTag}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Optional<TargetTag> getByName(@NotEmpty String name);
|
||||
|
||||
/**
|
||||
* Finds {@link TargetTag} by given id.
|
||||
*
|
||||
* @param id
|
||||
* to search for
|
||||
* @return the found {@link TargetTag}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Optional<TargetTag> get(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* updates the {@link TargetTag}.
|
||||
*
|
||||
* @param update
|
||||
* the {@link TargetTag} with updated values
|
||||
* @return the updated {@link TargetTag}
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* in case the {@link TargetTag} does not exists and cannot be
|
||||
* updated
|
||||
* @throws ConstraintViolationException
|
||||
* if fields are not filled as specified. Check
|
||||
* {@link TagUpdate} for field constraints.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetTag update(@NotNull TagUpdate update);
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.AbstractServerRtException;
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
|
||||
/**
|
||||
* Thrown if DS creation failed.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class DistributionSetCreationFailedMissingMandatoryModuleException extends AbstractServerRtException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new FileUploadFailedException with
|
||||
* {@link SpServerError#SP_DS_CREATION_FAILED_MISSING_MODULE} error.
|
||||
*/
|
||||
public DistributionSetCreationFailedMissingMandatoryModuleException() {
|
||||
super(SpServerError.SP_DS_CREATION_FAILED_MISSING_MODULE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
* for the exception
|
||||
*/
|
||||
public DistributionSetCreationFailedMissingMandatoryModuleException(final Throwable cause) {
|
||||
super(SpServerError.SP_DS_CREATION_FAILED_MISSING_MODULE, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
*/
|
||||
public DistributionSetCreationFailedMissingMandatoryModuleException(final String message) {
|
||||
super(message, SpServerError.SP_DS_CREATION_FAILED_MISSING_MODULE);
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class DistributionSetAssignmentResult extends AssignmentResult<Target> {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return targetManagement.findTargetsByControllerID(assignedTargets);
|
||||
return targetManagement.getByControllerID(assignedTargets);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public abstract class AbstractRolloutManagement implements RolloutManagement {
|
||||
final List<Long> groupTargetCounts = new ArrayList<>(groups.size());
|
||||
final Map<String, Long> targetFilterCounts = groups.stream()
|
||||
.map(group -> RolloutHelper.getGroupTargetFilter(baseFilter, group)).distinct()
|
||||
.collect(Collectors.toMap(Function.identity(), targetManagement::countTargetByTargetFilterQuery));
|
||||
.collect(Collectors.toMap(Function.identity(), targetManagement::countByRsql));
|
||||
|
||||
long unusedTargetsCount = 0;
|
||||
|
||||
@@ -136,7 +136,7 @@ public abstract class AbstractRolloutManagement implements RolloutManagement {
|
||||
if (targetFilterCounts.containsKey(overlappingTargetsFilter)) {
|
||||
return targetFilterCounts.get(overlappingTargetsFilter);
|
||||
} else {
|
||||
final long overlappingTargets = targetManagement.countTargetByTargetFilterQuery(overlappingTargetsFilter);
|
||||
final long overlappingTargets = targetManagement.countByRsql(overlappingTargetsFilter);
|
||||
targetFilterCounts.put(overlappingTargetsFilter, overlappingTargets);
|
||||
return overlappingTargets;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public abstract class AbstractRolloutManagement implements RolloutManagement {
|
||||
protected long calculateRemainingTargets(final List<RolloutGroup> groups, final String targetFilter,
|
||||
final Long createdAt) {
|
||||
final String baseFilter = RolloutHelper.getTargetFilterQuery(targetFilter, createdAt);
|
||||
final long totalTargets = targetManagement.countTargetByTargetFilterQuery(baseFilter);
|
||||
final long totalTargets = targetManagement.countByRsql(baseFilter);
|
||||
if (totalTargets == 0) {
|
||||
throw new ConstraintDeclarationException("Rollout target filter does not match any targets");
|
||||
}
|
||||
@@ -161,7 +161,7 @@ public abstract class AbstractRolloutManagement implements RolloutManagement {
|
||||
final String targetFilter, final Long createdAt) {
|
||||
|
||||
final String baseFilter = RolloutHelper.getTargetFilterQuery(targetFilter, createdAt);
|
||||
final long totalTargets = targetManagement.countTargetByTargetFilterQuery(baseFilter);
|
||||
final long totalTargets = targetManagement.countByRsql(baseFilter);
|
||||
if (totalTargets == 0) {
|
||||
throw new ConstraintDeclarationException("Rollout target filter does not match any targets");
|
||||
}
|
||||
|
||||
@@ -47,22 +47,9 @@ public interface DistributionSetRepository
|
||||
* to be found
|
||||
* @return list of found {@link DistributionSet}s
|
||||
*/
|
||||
@Query(value = "Select Distinct ds from JpaDistributionSet ds join ds.tags dst where dst.id = :tag")
|
||||
@Query(value = "Select Distinct ds from JpaDistributionSet ds join ds.tags dst where dst.id = :tag and ds.deleted = 0")
|
||||
Page<JpaDistributionSet> findByTag(Pageable pageable, @Param("tag") final Long tagId);
|
||||
|
||||
/**
|
||||
* Finds {@link DistributionSet}s by assigned {@link Tag}.
|
||||
*
|
||||
* @param pageable
|
||||
* paging and sorting information
|
||||
*
|
||||
* @param tagId
|
||||
* to be found
|
||||
* @return page of found {@link DistributionSet}s
|
||||
*/
|
||||
@Query(value = "Select Distinct ds from JpaDistributionSet ds join ds.tags dst where dst.id = :tagId")
|
||||
Page<JpaDistributionSet> findByTagId(Pageable pageable, @Param("tagId") final Long tagId);
|
||||
|
||||
/**
|
||||
* deletes the {@link DistributionSet}s with the given IDs.
|
||||
*
|
||||
@@ -175,4 +162,5 @@ public interface DistributionSetRepository
|
||||
@Transactional
|
||||
@Query("DELETE FROM JpaDistributionSet t WHERE t.tenant = :tenant")
|
||||
void deleteByTenant(@Param("tenant") String tenant);
|
||||
|
||||
}
|
||||
|
||||
@@ -82,4 +82,9 @@ public interface DistributionSetTagRepository
|
||||
@Transactional
|
||||
@Query("DELETE FROM JpaDistributionSetTag t WHERE t.tenant = :tenant")
|
||||
void deleteByTenant(@Param("tenant") String tenant);
|
||||
|
||||
@Override
|
||||
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477
|
||||
@Query("SELECT d FROM JpaDistributionSetTag d WHERE d.id IN ?1")
|
||||
List<JpaDistributionSetTag> findAll(Iterable<Long> ids);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
|
||||
@@ -48,7 +50,7 @@ public interface DistributionSetTypeRepository
|
||||
* count or all undeleted.
|
||||
* @return number of {@link DistributionSetType}s in the repository.
|
||||
*/
|
||||
Long countByDeleted(boolean isDeleted);
|
||||
long countByDeleted(boolean isDeleted);
|
||||
|
||||
/**
|
||||
* Counts all distribution set type where a specific software module type is
|
||||
@@ -60,7 +62,7 @@ public interface DistributionSetTypeRepository
|
||||
* @return the number of {@link DistributionSetType}s in the repository
|
||||
* assigned to the given software module type
|
||||
*/
|
||||
Long countByElementsSmType(JpaSoftwareModuleType softwareModuleType);
|
||||
long countByElementsSmType(JpaSoftwareModuleType softwareModuleType);
|
||||
|
||||
/**
|
||||
* Deletes all {@link TenantAwareBaseEntity} of a given tenant. For safety
|
||||
@@ -75,4 +77,9 @@ public interface DistributionSetTypeRepository
|
||||
@Transactional
|
||||
@Query("DELETE FROM JpaDistributionSetType t WHERE t.tenant = :tenant")
|
||||
void deleteByTenant(@Param("tenant") String tenant);
|
||||
|
||||
@Override
|
||||
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477
|
||||
@Query("SELECT d FROM JpaDistributionSetType d WHERE d.id IN ?1")
|
||||
List<JpaDistributionSetType> findAll(Iterable<Long> ids);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Artifact createArtifact(final InputStream stream, final Long moduleId, final String filename,
|
||||
public Artifact create(final InputStream stream, final Long moduleId, final String filename,
|
||||
final String providedMd5Sum, final String providedSha1Sum, final boolean overrideExisting,
|
||||
final String contentType) {
|
||||
AbstractDbArtifact result = null;
|
||||
@@ -137,8 +137,8 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteArtifact(final Long id) {
|
||||
final JpaArtifact existing = (JpaArtifact) findArtifact(id)
|
||||
public void delete(final Long id) {
|
||||
final JpaArtifact existing = (JpaArtifact) get(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Artifact.class, id));
|
||||
|
||||
clearArtifactBinary(existing.getSha1Hash(), existing.getSoftwareModule().getId());
|
||||
@@ -149,29 +149,29 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Artifact> findArtifact(final Long id) {
|
||||
public Optional<Artifact> get(final Long id) {
|
||||
return Optional.ofNullable(localArtifactRepository.findOne(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Artifact> findByFilenameAndSoftwareModule(final String filename, final Long softwareModuleId) {
|
||||
public Optional<Artifact> getByFilenameAndSoftwareModule(final String filename, final Long softwareModuleId) {
|
||||
throwExceptionIfSoftwareModuleDoesNotExist(softwareModuleId);
|
||||
|
||||
return localArtifactRepository.findFirstByFilenameAndSoftwareModuleId(filename, softwareModuleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Artifact> findFirstArtifactBySHA1(final String sha1Hash) {
|
||||
public Optional<Artifact> findFirstBySHA1(final String sha1Hash) {
|
||||
return localArtifactRepository.findFirstBySha1Hash(sha1Hash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Artifact> findArtifactByFilename(final String filename) {
|
||||
public Optional<Artifact> getByFilename(final String filename) {
|
||||
return localArtifactRepository.findFirstByFilename(filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Artifact> findArtifactBySoftwareModule(final Pageable pageReq, final Long swId) {
|
||||
public Page<Artifact> findBySoftwareModule(final Pageable pageReq, final Long swId) {
|
||||
throwExceptionIfSoftwareModuleDoesNotExist(swId);
|
||||
|
||||
return localArtifactRepository.findBySoftwareModuleId(pageReq, swId);
|
||||
@@ -206,13 +206,13 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Artifact createArtifact(final InputStream inputStream, final Long moduleId, final String filename,
|
||||
public Artifact create(final InputStream inputStream, final Long moduleId, final String filename,
|
||||
final boolean overrideExisting) {
|
||||
return createArtifact(inputStream, moduleId, filename, null, null, overrideExisting, null);
|
||||
return create(inputStream, moduleId, filename, null, null, overrideExisting, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countArtifactsAll() {
|
||||
public long count() {
|
||||
return localArtifactRepository.count();
|
||||
}
|
||||
|
||||
|
||||
@@ -483,12 +483,12 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Target> findByControllerId(final String controllerId) {
|
||||
public Optional<Target> getByControllerId(final String controllerId) {
|
||||
return targetRepository.findByControllerId(controllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Target> findByTargetId(final Long targetId) {
|
||||
public Optional<Target> get(final Long targetId) {
|
||||
return Optional.ofNullable(targetRepository.findOne(targetId));
|
||||
}
|
||||
|
||||
@@ -522,4 +522,9 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
|
||||
return messages.getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SoftwareModule> getSoftwareModule(final Long id) {
|
||||
return Optional.ofNullable(softwareModuleRepository.findOne(id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,14 +496,14 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countActionsByTarget(final String controllerId) {
|
||||
public long countActionsByTarget(final String controllerId) {
|
||||
throwExceptionIfTargetDoesNotExist(controllerId);
|
||||
|
||||
return actionRepository.countByTargetControllerId(controllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countActionsByTarget(final String rsqlParam, final String controllerId) {
|
||||
public long countActionsByTarget(final String rsqlParam, final String controllerId) {
|
||||
throwExceptionIfTargetDoesNotExist(controllerId);
|
||||
|
||||
return actionRepository.count(createSpecificationFor(controllerId, rsqlParam));
|
||||
@@ -578,12 +578,12 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countActionStatusAll() {
|
||||
public long countActionStatusAll() {
|
||||
return actionStatusRepository.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countActionsAll() {
|
||||
public long countActionsAll() {
|
||||
return actionRepository.count();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ import javax.persistence.EntityManager;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetFields;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetMetadataFields;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetUpdate;
|
||||
import org.eclipse.hawkbit.repository.builder.GenericDistributionSetUpdate;
|
||||
@@ -63,6 +63,7 @@ import org.springframework.dao.ConcurrencyFailureException;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.retry.annotation.Backoff;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
@@ -88,7 +89,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
private DistributionSetRepository distributionSetRepository;
|
||||
|
||||
@Autowired
|
||||
private TagManagement tagManagement;
|
||||
private DistributionSetTagManagement distributionSetTagManagement;
|
||||
|
||||
@Autowired
|
||||
private SystemManagement systemManagement;
|
||||
@@ -105,6 +106,9 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Autowired
|
||||
private ActionRepository actionRepository;
|
||||
|
||||
@Autowired
|
||||
private NoCountPagingRepository criteriaNoCountDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEventPublisher eventPublisher;
|
||||
|
||||
@@ -127,13 +131,17 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
private AfterTransactionCommitExecutor afterCommit;
|
||||
|
||||
@Override
|
||||
public Optional<DistributionSet> findDistributionSetByIdWithDetails(final Long distid) {
|
||||
public Optional<DistributionSet> getWithDetails(final Long distid) {
|
||||
return Optional.ofNullable(distributionSetRepository.findOne(DistributionSetSpecification.byId(distid)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DistributionSet> findDistributionSetById(final Long distid) {
|
||||
return Optional.ofNullable(distributionSetRepository.findOne(distid));
|
||||
public long countByTypeId(final Long typeId) {
|
||||
if (!distributionSetTypeManagement.exists(typeId)) {
|
||||
throw new EntityNotFoundException(DistributionSetType.class, typeId);
|
||||
}
|
||||
|
||||
return distributionSetRepository.countByTypeId(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,7 +156,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
sets.stream().map(DistributionSet::getId).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
final DistributionSetTag myTag = tagManagement.findDistributionSetTag(tagName)
|
||||
final DistributionSetTag myTag = distributionSetTagManagement.getByName(tagName)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, tagName));
|
||||
|
||||
DistributionSetTagAssignmentResult result;
|
||||
@@ -189,7 +197,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSet updateDistributionSet(final DistributionSetUpdate u) {
|
||||
public DistributionSet update(final DistributionSetUpdate u) {
|
||||
final GenericDistributionSetUpdate update = (GenericDistributionSetUpdate) u;
|
||||
|
||||
final JpaDistributionSet set = findDistributionSetAndThrowExceptionIfNotFound(update.getId());
|
||||
@@ -217,13 +225,13 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
|
||||
private JpaDistributionSetType findDistributionSetTypeAndThrowExceptionIfNotFound(final String key) {
|
||||
return (JpaDistributionSetType) distributionSetTypeManagement.findDistributionSetTypeByKey(key)
|
||||
return (JpaDistributionSetType) distributionSetTypeManagement.getByKey(key)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, key));
|
||||
|
||||
}
|
||||
|
||||
private JpaDistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) {
|
||||
return (JpaDistributionSet) findDistributionSetById(setId)
|
||||
return (JpaDistributionSet) get(setId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, setId));
|
||||
}
|
||||
|
||||
@@ -236,8 +244,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteDistributionSet(final Collection<Long> distributionSetIDs) {
|
||||
final List<DistributionSet> setsFound = findDistributionSetsById(distributionSetIDs);
|
||||
public void delete(final Collection<Long> distributionSetIDs) {
|
||||
final List<DistributionSet> setsFound = get(distributionSetIDs);
|
||||
|
||||
if (setsFound.size() < distributionSetIDs.size()) {
|
||||
throw new EntityNotFoundException(DistributionSet.class, distributionSetIDs,
|
||||
@@ -275,7 +283,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSet createDistributionSet(final DistributionSetCreate c) {
|
||||
public DistributionSet create(final DistributionSetCreate c) {
|
||||
final JpaDistributionSetCreate create = (JpaDistributionSetCreate) c;
|
||||
if (create.getType() == null) {
|
||||
create.type(systemManagement.getTenantMetadata().getDefaultDsType().getKey());
|
||||
@@ -288,8 +296,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<DistributionSet> createDistributionSets(final Collection<DistributionSetCreate> creates) {
|
||||
return creates.stream().map(this::createDistributionSet).collect(Collectors.toList());
|
||||
public List<DistributionSet> create(final Collection<DistributionSetCreate> creates) {
|
||||
return creates.stream().map(this::create).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -329,7 +337,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSet> findDistributionSetsByFilters(final Pageable pageable,
|
||||
public Page<DistributionSet> findByDistributionSetFilter(final Pageable pageable,
|
||||
final DistributionSetFilter distributionSetFilter) {
|
||||
final List<Specification<JpaDistributionSet>> specList = buildDistributionSetSpecifications(
|
||||
distributionSetFilter);
|
||||
@@ -341,6 +349,11 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
|
||||
private static Slice<DistributionSet> convertDsPage(final Slice<JpaDistributionSet> findAll,
|
||||
final Pageable pageable) {
|
||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param distributionSetFilter
|
||||
@@ -359,52 +372,21 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSet> findDistributionSetsByDeletedAndOrCompleted(final Pageable pageReq,
|
||||
final Boolean deleted, final Boolean complete) {
|
||||
final List<Specification<JpaDistributionSet>> specList = new ArrayList<>(2);
|
||||
|
||||
if (deleted != null) {
|
||||
final Specification<JpaDistributionSet> spec = DistributionSetSpecification.isDeleted(deleted);
|
||||
specList.add(spec);
|
||||
}
|
||||
public Page<DistributionSet> findByCompleted(final Pageable pageReq, final Boolean complete) {
|
||||
|
||||
List<Specification<JpaDistributionSet>> specList;
|
||||
if (complete != null) {
|
||||
final Specification<JpaDistributionSet> spec = DistributionSetSpecification.isCompleted(complete);
|
||||
specList.add(spec);
|
||||
specList = Arrays.asList(DistributionSetSpecification.isDeleted(false),
|
||||
DistributionSetSpecification.isCompleted(complete));
|
||||
} else {
|
||||
specList = Arrays.asList(DistributionSetSpecification.isDeleted(false));
|
||||
}
|
||||
|
||||
return convertDsPage(findByCriteriaAPI(pageReq, specList), pageReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSet> findDistributionSetsAll(final String rsqlParam, final Pageable pageReq,
|
||||
final Boolean deleted) {
|
||||
|
||||
final Specification<JpaDistributionSet> spec = RSQLUtility.parse(rsqlParam, DistributionSetFields.class,
|
||||
virtualPropertyReplacer);
|
||||
|
||||
final List<Specification<JpaDistributionSet>> specList = new ArrayList<>(2);
|
||||
if (deleted != null) {
|
||||
specList.add(DistributionSetSpecification.isDeleted(deleted));
|
||||
}
|
||||
specList.add(spec);
|
||||
|
||||
return convertDsPage(findByCriteriaAPI(pageReq, specList), pageReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSet> findDistributionSetsAll(final Pageable pageReq, final Boolean deleted) {
|
||||
|
||||
final List<Specification<JpaDistributionSet>> specList = new ArrayList<>(1);
|
||||
if (deleted != null) {
|
||||
specList.add(DistributionSetSpecification.isDeleted(deleted));
|
||||
}
|
||||
|
||||
return convertDsPage(findByCriteriaAPI(pageReq, specList), pageReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSet> findDistributionSetsAllOrderedByLinkTarget(final Pageable pageable,
|
||||
public Page<DistributionSet> findByFilterAndAssignedInstalledDsOrderedByLinkTarget(final Pageable pageable,
|
||||
final DistributionSetFilterBuilder distributionSetFilterBuilder, final String assignedOrInstalled) {
|
||||
|
||||
final DistributionSetFilter filterWithInstalledTargets = distributionSetFilterBuilder
|
||||
@@ -421,7 +403,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
.setAssignedTargetId(null).build();
|
||||
// first fine the distribution sets filtered by the given filter
|
||||
// parameters
|
||||
final Page<DistributionSet> findDistributionSetsByFilters = findDistributionSetsByFilters(pageable,
|
||||
final Page<DistributionSet> findDistributionSetsByFilters = findByDistributionSetFilter(pageable,
|
||||
dsFilterWithNoTargetLinked);
|
||||
|
||||
final List<DistributionSet> resultSet = new ArrayList<>(findDistributionSetsByFilters.getContent());
|
||||
@@ -446,8 +428,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DistributionSet> findDistributionSetByNameAndVersion(final String distributionName,
|
||||
final String version) {
|
||||
public Optional<DistributionSet> getByNameAndVersion(final String distributionName, final String version) {
|
||||
final Specification<JpaDistributionSet> spec = DistributionSetSpecification
|
||||
.equalsNameAndVersionIgnoreCase(distributionName, version);
|
||||
return Optional.ofNullable(distributionSetRepository.findOne(spec));
|
||||
@@ -455,7 +436,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countDistributionSetsAll() {
|
||||
public long count() {
|
||||
final Specification<JpaDistributionSet> spec = DistributionSetSpecification.isDeleted(Boolean.FALSE);
|
||||
|
||||
return distributionSetRepository.count(SpecificationsBuilder.combineWithAnd(Arrays.asList(spec)));
|
||||
@@ -465,7 +446,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<DistributionSetMetadata> createDistributionSetMetadata(final Long dsId, final Collection<MetaData> md) {
|
||||
public List<DistributionSetMetadata> createMetaData(final Long dsId, final Collection<MetaData> md) {
|
||||
|
||||
md.forEach(meta -> checkAndThrowAlreadyIfDistributionSetMetadataExists(
|
||||
new DsMetadataCompositeKey(dsId, meta.getKey())));
|
||||
@@ -482,10 +463,10 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSetMetadata updateDistributionSetMetadata(final Long dsId, final MetaData md) {
|
||||
public DistributionSetMetadata updateMetaData(final Long dsId, final MetaData md) {
|
||||
|
||||
// check if exists otherwise throw entity not found exception
|
||||
final JpaDistributionSetMetadata toUpdate = (JpaDistributionSetMetadata) findDistributionSetMetadata(dsId,
|
||||
final JpaDistributionSetMetadata toUpdate = (JpaDistributionSetMetadata) getMetaDataByDistributionSetId(dsId,
|
||||
md.getKey()).orElseThrow(
|
||||
() -> new EntityNotFoundException(DistributionSetMetadata.class, dsId, md.getKey()));
|
||||
toUpdate.setValue(md.getValue());
|
||||
@@ -499,8 +480,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteDistributionSetMetadata(final Long distributionSetId, final String key) {
|
||||
final JpaDistributionSetMetadata metadata = (JpaDistributionSetMetadata) findDistributionSetMetadata(
|
||||
public void deleteMetaData(final Long distributionSetId, final String key) {
|
||||
final JpaDistributionSetMetadata metadata = (JpaDistributionSetMetadata) getMetaDataByDistributionSetId(
|
||||
distributionSetId, key).orElseThrow(
|
||||
() -> new EntityNotFoundException(DistributionSetMetadata.class, distributionSetId, key));
|
||||
|
||||
@@ -535,13 +516,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
* of the DS to touch
|
||||
*/
|
||||
private JpaDistributionSet touch(final Long distId) {
|
||||
return touch(findDistributionSetById(distId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, distId)));
|
||||
return touch(get(distId).orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, distId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(final Long distributionSetId,
|
||||
final Pageable pageable) {
|
||||
public Page<DistributionSetMetadata> findMetaDataByDistributionSetId(final Pageable pageable,
|
||||
final Long distributionSetId) {
|
||||
throwExceptionIfDistributionSetDoesNotExist(distributionSetId);
|
||||
|
||||
return convertMdPage(distributionSetMetadataRepository
|
||||
@@ -552,8 +532,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(final Long distributionSetId,
|
||||
final String rsqlParam, final Pageable pageable) {
|
||||
public Page<DistributionSetMetadata> findMetaDataByDistributionSetIdAndRsql(final Pageable pageable,
|
||||
final Long distributionSetId, final String rsqlParam) {
|
||||
|
||||
throwExceptionIfDistributionSetDoesNotExist(distributionSetId);
|
||||
|
||||
@@ -575,14 +555,14 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DistributionSetMetadata> findDistributionSetMetadata(final Long setId, final String key) {
|
||||
public Optional<DistributionSetMetadata> getMetaDataByDistributionSetId(final Long setId, final String key) {
|
||||
throwExceptionIfDistributionSetDoesNotExist(setId);
|
||||
|
||||
return Optional.ofNullable(distributionSetMetadataRepository.findOne(new DsMetadataCompositeKey(setId, key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DistributionSet> findDistributionSetByAction(final Long actionId) {
|
||||
public Optional<DistributionSet> getByAction(final Long actionId) {
|
||||
if (!actionRepository.exists(actionId)) {
|
||||
throw new EntityNotFoundException(Action.class, actionId);
|
||||
}
|
||||
@@ -591,7 +571,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDistributionSetInUse(final Long setId) {
|
||||
public boolean isInUse(final Long setId) {
|
||||
throwExceptionIfDistributionSetDoesNotExist(setId);
|
||||
|
||||
return actionRepository.countByDistributionSetId(setId) > 0;
|
||||
@@ -693,7 +673,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
allDs.stream().map(DistributionSet::getId).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
final DistributionSetTag distributionSetTag = tagManagement.findDistributionSetTagById(dsTagId)
|
||||
final DistributionSetTag distributionSetTag = distributionSetTagManagement.get(dsTagId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, dsTagId));
|
||||
|
||||
allDs.forEach(ds -> ds.addTag(distributionSetTag));
|
||||
@@ -711,10 +691,10 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSet unAssignTag(final Long dsId, final Long dsTagId) {
|
||||
final JpaDistributionSet set = (JpaDistributionSet) findDistributionSetByIdWithDetails(dsId)
|
||||
final JpaDistributionSet set = (JpaDistributionSet) getWithDetails(dsId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, dsId));
|
||||
|
||||
final DistributionSetTag distributionSetTag = tagManagement.findDistributionSetTagById(dsTagId)
|
||||
final DistributionSetTag distributionSetTag = distributionSetTagManagement.get(dsTagId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, dsTagId));
|
||||
|
||||
set.removeTag(distributionSetTag);
|
||||
@@ -730,10 +710,10 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteDistributionSet(final Long setId) {
|
||||
public void delete(final Long setId) {
|
||||
throwExceptionIfDistributionSetDoesNotExist(setId);
|
||||
|
||||
deleteDistributionSet(Arrays.asList(setId));
|
||||
delete(Arrays.asList(setId));
|
||||
}
|
||||
|
||||
private void throwExceptionIfDistributionSetDoesNotExist(final Long setId) {
|
||||
@@ -743,12 +723,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DistributionSet> findDistributionSetsById(final Collection<Long> ids) {
|
||||
public List<DistributionSet> get(final Collection<Long> ids) {
|
||||
return Collections.unmodifiableList(distributionSetRepository.findAll(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSet> findDistributionSetsByTag(final Pageable pageable, final Long tagId) {
|
||||
public Page<DistributionSet> findByTag(final Pageable pageable, final Long tagId) {
|
||||
throwEntityNotFoundExceptionIfDsTagDoesNotExist(tagId);
|
||||
|
||||
return convertDsPage(distributionSetRepository.findByTag(pageable, tagId), pageable);
|
||||
@@ -762,17 +742,40 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSet> findDistributionSetsByTag(final Pageable pageable, final String rsqlParam,
|
||||
final Long tagId) {
|
||||
public Page<DistributionSet> findByRsqlAndTag(final Pageable pageable, final String rsqlParam, final Long tagId) {
|
||||
throwEntityNotFoundExceptionIfDsTagDoesNotExist(tagId);
|
||||
|
||||
final Specification<JpaDistributionSet> spec = RSQLUtility.parse(rsqlParam, DistributionSetFields.class,
|
||||
virtualPropertyReplacer);
|
||||
|
||||
return convertDsPage(distributionSetRepository.findAll((Specification<JpaDistributionSet>) (root, query,
|
||||
cb) -> cb.and(DistributionSetSpecification.hasTag(tagId).toPredicate(root, query, cb),
|
||||
spec.toPredicate(root, query, cb)),
|
||||
pageable), pageable);
|
||||
return convertDsPage(findByCriteriaAPI(pageable, Arrays.asList(spec, DistributionSetSpecification.hasTag(tagId),
|
||||
DistributionSetSpecification.isDeleted(false))), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<DistributionSet> findAll(final Pageable pageable) {
|
||||
return convertDsPage(criteriaNoCountDao.findAll(DistributionSetSpecification.isDeleted(false), pageable,
|
||||
JpaDistributionSet.class), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSet> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||
final Specification<JpaDistributionSet> spec = RSQLUtility.parse(rsqlParam, DistributionSetFields.class,
|
||||
virtualPropertyReplacer);
|
||||
|
||||
return convertDsPage(
|
||||
findByCriteriaAPI(pageable, Arrays.asList(spec, DistributionSetSpecification.isDeleted(false))),
|
||||
pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DistributionSet> get(final Long id) {
|
||||
return Optional.ofNullable(distributionSetRepository.findOne(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(final Long id) {
|
||||
return distributionSetRepository.exists(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,8 +14,9 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.TagFields;
|
||||
import org.eclipse.hawkbit.repository.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.GenericTagUpdate;
|
||||
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.TagUpdate;
|
||||
@@ -23,19 +24,16 @@ import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.jpa.builder.JpaTagCreate;
|
||||
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
|
||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.TagSpecification;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.retry.annotation.Backoff;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
@@ -43,111 +41,35 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
* JP>A implementation of {@link TagManagement}.
|
||||
* JPA implementation of {@link TargetTagManagement}.
|
||||
*
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
@Validated
|
||||
public class JpaTagManagement implements TagManagement {
|
||||
public class JpaDistributionSetTagManagement implements DistributionSetTagManagement {
|
||||
|
||||
@Autowired
|
||||
private TargetTagRepository targetTagRepository;
|
||||
private final DistributionSetTagRepository distributionSetTagRepository;
|
||||
|
||||
@Autowired
|
||||
private TargetRepository targetRepository;
|
||||
private final DistributionSetRepository distributionSetRepository;
|
||||
|
||||
@Autowired
|
||||
private DistributionSetTagRepository distributionSetTagRepository;
|
||||
private final VirtualPropertyReplacer virtualPropertyReplacer;
|
||||
|
||||
@Autowired
|
||||
private DistributionSetRepository distributionSetRepository;
|
||||
private final NoCountPagingRepository criteriaNoCountDao;
|
||||
|
||||
@Autowired
|
||||
private VirtualPropertyReplacer virtualPropertyReplacer;
|
||||
|
||||
@Override
|
||||
public Optional<TargetTag> findTargetTag(final String name) {
|
||||
return targetTagRepository.findByNameEquals(name);
|
||||
JpaDistributionSetTagManagement(final DistributionSetTagRepository distributionSetTagRepository,
|
||||
final DistributionSetRepository distributionSetRepository,
|
||||
final VirtualPropertyReplacer virtualPropertyReplacer, final NoCountPagingRepository criteriaNoCountDao) {
|
||||
this.distributionSetTagRepository = distributionSetTagRepository;
|
||||
this.distributionSetRepository = distributionSetRepository;
|
||||
this.virtualPropertyReplacer = virtualPropertyReplacer;
|
||||
this.criteriaNoCountDao = criteriaNoCountDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetTag createTargetTag(final TagCreate c) {
|
||||
final JpaTagCreate create = (JpaTagCreate) c;
|
||||
|
||||
return targetTagRepository.save(create.buildTargetTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<TargetTag> createTargetTags(final Collection<TagCreate> tt) {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
final Collection<JpaTagCreate> targetTags = (Collection) tt;
|
||||
|
||||
return Collections.unmodifiableList(targetTags.stream()
|
||||
.map(ttc -> targetTagRepository.save(ttc.buildTargetTag())).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteTargetTag(final String targetTagName) {
|
||||
if (!targetTagRepository.existsByName(targetTagName)) {
|
||||
throw new EntityNotFoundException(TargetTag.class, targetTagName);
|
||||
}
|
||||
|
||||
// finally delete the tag itself
|
||||
targetTagRepository.deleteByName(targetTagName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetTag> findAllTargetTags(final String rsqlParam, final Pageable pageable) {
|
||||
|
||||
final Specification<JpaTargetTag> spec = RSQLUtility.parse(rsqlParam, TagFields.class, virtualPropertyReplacer);
|
||||
return convertTPage(targetTagRepository.findAll(spec, pageable), pageable);
|
||||
}
|
||||
|
||||
private static Page<TargetTag> convertTPage(final Page<JpaTargetTag> findAll, final Pageable pageable) {
|
||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
|
||||
private static Page<DistributionSetTag> convertDsPage(final Page<JpaDistributionSetTag> findAll,
|
||||
final Pageable pageable) {
|
||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countTargetTags() {
|
||||
return targetTagRepository.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetTag updateTargetTag(final TagUpdate u) {
|
||||
final GenericTagUpdate update = (GenericTagUpdate) u;
|
||||
|
||||
final JpaTargetTag tag = targetTagRepository.findById(update.getId())
|
||||
.orElseThrow(() -> new EntityNotFoundException(TargetTag.class, update.getId()));
|
||||
|
||||
update.getName().ifPresent(tag::setName);
|
||||
update.getDescription().ifPresent(tag::setDescription);
|
||||
update.getColour().ifPresent(tag::setColour);
|
||||
|
||||
return targetTagRepository.save(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSetTag updateDistributionSetTag(final TagUpdate u) {
|
||||
public DistributionSetTag update(final TagUpdate u) {
|
||||
final GenericTagUpdate update = (GenericTagUpdate) u;
|
||||
|
||||
final JpaDistributionSetTag tag = distributionSetTagRepository.findById(update.getId())
|
||||
@@ -161,7 +83,7 @@ public class JpaTagManagement implements TagManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DistributionSetTag> findDistributionSetTag(final String name) {
|
||||
public Optional<DistributionSetTag> getByName(final String name) {
|
||||
return distributionSetTagRepository.findByNameEquals(name);
|
||||
}
|
||||
|
||||
@@ -169,7 +91,7 @@ public class JpaTagManagement implements TagManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSetTag createDistributionSetTag(final TagCreate c) {
|
||||
public DistributionSetTag create(final TagCreate c) {
|
||||
final JpaTagCreate create = (JpaTagCreate) c;
|
||||
return distributionSetTagRepository.save(create.buildDistributionSetTag());
|
||||
}
|
||||
@@ -178,7 +100,7 @@ public class JpaTagManagement implements TagManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<DistributionSetTag> createDistributionSetTags(final Collection<TagCreate> dst) {
|
||||
public List<DistributionSetTag> create(final Collection<TagCreate> dst) {
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
final Collection<JpaTagCreate> creates = (Collection) dst;
|
||||
@@ -192,7 +114,7 @@ public class JpaTagManagement implements TagManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteDistributionSetTag(final String tagName) {
|
||||
public void delete(final String tagName) {
|
||||
if (!distributionSetTagRepository.existsByName(tagName)) {
|
||||
throw new EntityNotFoundException(DistributionSetTag.class, tagName);
|
||||
}
|
||||
@@ -201,27 +123,12 @@ public class JpaTagManagement implements TagManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<TargetTag> findTargetTagById(final Long id) {
|
||||
return Optional.ofNullable(targetTagRepository.findOne(id));
|
||||
public Slice<DistributionSetTag> findAll(final Pageable pageable) {
|
||||
return convertDsPage(criteriaNoCountDao.findAll(pageable, JpaDistributionSetTag.class), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DistributionSetTag> findDistributionSetTagById(final Long id) {
|
||||
return Optional.ofNullable(distributionSetTagRepository.findOne(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetTag> findAllTargetTags(final Pageable pageable) {
|
||||
return convertTPage(targetTagRepository.findAll(pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSetTag> findAllDistributionSetTags(final Pageable pageable) {
|
||||
return convertDsPage(distributionSetTagRepository.findAll(pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSetTag> findAllDistributionSetTags(final String rsqlParam, final Pageable pageable) {
|
||||
public Page<DistributionSetTag> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||
final Specification<JpaDistributionSetTag> spec = RSQLUtility.parse(rsqlParam, TagFields.class,
|
||||
virtualPropertyReplacer);
|
||||
|
||||
@@ -229,17 +136,7 @@ public class JpaTagManagement implements TagManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetTag> findAllTargetTags(final Pageable pageable, final String controllerId) {
|
||||
if (!targetRepository.existsByControllerId(controllerId)) {
|
||||
throw new EntityNotFoundException(Target.class, controllerId);
|
||||
}
|
||||
|
||||
return convertTPage(targetTagRepository.findAll(TagSpecification.ofTarget(controllerId), pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSetTag> findDistributionSetTagsByDistributionSet(final Pageable pageable,
|
||||
final Long setId) {
|
||||
public Page<DistributionSetTag> findByDistributionSet(final Pageable pageable, final Long setId) {
|
||||
if (!distributionSetRepository.exists(setId)) {
|
||||
throw new EntityNotFoundException(DistributionSet.class, setId);
|
||||
}
|
||||
@@ -247,4 +144,58 @@ public class JpaTagManagement implements TagManagement {
|
||||
return convertDsPage(distributionSetTagRepository.findAll(TagSpecification.ofDistributionSet(setId), pageable),
|
||||
pageable);
|
||||
}
|
||||
|
||||
private static Page<DistributionSetTag> convertDsPage(final Page<JpaDistributionSetTag> findAll,
|
||||
final Pageable pageable) {
|
||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
|
||||
private static Slice<DistributionSetTag> convertDsPage(final Slice<JpaDistributionSetTag> findAll,
|
||||
final Pageable pageable) {
|
||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final Collection<Long> ids) {
|
||||
final List<JpaDistributionSetTag> setsFound = distributionSetTagRepository.findAll(ids);
|
||||
|
||||
if (setsFound.size() < ids.size()) {
|
||||
throw new EntityNotFoundException(DistributionSetTag.class, ids,
|
||||
setsFound.stream().map(DistributionSetTag::getId).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
distributionSetTagRepository.delete(setsFound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DistributionSetTag> get(final Collection<Long> ids) {
|
||||
return Collections.unmodifiableList(distributionSetTagRepository.findAll(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DistributionSetTag> get(final Long id) {
|
||||
return Optional.ofNullable(distributionSetTagRepository.findOne(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final Long id) {
|
||||
distributionSetTagRepository.delete(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(final Long id) {
|
||||
return distributionSetTagRepository.exists(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long count() {
|
||||
return distributionSetTagRepository.count();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -27,6 +28,7 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetTypeSpecification;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.SpecificationsBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||
@@ -34,10 +36,12 @@ import org.springframework.dao.ConcurrencyFailureException;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.retry.annotation.Backoff;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
@@ -56,21 +60,24 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
|
||||
private final VirtualPropertyReplacer virtualPropertyReplacer;
|
||||
|
||||
private final NoCountPagingRepository criteriaNoCountDao;
|
||||
|
||||
JpaDistributionSetTypeManagement(final DistributionSetTypeRepository distributionSetTypeRepository,
|
||||
final SoftwareModuleTypeRepository softwareModuleTypeRepository,
|
||||
final DistributionSetRepository distributionSetRepository,
|
||||
final VirtualPropertyReplacer virtualPropertyReplacer) {
|
||||
final VirtualPropertyReplacer virtualPropertyReplacer, final NoCountPagingRepository criteriaNoCountDao) {
|
||||
this.distributionSetTypeRepository = distributionSetTypeRepository;
|
||||
this.softwareModuleTypeRepository = softwareModuleTypeRepository;
|
||||
this.distributionSetRepository = distributionSetRepository;
|
||||
this.virtualPropertyReplacer = virtualPropertyReplacer;
|
||||
this.criteriaNoCountDao = criteriaNoCountDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSetType updateDistributionSetType(final DistributionSetTypeUpdate u) {
|
||||
public DistributionSetType update(final DistributionSetTypeUpdate u) {
|
||||
final GenericDistributionSetTypeUpdate update = (GenericDistributionSetTypeUpdate) u;
|
||||
|
||||
final JpaDistributionSetType type = findDistributionSetTypeAndThrowExceptionIfNotFound(update.getId());
|
||||
@@ -82,9 +89,9 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(update.getId());
|
||||
|
||||
update.getMandatory().ifPresent(
|
||||
mand -> softwareModuleTypeRepository.findByIdIn(mand).forEach(type::addMandatoryModuleType));
|
||||
update.getOptional().ifPresent(
|
||||
opt -> softwareModuleTypeRepository.findByIdIn(opt).forEach(type::addOptionalModuleType));
|
||||
mand -> softwareModuleTypeRepository.findAll(mand).forEach(type::addMandatoryModuleType));
|
||||
update.getOptional()
|
||||
.ifPresent(opt -> softwareModuleTypeRepository.findAll(opt).forEach(type::addOptionalModuleType));
|
||||
}
|
||||
|
||||
return distributionSetTypeRepository.save(type);
|
||||
@@ -96,8 +103,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSetType assignMandatorySoftwareModuleTypes(final Long dsTypeId,
|
||||
final Collection<Long> softwareModulesTypeIds) {
|
||||
final Collection<JpaSoftwareModuleType> modules = softwareModuleTypeRepository
|
||||
.findByIdIn(softwareModulesTypeIds);
|
||||
final Collection<JpaSoftwareModuleType> modules = softwareModuleTypeRepository.findAll(softwareModulesTypeIds);
|
||||
|
||||
if (modules.size() < softwareModulesTypeIds.size()) {
|
||||
throw new EntityNotFoundException(SoftwareModuleType.class, softwareModulesTypeIds,
|
||||
@@ -119,8 +125,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
public DistributionSetType assignOptionalSoftwareModuleTypes(final Long dsTypeId,
|
||||
final Collection<Long> softwareModulesTypeIds) {
|
||||
|
||||
final Collection<JpaSoftwareModuleType> modules = softwareModuleTypeRepository
|
||||
.findByIdIn(softwareModulesTypeIds);
|
||||
final Collection<JpaSoftwareModuleType> modules = softwareModuleTypeRepository.findAll(softwareModulesTypeIds);
|
||||
|
||||
if (modules.size() < softwareModulesTypeIds.size()) {
|
||||
throw new EntityNotFoundException(SoftwareModuleType.class, softwareModulesTypeIds,
|
||||
@@ -149,37 +154,32 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSetType> findDistributionSetTypesAll(final String rsqlParam, final Pageable pageable) {
|
||||
final Specification<JpaDistributionSetType> spec = RSQLUtility.parse(rsqlParam, DistributionSetTypeFields.class,
|
||||
virtualPropertyReplacer);
|
||||
|
||||
return convertDsTPage(distributionSetTypeRepository.findAll(spec, pageable));
|
||||
public Page<DistributionSetType> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||
return convertPage(findByCriteriaAPI(pageable,
|
||||
Arrays.asList(RSQLUtility.parse(rsqlParam, DistributionSetTypeFields.class, virtualPropertyReplacer),
|
||||
DistributionSetTypeSpecification.isDeleted(false))),
|
||||
pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionSetType> findDistributionSetTypesAll(final Pageable pageable) {
|
||||
return convertDsTPage(distributionSetTypeRepository.findByDeleted(pageable, false));
|
||||
public Slice<DistributionSetType> findAll(final Pageable pageable) {
|
||||
return convertPage(criteriaNoCountDao.findAll(DistributionSetTypeSpecification.isDeleted(false), pageable,
|
||||
JpaDistributionSetType.class), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countDistributionSetTypesAll() {
|
||||
public long count() {
|
||||
return distributionSetTypeRepository.countByDeleted(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DistributionSetType> findDistributionSetTypeByName(final String name) {
|
||||
public Optional<DistributionSetType> getByName(final String name) {
|
||||
return Optional
|
||||
.ofNullable(distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byName(name)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DistributionSetType> findDistributionSetTypeById(final Long typeId) {
|
||||
return Optional
|
||||
.ofNullable(distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byId(typeId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DistributionSetType> findDistributionSetTypeByKey(final String key) {
|
||||
public Optional<DistributionSetType> getByKey(final String key) {
|
||||
return Optional.ofNullable(distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byKey(key)));
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSetType createDistributionSetType(final DistributionSetTypeCreate c) {
|
||||
public DistributionSetType create(final DistributionSetTypeCreate c) {
|
||||
final JpaDistributionSetTypeCreate create = (JpaDistributionSetTypeCreate) c;
|
||||
|
||||
return distributionSetTypeRepository.save(create.build());
|
||||
@@ -197,7 +197,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteDistributionSetType(final Long typeId) {
|
||||
public void delete(final Long typeId) {
|
||||
|
||||
final JpaDistributionSetType toDelete = distributionSetTypeRepository.findById(typeId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, typeId));
|
||||
@@ -214,21 +214,12 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<DistributionSetType> createDistributionSetTypes(final Collection<DistributionSetTypeCreate> types) {
|
||||
return types.stream().map(this::createDistributionSetType).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countDistributionSetsByType(final Long typeId) {
|
||||
if (!distributionSetTypeRepository.exists(typeId)) {
|
||||
throw new EntityNotFoundException(DistributionSetType.class, typeId);
|
||||
}
|
||||
|
||||
return distributionSetRepository.countByTypeId(typeId);
|
||||
public List<DistributionSetType> create(final Collection<DistributionSetTypeCreate> types) {
|
||||
return types.stream().map(this::create).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private JpaDistributionSetType findDistributionSetTypeAndThrowExceptionIfNotFound(final Long setId) {
|
||||
return (JpaDistributionSetType) findDistributionSetTypeById(setId)
|
||||
return (JpaDistributionSetType) get(setId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, setId));
|
||||
}
|
||||
|
||||
@@ -243,8 +234,54 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
}
|
||||
}
|
||||
|
||||
private static Page<DistributionSetType> convertDsTPage(final Page<JpaDistributionSetType> findAll) {
|
||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()));
|
||||
private static Page<DistributionSetType> convertPage(final Page<JpaDistributionSetType> findAll,
|
||||
final Pageable pageable) {
|
||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
|
||||
private static Slice<DistributionSetType> convertPage(final Slice<JpaDistributionSetType> findAll,
|
||||
final Pageable pageable) {
|
||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, 0);
|
||||
}
|
||||
|
||||
private Page<JpaDistributionSetType> findByCriteriaAPI(final Pageable pageable,
|
||||
final List<Specification<JpaDistributionSetType>> specList) {
|
||||
|
||||
if (CollectionUtils.isEmpty(specList)) {
|
||||
return distributionSetTypeRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
return distributionSetTypeRepository.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final Collection<Long> ids) {
|
||||
final List<JpaDistributionSetType> setsFound = distributionSetTypeRepository.findAll(ids);
|
||||
|
||||
if (setsFound.size() < ids.size()) {
|
||||
throw new EntityNotFoundException(DistributionSetType.class, ids,
|
||||
setsFound.stream().map(DistributionSetType::getId).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
distributionSetTypeRepository.delete(setsFound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DistributionSetType> get(final Collection<Long> ids) {
|
||||
return Collections.unmodifiableList(distributionSetTypeRepository.findAll(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DistributionSetType> get(final Long id) {
|
||||
return Optional.ofNullable(distributionSetTypeRepository.findOne(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(final Long id) {
|
||||
return distributionSetTypeRepository.exists(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -85,12 +85,12 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
private RolloutStatusCache rolloutStatusCache;
|
||||
|
||||
@Override
|
||||
public Optional<RolloutGroup> findRolloutGroupById(final Long rolloutGroupId) {
|
||||
public Optional<RolloutGroup> get(final Long rolloutGroupId) {
|
||||
return Optional.ofNullable(rolloutGroupRepository.findOne(rolloutGroupId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<RolloutGroup> findRolloutGroupsByRolloutId(final Long rolloutId, final Pageable pageable) {
|
||||
public Page<RolloutGroup> findByRollout(final Pageable pageable, final Long rolloutId) {
|
||||
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
||||
|
||||
return convertPage(rolloutGroupRepository.findByRolloutId(rolloutId, pageable), pageable);
|
||||
@@ -105,8 +105,8 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<RolloutGroup> findRolloutGroupsAll(final Long rolloutId, final String rsqlParam,
|
||||
final Pageable pageable) {
|
||||
public Page<RolloutGroup> findByRolloutAndRsql(final Pageable pageable, final Long rolloutId,
|
||||
final String rsqlParam) {
|
||||
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
||||
|
||||
final Specification<JpaRolloutGroup> specification = RSQLUtility.parse(rsqlParam, RolloutGroupFields.class,
|
||||
@@ -130,7 +130,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<RolloutGroup> findAllRolloutGroupsWithDetailedStatus(final Long rolloutId, final Pageable pageable) {
|
||||
public Page<RolloutGroup> findByRolloutWithDetailedStatus(final Pageable pageable, final Long rolloutId) {
|
||||
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
||||
|
||||
final Page<JpaRolloutGroup> rolloutGroups = rolloutGroupRepository.findByRolloutId(rolloutId, pageable);
|
||||
@@ -155,8 +155,8 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<RolloutGroup> findRolloutGroupWithDetailedStatus(final Long rolloutGroupId) {
|
||||
final Optional<RolloutGroup> rolloutGroup = findRolloutGroupById(rolloutGroupId);
|
||||
public Optional<RolloutGroup> getWithDetailedStatus(final Long rolloutGroupId) {
|
||||
final Optional<RolloutGroup> rolloutGroup = get(rolloutGroupId);
|
||||
|
||||
if (!rolloutGroup.isPresent()) {
|
||||
return rolloutGroup;
|
||||
@@ -201,8 +201,8 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findRolloutGroupTargets(final Long rolloutGroupId, final String rsqlParam,
|
||||
final Pageable pageable) {
|
||||
public Page<Target> findTargetsOfRolloutGroupByRsql(final Pageable pageable, final Long rolloutGroupId,
|
||||
final String rsqlParam) {
|
||||
|
||||
throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId);
|
||||
|
||||
@@ -219,7 +219,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findRolloutGroupTargets(final Long rolloutGroupId, final Pageable page) {
|
||||
public Page<Target> findTargetsOfRolloutGroup(final Pageable page, final Long rolloutGroupId) {
|
||||
final JpaRolloutGroup rolloutGroup = rolloutGroupRepository.findById(rolloutGroupId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(RolloutGroup.class, rolloutGroupId));
|
||||
|
||||
@@ -237,7 +237,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetWithActionStatus> findAllTargetsWithActionStatus(final Pageable pageRequest,
|
||||
public Page<TargetWithActionStatus> findAllTargetsOfRolloutGroupWithActionStatus(final Pageable pageRequest,
|
||||
final Long rolloutGroupId) {
|
||||
throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId);
|
||||
|
||||
@@ -269,7 +269,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countTargetsOfRolloutsGroup(@NotNull final Long rolloutGroupId) {
|
||||
public long countTargetsOfRolloutsGroup(@NotNull final Long rolloutGroupId) {
|
||||
throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId);
|
||||
|
||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
@@ -287,7 +287,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRolloutGroupsByRolloutId(final Long rolloutId) {
|
||||
public long countByRollout(final Long rolloutId) {
|
||||
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
||||
|
||||
return rolloutGroupRepository.countByRolloutId(rolloutId);
|
||||
|
||||
@@ -165,7 +165,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Rollout> findAllByPredicate(final String rsqlParam, final Pageable pageable, final boolean deleted) {
|
||||
public Page<Rollout> findByRsql(final Pageable pageable, final String rsqlParam, final boolean deleted) {
|
||||
final List<Specification<JpaRollout>> specList = Lists.newArrayListWithExpectedSize(2);
|
||||
specList.add(RSQLUtility.parse(rsqlParam, RolloutFields.class, virtualPropertyReplacer));
|
||||
specList.add(RolloutSpecification.isDeletedWithDistributionSet(deleted));
|
||||
@@ -186,7 +186,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Rollout> findRolloutById(final Long rolloutId) {
|
||||
public Optional<Rollout> get(final Long rolloutId) {
|
||||
return Optional.ofNullable(rolloutRepository.findOne(rolloutId));
|
||||
}
|
||||
|
||||
@@ -194,8 +194,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Rollout createRollout(final RolloutCreate rollout, final int amountGroup,
|
||||
final RolloutGroupConditions conditions) {
|
||||
public Rollout create(final RolloutCreate rollout, final int amountGroup, final RolloutGroupConditions conditions) {
|
||||
RolloutHelper.verifyRolloutGroupParameter(amountGroup, quotaManagement);
|
||||
final JpaRollout savedRollout = createRollout((JpaRollout) rollout.build());
|
||||
return createRolloutGroups(amountGroup, conditions, savedRollout);
|
||||
@@ -205,7 +204,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Rollout createRollout(final RolloutCreate rollout, final List<RolloutGroupCreate> groups,
|
||||
public Rollout create(final RolloutCreate rollout, final List<RolloutGroupCreate> groups,
|
||||
final RolloutGroupConditions conditions) {
|
||||
RolloutHelper.verifyRolloutGroupParameter(groups.size(), quotaManagement);
|
||||
final JpaRollout savedRollout = createRollout((JpaRollout) rollout.build());
|
||||
@@ -214,7 +213,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
|
||||
private JpaRollout createRollout(final JpaRollout rollout) {
|
||||
|
||||
final Long totalTargets = targetManagement.countTargetByTargetFilterQuery(rollout.getTargetFilterQuery());
|
||||
final Long totalTargets = targetManagement.countByRsql(rollout.getTargetFilterQuery());
|
||||
if (totalTargets == 0) {
|
||||
throw new ValidationException("Rollout does not match any existing targets");
|
||||
}
|
||||
@@ -320,9 +319,9 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
private void handleCreateRollout(final JpaRollout rollout) {
|
||||
LOGGER.debug("handleCreateRollout called for rollout {}", rollout.getId());
|
||||
|
||||
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(rollout.getId(),
|
||||
new PageRequest(0, quotaManagement.getMaxRolloutGroupsPerRollout(), new Sort(Direction.ASC, "id")))
|
||||
.getContent();
|
||||
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement.findByRollout(
|
||||
new PageRequest(0, quotaManagement.getMaxRolloutGroupsPerRollout(), new Sort(Direction.ASC, "id")),
|
||||
rollout.getId()).getContent();
|
||||
|
||||
int readyGroups = 0;
|
||||
int totalTargets = 0;
|
||||
@@ -368,7 +367,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
RolloutGroupStatus.READY, group);
|
||||
|
||||
final long targetsInGroupFilter = runInNewTransaction("countAllTargetsByTargetFilterQueryAndNotInRolloutGroups",
|
||||
count -> targetManagement.countAllTargetsByTargetFilterQueryAndNotInRolloutGroups(readyGroups,
|
||||
count -> targetManagement.countByRsqlAndNotInRolloutGroups(readyGroups,
|
||||
groupTargetFilter));
|
||||
final long expectedInGroup = Math.round(group.getTargetPercentage() / 100 * (double) targetsInGroupFilter);
|
||||
final long currentlyInGroup = runInNewTransaction("countRolloutTargetGroupByRolloutGroup",
|
||||
@@ -410,7 +409,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
final List<Long> readyGroups = RolloutHelper.getGroupsByStatusIncludingGroup(rollout.getRolloutGroups(),
|
||||
RolloutGroupStatus.READY, group);
|
||||
final Page<Target> targets = targetManagement
|
||||
.findAllTargetsByTargetFilterQueryAndNotInRolloutGroups(pageRequest, readyGroups, targetFilter);
|
||||
.findByTargetFilterQueryAndNotInRolloutGroups(pageRequest, readyGroups, targetFilter);
|
||||
|
||||
createAssignmentOfTargetsToGroup(targets, group);
|
||||
|
||||
@@ -428,7 +427,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
final String targetFilter, final Long createdAt) {
|
||||
|
||||
final String baseFilter = RolloutHelper.getTargetFilterQuery(targetFilter, createdAt);
|
||||
final long totalTargets = targetManagement.countTargetByTargetFilterQuery(baseFilter);
|
||||
final long totalTargets = targetManagement.countByRsql(baseFilter);
|
||||
if (totalTargets == 0) {
|
||||
throw new ConstraintDeclarationException("Rollout target filter does not match any targets");
|
||||
}
|
||||
@@ -441,7 +440,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Rollout startRollout(final Long rolloutId) {
|
||||
public Rollout start(final Long rolloutId) {
|
||||
LOGGER.debug("startRollout called for rollout {}", rolloutId);
|
||||
|
||||
final JpaRollout rollout = getRolloutAndThrowExceptionIfNotFound(rolloutId);
|
||||
@@ -531,7 +530,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
final ActionType actionType = rollout.getActionType();
|
||||
final long forceTime = rollout.getForcedTime();
|
||||
|
||||
final Page<Target> targets = targetManagement.findAllTargetsInRolloutGroupWithoutAction(pageRequest,
|
||||
final Page<Target> targets = targetManagement.findByInRolloutGroupWithoutAction(pageRequest,
|
||||
groupId);
|
||||
if (targets.getTotalElements() > 0) {
|
||||
createScheduledAction(targets.getContent(), distributionSet, actionType, forceTime, rollout, group);
|
||||
@@ -812,7 +811,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
LOGGER.debug(
|
||||
"handleReadyRollout called for rollout {} with autostart beyond define time. Switch to STARTING",
|
||||
rollout.getId());
|
||||
startRollout(rollout.getId());
|
||||
start(rollout.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -820,7 +819,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteRollout(final long rolloutId) {
|
||||
public void delete(final Long rolloutId) {
|
||||
final JpaRollout jpaRollout = rolloutRepository.findOne(rolloutId);
|
||||
|
||||
if (jpaRollout == null) {
|
||||
@@ -915,17 +914,17 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countRolloutsAll() {
|
||||
public long count() {
|
||||
return rolloutRepository.count(RolloutSpecification.isDeletedWithDistributionSet(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countRolloutsAllByFilters(final String searchText) {
|
||||
public long countByFilters(final String searchText) {
|
||||
return rolloutRepository.count(JpaRolloutHelper.likeNameOrDescription(searchText, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Rollout> findRolloutWithDetailedStatusByFilters(final Pageable pageable, final String searchText,
|
||||
public Slice<Rollout> findByFiltersWithDetailedStatus(final Pageable pageable, final String searchText,
|
||||
final boolean deleted) {
|
||||
final Slice<JpaRollout> findAll = findByCriteriaAPI(pageable,
|
||||
Arrays.asList(JpaRolloutHelper.likeNameOrDescription(searchText, deleted)));
|
||||
@@ -934,7 +933,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Rollout> findRolloutByName(final String rolloutName) {
|
||||
public Optional<Rollout> getByName(final String rolloutName) {
|
||||
return rolloutRepository.findByName(rolloutName);
|
||||
}
|
||||
|
||||
@@ -942,7 +941,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Rollout updateRollout(final RolloutUpdate u) {
|
||||
public Rollout update(final RolloutUpdate u) {
|
||||
final GenericRolloutUpdate update = (GenericRolloutUpdate) u;
|
||||
final JpaRollout rollout = getRolloutAndThrowExceptionIfNotFound(update.getId());
|
||||
|
||||
@@ -954,7 +953,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
update.getForcedTime().ifPresent(rollout::setForcedTime);
|
||||
update.getStartAt().ifPresent(rollout::setStartAt);
|
||||
update.getSet().ifPresent(setId -> {
|
||||
final DistributionSet set = distributionSetManagement.findDistributionSetById(setId)
|
||||
final DistributionSet set = distributionSetManagement.get(setId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, setId));
|
||||
|
||||
rollout.setDistributionSet(set);
|
||||
@@ -975,7 +974,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Rollout> findAllRolloutsWithDetailedStatus(final Pageable pageable, final boolean deleted) {
|
||||
public Page<Rollout> findAllWithDetailedStatus(final Pageable pageable, final boolean deleted) {
|
||||
Page<JpaRollout> rollouts;
|
||||
final Specification<JpaRollout> spec = RolloutSpecification.isDeletedWithDistributionSet(deleted);
|
||||
rollouts = rolloutRepository.findAll(spec, pageable);
|
||||
@@ -984,8 +983,8 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Rollout> findRolloutWithDetailedStatus(final Long rolloutId) {
|
||||
final Optional<Rollout> rollout = findRolloutById(rolloutId);
|
||||
public Optional<Rollout> getWithDetailedStatus(final Long rolloutId) {
|
||||
final Optional<Rollout> rollout = get(rolloutId);
|
||||
|
||||
if (!rollout.isPresent()) {
|
||||
return rollout;
|
||||
|
||||
@@ -113,7 +113,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public SoftwareModule updateSoftwareModule(final SoftwareModuleUpdate u) {
|
||||
public SoftwareModule update(final SoftwareModuleUpdate u) {
|
||||
final GenericSoftwareModuleUpdate update = (GenericSoftwareModuleUpdate) u;
|
||||
|
||||
final JpaSoftwareModule module = softwareModuleRepository.findById(update.getId())
|
||||
@@ -129,7 +129,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public SoftwareModule createSoftwareModule(final SoftwareModuleCreate c) {
|
||||
public SoftwareModule create(final SoftwareModuleCreate c) {
|
||||
final JpaSoftwareModuleCreate create = (JpaSoftwareModuleCreate) c;
|
||||
|
||||
return softwareModuleRepository.save(create.build());
|
||||
@@ -139,12 +139,12 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<SoftwareModule> createSoftwareModule(final Collection<SoftwareModuleCreate> swModules) {
|
||||
return swModules.stream().map(this::createSoftwareModule).collect(Collectors.toList());
|
||||
public List<SoftwareModule> create(final Collection<SoftwareModuleCreate> swModules) {
|
||||
return swModules.stream().map(this::create).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<SoftwareModule> findSoftwareModulesByType(final Pageable pageable, final Long typeId) {
|
||||
public Slice<SoftwareModule> findByType(final Pageable pageable, final Long typeId) {
|
||||
throwExceptionIfSoftwareModuleTypeDoesNotExist(typeId);
|
||||
|
||||
final List<Specification<JpaSoftwareModule>> specList = Lists.newArrayListWithExpectedSize(2);
|
||||
@@ -152,7 +152,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
specList.add(SoftwareModuleSpecification.equalType(typeId));
|
||||
specList.add(SoftwareModuleSpecification.isDeletedFalse());
|
||||
|
||||
return convertSmPage(findSwModuleByCriteriaAPI(pageable, specList), pageable);
|
||||
return convertSmPage(findByCriteriaAPI(pageable, specList), pageable);
|
||||
}
|
||||
|
||||
private void throwExceptionIfSoftwareModuleTypeDoesNotExist(final Long typeId) {
|
||||
@@ -176,12 +176,12 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SoftwareModule> findSoftwareModuleById(final Long id) {
|
||||
public Optional<SoftwareModule> get(final Long id) {
|
||||
return Optional.ofNullable(softwareModuleRepository.findOne(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SoftwareModule> findSoftwareModuleByNameAndVersion(final String name, final String version,
|
||||
public Optional<SoftwareModule> getByNameAndVersionAndType(final String name, final String version,
|
||||
final Long typeId) {
|
||||
|
||||
throwExceptionIfSoftwareModuleTypeDoesNotExist(typeId);
|
||||
@@ -193,7 +193,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
return distributionSetRepository.countByModulesId(moduleId) <= 0;
|
||||
}
|
||||
|
||||
private Slice<JpaSoftwareModule> findSwModuleByCriteriaAPI(final Pageable pageable,
|
||||
private Slice<JpaSoftwareModule> findByCriteriaAPI(final Pageable pageable,
|
||||
final List<Specification<JpaSoftwareModule>> specList) {
|
||||
return criteriaNoCountDao.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable,
|
||||
JpaSoftwareModule.class);
|
||||
@@ -213,7 +213,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteSoftwareModules(final Collection<Long> ids) {
|
||||
public void delete(final Collection<Long> ids) {
|
||||
final List<JpaSoftwareModule> swModulesToDelete = softwareModuleRepository.findByIdIn(ids);
|
||||
|
||||
if (swModulesToDelete.size() < ids.size()) {
|
||||
@@ -245,7 +245,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<SoftwareModule> findSoftwareModulesAll(final Pageable pageable) {
|
||||
public Slice<SoftwareModule> findAll(final Pageable pageable) {
|
||||
|
||||
final List<Specification<JpaSoftwareModule>> specList = new ArrayList<>(2);
|
||||
|
||||
@@ -261,18 +261,18 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
specList.add(spec);
|
||||
|
||||
return convertSmPage(findSwModuleByCriteriaAPI(pageable, specList), pageable);
|
||||
return convertSmPage(findByCriteriaAPI(pageable, specList), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countSoftwareModulesAll() {
|
||||
public long count() {
|
||||
final Specification<JpaSoftwareModule> spec = SoftwareModuleSpecification.isDeletedFalse();
|
||||
|
||||
return countSwModuleByCriteriaAPI(Arrays.asList(spec));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SoftwareModule> findSoftwareModulesByPredicate(final String rsqlParam, final Pageable pageable) {
|
||||
public Page<SoftwareModule> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||
final Specification<JpaSoftwareModule> spec = RSQLUtility.parse(rsqlParam, SoftwareModuleFields.class,
|
||||
virtualPropertyReplacer);
|
||||
|
||||
@@ -281,12 +281,12 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
@Override
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
public List<SoftwareModule> findSoftwareModulesById(final Collection<Long> ids) {
|
||||
public List<SoftwareModule> get(final Collection<Long> ids) {
|
||||
return Collections.unmodifiableList(softwareModuleRepository.findByIdIn(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<SoftwareModule> findSoftwareModuleByFilters(final Pageable pageable, final String searchText,
|
||||
public Slice<SoftwareModule> findByTextAndType(final Pageable pageable, final String searchText,
|
||||
final Long typeId) {
|
||||
|
||||
final List<Specification<JpaSoftwareModule>> specList = new ArrayList<>(4);
|
||||
@@ -315,11 +315,11 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
specList.add(spec);
|
||||
|
||||
return convertSmPage(findSwModuleByCriteriaAPI(pageable, specList), pageable);
|
||||
return convertSmPage(findByCriteriaAPI(pageable, specList), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<AssignedSoftwareModule> findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
|
||||
public Slice<AssignedSoftwareModule> findAllOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
|
||||
final Pageable pageable, final Long orderByDistributionId, final String searchText, final Long typeId) {
|
||||
|
||||
final List<AssignedSoftwareModule> resultList = new ArrayList<>();
|
||||
@@ -408,7 +408,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countSoftwareModuleByFilters(final String searchText, final Long typeId) {
|
||||
public long countByTextAndType(final String searchText, final Long typeId) {
|
||||
|
||||
final List<Specification<JpaSoftwareModule>> specList = new ArrayList<>(3);
|
||||
|
||||
@@ -431,7 +431,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SoftwareModule> findSoftwareModuleByAssignedTo(final Pageable pageable, final Long setId) {
|
||||
public Page<SoftwareModule> findByAssignedTo(final Pageable pageable, final Long setId) {
|
||||
if (!distributionSetRepository.exists(setId)) {
|
||||
throw new EntityNotFoundException(DistributionSet.class, setId);
|
||||
}
|
||||
@@ -443,7 +443,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public SoftwareModuleMetadata createSoftwareModuleMetadata(final Long moduleId, final MetaData md) {
|
||||
public SoftwareModuleMetadata createMetaData(final Long moduleId, final MetaData md) {
|
||||
|
||||
checkAndThrowAlreadyIfSoftwareModuleMetadataExists(moduleId, md);
|
||||
|
||||
@@ -461,8 +461,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<SoftwareModuleMetadata> createSoftwareModuleMetadata(final Long moduleId,
|
||||
final Collection<MetaData> md) {
|
||||
public List<SoftwareModuleMetadata> createMetaData(final Long moduleId, final Collection<MetaData> md) {
|
||||
md.forEach(meta -> checkAndThrowAlreadyIfSoftwareModuleMetadataExists(moduleId, meta));
|
||||
|
||||
final JpaSoftwareModule module = touch(moduleId);
|
||||
@@ -477,10 +476,10 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public SoftwareModuleMetadata updateSoftwareModuleMetadata(final Long moduleId, final MetaData md) {
|
||||
public SoftwareModuleMetadata updateMetaData(final Long moduleId, final MetaData md) {
|
||||
|
||||
// check if exists otherwise throw entity not found exception
|
||||
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) findSoftwareModuleMetadata(moduleId,
|
||||
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) getMetaDataBySoftwareModuleId(moduleId,
|
||||
md.getKey()).orElseThrow(
|
||||
() -> new EntityNotFoundException(SoftwareModuleMetadata.class, moduleId, md.getKey()));
|
||||
metadata.setValue(md.getValue());
|
||||
@@ -515,30 +514,21 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
* of the module to touch
|
||||
*/
|
||||
private JpaSoftwareModule touch(final Long moduleId) {
|
||||
return touch(findSoftwareModuleById(moduleId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, moduleId)));
|
||||
return touch(get(moduleId).orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, moduleId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteSoftwareModuleMetadata(final Long moduleId, final String key) {
|
||||
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) findSoftwareModuleMetadata(moduleId, key)
|
||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleMetadata.class, moduleId, key));
|
||||
public void deleteMetaData(final Long moduleId, final String key) {
|
||||
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) getMetaDataBySoftwareModuleId(moduleId,
|
||||
key).orElseThrow(() -> new EntityNotFoundException(SoftwareModuleMetadata.class, moduleId, key));
|
||||
|
||||
touch(metadata.getSoftwareModule());
|
||||
softwareModuleMetadataRepository.delete(metadata.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(final Long swId,
|
||||
final Pageable pageable) {
|
||||
throwExceptionIfSoftwareModuleDoesNotExist(swId);
|
||||
|
||||
return softwareModuleMetadataRepository.findBySoftwareModuleId(swId, pageable);
|
||||
}
|
||||
|
||||
private void throwExceptionIfSoftwareModuleDoesNotExist(final Long swId) {
|
||||
if (!softwareModuleRepository.exists(swId)) {
|
||||
throw new EntityNotFoundException(SoftwareModule.class, swId);
|
||||
@@ -546,8 +536,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(final Long softwareModuleId,
|
||||
final String rsqlParam, final Pageable pageable) {
|
||||
public Page<SoftwareModuleMetadata> findMetaDataByRsql(final Pageable pageable, final Long softwareModuleId,
|
||||
final String rsqlParam) {
|
||||
|
||||
throwExceptionIfSoftwareModuleDoesNotExist(softwareModuleId);
|
||||
|
||||
@@ -564,18 +554,23 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(final Pageable pageable,
|
||||
final Long softwareModuleId) {
|
||||
throwExceptionIfSoftwareModuleDoesNotExist(softwareModuleId);
|
||||
private static Page<SoftwareModuleMetadata> convertMdPage(final Page<JpaSoftwareModuleMetadata> findAll,
|
||||
final Pageable pageable) {
|
||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
|
||||
return convertSmMdPage(softwareModuleMetadataRepository.findAll((root, query, cb) -> cb.equal(
|
||||
root.get(JpaSoftwareModuleMetadata_.softwareModule).get(JpaSoftwareModule_.id), softwareModuleId),
|
||||
@Override
|
||||
public Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleId(final Pageable pageable, final Long swId) {
|
||||
throwExceptionIfSoftwareModuleDoesNotExist(swId);
|
||||
|
||||
return convertMdPage(softwareModuleMetadataRepository.findAll(
|
||||
(Specification<JpaSoftwareModuleMetadata>) (root, query, cb) -> cb
|
||||
.equal(root.get(JpaSoftwareModuleMetadata_.softwareModule).get(JpaSoftwareModule_.id), swId),
|
||||
pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SoftwareModuleMetadata> findSoftwareModuleMetadata(final Long moduleId, final String key) {
|
||||
public Optional<SoftwareModuleMetadata> getMetaDataBySoftwareModuleId(final Long moduleId, final String key) {
|
||||
throwExceptionIfSoftwareModuleDoesNotExist(moduleId);
|
||||
|
||||
return Optional.ofNullable(softwareModuleMetadataRepository.findOne(new SwMetadataCompositeKey(moduleId, key)));
|
||||
@@ -589,13 +584,13 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteSoftwareModule(final Long moduleId) {
|
||||
deleteSoftwareModules(Arrays.asList(moduleId));
|
||||
public void delete(final Long moduleId) {
|
||||
delete(Arrays.asList(moduleId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SoftwareModuleType> findSoftwareModuleTypesById(final Collection<Long> ids) {
|
||||
return Collections.unmodifiableList(softwareModuleTypeRepository.findByIdIn(ids));
|
||||
public boolean exists(final Long id) {
|
||||
return softwareModuleRepository.exists(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.jpa.builder.JpaSoftwareModuleTypeCreate;
|
||||
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType_;
|
||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||
@@ -30,6 +31,7 @@ import org.springframework.dao.ConcurrencyFailureException;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.retry.annotation.Backoff;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
@@ -52,24 +54,27 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
||||
|
||||
private final SoftwareModuleRepository softwareModuleRepository;
|
||||
|
||||
private final NoCountPagingRepository criteriaNoCountDao;
|
||||
|
||||
JpaSoftwareModuleTypeManagement(final DistributionSetTypeRepository distributionSetTypeRepository,
|
||||
final SoftwareModuleTypeRepository softwareModuleTypeRepository,
|
||||
final VirtualPropertyReplacer virtualPropertyReplacer,
|
||||
final SoftwareModuleRepository softwareModuleRepository) {
|
||||
final SoftwareModuleRepository softwareModuleRepository, final NoCountPagingRepository criteriaNoCountDao) {
|
||||
this.distributionSetTypeRepository = distributionSetTypeRepository;
|
||||
this.softwareModuleTypeRepository = softwareModuleTypeRepository;
|
||||
this.virtualPropertyReplacer = virtualPropertyReplacer;
|
||||
this.softwareModuleRepository = softwareModuleRepository;
|
||||
this.criteriaNoCountDao = criteriaNoCountDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public SoftwareModuleType updateSoftwareModuleType(final SoftwareModuleTypeUpdate u) {
|
||||
public SoftwareModuleType update(final SoftwareModuleTypeUpdate u) {
|
||||
final GenericSoftwareModuleTypeUpdate update = (GenericSoftwareModuleTypeUpdate) u;
|
||||
|
||||
final JpaSoftwareModuleType type = (JpaSoftwareModuleType) findSoftwareModuleTypeById(update.getId())
|
||||
final JpaSoftwareModuleType type = (JpaSoftwareModuleType) get(update.getId())
|
||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, update.getId()));
|
||||
|
||||
update.getDescription().ifPresent(type::setDescription);
|
||||
@@ -79,36 +84,33 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SoftwareModuleType> findSoftwareModuleTypesAll(final String rsqlParam, final Pageable pageable) {
|
||||
public Page<SoftwareModuleType> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||
|
||||
final Specification<JpaSoftwareModuleType> spec = RSQLUtility.parse(rsqlParam, SoftwareModuleTypeFields.class,
|
||||
virtualPropertyReplacer);
|
||||
|
||||
return convertSmTPage(softwareModuleTypeRepository.findAll(spec, pageable), pageable);
|
||||
return convertPage(softwareModuleTypeRepository.findAll(spec, pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SoftwareModuleType> findSoftwareModuleTypesAll(final Pageable pageable) {
|
||||
return softwareModuleTypeRepository.findByDeleted(pageable, false);
|
||||
public Slice<SoftwareModuleType> findAll(final Pageable pageable) {
|
||||
return convertPage(criteriaNoCountDao.findAll(
|
||||
(targetRoot, query, cb) -> cb.equal(targetRoot.<Boolean> get(JpaSoftwareModuleType_.deleted), false),
|
||||
pageable, JpaSoftwareModuleType.class), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countSoftwareModuleTypesAll() {
|
||||
public long count() {
|
||||
return softwareModuleTypeRepository.countByDeleted(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SoftwareModuleType> findSoftwareModuleTypeByKey(final String key) {
|
||||
public Optional<SoftwareModuleType> getByKey(final String key) {
|
||||
return softwareModuleTypeRepository.findByKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SoftwareModuleType> findSoftwareModuleTypeById(final Long smTypeId) {
|
||||
return Optional.ofNullable(softwareModuleTypeRepository.findOne(smTypeId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SoftwareModuleType> findSoftwareModuleTypeByName(final String name) {
|
||||
public Optional<SoftwareModuleType> getByName(final String name) {
|
||||
return softwareModuleTypeRepository.findByName(name);
|
||||
}
|
||||
|
||||
@@ -116,7 +118,7 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public SoftwareModuleType createSoftwareModuleType(final SoftwareModuleTypeCreate c) {
|
||||
public SoftwareModuleType create(final SoftwareModuleTypeCreate c) {
|
||||
final JpaSoftwareModuleTypeCreate create = (JpaSoftwareModuleTypeCreate) c;
|
||||
|
||||
return softwareModuleTypeRepository.save(create.build());
|
||||
@@ -126,7 +128,7 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteSoftwareModuleType(final Long typeId) {
|
||||
public void delete(final Long typeId) {
|
||||
final JpaSoftwareModuleType toDelete = softwareModuleTypeRepository.findById(typeId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, typeId));
|
||||
|
||||
@@ -143,13 +145,48 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<SoftwareModuleType> createSoftwareModuleType(final Collection<SoftwareModuleTypeCreate> creates) {
|
||||
return creates.stream().map(this::createSoftwareModuleType).collect(Collectors.toList());
|
||||
public List<SoftwareModuleType> create(final Collection<SoftwareModuleTypeCreate> creates) {
|
||||
return creates.stream().map(this::create).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static Page<SoftwareModuleType> convertSmTPage(final Page<JpaSoftwareModuleType> findAll,
|
||||
private static Page<SoftwareModuleType> convertPage(final Page<JpaSoftwareModuleType> findAll,
|
||||
final Pageable pageable) {
|
||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
|
||||
private static Slice<SoftwareModuleType> convertPage(final Slice<JpaSoftwareModuleType> findAll,
|
||||
final Pageable pageable) {
|
||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final Collection<Long> ids) {
|
||||
final List<JpaSoftwareModuleType> setsFound = softwareModuleTypeRepository.findAll(ids);
|
||||
|
||||
if (setsFound.size() < ids.size()) {
|
||||
throw new EntityNotFoundException(SoftwareModuleType.class, ids,
|
||||
setsFound.stream().map(SoftwareModuleType::getId).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
softwareModuleTypeRepository.delete(setsFound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SoftwareModuleType> get(final Collection<Long> ids) {
|
||||
return Collections.unmodifiableList(softwareModuleTypeRepository.findAll(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SoftwareModuleType> get(final Long id) {
|
||||
return Optional.ofNullable(softwareModuleTypeRepository.findOne(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(final Long id) {
|
||||
return softwareModuleTypeRepository.exists(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetFilterQuery createTargetFilterQuery(final TargetFilterQueryCreate c) {
|
||||
public TargetFilterQuery create(final TargetFilterQueryCreate c) {
|
||||
final JpaTargetFilterQueryCreate create = (JpaTargetFilterQueryCreate) c;
|
||||
|
||||
return targetFilterQueryRepository.save(create.build());
|
||||
@@ -84,20 +84,20 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteTargetFilterQuery(final Long targetFilterQueryId) {
|
||||
findTargetFilterQueryById(targetFilterQueryId)
|
||||
public void delete(final Long targetFilterQueryId) {
|
||||
get(targetFilterQueryId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId));
|
||||
|
||||
targetFilterQueryRepository.delete(targetFilterQueryId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetFilterQuery> findAllTargetFilterQuery(final Pageable pageable) {
|
||||
public Page<TargetFilterQuery> findAll(final Pageable pageable) {
|
||||
return convertPage(targetFilterQueryRepository.findAll(pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countAllTargetFilterQuery() {
|
||||
public long count() {
|
||||
return targetFilterQueryRepository.count();
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetFilterQuery> findTargetFilterQueryByName(final Pageable pageable, final String name) {
|
||||
public Page<TargetFilterQuery> findByName(final Pageable pageable, final String name) {
|
||||
List<Specification<JpaTargetFilterQuery>> specList = Collections.emptyList();
|
||||
if (!StringUtils.isEmpty(name)) {
|
||||
specList = Collections.singletonList(TargetFilterQuerySpecification.likeName(name));
|
||||
@@ -116,7 +116,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetFilterQuery> findTargetFilterQueryByFilter(final Pageable pageable, final String rsqlFilter) {
|
||||
public Page<TargetFilterQuery> findByRsql(final Pageable pageable, final String rsqlFilter) {
|
||||
List<Specification<JpaTargetFilterQuery>> specList = Collections.emptyList();
|
||||
if (!StringUtils.isEmpty(rsqlFilter)) {
|
||||
specList = Collections.singletonList(
|
||||
@@ -126,7 +126,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetFilterQuery> findTargetFilterQueryByQuery(final Pageable pageable, final String query) {
|
||||
public Page<TargetFilterQuery> findByQuery(final Pageable pageable, final String query) {
|
||||
List<Specification<JpaTargetFilterQuery>> specList = Collections.emptyList();
|
||||
if (!StringUtils.isEmpty(query)) {
|
||||
specList = Collections.singletonList(TargetFilterQuerySpecification.equalsQuery(query));
|
||||
@@ -135,7 +135,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetFilterQuery> findTargetFilterQueryByAutoAssignDS(final Pageable pageable, final Long setId,
|
||||
public Page<TargetFilterQuery> findByAutoAssignDSAndRsql(final Pageable pageable, final Long setId,
|
||||
final String rsqlFilter) {
|
||||
final List<Specification<JpaTargetFilterQuery>> specList = Lists.newArrayListWithExpectedSize(2);
|
||||
|
||||
@@ -150,7 +150,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetFilterQuery> findTargetFilterQueryWithAutoAssignDS(final Pageable pageable) {
|
||||
public Page<TargetFilterQuery> findWithAutoAssignDS(final Pageable pageable) {
|
||||
final List<Specification<JpaTargetFilterQuery>> specList = Collections
|
||||
.singletonList(TargetFilterQuerySpecification.withAutoAssignDS());
|
||||
return convertPage(findTargetFilterQueryByCriteriaAPI(pageable, specList), pageable);
|
||||
@@ -167,18 +167,18 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<TargetFilterQuery> findTargetFilterQueryByName(final String targetFilterQueryName) {
|
||||
public Optional<TargetFilterQuery> getByName(final String targetFilterQueryName) {
|
||||
return targetFilterQueryRepository.findByName(targetFilterQueryName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<TargetFilterQuery> findTargetFilterQueryById(final Long targetFilterQueryId) {
|
||||
public Optional<TargetFilterQuery> get(final Long targetFilterQueryId) {
|
||||
return Optional.ofNullable(targetFilterQueryRepository.findOne(targetFilterQueryId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TargetFilterQuery updateTargetFilterQuery(final TargetFilterQueryUpdate u) {
|
||||
public TargetFilterQuery update(final TargetFilterQueryUpdate u) {
|
||||
final GenericTargetFilterQueryUpdate update = (GenericTargetFilterQueryUpdate) u;
|
||||
|
||||
final JpaTargetFilterQuery targetFilterQuery = findTargetFilterQueryOrThrowExceptionIfNotFound(update.getId());
|
||||
@@ -191,7 +191,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TargetFilterQuery updateTargetFilterQueryAutoAssignDS(final Long queryId, final Long dsId) {
|
||||
public TargetFilterQuery updateAutoAssignDS(final Long queryId, final Long dsId) {
|
||||
final JpaTargetFilterQuery targetFilterQuery = findTargetFilterQueryOrThrowExceptionIfNotFound(queryId);
|
||||
|
||||
targetFilterQuery.setAutoAssignDistributionSet(
|
||||
@@ -201,7 +201,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
}
|
||||
|
||||
private JpaDistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) {
|
||||
return (JpaDistributionSet) distributionSetManagement.findDistributionSetByIdWithDetails(setId)
|
||||
return (JpaDistributionSet) distributionSetManagement.getWithDetails(setId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, setId));
|
||||
}
|
||||
|
||||
|
||||
@@ -116,28 +116,28 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
private VirtualPropertyReplacer virtualPropertyReplacer;
|
||||
|
||||
@Override
|
||||
public Optional<Target> findTargetByControllerID(final String controllerId) {
|
||||
public Optional<Target> getByControllerID(final String controllerId) {
|
||||
return targetRepository.findByControllerId(controllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Target> findTargetsByControllerID(final Collection<String> controllerIDs) {
|
||||
public List<Target> getByControllerID(final Collection<String> controllerIDs) {
|
||||
return Collections.unmodifiableList(
|
||||
targetRepository.findAll(TargetSpecifications.byControllerIdWithAssignedDsInJoin(controllerIDs)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countTargetsAll() {
|
||||
public long count() {
|
||||
return targetRepository.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Target> findTargetsAll(final Pageable pageable) {
|
||||
public Slice<Target> findAll(final Pageable pageable) {
|
||||
return convertPage(criteriaNoCountDao.findAll(pageable, JpaTarget.class), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Target> findTargetsByTargetFilterQuery(final Long targetFilterQueryId, final Pageable pageable) {
|
||||
public Slice<Target> findByTargetFilterQuery(final Pageable pageable, final Long targetFilterQueryId) {
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryRepository.findById(targetFilterQueryId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId));
|
||||
|
||||
@@ -146,7 +146,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findTargetsAll(final String targetFilterQuery, final Pageable pageable) {
|
||||
public Page<Target> findByRsql(final Pageable pageable, final String targetFilterQuery) {
|
||||
return findTargetsBySpec(RSQLUtility.parse(targetFilterQuery, TargetFields.class, virtualPropertyReplacer),
|
||||
pageable);
|
||||
}
|
||||
@@ -159,7 +159,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Target updateTarget(final TargetUpdate u) {
|
||||
public Target update(final TargetUpdate u) {
|
||||
final JpaTargetUpdate update = (JpaTargetUpdate) u;
|
||||
|
||||
final JpaTarget target = (JpaTarget) targetRepository.findByControllerId(update.getControllerId())
|
||||
@@ -177,7 +177,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteTargets(final Collection<Long> targetIDs) {
|
||||
public void delete(final Collection<Long> targetIDs) {
|
||||
final List<JpaTarget> targets = targetRepository.findAll(targetIDs);
|
||||
|
||||
if (targets.size() < targetIDs.size()) {
|
||||
@@ -197,7 +197,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteTarget(final String controllerID) {
|
||||
public void deleteByControllerID(final String controllerID) {
|
||||
final Target target = targetRepository.findByControllerId(controllerID)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerID));
|
||||
|
||||
@@ -205,15 +205,15 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findTargetByAssignedDistributionSet(final Long distributionSetID, final Pageable pageReq) {
|
||||
public Page<Target> findByAssignedDistributionSet(final Pageable pageReq, final Long distributionSetID) {
|
||||
throwEntityNotFoundIfDsDoesNotExist(distributionSetID);
|
||||
|
||||
return targetRepository.findByAssignedDistributionSetId(pageReq, distributionSetID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findTargetByAssignedDistributionSet(final Long distributionSetID, final String rsqlParam,
|
||||
final Pageable pageReq) {
|
||||
public Page<Target> findByAssignedDistributionSetAndRsql(final Pageable pageReq, final Long distributionSetID,
|
||||
final String rsqlParam) {
|
||||
throwEntityNotFoundIfDsDoesNotExist(distributionSetID);
|
||||
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(rsqlParam, TargetFields.class, virtualPropertyReplacer);
|
||||
@@ -242,14 +242,14 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findTargetByInstalledDistributionSet(final Long distributionSetID, final Pageable pageReq) {
|
||||
public Page<Target> findByInstalledDistributionSet(final Pageable pageReq, final Long distributionSetID) {
|
||||
throwEntityNotFoundIfDsDoesNotExist(distributionSetID);
|
||||
return targetRepository.findByInstalledDistributionSetId(pageReq, distributionSetID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findTargetByInstalledDistributionSet(final Long distributionSetId, final String rsqlParam,
|
||||
final Pageable pageable) {
|
||||
public Page<Target> findByInstalledDistributionSetAndRsql(final Pageable pageable, final Long distributionSetId,
|
||||
final String rsqlParam) {
|
||||
throwEntityNotFoundIfDsDoesNotExist(distributionSetId);
|
||||
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(rsqlParam, TargetFields.class, virtualPropertyReplacer);
|
||||
@@ -264,27 +264,22 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findTargetByUpdateStatus(final Pageable pageable, final TargetUpdateStatus status) {
|
||||
public Page<Target> findByUpdateStatus(final Pageable pageable, final TargetUpdateStatus status) {
|
||||
return targetRepository.findByUpdateStatus(pageable, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Target> findTargetByFilters(final Pageable pageable, final Collection<TargetUpdateStatus> status,
|
||||
final Boolean overdueState, final String searchText, final Long installedOrAssignedDistributionSetId,
|
||||
final Boolean selectTargetWithNoTag, final String... tagNames) {
|
||||
final List<Specification<JpaTarget>> specList = buildSpecificationList(
|
||||
new FilterParams(installedOrAssignedDistributionSetId, status, overdueState, searchText,
|
||||
selectTargetWithNoTag, tagNames));
|
||||
public Slice<Target> findByFilters(final Pageable pageable, final FilterParams filterParams) {
|
||||
final List<Specification<JpaTarget>> specList = buildSpecificationList(filterParams);
|
||||
return findByCriteriaAPI(pageable, specList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countTargetByFilters(final Collection<TargetUpdateStatus> status, final Boolean overdueState,
|
||||
public long countByFilters(final Collection<TargetUpdateStatus> status, final Boolean overdueState,
|
||||
final String searchText, final Long installedOrAssignedDistributionSetId,
|
||||
final Boolean selectTargetWithNoTag, final String... tagNames) {
|
||||
final List<Specification<JpaTarget>> specList = buildSpecificationList(
|
||||
new FilterParams(installedOrAssignedDistributionSetId, status, overdueState, searchText,
|
||||
selectTargetWithNoTag, tagNames));
|
||||
final List<Specification<JpaTarget>> specList = buildSpecificationList(new FilterParams(status, overdueState,
|
||||
searchText, installedOrAssignedDistributionSetId, selectTargetWithNoTag, tagNames));
|
||||
return countByCriteriaAPI(specList);
|
||||
}
|
||||
|
||||
@@ -421,7 +416,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Target> findTargetsAllOrderByLinkedDistributionSet(final Pageable pageable,
|
||||
public Slice<Target> findByFilterOrderByLinkedDistributionSet(final Pageable pageable,
|
||||
final Long orderByDistributionId, final FilterParams filterParams) {
|
||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
final CriteriaQuery<JpaTarget> query = cb.createQuery(JpaTarget.class);
|
||||
@@ -475,22 +470,22 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countTargetByAssignedDistributionSet(final Long distId) {
|
||||
public long countByAssignedDistributionSet(final Long distId) {
|
||||
throwEntityNotFoundIfDsDoesNotExist(distId);
|
||||
|
||||
return targetRepository.countByAssignedDistributionSetId(distId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countTargetByInstalledDistributionSet(final Long distId) {
|
||||
public long countByInstalledDistributionSet(final Long distId) {
|
||||
throwEntityNotFoundIfDsDoesNotExist(distId);
|
||||
|
||||
return targetRepository.countByInstalledDistributionSetId(distId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findAllTargetsByTargetFilterQueryAndNonDS(final Pageable pageRequest,
|
||||
final Long distributionSetId, final String targetFilterQuery) {
|
||||
public Page<Target> findByTargetFilterQueryAndNonDS(final Pageable pageRequest, final Long distributionSetId,
|
||||
final String targetFilterQuery) {
|
||||
throwEntityNotFoundIfDsDoesNotExist(distributionSetId);
|
||||
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
||||
@@ -505,7 +500,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findAllTargetsByTargetFilterQueryAndNotInRolloutGroups(final Pageable pageRequest,
|
||||
public Page<Target> findByTargetFilterQueryAndNotInRolloutGroups(final Pageable pageRequest,
|
||||
final Collection<Long> groups, final String targetFilterQuery) {
|
||||
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
||||
@@ -517,7 +512,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findAllTargetsInRolloutGroupWithoutAction(@NotNull final Pageable pageRequest,
|
||||
public Page<Target> findByInRolloutGroupWithoutAction(@NotNull final Pageable pageRequest,
|
||||
@NotNull final Long group) {
|
||||
if (!rolloutGroupRepository.exists(group)) {
|
||||
throw new EntityNotFoundException(RolloutGroup.class, group);
|
||||
@@ -529,8 +524,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countAllTargetsByTargetFilterQueryAndNotInRolloutGroups(final Collection<Long> groups,
|
||||
final String targetFilterQuery) {
|
||||
public long countByRsqlAndNotInRolloutGroups(final Collection<Long> groups, final String targetFilterQuery) {
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
||||
virtualPropertyReplacer);
|
||||
final List<Specification<JpaTarget>> specList = Arrays.asList(spec,
|
||||
@@ -540,7 +534,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countTargetsByTargetFilterQueryAndNonDS(final Long distributionSetId, final String targetFilterQuery) {
|
||||
public long countByRsqlAndNonDS(final Long distributionSetId, final String targetFilterQuery) {
|
||||
throwEntityNotFoundIfDsDoesNotExist(distributionSetId);
|
||||
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
||||
@@ -556,7 +550,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Target createTarget(final TargetCreate c) {
|
||||
public Target create(final TargetCreate c) {
|
||||
final JpaTargetCreate create = (JpaTargetCreate) c;
|
||||
return targetRepository.save(create.build());
|
||||
}
|
||||
@@ -565,12 +559,12 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<Target> createTargets(final Collection<TargetCreate> targets) {
|
||||
return targets.stream().map(this::createTarget).collect(Collectors.toList());
|
||||
public List<Target> create(final Collection<TargetCreate> targets) {
|
||||
return targets.stream().map(this::create).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findTargetsByTag(final Pageable pageable, final Long tagId) {
|
||||
public Page<Target> findByTag(final Pageable pageable, final Long tagId) {
|
||||
throwEntityNotFoundExceptionIfTagDoesNotExist(tagId);
|
||||
|
||||
return convertPage(targetRepository.findByTag(pageable, tagId), pageable);
|
||||
@@ -583,7 +577,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findTargetsByTag(final Pageable pageable, final String rsqlParam, final Long tagId) {
|
||||
public Page<Target> findByRsqlAndTag(final Pageable pageable, final String rsqlParam, final Long tagId) {
|
||||
|
||||
throwEntityNotFoundExceptionIfTagDoesNotExist(tagId);
|
||||
|
||||
@@ -595,7 +589,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countTargetByTargetFilterQuery(final Long targetFilterQueryId) {
|
||||
public long countByTargetFilterQuery(final Long targetFilterQueryId) {
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryRepository.findById(targetFilterQueryId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId));
|
||||
|
||||
@@ -605,7 +599,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countTargetByTargetFilterQuery(final String targetFilterQuery) {
|
||||
public long countByRsql(final String targetFilterQuery) {
|
||||
final Specification<JpaTarget> specs = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
||||
virtualPropertyReplacer);
|
||||
return targetRepository.count((root, query, cb) -> {
|
||||
@@ -615,18 +609,18 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Target> findTargetById(final Long id) {
|
||||
public Optional<Target> get(final Long id) {
|
||||
return Optional.ofNullable(targetRepository.findOne(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Target> findTargetsById(final Collection<Long> ids) {
|
||||
public List<Target> get(final Collection<Long> ids) {
|
||||
return Collections.unmodifiableList(targetRepository.findAll(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getControllerAttributes(final String controllerId) {
|
||||
final JpaTarget target = (JpaTarget) findTargetByControllerID(controllerId)
|
||||
final JpaTarget target = (JpaTarget) getByControllerID(controllerId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||
|
||||
return target.getControllerAttributes();
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.TagFields;
|
||||
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.GenericTagUpdate;
|
||||
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.TagUpdate;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.jpa.builder.JpaTagCreate;
|
||||
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
|
||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.TagSpecification;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.retry.annotation.Backoff;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
* JPA implementation of {@link TargetTagManagement}.
|
||||
*
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
@Validated
|
||||
public class JpaTargetTagManagement implements TargetTagManagement {
|
||||
|
||||
private final TargetTagRepository targetTagRepository;
|
||||
|
||||
private final TargetRepository targetRepository;
|
||||
|
||||
private final VirtualPropertyReplacer virtualPropertyReplacer;
|
||||
|
||||
JpaTargetTagManagement(final TargetTagRepository targetTagRepository, final TargetRepository targetRepository,
|
||||
final VirtualPropertyReplacer virtualPropertyReplacer) {
|
||||
this.targetTagRepository = targetTagRepository;
|
||||
this.targetRepository = targetRepository;
|
||||
this.virtualPropertyReplacer = virtualPropertyReplacer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<TargetTag> getByName(final String name) {
|
||||
return targetTagRepository.findByNameEquals(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetTag create(final TagCreate c) {
|
||||
final JpaTagCreate create = (JpaTagCreate) c;
|
||||
|
||||
return targetTagRepository.save(create.buildTargetTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<TargetTag> create(final Collection<TagCreate> tt) {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
final Collection<JpaTagCreate> targetTags = (Collection) tt;
|
||||
|
||||
return Collections.unmodifiableList(targetTags.stream()
|
||||
.map(ttc -> targetTagRepository.save(ttc.buildTargetTag())).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final String targetTagName) {
|
||||
if (!targetTagRepository.existsByName(targetTagName)) {
|
||||
throw new EntityNotFoundException(TargetTag.class, targetTagName);
|
||||
}
|
||||
|
||||
// finally delete the tag itself
|
||||
targetTagRepository.deleteByName(targetTagName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetTag> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||
|
||||
final Specification<JpaTargetTag> spec = RSQLUtility.parse(rsqlParam, TagFields.class, virtualPropertyReplacer);
|
||||
return convertTPage(targetTagRepository.findAll(spec, pageable), pageable);
|
||||
}
|
||||
|
||||
private static Page<TargetTag> convertTPage(final Page<JpaTargetTag> findAll, final Pageable pageable) {
|
||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long count() {
|
||||
return targetTagRepository.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetTag update(final TagUpdate u) {
|
||||
final GenericTagUpdate update = (GenericTagUpdate) u;
|
||||
|
||||
final JpaTargetTag tag = targetTagRepository.findById(update.getId())
|
||||
.orElseThrow(() -> new EntityNotFoundException(TargetTag.class, update.getId()));
|
||||
|
||||
update.getName().ifPresent(tag::setName);
|
||||
update.getDescription().ifPresent(tag::setDescription);
|
||||
update.getColour().ifPresent(tag::setColour);
|
||||
|
||||
return targetTagRepository.save(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<TargetTag> get(final Long id) {
|
||||
return Optional.ofNullable(targetTagRepository.findOne(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetTag> findAll(final Pageable pageable) {
|
||||
return convertTPage(targetTagRepository.findAll(pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetTag> findByTarget(final Pageable pageable, final String controllerId) {
|
||||
if (!targetRepository.existsByControllerId(controllerId)) {
|
||||
throw new EntityNotFoundException(Target.class, controllerId);
|
||||
}
|
||||
|
||||
return convertTPage(targetTagRepository.findAll(TagSpecification.ofTarget(controllerId), pageable), pageable);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||
import org.eclipse.hawkbit.repository.ControllerManagement;
|
||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.PropertiesQuotaManagement;
|
||||
@@ -28,9 +29,9 @@ import org.eclipse.hawkbit.repository.RolloutStatusCache;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.repository.TenantStatsManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetBuilder;
|
||||
@@ -165,8 +166,9 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
||||
* @return DistributionSetTypeBuilder bean
|
||||
*/
|
||||
@Bean
|
||||
DistributionSetTypeBuilder distributionSetTypeBuilder(final SoftwareModuleManagement softwareManagement) {
|
||||
return new JpaDistributionSetTypeBuilder(softwareManagement);
|
||||
DistributionSetTypeBuilder distributionSetTypeBuilder(
|
||||
final SoftwareModuleTypeManagement softwareModuleTypeManagement) {
|
||||
return new JpaDistributionSetTypeBuilder(softwareModuleTypeManagement);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -369,9 +371,9 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
||||
final DistributionSetTypeRepository distributionSetTypeRepository,
|
||||
final SoftwareModuleTypeRepository softwareModuleTypeRepository,
|
||||
final DistributionSetRepository distributionSetRepository,
|
||||
final VirtualPropertyReplacer virtualPropertyReplacer) {
|
||||
final VirtualPropertyReplacer virtualPropertyReplacer, final NoCountPagingRepository criteriaNoCountDao) {
|
||||
return new JpaDistributionSetTypeManagement(distributionSetTypeRepository, softwareModuleTypeRepository,
|
||||
distributionSetRepository, virtualPropertyReplacer);
|
||||
distributionSetRepository, virtualPropertyReplacer, criteriaNoCountDao);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -430,14 +432,30 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link JpaTagManagement} bean.
|
||||
* {@link JpaTargetTagManagement} bean.
|
||||
*
|
||||
* @return a new {@link TagManagement}
|
||||
* @return a new {@link TargetTagManagement}
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
TagManagement tagManagement() {
|
||||
return new JpaTagManagement();
|
||||
TargetTagManagement targetTagManagement(final TargetTagRepository targetTagRepository,
|
||||
final TargetRepository targetRepository, final VirtualPropertyReplacer virtualPropertyReplacer) {
|
||||
return new JpaTargetTagManagement(targetTagRepository, targetRepository, virtualPropertyReplacer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link JpaDistributionSetTagManagement} bean.
|
||||
*
|
||||
* @return a new {@link JpaDistributionSetTagManagement}
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
DistributionSetTagManagement distributionSetTagManagement(
|
||||
final DistributionSetTagRepository distributionSetTagRepository,
|
||||
final DistributionSetRepository distributionSetRepository,
|
||||
final VirtualPropertyReplacer virtualPropertyReplacer, final NoCountPagingRepository criteriaNoCountDao) {
|
||||
return new JpaDistributionSetTagManagement(distributionSetTagRepository, distributionSetRepository,
|
||||
virtualPropertyReplacer, criteriaNoCountDao);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -462,9 +480,9 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
||||
final DistributionSetTypeRepository distributionSetTypeRepository,
|
||||
final SoftwareModuleTypeRepository softwareModuleTypeRepository,
|
||||
final VirtualPropertyReplacer virtualPropertyReplacer,
|
||||
final SoftwareModuleRepository softwareModuleRepository) {
|
||||
final SoftwareModuleRepository softwareModuleRepository, final NoCountPagingRepository criteriaNoCountDao) {
|
||||
return new JpaSoftwareModuleTypeManagement(distributionSetTypeRepository, softwareModuleTypeRepository,
|
||||
virtualPropertyReplacer, softwareModuleRepository);
|
||||
virtualPropertyReplacer, softwareModuleRepository, criteriaNoCountDao);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -537,7 +555,7 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public EntityFactory entityFactory() {
|
||||
EntityFactory entityFactory() {
|
||||
return new JpaEntityFactory();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,6 @@ package org.eclipse.hawkbit.repository.jpa;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleMetadata;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.SwMetadataCompositeKey;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -26,15 +24,4 @@ public interface SoftwareModuleMetadataRepository
|
||||
extends PagingAndSortingRepository<JpaSoftwareModuleMetadata, SwMetadataCompositeKey>,
|
||||
JpaSpecificationExecutor<JpaSoftwareModuleMetadata> {
|
||||
|
||||
/**
|
||||
* finds all software module meta data of the given software module id.
|
||||
*
|
||||
* @param swId
|
||||
* the ID of the software module to retrieve the meta data
|
||||
* @param pageable
|
||||
* the page request to page the result set
|
||||
* @return the paged result of all meta data of an given software module id
|
||||
*/
|
||||
Page<SoftwareModuleMetadata> findBySoftwareModuleId(final Long swId, Pageable pageable);
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.util.Optional;
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -68,18 +67,6 @@ public interface SoftwareModuleTypeRepository
|
||||
*/
|
||||
Optional<SoftwareModuleType> findByName(String name);
|
||||
|
||||
/**
|
||||
* retrieves all software module types with a given
|
||||
* {@link SoftwareModuleType#getId()}.
|
||||
*
|
||||
* @param ids
|
||||
* to search for
|
||||
* @return {@link List} of found {@link SoftwareModule}s
|
||||
*/
|
||||
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477
|
||||
@Query("SELECT sm FROM JpaSoftwareModuleType sm WHERE sm.id IN ?1")
|
||||
List<JpaSoftwareModuleType> findByIdIn(Iterable<Long> ids);
|
||||
|
||||
/**
|
||||
* Deletes all {@link TenantAwareBaseEntity} of a given tenant. For safety
|
||||
* reasons (this is a "delete everything" query after all) we add the tenant
|
||||
@@ -93,4 +80,9 @@ public interface SoftwareModuleTypeRepository
|
||||
@Transactional
|
||||
@Query("DELETE FROM JpaSoftwareModuleType t WHERE t.tenant = :tenant")
|
||||
void deleteByTenant(@Param("tenant") String tenant);
|
||||
|
||||
@Override
|
||||
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477
|
||||
@Query("SELECT d FROM JpaSoftwareModuleType d WHERE d.id IN ?1")
|
||||
List<JpaSoftwareModuleType> findAll(Iterable<Long> ids);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class AutoAssignChecker {
|
||||
final PageRequest pageRequest = new PageRequest(0, PAGE_SIZE);
|
||||
|
||||
final Page<TargetFilterQuery> filterQueries = targetFilterQueryManagement
|
||||
.findTargetFilterQueryWithAutoAssignDS(pageRequest);
|
||||
.findWithAutoAssignDS(pageRequest);
|
||||
|
||||
for (final TargetFilterQuery filterQuery : filterQueries) {
|
||||
checkByTargetFilterQueryAndAssignDS(filterQuery);
|
||||
@@ -176,7 +176,7 @@ public class AutoAssignChecker {
|
||||
private List<TargetWithActionType> getTargetsWithActionType(final String targetFilterQuery, final Long dsId,
|
||||
final int count) {
|
||||
final Page<Target> targets = targetManagement
|
||||
.findAllTargetsByTargetFilterQueryAndNonDS(new PageRequest(0, count), dsId, targetFilterQuery);
|
||||
.findByTargetFilterQueryAndNonDS(new PageRequest(0, count), dsId, targetFilterQuery);
|
||||
|
||||
return targets.getContent().stream().map(t -> new TargetWithActionType(t.getControllerId(),
|
||||
Action.ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME)).collect(Collectors.toList());
|
||||
|
||||
@@ -47,7 +47,7 @@ public class JpaDistributionSetCreate extends AbstractDistributionSetUpdateCreat
|
||||
}
|
||||
|
||||
private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final String distributionSetTypekey) {
|
||||
return distributionSetTypeManagement.findDistributionSetTypeByKey(distributionSetTypekey)
|
||||
return distributionSetTypeManagement.getByKey(distributionSetTypekey)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distributionSetTypekey));
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class JpaDistributionSetCreate extends AbstractDistributionSetUpdateCreat
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final Collection<SoftwareModule> module = softwareModuleManagement.findSoftwareModulesById(softwareModuleId);
|
||||
final Collection<SoftwareModule> module = softwareModuleManagement.get(softwareModuleId);
|
||||
if (module.size() < softwareModuleId.size()) {
|
||||
throw new EntityNotFoundException(SoftwareModule.class, softwareModuleId);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.builder;
|
||||
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeBuilder;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeUpdate;
|
||||
@@ -21,10 +21,10 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
*/
|
||||
public class JpaDistributionSetTypeBuilder implements DistributionSetTypeBuilder {
|
||||
|
||||
private final SoftwareModuleManagement softwareModuleManagement;
|
||||
private final SoftwareModuleTypeManagement softwareModuleTypeManagement;
|
||||
|
||||
public JpaDistributionSetTypeBuilder(final SoftwareModuleManagement softwareManagement) {
|
||||
this.softwareModuleManagement = softwareManagement;
|
||||
public JpaDistributionSetTypeBuilder(final SoftwareModuleTypeManagement softwareModuleTypeManagement) {
|
||||
this.softwareModuleTypeManagement = softwareModuleTypeManagement;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,7 +34,7 @@ public class JpaDistributionSetTypeBuilder implements DistributionSetTypeBuilder
|
||||
|
||||
@Override
|
||||
public DistributionSetTypeCreate create() {
|
||||
return new JpaDistributionSetTypeCreate(softwareModuleManagement);
|
||||
return new JpaDistributionSetTypeCreate(softwareModuleTypeManagement);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.repository.jpa.builder;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.AbstractDistributionSetTypeUpdateCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeCreate;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
@@ -26,10 +26,10 @@ import org.springframework.util.CollectionUtils;
|
||||
public class JpaDistributionSetTypeCreate extends AbstractDistributionSetTypeUpdateCreate<DistributionSetTypeCreate>
|
||||
implements DistributionSetTypeCreate {
|
||||
|
||||
private final SoftwareModuleManagement softwareModuleManagement;
|
||||
private final SoftwareModuleTypeManagement softwareModuleTypeManagement;
|
||||
|
||||
JpaDistributionSetTypeCreate(final SoftwareModuleManagement softwareManagement) {
|
||||
this.softwareModuleManagement = softwareManagement;
|
||||
JpaDistributionSetTypeCreate(final SoftwareModuleTypeManagement softwareModuleTypeManagement) {
|
||||
this.softwareModuleTypeManagement = softwareModuleTypeManagement;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,8 +48,7 @@ public class JpaDistributionSetTypeCreate extends AbstractDistributionSetTypeUpd
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final Collection<SoftwareModuleType> module = softwareModuleManagement
|
||||
.findSoftwareModuleTypesById(softwareModuleTypeId);
|
||||
final Collection<SoftwareModuleType> module = softwareModuleTypeManagement.get(softwareModuleTypeId);
|
||||
if (module.size() < softwareModuleTypeId.size()) {
|
||||
throw new EntityNotFoundException(SoftwareModuleType.class, softwareModuleTypeId);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class JpaRolloutCreate extends AbstractRolloutUpdateCreate<RolloutCreate>
|
||||
}
|
||||
|
||||
private DistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) {
|
||||
return distributionSetManagement.findDistributionSetById(setId)
|
||||
return distributionSetManagement.get(setId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, setId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class JpaSoftwareModuleCreate extends AbstractSoftwareModuleUpdateCreate<
|
||||
throw new ValidationException("type cannot be null");
|
||||
}
|
||||
|
||||
return softwareModuleTypeManagement.findSoftwareModuleTypeByKey(type.trim())
|
||||
return softwareModuleTypeManagement.getByKey(type.trim())
|
||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, type.trim()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class JpaTargetFilterQueryCreate extends AbstractTargetFilterQueryUpdateC
|
||||
}
|
||||
|
||||
private DistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) {
|
||||
return distributionSetManagement.findDistributionSetById(setId)
|
||||
return distributionSetManagement.get(setId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, setId));
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.google.common.base.Splitter;
|
||||
/**
|
||||
* Entity to store the status for a specific action.
|
||||
*/
|
||||
@Table(name = "sp_action_status", indexes = { @Index(name = "sp_idx_action_status_01", columnList = "tenant,action"),
|
||||
@Table(name = "sp_action_status", indexes = {
|
||||
@Index(name = "sp_idx_action_status_02", columnList = "tenant,action,status"),
|
||||
@Index(name = "sp_idx_action_status_prim", columnList = "tenant,id") })
|
||||
@NamedEntityGraph(name = "ActionStatus.withMessages", attributeNodes = { @NamedAttributeNode("messages") })
|
||||
|
||||
@@ -60,8 +60,7 @@ import org.springframework.context.ApplicationEvent;
|
||||
@Entity
|
||||
@Table(name = "sp_distribution_set", uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = { "name", "version", "tenant" }, name = "uk_distrib_set") }, indexes = {
|
||||
@Index(name = "sp_idx_distribution_set_01", columnList = "tenant,deleted,name,complete"),
|
||||
@Index(name = "sp_idx_distribution_set_02", columnList = "tenant,required_migration_step"),
|
||||
@Index(name = "sp_idx_distribution_set_01", columnList = "tenant,deleted,complete"),
|
||||
@Index(name = "sp_idx_distribution_set_prim", columnList = "tenant,id") })
|
||||
@NamedEntityGraph(name = "DistributionSet.detail", attributeNodes = { @NamedAttributeNode("modules"),
|
||||
@NamedAttributeNode("tags"), @NamedAttributeNode("type") })
|
||||
|
||||
@@ -19,7 +19,6 @@ import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.Index;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
@@ -52,9 +51,8 @@ import org.hibernate.validator.constraints.NotEmpty;
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "sp_rollout", indexes = {
|
||||
@Index(name = "sp_idx_rollout_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||
"name", "tenant" }, name = "uk_rollout"))
|
||||
@Table(name = "sp_rollout", uniqueConstraints = @UniqueConstraint(columnNames = { "name",
|
||||
"tenant" }, name = "uk_rollout"))
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
|
||||
@@ -17,7 +17,6 @@ import javax.persistence.ConstraintMode;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.Index;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
@@ -44,9 +43,8 @@ import org.eclipse.persistence.descriptors.DescriptorEvent;
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "sp_rolloutgroup", indexes = {
|
||||
@Index(name = "sp_idx_rolloutgroup_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||
"name", "rollout", "tenant" }, name = "uk_rolloutgroup"))
|
||||
@Table(name = "sp_rolloutgroup", uniqueConstraints = @UniqueConstraint(columnNames = { "name", "rollout",
|
||||
"tenant" }, name = "uk_rolloutgroup"))
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
|
||||
@@ -32,9 +32,9 @@ public class JpaSoftwareModuleMetadata extends JpaMetaData implements SoftwareMo
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@ManyToOne(optional = false, targetEntity = JpaSoftwareModule.class, fetch = FetchType.LAZY)
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "sw_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_sw"))
|
||||
private SoftwareModule softwareModule;
|
||||
private JpaSoftwareModule softwareModule;
|
||||
|
||||
public JpaSoftwareModuleMetadata() {
|
||||
// default public constructor for JPA
|
||||
@@ -42,7 +42,7 @@ public class JpaSoftwareModuleMetadata extends JpaMetaData implements SoftwareMo
|
||||
|
||||
public JpaSoftwareModuleMetadata(final String key, final SoftwareModule softwareModule, final String value) {
|
||||
super(key, value);
|
||||
this.softwareModule = softwareModule;
|
||||
this.softwareModule = (JpaSoftwareModule) softwareModule;
|
||||
}
|
||||
|
||||
public SwMetadataCompositeKey getId() {
|
||||
@@ -54,7 +54,7 @@ public class JpaSoftwareModuleMetadata extends JpaMetaData implements SoftwareMo
|
||||
return softwareModule;
|
||||
}
|
||||
|
||||
public void setSoftwareModule(final SoftwareModule softwareModule) {
|
||||
public void setSoftwareModule(final JpaSoftwareModule softwareModule) {
|
||||
this.softwareModule = softwareModule;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,6 @@ import org.slf4j.LoggerFactory;
|
||||
@Entity
|
||||
@Table(name = "sp_target", indexes = {
|
||||
@Index(name = "sp_idx_target_01", columnList = "tenant,name,assigned_distribution_set"),
|
||||
@Index(name = "sp_idx_target_02", columnList = "tenant,name"),
|
||||
@Index(name = "sp_idx_target_03", columnList = "tenant,controller_id,assigned_distribution_set"),
|
||||
@Index(name = "sp_idx_target_04", columnList = "tenant,created_at"),
|
||||
@Index(name = "sp_idx_target_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||
|
||||
@@ -13,7 +13,6 @@ import javax.persistence.ConstraintMode;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.Index;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
@@ -30,9 +29,8 @@ import org.hibernate.validator.constraints.NotEmpty;
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "sp_target_filter_query", indexes = {
|
||||
@Index(name = "sp_idx_target_filter_query_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||
"name", "tenant" }, name = "uk_tenant_custom_filter_name"))
|
||||
@Table(name = "sp_target_filter_query", uniqueConstraints = @UniqueConstraint(columnNames = { "name",
|
||||
"tenant" }, name = "uk_tenant_custom_filter_name"))
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
|
||||
@@ -74,7 +74,7 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
||||
context.setSyntaxErrorContext(errorContext);
|
||||
|
||||
try {
|
||||
targetManagement.findTargetsAll(rsqlQuery, new PageRequest(0, 1));
|
||||
targetManagement.findByRsql(new PageRequest(0, 1), rsqlQuery);
|
||||
context.setSyntaxError(false);
|
||||
suggestionContext.getSuggestions().addAll(getLogicalOperatorSuggestion(rsqlQuery));
|
||||
} catch (final RSQLParameterSyntaxException | RSQLParserException ex) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
ALTER TABLE sp_action_status DROP INDEX sp_idx_action_status_01;
|
||||
ALTER TABLE sp_rollout DROP INDEX sp_idx_rollout_01;
|
||||
ALTER TABLE sp_rolloutgroup DROP INDEX sp_idx_rolloutgroup_01;
|
||||
ALTER TABLE sp_target DROP INDEX sp_idx_target_02;
|
||||
ALTER TABLE sp_target_filter_query DROP INDEX sp_idx_target_filter_query_01;
|
||||
ALTER TABLE sp_distribution_set DROP INDEX sp_idx_distribution_set_01;
|
||||
ALTER TABLE sp_distribution_set DROP INDEX sp_idx_distribution_set_02;
|
||||
CREATE INDEX sp_idx_distribution_set_01 ON sp_distribution_set (tenant, deleted, complete);
|
||||
@@ -0,0 +1,8 @@
|
||||
ALTER TABLE sp_action_status DROP INDEX sp_idx_action_status_01;
|
||||
ALTER TABLE sp_rollout DROP INDEX sp_idx_rollout_01;
|
||||
ALTER TABLE sp_rolloutgroup DROP INDEX sp_idx_rolloutgroup_01;
|
||||
ALTER TABLE sp_target DROP INDEX sp_idx_target_02;
|
||||
ALTER TABLE sp_target_filter_query DROP INDEX sp_idx_target_filter_query_01;
|
||||
ALTER TABLE sp_distribution_set DROP INDEX sp_idx_distribution_set_01;
|
||||
ALTER TABLE sp_distribution_set DROP INDEX sp_idx_distribution_set_02;
|
||||
CREATE INDEX sp_idx_distribution_set_01 ON sp_distribution_set (tenant, deleted, complete);
|
||||
@@ -30,7 +30,7 @@ public class DistributionSetCreatedEventTest extends AbstractRemoteEntityEventTe
|
||||
|
||||
@Override
|
||||
protected DistributionSet createEntity() {
|
||||
return distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create()
|
||||
return distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("incomplete").version("2").description("incomplete").type("os"));
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class DistributionSetTagEventTest extends AbstractRemoteEntityEventTest<D
|
||||
|
||||
@Override
|
||||
protected DistributionSetTag createEntity() {
|
||||
return tagManagement.createDistributionSetTag(entityFactory.tag().create().name("tag1"));
|
||||
return distributionSetTagManagement.create(entityFactory.tag().create().name("tag1"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DistributionSetUpdatedEventTest extends AbstractRemoteEntityEventTe
|
||||
|
||||
@Override
|
||||
protected DistributionSet createEntity() {
|
||||
return distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create()
|
||||
return distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("incomplete").version("2").description("incomplete").type("os"));
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,10 @@ public class RolloutEventTest extends AbstractRemoteEntityEventTest<Rollout> {
|
||||
@Override
|
||||
protected Rollout createEntity() {
|
||||
testdataFactory.createTarget("12345");
|
||||
final DistributionSet ds = distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
final DistributionSet ds = distributionSetManagement.create(entityFactory.distributionSet()
|
||||
.create().name("incomplete").version("2").description("incomplete").type("os"));
|
||||
|
||||
return rolloutManagement.createRollout(
|
||||
return rolloutManagement.create(
|
||||
entityFactory.rollout().create().name("exampleRollout").targetFilterQuery("controllerId==*").set(ds),
|
||||
10, new RolloutGroupConditionBuilder().withDefaults()
|
||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
|
||||
|
||||
@@ -91,15 +91,15 @@ public class RolloutGroupEventTest extends AbstractRemoteEntityEventTest<Rollout
|
||||
protected RolloutGroup createEntity() {
|
||||
testdataFactory.createTarget(UUID.randomUUID().toString());
|
||||
|
||||
final DistributionSet ds = distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
final DistributionSet ds = distributionSetManagement.create(entityFactory.distributionSet()
|
||||
.create().name("incomplete").version("2").description("incomplete").type("os"));
|
||||
|
||||
final Rollout entity = rolloutManagement.createRollout(
|
||||
final Rollout entity = rolloutManagement.create(
|
||||
entityFactory.rollout().create().name("exampleRollout").targetFilterQuery("controllerId==*").set(ds),
|
||||
10, new RolloutGroupConditionBuilder().withDefaults()
|
||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
|
||||
|
||||
return rolloutGroupManagement.findRolloutGroupsByRolloutId(entity.getId(), PAGE).getContent().get(0);
|
||||
return rolloutGroupManagement.findByRollout(PAGE, entity.getId()).getContent().get(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class TargetTagEventTest extends AbstractRemoteEntityEventTest<TargetTag>
|
||||
|
||||
@Override
|
||||
protected TargetTag createEntity() {
|
||||
return tagManagement.createTargetTag(entityFactory.tag().create().name("tag1"));
|
||||
return targetTagManagement.create(entityFactory.tag().create().name("tag1"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,11 +53,11 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
final SoftwareModule module = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
assertThat(artifactManagement.findArtifact(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(artifactManagement.findByFilenameAndSoftwareModule(NOT_EXIST_ID, module.getId()).isPresent())
|
||||
assertThat(artifactManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(artifactManagement.getByFilenameAndSoftwareModule(NOT_EXIST_ID, module.getId()).isPresent())
|
||||
.isFalse();
|
||||
|
||||
assertThat(artifactManagement.findFirstArtifactBySHA1(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(artifactManagement.findFirstBySHA1(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(artifactManagement.loadArtifactBinary(NOT_EXIST_ID)).isNotPresent();
|
||||
}
|
||||
|
||||
@@ -67,20 +67,20 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
@ExpectEvents({ @Expect(type = SoftwareModuleDeletedEvent.class, count = 0) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() throws URISyntaxException {
|
||||
|
||||
verifyThrownExceptionBy(() -> artifactManagement.createArtifact(IOUtils.toInputStream("test", "UTF-8"),
|
||||
verifyThrownExceptionBy(() -> artifactManagement.create(IOUtils.toInputStream("test", "UTF-8"),
|
||||
NOT_EXIST_IDL, "xxx", null, null, false, null), "SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> artifactManagement.createArtifact(IOUtils.toInputStream("test", "UTF-8"), 1234L, "xxx", false),
|
||||
() -> artifactManagement.create(IOUtils.toInputStream("test", "UTF-8"), 1234L, "xxx", false),
|
||||
"SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(() -> artifactManagement.deleteArtifact(NOT_EXIST_IDL), "Artifact");
|
||||
verifyThrownExceptionBy(() -> artifactManagement.delete(NOT_EXIST_IDL), "Artifact");
|
||||
|
||||
verifyThrownExceptionBy(() -> artifactManagement.findArtifactBySoftwareModule(PAGE, NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> artifactManagement.findBySoftwareModule(PAGE, NOT_EXIST_IDL),
|
||||
"SoftwareModule");
|
||||
assertThat(artifactManagement.findArtifactByFilename(NOT_EXIST_ID).isPresent()).isFalse();
|
||||
assertThat(artifactManagement.getByFilename(NOT_EXIST_ID).isPresent()).isFalse();
|
||||
|
||||
verifyThrownExceptionBy(() -> artifactManagement.findByFilenameAndSoftwareModule("xxx", NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> artifactManagement.getByFilenameAndSoftwareModule("xxx", NOT_EXIST_IDL),
|
||||
"SoftwareModule");
|
||||
}
|
||||
|
||||
@@ -102,11 +102,11 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
|
||||
final Artifact result = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1",
|
||||
final Artifact result = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file1",
|
||||
false);
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file11", false);
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file12", false);
|
||||
final Artifact result2 = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm2.getId(),
|
||||
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file11", false);
|
||||
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file12", false);
|
||||
final Artifact result2 = artifactManagement.create(new ByteArrayInputStream(random), sm2.getId(),
|
||||
"file2", false);
|
||||
|
||||
assertThat(result).isInstanceOf(Artifact.class);
|
||||
@@ -117,15 +117,15 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(result).isNotEqualTo(result2);
|
||||
assertThat(((JpaArtifact) result).getSha1Hash()).isEqualTo(((JpaArtifact) result2).getSha1Hash());
|
||||
|
||||
assertThat(artifactManagement.findArtifactByFilename("file1").get().getSha1Hash())
|
||||
assertThat(artifactManagement.getByFilename("file1").get().getSha1Hash())
|
||||
.isEqualTo(HashGeneratorUtils.generateSHA1(random));
|
||||
assertThat(artifactManagement.findArtifactByFilename("file1").get().getMd5Hash())
|
||||
assertThat(artifactManagement.getByFilename("file1").get().getMd5Hash())
|
||||
.isEqualTo(HashGeneratorUtils.generateMD5(random));
|
||||
|
||||
assertThat(artifactRepository.findAll()).hasSize(4);
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(3);
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts()).hasSize(3);
|
||||
assertThat(softwareModuleManagement.get(sm.getId()).get().getArtifacts()).hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -136,7 +136,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
||||
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
||||
assertThat(artifactRepository.findAll()).hasSize(1);
|
||||
|
||||
softwareModuleRepository.deleteAll();
|
||||
@@ -145,7 +145,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.eclipse.hawkbit.repository.ArtifactManagement#deleteArtifact(java.lang.Long)}
|
||||
* {@link org.eclipse.hawkbit.repository.ArtifactManagement#delete(java.lang.Long)}
|
||||
* .
|
||||
*
|
||||
* @throws IOException
|
||||
@@ -162,9 +162,9 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
assertThat(artifactRepository.findAll()).isEmpty();
|
||||
|
||||
final Artifact result = artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), sm.getId(),
|
||||
final Artifact result = artifactManagement.create(new RandomGeneratedInputStream(5 * 1024), sm.getId(),
|
||||
"file1", false);
|
||||
final Artifact result2 = artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024),
|
||||
final Artifact result2 = artifactManagement.create(new RandomGeneratedInputStream(5 * 1024),
|
||||
sm2.getId(), "file2", false);
|
||||
|
||||
assertThat(artifactRepository.findAll()).hasSize(2);
|
||||
@@ -178,14 +178,14 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result2.getSha1Hash()))
|
||||
.isNotNull();
|
||||
|
||||
artifactManagement.deleteArtifact(result.getId());
|
||||
artifactManagement.delete(result.getId());
|
||||
|
||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
||||
.isNull();
|
||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result2.getSha1Hash()))
|
||||
.isNotNull();
|
||||
|
||||
artifactManagement.deleteArtifact(result2.getId());
|
||||
artifactManagement.delete(result2.getId());
|
||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result2.getSha1Hash()))
|
||||
.isNull();
|
||||
|
||||
@@ -204,9 +204,9 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
|
||||
final Artifact result = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1",
|
||||
final Artifact result = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file1",
|
||||
false);
|
||||
final Artifact result2 = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm2.getId(),
|
||||
final Artifact result2 = artifactManagement.create(new ByteArrayInputStream(random), sm2.getId(),
|
||||
"file2", false);
|
||||
|
||||
assertThat(artifactRepository.findAll()).hasSize(2);
|
||||
@@ -216,11 +216,11 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
||||
.isNotNull();
|
||||
artifactManagement.deleteArtifact(result.getId());
|
||||
artifactManagement.delete(result.getId());
|
||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
||||
.isNotNull();
|
||||
|
||||
artifactManagement.deleteArtifact(result2.getId());
|
||||
artifactManagement.delete(result2.getId());
|
||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
||||
.isNull();
|
||||
}
|
||||
@@ -228,10 +228,10 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Loads an local artifact based on given ID.")
|
||||
public void findArtifact() throws NoSuchAlgorithmException, IOException {
|
||||
final Artifact result = artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024),
|
||||
final Artifact result = artifactManagement.create(new RandomGeneratedInputStream(5 * 1024),
|
||||
testdataFactory.createSoftwareModuleOs().getId(), "file1", false);
|
||||
|
||||
assertThat(artifactManagement.findArtifact(result.getId()).get()).isEqualTo(result);
|
||||
assertThat(artifactManagement.get(result.getId()).get()).isEqualTo(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -239,7 +239,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void loadStreamOfArtifact() throws NoSuchAlgorithmException, IOException {
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
|
||||
final Artifact result = artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
||||
final Artifact result = artifactManagement.create(new ByteArrayInputStream(random),
|
||||
testdataFactory.createSoftwareModuleOs().getId(), "file1", false);
|
||||
|
||||
try (InputStream fileInputStream = artifactManagement.loadArtifactBinary(result.getSha1Hash()).get()
|
||||
@@ -266,11 +266,11 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void findArtifactBySoftwareModule() {
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
assertThat(artifactManagement.findArtifactBySoftwareModule(PAGE, sm.getId())).isEmpty();
|
||||
assertThat(artifactManagement.findBySoftwareModule(PAGE, sm.getId())).isEmpty();
|
||||
|
||||
artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file1", false);
|
||||
artifactManagement.create(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file1", false);
|
||||
|
||||
assertThat(artifactManagement.findArtifactBySoftwareModule(PAGE, sm.getId())).hasSize(1);
|
||||
assertThat(artifactManagement.findBySoftwareModule(PAGE, sm.getId())).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -278,12 +278,12 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void findByFilenameAndSoftwareModule() {
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
assertThat(artifactManagement.findByFilenameAndSoftwareModule("file1", sm.getId())).isNotPresent();
|
||||
assertThat(artifactManagement.getByFilenameAndSoftwareModule("file1", sm.getId())).isNotPresent();
|
||||
|
||||
artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file1", false);
|
||||
artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file2", false);
|
||||
artifactManagement.create(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file1", false);
|
||||
artifactManagement.create(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file2", false);
|
||||
|
||||
assertThat(artifactManagement.findByFilenameAndSoftwareModule("file1", sm.getId())).isPresent();
|
||||
assertThat(artifactManagement.getByFilenameAndSoftwareModule("file1", sm.getId())).isPresent();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule module = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
assertThat(controllerManagement.findActionWithDetails(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(controllerManagement.findByControllerId(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(controllerManagement.findByTargetId(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(controllerManagement.getByControllerId(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(controllerManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(controllerManagement.getActionForDownloadByTargetAndSoftwareModule(target.getControllerId(),
|
||||
module.getId())).isNotPresent();
|
||||
|
||||
@@ -308,8 +308,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Long dsId = testdataFactory.createDistributionSet().getId();
|
||||
testdataFactory.createTarget();
|
||||
assignDistributionSet(dsId, TestdataFactory.DEFAULT_CONTROLLER_ID);
|
||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
||||
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
return deploymentManagement.findActiveActionsByTarget(PAGE, TestdataFactory.DEFAULT_CONTROLLER_ID).getContent()
|
||||
.get(0).getId();
|
||||
@@ -364,7 +364,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void assertActionStatus(final Long actionId, final String controllerId,
|
||||
final TargetUpdateStatus expectedTargetUpdateStatus, final Action.Status expectedActionActionStatus,
|
||||
final Action.Status expectedActionStatus, final boolean actionActive) {
|
||||
final TargetUpdateStatus targetStatus = targetManagement.findTargetByControllerID(controllerId).get()
|
||||
final TargetUpdateStatus targetStatus = targetManagement.getByControllerID(controllerId).get()
|
||||
.getUpdateStatus();
|
||||
assertThat(targetStatus).isEqualTo(expectedTargetUpdateStatus);
|
||||
final Action action = deploymentManagement.findAction(actionId).get();
|
||||
@@ -396,9 +396,9 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
Target savedTarget = testdataFactory.createTarget();
|
||||
|
||||
// create two artifacts with identical SHA1 hash
|
||||
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
||||
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random),
|
||||
ds.findFirstModuleByType(osType).get().getId(), "file1", false);
|
||||
final Artifact artifact2 = artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
||||
final Artifact artifact2 = artifactManagement.create(new ByteArrayInputStream(random),
|
||||
ds2.findFirstModuleByType(osType).get().getId(), "file1", false);
|
||||
assertThat(artifact.getSha1Hash()).isEqualTo(artifact2.getSha1Hash());
|
||||
|
||||
@@ -531,8 +531,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
entityFactory.actionStatus().create(action.getId()).status(Action.Status.RUNNING));
|
||||
|
||||
// nothing changed as "feedback after close" is disabled
|
||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
||||
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(3);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, action.getId()).getNumberOfElements())
|
||||
@@ -556,8 +556,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
entityFactory.actionStatus().create(action.getId()).status(Action.Status.RUNNING));
|
||||
|
||||
// nothing changed as "feedback after close" is disabled
|
||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
||||
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
|
||||
// however, additional action status has been stored
|
||||
assertThat(actionStatusRepository.findAll(PAGE).getNumberOfElements()).isEqualTo(4);
|
||||
@@ -581,7 +581,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
});
|
||||
|
||||
// verify that audit information has not changed
|
||||
final Target targetVerify = targetManagement.findTargetByControllerID(controllerId).get();
|
||||
final Target targetVerify = targetManagement.getByControllerID(controllerId).get();
|
||||
assertThat(targetVerify.getCreatedBy()).isEqualTo(target.getCreatedBy());
|
||||
assertThat(targetVerify.getCreatedAt()).isEqualTo(target.getCreatedAt());
|
||||
assertThat(targetVerify.getLastModifiedBy()).isEqualTo(target.getLastModifiedBy());
|
||||
|
||||
@@ -40,6 +40,8 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaActionStatus;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetSpecification;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.SpecificationsBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
@@ -223,8 +225,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
// not exists
|
||||
assignDS.add(100L);
|
||||
|
||||
final DistributionSetTag tag = tagManagement
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("Tag1"));
|
||||
final DistributionSetTag tag = distributionSetTagManagement.create(entityFactory.tag().create().name("Tag1"));
|
||||
|
||||
assertThatExceptionOfType(EntityNotFoundException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.assignTag(assignDS, tag.getId()))
|
||||
@@ -271,8 +272,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet dsInstalled = action.getDistributionSet();
|
||||
|
||||
// check initial status
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
||||
.as("target has update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("target has update status")
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
|
||||
// assign the two sets in a row
|
||||
JpaAction firstAction = assignSet(target, dsFirst);
|
||||
@@ -289,7 +290,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
entityFactory.actionStatus().create(secondAction.getId()).status(Status.CANCELED));
|
||||
assertThat(actionStatusRepository.findAll()).as("wrong size of actions status").hasSize(7);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong ds").isEqualTo(dsFirst);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
// we cancel first -> back to installed
|
||||
@@ -301,7 +302,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(9);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong assigned ds")
|
||||
.isEqualTo(dsInstalled);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
}
|
||||
|
||||
@@ -317,7 +318,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet dsInstalled = action.getDistributionSet();
|
||||
|
||||
// check initial status
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
|
||||
// assign the two sets in a row
|
||||
@@ -336,8 +337,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(7);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong assigned ds")
|
||||
.isEqualTo(dsSecond);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
||||
.as("wrong target update status").isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong target update status")
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
// we cancel second -> remain assigned until finished cancellation
|
||||
deploymentManagement.cancelAction(secondAction.getId());
|
||||
@@ -351,7 +352,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
// cancelled success -> back to dsInstalled
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong installed ds")
|
||||
.isEqualTo(dsInstalled);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus())
|
||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
}
|
||||
|
||||
@@ -365,7 +366,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("newDS", true);
|
||||
|
||||
// verify initial status
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus())
|
||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
|
||||
Action assigningAction = assignSet(target, ds);
|
||||
@@ -386,8 +387,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(assigningAction.getStatus()).as("wrong size of status").isEqualTo(Status.CANCELED);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong assigned ds")
|
||||
.isEqualTo(dsInstalled);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
||||
.as("wrong target update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong target update status")
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -399,7 +400,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("newDS", true);
|
||||
|
||||
// verify initial status
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
|
||||
final Action assigningAction = assignSet(target, ds);
|
||||
@@ -418,7 +419,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private JpaAction assignSet(final Target target, final DistributionSet ds) {
|
||||
assignDistributionSet(ds.getId(), target.getControllerId());
|
||||
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).get().getUpdateStatus())
|
||||
assertThat(targetManagement.getByControllerID(target.getControllerId()).get().getUpdateStatus())
|
||||
.as("wrong update status").isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get())
|
||||
.as("wrong assigned ds").isEqualTo(ds);
|
||||
@@ -450,9 +451,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
.getAssignedEntity();
|
||||
assertThat(actionRepository.count()).isEqualTo(20);
|
||||
|
||||
assertThat(targetManagement.findTargetByInstalledDistributionSet(ds.getId(), PAGE).getContent())
|
||||
.containsAll(targets).hasSize(10)
|
||||
.containsAll(targetManagement.findTargetByAssignedDistributionSet(ds.getId(), PAGE))
|
||||
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, ds.getId()).getContent()).containsAll(targets)
|
||||
.hasSize(10).containsAll(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId()))
|
||||
.as("InstallationDate set").allMatch(target -> target.getInstallationDate() >= current)
|
||||
.as("TargetUpdateStatus IN_SYNC")
|
||||
.allMatch(target -> TargetUpdateStatus.IN_SYNC.equals(target.getUpdateStatus()))
|
||||
@@ -486,10 +486,10 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
// verify that one Action for each assignDistributionSet
|
||||
assertThat(actionRepository.findAll(PAGE).getNumberOfElements()).as("wrong size of actions").isEqualTo(20);
|
||||
|
||||
final Iterable<Target> allFoundTargets = targetManagement.findTargetsAll(PAGE).getContent();
|
||||
final Iterable<Target> allFoundTargets = targetManagement.findAll(PAGE).getContent();
|
||||
|
||||
// get final updated version of targets
|
||||
savedDeployedTargets = targetManagement.findTargetsByControllerID(
|
||||
savedDeployedTargets = targetManagement.getByControllerID(
|
||||
savedDeployedTargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()));
|
||||
|
||||
assertThat(allFoundTargets).as("founded targets are wrong").containsAll(savedDeployedTargets)
|
||||
@@ -500,13 +500,13 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
.doesNotContain(Iterables.toArray(savedDeployedTargets, Target.class));
|
||||
|
||||
for (final Target myt : savedNakedTargets) {
|
||||
final Target t = targetManagement.findTargetByControllerID(myt.getControllerId()).get();
|
||||
final Target t = targetManagement.getByControllerID(myt.getControllerId()).get();
|
||||
assertThat(deploymentManagement.countActionsByTarget(t.getControllerId())).as("action should be empty")
|
||||
.isEqualTo(0L);
|
||||
}
|
||||
|
||||
for (final Target myt : savedDeployedTargets) {
|
||||
final Target t = targetManagement.findTargetByControllerID(myt.getControllerId()).get();
|
||||
final Target t = targetManagement.getByControllerID(myt.getControllerId()).get();
|
||||
final List<Action> activeActionsByTarget = deploymentManagement
|
||||
.findActiveActionsByTarget(PAGE, t.getControllerId()).getContent();
|
||||
assertThat(activeActionsByTarget).as("action should not be empty").isNotEmpty();
|
||||
@@ -531,9 +531,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
||||
final SoftwareModule os = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final DistributionSet incomplete = distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("incomplete").version("v1")
|
||||
.type(standardDsType).modules(Arrays.asList(ah.getId())));
|
||||
final DistributionSet incomplete = distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("incomplete").version("v1").type(standardDsType).modules(Arrays.asList(ah.getId())));
|
||||
|
||||
try {
|
||||
assignDistributionSet(incomplete, targets);
|
||||
@@ -664,7 +663,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
.isEqualTo(dsC.getId());
|
||||
assertThat(deploymentManagement.getInstalledDistributionSet(t.getControllerId()))
|
||||
.as("installed ds should not be null").isNotPresent();
|
||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||
assertThat(targetManagement.getByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.PENDING);
|
||||
}
|
||||
|
||||
@@ -675,12 +674,12 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// verify, that dsA is deployed correctly
|
||||
for (final Target t_ : updatedTsDsA) {
|
||||
final Target t = targetManagement.findTargetByControllerID(t_.getControllerId()).get();
|
||||
final Target t = targetManagement.getByControllerID(t_.getControllerId()).get();
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet(t.getControllerId()).get())
|
||||
.as("assigned ds is wrong").isEqualTo(dsA);
|
||||
assertThat(deploymentManagement.getInstalledDistributionSet(t.getControllerId()).get())
|
||||
.as("installed ds is wrong").isEqualTo(dsA);
|
||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||
assertThat(targetManagement.getByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, t.getControllerId()))
|
||||
.as("no actions should be active").hasSize(0);
|
||||
@@ -695,19 +694,19 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
actionRepository.findByDistributionSetId(pageRequest, dsA.getId()).getContent().get(1);
|
||||
|
||||
// get final updated version of targets
|
||||
final List<Target> deployResWithDsBTargets = targetManagement.findTargetsByControllerID(deployResWithDsB
|
||||
final List<Target> deployResWithDsBTargets = targetManagement.getByControllerID(deployResWithDsB
|
||||
.getDeployedTargets().stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
|
||||
assertThat(deployed2DS).as("deployed ds is wrong").containsAll(deployResWithDsBTargets);
|
||||
assertThat(deployed2DS).as("deployed ds is wrong").hasSameSizeAs(deployResWithDsBTargets);
|
||||
|
||||
for (final Target t_ : deployed2DS) {
|
||||
final Target t = targetManagement.findTargetByControllerID(t_.getControllerId()).get();
|
||||
final Target t = targetManagement.getByControllerID(t_.getControllerId()).get();
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet(t.getControllerId()).get())
|
||||
.as("assigned ds is wrong").isEqualTo(dsA);
|
||||
assertThat(deploymentManagement.getInstalledDistributionSet(t.getControllerId()))
|
||||
.as("installed ds should be null").isNotPresent();
|
||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||
assertThat(targetManagement.getByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
}
|
||||
@@ -739,42 +738,41 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(dsA.getId());
|
||||
distributionSetManagement.delete(dsA.getId());
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetById(dsA.getId())).isNotPresent();
|
||||
assertThat(distributionSetManagement.get(dsA.getId())).isNotPresent();
|
||||
|
||||
// // verify that the ds is not physically deleted
|
||||
for (final DistributionSet ds : deploymentResult.getDistributionSets()) {
|
||||
distributionSetManagement.deleteDistributionSet(ds.getId());
|
||||
final DistributionSet foundDS = distributionSetManagement.findDistributionSetById(ds.getId()).get();
|
||||
distributionSetManagement.delete(ds.getId());
|
||||
final DistributionSet foundDS = distributionSetManagement.get(ds.getId()).get();
|
||||
assertThat(foundDS).as("founded should not be null").isNotNull();
|
||||
assertThat(foundDS.isDeleted()).as("found ds should be deleted").isTrue();
|
||||
}
|
||||
|
||||
// verify that deleted attribute is used correctly
|
||||
List<DistributionSet> allFoundDS = distributionSetManagement
|
||||
.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true).getContent();
|
||||
List<DistributionSet> allFoundDS = distributionSetManagement.findByCompleted(PAGE, true).getContent();
|
||||
assertThat(allFoundDS.size()).as("no ds should be founded").isEqualTo(0);
|
||||
allFoundDS = distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageRequest, true, true)
|
||||
.getContent();
|
||||
assertThat(allFoundDS).as("wrong size of founded ds").hasSize(noOfDistributionSets);
|
||||
|
||||
assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays
|
||||
.asList(DistributionSetSpecification.isDeleted(true), DistributionSetSpecification.isCompleted(true))),
|
||||
PAGE).getContent()).as("wrong size of founded ds").hasSize(noOfDistributionSets);
|
||||
|
||||
for (final DistributionSet ds : deploymentResult.getDistributionSets()) {
|
||||
testdataFactory.sendUpdateActionStatusToTargets(deploymentResult.getDeployedTargets(), Status.FINISHED,
|
||||
Collections.singletonList("blabla alles gut"));
|
||||
}
|
||||
// try to delete again
|
||||
distributionSetManagement.deleteDistributionSet(deploymentResult.getDistributionSetIDs());
|
||||
distributionSetManagement.delete(deploymentResult.getDistributionSetIDs());
|
||||
// verify that the result is the same, even though distributionSet dsA
|
||||
// has been installed
|
||||
// successfully and no activeAction is referring to created distribution
|
||||
// sets
|
||||
allFoundDS = distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageRequest, false, true)
|
||||
.getContent();
|
||||
allFoundDS = distributionSetManagement.findByCompleted(pageRequest, true).getContent();
|
||||
assertThat(allFoundDS.size()).as("no ds should be founded").isEqualTo(0);
|
||||
allFoundDS = distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageRequest, true, true)
|
||||
.getContent();
|
||||
assertThat(allFoundDS).as("size of founded ds is wrong").hasSize(noOfDistributionSets);
|
||||
assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays
|
||||
.asList(DistributionSetSpecification.isDeleted(true), DistributionSetSpecification.isCompleted(true))),
|
||||
PAGE).getContent()).as("wrong size of founded ds").hasSize(noOfDistributionSets);
|
||||
|
||||
}
|
||||
|
||||
@@ -798,13 +796,13 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
Collections.singletonList("blabla alles gut"));
|
||||
}
|
||||
|
||||
assertThat(targetManagement.countTargetsAll()).as("size of targets is wrong").isNotZero();
|
||||
assertThat(targetManagement.count()).as("size of targets is wrong").isNotZero();
|
||||
assertThat(actionStatusRepository.count()).as("size of action status is wrong").isNotZero();
|
||||
|
||||
targetManagement.deleteTargets(deploymentResult.getUndeployedTargetIDs());
|
||||
targetManagement.deleteTargets(deploymentResult.getDeployedTargetIDs());
|
||||
targetManagement.delete(deploymentResult.getUndeployedTargetIDs());
|
||||
targetManagement.delete(deploymentResult.getDeployedTargetIDs());
|
||||
|
||||
assertThat(targetManagement.countTargetsAll()).as("size of targets should be zero").isZero();
|
||||
assertThat(targetManagement.count()).as("size of targets should be zero").isZero();
|
||||
assertThat(actionStatusRepository.count()).as("size of action status is wrong").isZero();
|
||||
}
|
||||
|
||||
@@ -818,13 +816,13 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// doing the assignment
|
||||
targs = assignDistributionSet(dsA, targs).getAssignedEntity();
|
||||
Target targ = targetManagement.findTargetByControllerID(targs.iterator().next().getControllerId()).get();
|
||||
Target targ = targetManagement.getByControllerID(targs.iterator().next().getControllerId()).get();
|
||||
|
||||
// checking the revisions of the created entities
|
||||
// verifying that the revision of the object and the revision within the
|
||||
// DB has not changed
|
||||
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong").isEqualTo(
|
||||
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong")
|
||||
.isEqualTo(distributionSetManagement.getWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||
|
||||
// verifying that the assignment is correct
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements())
|
||||
@@ -843,7 +841,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
controllerManagement.addUpdateActionStatus(
|
||||
entityFactory.actionStatus().create(updAct.getContent().get(0).getId()).status(Status.FINISHED));
|
||||
|
||||
targ = targetManagement.findTargetByControllerID(targ.getControllerId()).get();
|
||||
targ = targetManagement.getByControllerID(targ.getControllerId()).get();
|
||||
|
||||
assertEquals("active target actions are wrong", 0,
|
||||
deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements());
|
||||
@@ -863,7 +861,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertEquals("active actions are wrong", 1,
|
||||
deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements());
|
||||
assertEquals("target status is wrong", TargetUpdateStatus.PENDING,
|
||||
targetManagement.findTargetByControllerID(targ.getControllerId()).get().getUpdateStatus());
|
||||
targetManagement.getByControllerID(targ.getControllerId()).get().getUpdateStatus());
|
||||
assertEquals("wrong assigned ds", dsB,
|
||||
deploymentManagement.getAssignedDistributionSet(targ.getControllerId()).get());
|
||||
assertEquals("Installed ds is wrong", dsA.getId(),
|
||||
@@ -881,13 +879,13 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createDistributionSet("b");
|
||||
final Target targ = testdataFactory.createTarget("target-id-A");
|
||||
|
||||
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong").isEqualTo(
|
||||
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong")
|
||||
.isEqualTo(distributionSetManagement.getWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||
|
||||
assignDistributionSet(dsA, Arrays.asList(targ));
|
||||
|
||||
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong").isEqualTo(
|
||||
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong")
|
||||
.isEqualTo(distributionSetManagement.getWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1004,9 +1002,9 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(event.getActionId()).as("Action id in database and event do not match")
|
||||
.isEqualTo(activeActionsByTarget.get(0).getId());
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetById(event.getDistributionSetId()).get()
|
||||
.getModules()).as("softwaremodule size is not correct")
|
||||
.containsOnly(ds.getModules().toArray(new SoftwareModule[ds.getModules().size()]));
|
||||
assertThat(distributionSetManagement.get(event.getDistributionSetId()).get().getModules())
|
||||
.as("softwaremodule size is not correct")
|
||||
.containsOnly(ds.getModules().toArray(new SoftwareModule[ds.getModules().size()]));
|
||||
}
|
||||
}
|
||||
assertThat(found).as("No event found for controller " + myt.getControllerId()).isTrue();
|
||||
|
||||
@@ -73,11 +73,10 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
final DistributionSet set = testdataFactory.createDistributionSet();
|
||||
assertThat(distributionSetManagement.findDistributionSetById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetManagement.findDistributionSetByNameAndVersion(NOT_EXIST_ID, NOT_EXIST_ID))
|
||||
.isNotPresent();
|
||||
assertThat(distributionSetManagement.findDistributionSetMetadata(set.getId(), NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetManagement.getWithDetails(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetManagement.getByNameAndVersion(NOT_EXIST_ID, NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetManagement.getMetaDataByDistributionSetId(set.getId(), NOT_EXIST_ID)).isNotPresent();
|
||||
|
||||
}
|
||||
|
||||
@@ -99,6 +98,8 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
() -> distributionSetManagement.assignSoftwareModules(set.getId(), Arrays.asList(NOT_EXIST_IDL)),
|
||||
"SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.countByTypeId(NOT_EXIST_IDL), "DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.unassignSoftwareModule(NOT_EXIST_IDL, module.getId()),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.unassignSoftwareModule(set.getId(), NOT_EXIST_IDL),
|
||||
@@ -110,10 +111,8 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.assignTag(Arrays.asList(NOT_EXIST_IDL), dsTag.getId()),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findDistributionSetsByTag(PAGE, NOT_EXIST_IDL),
|
||||
"DistributionSetTag");
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetManagement.findDistributionSetsByTag(PAGE, "name==*", NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findByTag(PAGE, NOT_EXIST_IDL), "DistributionSetTag");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findByRsqlAndTag(PAGE, "name==*", NOT_EXIST_IDL),
|
||||
"DistributionSetTag");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
@@ -131,47 +130,44 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("xxx").type(NOT_EXIST_ID)),
|
||||
.create(entityFactory.distributionSet().create().name("xxx").type(NOT_EXIST_ID)),
|
||||
"DistributionSetType");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.createDistributionSetMetadata(NOT_EXIST_IDL,
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.createMetaData(NOT_EXIST_IDL,
|
||||
Arrays.asList(entityFactory.generateMetadata("123", "123"))), "DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.deleteDistributionSet(Arrays.asList(NOT_EXIST_IDL)),
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.delete(Arrays.asList(NOT_EXIST_IDL)),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.deleteDistributionSet(NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.delete(NOT_EXIST_IDL), "DistributionSet");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.deleteMetaData(NOT_EXIST_IDL, "xxx"),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.deleteDistributionSetMetadata(NOT_EXIST_IDL, "xxx"),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetManagement.deleteDistributionSetMetadata(set.getId(), NOT_EXIST_ID),
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.deleteMetaData(set.getId(), NOT_EXIST_ID),
|
||||
"DistributionSetMetadata");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findDistributionSetByAction(NOT_EXIST_IDL), "Action");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.getByAction(NOT_EXIST_IDL), "Action");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findDistributionSetMetadata(NOT_EXIST_IDL, "xxx"),
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.getMetaDataByDistributionSetId(NOT_EXIST_IDL, "xxx"),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findMetaDataByDistributionSetId(PAGE, NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetManagement.findDistributionSetMetadataByDistributionSetId(NOT_EXIST_IDL, PAGE),
|
||||
() -> distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement
|
||||
.findDistributionSetMetadataByDistributionSetId(NOT_EXIST_IDL, "name==*", PAGE), "DistributionSet");
|
||||
|
||||
assertThatThrownBy(() -> distributionSetManagement.isDistributionSetInUse(NOT_EXIST_IDL))
|
||||
assertThatThrownBy(() -> distributionSetManagement.isInUse(NOT_EXIST_IDL))
|
||||
.isInstanceOf(EntityNotFoundException.class).hasMessageContaining(NOT_EXIST_ID)
|
||||
.hasMessageContaining("DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(NOT_EXIST_IDL)),
|
||||
() -> distributionSetManagement.update(entityFactory.distributionSet().update(NOT_EXIST_IDL)),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.updateDistributionSetMetadata(NOT_EXIST_IDL,
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.updateMetaData(NOT_EXIST_IDL,
|
||||
entityFactory.generateMetadata("xxx", "xxx")), "DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.updateDistributionSetMetadata(set.getId(),
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.updateMetaData(set.getId(),
|
||||
entityFactory.generateMetadata(NOT_EXIST_ID, "xxx")), "DistributionSetMetadata");
|
||||
}
|
||||
|
||||
@@ -192,13 +188,13 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createAndUpdateDistributionSetWithInvalidDescription(final DistributionSet set) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
.create().name("a").version("a").description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a")
|
||||
.version("a").description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("entity with too long description should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
||||
.update(set.getId()).description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||
.description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("entity with too long description should not be updated");
|
||||
|
||||
}
|
||||
@@ -207,23 +203,21 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createAndUpdateDistributionSetWithInvalidName(final DistributionSet set) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
.create().version("a").name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().version("a")
|
||||
.name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("entity with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||
() -> distributionSetManagement.create(entityFactory.distributionSet().create().version("a").name("")))
|
||||
.as("entity with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().version("a").name("")))
|
||||
.as("entity with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
||||
.update(set.getId()).name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||
.name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("entity with too long name should not be updated");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(set.getId()).name("")))
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||
() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId()).name("")))
|
||||
.as("entity with too short name should not be updated");
|
||||
|
||||
}
|
||||
@@ -232,23 +226,21 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createAndUpdateDistributionSetWithInvalidVersion(final DistributionSet set) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
.create().name("a").version(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a")
|
||||
.version(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("entity with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||
() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a").version("")))
|
||||
.as("entity with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("a").version("")))
|
||||
.as("entity with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
||||
.update(set.getId()).version(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||
.version(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("entity with too long name should not be updated");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(set.getId()).version("")))
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||
() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId()).version("")))
|
||||
.as("entity with too short name should not be updated");
|
||||
|
||||
}
|
||||
@@ -266,7 +258,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Verifies that a DS is of default type if not specified explicitly at creation time.")
|
||||
public void createDistributionSetWithImplicitType() {
|
||||
final DistributionSet set = distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("newtypesoft").version("1"));
|
||||
.create(entityFactory.distributionSet().create().name("newtypesoft").version("1"));
|
||||
|
||||
assertThat(set.getType()).as("Type should be equal to default type of tenant")
|
||||
.isEqualTo(systemManagement.getTenantMetadata().getDefaultDsType());
|
||||
@@ -276,11 +268,10 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Verifies that a DS cannot be created if another DS with same name and version exists.")
|
||||
public void createDistributionSetWithDuplicateNameAndVersionFails() {
|
||||
distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("newtypesoft").version("1"));
|
||||
distributionSetManagement.create(entityFactory.distributionSet().create().name("newtypesoft").version("1"));
|
||||
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class).isThrownBy(() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("newtypesoft").version("1")));
|
||||
.create(entityFactory.distributionSet().create().name("newtypesoft").version("1")));
|
||||
|
||||
}
|
||||
|
||||
@@ -293,7 +284,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
creates.add(entityFactory.distributionSet().create().name("newtypesoft" + i).version("1" + i));
|
||||
}
|
||||
|
||||
final List<DistributionSet> sets = distributionSetManagement.createDistributionSets(creates);
|
||||
final List<DistributionSet> sets = distributionSetManagement.create(creates);
|
||||
|
||||
assertThat(sets).as("Type should be equal to default type of tenant").are(new Condition<DistributionSet>() {
|
||||
@Override
|
||||
@@ -330,33 +321,30 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
assignDS.add(testdataFactory.createDistributionSet("DS" + i, "1.0", Collections.emptyList()).getId());
|
||||
}
|
||||
|
||||
final DistributionSetTag tag = tagManagement
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("Tag1"));
|
||||
final DistributionSetTag tag = distributionSetTagManagement.create(entityFactory.tag().create().name("Tag1"));
|
||||
|
||||
final List<DistributionSet> assignedDS = distributionSetManagement.assignTag(assignDS, tag.getId());
|
||||
assertThat(assignedDS.size()).as("assigned ds has wrong size").isEqualTo(4);
|
||||
assignedDS.stream().map(c -> (JpaDistributionSet) c)
|
||||
.forEach(ds -> assertThat(ds.getTags().size()).as("ds has wrong tag size").isEqualTo(1));
|
||||
|
||||
DistributionSetTag findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1").get();
|
||||
DistributionSetTag findDistributionSetTag = distributionSetTagManagement.getByName("Tag1").get();
|
||||
|
||||
assertThat(assignedDS.size()).as("assigned ds has wrong size").isEqualTo(
|
||||
distributionSetManagement.findDistributionSetsByTag(PAGE, tag.getId()).getNumberOfElements());
|
||||
assertThat(assignedDS.size()).as("assigned ds has wrong size")
|
||||
.isEqualTo(distributionSetManagement.findByTag(PAGE, tag.getId()).getNumberOfElements());
|
||||
|
||||
final JpaDistributionSet unAssignDS = (JpaDistributionSet) distributionSetManagement
|
||||
.unAssignTag(assignDS.get(0), findDistributionSetTag.getId());
|
||||
assertThat(unAssignDS.getId()).as("unassigned ds is wrong").isEqualTo(assignDS.get(0));
|
||||
assertThat(unAssignDS.getTags().size()).as("unassigned ds has wrong tag size").isEqualTo(0);
|
||||
findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1").get();
|
||||
assertThat(distributionSetManagement.findDistributionSetsByTag(PAGE, tag.getId()).getNumberOfElements())
|
||||
findDistributionSetTag = distributionSetTagManagement.getByName("Tag1").get();
|
||||
assertThat(distributionSetManagement.findByTag(PAGE, tag.getId()).getNumberOfElements())
|
||||
.as("ds tag ds has wrong ds size").isEqualTo(3);
|
||||
|
||||
assertThat(distributionSetManagement
|
||||
.findDistributionSetsByTag(PAGE, "name==" + unAssignDS.getName(), tag.getId()).getNumberOfElements())
|
||||
.as("ds tag ds has wrong ds size").isEqualTo(0);
|
||||
assertThat(distributionSetManagement
|
||||
.findDistributionSetsByTag(PAGE, "name!=" + unAssignDS.getName(), tag.getId()).getNumberOfElements())
|
||||
.as("ds tag ds has wrong ds size").isEqualTo(3);
|
||||
assertThat(distributionSetManagement.findByRsqlAndTag(PAGE, "name==" + unAssignDS.getName(), tag.getId())
|
||||
.getNumberOfElements()).as("ds tag ds has wrong ds size").isEqualTo(0);
|
||||
assertThat(distributionSetManagement.findByRsqlAndTag(PAGE, "name!=" + unAssignDS.getName(), tag.getId())
|
||||
.getNumberOfElements()).as("ds tag ds has wrong ds size").isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -375,7 +363,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// assign target
|
||||
assignDistributionSet(ds.getId(), target.getControllerId());
|
||||
ds = distributionSetManagement.findDistributionSetByIdWithDetails(ds.getId()).get();
|
||||
ds = distributionSetManagement.getWithDetails(ds.getId()).get();
|
||||
|
||||
final Long dsId = ds.getId();
|
||||
// not allowed as it is assigned now
|
||||
@@ -392,14 +380,13 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Ensures that it is not possible to add a software module that is not defined of the DS's type.")
|
||||
public void updateDistributionSetUnsupportedModuleFails() {
|
||||
final DistributionSet set = distributionSetManagement
|
||||
.createDistributionSet(
|
||||
entityFactory.distributionSet().create().name("agent-hub2").version("1.0.5")
|
||||
.type(distributionSetTypeManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create()
|
||||
.key("test").name("test").mandatory(Arrays.asList(osType.getId())))
|
||||
.getKey()));
|
||||
.create(entityFactory.distributionSet().create().name("agent-hub2")
|
||||
.version(
|
||||
"1.0.5")
|
||||
.type(distributionSetTypeManagement.create(entityFactory.distributionSetType().create()
|
||||
.key("test").name("test").mandatory(Arrays.asList(osType.getId()))).getKey()));
|
||||
|
||||
final SoftwareModule module = softwareModuleManagement.createSoftwareModule(
|
||||
final SoftwareModule module = softwareModuleManagement.create(
|
||||
entityFactory.softwareModule().create().name("agent-hub2").version("1.0.5").type(appType.getKey()));
|
||||
|
||||
// update data
|
||||
@@ -418,19 +405,18 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
// update data
|
||||
// legal update of module addition
|
||||
distributionSetManagement.assignSoftwareModules(ds.getId(), Sets.newHashSet(os.getId()));
|
||||
ds = distributionSetManagement.findDistributionSetByIdWithDetails(ds.getId()).get();
|
||||
ds = distributionSetManagement.getWithDetails(ds.getId()).get();
|
||||
assertThat(ds.findFirstModuleByType(osType).get()).isEqualTo(os);
|
||||
|
||||
// legal update of module removal
|
||||
distributionSetManagement.unassignSoftwareModule(ds.getId(), ds.findFirstModuleByType(appType).get().getId());
|
||||
ds = distributionSetManagement.findDistributionSetByIdWithDetails(ds.getId()).get();
|
||||
ds = distributionSetManagement.getWithDetails(ds.getId()).get();
|
||||
assertThat(ds.findFirstModuleByType(appType).isPresent()).isFalse();
|
||||
|
||||
// Update description
|
||||
distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(ds.getId()).name("a new name")
|
||||
.description("a new description").version("a new version").requiredMigrationStep(true));
|
||||
ds = distributionSetManagement.findDistributionSetByIdWithDetails(ds.getId()).get();
|
||||
distributionSetManagement.update(entityFactory.distributionSet().update(ds.getId()).name("a new name")
|
||||
.description("a new description").version("a new version").requiredMigrationStep(true));
|
||||
ds = distributionSetManagement.getWithDetails(ds.getId()).get();
|
||||
assertThat(ds.getDescription()).isEqualTo("a new description");
|
||||
assertThat(ds.getName()).isEqualTo("a new name");
|
||||
assertThat(ds.getVersion()).isEqualTo("a new version");
|
||||
@@ -453,18 +439,18 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
// create an DS meta data entry
|
||||
createDistributionSetMetadata(ds.getId(), new JpaDistributionSetMetadata(knownKey, ds, knownValue));
|
||||
|
||||
DistributionSet changedLockRevisionDS = distributionSetManagement.findDistributionSetById(ds.getId()).get();
|
||||
DistributionSet changedLockRevisionDS = distributionSetManagement.get(ds.getId()).get();
|
||||
assertThat(changedLockRevisionDS.getOptLockRevision()).isEqualTo(2);
|
||||
|
||||
Thread.sleep(100);
|
||||
|
||||
// update the DS metadata
|
||||
final JpaDistributionSetMetadata updated = (JpaDistributionSetMetadata) distributionSetManagement
|
||||
.updateDistributionSetMetadata(ds.getId(), entityFactory.generateMetadata(knownKey, knownUpdateValue));
|
||||
.updateMetaData(ds.getId(), entityFactory.generateMetadata(knownKey, knownUpdateValue));
|
||||
// we are updating the sw meta data so also modifying the base software
|
||||
// module so opt lock
|
||||
// revision must be three
|
||||
changedLockRevisionDS = distributionSetManagement.findDistributionSetById(ds.getId()).get();
|
||||
changedLockRevisionDS = distributionSetManagement.get(ds.getId()).get();
|
||||
assertThat(changedLockRevisionDS.getOptLockRevision()).isEqualTo(3);
|
||||
assertThat(changedLockRevisionDS.getLastModifiedAt()).isGreaterThan(0L);
|
||||
|
||||
@@ -505,15 +491,19 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
.setIsDeleted(false).setIsComplete(true).setSelectDSWithNoTag(Boolean.FALSE);
|
||||
|
||||
// target first only has an assigned DS-three so check order correct
|
||||
final List<DistributionSet> tFirstPin = distributionSetManagement.findDistributionSetsAllOrderedByLinkTarget(
|
||||
PAGE, distributionSetFilterBuilder, tFirst.getControllerId()).getContent();
|
||||
final List<DistributionSet> tFirstPin = distributionSetManagement
|
||||
.findByFilterAndAssignedInstalledDsOrderedByLinkTarget(PAGE, distributionSetFilterBuilder,
|
||||
tFirst.getControllerId())
|
||||
.getContent();
|
||||
assertThat(tFirstPin.get(0)).isEqualTo(dsThree);
|
||||
assertThat(tFirstPin).hasSize(10);
|
||||
|
||||
// target second has installed DS-2 and assigned DS-4 so check order
|
||||
// correct
|
||||
final List<DistributionSet> tSecondPin = distributionSetManagement.findDistributionSetsAllOrderedByLinkTarget(
|
||||
PAGE, distributionSetFilterBuilder, tSecond.getControllerId()).getContent();
|
||||
final List<DistributionSet> tSecondPin = distributionSetManagement
|
||||
.findByFilterAndAssignedInstalledDsOrderedByLinkTarget(PAGE, distributionSetFilterBuilder,
|
||||
tSecond.getControllerId())
|
||||
.getContent();
|
||||
assertThat(tSecondPin.get(0)).isEqualTo(dsSecond);
|
||||
assertThat(tSecondPin.get(1)).isEqualTo(dsFour);
|
||||
assertThat(tFirstPin).hasSize(10);
|
||||
@@ -522,35 +512,35 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("searches for distribution sets based on the various filter options, e.g. name, version, desc., tags.")
|
||||
public void searchDistributionSetsOnFilters() {
|
||||
DistributionSetTag dsTagA = tagManagement
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-A"));
|
||||
final DistributionSetTag dsTagB = tagManagement
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-B"));
|
||||
final DistributionSetTag dsTagC = tagManagement
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-C"));
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-D"));
|
||||
DistributionSetTag dsTagA = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("DistributionSetTag-A"));
|
||||
final DistributionSetTag dsTagB = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("DistributionSetTag-B"));
|
||||
final DistributionSetTag dsTagC = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("DistributionSetTag-C"));
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("DistributionSetTag-D"));
|
||||
|
||||
List<DistributionSet> ds5Group1 = testdataFactory.createDistributionSets("", 5);
|
||||
List<DistributionSet> dsGroup2 = testdataFactory.createDistributionSets("test2", 5);
|
||||
DistributionSet dsDeleted = testdataFactory.createDistributionSet("deleted");
|
||||
final DistributionSet dsInComplete = distributionSetManagement.createDistributionSet(entityFactory
|
||||
.distributionSet().create().name("notcomplete").version("1").type(standardDsType.getKey()));
|
||||
final DistributionSet dsInComplete = distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("notcomplete").version("1").type(standardDsType.getKey()));
|
||||
|
||||
DistributionSetType newType = distributionSetTypeManagement.createDistributionSetType(
|
||||
entityFactory.distributionSetType().create().key("foo").name("bar").description("test"));
|
||||
DistributionSetType newType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("foo").name("bar").description("test"));
|
||||
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(newType.getId(),
|
||||
Arrays.asList(osType.getId()));
|
||||
newType = distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(newType.getId(),
|
||||
Arrays.asList(appType.getId(), runtimeType.getId()));
|
||||
|
||||
final DistributionSet dsNewType = distributionSetManagement.createDistributionSet(
|
||||
final DistributionSet dsNewType = distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name("newtype").version("1").type(newType.getKey()).modules(
|
||||
dsDeleted.getModules().stream().map(SoftwareModule::getId).collect(Collectors.toList())));
|
||||
|
||||
assignDistributionSet(dsDeleted, testdataFactory.createTargets(5));
|
||||
distributionSetManagement.deleteDistributionSet(dsDeleted.getId());
|
||||
dsDeleted = distributionSetManagement.findDistributionSetById(dsDeleted.getId()).get();
|
||||
distributionSetManagement.delete(dsDeleted.getId());
|
||||
dsDeleted = distributionSetManagement.get(dsDeleted.getId()).get();
|
||||
|
||||
ds5Group1 = toggleTagAssignment(ds5Group1, dsTagA).getAssignedEntity();
|
||||
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName()).get();
|
||||
@@ -571,18 +561,18 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
expected.add(dsNewType);
|
||||
|
||||
assertThat(distributionSetManagement
|
||||
.findDistributionSetsByFilters(PAGE, getDistributionSetFilterBuilder().build()).getContent())
|
||||
.hasSize(13).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
.findByDistributionSetFilter(PAGE, getDistributionSetFilterBuilder().build()).getContent()).hasSize(13)
|
||||
.containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
DistributionSetFilterBuilder distributionSetFilterBuilder;
|
||||
|
||||
// search for not deleted
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.TRUE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(false);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(12);
|
||||
|
||||
// search for completed
|
||||
@@ -593,50 +583,50 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
expected.add(dsNewType);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(12).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.FALSE);
|
||||
expected = new ArrayList<>();
|
||||
expected.add(dsInComplete);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
// search for type
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(newType);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(12);
|
||||
|
||||
// search for text
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setSearchText("%test2");
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(5);
|
||||
|
||||
// search for tags
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagA.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(10);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagB.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(5);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
|
||||
.setTagNames(Arrays.asList(dsTagA.getName(), dsTagB.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(10);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
|
||||
.setTagNames(Arrays.asList(dsTagC.getName(), dsTagB.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(5);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagC.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
// combine deleted and complete
|
||||
@@ -647,23 +637,23 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setIsDeleted(Boolean.FALSE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(11).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
expected = Arrays.asList(dsInComplete);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.FALSE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
expected = Arrays.asList(dsDeleted);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setIsDeleted(Boolean.TRUE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.TRUE)
|
||||
.setIsComplete(Boolean.FALSE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
// combine deleted and complete and type
|
||||
@@ -672,57 +662,57 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
expected.addAll(dsGroup2);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.FALSE)
|
||||
.setIsComplete(Boolean.TRUE).setType(standardDsType);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(10).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
expected = Arrays.asList(dsDeleted);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setType(standardDsType).setIsDeleted(Boolean.TRUE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.TRUE)
|
||||
.setIsComplete(Boolean.FALSE).setType(standardDsType);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
expected = Arrays.asList(dsNewType);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setType(newType);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
// combine deleted and complete and type and text
|
||||
expected = dsGroup2;
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setType(standardDsType).setSearchText("%test2");
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(5).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setIsDeleted(Boolean.TRUE).setType(standardDsType).setSearchText("%test2");
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType).setSearchText("%test2")
|
||||
.setIsComplete(false).setIsDeleted(false);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(newType).setSearchText("%test2")
|
||||
.setIsComplete(Boolean.TRUE).setIsDeleted(false);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
// combine deleted and complete and type and text and tag
|
||||
expected = dsGroup2;
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setType(standardDsType)
|
||||
.setSearchText("%test2").setTagNames(Arrays.asList(dsTagA.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(5).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType).setSearchText("%test2")
|
||||
.setTagNames(Arrays.asList(dsTagA.getName())).setIsComplete(Boolean.FALSE).setIsDeleted(Boolean.FALSE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
}
|
||||
@@ -736,8 +726,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void findDistributionSetsWithoutLazy() {
|
||||
testdataFactory.createDistributionSets(20);
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true))
|
||||
.hasSize(20);
|
||||
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(20);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -748,12 +737,10 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// delete a ds
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(2);
|
||||
distributionSetManagement.deleteDistributionSet(ds1.getId());
|
||||
distributionSetManagement.delete(ds1.getId());
|
||||
// not assigned so not marked as deleted but fully deleted
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(1);
|
||||
assertThat(distributionSetManagement
|
||||
.findDistributionSetsByDeletedAndOrCompleted(PAGE, Boolean.FALSE, Boolean.TRUE).getTotalElements())
|
||||
.isEqualTo(1);
|
||||
assertThat(distributionSetManagement.findByCompleted(PAGE, true).getTotalElements()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -776,10 +763,10 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
final Page<DistributionSetMetadata> metadataOfDs1 = distributionSetManagement
|
||||
.findDistributionSetMetadataByDistributionSetId(ds1.getId(), new PageRequest(0, 100));
|
||||
.findMetaDataByDistributionSetId(new PageRequest(0, 100), ds1.getId());
|
||||
|
||||
final Page<DistributionSetMetadata> metadataOfDs2 = distributionSetManagement
|
||||
.findDistributionSetMetadataByDistributionSetId(ds2.getId(), new PageRequest(0, 100));
|
||||
.findMetaDataByDistributionSetId(new PageRequest(0, 100), ds2.getId());
|
||||
|
||||
assertThat(metadataOfDs1.getNumberOfElements()).isEqualTo(10);
|
||||
assertThat(metadataOfDs1.getTotalElements()).isEqualTo(10);
|
||||
@@ -806,14 +793,11 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// delete assigned ds
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
||||
distributionSetManagement
|
||||
.deleteDistributionSet(Arrays.asList(dsToTargetAssigned.getId(), dsToRolloutAssigned.getId()));
|
||||
distributionSetManagement.delete(Arrays.asList(dsToTargetAssigned.getId(), dsToRolloutAssigned.getId()));
|
||||
|
||||
// not assigned so not marked as deleted
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
||||
assertThat(distributionSetManagement
|
||||
.findDistributionSetsByDeletedAndOrCompleted(PAGE, Boolean.FALSE, Boolean.TRUE).getTotalElements())
|
||||
.isEqualTo(2);
|
||||
assertThat(distributionSetManagement.findByCompleted(PAGE, true).getTotalElements()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -846,7 +830,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createDistributionSet("test" + i);
|
||||
}
|
||||
|
||||
final List<DistributionSet> foundDs = distributionSetManagement.findDistributionSetsById(searchIds);
|
||||
final List<DistributionSet> foundDs = distributionSetManagement.get(searchIds);
|
||||
|
||||
assertThat(foundDs).hasSize(3);
|
||||
|
||||
|
||||
@@ -18,20 +18,16 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.Tag;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.test.matcher.Expect;
|
||||
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
|
||||
import org.junit.Test;
|
||||
@@ -41,22 +37,20 @@ import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
/**
|
||||
* Test class for {@link TagManagement}.
|
||||
* {@link DistributionSetTagManagement} tests.
|
||||
*
|
||||
*/
|
||||
@Features("Component Tests - Repository")
|
||||
@Stories("Tag Management")
|
||||
public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Stories("DistributionSet Tag Management")
|
||||
public class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Verifies that management get access reacts as specfied on calls for non existing entities by means "
|
||||
+ "of Optional not present.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(tagManagement.findDistributionSetTag(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(tagManagement.findDistributionSetTagById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(tagManagement.findTargetTag(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(tagManagement.findTargetTagById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetTagManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetTagManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -65,18 +59,16 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
@ExpectEvents({ @Expect(type = DistributionSetTagUpdatedEvent.class, count = 0),
|
||||
@Expect(type = TargetTagUpdatedEvent.class, count = 0) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
verifyThrownExceptionBy(() -> tagManagement.deleteDistributionSetTag(NOT_EXIST_ID), "DistributionSetTag");
|
||||
verifyThrownExceptionBy(() -> tagManagement.deleteTargetTag(NOT_EXIST_ID), "TargetTag");
|
||||
verifyThrownExceptionBy(() -> distributionSetTagManagement.delete(NOT_EXIST_ID),
|
||||
"DistributionSetTag");
|
||||
|
||||
verifyThrownExceptionBy(() -> tagManagement.findDistributionSetTagsByDistributionSet(PAGE, NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetTagManagement.findByDistributionSet(PAGE, NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> tagManagement.updateDistributionSetTag(entityFactory.tag().update(NOT_EXIST_IDL)),
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetTagManagement.update(entityFactory.tag().update(NOT_EXIST_IDL)),
|
||||
"DistributionSetTag");
|
||||
verifyThrownExceptionBy(() -> tagManagement.updateTargetTag(entityFactory.tag().update(NOT_EXIST_IDL)),
|
||||
"TargetTag");
|
||||
|
||||
verifyThrownExceptionBy(() -> tagManagement.findAllTargetTags(PAGE, NOT_EXIST_ID), "Target");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,28 +82,33 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Collection<DistributionSet> dsBCs = testdataFactory.createDistributionSets("DS-BC", 13);
|
||||
final Collection<DistributionSet> dsABCs = testdataFactory.createDistributionSets("DS-ABC", 9);
|
||||
|
||||
final DistributionSetTag tagA = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("A"));
|
||||
final DistributionSetTag tagB = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("B"));
|
||||
final DistributionSetTag tagC = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("C"));
|
||||
final DistributionSetTag tagX = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("X"));
|
||||
final DistributionSetTag tagY = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("Y"));
|
||||
final DistributionSetTag tagA = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("A"));
|
||||
final DistributionSetTag tagB = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("B"));
|
||||
final DistributionSetTag tagC = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("C"));
|
||||
final DistributionSetTag tagX = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("X"));
|
||||
final DistributionSetTag tagY = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("Y"));
|
||||
|
||||
toggleTagAssignment(dsAs, tagA);
|
||||
toggleTagAssignment(dsBs, tagB);
|
||||
toggleTagAssignment(dsCs, tagC);
|
||||
|
||||
toggleTagAssignment(dsABs, tagManagement.findDistributionSetTag(tagA.getName()).get());
|
||||
toggleTagAssignment(dsABs, tagManagement.findDistributionSetTag(tagB.getName()).get());
|
||||
toggleTagAssignment(dsABs, distributionSetTagManagement.getByName(tagA.getName()).get());
|
||||
toggleTagAssignment(dsABs, distributionSetTagManagement.getByName(tagB.getName()).get());
|
||||
|
||||
toggleTagAssignment(dsACs, tagManagement.findDistributionSetTag(tagA.getName()).get());
|
||||
toggleTagAssignment(dsACs, tagManagement.findDistributionSetTag(tagC.getName()).get());
|
||||
toggleTagAssignment(dsACs, distributionSetTagManagement.getByName(tagA.getName()).get());
|
||||
toggleTagAssignment(dsACs, distributionSetTagManagement.getByName(tagC.getName()).get());
|
||||
|
||||
toggleTagAssignment(dsBCs, tagManagement.findDistributionSetTag(tagB.getName()).get());
|
||||
toggleTagAssignment(dsBCs, tagManagement.findDistributionSetTag(tagC.getName()).get());
|
||||
toggleTagAssignment(dsBCs, distributionSetTagManagement.getByName(tagB.getName()).get());
|
||||
toggleTagAssignment(dsBCs, distributionSetTagManagement.getByName(tagC.getName()).get());
|
||||
|
||||
toggleTagAssignment(dsABCs, tagManagement.findDistributionSetTag(tagA.getName()).get());
|
||||
toggleTagAssignment(dsABCs, tagManagement.findDistributionSetTag(tagB.getName()).get());
|
||||
toggleTagAssignment(dsABCs, tagManagement.findDistributionSetTag(tagC.getName()).get());
|
||||
toggleTagAssignment(dsABCs, distributionSetTagManagement.getByName(tagA.getName()).get());
|
||||
toggleTagAssignment(dsABCs, distributionSetTagManagement.getByName(tagB.getName()).get());
|
||||
toggleTagAssignment(dsABCs, distributionSetTagManagement.getByName(tagC.getName()).get());
|
||||
|
||||
DistributionSetFilterBuilder distributionSetFilterBuilder;
|
||||
|
||||
@@ -121,7 +118,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertEquals("filter works not correct",
|
||||
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
@@ -129,7 +126,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertEquals("filter works not correct",
|
||||
dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
@@ -137,22 +134,22 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertEquals("filter works not correct",
|
||||
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
.setTagNames(Arrays.asList(tagX.getName()));
|
||||
assertEquals("filter works not correct", 0, distributionSetManagement
|
||||
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
|
||||
.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
|
||||
|
||||
assertEquals("wrong tag size", 5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
|
||||
tagManagement.deleteDistributionSetTag(tagY.getName());
|
||||
distributionSetTagManagement.delete(tagY.getName());
|
||||
assertEquals("wrong tag size", 4, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
tagManagement.deleteDistributionSetTag(tagX.getName());
|
||||
distributionSetTagManagement.delete(tagX.getName());
|
||||
assertEquals("wrong tag size", 3, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
|
||||
tagManagement.deleteDistributionSetTag(tagB.getName());
|
||||
distributionSetTagManagement.delete(tagB.getName());
|
||||
assertEquals("wrong tag size", 2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
@@ -160,27 +157,23 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertEquals("filter works not correct",
|
||||
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setTagNames(Arrays.asList(tagB.getName()));
|
||||
assertEquals("filter works not correct", 0, distributionSetManagement
|
||||
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
|
||||
.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setTagNames(Arrays.asList(tagC.getName()));
|
||||
assertEquals("filter works not correct",
|
||||
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
}
|
||||
|
||||
private DistributionSetFilterBuilder getDistributionSetFilterBuilder() {
|
||||
return new DistributionSetFilterBuilder();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies the toogle mechanism by means on assigning tag if at least on DS in the list does not have"
|
||||
+ "the tag yet. Unassign if all of them have the tag already.")
|
||||
@@ -188,15 +181,15 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Collection<DistributionSet> groupA = testdataFactory.createDistributionSets(20);
|
||||
final Collection<DistributionSet> groupB = testdataFactory.createDistributionSets("unassigned", 20);
|
||||
|
||||
final DistributionSetTag tag = tagManagement
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
||||
final DistributionSetTag tag = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
||||
|
||||
// toggle A only -> A is now assigned
|
||||
DistributionSetTagAssignmentResult result = toggleTagAssignment(groupA, tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(distributionSetManagement
|
||||
.findDistributionSetsById(groupA.stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
||||
.get(groupA.stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
||||
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
||||
@@ -206,7 +199,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(distributionSetManagement
|
||||
.findDistributionSetsById(groupB.stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
||||
.get(groupB.stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
||||
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
||||
@@ -217,147 +210,24 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(result.getAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssignedEntity()).isEmpty();
|
||||
assertThat(result.getUnassigned()).isEqualTo(40);
|
||||
assertThat(result.getUnassignedEntity()).containsAll(distributionSetManagement.findDistributionSetsById(
|
||||
assertThat(result.getUnassignedEntity()).containsAll(distributionSetManagement.get(
|
||||
concat(groupB, groupA).stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
||||
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies the toogle mechanism by means on assigning tag if at least on target in the list does not have"
|
||||
+ "the tag yet. Unassign if all of them have the tag already.")
|
||||
public void assignAndUnassignTargetTags() {
|
||||
final List<Target> groupA = testdataFactory.createTargets(20);
|
||||
final List<Target> groupB = testdataFactory.createTargets(20, "groupb", "groupb");
|
||||
|
||||
final TargetTag tag = tagManagement
|
||||
.createTargetTag(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
||||
|
||||
// toggle A only -> A is now assigned
|
||||
TargetTagAssignmentResult result = toggleTagAssignment(groupA, tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(targetManagement.findTargetsByControllerID(
|
||||
groupA.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||
|
||||
// toggle A+B -> A is still assigned and B is assigned as well
|
||||
result = toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(targetManagement.findTargetsByControllerID(
|
||||
groupB.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||
|
||||
// toggle A+B -> both unassigned
|
||||
result = toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssignedEntity()).isEmpty();
|
||||
assertThat(result.getUnassigned()).isEqualTo(40);
|
||||
assertThat(result.getUnassignedEntity()).containsAll(targetManagement.findTargetsByControllerID(
|
||||
concat(groupB, groupA).stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
private final <T> Collection<T> concat(final Collection<T>... targets) {
|
||||
final List<T> result = new ArrayList<>();
|
||||
Arrays.asList(targets).forEach(result::addAll);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that all tags are retrieved through repository.")
|
||||
public void findAllTargetTags() {
|
||||
final List<JpaTargetTag> tags = createTargetsWithTags();
|
||||
|
||||
assertThat(targetTagRepository.findAll()).isEqualTo(targetTagRepository.findAll()).isEqualTo(tags)
|
||||
.as("Wrong tag size").hasSize(20);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a created tag is persisted in the repository as defined.")
|
||||
public void createTargetTag() {
|
||||
final Tag tag = tagManagement
|
||||
.createTargetTag(entityFactory.tag().create().name("kai1").description("kai2").colour("colour"));
|
||||
|
||||
assertThat(targetTagRepository.findByNameEquals("kai1").get().getDescription()).as("wrong tag ed")
|
||||
.isEqualTo("kai2");
|
||||
assertThat(tagManagement.findTargetTag("kai1").get().getColour()).as("wrong tag found").isEqualTo("colour");
|
||||
assertThat(tagManagement.findTargetTagById(tag.getId()).get().getColour()).as("wrong tag found")
|
||||
.isEqualTo("colour");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a deleted tag is removed from the repository as defined.")
|
||||
public void deleteTargetTags() {
|
||||
|
||||
// create test data
|
||||
final Iterable<JpaTargetTag> tags = createTargetsWithTags();
|
||||
final TargetTag toDelete = tags.iterator().next();
|
||||
|
||||
for (final Target target : targetRepository.findAll()) {
|
||||
assertThat(tagManagement.findAllTargetTags(PAGE, target.getControllerId()).getContent())
|
||||
.contains(toDelete);
|
||||
}
|
||||
|
||||
// delete
|
||||
tagManagement.deleteTargetTag(toDelete.getName());
|
||||
|
||||
// check
|
||||
for (final Target target : targetRepository.findAll()) {
|
||||
assertThat(tagManagement.findAllTargetTags(PAGE, target.getControllerId()).getContent())
|
||||
.doesNotContain(toDelete);
|
||||
}
|
||||
assertThat(targetTagRepository.findOne(toDelete.getId())).as("No tag should be found").isNull();
|
||||
assertThat(targetTagRepository.findAll()).as("Wrong target tag size").hasSize(19);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the name update of a target tag.")
|
||||
public void updateTargetTag() {
|
||||
final List<JpaTargetTag> tags = createTargetsWithTags();
|
||||
|
||||
// change data
|
||||
final TargetTag savedAssigned = tags.iterator().next();
|
||||
|
||||
// persist
|
||||
tagManagement.updateTargetTag(entityFactory.tag().update(savedAssigned.getId()).name("test123"));
|
||||
|
||||
// check data
|
||||
assertThat(targetTagRepository.findAll()).as("Wrong target tag size").hasSize(tags.size());
|
||||
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getName()).as("wrong target tag is saved")
|
||||
.isEqualTo("test123");
|
||||
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getOptLockRevision())
|
||||
.as("wrong target tag is saved").isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a created tag is persisted in the repository as defined.")
|
||||
public void createDistributionSetTag() {
|
||||
final Tag tag = tagManagement.createDistributionSetTag(
|
||||
final Tag tag = distributionSetTagManagement.create(
|
||||
entityFactory.tag().create().name("kai1").description("kai2").colour("colour"));
|
||||
|
||||
assertThat(distributionSetTagRepository.findByNameEquals("kai1").get().getDescription()).as("wrong tag found")
|
||||
.isEqualTo("kai2");
|
||||
assertThat(tagManagement.findDistributionSetTag("kai1").get().getColour()).as("wrong tag found")
|
||||
assertThat(distributionSetTagManagement.getByName("kai1").get().getColour()).as("wrong tag found")
|
||||
.isEqualTo("colour");
|
||||
assertThat(tagManagement.findDistributionSetTagById(tag.getId()).get().getColour()).as("wrong tag found")
|
||||
.isEqualTo("colour");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a created tags are persisted in the repository as defined.")
|
||||
public void createDistributionSetTags() {
|
||||
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
||||
|
||||
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags created").hasSize(tags.size());
|
||||
assertThat(distributionSetTagManagement.get(tag.getId()).get().getColour())
|
||||
.as("wrong tag found").isEqualTo("colour");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -373,11 +243,11 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
// delete
|
||||
tagManagement.deleteDistributionSetTag(tags.iterator().next().getName());
|
||||
distributionSetTagManagement.delete(tags.iterator().next().getName());
|
||||
|
||||
// check
|
||||
assertThat(distributionSetTagRepository.findOne(toDelete.getId())).as("Deleted tag should be null").isNull();
|
||||
assertThat(tagManagement.findAllDistributionSetTags(PAGE).getContent())
|
||||
assertThat(distributionSetTagManagement.findAll(PAGE).getContent())
|
||||
.as("Wrong size of tags after deletion").hasSize(19);
|
||||
|
||||
for (final DistributionSet set : distributionSetRepository.findAll()) {
|
||||
@@ -386,39 +256,12 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
|
||||
public void failedDuplicateTargetTagNameException() {
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("A"));
|
||||
|
||||
try {
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("A"));
|
||||
fail("should not have worked as tag already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
|
||||
public void failedDuplicateTargetTagNameExceptionAfterUpdate() {
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("A"));
|
||||
final TargetTag tag = tagManagement.createTargetTag(entityFactory.tag().create().name("B"));
|
||||
|
||||
try {
|
||||
tagManagement.updateTargetTag(entityFactory.tag().update(tag.getId()).name("A"));
|
||||
fail("should not have worked as tag already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
|
||||
public void failedDuplicateDsTagNameException() {
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("A"));
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
try {
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("A"));
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
fail("should not have worked as tag already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
@@ -428,11 +271,12 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
|
||||
public void failedDuplicateDsTagNameExceptionAfterUpdate() {
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("A"));
|
||||
final DistributionSetTag tag = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("B"));
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
final DistributionSetTag tag = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("B"));
|
||||
|
||||
try {
|
||||
tagManagement.updateDistributionSetTag(entityFactory.tag().update(tag.getId()).name("A"));
|
||||
distributionSetTagManagement.update(entityFactory.tag().update(tag.getId()).name("A"));
|
||||
fail("should not have worked as tag already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
@@ -450,11 +294,12 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSetTag savedAssigned = tags.iterator().next();
|
||||
|
||||
// persist
|
||||
tagManagement.updateDistributionSetTag(entityFactory.tag().update(savedAssigned.getId()).name("test123"));
|
||||
distributionSetTagManagement
|
||||
.update(entityFactory.tag().update(savedAssigned.getId()).name("test123"));
|
||||
|
||||
// check data
|
||||
assertThat(tagManagement.findAllDistributionSetTags(PAGE).getContent()).as("Wrong size of ds tags")
|
||||
.hasSize(tags.size());
|
||||
assertThat(distributionSetTagManagement.findAll(PAGE).getContent())
|
||||
.as("Wrong size of ds tags").hasSize(tags.size());
|
||||
assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).as("Wrong ds tag found")
|
||||
.isEqualTo("test123");
|
||||
}
|
||||
@@ -465,18 +310,17 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
||||
|
||||
// test
|
||||
assertThat(tagManagement.findAllDistributionSetTags(PAGE).getContent()).as("Wrong size of tags")
|
||||
assertThat(distributionSetTagManagement.findAll(PAGE).getContent()).as("Wrong size of tags")
|
||||
.hasSize(tags.size());
|
||||
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags").hasSize(20);
|
||||
}
|
||||
|
||||
private List<JpaTargetTag> createTargetsWithTags() {
|
||||
final List<Target> targets = testdataFactory.createTargets(20);
|
||||
final Iterable<TargetTag> tags = testdataFactory.createTargetTags(20, "");
|
||||
@Test
|
||||
@Description("Ensures that a created tags are persisted in the repository as defined.")
|
||||
public void createDistributionSetTags() {
|
||||
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
||||
|
||||
tags.forEach(tag -> toggleTagAssignment(targets, tag));
|
||||
|
||||
return targetTagRepository.findAll();
|
||||
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags created").hasSize(tags.size());
|
||||
}
|
||||
|
||||
private List<DistributionSetTag> createDsSetsWithTags() {
|
||||
@@ -486,6 +330,18 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
tags.forEach(tag -> toggleTagAssignment(sets, tag));
|
||||
|
||||
return tagManagement.findAllDistributionSetTags(PAGE).getContent();
|
||||
return distributionSetTagManagement.findAll(PAGE).getContent();
|
||||
}
|
||||
|
||||
private DistributionSetFilterBuilder getDistributionSetFilterBuilder() {
|
||||
return new DistributionSetFilterBuilder();
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
private final <T> Collection<T> concat(final Collection<T>... targets) {
|
||||
final List<T> result = new ArrayList<>();
|
||||
Arrays.asList(targets).forEach(result::addAll);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,9 +48,9 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
+ "of Optional not present.")
|
||||
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 0) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.getByKey(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,15 +71,10 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
testdataFactory.findOrCreateDistributionSetType("xxx", "xxx").getId(), Arrays.asList(NOT_EXIST_IDL)),
|
||||
"SoftwareModuleType");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetTypeManagement.countDistributionSetsByType(NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetTypeManagement.deleteDistributionSetType(NOT_EXIST_IDL),
|
||||
"DistributionSetType");
|
||||
verifyThrownExceptionBy(() -> distributionSetTypeManagement.delete(NOT_EXIST_IDL), "DistributionSetType");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetTypeManagement
|
||||
.updateDistributionSetType(entityFactory.distributionSetType().update(NOT_EXIST_IDL)),
|
||||
() -> distributionSetTypeManagement.update(entityFactory.distributionSetType().update(NOT_EXIST_IDL)),
|
||||
"DistributionSet");
|
||||
}
|
||||
|
||||
@@ -100,12 +95,12 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
private void createAndUpdateDistributionSetWithInvalidDescription(final DistributionSet set) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet()
|
||||
.create().name("a").version("a").description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("set with too long description should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet()
|
||||
.update(set.getId()).description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("set with too long description should not be updated");
|
||||
|
||||
@@ -115,28 +110,28 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
private void createAndUpdateDistributionSetWithInvalidName(final DistributionSet set) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet()
|
||||
.create().version("a").name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("set with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().version("a").name("")))
|
||||
.create(entityFactory.distributionSet().create().version("a").name("")))
|
||||
.as("set with too short name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().version("a").name(null)))
|
||||
.create(entityFactory.distributionSet().create().version("a").name(null)))
|
||||
.as("set with null name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet()
|
||||
.update(set.getId()).name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("set with too long name should not be updated");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(set.getId()).name("")))
|
||||
.update(entityFactory.distributionSet().update(set.getId()).name("")))
|
||||
.as("set with too short name should not be updated");
|
||||
}
|
||||
|
||||
@@ -144,85 +139,80 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
private void createAndUpdateDistributionSetWithInvalidVersion(final DistributionSet set) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet()
|
||||
.create().name("a").version(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("set with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("a").version("")))
|
||||
.create(entityFactory.distributionSet().create().name("a").version("")))
|
||||
.as("set with too short name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("a").version(null)))
|
||||
.create(entityFactory.distributionSet().create().name("a").version(null)))
|
||||
.as("set with null name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet()
|
||||
.update(set.getId()).version(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("set with too long name should not be updated");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(set.getId()).version("")))
|
||||
.update(entityFactory.distributionSet().update(set.getId()).version("")))
|
||||
.as("set with too short name should not be updated");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the successfull module update of unused distribution set type which is in fact allowed.")
|
||||
public void updateUnassignedDistributionSetTypeModules() {
|
||||
final DistributionSetType updatableType = distributionSetTypeManagement.createDistributionSetType(
|
||||
entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get()
|
||||
.getMandatoryModuleTypes()).isEmpty();
|
||||
final DistributionSetType updatableType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
|
||||
// add OS
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(),
|
||||
Sets.newHashSet(osType.getId()));
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get()
|
||||
.getMandatoryModuleTypes()).containsOnly(osType);
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
|
||||
.containsOnly(osType);
|
||||
|
||||
// add JVM
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(),
|
||||
Sets.newHashSet(runtimeType.getId()));
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get()
|
||||
.getMandatoryModuleTypes()).containsOnly(osType, runtimeType);
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
|
||||
.containsOnly(osType, runtimeType);
|
||||
|
||||
// remove OS
|
||||
distributionSetTypeManagement.unassignSoftwareModuleType(updatableType.getId(), osType.getId());
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get()
|
||||
.getMandatoryModuleTypes()).containsOnly(runtimeType);
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
|
||||
.containsOnly(runtimeType);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the successfull update of used distribution set type meta data which is in fact allowed.")
|
||||
public void updateAssignedDistributionSetTypeMetaData() {
|
||||
final DistributionSetType nonUpdatableType = distributionSetTypeManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("updatableType")
|
||||
.name("to be deleted").colour("test123"));
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get()
|
||||
.getMandatoryModuleTypes()).isEmpty();
|
||||
distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create().name("newtypesoft")
|
||||
final DistributionSetType nonUpdatableType = distributionSetTypeManagement.create(entityFactory
|
||||
.distributionSetType().create().key("updatableType").name("to be deleted").colour("test123"));
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
distributionSetManagement.create(entityFactory.distributionSet().create().name("newtypesoft")
|
||||
.version("1").type(nonUpdatableType.getKey()));
|
||||
|
||||
distributionSetTypeManagement.updateDistributionSetType(
|
||||
distributionSetTypeManagement.update(
|
||||
entityFactory.distributionSetType().update(nonUpdatableType.getId()).description("a new description"));
|
||||
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get().getDescription())
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getDescription())
|
||||
.isEqualTo("a new description");
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get().getColour())
|
||||
.isEqualTo("test123");
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getColour()).isEqualTo("test123");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the unsuccessfull update of used distribution set type (module addition).")
|
||||
public void addModuleToAssignedDistributionSetTypeFails() {
|
||||
final DistributionSetType nonUpdatableType = distributionSetTypeManagement.createDistributionSetType(
|
||||
entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get()
|
||||
.getMandatoryModuleTypes()).isEmpty();
|
||||
distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create().name("newtypesoft")
|
||||
final DistributionSetType nonUpdatableType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
distributionSetManagement.create(entityFactory.distributionSet().create().name("newtypesoft")
|
||||
.version("1").type(nonUpdatableType.getKey()));
|
||||
|
||||
assertThatThrownBy(() -> distributionSetTypeManagement
|
||||
@@ -233,14 +223,13 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
@Test
|
||||
@Description("Tests the unsuccessfull update of used distribution set type (module removal).")
|
||||
public void removeModuleToAssignedDistributionSetTypeFails() {
|
||||
DistributionSetType nonUpdatableType = distributionSetTypeManagement.createDistributionSetType(
|
||||
entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get()
|
||||
.getMandatoryModuleTypes()).isEmpty();
|
||||
DistributionSetType nonUpdatableType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
|
||||
nonUpdatableType = distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(nonUpdatableType.getId(),
|
||||
Sets.newHashSet(osType.getId()));
|
||||
distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create().name("newtypesoft")
|
||||
distributionSetManagement.create(entityFactory.distributionSet().create().name("newtypesoft")
|
||||
.version("1").type(nonUpdatableType.getKey()));
|
||||
|
||||
final Long typeId = nonUpdatableType.getId();
|
||||
@@ -252,11 +241,10 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
@Description("Tests the successfull deletion of unused (hard delete) distribution set types.")
|
||||
public void deleteUnassignedDistributionSetType() {
|
||||
final JpaDistributionSetType hardDelete = (JpaDistributionSetType) distributionSetTypeManagement
|
||||
.createDistributionSetType(
|
||||
entityFactory.distributionSetType().create().key("delete").name("to be deleted"));
|
||||
.create(entityFactory.distributionSetType().create().key("delete").name("to be deleted"));
|
||||
|
||||
assertThat(distributionSetTypeRepository.findAll()).contains(hardDelete);
|
||||
distributionSetTypeManagement.deleteDistributionSetType(hardDelete.getId());
|
||||
distributionSetTypeManagement.delete(hardDelete.getId());
|
||||
|
||||
assertThat(distributionSetTypeRepository.findAll()).doesNotContain(hardDelete);
|
||||
}
|
||||
@@ -265,16 +253,14 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
@Description("Tests the successfull deletion of used (soft delete) distribution set types.")
|
||||
public void deleteAssignedDistributionSetType() {
|
||||
final JpaDistributionSetType softDelete = (JpaDistributionSetType) distributionSetTypeManagement
|
||||
.createDistributionSetType(
|
||||
entityFactory.distributionSetType().create().key("softdeleted").name("to be deleted"));
|
||||
.create(entityFactory.distributionSetType().create().key("softdeleted").name("to be deleted"));
|
||||
|
||||
assertThat(distributionSetTypeRepository.findAll()).contains(softDelete);
|
||||
distributionSetManagement.createDistributionSet(
|
||||
distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name("softdeleted").version("1").type(softDelete.getKey()));
|
||||
|
||||
distributionSetTypeManagement.deleteDistributionSetType(softDelete.getId());
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("softdeleted").get().isDeleted())
|
||||
.isEqualTo(true);
|
||||
distributionSetTypeManagement.delete(softDelete.getId());
|
||||
assertThat(distributionSetTypeManagement.getByKey("softdeleted").get().isDeleted()).isEqualTo(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ public class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
|
||||
+ "of Optional not present.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(rolloutGroupManagement.findRolloutGroupById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(rolloutGroupManagement.findRolloutGroupWithDetailedStatus(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(rolloutGroupManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(rolloutGroupManagement.getWithDetailedStatus(NOT_EXIST_IDL)).isNotPresent();
|
||||
|
||||
}
|
||||
|
||||
@@ -52,19 +52,19 @@ public class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
testdataFactory.createRollout("xxx");
|
||||
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.countRolloutGroupsByRolloutId(NOT_EXIST_IDL), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.countByRollout(NOT_EXIST_IDL), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.countTargetsOfRolloutsGroup(NOT_EXIST_IDL),
|
||||
"RolloutGroup");
|
||||
verifyThrownExceptionBy(
|
||||
() -> rolloutGroupManagement.findAllRolloutGroupsWithDetailedStatus(NOT_EXIST_IDL, PAGE), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findAllTargetsWithActionStatus(PAGE, NOT_EXIST_IDL),
|
||||
() -> rolloutGroupManagement.findByRolloutWithDetailedStatus(PAGE, NOT_EXIST_IDL), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findAllTargetsOfRolloutGroupWithActionStatus(PAGE, NOT_EXIST_IDL),
|
||||
"RolloutGroup");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findRolloutGroupsAll(NOT_EXIST_IDL, "name==*", PAGE),
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findByRolloutAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"Rollout");
|
||||
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findRolloutGroupTargets(NOT_EXIST_IDL, PAGE),
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findTargetsOfRolloutGroup(PAGE, NOT_EXIST_IDL),
|
||||
"RolloutGroup");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findRolloutGroupTargets(NOT_EXIST_IDL, "name==*", PAGE),
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"RolloutGroup");
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
// start rollout
|
||||
final Rollout rollout = testdataFactory.createRolloutByVariables("rolloutNotCancelRunningAction", "description",
|
||||
1, "name==*", knownDistributionSet, "50", "5");
|
||||
rolloutManagement.startRollout(rollout.getId());
|
||||
rolloutManagement.start(rollout.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
// verify that manually created action is still running and action
|
||||
@@ -124,9 +124,9 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
+ "of Optional not present.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(rolloutManagement.findRolloutById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(rolloutManagement.findRolloutByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(rolloutManagement.findRolloutWithDetailedStatus(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(rolloutManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(rolloutManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(rolloutManagement.getWithDetailedStatus(NOT_EXIST_IDL)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -142,13 +142,13 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
testdataFactory.createRollout("xxx");
|
||||
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.deleteRollout(NOT_EXIST_IDL), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.delete(NOT_EXIST_IDL), "Rollout");
|
||||
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.pauseRollout(NOT_EXIST_IDL), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.resumeRollout(NOT_EXIST_IDL), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.startRollout(NOT_EXIST_IDL), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.start(NOT_EXIST_IDL), "Rollout");
|
||||
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.updateRollout(entityFactory.rollout().update(NOT_EXIST_IDL)),
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.update(entityFactory.rollout().update(NOT_EXIST_IDL)),
|
||||
"Rollout");
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// verify the split of the target and targetGroup
|
||||
final Page<RolloutGroup> rolloutGroups = rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(createdRollout.getId(), PAGE);
|
||||
.findByRollout(PAGE, createdRollout.getId());
|
||||
// we have total of #amountTargetsForRollout in rollouts splitted in
|
||||
// group size #groupSize
|
||||
assertThat(rolloutGroups).hasSize(amountGroups);
|
||||
@@ -183,13 +183,13 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
successCondition, errorCondition);
|
||||
|
||||
// verify first group is running
|
||||
final RolloutGroup firstGroup = rolloutGroupManagement.findRolloutGroupsByRolloutId(createdRollout.getId(),
|
||||
new OffsetBasedPageRequest(0, 1, new Sort(Direction.ASC, "id"))).getContent().get(0);
|
||||
final RolloutGroup firstGroup = rolloutGroupManagement.findByRollout(new OffsetBasedPageRequest(0, 1, new Sort(Direction.ASC, "id")),
|
||||
createdRollout.getId()).getContent().get(0);
|
||||
assertThat(firstGroup.getStatus()).isEqualTo(RolloutGroupStatus.RUNNING);
|
||||
|
||||
// verify other groups are scheduled
|
||||
final List<RolloutGroup> scheduledGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(1, 100, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> scheduledGroups = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(1, 100, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
scheduledGroups.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.SCHEDULED)
|
||||
.as("group which should be in scheduled state is in " + group.getStatus() + " state"));
|
||||
// verify that the first group actions has been started and are in state
|
||||
@@ -224,15 +224,15 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
// verify that now the first and the second group are in running state
|
||||
final List<RolloutGroup> runningRolloutGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(0, 2, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> runningRolloutGroups = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(0, 2, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
runningRolloutGroups.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.RUNNING)
|
||||
.as("group should be in running state because it should be started but it is in " + group.getStatus()
|
||||
+ " state"));
|
||||
|
||||
// verify that the other groups are still in schedule state
|
||||
final List<RolloutGroup> scheduledRolloutGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(2, 10, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> scheduledRolloutGroups = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(2, 10, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
scheduledRolloutGroups.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.SCHEDULED)
|
||||
.as("group should be in scheduled state because it should not be started but it is in "
|
||||
+ group.getStatus() + " state"));
|
||||
@@ -269,12 +269,12 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final Rollout createdRollout = createSimpleTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout,
|
||||
amountOtherTargets, amountGroups, successCondition, errorCondition);
|
||||
rolloutManagement.startRollout(createdRollout.getId());
|
||||
rolloutManagement.start(createdRollout.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
return rolloutManagement.findRolloutById(createdRollout.getId()).get();
|
||||
return rolloutManagement.get(createdRollout.getId()).get();
|
||||
}
|
||||
|
||||
@Step("Finish three actions of the rollout group and delete two targets")
|
||||
@@ -286,15 +286,15 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
finishAction(runningActions.get(0));
|
||||
finishAction(runningActions.get(1));
|
||||
finishAction(runningActions.get(2));
|
||||
targetManagement.deleteTargets(
|
||||
targetManagement.delete(
|
||||
Arrays.asList(runningActions.get(3).getTarget().getId(), runningActions.get(4).getTarget().getId()));
|
||||
}
|
||||
|
||||
@Step("Check the status of the rollout groups, second group should be in running status")
|
||||
private void checkSecondGroupStatusIsRunning(final Rollout createdRollout) {
|
||||
rolloutManagement.handleRollouts();
|
||||
final List<RolloutGroup> runningRolloutGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(0, 10, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> runningRolloutGroups = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(0, 10, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
assertThat(runningRolloutGroups.get(0).getStatus()).isEqualTo(RolloutGroupStatus.FINISHED);
|
||||
assertThat(runningRolloutGroups.get(1).getStatus()).isEqualTo(RolloutGroupStatus.RUNNING);
|
||||
assertThat(runningRolloutGroups.get(2).getStatus()).isEqualTo(RolloutGroupStatus.SCHEDULED);
|
||||
@@ -306,7 +306,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
createdRollout.getId(), Status.RUNNING);
|
||||
final List<JpaAction> runningActions = runningActionsSlice.getContent();
|
||||
finishAction(runningActions.get(0));
|
||||
targetManagement.deleteTargets(
|
||||
targetManagement.delete(
|
||||
Arrays.asList(runningActions.get(1).getTarget().getId(), runningActions.get(2).getTarget().getId(),
|
||||
runningActions.get(3).getTarget().getId(), runningActions.get(4).getTarget().getId()));
|
||||
|
||||
@@ -317,7 +317,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Slice<JpaAction> runningActionsSlice = actionRepository.findByRolloutIdAndStatus(PAGE,
|
||||
createdRollout.getId(), Status.SCHEDULED);
|
||||
final List<JpaAction> runningActions = runningActionsSlice.getContent();
|
||||
targetManagement.deleteTargets(Arrays.asList(runningActions.get(0).getTarget().getId(),
|
||||
targetManagement.delete(Arrays.asList(runningActions.get(0).getTarget().getId(),
|
||||
runningActions.get(1).getTarget().getId(), runningActions.get(2).getTarget().getId(),
|
||||
runningActions.get(3).getTarget().getId(), runningActions.get(4).getTarget().getId()));
|
||||
}
|
||||
@@ -326,11 +326,11 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void verifyRolloutAndAllGroupsAreFinished(final Rollout createdRollout) {
|
||||
rolloutManagement.handleRollouts();
|
||||
final List<RolloutGroup> runningRolloutGroups = rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(createdRollout.getId(), PAGE).getContent();
|
||||
.findByRollout(PAGE, createdRollout.getId()).getContent();
|
||||
assertThat(runningRolloutGroups.get(0).getStatus()).isEqualTo(RolloutGroupStatus.FINISHED);
|
||||
assertThat(runningRolloutGroups.get(1).getStatus()).isEqualTo(RolloutGroupStatus.FINISHED);
|
||||
assertThat(runningRolloutGroups.get(2).getStatus()).isEqualTo(RolloutGroupStatus.FINISHED);
|
||||
assertThat(rolloutManagement.findRolloutById(createdRollout.getId()).get().getStatus())
|
||||
assertThat(rolloutManagement.get(createdRollout.getId()).get().getStatus())
|
||||
.isEqualTo(RolloutStatus.FINISHED);
|
||||
|
||||
}
|
||||
@@ -365,19 +365,19 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
// and should execute the error action
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
final Rollout rollout = rolloutManagement.findRolloutById(createdRollout.getId()).get();
|
||||
final Rollout rollout = rolloutManagement.get(createdRollout.getId()).get();
|
||||
// the rollout itself should be in paused based on the error action
|
||||
assertThat(rollout.getStatus()).isEqualTo(RolloutStatus.PAUSED);
|
||||
|
||||
// the first rollout group should be in error state
|
||||
final List<RolloutGroup> errorGroup = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(0, 1, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> errorGroup = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(0, 1, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
assertThat(errorGroup).hasSize(1);
|
||||
assertThat(errorGroup.get(0).getStatus()).isEqualTo(RolloutGroupStatus.ERROR);
|
||||
|
||||
// all other groups should still be in scheduled state
|
||||
final List<RolloutGroup> scheduleGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(1, 100, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> scheduleGroups = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(1, 100, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
scheduleGroups.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.SCHEDULED));
|
||||
}
|
||||
|
||||
@@ -405,28 +405,28 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
// and should execute the error action
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
final Rollout rollout = rolloutManagement.findRolloutById(createdRollout.getId()).get();
|
||||
final Rollout rollout = rolloutManagement.get(createdRollout.getId()).get();
|
||||
// the rollout itself should be in paused based on the error action
|
||||
assertThat(rollout.getStatus()).isEqualTo(RolloutStatus.PAUSED);
|
||||
|
||||
// all other groups should still be in scheduled state
|
||||
final List<RolloutGroup> scheduleGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(1, 100, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> scheduleGroups = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(1, 100, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
scheduleGroups.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.SCHEDULED));
|
||||
|
||||
// resume the rollout again after it gets paused by error action
|
||||
rolloutManagement.resumeRollout(createdRollout.getId());
|
||||
|
||||
// the rollout should be running again
|
||||
assertThat(rolloutManagement.findRolloutById(createdRollout.getId()).get().getStatus())
|
||||
assertThat(rolloutManagement.get(createdRollout.getId()).get().getStatus())
|
||||
.isEqualTo(RolloutStatus.RUNNING);
|
||||
|
||||
// checking rollouts again
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
// next group should be running again after resuming the rollout
|
||||
final List<RolloutGroup> resumedGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(1, 1, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> resumedGroups = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(1, 1, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
assertThat(resumedGroups).hasSize(1);
|
||||
assertThat(resumedGroups.get(0).getStatus()).isEqualTo(RolloutGroupStatus.RUNNING);
|
||||
}
|
||||
@@ -451,7 +451,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutManagement.handleRollouts();
|
||||
// finish running actions, 2 actions should be finished
|
||||
assertThat(changeStatusForAllRunningActions(createdRollout, Status.FINISHED)).isEqualTo(2);
|
||||
assertThat(rolloutManagement.findRolloutById(createdRollout.getId()).get().getStatus())
|
||||
assertThat(rolloutManagement.get(createdRollout.getId()).get().getStatus())
|
||||
.isEqualTo(RolloutStatus.RUNNING);
|
||||
|
||||
}
|
||||
@@ -461,12 +461,12 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// verify all groups are in finished state
|
||||
rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(createdRollout.getId(),
|
||||
new OffsetBasedPageRequest(0, 100, new Sort(Direction.ASC, "id")))
|
||||
.findByRollout(new OffsetBasedPageRequest(0, 100, new Sort(Direction.ASC, "id")),
|
||||
createdRollout.getId())
|
||||
.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.FINISHED));
|
||||
|
||||
// verify that rollout itself is in finished state
|
||||
final Rollout findRolloutById = rolloutManagement.findRolloutById(createdRollout.getId()).get();
|
||||
final Rollout findRolloutById = rolloutManagement.get(createdRollout.getId()).get();
|
||||
assertThat(findRolloutById.getStatus()).isEqualTo(RolloutStatus.FINISHED);
|
||||
}
|
||||
|
||||
@@ -487,7 +487,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
validationMap.put(TotalTargetCountStatus.Status.NOTSTARTED, 8L);
|
||||
validateRolloutActionStatus(createdRollout.getId(), validationMap);
|
||||
|
||||
rolloutManagement.startRollout(createdRollout.getId());
|
||||
rolloutManagement.start(createdRollout.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
@@ -550,7 +550,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
validationMap.put(TotalTargetCountStatus.Status.NOTSTARTED, 8L);
|
||||
validateRolloutActionStatus(createdRollout.getId(), validationMap);
|
||||
|
||||
rolloutManagement.startRollout(createdRollout.getId());
|
||||
rolloutManagement.start(createdRollout.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
@@ -589,9 +589,9 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
// round(7/3)=2 targets running (Group 3)
|
||||
// round(5/2)=3 targets SCHEDULED (Group 3)
|
||||
// round(2/1)=2 targets SCHEDULED (Group 4)
|
||||
createdRollout = rolloutManagement.findRolloutById(createdRollout.getId()).get();
|
||||
createdRollout = rolloutManagement.get(createdRollout.getId()).get();
|
||||
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(createdRollout.getId(), PAGE).getContent();
|
||||
.findByRollout(PAGE, createdRollout.getId()).getContent();
|
||||
|
||||
Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.FINISHED, 2L);
|
||||
@@ -624,15 +624,15 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
successCondition, errorCondition);
|
||||
final DistributionSet ds = createdRollout.getDistributionSet();
|
||||
|
||||
createdRollout = rolloutManagement.findRolloutById(createdRollout.getId()).get();
|
||||
createdRollout = rolloutManagement.get(createdRollout.getId()).get();
|
||||
// 5 targets are running
|
||||
final List<Action> runningActions = findActionsByRolloutAndStatus(createdRollout, Status.RUNNING);
|
||||
assertThat(runningActions.size()).isEqualTo(5);
|
||||
|
||||
// 5 targets are in the group and the DS has been assigned
|
||||
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(createdRollout.getId(), PAGE).getContent();
|
||||
final Page<Target> targets = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(0).getId(), PAGE);
|
||||
.findByRollout(PAGE, createdRollout.getId()).getContent();
|
||||
final Page<Target> targets = rolloutGroupManagement.findTargetsOfRolloutGroup(PAGE, rolloutGroups.get(0).getId());
|
||||
final List<Target> targetList = targets.getContent();
|
||||
assertThat(targetList.size()).isEqualTo(5);
|
||||
|
||||
@@ -665,7 +665,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
Rollout rolloutOne = createAndStartRollout(amountTargetsForRollout, amountOtherTargets, amountGroups,
|
||||
successCondition, errorCondition);
|
||||
|
||||
rolloutOne = rolloutManagement.findRolloutById(rolloutOne.getId()).get();
|
||||
rolloutOne = rolloutManagement.get(rolloutOne.getId()).get();
|
||||
|
||||
final DistributionSet dsForRolloutTwo = testdataFactory.createDistributionSet("dsForRolloutTwo");
|
||||
|
||||
@@ -680,7 +680,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.SCHEDULED, 5L);
|
||||
validateRolloutActionStatus(rolloutOne.getId(), expectedTargetCountStatus);
|
||||
|
||||
rolloutManagement.startRollout(rolloutTwo.getId());
|
||||
rolloutManagement.start(rolloutTwo.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
@@ -707,7 +707,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
successCondition, errorCondition);
|
||||
final DistributionSet distributionSet = rolloutOne.getDistributionSet();
|
||||
|
||||
rolloutOne = rolloutManagement.findRolloutById(rolloutOne.getId()).get();
|
||||
rolloutOne = rolloutManagement.get(rolloutOne.getId()).get();
|
||||
changeStatusForRunningActions(rolloutOne, Status.ERROR, 2);
|
||||
changeStatusForRunningActions(rolloutOne, Status.FINISHED, 3);
|
||||
rolloutManagement.handleRollouts();
|
||||
@@ -724,7 +724,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.ERROR, 6L);
|
||||
validateRolloutActionStatus(rolloutOne.getId(), expectedTargetCountStatus);
|
||||
// rollout is finished
|
||||
rolloutOne = rolloutManagement.findRolloutById(rolloutOne.getId()).get();
|
||||
rolloutOne = rolloutManagement.get(rolloutOne.getId()).get();
|
||||
assertThat(rolloutOne.getStatus()).isEqualTo(RolloutStatus.FINISHED);
|
||||
|
||||
final int amountGroupsForRolloutTwo = 1;
|
||||
@@ -732,19 +732,19 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
"This is the description for rollout two", amountGroupsForRolloutTwo, "controllerId==rollout-*",
|
||||
distributionSet, "50", "80");
|
||||
|
||||
rolloutManagement.startRollout(rolloutTwo.getId());
|
||||
rolloutManagement.start(rolloutTwo.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
rolloutTwo = rolloutManagement.findRolloutById(rolloutTwo.getId()).get();
|
||||
rolloutTwo = rolloutManagement.get(rolloutTwo.getId()).get();
|
||||
// 6 error targets are now running
|
||||
expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 6L);
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.FINISHED, 9L);
|
||||
validateRolloutActionStatus(rolloutTwo.getId(), expectedTargetCountStatus);
|
||||
changeStatusForAllRunningActions(rolloutTwo, Status.FINISHED);
|
||||
final Page<Target> targetPage = targetManagement.findTargetByUpdateStatus(PAGE, TargetUpdateStatus.IN_SYNC);
|
||||
final Page<Target> targetPage = targetManagement.findByUpdateStatus(PAGE, TargetUpdateStatus.IN_SYNC);
|
||||
final List<Target> targetList = targetPage.getContent();
|
||||
// 15 targets in finished/IN_SYNC status and same DS assigned
|
||||
assertThat(targetList.size()).isEqualTo(amountTargetsForRollout);
|
||||
@@ -764,13 +764,13 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
Rollout rolloutOne = createAndStartRollout(amountTargetsForRollout, amountOtherTargets, amountGroups,
|
||||
successCondition, errorCondition);
|
||||
|
||||
rolloutOne = rolloutManagement.findRolloutById(rolloutOne.getId()).get();
|
||||
rolloutOne = rolloutManagement.get(rolloutOne.getId()).get();
|
||||
changeStatusForRunningActions(rolloutOne, Status.ERROR, 2);
|
||||
changeStatusForRunningActions(rolloutOne, Status.FINISHED, 3);
|
||||
rolloutManagement.handleRollouts();
|
||||
// verify: 40% error but 60% finished -> should move to next group
|
||||
final List<RolloutGroup> rolloutGruops = rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(rolloutOne.getId(), PAGE).getContent();
|
||||
.findByRollout(PAGE, rolloutOne.getId()).getContent();
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 5L);
|
||||
validateRolloutGroupActionStatus(rolloutGruops.get(1), expectedTargetCountStatus);
|
||||
@@ -789,14 +789,14 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
Rollout rolloutOne = createAndStartRollout(amountTargetsForRollout, amountOtherTargets, amountGroups,
|
||||
successCondition, errorCondition);
|
||||
|
||||
rolloutOne = rolloutManagement.findRolloutById(rolloutOne.getId()).get();
|
||||
rolloutOne = rolloutManagement.get(rolloutOne.getId()).get();
|
||||
changeStatusForRunningActions(rolloutOne, Status.ERROR, 2);
|
||||
changeStatusForRunningActions(rolloutOne, Status.FINISHED, 3);
|
||||
rolloutManagement.handleRollouts();
|
||||
// verify: 40% error and 60% finished -> should not move to next group
|
||||
// because successCondition 80%
|
||||
final List<RolloutGroup> rolloutGruops = rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(rolloutOne.getId(), PAGE).getContent();
|
||||
.findByRollout(PAGE, rolloutOne.getId()).getContent();
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.SCHEDULED, 5L);
|
||||
validateRolloutGroupActionStatus(rolloutGruops.get(1), expectedTargetCountStatus);
|
||||
@@ -814,12 +814,12 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
Rollout rolloutOne = createAndStartRollout(amountTargetsForRollout, amountOtherTargets, amountGroups,
|
||||
successCondition, errorCondition);
|
||||
|
||||
rolloutOne = rolloutManagement.findRolloutById(rolloutOne.getId()).get();
|
||||
rolloutOne = rolloutManagement.get(rolloutOne.getId()).get();
|
||||
changeStatusForRunningActions(rolloutOne, Status.ERROR, 2);
|
||||
changeStatusForRunningActions(rolloutOne, Status.FINISHED, 3);
|
||||
rolloutManagement.handleRollouts();
|
||||
// verify: 40% error -> should pause because errorCondition is 20%
|
||||
rolloutOne = rolloutManagement.findRolloutById(rolloutOne.getId()).get();
|
||||
rolloutOne = rolloutManagement.get(rolloutOne.getId()).get();
|
||||
assertThat(RolloutStatus.PAUSED).isEqualTo(rolloutOne.getStatus());
|
||||
}
|
||||
|
||||
@@ -833,14 +833,14 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final String errorCondition = "20";
|
||||
final Rollout rolloutA = createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout, amountGroups,
|
||||
successCondition, errorCondition, "RolloutA", "RolloutA");
|
||||
rolloutManagement.startRollout(rolloutA.getId());
|
||||
rolloutManagement.start(rolloutA.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
final int amountTargetsForRollout2 = 10;
|
||||
final int amountGroups2 = 2;
|
||||
final Rollout rolloutB = createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout2, amountGroups2,
|
||||
successCondition, errorCondition, "RolloutB", "RolloutB");
|
||||
rolloutManagement.startRollout(rolloutB.getId());
|
||||
rolloutManagement.start(rolloutB.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
changeStatusForAllRunningActions(rolloutB, Status.FINISHED);
|
||||
@@ -850,7 +850,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final int amountGroups3 = 2;
|
||||
final Rollout rolloutC = createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout3, amountGroups3,
|
||||
successCondition, errorCondition, "RolloutC", "RolloutC");
|
||||
rolloutManagement.startRollout(rolloutC.getId());
|
||||
rolloutManagement.start(rolloutC.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
changeStatusForAllRunningActions(rolloutC, Status.ERROR);
|
||||
@@ -860,7 +860,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final int amountGroups4 = 3;
|
||||
final Rollout rolloutD = createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout4, amountGroups4,
|
||||
successCondition, errorCondition, "RolloutD", "RolloutD");
|
||||
rolloutManagement.startRollout(rolloutD.getId());
|
||||
rolloutManagement.start(rolloutD.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
changeStatusForRunningActions(rolloutD, Status.ERROR, 1);
|
||||
@@ -868,7 +868,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
changeStatusForAllRunningActions(rolloutD, Status.FINISHED);
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
final Page<Rollout> rolloutPage = rolloutManagement.findAllRolloutsWithDetailedStatus(
|
||||
final Page<Rollout> rolloutPage = rolloutManagement.findAllWithDetailedStatus(
|
||||
new OffsetBasedPageRequest(0, 100, new Sort(Direction.ASC, "name")), false);
|
||||
final List<Rollout> rolloutList = rolloutPage.getContent();
|
||||
|
||||
@@ -911,7 +911,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout, amountGroups, successCondition,
|
||||
errorCondition, "Rollout" + i, "Rollout" + i);
|
||||
}
|
||||
final Long count = rolloutManagement.countRolloutsAll();
|
||||
final Long count = rolloutManagement.count();
|
||||
assertThat(count).isEqualTo(10L);
|
||||
}
|
||||
|
||||
@@ -932,7 +932,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
errorCondition, "SomethingElse" + i, "SomethingElse" + i);
|
||||
}
|
||||
|
||||
final Long count = rolloutManagement.countRolloutsAllByFilters("Rollout%");
|
||||
final Long count = rolloutManagement.countByFilters("Rollout%");
|
||||
assertThat(count).isEqualTo(5L);
|
||||
|
||||
}
|
||||
@@ -954,7 +954,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
errorCondition, "SomethingElse" + i, "SomethingElse" + i);
|
||||
}
|
||||
|
||||
final Slice<Rollout> rollout = rolloutManagement.findRolloutWithDetailedStatusByFilters(
|
||||
final Slice<Rollout> rollout = rolloutManagement.findByFiltersWithDetailedStatus(
|
||||
new OffsetBasedPageRequest(0, 100, new Sort(Direction.ASC, "name")), "Rollout%", false);
|
||||
final List<Rollout> rolloutList = rollout.getContent();
|
||||
assertThat(rolloutList.size()).isEqualTo(5);
|
||||
@@ -977,7 +977,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Rollout rolloutCreated = createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout,
|
||||
amountGroups, successCondition, errorCondition, rolloutName, "RolloutA");
|
||||
|
||||
final Rollout rolloutFound = rolloutManagement.findRolloutByName(rolloutName).get();
|
||||
final Rollout rolloutFound = rolloutManagement.getByName(rolloutName).get();
|
||||
assertThat(rolloutCreated).isEqualTo(rolloutFound);
|
||||
|
||||
}
|
||||
@@ -993,18 +993,18 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final String rolloutName = "MyRollout";
|
||||
Rollout myRollout = createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout, amountGroups,
|
||||
successCondition, errorCondition, rolloutName, rolloutName);
|
||||
rolloutManagement.startRollout(myRollout.getId());
|
||||
rolloutManagement.start(myRollout.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
changeStatusForRunningActions(myRollout, Status.FINISHED, 2);
|
||||
rolloutManagement.handleRollouts();
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
|
||||
float percent = rolloutGroupManagement
|
||||
.findRolloutGroupWithDetailedStatus(rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE).getContent().get(0).getId())
|
||||
.getWithDetailedStatus(rolloutGroupManagement
|
||||
.findByRollout(PAGE, myRollout.getId()).getContent().get(0).getId())
|
||||
.get().getTotalTargetCountStatus().getFinishedPercent();
|
||||
assertThat(percent).isEqualTo(40);
|
||||
|
||||
@@ -1012,8 +1012,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
percent = rolloutGroupManagement
|
||||
.findRolloutGroupWithDetailedStatus(rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE).getContent().get(0).getId())
|
||||
.getWithDetailedStatus(rolloutGroupManagement
|
||||
.findByRollout(PAGE, myRollout.getId()).getContent().get(0).getId())
|
||||
.get().getTotalTargetCountStatus().getFinishedPercent();
|
||||
assertThat(percent).isEqualTo(100);
|
||||
|
||||
@@ -1022,8 +1022,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
percent = rolloutGroupManagement
|
||||
.findRolloutGroupWithDetailedStatus(rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE).getContent().get(1).getId())
|
||||
.getWithDetailedStatus(rolloutGroupManagement
|
||||
.findByRollout(PAGE, myRollout.getId()).getContent().get(1).getId())
|
||||
.get().getTotalTargetCountStatus().getFinishedPercent();
|
||||
assertThat(percent).isEqualTo(80);
|
||||
}
|
||||
@@ -1045,7 +1045,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final String rsqlParam = "controllerId==*MyRoll*";
|
||||
|
||||
rolloutManagement.startRollout(myRollout.getId());
|
||||
rolloutManagement.start(myRollout.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
@@ -1053,26 +1053,26 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Condition<String> targetBelongsInRollout = new Condition<>(s -> s.startsWith(rolloutName),
|
||||
"Target belongs into rollout");
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE).getContent();
|
||||
.findByRollout(PAGE, myRollout.getId()).getContent();
|
||||
|
||||
Page<Target> targetPage = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(0).getId(),
|
||||
rsqlParam, new OffsetBasedPageRequest(0, 100));
|
||||
Page<Target> targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(new OffsetBasedPageRequest(0, 100),
|
||||
rolloutGroups.get(0).getId(), rsqlParam);
|
||||
final List<Target> targetlistGroup1 = targetPage.getContent();
|
||||
assertThat(targetlistGroup1.size()).isEqualTo(5);
|
||||
assertThat(targetlistGroup1.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
||||
.are(targetBelongsInRollout);
|
||||
|
||||
targetPage = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(1).getId(), rsqlParam,
|
||||
new OffsetBasedPageRequest(0, 100));
|
||||
targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(new OffsetBasedPageRequest(0, 100), rolloutGroups.get(1).getId(),
|
||||
rsqlParam);
|
||||
final List<Target> targetlistGroup2 = targetPage.getContent();
|
||||
assertThat(targetlistGroup2.size()).isEqualTo(5);
|
||||
assertThat(targetlistGroup2.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
||||
.are(targetBelongsInRollout);
|
||||
|
||||
targetPage = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(2).getId(), rsqlParam,
|
||||
new OffsetBasedPageRequest(0, 100));
|
||||
targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(new OffsetBasedPageRequest(0, 100), rolloutGroups.get(2).getId(),
|
||||
rsqlParam);
|
||||
final List<Target> targetlistGroup3 = targetPage.getContent();
|
||||
assertThat(targetlistGroup3.size()).isEqualTo(5);
|
||||
assertThat(targetlistGroup3.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
||||
@@ -1135,7 +1135,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
|
||||
|
||||
final List<RolloutGroup> groups = rolloutGroupManagement.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE)
|
||||
final List<RolloutGroup> groups = rolloutGroupManagement.findByRollout(PAGE, myRollout.getId())
|
||||
.getContent();
|
||||
|
||||
assertThat(groups.get(0).getStatus()).isEqualTo(RolloutGroupStatus.READY);
|
||||
@@ -1149,7 +1149,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(groups.get(4).getStatus()).isEqualTo(RolloutGroupStatus.READY);
|
||||
assertThat(groups.get(4).getTotalTargets()).isEqualTo(0);
|
||||
|
||||
rolloutManagement.startRollout(myRollout.getId());
|
||||
rolloutManagement.start(myRollout.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
@@ -1159,7 +1159,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(MultipleInvokeHelper.doWithTimeout(new RolloutStatusCallable(myRollout.getId()),
|
||||
conditionRolloutStatus, 15000, 500)).as("Rollout status").isNotNull();
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.RUNNING);
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 1L);
|
||||
@@ -1188,10 +1188,10 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
|
||||
|
||||
rolloutManagement.startRollout(myRollout.getId());
|
||||
rolloutManagement.start(myRollout.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
@@ -1201,7 +1201,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(MultipleInvokeHelper.doWithTimeout(new RolloutStatusCallable(myRollout.getId()),
|
||||
conditionRolloutTargetCount, 15000, 500)).as("Rollout status").isNotNull();
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.RUNNING);
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 10L);
|
||||
@@ -1228,20 +1228,20 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
|
||||
|
||||
// schedule rollout auto start into the future
|
||||
rolloutManagement.updateRollout(
|
||||
rolloutManagement.update(
|
||||
entityFactory.rollout().update(myRollout.getId()).startAt(System.currentTimeMillis() + 60000));
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
// rollout should not have been started
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
|
||||
|
||||
// schedule to now
|
||||
rolloutManagement
|
||||
.updateRollout(entityFactory.rollout().update(myRollout.getId()).startAt(System.currentTimeMillis()));
|
||||
.update(entityFactory.rollout().update(myRollout.getId()).startAt(System.currentTimeMillis()));
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.STARTING);
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
@@ -1252,7 +1252,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(MultipleInvokeHelper.doWithTimeout(new RolloutStatusCallable(myRollout.getId()),
|
||||
conditionRolloutTargetCount, 15000, 500)).as("Rollout status").isNotNull();
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.RUNNING);
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 10L);
|
||||
@@ -1288,11 +1288,11 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutGroups.add(generateRolloutGroup(1, percentTargetsInGroup2, null));
|
||||
rolloutGroups.add(generateRolloutGroup(2, percentTargetsInGroup3, null));
|
||||
|
||||
Rollout myRollout = rolloutManagement.createRollout(rolloutcreate, rolloutGroups, conditions);
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
Rollout myRollout = rolloutManagement.create(rolloutcreate, rolloutGroups, conditions);
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.CREATING);
|
||||
for (final RolloutGroup group : rolloutGroupManagement.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE)
|
||||
for (final RolloutGroup group : rolloutGroupManagement.findByRollout(PAGE, myRollout.getId())
|
||||
.getContent()) {
|
||||
assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.CREATING);
|
||||
}
|
||||
@@ -1304,11 +1304,11 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
|
||||
assertThat(myRollout.getTotalTargets()).isEqualTo(amountTargetsInGroup1and2 + amountTargetsInGroup1);
|
||||
|
||||
final List<RolloutGroup> groups = rolloutGroupManagement.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE)
|
||||
final List<RolloutGroup> groups = rolloutGroupManagement.findByRollout(PAGE, myRollout.getId())
|
||||
.getContent();
|
||||
;
|
||||
assertThat(groups.get(0).getStatus()).isEqualTo(RolloutGroupStatus.READY);
|
||||
@@ -1338,7 +1338,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutGroups.add(generateRolloutGroup(1, percentTargetsInGroup2, null));
|
||||
|
||||
assertThatExceptionOfType(ValidationException.class)
|
||||
.isThrownBy(() -> rolloutManagement.createRollout(myRollout, rolloutGroups, conditions))
|
||||
.isThrownBy(() -> rolloutManagement.create(myRollout, rolloutGroups, conditions))
|
||||
.withMessageContaining("groups don't match");
|
||||
|
||||
}
|
||||
@@ -1359,7 +1359,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
generateRolloutGroup(1, percentTargetsInGroup2, null));
|
||||
|
||||
assertThatExceptionOfType(ValidationException.class)
|
||||
.isThrownBy(() -> rolloutManagement.createRollout(myRollout, rolloutGroups, conditions))
|
||||
.isThrownBy(() -> rolloutManagement.create(myRollout, rolloutGroups, conditions))
|
||||
.withMessageContaining("percentage has to be between 1 and 100");
|
||||
|
||||
}
|
||||
@@ -1375,7 +1375,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final RolloutCreate myRollout = generateTargetsAndRollout(rolloutName, amountTargetsForRollout);
|
||||
|
||||
assertThatExceptionOfType(ValidationException.class)
|
||||
.isThrownBy(() -> rolloutManagement.createRollout(myRollout, illegalGroupAmount, conditions))
|
||||
.isThrownBy(() -> rolloutManagement.create(myRollout, illegalGroupAmount, conditions))
|
||||
.withMessageContaining("not be greater than " + quotaManagement.getMaxRolloutGroupsPerRollout());
|
||||
|
||||
}
|
||||
@@ -1400,14 +1400,14 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
.description("some description").targetFilterQuery("id==" + targetPrefixName + "-*")
|
||||
.set(distributionSet);
|
||||
|
||||
Rollout myRollout = rolloutManagement.createRollout(rolloutToCreate, amountGroups, conditions);
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
Rollout myRollout = rolloutManagement.create(rolloutToCreate, amountGroups, conditions);
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.CREATING);
|
||||
|
||||
final Long rolloutId = myRollout.getId();
|
||||
assertThatExceptionOfType(RolloutIllegalStateException.class)
|
||||
.isThrownBy(() -> rolloutManagement.startRollout(rolloutId))
|
||||
.isThrownBy(() -> rolloutManagement.start(rolloutId))
|
||||
.withMessageContaining("can only be started in state ready");
|
||||
|
||||
}
|
||||
@@ -1430,7 +1430,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
amountOtherTargets, amountGroups, successCondition, errorCondition);
|
||||
|
||||
// test
|
||||
rolloutManagement.deleteRollout(createdRollout.getId());
|
||||
rolloutManagement.delete(createdRollout.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
// verify
|
||||
@@ -1462,7 +1462,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// start the rollout, so it has active running actions and a group which
|
||||
// has been started
|
||||
rolloutManagement.startRollout(createdRollout.getId());
|
||||
rolloutManagement.start(createdRollout.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
// verify we have running actions
|
||||
@@ -1470,7 +1470,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
.getNumberOfElements()).isEqualTo(2);
|
||||
|
||||
// test
|
||||
rolloutManagement.deleteRollout(createdRollout.getId());
|
||||
rolloutManagement.delete(createdRollout.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
// verify
|
||||
@@ -1480,12 +1480,12 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(deletedRollout.getStatus()).isEqualTo(RolloutStatus.DELETED);
|
||||
assertThatExceptionOfType(EntityReadOnlyException.class)
|
||||
.isThrownBy(() -> rolloutManagement
|
||||
.updateRollout(entityFactory.rollout().update(createdRollout.getId()).description("test")))
|
||||
.update(entityFactory.rollout().update(createdRollout.getId()).description("test")))
|
||||
.withMessageContaining("" + createdRollout.getId());
|
||||
|
||||
assertThat(rolloutManagement.findAll(PAGE, true).getContent()).hasSize(1);
|
||||
assertThat(rolloutManagement.findAll(PAGE, false).getContent()).hasSize(0);
|
||||
assertThat(rolloutGroupManagement.findAllRolloutGroupsWithDetailedStatus(createdRollout.getId(), PAGE)
|
||||
assertThat(rolloutGroupManagement.findByRolloutWithDetailedStatus(PAGE, createdRollout.getId())
|
||||
.getContent()).hasSize(amountGroups);
|
||||
|
||||
// verify that all scheduled actions are deleted
|
||||
@@ -1517,13 +1517,13 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void validateRolloutGroupActionStatus(final RolloutGroup rolloutGroup,
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus) {
|
||||
final RolloutGroup rolloutGroupWithDetail = rolloutGroupManagement
|
||||
.findRolloutGroupWithDetailedStatus(rolloutGroup.getId()).get();
|
||||
.getWithDetailedStatus(rolloutGroup.getId()).get();
|
||||
validateStatus(rolloutGroupWithDetail.getTotalTargetCountStatus(), expectedTargetCountStatus);
|
||||
}
|
||||
|
||||
private void validateRolloutActionStatus(final Long rolloutId,
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus) {
|
||||
final Rollout rolloutWithDetail = rolloutManagement.findRolloutWithDetailedStatus(rolloutId).get();
|
||||
final Rollout rolloutWithDetail = rolloutManagement.getWithDetailedStatus(rolloutId).get();
|
||||
validateStatus(rolloutWithDetail.getTotalTargetCountStatus(), expectedTargetCountStatus);
|
||||
}
|
||||
|
||||
@@ -1608,7 +1608,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Override
|
||||
public RolloutStatus call() throws Exception {
|
||||
|
||||
final Rollout myRollout = rolloutManagement.findRolloutById(rolloutId).get();
|
||||
final Rollout myRollout = rolloutManagement.get(rolloutId).get();
|
||||
return myRollout.getStatus();
|
||||
|
||||
}
|
||||
|
||||
@@ -60,13 +60,12 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
final SoftwareModule module = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleById(1234L)).isNotPresent();
|
||||
assertThat(softwareModuleManagement.get(1234L)).isNotPresent();
|
||||
|
||||
assertThat(
|
||||
softwareModuleManagement.findSoftwareModuleByNameAndVersion(NOT_EXIST_ID, NOT_EXIST_ID, osType.getId()))
|
||||
.isNotPresent();
|
||||
assertThat(softwareModuleManagement.getByNameAndVersionAndType(NOT_EXIST_ID, NOT_EXIST_ID, osType.getId()))
|
||||
.isNotPresent();
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleMetadata(module.getId(), NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(module.getId(), NOT_EXIST_ID)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -77,53 +76,49 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule module = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.createSoftwareModule(
|
||||
Arrays.asList(entityFactory.softwareModule().create().name("xxx").type(NOT_EXIST_ID))),
|
||||
() -> softwareModuleManagement
|
||||
.create(Arrays.asList(entityFactory.softwareModule().create().name("xxx").type(NOT_EXIST_ID))),
|
||||
"SoftwareModuleType");
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement
|
||||
.createSoftwareModule(entityFactory.softwareModule().create().name("xxx").type(NOT_EXIST_ID)),
|
||||
.create(entityFactory.softwareModule().create().name("xxx").type(NOT_EXIST_ID)),
|
||||
"SoftwareModuleType");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.createSoftwareModuleMetadata(NOT_EXIST_IDL,
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.createMetaData(NOT_EXIST_IDL,
|
||||
entityFactory.generateMetadata("xxx", "xxx")), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.createSoftwareModuleMetadata(NOT_EXIST_IDL,
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.createMetaData(NOT_EXIST_IDL,
|
||||
Arrays.asList(entityFactory.generateMetadata("xxx", "xxx"))), "SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.deleteSoftwareModule(NOT_EXIST_IDL), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.deleteSoftwareModules(Arrays.asList(NOT_EXIST_IDL)),
|
||||
"SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.deleteSoftwareModuleMetadata(NOT_EXIST_IDL, "xxx"),
|
||||
"SoftwareModule");
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.deleteSoftwareModuleMetadata(module.getId(), NOT_EXIST_ID),
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.delete(NOT_EXIST_IDL), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.delete(Arrays.asList(NOT_EXIST_IDL)), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.deleteMetaData(NOT_EXIST_IDL, "xxx"), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.deleteMetaData(module.getId(), NOT_EXIST_ID),
|
||||
"SoftwareModuleMetadata");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.updateSoftwareModuleMetadata(NOT_EXIST_IDL,
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.updateMetaData(NOT_EXIST_IDL,
|
||||
entityFactory.generateMetadata("xxx", "xxx")), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.updateSoftwareModuleMetadata(module.getId(),
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.updateMetaData(module.getId(),
|
||||
entityFactory.generateMetadata(NOT_EXIST_ID, "xxx")), "SoftwareModuleMetadata");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findSoftwareModuleByAssignedTo(PAGE, NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findByAssignedTo(PAGE, NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.findSoftwareModuleByNameAndVersion("xxx", "xxx", NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.getByNameAndVersionAndType("xxx", "xxx", NOT_EXIST_IDL),
|
||||
"SoftwareModuleType");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findSoftwareModuleMetadata(NOT_EXIST_IDL, NOT_EXIST_ID),
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.getMetaDataBySoftwareModuleId(NOT_EXIST_IDL, NOT_EXIST_ID),
|
||||
"SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findMetaDataBySoftwareModuleId(PAGE, NOT_EXIST_IDL),
|
||||
"SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findMetaDataByRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findByType(PAGE, NOT_EXIST_IDL), "SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.findSoftwareModuleMetadataBySoftwareModuleId(PAGE, NOT_EXIST_IDL),
|
||||
() -> softwareModuleManagement.update(entityFactory.softwareModule().update(NOT_EXIST_IDL)),
|
||||
"SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement
|
||||
.findSoftwareModuleMetadataBySoftwareModuleId(NOT_EXIST_IDL, "name==*", PAGE), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findSoftwareModulesByType(PAGE, NOT_EXIST_IDL),
|
||||
"SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement
|
||||
.updateSoftwareModule(entityFactory.softwareModule().update(NOT_EXIST_IDL)), "SoftwareModule");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -132,7 +127,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final SoftwareModule updated = softwareModuleManagement
|
||||
.updateSoftwareModule(entityFactory.softwareModule().update(ah.getId()));
|
||||
.update(entityFactory.softwareModule().update(ah.getId()));
|
||||
|
||||
assertThat(updated.getOptLockRevision())
|
||||
.as("Expected version number of updated entitity to be equal to created version")
|
||||
@@ -144,8 +139,8 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void updateSoftareModuleFieldsToNewValue() {
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final SoftwareModule updated = softwareModuleManagement.updateSoftwareModule(
|
||||
entityFactory.softwareModule().update(ah.getId()).description("changed").vendor("changed"));
|
||||
final SoftwareModule updated = softwareModuleManagement
|
||||
.update(entityFactory.softwareModule().update(ah.getId()).description("changed").vendor("changed"));
|
||||
|
||||
assertThat(updated.getOptLockRevision()).as("Expected version number of updated entitity is")
|
||||
.isEqualTo(ah.getOptLockRevision() + 1);
|
||||
@@ -168,54 +163,47 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("searched for software modules based on the various filter options, e.g. name,desc,type, version.")
|
||||
public void findSoftwareModuleByFilters() {
|
||||
final SoftwareModule ah = softwareModuleManagement.createSoftwareModule(
|
||||
entityFactory.softwareModule().create().type(appType).name("agent-hub").version("1.0.1"));
|
||||
final SoftwareModule jvm = softwareModuleManagement.createSoftwareModule(
|
||||
entityFactory.softwareModule().create().type(runtimeType).name("oracle-jre").version("1.7.2"));
|
||||
final SoftwareModule os = softwareModuleManagement.createSoftwareModule(
|
||||
entityFactory.softwareModule().create().type(osType).name("poky").version("3.0.2"));
|
||||
final SoftwareModule ah = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(appType).name("agent-hub").version("1.0.1"));
|
||||
final SoftwareModule jvm = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(runtimeType).name("oracle-jre").version("1.7.2"));
|
||||
final SoftwareModule os = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(osType).name("poky").version("3.0.2"));
|
||||
|
||||
final SoftwareModule ah2 = softwareModuleManagement.createSoftwareModule(
|
||||
entityFactory.softwareModule().create().type(appType).name("agent-hub").version("1.0.2"));
|
||||
final SoftwareModule ah2 = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(appType).name("agent-hub").version("1.0.2"));
|
||||
JpaDistributionSet ds = (JpaDistributionSet) distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("ds-1").version("1.0.1")
|
||||
.type(standardDsType).modules(Arrays.asList(os.getId(), jvm.getId(), ah2.getId())));
|
||||
.create(entityFactory.distributionSet().create().name("ds-1").version("1.0.1").type(standardDsType)
|
||||
.modules(Arrays.asList(os.getId(), jvm.getId(), ah2.getId())));
|
||||
|
||||
final JpaTarget target = (JpaTarget) testdataFactory.createTarget();
|
||||
ds = (JpaDistributionSet) assignSet(target, ds).getDistributionSet();
|
||||
|
||||
// standard searches
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "poky", osType.getId()).getContent())
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "poky", osType.getId()).getContent()).hasSize(1);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "poky", osType.getId()).getContent().get(0))
|
||||
.isEqualTo(os);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "oracle%", runtimeType.getId()).getContent())
|
||||
.hasSize(1);
|
||||
assertThat(
|
||||
softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "poky", osType.getId()).getContent().get(0))
|
||||
.isEqualTo(os);
|
||||
assertThat(
|
||||
softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "oracle%", runtimeType.getId()).getContent())
|
||||
.hasSize(1);
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "oracle%", runtimeType.getId())
|
||||
.getContent().get(0)).isEqualTo(jvm);
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "1.0.1", appType.getId()).getContent())
|
||||
.hasSize(1);
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "1.0.1", appType.getId()).getContent()
|
||||
.get(0)).isEqualTo(ah);
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "1.0%", appType.getId()).getContent())
|
||||
.hasSize(2);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "oracle%", runtimeType.getId()).getContent().get(0))
|
||||
.isEqualTo(jvm);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "1.0.1", appType.getId()).getContent()).hasSize(1);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "1.0.1", appType.getId()).getContent().get(0))
|
||||
.isEqualTo(ah);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "1.0%", appType.getId()).getContent()).hasSize(2);
|
||||
|
||||
// no we search with on entity marked as deleted
|
||||
softwareModuleManagement.deleteSoftwareModule(
|
||||
softwareModuleManagement.delete(
|
||||
softwareModuleRepository.findByAssignedToAndType(PAGE, ds, appType).getContent().get(0).getId());
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "1.0%", appType.getId()).getContent())
|
||||
.hasSize(1);
|
||||
assertThat(
|
||||
softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "1.0%", appType.getId()).getContent().get(0))
|
||||
.isEqualTo(ah);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "1.0%", appType.getId()).getContent()).hasSize(1);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "1.0%", appType.getId()).getContent().get(0))
|
||||
.isEqualTo(ah);
|
||||
}
|
||||
|
||||
private Action assignSet(final JpaTarget target, final JpaDistributionSet ds) {
|
||||
assignDistributionSet(ds.getId(), target.getControllerId());
|
||||
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).get().getUpdateStatus())
|
||||
assertThat(targetManagement.getByControllerID(target.getControllerId()).get().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(ds);
|
||||
final Action action = actionRepository.findByTargetAndDistributionSet(PAGE, target, ds).getContent().get(0);
|
||||
@@ -230,7 +218,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final List<Long> modules = Arrays.asList(testdataFactory.createSoftwareModuleOs().getId(),
|
||||
testdataFactory.createSoftwareModuleApp().getId(), 624355263L);
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModulesById(modules)).hasSize(2);
|
||||
assertThat(softwareModuleManagement.get(modules)).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -240,10 +228,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule one = testdataFactory.createSoftwareModuleOs("one");
|
||||
final SoftwareModule two = testdataFactory.createSoftwareModuleOs("two");
|
||||
// ignored
|
||||
softwareModuleManagement.deleteSoftwareModule(testdataFactory.createSoftwareModuleOs("deleted").getId());
|
||||
softwareModuleManagement.delete(testdataFactory.createSoftwareModuleOs("deleted").getId());
|
||||
testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent())
|
||||
assertThat(softwareModuleManagement.findByType(PAGE, osType.getId()).getContent())
|
||||
.as("Expected to find the following number of modules:").hasSize(2).as("with the following elements")
|
||||
.contains(two, one);
|
||||
}
|
||||
@@ -256,10 +244,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createSoftwareModuleOs("two");
|
||||
final SoftwareModule deleted = testdataFactory.createSoftwareModuleOs("deleted");
|
||||
// ignored
|
||||
softwareModuleManagement.deleteSoftwareModule(deleted.getId());
|
||||
softwareModuleManagement.delete(deleted.getId());
|
||||
|
||||
assertThat(softwareModuleManagement.countSoftwareModulesAll())
|
||||
.as("Expected to find the following number of modules:").isEqualTo(2);
|
||||
assertThat(softwareModuleManagement.count()).as("Expected to find the following number of modules:")
|
||||
.isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -273,12 +261,12 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Artifact artifact2 = artifactsIt.next();
|
||||
|
||||
// [STEP2]: Delete unassigned SoftwareModule
|
||||
softwareModuleManagement.deleteSoftwareModule(unassignedModule.getId());
|
||||
softwareModuleManagement.delete(unassignedModule.getId());
|
||||
|
||||
// [VERIFY EXPECTED RESULT]:
|
||||
// verify: SoftwareModule is deleted
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(0);
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleById(unassignedModule.getId())).isNotPresent();
|
||||
assertThat(softwareModuleManagement.get(unassignedModule.getId())).isNotPresent();
|
||||
|
||||
// verify: binary data of artifact is deleted
|
||||
assertArtfiactNull(artifact1, artifact2);
|
||||
@@ -299,13 +287,13 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createDistributionSet(Sets.newHashSet(assignedModule));
|
||||
|
||||
// [STEP3]: Delete the assigned SoftwareModule
|
||||
softwareModuleManagement.deleteSoftwareModule(assignedModule.getId());
|
||||
softwareModuleManagement.delete(assignedModule.getId());
|
||||
|
||||
// [VERIFY EXPECTED RESULT]:
|
||||
// verify: assignedModule is marked as deleted
|
||||
assignedModule = softwareModuleManagement.findSoftwareModuleById(assignedModule.getId()).get();
|
||||
assignedModule = softwareModuleManagement.get(assignedModule.getId()).get();
|
||||
assertTrue("The module should be flagged as deleted", assignedModule.isDeleted());
|
||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(1);
|
||||
|
||||
// verify: binary data is deleted
|
||||
@@ -336,16 +324,16 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
assignDistributionSet(disSet, Arrays.asList(target));
|
||||
|
||||
// [STEP4]: Delete the DistributionSet
|
||||
distributionSetManagement.deleteDistributionSet(disSet.getId());
|
||||
distributionSetManagement.delete(disSet.getId());
|
||||
|
||||
// [STEP5]: Delete the assigned SoftwareModule
|
||||
softwareModuleManagement.deleteSoftwareModule(assignedModule.getId());
|
||||
softwareModuleManagement.delete(assignedModule.getId());
|
||||
|
||||
// [VERIFY EXPECTED RESULT]:
|
||||
// verify: assignedModule is marked as deleted
|
||||
assignedModule = softwareModuleManagement.findSoftwareModuleById(assignedModule.getId()).get();
|
||||
assignedModule = softwareModuleManagement.get(assignedModule.getId()).get();
|
||||
assertTrue("The found module should be flagged deleted", assignedModule.isDeleted());
|
||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(1);
|
||||
|
||||
// verify: binary data is deleted
|
||||
@@ -370,26 +358,26 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
SoftwareModule moduleX = createSoftwareModuleWithArtifacts(osType, "modulex", "v1.0", 0);
|
||||
|
||||
// [STEP2]: Create newArtifactX and add it to SoftwareModuleX
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(source), moduleX.getId(), "artifactx", false);
|
||||
moduleX = softwareModuleManagement.findSoftwareModuleById(moduleX.getId()).get();
|
||||
artifactManagement.create(new ByteArrayInputStream(source), moduleX.getId(), "artifactx", false);
|
||||
moduleX = softwareModuleManagement.get(moduleX.getId()).get();
|
||||
final Artifact artifactX = moduleX.getArtifacts().iterator().next();
|
||||
|
||||
// [STEP3]: Create SoftwareModuleY and add the same ArtifactX
|
||||
SoftwareModule moduleY = createSoftwareModuleWithArtifacts(osType, "moduley", "v1.0", 0);
|
||||
|
||||
// [STEP4]: Assign the same ArtifactX to SoftwareModuleY
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(source), moduleY.getId(), "artifactx", false);
|
||||
moduleY = softwareModuleManagement.findSoftwareModuleById(moduleY.getId()).get();
|
||||
artifactManagement.create(new ByteArrayInputStream(source), moduleY.getId(), "artifactx", false);
|
||||
moduleY = softwareModuleManagement.get(moduleY.getId()).get();
|
||||
final Artifact artifactY = moduleY.getArtifacts().iterator().next();
|
||||
|
||||
// [STEP5]: Delete SoftwareModuleX
|
||||
softwareModuleManagement.deleteSoftwareModule(moduleX.getId());
|
||||
softwareModuleManagement.delete(moduleX.getId());
|
||||
|
||||
// [VERIFY EXPECTED RESULT]:
|
||||
// verify: SoftwareModuleX is deleted, and ModuelY still exists
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(1);
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleById(moduleX.getId())).isNotPresent();
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleById(moduleY.getId())).isPresent();
|
||||
assertThat(softwareModuleManagement.get(moduleX.getId())).isNotPresent();
|
||||
assertThat(softwareModuleManagement.get(moduleY.getId())).isPresent();
|
||||
|
||||
// verify: binary data of artifact is not deleted
|
||||
assertArtfiactNotNull(artifactY);
|
||||
@@ -412,15 +400,15 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
// [STEP1]: Create SoftwareModuleX and add a new ArtifactX
|
||||
SoftwareModule moduleX = createSoftwareModuleWithArtifacts(osType, "modulex", "v1.0", 0);
|
||||
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(source), moduleX.getId(), "artifactx", false);
|
||||
moduleX = softwareModuleManagement.findSoftwareModuleById(moduleX.getId()).get();
|
||||
artifactManagement.create(new ByteArrayInputStream(source), moduleX.getId(), "artifactx", false);
|
||||
moduleX = softwareModuleManagement.get(moduleX.getId()).get();
|
||||
final Artifact artifactX = moduleX.getArtifacts().iterator().next();
|
||||
|
||||
// [STEP2]: Create SoftwareModuleY and add the same ArtifactX
|
||||
SoftwareModule moduleY = createSoftwareModuleWithArtifacts(osType, "moduley", "v1.0", 0);
|
||||
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(source), moduleY.getId(), "artifactx", false);
|
||||
moduleY = softwareModuleManagement.findSoftwareModuleById(moduleY.getId()).get();
|
||||
artifactManagement.create(new ByteArrayInputStream(source), moduleY.getId(), "artifactx", false);
|
||||
moduleY = softwareModuleManagement.get(moduleY.getId()).get();
|
||||
final Artifact artifactY = moduleY.getArtifacts().iterator().next();
|
||||
|
||||
// [STEP3]: Assign SoftwareModuleX to DistributionSetX and to target
|
||||
@@ -432,21 +420,21 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
assignDistributionSet(disSetY, Arrays.asList(target));
|
||||
|
||||
// [STEP5]: Delete SoftwareModuleX
|
||||
softwareModuleManagement.deleteSoftwareModule(moduleX.getId());
|
||||
softwareModuleManagement.delete(moduleX.getId());
|
||||
|
||||
// [STEP6]: Delete SoftwareModuleY
|
||||
softwareModuleManagement.deleteSoftwareModule(moduleY.getId());
|
||||
softwareModuleManagement.delete(moduleY.getId());
|
||||
|
||||
// [VERIFY EXPECTED RESULT]:
|
||||
moduleX = softwareModuleManagement.findSoftwareModuleById(moduleX.getId()).get();
|
||||
moduleY = softwareModuleManagement.findSoftwareModuleById(moduleY.getId()).get();
|
||||
moduleX = softwareModuleManagement.get(moduleX.getId()).get();
|
||||
moduleY = softwareModuleManagement.get(moduleY.getId()).get();
|
||||
|
||||
// verify: SoftwareModuleX and SofwtareModule are marked as deleted
|
||||
assertThat(moduleX).isNotNull();
|
||||
assertThat(moduleY).isNotNull();
|
||||
assertTrue("The module should be flagged deleted", moduleX.isDeleted());
|
||||
assertTrue("The module should be flagged deleted", moduleY.isDeleted());
|
||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(2);
|
||||
|
||||
// verify: binary data of artifact is deleted
|
||||
@@ -462,16 +450,16 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final long countSoftwareModule = softwareModuleRepository.count();
|
||||
|
||||
// create SoftwareModule
|
||||
SoftwareModule softwareModule = softwareModuleManagement.createSoftwareModule(entityFactory.softwareModule()
|
||||
.create().type(type).name(name).version(version).description("description of artifact " + name));
|
||||
SoftwareModule softwareModule = softwareModuleManagement.create(entityFactory.softwareModule().create()
|
||||
.type(type).name(name).version(version).description("description of artifact " + name));
|
||||
|
||||
for (int i = 0; i < numberArtifacts; i++) {
|
||||
artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), softwareModule.getId(),
|
||||
artifactManagement.create(new RandomGeneratedInputStream(5 * 1024), softwareModule.getId(),
|
||||
"file" + (i + 1), false);
|
||||
}
|
||||
|
||||
// Verify correct Creation of SoftwareModule and corresponding artifacts
|
||||
softwareModule = softwareModuleManagement.findSoftwareModuleById(softwareModule.getId()).get();
|
||||
softwareModule = softwareModuleManagement.get(softwareModule.getId()).get();
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize((int) countSoftwareModule + 1);
|
||||
|
||||
final List<Artifact> artifacts = softwareModule.getArtifacts();
|
||||
@@ -505,10 +493,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Test verfies that results are returned based on given filter parameters and in the specified order.")
|
||||
public void findSoftwareModuleOrderByDistributionModuleNameAscModuleVersionAsc() {
|
||||
// test meta data
|
||||
final SoftwareModuleType testType = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
entityFactory.softwareModuleType().create().key("thetype").name("thename").maxAssignments(100));
|
||||
final SoftwareModuleType testType = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("thetype").name("thename").maxAssignments(100));
|
||||
DistributionSetType testDsType = distributionSetTypeManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("key").name("name"));
|
||||
.create(entityFactory.distributionSetType().create().key("key").name("name"));
|
||||
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(testDsType.getId(),
|
||||
Arrays.asList(osType.getId()));
|
||||
@@ -525,28 +513,28 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule deleted = testdataFactory.createSoftwareModule("thetype", "deleted");
|
||||
final SoftwareModule four = testdataFactory.createSoftwareModuleOs("e");
|
||||
|
||||
final DistributionSet set = distributionSetManagement.createDistributionSet(
|
||||
entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(Lists
|
||||
final DistributionSet set = distributionSetManagement
|
||||
.create(entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(Lists
|
||||
.newArrayList(one.getId(), two.getId(), deleted.getId(), four.getId(), differentName.getId())));
|
||||
softwareModuleManagement.deleteSoftwareModule(deleted.getId());
|
||||
softwareModuleManagement.delete(deleted.getId());
|
||||
|
||||
// with filter on name, version and module type
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(PAGE,
|
||||
assertThat(softwareModuleManagement.findAllOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(PAGE,
|
||||
set.getId(), "%found%", testType.getId()).getContent())
|
||||
.as("Found modules with given name, given module type and the assigned ones first")
|
||||
.containsExactly(new AssignedSoftwareModule(one, true), new AssignedSoftwareModule(two, true),
|
||||
new AssignedSoftwareModule(unassigned, false));
|
||||
|
||||
// with filter on module type only
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(PAGE,
|
||||
set.getId(), null, testType.getId()).getContent())
|
||||
.as("Found modules with given module type and the assigned ones first").containsExactly(
|
||||
new AssignedSoftwareModule(differentName, true), new AssignedSoftwareModule(one, true),
|
||||
new AssignedSoftwareModule(two, true), new AssignedSoftwareModule(unassigned, false));
|
||||
assertThat(softwareModuleManagement
|
||||
.findAllOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(PAGE, set.getId(), null, testType.getId())
|
||||
.getContent()).as("Found modules with given module type and the assigned ones first").containsExactly(
|
||||
new AssignedSoftwareModule(differentName, true), new AssignedSoftwareModule(one, true),
|
||||
new AssignedSoftwareModule(two, true), new AssignedSoftwareModule(unassigned, false));
|
||||
|
||||
// without any filter
|
||||
assertThat(softwareModuleManagement
|
||||
.findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(PAGE, set.getId(), null, null)
|
||||
.findAllOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(PAGE, set.getId(), null, null)
|
||||
.getContent()).as("Found modules with the assigned ones first").containsExactly(
|
||||
new AssignedSoftwareModule(differentName, true), new AssignedSoftwareModule(one, true),
|
||||
new AssignedSoftwareModule(two, true), new AssignedSoftwareModule(four, true),
|
||||
@@ -557,10 +545,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Checks that number of modules is returned as expected based on given filters.")
|
||||
public void countSoftwareModuleByFilters() {
|
||||
// test meta data
|
||||
final SoftwareModuleType testType = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
entityFactory.softwareModuleType().create().key("thetype").name("thename").maxAssignments(100));
|
||||
final SoftwareModuleType testType = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("thetype").name("thename").maxAssignments(100));
|
||||
DistributionSetType testDsType = distributionSetTypeManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("key").name("name"));
|
||||
.create(entityFactory.distributionSetType().create().key("key").name("name"));
|
||||
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(testDsType.getId(),
|
||||
Arrays.asList(osType.getId()));
|
||||
@@ -577,17 +565,17 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule deleted = testdataFactory.createSoftwareModule("thetype", "deleted");
|
||||
final SoftwareModule four = testdataFactory.createSoftwareModuleOs("e");
|
||||
|
||||
distributionSetManagement.createDistributionSet(
|
||||
entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(Lists
|
||||
distributionSetManagement
|
||||
.create(entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(Lists
|
||||
.newArrayList(one.getId(), two.getId(), deleted.getId(), four.getId(), differentName.getId())));
|
||||
softwareModuleManagement.deleteSoftwareModule(deleted.getId());
|
||||
softwareModuleManagement.delete(deleted.getId());
|
||||
|
||||
// test
|
||||
assertThat(softwareModuleManagement.countSoftwareModuleByFilters("%found%", testType.getId()))
|
||||
assertThat(softwareModuleManagement.countByTextAndType("%found%", testType.getId()))
|
||||
.as("Number of modules with given name or version and type").isEqualTo(3);
|
||||
assertThat(softwareModuleManagement.countSoftwareModuleByFilters(null, testType.getId()))
|
||||
assertThat(softwareModuleManagement.countByTextAndType(null, testType.getId()))
|
||||
.as("Number of modules with given type").isEqualTo(4);
|
||||
assertThat(softwareModuleManagement.countSoftwareModuleByFilters(null, null)).as("Number of modules overall")
|
||||
assertThat(softwareModuleManagement.countByTextAndType(null, null)).as("Number of modules overall")
|
||||
.isEqualTo(5);
|
||||
}
|
||||
|
||||
@@ -599,9 +587,9 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
// one soft deleted
|
||||
final SoftwareModule deleted = testdataFactory.createSoftwareModuleApp();
|
||||
testdataFactory.createDistributionSet(Arrays.asList(deleted));
|
||||
softwareModuleManagement.deleteSoftwareModule(deleted.getId());
|
||||
softwareModuleManagement.delete(deleted.getId());
|
||||
|
||||
assertThat(softwareModuleManagement.countSoftwareModulesAll()).as("Number of undeleted modules").isEqualTo(1);
|
||||
assertThat(softwareModuleManagement.count()).as("Number of undeleted modules").isEqualTo(1);
|
||||
assertThat(softwareModuleRepository.count()).as("Number of all modules").isEqualTo(2);
|
||||
}
|
||||
|
||||
@@ -614,11 +602,11 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// one soft deleted
|
||||
final SoftwareModule deleted = testdataFactory.createSoftwareModuleApp();
|
||||
final DistributionSet set = distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
.create().name("set").version("1").modules(Arrays.asList(one.getId(), deleted.getId())));
|
||||
softwareModuleManagement.deleteSoftwareModule(deleted.getId());
|
||||
final DistributionSet set = distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("set").version("1").modules(Arrays.asList(one.getId(), deleted.getId())));
|
||||
softwareModuleManagement.delete(deleted.getId());
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleByAssignedTo(PAGE, set.getId()).getContent())
|
||||
assertThat(softwareModuleManagement.findByAssignedTo(PAGE, set.getId()).getContent())
|
||||
.as("Found this number of modules").hasSize(2);
|
||||
}
|
||||
|
||||
@@ -640,11 +628,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final SoftwareModuleMetadata swMetadata2 = new JpaSoftwareModuleMetadata(knownKey2, ah, knownValue2);
|
||||
|
||||
final List<SoftwareModuleMetadata> softwareModuleMetadata = softwareModuleManagement
|
||||
.createSoftwareModuleMetadata(ah.getId(), Arrays.asList(swMetadata1, swMetadata2));
|
||||
final List<SoftwareModuleMetadata> softwareModuleMetadata = softwareModuleManagement.createMetaData(ah.getId(),
|
||||
Arrays.asList(swMetadata1, swMetadata2));
|
||||
|
||||
final SoftwareModule changedLockRevisionModule = softwareModuleManagement.findSoftwareModuleById(ah.getId())
|
||||
.get();
|
||||
final SoftwareModule changedLockRevisionModule = softwareModuleManagement.get(ah.getId()).get();
|
||||
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(2);
|
||||
|
||||
assertThat(softwareModuleMetadata).hasSize(2);
|
||||
@@ -664,12 +651,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
softwareModuleManagement.createSoftwareModuleMetadata(ah.getId(),
|
||||
entityFactory.generateMetadata(knownKey1, knownValue1));
|
||||
softwareModuleManagement.createMetaData(ah.getId(), entityFactory.generateMetadata(knownKey1, knownValue1));
|
||||
|
||||
try {
|
||||
softwareModuleManagement.createSoftwareModuleMetadata(ah.getId(),
|
||||
entityFactory.generateMetadata(knownKey1, knownValue2));
|
||||
softwareModuleManagement.createMetaData(ah.getId(), entityFactory.generateMetadata(knownKey1, knownValue2));
|
||||
fail("should not have worked as module metadata already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
@@ -690,24 +675,23 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(ah.getOptLockRevision()).isEqualTo(1);
|
||||
|
||||
// create an software module meta data entry
|
||||
final List<SoftwareModuleMetadata> softwareModuleMetadata = softwareModuleManagement
|
||||
.createSoftwareModuleMetadata(ah.getId(),
|
||||
Collections.singleton(entityFactory.generateMetadata(knownKey, knownValue)));
|
||||
final List<SoftwareModuleMetadata> softwareModuleMetadata = softwareModuleManagement.createMetaData(ah.getId(),
|
||||
Collections.singleton(entityFactory.generateMetadata(knownKey, knownValue)));
|
||||
assertThat(softwareModuleMetadata).hasSize(1);
|
||||
// base software module should have now the opt lock revision one
|
||||
// because we are modifying the
|
||||
// base software module
|
||||
SoftwareModule changedLockRevisionModule = softwareModuleManagement.findSoftwareModuleById(ah.getId()).get();
|
||||
SoftwareModule changedLockRevisionModule = softwareModuleManagement.get(ah.getId()).get();
|
||||
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(2);
|
||||
|
||||
// update the software module metadata
|
||||
Thread.sleep(100);
|
||||
final SoftwareModuleMetadata updated = softwareModuleManagement.updateSoftwareModuleMetadata(ah.getId(),
|
||||
final SoftwareModuleMetadata updated = softwareModuleManagement.updateMetaData(ah.getId(),
|
||||
entityFactory.generateMetadata(knownKey, knownUpdateValue));
|
||||
// we are updating the sw meta data so also modiying the base software
|
||||
// module so opt lock
|
||||
// revision must be two
|
||||
changedLockRevisionModule = softwareModuleManagement.findSoftwareModuleById(ah.getId()).get();
|
||||
changedLockRevisionModule = softwareModuleManagement.get(ah.getId()).get();
|
||||
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(3);
|
||||
|
||||
// verify updated meta data contains the updated value
|
||||
@@ -725,19 +709,16 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
ah = softwareModuleManagement
|
||||
.createSoftwareModuleMetadata(ah.getId(), entityFactory.generateMetadata(knownKey1, knownValue1))
|
||||
ah = softwareModuleManagement.createMetaData(ah.getId(), entityFactory.generateMetadata(knownKey1, knownValue1))
|
||||
.getSoftwareModule();
|
||||
|
||||
assertThat(softwareModuleManagement
|
||||
.findSoftwareModuleMetadataBySoftwareModuleId(new PageRequest(0, 100), ah.getId()).getContent())
|
||||
.as("Contains the created metadata element")
|
||||
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(new PageRequest(0, 10), ah.getId())
|
||||
.getContent()).as("Contains the created metadata element")
|
||||
.containsExactly(new JpaSoftwareModuleMetadata(knownKey1, ah, knownValue1));
|
||||
|
||||
softwareModuleManagement.deleteSoftwareModuleMetadata(ah.getId(), knownKey1);
|
||||
assertThat(softwareModuleManagement
|
||||
.findSoftwareModuleMetadataBySoftwareModuleId(new PageRequest(0, 100), ah.getId()).getContent())
|
||||
.as("Metadata elemenets are").isEmpty();
|
||||
softwareModuleManagement.deleteMetaData(ah.getId(), knownKey1);
|
||||
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(new PageRequest(0, 10), ah.getId())
|
||||
.getContent()).as("Metadata elemenets are").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -748,11 +729,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
ah = softwareModuleManagement
|
||||
.createSoftwareModuleMetadata(ah.getId(), entityFactory.generateMetadata(knownKey1, knownValue1))
|
||||
ah = softwareModuleManagement.createMetaData(ah.getId(), entityFactory.generateMetadata(knownKey1, knownValue1))
|
||||
.getSoftwareModule();
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleMetadata(ah.getId(), "doesnotexist")).isNotPresent();
|
||||
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(ah.getId(), "doesnotexist")).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -764,20 +744,22 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
SoftwareModule sw2 = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
for (int index = 0; index < 10; index++) {
|
||||
sw1 = softwareModuleManagement.createSoftwareModuleMetadata(sw1.getId(),
|
||||
entityFactory.generateMetadata("key" + index, "value" + index)).getSoftwareModule();
|
||||
sw1 = softwareModuleManagement
|
||||
.createMetaData(sw1.getId(), entityFactory.generateMetadata("key" + index, "value" + index))
|
||||
.getSoftwareModule();
|
||||
}
|
||||
|
||||
for (int index = 0; index < 20; index++) {
|
||||
sw2 = softwareModuleManagement.createSoftwareModuleMetadata(sw2.getId(),
|
||||
new JpaSoftwareModuleMetadata("key" + index, sw2, "value" + index)).getSoftwareModule();
|
||||
sw2 = softwareModuleManagement
|
||||
.createMetaData(sw2.getId(), new JpaSoftwareModuleMetadata("key" + index, sw2, "value" + index))
|
||||
.getSoftwareModule();
|
||||
}
|
||||
|
||||
final Page<SoftwareModuleMetadata> metadataOfSw1 = softwareModuleManagement
|
||||
.findSoftwareModuleMetadataBySoftwareModuleId(sw1.getId(), new PageRequest(0, 100));
|
||||
.findMetaDataBySoftwareModuleId(new PageRequest(0, 100), sw1.getId());
|
||||
|
||||
final Page<SoftwareModuleMetadata> metadataOfSw2 = softwareModuleManagement
|
||||
.findSoftwareModuleMetadataBySoftwareModuleId(sw2.getId(), new PageRequest(0, 100));
|
||||
.findMetaDataBySoftwareModuleId(new PageRequest(0, 100), sw2.getId());
|
||||
|
||||
assertThat(metadataOfSw1.getNumberOfElements()).isEqualTo(10);
|
||||
assertThat(metadataOfSw1.getTotalElements()).isEqualTo(10);
|
||||
|
||||
@@ -39,9 +39,9 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 0) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypeById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypeByKey(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypeByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(softwareModuleTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(softwareModuleTypeManagement.getByKey(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(softwareModuleTypeManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -49,23 +49,23 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
+ " by means of throwing EntityNotFoundException.")
|
||||
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 0) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
verifyThrownExceptionBy(() -> softwareModuleTypeManagement.deleteSoftwareModuleType(NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> softwareModuleTypeManagement.delete(NOT_EXIST_IDL),
|
||||
"SoftwareModuleType");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleTypeManagement
|
||||
.updateSoftwareModuleType(entityFactory.softwareModuleType().update(1234L)),
|
||||
.update(entityFactory.softwareModuleType().update(1234L)),
|
||||
"SoftwareModuleType");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Calling update without changing fields results in no recorded change in the repository including unchanged audit fields.")
|
||||
public void updateNothingResultsInUnchangedRepositoryForType() {
|
||||
final SoftwareModuleType created = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
final SoftwareModuleType created = softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("test-key").name("test-name"));
|
||||
|
||||
final SoftwareModuleType updated = softwareModuleTypeManagement
|
||||
.updateSoftwareModuleType(entityFactory.softwareModuleType().update(created.getId()));
|
||||
.update(entityFactory.softwareModuleType().update(created.getId()));
|
||||
|
||||
assertThat(updated.getOptLockRevision())
|
||||
.as("Expected version number of updated entitity to be equal to created version")
|
||||
@@ -75,10 +75,10 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
@Test
|
||||
@Description("Calling update for changed fields results in change in the repository.")
|
||||
public void updateSoftareModuleTypeFieldsToNewValue() {
|
||||
final SoftwareModuleType created = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
final SoftwareModuleType created = softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("test-key").name("test-name"));
|
||||
|
||||
final SoftwareModuleType updated = softwareModuleTypeManagement.updateSoftwareModuleType(
|
||||
final SoftwareModuleType updated = softwareModuleTypeManagement.update(
|
||||
entityFactory.softwareModuleType().update(created.getId()).description("changed").colour("changed"));
|
||||
|
||||
assertThat(updated.getOptLockRevision()).as("Expected version number of updated entitity is")
|
||||
@@ -94,9 +94,9 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
entityFactory.softwareModuleType().create().key("test-key").name("test-name"),
|
||||
entityFactory.softwareModuleType().create().key("test-key2").name("test-name2"));
|
||||
|
||||
softwareModuleTypeManagement.createSoftwareModuleType(created);
|
||||
softwareModuleTypeManagement.create(created);
|
||||
try {
|
||||
softwareModuleTypeManagement.createSoftwareModuleType(created);
|
||||
softwareModuleTypeManagement.create(created);
|
||||
fail("Should not have worked as module already exists.");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
@@ -106,34 +106,34 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
@Test
|
||||
@Description("Tests the successfull deletion of software module types. Both unused (hard delete) and used ones (soft delete).")
|
||||
public void deleteAssignedAndUnassignedSoftwareModuleTypes() {
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypesAll(PAGE)).hasSize(3).contains(osType,
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType,
|
||||
runtimeType, appType);
|
||||
|
||||
SoftwareModuleType type = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
SoftwareModuleType type = softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("bundle").name("OSGi Bundle"));
|
||||
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypesAll(PAGE)).hasSize(4).contains(osType,
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType,
|
||||
runtimeType, appType, type);
|
||||
|
||||
// delete unassigned
|
||||
softwareModuleTypeManagement.deleteSoftwareModuleType(type.getId());
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypesAll(PAGE)).hasSize(3).contains(osType,
|
||||
softwareModuleTypeManagement.delete(type.getId());
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType,
|
||||
runtimeType, appType);
|
||||
assertThat(softwareModuleTypeRepository.findAll()).hasSize(3).contains((JpaSoftwareModuleType) osType,
|
||||
(JpaSoftwareModuleType) runtimeType, (JpaSoftwareModuleType) appType);
|
||||
|
||||
type = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
type = softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("bundle2").name("OSGi Bundle2"));
|
||||
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypesAll(PAGE)).hasSize(4).contains(osType,
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType,
|
||||
runtimeType, appType, type);
|
||||
|
||||
softwareModuleManagement.createSoftwareModule(
|
||||
softwareModuleManagement.create(
|
||||
entityFactory.softwareModule().create().type(type).name("Test SM").version("1.0"));
|
||||
|
||||
// delete assigned
|
||||
softwareModuleTypeManagement.deleteSoftwareModuleType(type.getId());
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypesAll(PAGE)).hasSize(3).contains(osType,
|
||||
softwareModuleTypeManagement.delete(type.getId());
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType,
|
||||
runtimeType, appType);
|
||||
|
||||
assertThat(softwareModuleTypeRepository.findAll()).hasSize(4).contains((JpaSoftwareModuleType) osType,
|
||||
@@ -146,11 +146,11 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
public void findSoftwareModuleTypeByName() {
|
||||
testdataFactory.createSoftwareModuleOs();
|
||||
final SoftwareModuleType found = softwareModuleTypeManagement
|
||||
.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("thetype2").name("anothername"));
|
||||
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypeByName("thename").get())
|
||||
assertThat(softwareModuleTypeManagement.getByName("thename").get())
|
||||
.as("Type with given name").isEqualTo(found);
|
||||
}
|
||||
|
||||
@@ -158,9 +158,9 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Verfies that it is not possible to create a type that alrady exists.")
|
||||
public void createSoftwareModuleTypeFailsWithExistingEntity() {
|
||||
softwareModuleTypeManagement
|
||||
.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
try {
|
||||
softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
fail("should not have worked as module type already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
@@ -173,9 +173,9 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Verfies that it is not possible to create a list of types where one already exists.")
|
||||
public void createSoftwareModuleTypesFailsWithExistingEntity() {
|
||||
softwareModuleTypeManagement
|
||||
.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
try {
|
||||
softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
softwareModuleTypeManagement.create(
|
||||
Arrays.asList(entityFactory.softwareModuleType().create().key("thetype").name("thename"),
|
||||
entityFactory.softwareModuleType().create().key("anothertype").name("anothername")));
|
||||
fail("should not have worked as module type already exists");
|
||||
@@ -188,7 +188,7 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Verifies that the creation of a softwareModuleType is failing because of invalid max assignment")
|
||||
public void createSoftwareModuleTypesFailsWithInvalidMaxAssignment() {
|
||||
try {
|
||||
softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("type").name("name").maxAssignments(0));
|
||||
fail("should not have worked as max assignment is invalid. Should be greater than 0.");
|
||||
} catch (final ConstraintViolationException e) {
|
||||
@@ -199,12 +199,12 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
@Test
|
||||
@Description("Verfies that multiple types are created as requested.")
|
||||
public void createMultipleSoftwareModuleTypes() {
|
||||
final List<SoftwareModuleType> created = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
final List<SoftwareModuleType> created = softwareModuleTypeManagement.create(
|
||||
Arrays.asList(entityFactory.softwareModuleType().create().key("thetype").name("thename"),
|
||||
entityFactory.softwareModuleType().create().key("thetype2").name("thename2")));
|
||||
|
||||
assertThat(created.size()).as("Number of created types").isEqualTo(2);
|
||||
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).as("Number of types in repository")
|
||||
assertThat(softwareModuleTypeManagement.count()).as("Number of types in repository")
|
||||
.isEqualTo(5);
|
||||
}
|
||||
|
||||
|
||||
@@ -134,14 +134,14 @@ public class SystemManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createTestArtifact(final byte[] random) {
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
||||
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
||||
}
|
||||
|
||||
private void createDeletedTestArtifact(final byte[] random) {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("deleted garbage", true);
|
||||
ds.getModules().stream().forEach(module -> {
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), module.getId(), "file1", false);
|
||||
softwareModuleManagement.deleteSoftwareModule(module.getId());
|
||||
artifactManagement.create(new ByteArrayInputStream(random), module.getId(), "file1", false);
|
||||
softwareModuleManagement.delete(module.getId());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
+ "of Optional not present.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(targetFilterQueryManagement.findTargetFilterQueryById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(targetFilterQueryManagement.findTargetFilterQueryByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(targetFilterQueryManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(targetFilterQueryManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -62,50 +62,51 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
final DistributionSet set = testdataFactory.createDistributionSet();
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name("test filter").query("name==PendingTargets001"));
|
||||
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement.deleteTargetFilterQuery(NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement.delete(NOT_EXIST_IDL),
|
||||
"TargetFilterQuery");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement.findTargetFilterQueryByAutoAssignDS(PAGE,
|
||||
NOT_EXIST_IDL, "name==*"), "DistributionSet");
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetFilterQueryManagement
|
||||
.updateTargetFilterQuery(entityFactory.targetFilterQuery().update(NOT_EXIST_IDL)),
|
||||
.update(entityFactory.targetFilterQuery().update(NOT_EXIST_IDL)),
|
||||
"TargetFilterQuery");
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement
|
||||
.updateTargetFilterQueryAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL), "DistributionSet");
|
||||
.updateAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL), "DistributionSet");
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(1234L, set.getId()),
|
||||
() -> targetFilterQueryManagement.updateAutoAssignDS(1234L, set.getId()),
|
||||
"TargetFilterQuery");
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement
|
||||
.updateTargetFilterQueryAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL), "DistributionSet");
|
||||
.updateAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL), "DistributionSet");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Test creation of target filter query.")
|
||||
public void createTargetFilterQuery() {
|
||||
final String filterName = "new target filter";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
assertEquals("Retrieved newly created custom target filter", targetFilterQuery,
|
||||
targetFilterQueryManagement.findTargetFilterQueryByName(filterName).get());
|
||||
targetFilterQueryManagement.getByName(filterName).get());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Test searching a target filter query.")
|
||||
public void searchTargetFilterQuery() {
|
||||
final String filterName = "targetFilterQueryName";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name("someOtherFilter").query("name==PendingTargets002"));
|
||||
|
||||
final List<TargetFilterQuery> results = targetFilterQueryManagement
|
||||
.findTargetFilterQueryByFilter(new PageRequest(0, 10), "name==" + filterName).getContent();
|
||||
.findByRsql(new PageRequest(0, 10), "name==" + filterName).getContent();
|
||||
assertEquals("Search result should have 1 result", 1, results.size());
|
||||
assertEquals("Retrieved newly created custom target filter", targetFilterQuery, results.get(0));
|
||||
}
|
||||
@@ -114,7 +115,7 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test searching a target filter query with an invalid filter.")
|
||||
public void searchTargetFilterQueryInvalidField() {
|
||||
// Should throw an exception
|
||||
targetFilterQueryManagement.findTargetFilterQueryByFilter(new PageRequest(0, 10), "unknownField==testValue")
|
||||
targetFilterQueryManagement.findByRsql(new PageRequest(0, 10), "unknownField==testValue")
|
||||
.getContent();
|
||||
|
||||
}
|
||||
@@ -123,11 +124,11 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Checks if the EntityAlreadyExistsException is thrown if a targetfilterquery with the same name are created more than once.")
|
||||
public void createDuplicateTargetFilterQuery() {
|
||||
final String filterName = "new target filter duplicate";
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
try {
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
fail("should not have worked as query already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
@@ -139,11 +140,11 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test deletion of target filter query.")
|
||||
public void deleteTargetFilterQuery() {
|
||||
final String filterName = "delete_target_filter_query";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
targetFilterQueryManagement.deleteTargetFilterQuery(targetFilterQuery.getId());
|
||||
targetFilterQueryManagement.delete(targetFilterQuery.getId());
|
||||
assertFalse("Returns null as the target filter is deleted",
|
||||
targetFilterQueryManagement.findTargetFilterQueryById(targetFilterQuery.getId()).isPresent());
|
||||
targetFilterQueryManagement.get(targetFilterQuery.getId()).isPresent());
|
||||
|
||||
}
|
||||
|
||||
@@ -151,14 +152,14 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test updation of target filter query.")
|
||||
public void updateTargetFilterQuery() {
|
||||
final String filterName = "target_filter_01";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
final String newQuery = "status==UNKNOWN";
|
||||
targetFilterQueryManagement.updateTargetFilterQuery(
|
||||
targetFilterQueryManagement.update(
|
||||
entityFactory.targetFilterQuery().update(targetFilterQuery.getId()).query(newQuery));
|
||||
assertEquals("Returns updated target filter query", newQuery,
|
||||
targetFilterQueryManagement.findTargetFilterQueryByName(filterName).get().getQuery());
|
||||
targetFilterQueryManagement.getByName(filterName).get().getQuery());
|
||||
|
||||
}
|
||||
|
||||
@@ -166,15 +167,15 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test assigning a distribution set")
|
||||
public void assignDistributionSet() {
|
||||
final String filterName = "target_filter_02";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(targetFilterQuery.getId(),
|
||||
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(),
|
||||
distributionSet.getId());
|
||||
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement.findTargetFilterQueryByName(filterName).get();
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
|
||||
assertEquals("Returns correct distribution set", distributionSet, tfq.getAutoAssignDistributionSet());
|
||||
|
||||
@@ -184,22 +185,22 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test removing distribution set while it has a relation to a target filter query")
|
||||
public void removeAssignDistributionSet() {
|
||||
final String filterName = "target_filter_03";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(targetFilterQuery.getId(),
|
||||
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(),
|
||||
distributionSet.getId());
|
||||
|
||||
// Check if target filter query is there
|
||||
TargetFilterQuery tfq = targetFilterQueryManagement.findTargetFilterQueryByName(filterName).get();
|
||||
TargetFilterQuery tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
assertEquals("Returns correct distribution set", distributionSet, tfq.getAutoAssignDistributionSet());
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(distributionSet.getId());
|
||||
distributionSetManagement.delete(distributionSet.getId());
|
||||
|
||||
// Check if auto assign distribution set is null
|
||||
tfq = targetFilterQueryManagement.findTargetFilterQueryByName(filterName).get();
|
||||
tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
assertNotNull("Returns target filter query", tfq);
|
||||
assertNull("Returns distribution set as null", tfq.getAutoAssignDistributionSet());
|
||||
|
||||
@@ -216,23 +217,23 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
// later step
|
||||
assignDistributionSet(distributionSet.getId(), target.getControllerId());
|
||||
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(targetFilterQueryManagement
|
||||
.createTargetFilterQuery(
|
||||
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQueryManagement
|
||||
.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"))
|
||||
.getId(), distributionSet.getId());
|
||||
|
||||
// Check if target filter query is there with the distribution set
|
||||
TargetFilterQuery tfq = targetFilterQueryManagement.findTargetFilterQueryByName(filterName).get();
|
||||
TargetFilterQuery tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
assertEquals("Returns correct distribution set", distributionSet, tfq.getAutoAssignDistributionSet());
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(distributionSet.getId());
|
||||
distributionSetManagement.delete(distributionSet.getId());
|
||||
|
||||
// Check if distribution set is still in the database with deleted flag
|
||||
assertTrue("Distribution set should be deleted",
|
||||
distributionSetManagement.findDistributionSetById(distributionSet.getId()).get().isDeleted());
|
||||
distributionSetManagement.get(distributionSet.getId()).get().isDeleted());
|
||||
|
||||
// Check if auto assign distribution set is null
|
||||
tfq = targetFilterQueryManagement.findTargetFilterQueryByName(filterName).get();
|
||||
tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
assertNotNull("Returns target filter query", tfq);
|
||||
assertNull("Returns distribution set as null", tfq.getAutoAssignDistributionSet());
|
||||
|
||||
@@ -244,40 +245,40 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
|
||||
final String filterName = "d";
|
||||
|
||||
assertEquals(0L, targetFilterQueryManagement.countAllTargetFilterQuery().longValue());
|
||||
assertEquals(0L, targetFilterQueryManagement.count());
|
||||
|
||||
targetFilterQueryManagement
|
||||
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name("a").query("name==*"));
|
||||
.create(entityFactory.targetFilterQuery().create().name("a").query("name==*"));
|
||||
targetFilterQueryManagement
|
||||
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name("b").query("name==*"));
|
||||
.create(entityFactory.targetFilterQuery().create().name("b").query("name==*"));
|
||||
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
final DistributionSet distributionSet2 = testdataFactory.createDistributionSet("2");
|
||||
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement
|
||||
.updateTargetFilterQueryAutoAssignDS(
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
.updateAutoAssignDS(
|
||||
targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name("c").query("name==x")).getId(),
|
||||
distributionSet.getId());
|
||||
|
||||
final TargetFilterQuery tfq2 = targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery tfq2 = targetFilterQueryManagement.updateAutoAssignDS(
|
||||
targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==z*")).getId(),
|
||||
distributionSet2.getId());
|
||||
|
||||
assertEquals(4L, targetFilterQueryManagement.countAllTargetFilterQuery().longValue());
|
||||
assertEquals(4L, targetFilterQueryManagement.count());
|
||||
|
||||
// check if find works
|
||||
Page<TargetFilterQuery> tfqList = targetFilterQueryManagement
|
||||
.findTargetFilterQueryByAutoAssignDS(new PageRequest(0, 500), distributionSet.getId(), null);
|
||||
.findByAutoAssignDSAndRsql(new PageRequest(0, 500), distributionSet.getId(), null);
|
||||
assertThat(1L).as("Target filter query").isEqualTo(tfqList.getTotalElements());
|
||||
|
||||
assertEquals("Returns correct target filter query", tfq.getId(), tfqList.iterator().next().getId());
|
||||
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(tfq2.getId(), distributionSet.getId());
|
||||
targetFilterQueryManagement.updateAutoAssignDS(tfq2.getId(), distributionSet.getId());
|
||||
|
||||
// check if find works for two
|
||||
tfqList = targetFilterQueryManagement.findTargetFilterQueryByAutoAssignDS(new PageRequest(0, 500),
|
||||
tfqList = targetFilterQueryManagement.findByAutoAssignDSAndRsql(new PageRequest(0, 500),
|
||||
distributionSet.getId(), null);
|
||||
assertThat(2L).as("Target filter query count").isEqualTo(tfqList.getTotalElements());
|
||||
Iterator<TargetFilterQuery> iterator = tfqList.iterator();
|
||||
@@ -285,14 +286,14 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
assertEquals("Returns correct target filter query 2", tfq2.getId(), iterator.next().getId());
|
||||
|
||||
// check if find works with name filter
|
||||
tfqList = targetFilterQueryManagement.findTargetFilterQueryByAutoAssignDS(new PageRequest(0, 500),
|
||||
tfqList = targetFilterQueryManagement.findByAutoAssignDSAndRsql(new PageRequest(0, 500),
|
||||
distributionSet.getId(), "name==" + filterName);
|
||||
assertThat(1L).as("Target filter query count").isEqualTo(tfqList.getTotalElements());
|
||||
|
||||
assertEquals("Returns correct target filter query", tfq2.getId(), tfqList.iterator().next().getId());
|
||||
|
||||
// check if find works for all with auto assign DS
|
||||
tfqList = targetFilterQueryManagement.findTargetFilterQueryWithAutoAssignDS(new PageRequest(0, 500));
|
||||
tfqList = targetFilterQueryManagement.findWithAutoAssignDS(new PageRequest(0, 500));
|
||||
assertThat(2L).as("Target filter query count").isEqualTo(tfqList.getTotalElements());
|
||||
iterator = tfqList.iterator();
|
||||
assertEquals("Returns correct target filter query 1", tfq.getId(), iterator.next().getId());
|
||||
|
||||
@@ -47,10 +47,10 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
+ "That includes both the test itself, as a count operation with the same filters "
|
||||
+ "and query definitions by RSQL (named and un-named).")
|
||||
public void targetSearchWithVariousFilterCombinations() {
|
||||
final TargetTag targTagX = tagManagement.createTargetTag(entityFactory.tag().create().name("TargTag-X"));
|
||||
final TargetTag targTagY = tagManagement.createTargetTag(entityFactory.tag().create().name("TargTag-Y"));
|
||||
final TargetTag targTagZ = tagManagement.createTargetTag(entityFactory.tag().create().name("TargTag-Z"));
|
||||
final TargetTag targTagW = tagManagement.createTargetTag(entityFactory.tag().create().name("TargTag-W"));
|
||||
final TargetTag targTagX = targetTagManagement.create(entityFactory.tag().create().name("TargTag-X"));
|
||||
final TargetTag targTagY = targetTagManagement.create(entityFactory.tag().create().name("TargTag-Y"));
|
||||
final TargetTag targTagZ = targetTagManagement.create(entityFactory.tag().create().name("TargTag-Z"));
|
||||
final TargetTag targTagW = targetTagManagement.create(entityFactory.tag().create().name("TargTag-W"));
|
||||
|
||||
final DistributionSet setA = testdataFactory.createDistributionSet("");
|
||||
|
||||
@@ -66,7 +66,7 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
targAs = toggleTagAssignment(targAs, targTagX).getAssignedEntity();
|
||||
|
||||
final Target targSpecialName = targetManagement
|
||||
.updateTarget(entityFactory.target().update(targAs.get(0).getControllerId()).name("targ-A-special"));
|
||||
.update(entityFactory.target().update(targAs.get(0).getControllerId()).name("targ-A-special"));
|
||||
|
||||
final String targetDsBIdPref = "targ-B";
|
||||
List<Target> targBs = testdataFactory.createTargets(100, targetDsBIdPref,
|
||||
@@ -102,61 +102,58 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final List<TargetUpdateStatus> unknown = Arrays.asList(TargetUpdateStatus.UNKNOWN);
|
||||
final List<TargetUpdateStatus> pending = Arrays.asList(TargetUpdateStatus.PENDING);
|
||||
final List<TargetUpdateStatus> both = Arrays.asList(TargetUpdateStatus.UNKNOWN,
|
||||
TargetUpdateStatus.PENDING);
|
||||
final List<TargetUpdateStatus> both = Arrays.asList(TargetUpdateStatus.UNKNOWN, TargetUpdateStatus.PENDING);
|
||||
|
||||
// get final updated version of targets
|
||||
targAs = targetManagement
|
||||
.findTargetsByControllerID(targAs.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
.getByControllerID(targAs.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
targBs = targetManagement
|
||||
.findTargetsByControllerID(targBs.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
.getByControllerID(targBs.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
targCs = targetManagement
|
||||
.findTargetsByControllerID(targCs.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
.getByControllerID(targCs.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
|
||||
// try to find several targets with different filter settings
|
||||
verifyThat1TargetHasNameAndId("targ-A-special", targSpecialName.getControllerId());
|
||||
verifyThatRepositoryContains400Targets();
|
||||
verifyThat200TargetsHaveTagD(targTagW, concat(targBs, targCs));
|
||||
verifyThat100TargetsContainsGivenTextAndHaveTagAssigned(targTagY, targTagW, targBs);
|
||||
verifyThat1TargetHasTagHasDescOrNameAndDs(targTagW, setA,
|
||||
targetManagement.findTargetByControllerID(assignedC).get());
|
||||
verifyThat1TargetHasTagHasDescOrNameAndDs(targTagW, setA, targetManagement.getByControllerID(assignedC).get());
|
||||
verifyThat0TargetsWithTagAndDescOrNameHasDS(targTagW, setA);
|
||||
verifyThat0TargetsWithNameOrdescAndDSHaveTag(targTagX, setA);
|
||||
verifyThat3TargetsHaveDSAssigned(setA,
|
||||
targetManagement.findTargetsByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
verifyThat1TargetWithDescOrNameHasDS(setA, targetManagement.findTargetByControllerID(assignedA).get());
|
||||
targetManagement.getByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
verifyThat1TargetWithDescOrNameHasDS(setA, targetManagement.getByControllerID(assignedA).get());
|
||||
List<Target> expected = concat(targAs, targBs, targCs, targDs);
|
||||
expected.removeAll(
|
||||
targetManagement.findTargetsByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
expected.removeAll(targetManagement.getByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
verifyThat397TargetsAreInStatusUnknown(unknown, expected);
|
||||
expected = concat(targBs, targCs);
|
||||
expected.removeAll(targetManagement.findTargetsByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
expected.removeAll(targetManagement.getByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
verifyThat198TargetsAreInStatusUnknownAndHaveGivenTags(targTagY, targTagW, unknown, expected);
|
||||
verfyThat0TargetsAreInStatusUnknownAndHaveDSAssigned(setA, unknown);
|
||||
expected = concat(targAs);
|
||||
expected.remove(targetManagement.findTargetByControllerID(assignedA).get());
|
||||
expected.remove(targetManagement.getByControllerID(assignedA).get());
|
||||
verifyThat99TargetsWithNameOrDescriptionAreInGivenStatus(unknown, expected);
|
||||
expected = concat(targBs);
|
||||
expected.remove(targetManagement.findTargetByControllerID(assignedB).get());
|
||||
expected.remove(targetManagement.getByControllerID(assignedB).get());
|
||||
verifyThat99TargetsWithGivenNameOrDescAndTagAreInStatusUnknown(targTagW, unknown, expected);
|
||||
verifyThat3TargetsAreInStatusPending(pending,
|
||||
targetManagement.findTargetsByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
targetManagement.getByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
verifyThat3TargetsWithGivenDSAreInPending(setA, pending,
|
||||
targetManagement.findTargetsByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
targetManagement.getByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
verifyThat1TargetWithGivenNameOrDescAndDSIsInPending(setA, pending,
|
||||
targetManagement.findTargetByControllerID(assignedA).get());
|
||||
targetManagement.getByControllerID(assignedA).get());
|
||||
verifyThat1TargetWithGivenNameOrDescAndTagAndDSIsInPending(targTagW, setA, pending,
|
||||
targetManagement.findTargetByControllerID(assignedB).get());
|
||||
targetManagement.getByControllerID(assignedB).get());
|
||||
verifyThat2TargetsWithGivenTagAndDSIsInPending(targTagW, setA, pending,
|
||||
targetManagement.findTargetsByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
targetManagement.getByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
verifyThat2TargetsWithGivenTagAreInPending(targTagW, pending,
|
||||
targetManagement.findTargetsByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
targetManagement.getByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
verifyThat200targetsWithGivenTagAreInStatusPendingorUnknown(targTagW, both, concat(targBs, targCs));
|
||||
verfiyThat1TargetAIsInStatusPendingAndHasDSInstalled(installedSet, pending,
|
||||
targetManagement.findTargetByControllerID(installedC).get());
|
||||
targetManagement.getByControllerID(installedC).get());
|
||||
|
||||
expected = concat(targBs, targCs);
|
||||
expected.removeAll(targetManagement.findTargetsByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
expected.removeAll(targetManagement.getByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
verifyThat198TargetsAreInStatusUnknownAndOverdue(unknown, expected);
|
||||
}
|
||||
|
||||
@@ -165,14 +162,15 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final List<TargetUpdateStatus> pending, final Target expected) {
|
||||
final String query = "updatestatus==pending and installedds.name==" + installedSet.getName();
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, pending, null, null, installedSet.getId(), Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(pending, null, null, installedSet.getId(), Boolean.FALSE, new String[0]))
|
||||
.getContent()).as("has number of elements").hasSize(1)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, null,
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(pending, null, null,
|
||||
installedSet.getId(), Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsExactly(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@@ -182,13 +180,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "(updatestatus==pending or updatestatus==unknown) and tag==" + targTagW.getName();
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, both, null, null, null, Boolean.FALSE, targTagW.getName()).getContent())
|
||||
.as("has number of elements").hasSize(200).as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(both, null, null, null,
|
||||
.findByFilters(PAGE, new FilterParams(both, null, null, null, Boolean.FALSE, targTagW.getName()))
|
||||
.getContent()).as("has number of elements").hasSize(200)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(both, null, null, null,
|
||||
Boolean.FALSE, targTagW.getName())))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -197,14 +196,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==pending and tag==" + targTagW.getName();
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, pending, null, null, null, Boolean.FALSE, targTagW.getName())
|
||||
.findByFilters(PAGE, new FilterParams(pending, null, null, null, Boolean.FALSE, targTagW.getName()))
|
||||
.getContent()).as("has number of elements").hasSize(2)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, null, null,
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(pending, null, null, null,
|
||||
Boolean.FALSE, targTagW.getName())))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -214,14 +213,15 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
+ setA.getName() + ") and tag==" + targTagW.getName();
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, pending, null, null, setA.getId(), Boolean.FALSE, targTagW.getName())
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(pending, null, null, setA.getId(), Boolean.FALSE, targTagW.getName()))
|
||||
.getContent()).as("has number of elements").hasSize(2)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, null,
|
||||
setA.getId(), Boolean.FALSE, targTagW.getName())))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(pending, null, null, setA.getId(),
|
||||
Boolean.FALSE, targTagW.getName())))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -230,14 +230,16 @@ public 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.findTargetByFilters(PAGE, pending, null, "%targ-B%", setA.getId(), Boolean.FALSE,
|
||||
targTagW.getName()).getContent()).as("has number of elements").hasSize(1)
|
||||
assertThat(targetManagement
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(pending, null, "%targ-B%", setA.getId(), Boolean.FALSE, targTagW.getName()))
|
||||
.getContent()).as("has number of elements").hasSize(1)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, "%targ-B%",
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(pending, null, "%targ-B%",
|
||||
setA.getId(), Boolean.FALSE, targTagW.getName())))
|
||||
.as("and contains the following elements").containsExactly(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -247,14 +249,15 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
+ setA.getName() + ") and (name==*targ-A* or description==*targ-A*)";
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, pending, null, "%targ-A%", setA.getId(), Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(pending, null, "%targ-A%", setA.getId(), Boolean.FALSE, new String[0]))
|
||||
.getContent()).as("has number of elements").hasSize(1)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, "%targ-A%",
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(pending, null, "%targ-A%",
|
||||
setA.getId(), Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsExactly(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -264,14 +267,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
+ setA.getName() + ")";
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, pending, null, null, setA.getId(), Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE, new FilterParams(pending, null, null, setA.getId(), Boolean.FALSE, new String[0]))
|
||||
.getContent()).as("has number of elements").hasSize(3)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, null,
|
||||
setA.getId(), Boolean.FALSE, new String[0])))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(pending, null, null, setA.getId(),
|
||||
Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -280,13 +283,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==pending";
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, pending, null, null, null, Boolean.FALSE, new String[0]).getContent())
|
||||
.as("has number of elements").hasSize(3).as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, null, null,
|
||||
.findByFilters(PAGE, new FilterParams(pending, null, null, null, Boolean.FALSE, new String[0]))
|
||||
.getContent()).as("has number of elements").hasSize(3)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(pending, null, null, null,
|
||||
Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -296,14 +300,15 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
+ targTagW.getName();
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, unknown, null, "%targ-B%", null, Boolean.FALSE, targTagW.getName())
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(unknown, null, "%targ-B%", null, Boolean.FALSE, targTagW.getName()))
|
||||
.getContent()).as("has number of elements").hasSize(99)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, null, "%targ-B%",
|
||||
null, Boolean.FALSE, targTagW.getName())))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(unknown, null, "%targ-B%", null,
|
||||
Boolean.FALSE, targTagW.getName())))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -312,14 +317,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==unknown and (name==*targ-A* or description==*targ-A*)";
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, unknown, null, "%targ-A%", null, Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE, new FilterParams(unknown, null, "%targ-A%", null, Boolean.FALSE, new String[0]))
|
||||
.getContent()).as("has number of elements").hasSize(99)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, null, "%targ-A%",
|
||||
null, Boolean.FALSE, new String[0])))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(unknown, null, "%targ-A%", null,
|
||||
Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@@ -330,13 +335,13 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
+ setA.getName() + ")";
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, unknown, null, null, setA.getId(), Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE, new FilterParams(unknown, null, null, setA.getId(), Boolean.FALSE, new String[0]))
|
||||
.getContent()).as("has number of elements").hasSize(0)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, null, null,
|
||||
setA.getId(), Boolean.FALSE, new String[0])))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(unknown, null, null, setA.getId(),
|
||||
Boolean.FALSE, new String[0])))
|
||||
.as("and filter query returns the same result")
|
||||
.hasSize(targetManagement.findTargetsAll(query, PAGE).getContent().size());
|
||||
.hasSize(targetManagement.findByRsql(PAGE, query).getContent().size());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -345,14 +350,15 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==unknown and (tag==" + targTagY.getName() + " or tag==" + targTagW.getName()
|
||||
+ ")";
|
||||
|
||||
assertThat(targetManagement.findTargetByFilters(PAGE, unknown, null, null, null, Boolean.FALSE,
|
||||
targTagY.getName(), targTagW.getName()).getContent()).as("has number of elements").hasSize(198)
|
||||
assertThat(targetManagement.findByFilters(PAGE,
|
||||
new FilterParams(unknown, null, null, null, Boolean.FALSE, targTagY.getName(), targTagW.getName()))
|
||||
.getContent()).as("has number of elements").hasSize(198)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, null, null, null,
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(unknown, null, null, null,
|
||||
Boolean.FALSE, targTagY.getName(), targTagW.getName())))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -361,13 +367,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==unknown";
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, unknown, null, null, null, Boolean.FALSE, new String[0]).getContent())
|
||||
.as("has number of elements").hasSize(397).as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, null, null, null,
|
||||
.findByFilters(PAGE, new FilterParams(unknown, null, null, null, Boolean.FALSE, new String[0]))
|
||||
.getContent()).as("has number of elements").hasSize(397)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(unknown, null, null, null,
|
||||
Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@@ -378,14 +385,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "lastcontrollerrequestat=le=${overdue_ts};updatestatus==UNKNOWN";
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, unknown, Boolean.TRUE, null, null, Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE, new FilterParams(unknown, Boolean.TRUE, null, null, Boolean.FALSE, new String[0]))
|
||||
.getContent()).as("has number of elements").hasSize(198)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, Boolean.TRUE, null,
|
||||
null, Boolean.FALSE, new String[0])))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(unknown, Boolean.TRUE, null, null,
|
||||
Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -394,14 +401,15 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
+ " or installedds.name==" + setA.getName() + ")";
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, null, null, "%targ-A%", setA.getId(), Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(null, null, "%targ-A%", setA.getId(), Boolean.FALSE, new String[0]))
|
||||
.getContent()).as("has number of elements").hasSize(1)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, "%targ-A%",
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(null, null, "%targ-A%",
|
||||
setA.getId(), Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsExactly(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@@ -410,14 +418,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName();
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, null, null, null, setA.getId(), Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE, new FilterParams(null, null, null, setA.getId(), Boolean.FALSE, new String[0]))
|
||||
.getContent()).as("has number of elements").hasSize(3)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, null,
|
||||
setA.getId(), Boolean.FALSE, new String[0])))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(null, null, null, setA.getId(),
|
||||
Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@@ -426,13 +434,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
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
|
||||
.findTargetByFilters(PAGE, null, null, "%targ-C%", setA.getId(), Boolean.FALSE, targTagX.getName())
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(null, null, "%targ-C%", setA.getId(), Boolean.FALSE, targTagX.getName()))
|
||||
.getContent()).as("has number of elements").hasSize(0)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, "%targ-C%",
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(null, null, "%targ-C%",
|
||||
setA.getId(), Boolean.FALSE, targTagX.getName())))
|
||||
.as("and filter query returns the same result")
|
||||
.hasSize(targetManagement.findTargetsAll(query, PAGE).getContent().size());
|
||||
.hasSize(targetManagement.findByRsql(PAGE, query).getContent().size());
|
||||
|
||||
}
|
||||
|
||||
@@ -441,13 +450,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
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
|
||||
.findTargetByFilters(PAGE, null, null, "%targ-A%", setA.getId(), Boolean.FALSE, targTagW.getName())
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(null, null, "%targ-A%", setA.getId(), Boolean.FALSE, targTagW.getName()))
|
||||
.getContent()).as("has number of elements").hasSize(0)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, "%targ-A%",
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(null, null, "%targ-A%",
|
||||
setA.getId(), Boolean.FALSE, targTagW.getName())))
|
||||
.as("and filter query returns the same result")
|
||||
.hasSize(targetManagement.findTargetsAll(query, PAGE).getContent().size());
|
||||
.hasSize(targetManagement.findByRsql(PAGE, query).getContent().size());
|
||||
|
||||
}
|
||||
|
||||
@@ -457,27 +467,29 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
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
|
||||
.findTargetByFilters(PAGE, null, null, "%targ-C%", setA.getId(), Boolean.FALSE, targTagW.getName())
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(null, null, "%targ-C%", setA.getId(), Boolean.FALSE, targTagW.getName()))
|
||||
.getContent()).as("has number of elements").hasSize(1)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, "%targ-C%",
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(null, null, "%targ-C%",
|
||||
setA.getId(), Boolean.FALSE, targTagW.getName())))
|
||||
.as("and contains the following elements").containsExactly(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@Step
|
||||
private void verifyThat1TargetHasNameAndId(final String name, final String controllerId) {
|
||||
assertThat(targetManagement.findTargetByFilters(PAGE, null, null, name, null, Boolean.FALSE).getContent())
|
||||
.as("has number of elements").hasSize(1).as("that number is also returned by count query").hasSize(Ints
|
||||
.saturatedCast(targetManagement.countTargetByFilters(null, null, name, null, Boolean.FALSE)));
|
||||
assertThat(targetManagement.findByFilters(PAGE, new FilterParams(null, null, name, null, Boolean.FALSE))
|
||||
.getContent()).as("has number of elements").hasSize(1).as("that number is also returned by count query")
|
||||
.hasSize(Ints
|
||||
.saturatedCast(targetManagement.countByFilters(null, null, name, null, Boolean.FALSE)));
|
||||
|
||||
assertThat(targetManagement.findTargetByFilters(PAGE, null, null, controllerId, null, Boolean.FALSE)
|
||||
assertThat(targetManagement.findByFilters(PAGE, new FilterParams(null, null, controllerId, null, Boolean.FALSE))
|
||||
.getContent()).as("has number of elements").hasSize(1).as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(
|
||||
targetManagement.countTargetByFilters(null, null, controllerId, null, Boolean.FALSE)));
|
||||
targetManagement.countByFilters(null, null, controllerId, null, Boolean.FALSE)));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -485,14 +497,15 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final TargetTag targTagW, final List<Target> expected) {
|
||||
final String query = "(name==*targ-B* or description==*targ-B*) and (tag==" + targTagY.getName() + " or tag=="
|
||||
+ targTagW.getName() + ")";
|
||||
assertThat(targetManagement.findTargetByFilters(PAGE, null, null, "%targ-B%", null, Boolean.FALSE,
|
||||
targTagY.getName(), targTagW.getName()).getContent()).as("has number of elements").hasSize(100)
|
||||
assertThat(targetManagement.findByFilters(PAGE,
|
||||
new FilterParams(null, null, "%targ-B%", null, Boolean.FALSE, targTagY.getName(), targTagW.getName()))
|
||||
.getContent()).as("has number of elements").hasSize(100)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, "%targ-B%", null,
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(null, null, "%targ-B%", null,
|
||||
Boolean.FALSE, targTagY.getName(), targTagW.getName())))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@@ -507,26 +520,25 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
private void verifyThat200TargetsHaveTagD(final TargetTag targTagD, final List<Target> expected) {
|
||||
final String query = "tag==" + targTagD.getName();
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, null, null, null, null, Boolean.FALSE, targTagD.getName()).getContent())
|
||||
.as("Expected number of results is").hasSize(200)
|
||||
.findByFilters(PAGE, new FilterParams(null, null, null, null, Boolean.FALSE, targTagD.getName()))
|
||||
.getContent()).as("Expected number of results is").hasSize(200)
|
||||
.as("and is expected number of results is equal to ")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, null, null,
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(null, null, null, null,
|
||||
Boolean.FALSE, targTagD.getName())))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@Step
|
||||
private void verifyThatRepositoryContains400Targets() {
|
||||
assertThat(
|
||||
targetManagement.findTargetByFilters(PAGE, null, null, null, null, null, new String[0]).getContent())
|
||||
.as("Overall we expect that many targets in the repository").hasSize(400)
|
||||
assertThat(targetManagement.findByFilters(PAGE, new FilterParams(null, null, null, null, null, new String[0]))
|
||||
.getContent()).as("Overall we expect that many targets in the repository").hasSize(400)
|
||||
.as("which is also reflected by repository count")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetsAll()))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.count()))
|
||||
.as("which is also reflected by call without specification")
|
||||
.containsAll(targetManagement.findTargetsAll(PAGE).getContent());
|
||||
.containsAll(targetManagement.findAll(PAGE).getContent());
|
||||
|
||||
}
|
||||
|
||||
@@ -546,7 +558,7 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
.sendUpdateActionStatusToTargets(targInstalled, Status.FINISHED, Collections.singletonList("installed"))
|
||||
.stream().map(Action::getTarget).collect(Collectors.toList());
|
||||
|
||||
final Slice<Target> result = targetManagement.findTargetsAllOrderByLinkedDistributionSet(PAGE, ds.getId(),
|
||||
final Slice<Target> result = targetManagement.findByFilterOrderByLinkedDistributionSet(PAGE, ds.getId(),
|
||||
new FilterParams(null, null, null, null, Boolean.FALSE, new String[0]));
|
||||
|
||||
final Comparator<TenantAwareBaseEntity> byId = (e1, e2) -> Long.compare(e2.getId(), e1.getId());
|
||||
@@ -580,11 +592,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
List<Target> targInstalled = Lists.newArrayListWithExpectedSize(overdueMix.length);
|
||||
|
||||
for (int i = 0; i < overdueMix.length; i++) {
|
||||
notAssigned.add(targetManagement.createTarget(
|
||||
entityFactory.target().create().controllerId("not" + i).lastTargetQuery(overdueMix[i])));
|
||||
targAssigned.add(targetManagement.createTarget(
|
||||
notAssigned.add(targetManagement
|
||||
.create(entityFactory.target().create().controllerId("not" + i).lastTargetQuery(overdueMix[i])));
|
||||
targAssigned.add(targetManagement.create(
|
||||
entityFactory.target().create().controllerId("assigned" + i).lastTargetQuery(overdueMix[i])));
|
||||
targInstalled.add(targetManagement.createTarget(
|
||||
targInstalled.add(targetManagement.create(
|
||||
entityFactory.target().create().controllerId("installed" + i).lastTargetQuery(overdueMix[i])));
|
||||
}
|
||||
|
||||
@@ -596,8 +608,8 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
.sendUpdateActionStatusToTargets(targInstalled, Status.FINISHED, Collections.singletonList("installed"))
|
||||
.stream().map(Action::getTarget).collect(Collectors.toList());
|
||||
|
||||
final Slice<Target> result = targetManagement.findTargetsAllOrderByLinkedDistributionSet(PAGE, ds.getId(),
|
||||
new FilterParams(null, null, Boolean.TRUE, null, Boolean.FALSE, new String[0]));
|
||||
final Slice<Target> result = targetManagement.findByFilterOrderByLinkedDistributionSet(PAGE, ds.getId(),
|
||||
new FilterParams(null, Boolean.TRUE, null, null, Boolean.FALSE, new String[0]));
|
||||
|
||||
final Comparator<TenantAwareBaseEntity> byId = (e1, e2) -> Long.compare(e2.getId(), e1.getId());
|
||||
|
||||
@@ -627,10 +639,10 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
assignDistributionSet(assignedSet, assignedtargets);
|
||||
|
||||
// get final updated version of targets
|
||||
assignedtargets = targetManagement.findTargetsByControllerID(
|
||||
assignedtargets = targetManagement.getByControllerID(
|
||||
assignedtargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()));
|
||||
|
||||
assertThat(targetManagement.findTargetByAssignedDistributionSet(assignedSet.getId(), PAGE))
|
||||
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, assignedSet.getId()))
|
||||
.as("Contains the assigned targets").containsAll(assignedtargets)
|
||||
.as("and that means the following expected amount").hasSize(10);
|
||||
|
||||
@@ -641,14 +653,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
public void findTargetWithoutAssignedDistributionSet() {
|
||||
final DistributionSet assignedSet = testdataFactory.createDistributionSet("");
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement
|
||||
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name("tfq").query("name==*"));
|
||||
.create(entityFactory.targetFilterQuery().create().name("tfq").query("name==*"));
|
||||
final List<Target> unassignedTargets = testdataFactory.createTargets(12, "unassigned", "unassigned");
|
||||
final List<Target> assignedTargets = testdataFactory.createTargets(10, "assigned", "assigned");
|
||||
|
||||
assignDistributionSet(assignedSet, assignedTargets);
|
||||
|
||||
final List<Target> result = targetManagement
|
||||
.findAllTargetsByTargetFilterQueryAndNonDS(PAGE, assignedSet.getId(), tfq.getQuery()).getContent();
|
||||
.findByTargetFilterQueryAndNonDS(PAGE, assignedSet.getId(), tfq.getQuery()).getContent();
|
||||
assertThat(result).as("count of targets").hasSize(unassignedTargets.size()).as("contains all targets")
|
||||
.containsAll(unassignedTargets);
|
||||
|
||||
@@ -668,10 +680,10 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
assignDistributionSet(assignedSet, installedtargets);
|
||||
|
||||
// get final updated version of targets
|
||||
installedtargets = targetManagement.findTargetsByControllerID(
|
||||
installedtargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()));
|
||||
installedtargets = targetManagement
|
||||
.getByControllerID(installedtargets.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
|
||||
assertThat(targetManagement.findTargetByInstalledDistributionSet(installedSet.getId(), PAGE))
|
||||
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, installedSet.getId()))
|
||||
.as("Contains the assigned targets").containsAll(installedtargets)
|
||||
.as("and that means the following expected amount").hasSize(10);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import javax.validation.ConstraintViolationException;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.FilterParams;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent;
|
||||
@@ -71,8 +72,8 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
+ "of Optional not present.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(targetManagement.findTargetByControllerID(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(targetManagement.findTargetById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(targetManagement.getByControllerID(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(targetManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,45 +82,42 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetTagCreatedEvent.class, count = 1) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
final TargetTag tag = tagManagement.createTargetTag(entityFactory.tag().create().name("A"));
|
||||
final TargetTag tag = targetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
final Target target = testdataFactory.createTarget();
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetManagement.assignTag(Arrays.asList(target.getControllerId()), NOT_EXIST_IDL), "TargetTag");
|
||||
verifyThrownExceptionBy(() -> targetManagement.assignTag(Arrays.asList(NOT_EXIST_ID), tag.getId()), "Target");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetManagement.findTargetsByTag(PAGE, NOT_EXIST_IDL), "TargetTag");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findTargetsByTag(PAGE, "name==*", NOT_EXIST_IDL), "TargetTag");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByTag(PAGE, NOT_EXIST_IDL), "TargetTag");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByRsqlAndTag(PAGE, "name==*", NOT_EXIST_IDL), "TargetTag");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetManagement.countTargetByAssignedDistributionSet(NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> targetManagement.countByAssignedDistributionSet(NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(() -> targetManagement.countTargetByInstalledDistributionSet(NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> targetManagement.countByInstalledDistributionSet(NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetManagement.countTargetByTargetFilterQuery(NOT_EXIST_IDL),
|
||||
"TargetFilterQuery");
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetManagement.countTargetsByTargetFilterQueryAndNonDS(NOT_EXIST_IDL, "name==*"),
|
||||
verifyThrownExceptionBy(() -> targetManagement.countByTargetFilterQuery(NOT_EXIST_IDL), "TargetFilterQuery");
|
||||
verifyThrownExceptionBy(() -> targetManagement.countByRsqlAndNonDS(NOT_EXIST_IDL, "name==*"),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetManagement.deleteTarget(NOT_EXIST_ID), "Target");
|
||||
verifyThrownExceptionBy(() -> targetManagement.deleteTargets(Arrays.asList(NOT_EXIST_IDL)), "Target");
|
||||
verifyThrownExceptionBy(() -> targetManagement.deleteByControllerID(NOT_EXIST_ID), "Target");
|
||||
verifyThrownExceptionBy(() -> targetManagement.delete(Arrays.asList(NOT_EXIST_IDL)), "Target");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetManagement.findAllTargetsByTargetFilterQueryAndNonDS(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByTargetFilterQueryAndNonDS(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findAllTargetsInRolloutGroupWithoutAction(PAGE, NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByInRolloutGroupWithoutAction(PAGE, NOT_EXIST_IDL),
|
||||
"RolloutGroup");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findTargetByAssignedDistributionSet(NOT_EXIST_IDL, PAGE),
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByAssignedDistributionSet(PAGE, NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetManagement.findTargetByAssignedDistributionSet(NOT_EXIST_IDL, "name==*", PAGE),
|
||||
() -> targetManagement.findByAssignedDistributionSetAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetManagement.findTargetByInstalledDistributionSet(NOT_EXIST_IDL, PAGE),
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByInstalledDistributionSet(PAGE, NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetManagement.findTargetByInstalledDistributionSet(NOT_EXIST_IDL, "name==*", PAGE),
|
||||
() -> targetManagement.findByInstalledDistributionSetAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
@@ -131,16 +129,15 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
verifyThrownExceptionBy(() -> targetManagement.unAssignTag(NOT_EXIST_ID, tag.getId()), "Target");
|
||||
verifyThrownExceptionBy(() -> targetManagement.unAssignTag(target.getControllerId(), NOT_EXIST_IDL),
|
||||
"TargetTag");
|
||||
verifyThrownExceptionBy(() -> targetManagement.updateTarget(entityFactory.target().update(NOT_EXIST_ID)),
|
||||
"Target");
|
||||
verifyThrownExceptionBy(() -> targetManagement.update(entityFactory.target().update(NOT_EXIST_ID)), "Target");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that retrieving the target security is only permitted with the necessary permissions.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
|
||||
public void getTargetSecurityTokenOnlyWithCorrectPermission() throws Exception {
|
||||
final Target createdTarget = targetManagement.createTarget(
|
||||
entityFactory.target().create().controllerId("targetWithSecurityToken").securityToken("token"));
|
||||
final Target createdTarget = targetManagement
|
||||
.create(entityFactory.target().create().controllerId("targetWithSecurityToken").securityToken("token"));
|
||||
|
||||
// retrieve security token only with READ_TARGET_SEC_TOKEN permission
|
||||
final String securityTokenWithReadPermission = securityRule.runAs(WithSpringAuthorityRule
|
||||
@@ -172,7 +169,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
public void createTargetForTenantWhichDoesNotExistThrowsTenantNotExistException() {
|
||||
try {
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId("targetId123"));
|
||||
targetManagement.create(entityFactory.target().create().controllerId("targetId123"));
|
||||
fail("should not be possible as the tenant does not exist");
|
||||
} catch (final TenantNotExistException e) {
|
||||
// ok
|
||||
@@ -183,10 +180,10 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Verify that a target with same controller ID than another device cannot be created.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
|
||||
public void createTargetThatViolatesUniqueConstraintFails() {
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId("123"));
|
||||
targetManagement.create(entityFactory.target().create().controllerId("123"));
|
||||
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("123")));
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("123")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -207,12 +204,12 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createAndUpdateTargetWithInvalidDescription(final Target target) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("a")
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("a")
|
||||
.description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("target with too long description should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.updateTarget(entityFactory.target().update(target.getControllerId())
|
||||
.isThrownBy(() -> targetManagement.update(entityFactory.target().update(target.getControllerId())
|
||||
.description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("target with too long description should not be updated");
|
||||
|
||||
@@ -222,17 +219,18 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createAndUpdateTargetWithInvalidName(final Target target) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("a")
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("a")
|
||||
.name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("target with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.updateTarget(entityFactory.target().update(target.getControllerId())
|
||||
.isThrownBy(() -> targetManagement.update(entityFactory.target().update(target.getControllerId())
|
||||
.name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("target with too long name should not be updated");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||
() -> targetManagement.updateTarget(entityFactory.target().update(target.getControllerId()).name("")))
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(
|
||||
() -> targetManagement.update(entityFactory.target().update(target.getControllerId()).name("")))
|
||||
.as("target with too short name should not be updated");
|
||||
|
||||
}
|
||||
@@ -241,18 +239,18 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createAndUpdateTargetWithInvalidSecurityToken(final Target target) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("a")
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("a")
|
||||
.securityToken(RandomStringUtils.randomAlphanumeric(129))))
|
||||
.as("target with too long token should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.updateTarget(entityFactory.target().update(target.getControllerId())
|
||||
.isThrownBy(() -> targetManagement.update(entityFactory.target().update(target.getControllerId())
|
||||
.securityToken(RandomStringUtils.randomAlphanumeric(129))))
|
||||
.as("target with too long token should not be updated");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement
|
||||
.updateTarget(entityFactory.target().update(target.getControllerId()).securityToken("")))
|
||||
.update(entityFactory.target().update(target.getControllerId()).securityToken("")))
|
||||
.as("target with too short token should not be updated");
|
||||
}
|
||||
|
||||
@@ -260,12 +258,12 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createAndUpdateTargetWithInvalidAddress(final Target target) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("a")
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("a")
|
||||
.address(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("target with too long address should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.updateTarget(entityFactory.target().update(target.getControllerId())
|
||||
.isThrownBy(() -> targetManagement.update(entityFactory.target().update(target.getControllerId())
|
||||
.address(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("target with too long address should not be updated");
|
||||
}
|
||||
@@ -273,41 +271,40 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Step
|
||||
private void createTargetWithInvalidControllerId() {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("")))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("")))
|
||||
.as("target with empty controller id should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId(null)))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId(null)))
|
||||
.as("target with null controller id should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(
|
||||
entityFactory.target().create().controllerId(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.isThrownBy(() -> targetManagement
|
||||
.create(entityFactory.target().create().controllerId(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("target with too long controller id should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId(" ")))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId(" ")))
|
||||
.as(WHITESPACE_ERROR);
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId(" a")))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId(" a")))
|
||||
.as(WHITESPACE_ERROR);
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("a ")))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("a ")))
|
||||
.as(WHITESPACE_ERROR);
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("a b")))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("a b")))
|
||||
.as(WHITESPACE_ERROR);
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId(" ")))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId(" ")))
|
||||
.as(WHITESPACE_ERROR);
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(
|
||||
() -> targetManagement.createTarget(entityFactory.target().create().controllerId("aaa bbb")))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("aaa bbb")))
|
||||
.as(WHITESPACE_ERROR);
|
||||
|
||||
}
|
||||
@@ -319,36 +316,36 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 5) })
|
||||
public void assignAndUnassignTargetsToTag() {
|
||||
final List<String> assignTarget = new ArrayList<>();
|
||||
assignTarget.add(targetManagement.createTarget(entityFactory.target().create().controllerId("targetId123"))
|
||||
assignTarget.add(
|
||||
targetManagement.create(entityFactory.target().create().controllerId("targetId123")).getControllerId());
|
||||
assignTarget.add(targetManagement.create(entityFactory.target().create().controllerId("targetId1234"))
|
||||
.getControllerId());
|
||||
assignTarget.add(targetManagement.createTarget(entityFactory.target().create().controllerId("targetId1234"))
|
||||
assignTarget.add(targetManagement.create(entityFactory.target().create().controllerId("targetId1235"))
|
||||
.getControllerId());
|
||||
assignTarget.add(targetManagement.createTarget(entityFactory.target().create().controllerId("targetId1235"))
|
||||
.getControllerId());
|
||||
assignTarget.add(targetManagement.createTarget(entityFactory.target().create().controllerId("targetId1236"))
|
||||
assignTarget.add(targetManagement.create(entityFactory.target().create().controllerId("targetId1236"))
|
||||
.getControllerId());
|
||||
|
||||
final TargetTag targetTag = tagManagement.createTargetTag(entityFactory.tag().create().name("Tag1"));
|
||||
final TargetTag targetTag = targetTagManagement.create(entityFactory.tag().create().name("Tag1"));
|
||||
|
||||
final List<Target> assignedTargets = targetManagement.assignTag(assignTarget, targetTag.getId());
|
||||
assertThat(assignedTargets.size()).as("Assigned targets are wrong").isEqualTo(4);
|
||||
assignedTargets.forEach(target -> assertThat(
|
||||
tagManagement.findAllTargetTags(PAGE, target.getControllerId()).getNumberOfElements()).isEqualTo(1));
|
||||
targetTagManagement.findByTarget(PAGE, target.getControllerId()).getNumberOfElements())
|
||||
.isEqualTo(1));
|
||||
|
||||
TargetTag findTargetTag = tagManagement.findTargetTag("Tag1").get();
|
||||
TargetTag findTargetTag = targetTagManagement.getByName("Tag1").get();
|
||||
assertThat(assignedTargets.size()).as("Assigned targets are wrong")
|
||||
.isEqualTo(targetManagement.findTargetsByTag(PAGE, targetTag.getId()).getNumberOfElements());
|
||||
.isEqualTo(targetManagement.findByTag(PAGE, targetTag.getId()).getNumberOfElements());
|
||||
|
||||
final Target unAssignTarget = targetManagement.unAssignTag("targetId123", findTargetTag.getId());
|
||||
assertThat(unAssignTarget.getControllerId()).as("Controller id is wrong").isEqualTo("targetId123");
|
||||
assertThat(tagManagement.findAllTargetTags(PAGE, unAssignTarget.getControllerId())).as("Tag size is wrong")
|
||||
.isEmpty();
|
||||
findTargetTag = tagManagement.findTargetTag("Tag1").get();
|
||||
assertThat(targetManagement.findTargetsByTag(PAGE, targetTag.getId())).as("Assigned targets are wrong")
|
||||
.hasSize(3);
|
||||
assertThat(targetManagement.findTargetsByTag(PAGE, "controllerId==targetId123", targetTag.getId()))
|
||||
assertThat(targetTagManagement.findByTarget(PAGE, unAssignTarget.getControllerId()))
|
||||
.as("Tag size is wrong").isEmpty();
|
||||
findTargetTag = targetTagManagement.getByName("Tag1").get();
|
||||
assertThat(targetManagement.findByTag(PAGE, targetTag.getId())).as("Assigned targets are wrong").hasSize(3);
|
||||
assertThat(targetManagement.findByRsqlAndTag(PAGE, "controllerId==targetId123", targetTag.getId()))
|
||||
.as("Assigned targets are wrong").isEmpty();
|
||||
assertThat(targetManagement.findTargetsByTag(PAGE, "controllerId==targetId1234", targetTag.getId()))
|
||||
assertThat(targetManagement.findByRsqlAndTag(PAGE, "controllerId==targetId1234", targetTag.getId()))
|
||||
.as("Assigned targets are wrong").hasSize(1);
|
||||
|
||||
}
|
||||
@@ -358,32 +355,32 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 12),
|
||||
@Expect(type = TargetDeletedEvent.class, count = 12), @Expect(type = TargetUpdatedEvent.class, count = 6) })
|
||||
public void deleteAndCreateTargets() {
|
||||
Target target = targetManagement.createTarget(entityFactory.target().create().controllerId("targetId123"));
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(1);
|
||||
targetManagement.deleteTargets(Arrays.asList(target.getId()));
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(0);
|
||||
Target target = targetManagement.create(entityFactory.target().create().controllerId("targetId123"));
|
||||
assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(1);
|
||||
targetManagement.delete(Arrays.asList(target.getId()));
|
||||
assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(0);
|
||||
|
||||
target = createTargetWithAttributes("4711");
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(1);
|
||||
targetManagement.deleteTargets(Arrays.asList(target.getId()));
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(0);
|
||||
assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(1);
|
||||
targetManagement.delete(Arrays.asList(target.getId()));
|
||||
assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(0);
|
||||
|
||||
final List<Long> targets = new ArrayList<>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
target = targetManagement.createTarget(entityFactory.target().create().controllerId("" + i));
|
||||
target = targetManagement.create(entityFactory.target().create().controllerId("" + i));
|
||||
targets.add(target.getId());
|
||||
targets.add(createTargetWithAttributes("" + (i * i + 1000)).getId());
|
||||
}
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(10);
|
||||
targetManagement.deleteTargets(targets);
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(0);
|
||||
assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(10);
|
||||
targetManagement.delete(targets);
|
||||
assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(0);
|
||||
}
|
||||
|
||||
private Target createTargetWithAttributes(final String controllerId) {
|
||||
final Map<String, String> testData = new HashMap<>();
|
||||
testData.put("test1", "testdata1");
|
||||
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId(controllerId));
|
||||
targetManagement.create(entityFactory.target().create().controllerId(controllerId));
|
||||
final Target target = controllerManagement.updateControllerAttributes(controllerId, testData);
|
||||
|
||||
assertThat(targetManagement.getControllerAttributes(controllerId)).as("Controller Attributes are wrong")
|
||||
@@ -403,13 +400,13 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("test");
|
||||
final DistributionSet set2 = testdataFactory.createDistributionSet("test2");
|
||||
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByAssignedDistributionSet(set.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByInstalledDistributionSet(set.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByAssignedDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByInstalledDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
|
||||
Target target = createTargetWithAttributes("4711");
|
||||
@@ -423,16 +420,16 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
entityFactory.actionStatus().create(result.getActions().get(0)).status(Status.FINISHED));
|
||||
assignDistributionSet(set2.getId(), "4711");
|
||||
|
||||
target = targetManagement.findTargetByControllerID("4711").get();
|
||||
target = targetManagement.getByControllerID("4711").get();
|
||||
// read data
|
||||
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByAssignedDistributionSet(set.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByInstalledDistributionSet(set.getId())).as("Target count is wrong")
|
||||
.isEqualTo(1);
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByAssignedDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
.isEqualTo(1);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByInstalledDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
assertThat(target.getLastTargetQuery()).as("Target query is not work").isGreaterThanOrEqualTo(current);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet("4711").get()).as("Assigned ds size is wrong")
|
||||
@@ -458,9 +455,9 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Checks if the EntityAlreadyExistsException is thrown if a single target with the same controller ID are created twice.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
|
||||
public void createTargetDuplicate() {
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId("4711"));
|
||||
targetManagement.create(entityFactory.target().create().controllerId("4711"));
|
||||
try {
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId("4711"));
|
||||
targetManagement.create(entityFactory.target().create().controllerId("4711"));
|
||||
fail("Target already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
}
|
||||
@@ -484,7 +481,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
private void checkTargetHasTags(final boolean strict, final Iterable<Target> targets, final TargetTag... tags) {
|
||||
_target: for (final Target tl : targets) {
|
||||
for (final Tag tt : tagManagement.findAllTargetTags(PAGE, tl.getControllerId())) {
|
||||
for (final Tag tt : targetTagManagement.findByTarget(PAGE, tl.getControllerId())) {
|
||||
for (final Tag tag : tags) {
|
||||
if (tag.getName().equals(tt.getName())) {
|
||||
continue _target;
|
||||
@@ -500,10 +497,10 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private void checkTargetHasNotTags(final Iterable<Target> targets, final TargetTag... tags) {
|
||||
for (final Target tl : targets) {
|
||||
targetManagement.findTargetByControllerID(tl.getControllerId()).get();
|
||||
targetManagement.getByControllerID(tl.getControllerId()).get();
|
||||
|
||||
for (final Tag tag : tags) {
|
||||
for (final Tag tt : tagManagement.findAllTargetTags(PAGE, tl.getControllerId())) {
|
||||
for (final Tag tt : targetTagManagement.findByTarget(PAGE, tl.getControllerId())) {
|
||||
if (tag.getName().equals(tt.getName())) {
|
||||
fail("Target should have no tags");
|
||||
}
|
||||
@@ -531,7 +528,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertNotNull("The lastModifiedAt attribut of the target should no be null", savedTarget.getLastModifiedAt());
|
||||
|
||||
Thread.sleep(1);
|
||||
savedTarget = targetManagement.updateTarget(
|
||||
savedTarget = targetManagement.update(
|
||||
entityFactory.target().update(savedTarget.getControllerId()).description("changed description"));
|
||||
assertNotNull("The lastModifiedAt attribute of the target should not be null", savedTarget.getLastModifiedAt());
|
||||
assertThat(createdAt).as("CreatedAt compared with saved modifiedAt")
|
||||
@@ -540,7 +537,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
.isNotEqualTo(savedTarget.getLastModifiedAt());
|
||||
modifiedAt = savedTarget.getLastModifiedAt();
|
||||
|
||||
final Target foundTarget = targetManagement.findTargetByControllerID(savedTarget.getControllerId()).get();
|
||||
final Target foundTarget = targetManagement.getByControllerID(savedTarget.getControllerId()).get();
|
||||
assertNotNull("The target should not be null", foundTarget);
|
||||
assertThat(myCtrlID).as("ControllerId compared with saved controllerId")
|
||||
.isEqualTo(foundTarget.getControllerId());
|
||||
@@ -572,7 +569,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
// change the objects and save to again to trigger a change on
|
||||
// lastModifiedAt
|
||||
firstList = firstList.stream()
|
||||
.map(t -> targetManagement.updateTarget(
|
||||
.map(t -> targetManagement.update(
|
||||
entityFactory.target().update(t.getControllerId()).name(t.getName().concat("\tchanged"))))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -600,16 +597,16 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
targetManagement.deleteTarget(extra.getControllerId());
|
||||
targetManagement.deleteByControllerID(extra.getControllerId());
|
||||
|
||||
final int numberToDelete = 50;
|
||||
final Collection<Target> targetsToDelete = firstList.subList(0, numberToDelete);
|
||||
final Target[] deletedTargets = Iterables.toArray(targetsToDelete, Target.class);
|
||||
final List<Long> targetsIdsToDelete = targetsToDelete.stream().map(Target::getId).collect(Collectors.toList());
|
||||
|
||||
targetManagement.deleteTargets(targetsIdsToDelete);
|
||||
targetManagement.delete(targetsIdsToDelete);
|
||||
|
||||
final List<Target> targetsLeft = targetManagement.findTargetsAll(new PageRequest(0, 200)).getContent();
|
||||
final List<Target> targetsLeft = targetManagement.findAll(new PageRequest(0, 200)).getContent();
|
||||
assertThat(firstList.spliterator().getExactSizeIfKnown() - numberToDelete).as("Size of splited list")
|
||||
.isEqualTo(targetsLeft.spliterator().getExactSizeIfKnown());
|
||||
|
||||
@@ -633,17 +630,17 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
final List<TargetTag> t2Tags = testdataFactory.createTargetTags(noT2Tags, "tag2");
|
||||
t2Tags.forEach(tag -> targetManagement.assignTag(Arrays.asList(t2.getControllerId()), tag.getId()));
|
||||
|
||||
final Target t11 = targetManagement.findTargetByControllerID(t1.getControllerId()).get();
|
||||
assertThat(tagManagement.findAllTargetTags(PAGE, t11.getControllerId()).getContent()).as("Tag size is wrong")
|
||||
.hasSize(noT1Tags).containsAll(t1Tags);
|
||||
assertThat(tagManagement.findAllTargetTags(PAGE, t11.getControllerId()).getContent()).as("Tag size is wrong")
|
||||
.hasSize(noT1Tags).doesNotContain(Iterables.toArray(t2Tags, TargetTag.class));
|
||||
final Target t11 = targetManagement.getByControllerID(t1.getControllerId()).get();
|
||||
assertThat(targetTagManagement.findByTarget(PAGE, t11.getControllerId()).getContent())
|
||||
.as("Tag size is wrong").hasSize(noT1Tags).containsAll(t1Tags);
|
||||
assertThat(targetTagManagement.findByTarget(PAGE, t11.getControllerId()).getContent())
|
||||
.as("Tag size is wrong").hasSize(noT1Tags).doesNotContain(Iterables.toArray(t2Tags, TargetTag.class));
|
||||
|
||||
final Target t21 = targetManagement.findTargetByControllerID(t2.getControllerId()).get();
|
||||
assertThat(tagManagement.findAllTargetTags(PAGE, t21.getControllerId()).getContent()).as("Tag size is wrong")
|
||||
.hasSize(noT2Tags).containsAll(t2Tags);
|
||||
assertThat(tagManagement.findAllTargetTags(PAGE, t21.getControllerId()).getContent()).as("Tag size is wrong")
|
||||
.hasSize(noT2Tags).doesNotContain(Iterables.toArray(t1Tags, TargetTag.class));
|
||||
final Target t21 = targetManagement.getByControllerID(t2.getControllerId()).get();
|
||||
assertThat(targetTagManagement.findByTarget(PAGE, t21.getControllerId()).getContent())
|
||||
.as("Tag size is wrong").hasSize(noT2Tags).containsAll(t2Tags);
|
||||
assertThat(targetTagManagement.findByTarget(PAGE, t21.getControllerId()).getContent())
|
||||
.as("Tag size is wrong").hasSize(noT2Tags).doesNotContain(Iterables.toArray(t1Tags, TargetTag.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -660,10 +657,10 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final List<Target> tagABCTargets = testdataFactory.createTargets(10, "tagABCTargets", "first description");
|
||||
|
||||
final TargetTag tagA = tagManagement.createTargetTag(entityFactory.tag().create().name("A"));
|
||||
final TargetTag tagB = tagManagement.createTargetTag(entityFactory.tag().create().name("B"));
|
||||
final TargetTag tagC = tagManagement.createTargetTag(entityFactory.tag().create().name("C"));
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("X"));
|
||||
final TargetTag tagA = targetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
final TargetTag tagB = targetTagManagement.create(entityFactory.tag().create().name("B"));
|
||||
final TargetTag tagC = targetTagManagement.create(entityFactory.tag().create().name("C"));
|
||||
targetTagManagement.create(entityFactory.tag().create().name("X"));
|
||||
|
||||
// doing different assignments
|
||||
toggleTagAssignment(tagATargets, tagA);
|
||||
@@ -677,7 +674,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
toggleTagAssignment(tagABCTargets, tagB);
|
||||
toggleTagAssignment(tagABCTargets, tagC);
|
||||
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, null, Boolean.FALSE, "X"))
|
||||
assertThat(targetManagement.countByFilters(null, null, null, null, Boolean.FALSE, "X"))
|
||||
.as("Target count is wrong").isEqualTo(0);
|
||||
|
||||
// search for targets with tag tagA
|
||||
@@ -707,11 +704,11 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
checkTargetHasNotTags(tagCTargets, tagA, tagB);
|
||||
|
||||
// check again target lists refreshed from DB
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, null, Boolean.FALSE, "A"))
|
||||
assertThat(targetManagement.countByFilters(null, null, null, null, Boolean.FALSE, "A"))
|
||||
.as("Target count is wrong").isEqualTo(targetWithTagA.size());
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, null, Boolean.FALSE, "B"))
|
||||
assertThat(targetManagement.countByFilters(null, null, null, null, Boolean.FALSE, "B"))
|
||||
.as("Target count is wrong").isEqualTo(targetWithTagB.size());
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, null, Boolean.FALSE, "C"))
|
||||
assertThat(targetManagement.countByFilters(null, null, null, null, Boolean.FALSE, "C"))
|
||||
.as("Target count is wrong").isEqualTo(targetWithTagC.size());
|
||||
}
|
||||
|
||||
@@ -721,9 +718,9 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = TargetCreatedEvent.class, count = 109),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 227) })
|
||||
public void targetTagBulkUnassignments() {
|
||||
final TargetTag targTagA = tagManagement.createTargetTag(entityFactory.tag().create().name("Targ-A-Tag"));
|
||||
final TargetTag targTagB = tagManagement.createTargetTag(entityFactory.tag().create().name("Targ-B-Tag"));
|
||||
final TargetTag targTagC = tagManagement.createTargetTag(entityFactory.tag().create().name("Targ-C-Tag"));
|
||||
final TargetTag targTagA = targetTagManagement.create(entityFactory.tag().create().name("Targ-A-Tag"));
|
||||
final TargetTag targTagB = targetTagManagement.create(entityFactory.tag().create().name("Targ-B-Tag"));
|
||||
final TargetTag targTagC = targetTagManagement.create(entityFactory.tag().create().name("Targ-C-Tag"));
|
||||
|
||||
final List<Target> targAs = testdataFactory.createTargets(25, "target-id-A", "first description");
|
||||
final List<Target> targBs = testdataFactory.createTargets(20, "target-id-B", "first description");
|
||||
@@ -780,7 +777,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 25) })
|
||||
public void findTargetsWithNoTag() {
|
||||
|
||||
final TargetTag targTagA = tagManagement.createTargetTag(entityFactory.tag().create().name("Targ-A-Tag"));
|
||||
final TargetTag targTagA = targetTagManagement.create(entityFactory.tag().create().name("Targ-A-Tag"));
|
||||
final List<Target> targAs = testdataFactory.createTargets(25, "target-id-A", "first description");
|
||||
toggleTagAssignment(targAs, targTagA);
|
||||
|
||||
@@ -788,9 +785,9 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final String[] tagNames = null;
|
||||
final List<Target> targetsListWithNoTag = targetManagement
|
||||
.findTargetByFilters(PAGE, null, null, null, null, Boolean.TRUE, tagNames).getContent();
|
||||
.findByFilters(PAGE, new FilterParams(null, null, null, null, Boolean.TRUE, tagNames)).getContent();
|
||||
|
||||
assertThat(50L).as("Total targets").isEqualTo(targetManagement.countTargetsAll());
|
||||
assertThat(50L).as("Total targets").isEqualTo(targetManagement.count());
|
||||
assertThat(25).as("Targets with no tag").isEqualTo(targetsListWithNoTag.size());
|
||||
|
||||
}
|
||||
@@ -804,8 +801,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
controllerManagement.findOrRegisterTargetIfItDoesNotexist(knownTargetControllerId, new URI("http://127.0.0.1"));
|
||||
|
||||
securityRule.runAs(WithSpringAuthorityRule.withUser("bumlux", "READ_TARGET"), () -> {
|
||||
final Target findTargetByControllerID = targetManagement.findTargetByControllerID(knownTargetControllerId)
|
||||
.get();
|
||||
final Target findTargetByControllerID = targetManagement.getByControllerID(knownTargetControllerId).get();
|
||||
assertThat(findTargetByControllerID).isNotNull();
|
||||
assertThat(findTargetByControllerID.getPollStatus()).isNotNull();
|
||||
return null;
|
||||
@@ -817,16 +813,16 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Test that RSQL filter finds targets with tags or specific ids.")
|
||||
public void findTargetsWithTagOrId() {
|
||||
final String rsqlFilter = "tag==Targ-A-Tag,id==target-id-B-00001,id==target-id-B-00008";
|
||||
final TargetTag targTagA = tagManagement.createTargetTag(entityFactory.tag().create().name("Targ-A-Tag"));
|
||||
final TargetTag targTagA = targetTagManagement.create(entityFactory.tag().create().name("Targ-A-Tag"));
|
||||
final List<String> targAs = testdataFactory.createTargets(25, "target-id-A", "first description").stream()
|
||||
.map(Target::getControllerId).collect(Collectors.toList());
|
||||
targetManagement.toggleTagAssignment(targAs, targTagA.getName());
|
||||
|
||||
testdataFactory.createTargets(25, "target-id-B", "first description");
|
||||
|
||||
final Page<Target> foundTargets = targetManagement.findTargetsAll(rsqlFilter, PAGE);
|
||||
final Page<Target> foundTargets = targetManagement.findByRsql(PAGE, rsqlFilter);
|
||||
|
||||
assertThat(targetManagement.countTargetsAll()).as("Total targets").isEqualTo(50L);
|
||||
assertThat(targetManagement.count()).as("Total targets").isEqualTo(50L);
|
||||
assertThat(foundTargets.getTotalElements()).as("Targets in RSQL filter").isEqualTo(27L);
|
||||
}
|
||||
|
||||
@@ -840,7 +836,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createTarget("test" + i);
|
||||
}
|
||||
|
||||
final List<Target> foundDs = targetManagement.findTargetsById(searchIds);
|
||||
final List<Target> foundDs = targetManagement.get(searchIds);
|
||||
|
||||
assertThat(foundDs).hasSize(3);
|
||||
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.Tag;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.test.matcher.Expect;
|
||||
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
|
||||
import org.junit.Test;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
/**
|
||||
* Test class for {@link TargetTagManagement}.
|
||||
*
|
||||
*/
|
||||
@Features("Component Tests - Repository")
|
||||
@Stories("Target Tag Management")
|
||||
public class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Verifies that management get access reacts as specfied on calls for non existing entities by means "
|
||||
+ "of Optional not present.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(targetTagManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(targetTagManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that management queries react as specfied on calls for non existing entities "
|
||||
+ " by means of throwing EntityNotFoundException.")
|
||||
@ExpectEvents({ @Expect(type = DistributionSetTagUpdatedEvent.class, count = 0),
|
||||
@Expect(type = TargetTagUpdatedEvent.class, count = 0) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
verifyThrownExceptionBy(() -> targetTagManagement.delete(NOT_EXIST_ID), "TargetTag");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetTagManagement.update(entityFactory.tag().update(NOT_EXIST_IDL)),
|
||||
"TargetTag");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetTagManagement.findByTarget(PAGE, NOT_EXIST_ID), "Target");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies the toogle mechanism by means on assigning tag if at least on target in the list does not have"
|
||||
+ "the tag yet. Unassign if all of them have the tag already.")
|
||||
public void assignAndUnassignTargetTags() {
|
||||
final List<Target> groupA = testdataFactory.createTargets(20);
|
||||
final List<Target> groupB = testdataFactory.createTargets(20, "groupb", "groupb");
|
||||
|
||||
final TargetTag tag = targetTagManagement
|
||||
.create(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
||||
|
||||
// toggle A only -> A is now assigned
|
||||
TargetTagAssignmentResult result = toggleTagAssignment(groupA, tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(targetManagement.getByControllerID(
|
||||
groupA.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||
|
||||
// toggle A+B -> A is still assigned and B is assigned as well
|
||||
result = toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(targetManagement.getByControllerID(
|
||||
groupB.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||
|
||||
// toggle A+B -> both unassigned
|
||||
result = toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssignedEntity()).isEmpty();
|
||||
assertThat(result.getUnassigned()).isEqualTo(40);
|
||||
assertThat(result.getUnassignedEntity()).containsAll(targetManagement.getByControllerID(
|
||||
concat(groupB, groupA).stream().map(Target::getControllerId).collect(Collectors.toList())));
|
||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
private final <T> Collection<T> concat(final Collection<T>... targets) {
|
||||
final List<T> result = new ArrayList<>();
|
||||
Arrays.asList(targets).forEach(result::addAll);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that all tags are retrieved through repository.")
|
||||
public void findAllTargetTags() {
|
||||
final List<JpaTargetTag> tags = createTargetsWithTags();
|
||||
|
||||
assertThat(targetTagRepository.findAll()).isEqualTo(targetTagRepository.findAll()).isEqualTo(tags)
|
||||
.as("Wrong tag size").hasSize(20);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a created tag is persisted in the repository as defined.")
|
||||
public void createTargetTag() {
|
||||
final Tag tag = targetTagManagement
|
||||
.create(entityFactory.tag().create().name("kai1").description("kai2").colour("colour"));
|
||||
|
||||
assertThat(targetTagRepository.findByNameEquals("kai1").get().getDescription()).as("wrong tag ed")
|
||||
.isEqualTo("kai2");
|
||||
assertThat(targetTagManagement.getByName("kai1").get().getColour()).as("wrong tag found")
|
||||
.isEqualTo("colour");
|
||||
assertThat(targetTagManagement.get(tag.getId()).get().getColour()).as("wrong tag found")
|
||||
.isEqualTo("colour");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a deleted tag is removed from the repository as defined.")
|
||||
public void deleteTargetTags() {
|
||||
|
||||
// create test data
|
||||
final Iterable<JpaTargetTag> tags = createTargetsWithTags();
|
||||
final TargetTag toDelete = tags.iterator().next();
|
||||
|
||||
for (final Target target : targetRepository.findAll()) {
|
||||
assertThat(targetTagManagement.findByTarget(PAGE, target.getControllerId()).getContent())
|
||||
.contains(toDelete);
|
||||
}
|
||||
|
||||
// delete
|
||||
targetTagManagement.delete(toDelete.getName());
|
||||
|
||||
// check
|
||||
for (final Target target : targetRepository.findAll()) {
|
||||
assertThat(targetTagManagement.findByTarget(PAGE, target.getControllerId()).getContent())
|
||||
.doesNotContain(toDelete);
|
||||
}
|
||||
assertThat(targetTagRepository.findOne(toDelete.getId())).as("No tag should be found").isNull();
|
||||
assertThat(targetTagRepository.findAll()).as("Wrong target tag size").hasSize(19);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the name update of a target tag.")
|
||||
public void updateTargetTag() {
|
||||
final List<JpaTargetTag> tags = createTargetsWithTags();
|
||||
|
||||
// change data
|
||||
final TargetTag savedAssigned = tags.iterator().next();
|
||||
|
||||
// persist
|
||||
targetTagManagement.update(entityFactory.tag().update(savedAssigned.getId()).name("test123"));
|
||||
|
||||
// check data
|
||||
assertThat(targetTagRepository.findAll()).as("Wrong target tag size").hasSize(tags.size());
|
||||
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getName()).as("wrong target tag is saved")
|
||||
.isEqualTo("test123");
|
||||
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getOptLockRevision())
|
||||
.as("wrong target tag is saved").isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
|
||||
public void failedDuplicateTargetTagNameException() {
|
||||
targetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
|
||||
try {
|
||||
targetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
fail("should not have worked as tag already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
|
||||
public void failedDuplicateTargetTagNameExceptionAfterUpdate() {
|
||||
targetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
final TargetTag tag = targetTagManagement.create(entityFactory.tag().create().name("B"));
|
||||
|
||||
try {
|
||||
targetTagManagement.update(entityFactory.tag().update(tag.getId()).name("A"));
|
||||
fail("should not have worked as tag already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private List<JpaTargetTag> createTargetsWithTags() {
|
||||
final List<Target> targets = testdataFactory.createTargets(20);
|
||||
final Iterable<TargetTag> tags = testdataFactory.createTargetTags(20, "");
|
||||
|
||||
tags.forEach(tag -> toggleTagAssignment(targets, tag));
|
||||
|
||||
return targetTagRepository.findAll();
|
||||
}
|
||||
}
|
||||
@@ -49,8 +49,8 @@ public class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// target filter query that matches all targets
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name("filterA").query("name==*"));
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(targetFilterQuery.getId(), setA.getId());
|
||||
.create(entityFactory.targetFilterQuery().create().name("filterA").query("name==*"));
|
||||
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(), setA.getId());
|
||||
|
||||
final String targetDsAIdPref = "targ";
|
||||
final List<Target> targets = testdataFactory.createTargets(100, targetDsAIdPref,
|
||||
@@ -72,7 +72,7 @@ public class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
|
||||
verifyThatTargetsHaveDistributionSetAssignment(setB, targets.subList(10, 20), targetsCount);
|
||||
|
||||
// Count the number of targets that will be assigned with setA
|
||||
assertThat(targetManagement.countTargetsByTargetFilterQueryAndNonDS(setA.getId(), targetFilterQuery.getQuery()))
|
||||
assertThat(targetManagement.countByRsqlAndNonDS(setA.getId(), targetFilterQuery.getQuery()))
|
||||
.isEqualTo(90);
|
||||
|
||||
// Run the check
|
||||
@@ -90,7 +90,7 @@ public class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
|
||||
public void checkAutoAssignWithFailures() {
|
||||
|
||||
// incomplete distribution set that will be assigned
|
||||
final DistributionSet setF = distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
final DistributionSet setF = distributionSetManagement.create(entityFactory.distributionSet()
|
||||
.create().name("dsA").version("1").type(testdataFactory.findOrCreateDefaultTestDsType()));
|
||||
final DistributionSet setA = testdataFactory.createDistributionSet("dsA");
|
||||
final DistributionSet setB = testdataFactory.createDistributionSet("dsB");
|
||||
@@ -100,14 +100,14 @@ public class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// target filter query that matches first bunch of targets, that should
|
||||
// fail
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(
|
||||
targetFilterQueryManagement.createTargetFilterQuery(entityFactory.targetFilterQuery().create()
|
||||
targetFilterQueryManagement.updateAutoAssignDS(
|
||||
targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create()
|
||||
.name("filterA").query("id==" + targetDsFIdPref + "*")).getId(),
|
||||
setF.getId());
|
||||
|
||||
// target filter query that matches failed bunch of targets
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(
|
||||
targetFilterQueryManagement.createTargetFilterQuery(entityFactory.targetFilterQuery().create()
|
||||
targetFilterQueryManagement.updateAutoAssignDS(
|
||||
targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create()
|
||||
.name("filterB").query("id==" + targetDsAIdPref + "*")).getId(),
|
||||
setA.getId());
|
||||
|
||||
@@ -145,7 +145,7 @@ public class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
|
||||
final int count) {
|
||||
final List<Long> targetIds = targets.stream().map(Target::getId).collect(Collectors.toList());
|
||||
|
||||
final Slice<Target> targetsAll = targetManagement.findTargetsAll(PAGE);
|
||||
final Slice<Target> targetsAll = targetManagement.findAll(PAGE);
|
||||
assertThat(targetsAll).as("Count of targets").hasSize(count);
|
||||
|
||||
for (final Target target : targetsAll) {
|
||||
|
||||
@@ -69,8 +69,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Verifies that the target update event is published when a target has been updated")
|
||||
public void targetUpdateEventIsPublished() throws InterruptedException {
|
||||
final Target createdTarget = testdataFactory.createTarget("12345");
|
||||
targetManagement
|
||||
.updateTarget(entityFactory.target().update(createdTarget.getControllerId()).name("updateName"));
|
||||
targetManagement.update(entityFactory.target().update(createdTarget.getControllerId()).name("updateName"));
|
||||
|
||||
final TargetUpdatedEvent targetUpdatedEvent = eventListener.waitForEvent(TargetUpdatedEvent.class);
|
||||
assertThat(targetUpdatedEvent).isNotNull();
|
||||
@@ -82,7 +81,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
public void targetDeletedEventIsPublished() throws InterruptedException {
|
||||
final Target createdTarget = testdataFactory.createTarget("12345");
|
||||
|
||||
targetManagement.deleteTarget("12345");
|
||||
targetManagement.deleteByControllerID("12345");
|
||||
|
||||
final TargetDeletedEvent targetDeletedEvent = eventListener.waitForEvent(TargetDeletedEvent.class);
|
||||
assertThat(targetDeletedEvent).isNotNull();
|
||||
@@ -104,7 +103,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
final Rollout createdRollout = testdataFactory.createRolloutByVariables(rolloutName, "desc", amountGroups,
|
||||
"controllerId==" + targetPrefixName + "-*", distributionSet, successCondition, errorCondition);
|
||||
|
||||
rolloutManagement.deleteRollout(createdRollout.getId());
|
||||
rolloutManagement.delete(createdRollout.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
final RolloutDeletedEvent rolloutDeletedEvent = eventListener.waitForEvent(RolloutDeletedEvent.class);
|
||||
@@ -128,7 +127,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
public void distributionSetDeletedEventIsPublished() throws InterruptedException {
|
||||
final DistributionSet createDistributionSet = testdataFactory.createDistributionSet();
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(createDistributionSet.getId());
|
||||
distributionSetManagement.delete(createDistributionSet.getId());
|
||||
|
||||
final DistributionSetDeletedEvent dsDeletedEvent = eventListener
|
||||
.waitForEvent(DistributionSetDeletedEvent.class);
|
||||
@@ -152,7 +151,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
public void softwareModuleUpdateEventIsPublished() throws InterruptedException {
|
||||
final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp();
|
||||
softwareModuleManagement
|
||||
.updateSoftwareModule(entityFactory.softwareModule().update(softwareModule.getId()).description("New"));
|
||||
.update(entityFactory.softwareModule().update(softwareModule.getId()).description("New"));
|
||||
|
||||
final SoftwareModuleUpdatedEvent softwareModuleUpdatedEvent = eventListener
|
||||
.waitForEvent(SoftwareModuleUpdatedEvent.class);
|
||||
@@ -164,7 +163,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Verifies that the software module deleted event is published when a software module has been deleted")
|
||||
public void softwareModuleDeletedEventIsPublished() throws InterruptedException {
|
||||
final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp();
|
||||
softwareModuleManagement.deleteSoftwareModule(softwareModule.getId());
|
||||
softwareModuleManagement.delete(softwareModule.getId());
|
||||
|
||||
final SoftwareModuleDeletedEvent softwareModuleDeletedEvent = eventListener
|
||||
.waitForEvent(SoftwareModuleDeletedEvent.class);
|
||||
|
||||
@@ -54,8 +54,7 @@ public class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final Target targetToBeCreated = testdataFactory.createTarget("targetToBeCreated");
|
||||
|
||||
final Target loadedTarget = targetManagement.findTargetByControllerID(targetToBeCreated.getControllerId())
|
||||
.get();
|
||||
final Target loadedTarget = targetManagement.getByControllerID(targetToBeCreated.getControllerId()).get();
|
||||
assertThat(postLoadEntityListener.getEntity()).isNotNull();
|
||||
assertThat(postLoadEntityListener.getEntity()).isEqualTo(loadedTarget);
|
||||
}
|
||||
@@ -95,7 +94,7 @@ public class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest {
|
||||
Target updateTarget = addListenerAndCreateTarget(entityInterceptor, "targetToBeCreated");
|
||||
|
||||
updateTarget = targetManagement
|
||||
.updateTarget(entityFactory.target().update(updateTarget.getControllerId()).name("New"));
|
||||
.update(entityFactory.target().update(updateTarget.getControllerId()).name("New"));
|
||||
|
||||
assertThat(entityInterceptor.getEntity()).isNotNull();
|
||||
assertThat(entityInterceptor.getEntity()).isEqualTo(updateTarget);
|
||||
@@ -104,9 +103,9 @@ public class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest {
|
||||
private void executeDeleteAndAssertCallbackResult(final AbstractEntityListener entityInterceptor) {
|
||||
EntityInterceptorHolder.getInstance().getEntityInterceptors().add(entityInterceptor);
|
||||
final SoftwareModuleType type = softwareModuleTypeManagement
|
||||
.createSoftwareModuleType(entityFactory.softwareModuleType().create().name("test").key("test"));
|
||||
.create(entityFactory.softwareModuleType().create().name("test").key("test"));
|
||||
|
||||
softwareModuleTypeManagement.deleteSoftwareModuleType(type.getId());
|
||||
softwareModuleTypeManagement.delete(type.getId());
|
||||
assertThat(entityInterceptor.getEntity()).isNotNull();
|
||||
assertThat(entityInterceptor.getEntity()).isEqualTo(type);
|
||||
}
|
||||
|
||||
@@ -56,11 +56,11 @@ public class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Verfies that updated entities are not equal.")
|
||||
public void changedEntitiesAreNotEqual() {
|
||||
final SoftwareModuleType type = softwareModuleTypeManagement
|
||||
.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("test").name("test"));
|
||||
.create(entityFactory.softwareModuleType().create().key("test").name("test"));
|
||||
assertThat(type).as("persited entity is not equal to regular object")
|
||||
.isNotEqualTo(entityFactory.softwareModuleType().create().key("test").name("test").build());
|
||||
|
||||
final SoftwareModuleType updated = softwareModuleTypeManagement.updateSoftwareModuleType(
|
||||
final SoftwareModuleType updated = softwareModuleTypeManagement.update(
|
||||
entityFactory.softwareModuleType().update(type.getId()).description("another"));
|
||||
assertThat(type).as("Changed entity is not equal to the previous version").isNotEqualTo(updated);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Verify that no proxy of the entity manager has an influence on the equals or hashcode result.")
|
||||
public void managedEntityIsEqualToUnamangedObjectWithSameKey() {
|
||||
final SoftwareModuleType type = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
final SoftwareModuleType type = softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("test").name("test").description("test"));
|
||||
|
||||
final JpaSoftwareModuleType mock = new JpaSoftwareModuleType("test", "test", "test", 1);
|
||||
|
||||
@@ -40,7 +40,7 @@ public class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
|
||||
public void setupBeforeTest() {
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("daA");
|
||||
target = (JpaTarget) targetManagement
|
||||
.createTarget(entityFactory.target().create().controllerId("targetId123").description("targetId123"));
|
||||
.create(entityFactory.target().create().controllerId("targetId123").description("targetId123"));
|
||||
action = new JpaAction();
|
||||
action.setActionType(ActionType.SOFT);
|
||||
action.setDistributionSet(dsA);
|
||||
|
||||
@@ -36,21 +36,19 @@ public class RSQLDistributionSetFieldTest extends AbstractJpaIntegrationTest {
|
||||
public void seuptBeforeTest() {
|
||||
|
||||
DistributionSet ds = testdataFactory.createDistributionSet("DS");
|
||||
ds = distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(ds.getId()).description("DS"));
|
||||
ds = distributionSetManagement.update(entityFactory.distributionSet().update(ds.getId()).description("DS"));
|
||||
createDistributionSetMetadata(ds.getId(), entityFactory.generateMetadata("metaKey", "metaValue"));
|
||||
|
||||
DistributionSet ds2 = testdataFactory.createDistributionSets("NewDS", 3).get(0);
|
||||
|
||||
ds2 = distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(ds2.getId()).description("DS%"));
|
||||
ds2 = distributionSetManagement.update(entityFactory.distributionSet().update(ds2.getId()).description("DS%"));
|
||||
createDistributionSetMetadata(ds2.getId(), entityFactory.generateMetadata("metaKey", "value"));
|
||||
|
||||
final DistributionSetTag targetTag = tagManagement
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("Tag1"));
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("Tag2"));
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("Tag3"));
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("Tag4"));
|
||||
final DistributionSetTag targetTag = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("Tag1"));
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("Tag2"));
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("Tag3"));
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("Tag4"));
|
||||
|
||||
distributionSetManagement.assignTag(Arrays.asList(ds.getId(), ds2.getId()), targetTag.getId());
|
||||
}
|
||||
@@ -138,8 +136,7 @@ public class RSQLDistributionSetFieldTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {
|
||||
final Page<DistributionSet> find = distributionSetManagement.findDistributionSetsAll(rsqlParam,
|
||||
new PageRequest(0, 100), false);
|
||||
final Page<DistributionSet> find = distributionSetManagement.findByRsql(new PageRequest(0, 100), rsqlParam);
|
||||
final long countAll = find.getTotalElements();
|
||||
assertThat(find).as("Founded entity is should not be null").isNotNull();
|
||||
assertThat(countAll).as("Founded entity size is wrong").isEqualTo(excpectedEntity);
|
||||
|
||||
@@ -43,7 +43,7 @@ public class RSQLDistributionSetMetadataFieldsTest extends AbstractJpaIntegratio
|
||||
metadata.add(entityFactory.generateMetadata("" + i, "" + i));
|
||||
}
|
||||
|
||||
distributionSetManagement.createDistributionSetMetadata(distributionSetId, metadata);
|
||||
distributionSetManagement.createMetaData(distributionSetId, metadata);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -67,7 +67,7 @@ public class RSQLDistributionSetMetadataFieldsTest extends AbstractJpaIntegratio
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
|
||||
|
||||
final Page<DistributionSetMetadata> findEnitity = distributionSetManagement
|
||||
.findDistributionSetMetadataByDistributionSetId(distributionSetId, rsqlParam, new PageRequest(0, 100));
|
||||
.findMetaDataByDistributionSetIdAndRsql(new PageRequest(0, 100), distributionSetId, rsqlParam);
|
||||
final long countAllEntities = findEnitity.getTotalElements();
|
||||
assertThat(findEnitity).isNotNull();
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
|
||||
@@ -39,9 +39,9 @@ public class RSQLRolloutGroupFields extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
rollout = createRollout("rollout1", 4, dsA.getId(), "controllerId==rollout*");
|
||||
rollout = rolloutManagement.findRolloutById(rollout.getId()).get();
|
||||
rollout = rolloutManagement.get(rollout.getId()).get();
|
||||
|
||||
this.rolloutGroupId = rolloutGroupManagement.findRolloutGroupsByRolloutId(rollout.getId(), PAGE).getContent()
|
||||
this.rolloutGroupId = rolloutGroupManagement.findByRollout(PAGE, rollout.getId()).getContent()
|
||||
.get(0).getId();
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ public class RSQLRolloutGroupFields extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expcetedTargets) {
|
||||
final Page<RolloutGroup> findTargetPage = rolloutGroupManagement.findRolloutGroupsAll(rollout.getId(),
|
||||
rsqlParam, new PageRequest(0, 100));
|
||||
final Page<RolloutGroup> findTargetPage = rolloutGroupManagement.findByRolloutAndRsql(new PageRequest(0, 100),
|
||||
rollout.getId(), rsqlParam);
|
||||
final long countTargetsAll = findTargetPage.getTotalElements();
|
||||
assertThat(findTargetPage).isNotNull();
|
||||
assertThat(countTargetsAll).isEqualTo(expcetedTargets);
|
||||
@@ -84,9 +84,9 @@ public class RSQLRolloutGroupFields extends AbstractJpaIntegrationTest {
|
||||
|
||||
private Rollout createRollout(final String name, final int amountGroups, final long distributionSetId,
|
||||
final String targetFilterQuery) {
|
||||
return rolloutManagement.createRollout(
|
||||
return rolloutManagement.create(
|
||||
entityFactory.rollout().create()
|
||||
.set(distributionSetManagement.findDistributionSetById(distributionSetId).get()).name(name)
|
||||
.set(distributionSetManagement.get(distributionSetId).get()).name(name)
|
||||
.targetFilterQuery(targetFilterQuery),
|
||||
amountGroups, new RolloutGroupConditionBuilder().withDefaults()
|
||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "100").build());
|
||||
|
||||
@@ -31,21 +31,21 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Before
|
||||
public void setupBeforeTest() {
|
||||
final SoftwareModule ah = softwareModuleManagement.createSoftwareModule(entityFactory.softwareModule().create()
|
||||
final SoftwareModule ah = softwareModuleManagement.create(entityFactory.softwareModule().create()
|
||||
.type(appType).name("agent-hub").version("1.0.1").description("agent-hub"));
|
||||
softwareModuleManagement.createSoftwareModule(entityFactory.softwareModule().create().type(runtimeType)
|
||||
softwareModuleManagement.create(entityFactory.softwareModule().create().type(runtimeType)
|
||||
.name("oracle-jre").version("1.7.2").description("aa"));
|
||||
softwareModuleManagement.createSoftwareModule(
|
||||
softwareModuleManagement.create(
|
||||
entityFactory.softwareModule().create().type(osType).name("poky").version("3.0.2").description("aa"));
|
||||
|
||||
final JpaSoftwareModule ah2 = (JpaSoftwareModule) softwareModuleManagement.createSoftwareModule(entityFactory
|
||||
final JpaSoftwareModule ah2 = (JpaSoftwareModule) softwareModuleManagement.create(entityFactory
|
||||
.softwareModule().create().type(appType).name("agent-hub2").version("1.0.1").description("agent-hub2"));
|
||||
|
||||
final MetaData softwareModuleMetadata = entityFactory.generateMetadata("metaKey", "metaValue");
|
||||
softwareModuleManagement.createSoftwareModuleMetadata(ah.getId(), softwareModuleMetadata);
|
||||
softwareModuleManagement.createMetaData(ah.getId(), softwareModuleMetadata);
|
||||
|
||||
final MetaData softwareModuleMetadata2 = entityFactory.generateMetadata("metaKey", "value");
|
||||
softwareModuleManagement.createSoftwareModuleMetadata(ah2.getId(), softwareModuleMetadata2);
|
||||
softwareModuleManagement.createMetaData(ah2.getId(), softwareModuleMetadata2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -105,8 +105,8 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {
|
||||
final Page<SoftwareModule> find = softwareModuleManagement.findSoftwareModulesByPredicate(rsqlParam,
|
||||
new PageRequest(0, 100));
|
||||
final Page<SoftwareModule> find = softwareModuleManagement.findByRsql(new PageRequest(0, 100),
|
||||
rsqlParam);
|
||||
final long countAll = find.getTotalElements();
|
||||
assertThat(find).isNotNull();
|
||||
assertThat(countAll).isEqualTo(excpectedEntity);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractJpaIntegration
|
||||
metadata.add(entityFactory.generateMetadata("" + i, "" + i));
|
||||
}
|
||||
|
||||
softwareModuleManagement.createSoftwareModuleMetadata(softwareModule.getId(), metadata);
|
||||
softwareModuleManagement.createMetaData(softwareModule.getId(), metadata);
|
||||
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractJpaIntegration
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
|
||||
|
||||
final Page<SoftwareModuleMetadata> findEnitity = softwareModuleManagement
|
||||
.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, rsqlParam, new PageRequest(0, 100));
|
||||
.findMetaDataByRsql(new PageRequest(0, 100), softwareModuleId, rsqlParam);
|
||||
final long countAllEntities = findEnitity.getTotalElements();
|
||||
assertThat(findEnitity).isNotNull();
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
|
||||
@@ -60,8 +60,8 @@ public class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {
|
||||
final Page<SoftwareModuleType> find = softwareModuleTypeManagement.findSoftwareModuleTypesAll(rsqlParam,
|
||||
new PageRequest(0, 100));
|
||||
final Page<SoftwareModuleType> find = softwareModuleTypeManagement.findByRsql(new PageRequest(0, 100),
|
||||
rsqlParam);
|
||||
final long countAll = find.getTotalElements();
|
||||
assertThat(find).isNotNull();
|
||||
assertThat(countAll).isEqualTo(excpectedEntity);
|
||||
|
||||
@@ -34,8 +34,8 @@ public class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
final TagCreate targetTag = entityFactory.tag().create().name(Integer.toString(i))
|
||||
.description(Integer.toString(i)).colour(i % 2 == 0 ? "red" : "blue");
|
||||
tagManagement.createTargetTag(targetTag);
|
||||
tagManagement.createDistributionSetTag(targetTag);
|
||||
targetTagManagement.create(targetTag);
|
||||
distributionSetTagManagement.create(targetTag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,8 +101,8 @@ public class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private void assertRSQLQueryDistributionSet(final String rsqlParam, final long expectedEntities) {
|
||||
|
||||
final Page<DistributionSetTag> findEnitity = tagManagement.findAllDistributionSetTags(rsqlParam,
|
||||
new PageRequest(0, 100));
|
||||
final Page<DistributionSetTag> findEnitity = distributionSetTagManagement.findByRsql(new PageRequest(0, 100),
|
||||
rsqlParam);
|
||||
final long countAllEntities = findEnitity.getTotalElements();
|
||||
assertThat(findEnitity).isNotNull();
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
@@ -110,7 +110,7 @@ public class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private void assertRSQLQueryTarget(final String rsqlParam, final long expectedEntities) {
|
||||
|
||||
final Page<TargetTag> findEnitity = tagManagement.findAllTargetTags(rsqlParam, new PageRequest(0, 100));
|
||||
final Page<TargetTag> findEnitity = targetTagManagement.findByRsql(new PageRequest(0, 100), rsqlParam);
|
||||
final long countAllEntities = findEnitity.getTotalElements();
|
||||
assertThat(findEnitity).isNotNull();
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
|
||||
@@ -44,14 +44,14 @@ public class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final Map<String, String> attributes = new HashMap<>();
|
||||
|
||||
target = targetManagement.createTarget(entityFactory.target().create().controllerId("targetId123")
|
||||
target = targetManagement.create(entityFactory.target().create().controllerId("targetId123")
|
||||
.name("targetName123").description("targetDesc123"));
|
||||
attributes.put("revision", "1.1");
|
||||
target = controllerManagement.updateControllerAttributes(target.getControllerId(), attributes);
|
||||
target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(target.getControllerId(), LOCALHOST);
|
||||
|
||||
target2 = targetManagement
|
||||
.createTarget(entityFactory.target().create().controllerId("targetId1234").description("targetId1234"));
|
||||
.create(entityFactory.target().create().controllerId("targetId1234").description("targetId1234"));
|
||||
attributes.put("revision", "1.2");
|
||||
Thread.sleep(1);
|
||||
target2 = controllerManagement.updateControllerAttributes(target2.getControllerId(), attributes);
|
||||
@@ -60,10 +60,10 @@ public class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createTarget("targetId1235");
|
||||
testdataFactory.createTarget("targetId1236");
|
||||
|
||||
final TargetTag targetTag = tagManagement.createTargetTag(entityFactory.tag().create().name("Tag1"));
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("Tag2"));
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("Tag3"));
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("Tag4"));
|
||||
final TargetTag targetTag = targetTagManagement.create(entityFactory.tag().create().name("Tag1"));
|
||||
targetTagManagement.create(entityFactory.tag().create().name("Tag2"));
|
||||
targetTagManagement.create(entityFactory.tag().create().name("Tag3"));
|
||||
targetTagManagement.create(entityFactory.tag().create().name("Tag4"));
|
||||
|
||||
targetManagement.assignTag(Arrays.asList(target.getControllerId(), target2.getControllerId()),
|
||||
targetTag.getId());
|
||||
@@ -182,7 +182,7 @@ public class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expcetedTargets) {
|
||||
final Page<Target> findTargetPage = targetManagement.findTargetsAll(rsqlParam, PAGE);
|
||||
final Page<Target> findTargetPage = targetManagement.findByRsql(PAGE, rsqlParam);
|
||||
final long countTargetsAll = findTargetPage.getTotalElements();
|
||||
assertThat(findTargetPage).isNotNull();
|
||||
assertThat(countTargetsAll).isEqualTo(expcetedTargets);
|
||||
|
||||
@@ -72,7 +72,7 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
createTargetForTenant(controllerAnotherTenant, anotherTenant);
|
||||
|
||||
// find all targets for current tenant "mytenant"
|
||||
final Slice<Target> findTargetsAll = targetManagement.findTargetsAll(PAGE);
|
||||
final Slice<Target> findTargetsAll = targetManagement.findAll(PAGE);
|
||||
// no target has been created for "mytenant"
|
||||
assertThat(findTargetsAll).hasSize(0);
|
||||
|
||||
@@ -105,9 +105,9 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// logged in tenant mytenant - check if tenant default data is
|
||||
// autogenerated
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypesAll(PAGE)).isEmpty();
|
||||
assertThat(distributionSetTypeManagement.findAll(PAGE)).isEmpty();
|
||||
assertThat(systemManagement.getTenantMetadata().getTenant().toUpperCase()).isEqualTo("mytenant".toUpperCase());
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypesAll(PAGE)).isNotEmpty();
|
||||
assertThat(distributionSetTypeManagement.findAll(PAGE)).isNotEmpty();
|
||||
|
||||
// check that the cache is not getting in the way, i.e. "bumlux" results
|
||||
// in bumlux and not
|
||||
@@ -128,7 +128,7 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// ensure target cannot be deleted by 'mytenant'
|
||||
try {
|
||||
targetManagement.deleteTargets(Arrays.asList(createTargetForTenant.getId()));
|
||||
targetManagement.delete(Arrays.asList(createTargetForTenant.getId()));
|
||||
fail("mytenant should not have been able to delete target of anotherTenant");
|
||||
} catch (final EntityNotFoundException ex) {
|
||||
// ok
|
||||
@@ -173,12 +173,12 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private Slice<Target> findTargetsForTenant(final String tenant) throws Exception {
|
||||
return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant),
|
||||
() -> targetManagement.findTargetsAll(PAGE));
|
||||
() -> targetManagement.findAll(PAGE));
|
||||
}
|
||||
|
||||
private void deleteTargetsForTenant(final String tenant, final Collection<Long> targetIds) throws Exception {
|
||||
securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant), () -> {
|
||||
targetManagement.deleteTargets(targetIds);
|
||||
targetManagement.delete(targetIds);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
@@ -190,7 +190,7 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private Page<DistributionSet> findDistributionSetForTenant(final String tenant) throws Exception {
|
||||
return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant),
|
||||
() -> distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true));
|
||||
() -> distributionSetManagement.findByCompleted(PAGE, true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||
import org.eclipse.hawkbit.repository.ControllerManagement;
|
||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.QuotaManagement;
|
||||
@@ -37,9 +38,9 @@ import org.eclipse.hawkbit.repository.RolloutManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
@@ -143,7 +144,10 @@ public abstract class AbstractIntegrationTest {
|
||||
protected TargetFilterQueryManagement targetFilterQueryManagement;
|
||||
|
||||
@Autowired
|
||||
protected TagManagement tagManagement;
|
||||
protected TargetTagManagement targetTagManagement;
|
||||
|
||||
@Autowired
|
||||
protected DistributionSetTagManagement distributionSetTagManagement;
|
||||
|
||||
@Autowired
|
||||
protected DeploymentManagement deploymentManagement;
|
||||
@@ -234,7 +238,7 @@ public abstract class AbstractIntegrationTest {
|
||||
}
|
||||
|
||||
protected DistributionSetMetadata createDistributionSetMetadata(final Long dsId, final MetaData md) {
|
||||
return distributionSetManagement.createDistributionSetMetadata(dsId, Collections.singletonList(md)).get(0);
|
||||
return distributionSetManagement.createMetaData(dsId, Collections.singletonList(md)).get(0);
|
||||
}
|
||||
|
||||
protected Long getOsModule(final DistributionSet ds) {
|
||||
@@ -267,17 +271,17 @@ public abstract class AbstractIntegrationTest {
|
||||
|
||||
osType = securityRule
|
||||
.runAsPrivileged(() -> testdataFactory.findOrCreateSoftwareModuleType(TestdataFactory.SM_TYPE_OS));
|
||||
osType = securityRule.runAsPrivileged(() -> softwareModuleTypeManagement.updateSoftwareModuleType(
|
||||
osType = securityRule.runAsPrivileged(() -> softwareModuleTypeManagement.update(
|
||||
entityFactory.softwareModuleType().update(osType.getId()).description(description)));
|
||||
|
||||
appType = securityRule.runAsPrivileged(
|
||||
() -> testdataFactory.findOrCreateSoftwareModuleType(TestdataFactory.SM_TYPE_APP, Integer.MAX_VALUE));
|
||||
appType = securityRule.runAsPrivileged(() -> softwareModuleTypeManagement.updateSoftwareModuleType(
|
||||
appType = securityRule.runAsPrivileged(() -> softwareModuleTypeManagement.update(
|
||||
entityFactory.softwareModuleType().update(appType.getId()).description(description)));
|
||||
|
||||
runtimeType = securityRule
|
||||
.runAsPrivileged(() -> testdataFactory.findOrCreateSoftwareModuleType(TestdataFactory.SM_TYPE_RT));
|
||||
runtimeType = securityRule.runAsPrivileged(() -> softwareModuleTypeManagement.updateSoftwareModuleType(
|
||||
runtimeType = securityRule.runAsPrivileged(() -> softwareModuleTypeManagement.update(
|
||||
entityFactory.softwareModuleType().update(runtimeType.getId()).description(description)));
|
||||
|
||||
standardDsType = securityRule.runAsPrivileged(() -> testdataFactory.findOrCreateDefaultTestDsType());
|
||||
|
||||
@@ -27,13 +27,14 @@ import org.eclipse.hawkbit.repository.Constants;
|
||||
import org.eclipse.hawkbit.repository.ControllerManagement;
|
||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.RolloutManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.TargetCreate;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
@@ -135,7 +136,10 @@ public class TestdataFactory {
|
||||
private DeploymentManagement deploymentManagement;
|
||||
|
||||
@Autowired
|
||||
private TagManagement tagManagement;
|
||||
private TargetTagManagement targetTagManagement;
|
||||
|
||||
@Autowired
|
||||
private DistributionSetTagManagement distributionSetTagManagement;
|
||||
|
||||
@Autowired
|
||||
private EntityFactory entityFactory;
|
||||
@@ -262,20 +266,20 @@ public class TestdataFactory {
|
||||
public DistributionSet createDistributionSet(final String prefix, final String version,
|
||||
final boolean isRequiredMigrationStep) {
|
||||
|
||||
final SoftwareModule appMod = softwareModuleManagement.createSoftwareModule(entityFactory.softwareModule()
|
||||
final SoftwareModule appMod = softwareModuleManagement.create(entityFactory.softwareModule()
|
||||
.create().type(findOrCreateSoftwareModuleType(SM_TYPE_APP, Integer.MAX_VALUE))
|
||||
.name(prefix + SM_TYPE_APP).version(version + "." + new SecureRandom().nextInt(100))
|
||||
.description(LOREM.words(20)).vendor(prefix + " vendor Limited, California"));
|
||||
final SoftwareModule runtimeMod = softwareModuleManagement.createSoftwareModule(
|
||||
final SoftwareModule runtimeMod = softwareModuleManagement.create(
|
||||
entityFactory.softwareModule().create().type(findOrCreateSoftwareModuleType(SM_TYPE_RT))
|
||||
.name(prefix + "app runtime").version(version + "." + new SecureRandom().nextInt(100))
|
||||
.description(LOREM.words(20)).vendor(prefix + " vendor GmbH, Stuttgart, Germany"));
|
||||
final SoftwareModule osMod = softwareModuleManagement.createSoftwareModule(
|
||||
final SoftwareModule osMod = softwareModuleManagement.create(
|
||||
entityFactory.softwareModule().create().type(findOrCreateSoftwareModuleType(SM_TYPE_OS))
|
||||
.name(prefix + " Firmware").version(version + "." + new SecureRandom().nextInt(100))
|
||||
.description(LOREM.words(20)).vendor(prefix + " vendor Limited Inc, California"));
|
||||
|
||||
return distributionSetManagement.createDistributionSet(
|
||||
return distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name(prefix != null && prefix.length() > 0 ? prefix : "DS")
|
||||
.version(version).description(LOREM.words(10)).type(findOrCreateDefaultTestDsType())
|
||||
.modules(Arrays.asList(osMod.getId(), runtimeMod.getId(), appMod.getId()))
|
||||
@@ -302,7 +306,7 @@ public class TestdataFactory {
|
||||
public DistributionSet createDistributionSet(final String prefix, final String version,
|
||||
final boolean isRequiredMigrationStep, final Collection<SoftwareModule> modules) {
|
||||
|
||||
return distributionSetManagement.createDistributionSet(
|
||||
return distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name(prefix != null && prefix.length() > 0 ? prefix : "DS")
|
||||
.version(version).description(LOREM.words(10)).type(findOrCreateDefaultTestDsType())
|
||||
.modules(modules.stream().map(SoftwareModule::getId).collect(Collectors.toList()))
|
||||
@@ -333,7 +337,7 @@ public class TestdataFactory {
|
||||
|
||||
tags.forEach(tag -> distributionSetManagement.toggleTagAssignment(Arrays.asList(set.getId()), tag.getName()));
|
||||
|
||||
return distributionSetManagement.findDistributionSetById(set.getId()).get();
|
||||
return distributionSetManagement.get(set.getId()).get();
|
||||
|
||||
}
|
||||
|
||||
@@ -366,7 +370,7 @@ public class TestdataFactory {
|
||||
|
||||
final List<DistributionSet> sets = Lists.newArrayListWithExpectedSize(number);
|
||||
for (int i = 0; i < number; i++) {
|
||||
sets.add(distributionSetManagement.createDistributionSet(
|
||||
sets.add(distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name("DS" + i).version(DEFAULT_VERSION + "." + i)
|
||||
.description(LOREM.words(10)).type(findOrCreateDefaultTestDsType())));
|
||||
}
|
||||
@@ -413,7 +417,7 @@ public class TestdataFactory {
|
||||
*/
|
||||
public DistributionSet createDistributionSetWithNoSoftwareModules(final String name, final String version) {
|
||||
|
||||
return distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create().name(name)
|
||||
return distributionSetManagement.create(entityFactory.distributionSet().create().name(name)
|
||||
.version(version).description(DEFAULT_DESCRIPTION).type(findOrCreateDefaultTestDsType()));
|
||||
}
|
||||
|
||||
@@ -430,7 +434,7 @@ public class TestdataFactory {
|
||||
final List<Artifact> artifacts = new ArrayList<>();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
final InputStream stubInputStream = IOUtils.toInputStream("some test data" + i, Charset.forName("UTF-8"));
|
||||
artifacts.add(artifactManagement.createArtifact(stubInputStream, moduleId, "filename" + i, false));
|
||||
artifacts.add(artifactManagement.create(stubInputStream, moduleId, "filename" + i, false));
|
||||
|
||||
}
|
||||
|
||||
@@ -522,7 +526,7 @@ public class TestdataFactory {
|
||||
* @return persisted {@link SoftwareModule}.
|
||||
*/
|
||||
public SoftwareModule createSoftwareModule(final String typeKey, final String prefix) {
|
||||
return softwareModuleManagement.createSoftwareModule(entityFactory.softwareModule().create()
|
||||
return softwareModuleManagement.create(entityFactory.softwareModule().create()
|
||||
.type(findOrCreateSoftwareModuleType(typeKey)).name(prefix + typeKey).version(prefix + DEFAULT_VERSION)
|
||||
.description(LOREM.words(10)).vendor(DEFAULT_VENDOR));
|
||||
}
|
||||
@@ -540,7 +544,7 @@ public class TestdataFactory {
|
||||
* @return persisted {@link Target}
|
||||
*/
|
||||
public Target createTarget(final String controllerId) {
|
||||
final Target target = targetManagement.createTarget(entityFactory.target().create().controllerId(controllerId));
|
||||
final Target target = targetManagement.create(entityFactory.target().create().controllerId(controllerId));
|
||||
assertThat(target.getCreatedBy()).isNotNull();
|
||||
assertThat(target.getCreatedAt()).isNotNull();
|
||||
assertThat(target.getLastModifiedBy()).isNotNull();
|
||||
@@ -566,14 +570,14 @@ public class TestdataFactory {
|
||||
*/
|
||||
public DistributionSet createUpdatedDistributionSet() {
|
||||
DistributionSet set = createDistributionSet("");
|
||||
set = distributionSetManagement.updateDistributionSet(
|
||||
set = distributionSetManagement.update(
|
||||
entityFactory.distributionSet().update(set.getId()).description("Updated " + DEFAULT_DESCRIPTION));
|
||||
|
||||
set.getModules().forEach(module -> softwareModuleManagement.updateSoftwareModule(
|
||||
set.getModules().forEach(module -> softwareModuleManagement.update(
|
||||
entityFactory.softwareModule().update(module.getId()).description("Updated " + DEFAULT_DESCRIPTION)));
|
||||
|
||||
// load also lazy stuff
|
||||
return distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).get();
|
||||
return distributionSetManagement.getWithDetails(set.getId()).get();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -604,8 +608,8 @@ public class TestdataFactory {
|
||||
* @return persisted {@link DistributionSetType}
|
||||
*/
|
||||
public DistributionSetType findOrCreateDistributionSetType(final String dsTypeKey, final String dsTypeName) {
|
||||
return distributionSetTypeManagement.findDistributionSetTypeByKey(dsTypeKey).orElseGet(
|
||||
() -> distributionSetTypeManagement.createDistributionSetType(entityFactory.distributionSetType()
|
||||
return distributionSetTypeManagement.getByKey(dsTypeKey).orElseGet(
|
||||
() -> distributionSetTypeManagement.create(entityFactory.distributionSetType()
|
||||
.create().key(dsTypeKey).name(dsTypeName).description(LOREM.words(10)).colour("black")));
|
||||
}
|
||||
|
||||
@@ -626,8 +630,8 @@ public class TestdataFactory {
|
||||
*/
|
||||
public DistributionSetType findOrCreateDistributionSetType(final String dsTypeKey, final String dsTypeName,
|
||||
final Collection<SoftwareModuleType> mandatory, final Collection<SoftwareModuleType> optional) {
|
||||
return distributionSetTypeManagement.findDistributionSetTypeByKey(dsTypeKey)
|
||||
.orElseGet(() -> distributionSetTypeManagement.createDistributionSetType(entityFactory
|
||||
return distributionSetTypeManagement.getByKey(dsTypeKey)
|
||||
.orElseGet(() -> distributionSetTypeManagement.create(entityFactory
|
||||
.distributionSetType().create().key(dsTypeKey).name(dsTypeName).description(LOREM.words(10))
|
||||
.colour("black")
|
||||
.optional(optional.stream().map(SoftwareModuleType::getId).collect(Collectors.toList()))
|
||||
@@ -660,8 +664,8 @@ public class TestdataFactory {
|
||||
* @return persisted {@link SoftwareModuleType}
|
||||
*/
|
||||
public SoftwareModuleType findOrCreateSoftwareModuleType(final String key, final int maxAssignments) {
|
||||
return softwareModuleTypeManagement.findSoftwareModuleTypeByKey(key).orElseGet(
|
||||
() -> softwareModuleTypeManagement.createSoftwareModuleType(entityFactory.softwareModuleType().create()
|
||||
return softwareModuleTypeManagement.getByKey(key).orElseGet(
|
||||
() -> softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create()
|
||||
.key(key).name(key).description(LOREM.words(10)).maxAssignments(maxAssignments)));
|
||||
}
|
||||
|
||||
@@ -681,7 +685,7 @@ public class TestdataFactory {
|
||||
*/
|
||||
public DistributionSet createDistributionSet(final String name, final String version,
|
||||
final DistributionSetType type, final Collection<SoftwareModule> modules) {
|
||||
return distributionSetManagement.createDistributionSet(
|
||||
return distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name(name).version(version).description(LOREM.words(10))
|
||||
.type(type).modules(modules.stream().map(SoftwareModule::getId).collect(Collectors.toList())));
|
||||
}
|
||||
@@ -759,7 +763,7 @@ public class TestdataFactory {
|
||||
targets.add(entityFactory.target().create().controllerId(DEFAULT_CONTROLLER_ID + i));
|
||||
}
|
||||
|
||||
return targetManagement.createTargets(targets);
|
||||
return targetManagement.create(targets);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -825,7 +829,7 @@ public class TestdataFactory {
|
||||
public List<Target> createTargets(final int numberOfTargets, final String controllerIdPrefix,
|
||||
final String descriptionPrefix) {
|
||||
|
||||
return targetManagement.createTargets(IntStream.range(0, numberOfTargets)
|
||||
return targetManagement.create(IntStream.range(0, numberOfTargets)
|
||||
.mapToObj(i -> entityFactory.target().create()
|
||||
.controllerId(String.format("%s-%05d", controllerIdPrefix, i))
|
||||
.description(descriptionPrefix + i))
|
||||
@@ -848,7 +852,7 @@ public class TestdataFactory {
|
||||
public List<Target> createTargets(final int numberOfTargets, final String controllerIdPrefix,
|
||||
final String descriptionPrefix, final Long lastTargetQuery) {
|
||||
|
||||
return targetManagement.createTargets(IntStream.range(0, numberOfTargets)
|
||||
return targetManagement.create(IntStream.range(0, numberOfTargets)
|
||||
.mapToObj(i -> entityFactory.target().create().controllerId(controllerIdPrefix + i)
|
||||
.description(descriptionPrefix + i).lastTargetQuery(lastTargetQuery))
|
||||
.collect(Collectors.toList()));
|
||||
@@ -871,7 +875,7 @@ public class TestdataFactory {
|
||||
.colour(String.valueOf(i)));
|
||||
}
|
||||
|
||||
return tagManagement.createTargetTags(result);
|
||||
return targetTagManagement.create(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -890,7 +894,7 @@ public class TestdataFactory {
|
||||
entityFactory.tag().create().name("tag" + i).description("tagdesc" + i).colour(String.valueOf(i)));
|
||||
}
|
||||
|
||||
return tagManagement.createDistributionSetTags(result);
|
||||
return distributionSetTagManagement.create(result);
|
||||
}
|
||||
|
||||
private Action sendUpdateActionStatusToTarget(final Status status, final Action updActA,
|
||||
@@ -971,14 +975,14 @@ public class TestdataFactory {
|
||||
.errorCondition(RolloutGroupErrorCondition.THRESHOLD, errorCondition)
|
||||
.errorAction(RolloutGroupErrorAction.PAUSE, null).build();
|
||||
|
||||
final Rollout rollout = rolloutManagement.createRollout(entityFactory.rollout().create().name(rolloutName)
|
||||
final Rollout rollout = rolloutManagement.create(entityFactory.rollout().create().name(rolloutName)
|
||||
.description(rolloutDescription).targetFilterQuery(filterQuery).set(distributionSet), groupSize,
|
||||
conditions);
|
||||
|
||||
// Run here, because Scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
return rolloutManagement.findRolloutById(rollout.getId()).get();
|
||||
return rolloutManagement.get(rollout.getId()).get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user