Complete repo exception tests (#452)

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-03-23 18:24:58 +01:00
committed by GitHub
parent c4d3ff5166
commit 081c3cccbf
26 changed files with 740 additions and 300 deletions

View File

@@ -17,6 +17,7 @@ import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.IncompleteDistributionSetException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
import org.eclipse.hawkbit.repository.model.Action;
@@ -58,12 +59,13 @@ public interface DeploymentManagement {
* the IDs of the target to assign the distribution set
* @return the assignment result
*
* @throw IncompleteDistributionSetException if mandatory
* {@link SoftwareModuleType} are not assigned as define by the
* {@link DistributionSetType}.
* @throws IncompleteDistributionSetException
* if mandatory {@link SoftwareModuleType} are not assigned as
* define by the {@link DistributionSetType}.
*
* @throw {@link EntityNotFoundException} if either provided
* {@link DistributionSet} or {@link Target}s do not exist
* @throws EntityNotFoundException
* if either provided {@link DistributionSet} or {@link Target}s
* do not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID, @NotNull ActionType actionType,
@@ -79,12 +81,13 @@ public interface DeploymentManagement {
* a list of all targets and their action type
* @return the assignment result
*
* @throw IncompleteDistributionSetException if mandatory
* {@link SoftwareModuleType} are not assigned as define by the
* {@link DistributionSetType}.
* @throws IncompleteDistributionSetException
* if mandatory {@link SoftwareModuleType} are not assigned as
* define by the {@link DistributionSetType}.
*
* @throw {@link EntityNotFoundException} if either provided
* {@link DistributionSet} or {@link Target}s do not exist
* @throws EntityNotFoundException
* if either provided {@link DistributionSet} or {@link Target}s
* do not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID,
@@ -102,12 +105,13 @@ public interface DeploymentManagement {
* an optional message for the action status
* @return the assignment result
*
* @throw IncompleteDistributionSetException if mandatory
* {@link SoftwareModuleType} are not assigned as define by the
* {@link DistributionSetType}.
* @throws IncompleteDistributionSetException
* if mandatory {@link SoftwareModuleType} are not assigned as
* define by the {@link DistributionSetType}.
*
* @throw {@link EntityNotFoundException} if either provided
* {@link DistributionSet} or {@link Target}s do not exist
* @throws EntityNotFoundException
* if either provided {@link DistributionSet} or {@link Target}s
* do not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID,
@@ -210,6 +214,9 @@ public interface DeploymentManagement {
* in the result
* @return a list of {@link Action} which are assigned to a specific
* {@link DistributionSet}
*
* @throws EntityNotFoundException
* if distribution set with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<Action> findActionsByDistributionSet(@NotNull Pageable pageable, @NotNull Long distributionSetId);
@@ -290,6 +297,9 @@ public interface DeploymentManagement {
* the target associated with the actions
* @return a list of actions associated with the given target ordered by
* action ID
*
* @throws EntityNotFoundException
* if target with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<ActionWithStatusCount> findActionsWithStatusCountByTargetOrderByIdDesc(@NotNull String controllerId);

View File

@@ -255,7 +255,7 @@ public interface DistributionSetManagement {
* if given set does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
void deleteDistributionSetMetadata(@NotNull final Long dsId, @NotNull final String key);
void deleteDistributionSetMetadata(@NotNull final Long dsId, @NotEmpty final String key);
/**
* Deletes or mark as delete in case the type is in use.
@@ -517,7 +517,10 @@ public interface DistributionSetManagement {
* of the {@link DistributionSet}
* @param key
* of the meta data element
* @return the found DistributionSetMetadata or {@code null} if not exits
* @return the found DistributionSetMetadata
*
* @throws EntityNotFoundException
* is set with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Optional<DistributionSetMetadata> findDistributionSetMetadata(@NotNull Long setId, @NotEmpty String key);

View File

@@ -310,7 +310,7 @@ public interface RolloutManagement {
* sufficient due the {@link #checkRunningRollouts(long)} will not check
* this rollout anymore.
*
* @param rollout
* @param rolloutId
* the rollout to be paused.
*
* @throws EntityNotFoundException
@@ -321,14 +321,14 @@ public interface RolloutManagement {
*
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
void pauseRollout(@NotNull Long rollout);
void pauseRollout(@NotNull Long rolloutId);
/**
* Resumes a paused rollout. The rollout switches back to
* {@link RolloutStatus#RUNNING} state which is then picked up again by the
* {@link #checkRunningRollouts(long)}.
*
* @param rollout
* @param rolloutId
* the rollout to be resumed
*
* @throws EntityNotFoundException
@@ -338,7 +338,7 @@ public interface RolloutManagement {
* paused rollouts can be resumed.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
void resumeRollout(@NotNull Long rollout);
void resumeRollout(@NotNull Long rolloutId);
/**
* Starts a rollout which has been created. The rollout must be in

View File

@@ -286,6 +286,9 @@ public interface SoftwareManagement {
* @param key
* of the meta data element
* @return the found SoftwareModuleMetadata or {@code null} if not exits
*
* @throws EntityNotFoundException
* is module with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Optional<SoftwareModuleMetadata> findSoftwareModuleMetadata(@NotNull Long moduleId, @NotEmpty String key);
@@ -441,7 +444,7 @@ public interface SoftwareManagement {
* {@link SoftwareModuleType#getName()}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Optional<SoftwareModuleType> findSoftwareModuleTypeByName(@NotNull String name);
Optional<SoftwareModuleType> findSoftwareModuleTypeByName(@NotEmpty String name);
/**
* @param pageable

View File

@@ -52,7 +52,7 @@ public interface TargetManagement {
* @return list of assigned targets
*
* @throws EntityNotFoundException
* if given tagId does not exist
* if given tagId or at least one of the targets do not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
List<Target> assignTag(@NotEmpty Collection<String> controllerIds, @NotNull Long tagId);
@@ -413,7 +413,7 @@ public interface TargetManagement {
* the ID of the {@link DistributionSet}
* @param rsqlParam
* the specification to filter the result
* @param pageable
* @param pageReq
* page parameter
* @return the found {@link Target}s, never {@code null}
*
@@ -428,7 +428,7 @@ public interface TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
Page<Target> findTargetByInstalledDistributionSet(@NotNull Long distributionSetId, @NotNull String rsqlParam,
@NotNull Pageable pageable);
@NotNull Pageable pageReq);
/**
* Retrieves the {@link Target} which have a certain
@@ -547,7 +547,7 @@ public interface TargetManagement {
* yet assigned, they will be. If all of theme have the tag already assigned
* they will be removed instead.
*
* @param targetIds
* @param controllerIds
* to toggle for
* @param tagName
* to toggle
@@ -557,7 +557,7 @@ public interface TargetManagement {
* if tag with given name does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
TargetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<String> targetIds, @NotEmpty String tagName);
TargetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<String> controllerIds, @NotEmpty String tagName);
/**
* Un-assign all {@link Target} from a given {@link TargetTag} .

View File

@@ -102,9 +102,10 @@ public class EntityNotFoundException extends AbstractServerRtException {
* @param found
* collection of the {@link BaseEntity#getId()}s
*/
public EntityNotFoundException(final Class<? extends BaseEntity> type, final Collection<Long> expected,
final Collection<Long> found) {
public EntityNotFoundException(final Class<? extends BaseEntity> type, final Collection<?> expected,
final Collection<?> found) {
this(type.getSimpleName() + "s with given identifiers {" + expected.stream().filter(id -> !found.contains(id))
.map(String::valueOf).collect(Collectors.joining(",")) + "} do not exist.");
}
}