Skip to content

Commit 48d7776

Browse files
authored
Abstract RepositoryManagement test (#2631)
* Abstract RepositoryManagement test * mvn_in * Small management interface cleanup
1 parent 42b0bc0 commit 48d7776

File tree

52 files changed

+1808
-2949
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1808
-2949
lines changed

hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,10 @@ public interface ControllerManagement {
239239
*
240240
* @param actionId to the handle status for
241241
* @param message for the status
242-
* @return the update action in case the status has been changed to {@link Status#RETRIEVED}
243242
* @throws EntityNotFoundException if action with given ID does not exist
244243
*/
245244
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
246-
Action registerRetrieved(long actionId, String message);
245+
void registerRetrieved(long actionId, String message);
247246

248247
/**
249248
* Updates attributes of the controller according to the given {@link UpdateMode}.
@@ -260,8 +259,7 @@ public interface ControllerManagement {
260259
Target updateControllerAttributes(@NotEmpty String controllerId, @NotNull Map<String, String> attributes, UpdateMode mode);
261260

262261
/**
263-
* Finds {@link Target} based on given controller ID returns found Target without details, i.e.
264-
* NO {@link Target#getTags()} and {@link Target#getActions()} possible.
262+
* Finds {@link Target} based on given controller ID returns found Target without details
265263
*
266264
* @param controllerId to look for.
267265
* @return {@link Target} or {@code null} if it does not exist
@@ -271,9 +269,7 @@ public interface ControllerManagement {
271269
Optional<Target> findByControllerId(@NotEmpty String controllerId);
272270

273271
/**
274-
* Finds {@link Target} based on given ID returns found Target without details, i.e.
275-
* NO {@link Target#getTags()} and {@link Target#getActions()}
276-
* possible.
272+
* Finds {@link Target} based on given ID returns found Target without details
277273
*
278274
* @param targetId to look for.
279275
* @return {@link Target} or {@code null} if it does not exist

hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,6 @@ List<DistributionSetAssignmentResult> assignDistributionSets(
242242
@PreAuthorize(SpringEvalExpressions.HAS_READ_REPOSITORY)
243243
Page<ActionStatus> findActionStatusByAction(long actionId, @NotNull Pageable pageable);
244244

245-
/**
246-
* Counts all the {@link ActionStatus} entries of the given {@link Action}.
247-
*
248-
* @param actionId to be filtered on
249-
* @return count of {@link ActionStatus} entries
250-
* @throws EntityNotFoundException if action with given ID does not exist
251-
*/
252-
@PreAuthorize(SpringEvalExpressions.HAS_READ_REPOSITORY)
253-
long countActionStatusByAction(long actionId);
254-
255245
/**
256246
* Retrieves all messages for an {@link ActionStatus}.<p/>
257247
* No entity based access control applied.

hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetInvalidationManagement.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.eclipse.hawkbit.im.authentication.SpringEvalExpressions;
1414
import org.eclipse.hawkbit.repository.model.DistributionSet;
1515
import org.eclipse.hawkbit.repository.model.DistributionSetInvalidation;
16-
import org.eclipse.hawkbit.repository.model.DistributionSetInvalidationCount;
1716
import org.springframework.security.access.prepost.PreAuthorize;
1817

1918
/**

hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagManagement.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
*/
1010
package org.eclipse.hawkbit.repository;
1111

12-
import java.util.Optional;
13-
14-
import jakarta.validation.constraints.NotEmpty;
1512
import jakarta.validation.constraints.NotNull;
1613
import jakarta.validation.constraints.Size;
1714

@@ -20,17 +17,9 @@
2017
import lombok.ToString;
2118
import lombok.experimental.SuperBuilder;
2219
import org.eclipse.hawkbit.im.authentication.SpPermission;
23-
import org.eclipse.hawkbit.im.authentication.SpringEvalExpressions;
24-
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
25-
import org.eclipse.hawkbit.repository.model.DistributionSet;
2620
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
2721
import org.eclipse.hawkbit.repository.model.NamedEntity;
2822
import org.eclipse.hawkbit.repository.model.Tag;
29-
import org.eclipse.hawkbit.repository.model.Target;
30-
import org.eclipse.hawkbit.repository.model.TargetTag;
31-
import org.springframework.data.domain.Page;
32-
import org.springframework.data.domain.Pageable;
33-
import org.springframework.security.access.prepost.PreAuthorize;
3423

3524
/**
3625
* Management service for {@link DistributionSetTag}s.

hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/MaintenanceScheduleHelper.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@ public static void validateMaintenanceSchedule(final String cronSchedule, final
8888
if (allNotEmpty(cronSchedule, duration, timezone)) {
8989
validateCronSchedule(cronSchedule);
9090
validateDuration(duration);
91-
// check if there is a window currently active or available in
92-
// future.
93-
if (!getNextMaintenanceWindow(cronSchedule, duration, timezone).isPresent()) {
94-
throw new InvalidMaintenanceScheduleException(
95-
"No valid maintenance window available after current time");
91+
// check if there is a window currently active or available in the future.
92+
if (getNextMaintenanceWindow(cronSchedule, duration, timezone).isEmpty()) {
93+
throw new InvalidMaintenanceScheduleException("No valid maintenance window available after current time");
9694
}
9795
} else if (atLeastOneNotEmpty(cronSchedule, duration, timezone)) {
9896
throw new InvalidMaintenanceScheduleException("All of schedule, duration and timezone should either be null or non empty.");

hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/OffsetBasedPageRequest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
import org.springframework.data.domain.Sort;
1919

2020
/**
21-
* An implementation of the {@link PageRequest} which is offset based by means
22-
* the offset is given and not the page number as in the original
23-
* {@link PageRequest} implementation where the offset is generated. Due that
24-
* the REST-API is working with {@code offset} and {@code limit} parameter we
25-
* need an offset based page request.
21+
* An implementation of the {@link PageRequest} which is offset based by means the offset is given and not the page number as in the original
22+
* {@link PageRequest} implementation where the offset is generated. Due to the REST-API is working with {@code offset} and {@code limit}
23+
* parameter we need an offset based page request.
2624
*/
2725
@Getter
2826
@EqualsAndHashCode(callSuper = true)

hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/QuotaManagement.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
public interface QuotaManagement {
2121

2222
/**
23-
* @return maximum number of {@link ActionStatus} entries that the
24-
* controller can report for an {@link Action}.
23+
* @return maximum number of {@link ActionStatus} entries that the controller can report for an {@link Action}.
2524
*/
2625
int getMaxStatusEntriesPerAction();
2726

@@ -31,15 +30,12 @@ public interface QuotaManagement {
3130
int getMaxAttributeEntriesPerTarget();
3231

3332
/**
34-
* @return maximum number of allowed {@link RolloutGroup}s per
35-
* {@link Rollout}.
33+
* @return maximum number of allowed {@link RolloutGroup}s per {@link Rollout}.
3634
*/
3735
int getMaxRolloutGroupsPerRollout();
3836

3937
/**
40-
* @return maximum number of
41-
* {@link ControllerManagement#getActionHistoryMessages(Long, int)}
42-
* for an individual {@link ActionStatus}.
38+
* @return maximum number of action (history) messages per actions status.
4339
*/
4440
int getMaxMessagesPerActionStatus();
4541

@@ -49,7 +45,7 @@ public interface QuotaManagement {
4945
int getMaxMetaDataEntriesPerSoftwareModule();
5046

5147
/**
52-
* @return maximum number of meta data entries per distribution set
48+
* @return maximum number of metadata entries per distribution set
5349
*/
5450
int getMaxMetaDataEntriesPerDistributionSet();
5551

@@ -80,14 +76,12 @@ public interface QuotaManagement {
8076
int getMaxTargetsPerRolloutGroup();
8177

8278
/**
83-
* @return the maximum number of target distribution set assignments
84-
* resulting from a manual assignment
79+
* @return the maximum number of target distribution set assignments resulting from a manual assignment
8580
*/
8681
int getMaxTargetDistributionSetAssignmentsPerManualAssignment();
8782

8883
/**
89-
* @return the maximum number of targets for an automatic distribution set
90-
* assignment
84+
* @return the maximum number of targets for an automatic distribution set assignment
9185
*/
9286
int getMaxTargetsPerAutoAssignment();
9387

@@ -110,5 +104,4 @@ public interface QuotaManagement {
110104
* @return the maximum number of distribution set types per target type
111105
*/
112106
int getMaxDistributionSetTypesPerTargetType();
113-
114-
}
107+
}

hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RegexCharacterCollection.java

Lines changed: 0 additions & 68 deletions
This file was deleted.

hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RepositoryConstants.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import lombok.AccessLevel;
1313
import lombok.NoArgsConstructor;
1414
import org.eclipse.hawkbit.repository.model.Action;
15-
import org.eclipse.hawkbit.repository.model.ActionStatus;
1615
import org.eclipse.hawkbit.repository.model.DistributionSetType;
1716
import org.eclipse.hawkbit.repository.model.SoftwareModule;
1817

@@ -23,15 +22,12 @@
2322
public final class RepositoryConstants {
2423

2524
/**
26-
* Prefix that the server puts in front of
27-
* {@link ActionStatus#getMessages()} if the message is generated by the
28-
* server.
25+
* Prefix that the server puts in front of action status messages if the message is generated by the server.
2926
*/
3027
public static final String SERVER_MESSAGE_PREFIX = "Update Server: ";
3128

3229
/**
33-
* Number of {@link DistributionSetType}s that are generated as part of
34-
* default tenant setup.
30+
* Number of {@link DistributionSetType}s that are generated as part of default tenant setup.
3531
*/
3632
public static final int DEFAULT_DS_TYPES_IN_TENANT = 3;
3733

@@ -41,8 +37,7 @@ public final class RepositoryConstants {
4137
public static final int MAX_ACTION_COUNT = 100;
4238

4339
/**
44-
* Maximum number of messages that can be retrieved by a controller for an
45-
* {@link Action}.
40+
* Maximum number of messages that can be retrieved by a controller for an {@link Action}.
4641
*/
4742
public static final int MAX_ACTION_HISTORY_MSG_COUNT = 100;
4843

hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutExecutor.java

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
package org.eclipse.hawkbit.repository;
1111

1212
import org.eclipse.hawkbit.im.authentication.SpringEvalExpressions;
13-
1413
import org.eclipse.hawkbit.repository.model.Rollout;
14+
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
15+
import org.eclipse.hawkbit.repository.model.RolloutGroup;
1516
import org.eclipse.hawkbit.repository.model.Target;
1617
import org.springframework.security.access.prepost.PreAuthorize;
1718

@@ -22,32 +23,25 @@
2223
public interface RolloutExecutor {
2324

2425
/**
25-
* This execution should only be triggered by the system as a background job and
26-
* not available via API.
27-
*
26+
* This execution should only be triggered by the system as a background job and not available via API.
27+
* <p/>
2828
* Process rollout based on its current {@link Rollout#getStatus()}.
29-
*
30-
* For {@link RolloutStatus#CREATING} that means creating the
31-
* {@link RolloutGroup}s with {@link Target}s and when finished switch to
32-
* {@link RolloutStatus#READY}.
33-
*
34-
* For {@link RolloutStatus#READY} that means switching to
35-
* {@link RolloutStatus#STARTING} if the {@link Rollout#getStartAt()} is set and
36-
* time of calling this method is beyond this point in time. This auto start
37-
* mechanism is optional. Call {@link #start(Long)} otherwise.
38-
*
39-
* For {@link RolloutStatus#STARTING} that means starting the first
40-
* {@link RolloutGroup}s in line and when finished switch to
29+
* <p/>
30+
* For {@link RolloutStatus#CREATING} that means creating the {@link org.eclipse.hawkbit.repository.model.RolloutGroup}s
31+
* with {@link Target}s and when finished switch to {@link RolloutStatus#READY}.
32+
* <p/>
33+
* For {@link RolloutStatus#READY} that means switching to {@link RolloutStatus#STARTING} if the {@link Rollout#getStartAt()} is set and
34+
* time of calling this method is beyond this point in time. This auto start mechanism is optional.
35+
* Call {@link RolloutManagement#start(long)} otherwise.
36+
* <p/>
37+
* For {@link RolloutStatus#STARTING} that means starting the first {@link RolloutGroup}s in line and when finished switch to
4138
* {@link RolloutStatus#RUNNING}.
42-
*
43-
* For {@link RolloutStatus#RUNNING} that means checking to activate further
44-
* groups based on the defined thresholds. Switched to
39+
* <p/>
40+
* For {@link RolloutStatus#RUNNING} that means checking to activate further groups based on the defined thresholds. Switched to
4541
* {@link RolloutStatus#FINISHED} is all groups are finished.
46-
*
47-
* For {@link RolloutStatus#DELETING} that means either soft delete in case
48-
* rollout was already {@link RolloutStatus#RUNNING} which results in status
49-
* change {@link RolloutStatus#DELETED} or hard delete from the persistence
50-
* otherwise.
42+
* <p/>
43+
* For {@link RolloutStatus#DELETING} that means either soft delete in case rollout was already {@link RolloutStatus#RUNNING}
44+
* which results in status change {@link RolloutStatus#DELETED} or hard delete from the persistence otherwise.
5145
*/
5246
@PreAuthorize(SpringEvalExpressions.IS_SYSTEM_CODE)
5347
void execute(Rollout rollout);

0 commit comments

Comments
 (0)