Align DeploymentRequestBuilder with the rest of the builders (#2607)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -34,7 +34,6 @@ import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.ActionCancellationType;
|
||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
import org.eclipse.hawkbit.repository.model.DeploymentRequest;
|
||||
import org.eclipse.hawkbit.repository.model.DeploymentRequestBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
@@ -59,17 +58,6 @@ public interface DeploymentManagement extends PermissionSupport {
|
||||
return SpPermission.TARGET;
|
||||
}
|
||||
|
||||
/**
|
||||
* build a {@link DeploymentRequest} for a target distribution set assignment
|
||||
*
|
||||
* @param controllerId ID of target
|
||||
* @param distributionSetId ID of distribution set
|
||||
* @return the builder
|
||||
*/
|
||||
static DeploymentRequestBuilder deploymentRequest(final String controllerId, final long distributionSetId) {
|
||||
return new DeploymentRequestBuilder(controllerId, distributionSetId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns {@link DistributionSet}s to {@link Target}s according to the {@link DeploymentRequest}.
|
||||
*
|
||||
@@ -316,14 +304,6 @@ public interface DeploymentManagement extends PermissionSupport {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_READ_REPOSITORY)
|
||||
List<Action> findActiveActionsWithHighestWeight(@NotEmpty String controllerId, int maxActionCount);
|
||||
|
||||
/**
|
||||
* Get weight of an Action. Returns the default value if the weight is null according to the properties.
|
||||
*
|
||||
* @param action to extract the weight from
|
||||
* @return weight of the action
|
||||
*/
|
||||
int getWeightConsideringDefault(final Action action);
|
||||
|
||||
/**
|
||||
* Force cancels given {@link Action} for given {@link Target}. Force canceling means that the action is marked as canceled on the SP server
|
||||
* and a cancel request is sent to the target. But however it's not tracked, if the targets handles the cancel request or not.
|
||||
|
||||
@@ -266,6 +266,7 @@ public interface RolloutManagement extends PermissionSupport {
|
||||
* @param rolloutId rollout id
|
||||
* @return <code>true</code> if rollout exists
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_READ_REPOSITORY)
|
||||
boolean exists(long rolloutId);
|
||||
|
||||
/**
|
||||
|
||||
@@ -85,7 +85,7 @@ public interface TargetFilterQueryManagement<T extends TargetFilterQuery>
|
||||
* @return the page with the found {@link TargetFilterQuery}s
|
||||
* @throws EntityNotFoundException if DS with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_READ_REPOSITORY)
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_READ_REPOSITORY + " and " + "hasAuthority('READ_" + SpPermission.DISTRIBUTION_SET + "')")
|
||||
Page<TargetFilterQuery> findByAutoAssignDSAndRsql(long setId, String rsql, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,8 @@ package org.eclipse.hawkbit.repository.model;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.eclipse.hawkbit.repository.exception.InvalidMaintenanceScheduleException;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
|
||||
@@ -69,4 +71,72 @@ public class DeploymentRequest {
|
||||
public String getControllerId() {
|
||||
return targetWithActionType.getControllerId();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a {@link DeploymentRequest} for a target distribution set assignment
|
||||
*
|
||||
* @param controllerId ID of target
|
||||
* @param distributionSetId ID of distribution set
|
||||
* @return the builder
|
||||
*/
|
||||
public static DeploymentRequestBuilder builder(final String controllerId, final long distributionSetId) {
|
||||
return new DeploymentRequestBuilder(controllerId, distributionSetId);
|
||||
}
|
||||
|
||||
@Accessors(fluent = true)
|
||||
public static class DeploymentRequestBuilder {
|
||||
|
||||
private final String controllerId;
|
||||
private final Long distributionSetId;
|
||||
@Setter
|
||||
private Integer weight;
|
||||
@Setter
|
||||
private long forceTime = RepositoryModelConstants.NO_FORCE_TIME;
|
||||
@Setter
|
||||
private ActionType actionType = ActionType.FORCED;
|
||||
private String maintenanceSchedule;
|
||||
private String maintenanceWindowDuration;
|
||||
private String maintenanceWindowTimeZone;
|
||||
@Setter
|
||||
private boolean confirmationRequired;
|
||||
|
||||
/**
|
||||
* Create a builder for a target distribution set assignment with the
|
||||
* mandatory fields
|
||||
*
|
||||
* @param controllerId ID of the target
|
||||
* @param distributionSetId ID of the distribution set
|
||||
*/
|
||||
private DeploymentRequestBuilder(final String controllerId, final Long distributionSetId) {
|
||||
this.controllerId = controllerId;
|
||||
this.distributionSetId = distributionSetId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a maintenanceWindow
|
||||
*
|
||||
* @param maintenanceSchedule is the cron expression to be used for scheduling maintenance
|
||||
* windows. Expression has 6 mandatory fields and 1 last optional
|
||||
* field: "second minute hour dayofmonth month weekday year"
|
||||
* @param maintenanceWindowDuration in HH:mm:ss format specifying the duration of a maintenance
|
||||
* window, for example 00:30:00 for 30 minutes
|
||||
* @param maintenanceWindowTimeZone is the time zone specified as +/-hh:mm offset from UTC, for
|
||||
* example +02:00 for CET summer time and +00:00 for UTC. The
|
||||
* start time of a maintenance window calculated based on the
|
||||
* cron expression is relative to this time zone.
|
||||
* @return builder
|
||||
*/
|
||||
public DeploymentRequestBuilder maintenance(
|
||||
final String maintenanceSchedule, final String maintenanceWindowDuration, final String maintenanceWindowTimeZone) {
|
||||
this.maintenanceSchedule = maintenanceSchedule;
|
||||
this.maintenanceWindowDuration = maintenanceWindowDuration;
|
||||
this.maintenanceWindowTimeZone = maintenanceWindowTimeZone;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeploymentRequest build() {
|
||||
return new DeploymentRequest(controllerId, distributionSetId, actionType, forceTime, weight,
|
||||
maintenanceSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone, confirmationRequired);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2019 Bosch Software Innovations GmbH and others
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.model;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
|
||||
/**
|
||||
* Builder for {@link DeploymentRequest}
|
||||
*/
|
||||
public class DeploymentRequestBuilder {
|
||||
|
||||
private final String controllerId;
|
||||
private final Long distributionSetId;
|
||||
private Integer weight;
|
||||
private long forceTime = RepositoryModelConstants.NO_FORCE_TIME;
|
||||
private ActionType actionType = ActionType.FORCED;
|
||||
private String maintenanceSchedule;
|
||||
private String maintenanceWindowDuration;
|
||||
private String maintenanceWindowTimeZone;
|
||||
private boolean confirmationRequired;
|
||||
|
||||
/**
|
||||
* Create a builder for a target distribution set assignment with the
|
||||
* mandatory fields
|
||||
*
|
||||
* @param controllerId ID of the target
|
||||
* @param distributionSetId ID of the distribution set
|
||||
*/
|
||||
public DeploymentRequestBuilder(final String controllerId, final Long distributionSetId) {
|
||||
this.controllerId = controllerId;
|
||||
this.distributionSetId = distributionSetId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an other {@link ActionType} than {@link ActionType#FORCED}
|
||||
*
|
||||
* @param actionType type to used
|
||||
* @return builder
|
||||
*/
|
||||
public DeploymentRequestBuilder setActionType(final ActionType actionType) {
|
||||
this.actionType = actionType;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a forceTime other than the default one.
|
||||
*
|
||||
* @param forceTime at what time the type soft turns into forced.
|
||||
* @return builder
|
||||
*/
|
||||
public DeploymentRequestBuilder setForceTime(final long forceTime) {
|
||||
this.forceTime = forceTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the weight of the action.
|
||||
*
|
||||
* @param weight the priority given to the action.
|
||||
* @return builder
|
||||
*/
|
||||
public DeploymentRequestBuilder setWeight(final Integer weight) {
|
||||
this.weight = weight;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a maintenanceWindow
|
||||
*
|
||||
* @param maintenanceSchedule is the cron expression to be used for scheduling maintenance
|
||||
* windows. Expression has 6 mandatory fields and 1 last optional
|
||||
* field: "second minute hour dayofmonth month weekday year"
|
||||
* @param maintenanceWindowDuration in HH:mm:ss format specifying the duration of a maintenance
|
||||
* window, for example 00:30:00 for 30 minutes
|
||||
* @param maintenanceWindowTimeZone is the time zone specified as +/-hh:mm offset from UTC, for
|
||||
* example +02:00 for CET summer time and +00:00 for UTC. The
|
||||
* start time of a maintenance window calculated based on the
|
||||
* cron expression is relative to this time zone.
|
||||
* @return builder
|
||||
*/
|
||||
public DeploymentRequestBuilder setMaintenance(final String maintenanceSchedule,
|
||||
final String maintenanceWindowDuration, final String maintenanceWindowTimeZone) {
|
||||
this.maintenanceSchedule = maintenanceSchedule;
|
||||
this.maintenanceWindowDuration = maintenanceWindowDuration;
|
||||
this.maintenanceWindowTimeZone = maintenanceWindowTimeZone;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if a confirmation is required.
|
||||
*
|
||||
* @param confirmationRequired if a confirmation is required for the {@link Action}
|
||||
* @return builder
|
||||
*/
|
||||
public DeploymentRequestBuilder setConfirmationRequired(final boolean confirmationRequired) {
|
||||
this.confirmationRequired = confirmationRequired;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* build the request
|
||||
*
|
||||
* @return the request object
|
||||
*/
|
||||
public DeploymentRequest build() {
|
||||
return new DeploymentRequest(controllerId, distributionSetId, actionType, forceTime, weight,
|
||||
maintenanceSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone, confirmationRequired);
|
||||
}
|
||||
}
|
||||
@@ -169,10 +169,10 @@ public abstract class AbstractAutoAssignExecutor implements AutoAssignExecutor {
|
||||
: filterQuery.getAutoAssignActionType();
|
||||
|
||||
return controllerIds.stream()
|
||||
.map(controllerId -> DeploymentManagement
|
||||
.deploymentRequest(controllerId, filterQuery.getAutoAssignDistributionSet().getId())
|
||||
.setActionType(autoAssignActionType).setWeight(filterQuery.getAutoAssignWeight().orElse(null))
|
||||
.setConfirmationRequired(filterQuery.isConfirmationRequired()).build())
|
||||
.map(controllerId -> DeploymentRequest
|
||||
.builder(controllerId, filterQuery.getAutoAssignDistributionSet().getId())
|
||||
.actionType(autoAssignActionType).weight(filterQuery.getAutoAssignWeight().orElse(null))
|
||||
.confirmationRequired(filterQuery.isConfirmationRequired()).build())
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class JpaActionManagement {
|
||||
this.repositoryProperties = repositoryProperties;
|
||||
}
|
||||
|
||||
public int getWeightConsideringDefault(final Action action) {
|
||||
protected int getWeightConsideringDefault(final Action action) {
|
||||
return action.getWeight().orElse(repositoryProperties.getActionWeightIfAbsent());
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
enforceMaxAssignmentsPerRequest(distinctAssignments.size());
|
||||
|
||||
final List<DeploymentRequest> deploymentRequests = distinctAssignments.stream()
|
||||
.map(entry -> DeploymentManagement.deploymentRequest(entry.getKey(), entry.getValue()).build()).toList();
|
||||
.map(entry -> DeploymentRequest.builder(entry.getKey(), entry.getValue()).build()).toList();
|
||||
|
||||
return assignDistributionSets(
|
||||
auditorAware.getCurrentAuditor().orElse(tenantAware.getCurrentUsername()), deploymentRequests, null,
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.DeploymentRequest;
|
||||
import org.eclipse.hawkbit.repository.model.DeploymentRequestBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -326,7 +325,7 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private static DeploymentRequest toDeploymentRequest(final String controllerId, final Long distributionSetId) {
|
||||
return new DeploymentRequestBuilder(controllerId, distributionSetId).setConfirmationRequired(true).build();
|
||||
return DeploymentRequest.builder(controllerId, distributionSetId).confirmationRequired(true).build();
|
||||
}
|
||||
|
||||
private void verifyAutoConfirmationIsDisabled(final String controllerId) {
|
||||
|
||||
@@ -32,7 +32,6 @@ import jakarta.validation.ConstraintViolationException;
|
||||
import lombok.Getter;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.eclipse.hawkbit.repository.ActionStatusFields;
|
||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.event.remote.CancelTargetAssignmentEvent;
|
||||
@@ -65,7 +64,6 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet_;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget_;
|
||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.ActionSpecifications;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetSpecification;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.SpecificationsBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
@@ -74,7 +72,6 @@ import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
import org.eclipse.hawkbit.repository.model.DeploymentRequest;
|
||||
import org.eclipse.hawkbit.repository.model.DeploymentRequestBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
@@ -747,11 +744,11 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Target target = testdataFactory.createTarget();
|
||||
final List<DistributionSet> distributionSets = testdataFactory.createDistributionSets(2);
|
||||
|
||||
final DeploymentRequest targetToDS0 = DeploymentManagement
|
||||
.deploymentRequest(target.getControllerId(), distributionSets.get(0).getId()).setWeight(78).build();
|
||||
final DeploymentRequest targetToDS0 = DeploymentRequest
|
||||
.builder(target.getControllerId(), distributionSets.get(0).getId()).weight(78).build();
|
||||
|
||||
final DeploymentRequest targetToDS1 = DeploymentManagement
|
||||
.deploymentRequest(target.getControllerId(), distributionSets.get(1).getId()).setWeight(565).build();
|
||||
final DeploymentRequest targetToDS1 = DeploymentRequest
|
||||
.builder(target.getControllerId(), distributionSets.get(1).getId()).weight(565).build();
|
||||
|
||||
final List<DeploymentRequest> deploymentRequests = List.of(targetToDS0, targetToDS1);
|
||||
Assertions.assertThatExceptionOfType(MultiAssignmentIsNotEnabledException.class)
|
||||
@@ -835,8 +832,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
|
||||
assignDistributionSets(Collections
|
||||
.singletonList(new DeploymentRequestBuilder(target.getControllerId(), distributionSet.getId())
|
||||
.setConfirmationRequired(confirmationRequired).build()));
|
||||
.singletonList(DeploymentRequest.builder(target.getControllerId(), distributionSet.getId())
|
||||
.confirmationRequired(confirmationRequired).build()));
|
||||
|
||||
assertThat(deploymentManagement.findActionsByTarget(target.getControllerId(), PAGE).getContent()).hasSize(1)
|
||||
.allSatisfy(action -> {
|
||||
@@ -952,14 +949,14 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final String targetId = testdataFactory.createTarget().getControllerId();
|
||||
final Long dsId = testdataFactory.createDistributionSet().getId();
|
||||
final List<DeploymentRequest> twoEqualAssignments = Collections.nCopies(2,
|
||||
DeploymentManagement.deploymentRequest(targetId, dsId).build());
|
||||
DeploymentRequest.builder(targetId, dsId).build());
|
||||
|
||||
assertThat(getResultingActionCount(deploymentManagement.assignDistributionSets(twoEqualAssignments)))
|
||||
.isEqualTo(1);
|
||||
|
||||
enableMultiAssignments();
|
||||
final List<DeploymentRequest> twoEqualAssignmentsWithWeight = Collections.nCopies(2,
|
||||
DeploymentManagement.deploymentRequest(targetId, dsId).setWeight(555).build());
|
||||
DeploymentRequest.builder(targetId, dsId).weight(555).build());
|
||||
|
||||
assertThat(getResultingActionCount(deploymentManagement.assignDistributionSets(twoEqualAssignmentsWithWeight)))
|
||||
.isEqualTo(1);
|
||||
@@ -987,7 +984,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
for (int i = 0; i < size; i++) {
|
||||
final Long dsId = testdataFactory.createDistributionSet().getId();
|
||||
deploymentRequests.add(
|
||||
DeploymentManagement.deploymentRequest(controllerId, dsId).setWeight(24).build());
|
||||
DeploymentRequest.builder(controllerId, dsId).weight(24).build());
|
||||
}
|
||||
|
||||
enableMultiAssignments();
|
||||
@@ -1004,8 +1001,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final String targetId = testdataFactory.createTarget().getControllerId();
|
||||
final Long dsId = testdataFactory.createDistributionSet().getId();
|
||||
|
||||
final DeploymentRequest assignWithoutWeight = DeploymentManagement.deploymentRequest(targetId, dsId).build();
|
||||
final DeploymentRequest assignWithWeight = DeploymentManagement.deploymentRequest(targetId, dsId).setWeight(567).build();
|
||||
final DeploymentRequest assignWithoutWeight = DeploymentRequest.builder(targetId, dsId).build();
|
||||
final DeploymentRequest assignWithWeight = DeploymentRequest.builder(targetId, dsId).weight(567).build();
|
||||
|
||||
enableMultiAssignments();
|
||||
assertThat(deploymentManagement.assignDistributionSets(List.of(assignWithoutWeight, assignWithWeight))).isNotNull();
|
||||
@@ -1019,7 +1016,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final String targetId = testdataFactory.createTarget().getControllerId();
|
||||
final Long dsId = testdataFactory.createDistributionSet().getId();
|
||||
|
||||
final DeploymentRequest assignWithoutWeight = DeploymentManagement.deploymentRequest(targetId, dsId).setWeight(456).build();
|
||||
final DeploymentRequest assignWithoutWeight = DeploymentRequest.builder(targetId, dsId).weight(456).build();
|
||||
assertThat(deploymentManagement.assignDistributionSets(Collections.singletonList(assignWithoutWeight))).isNotNull().size().isEqualTo(1);
|
||||
}
|
||||
|
||||
@@ -1040,14 +1037,10 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
void weightValidatedAndSaved() {
|
||||
final String targetId = testdataFactory.createTarget().getControllerId();
|
||||
final Long dsId = testdataFactory.createDistributionSet().getId();
|
||||
final DeploymentRequest valideRequest1 = DeploymentManagement.deploymentRequest(targetId, dsId)
|
||||
.setWeight(Action.WEIGHT_MAX).build();
|
||||
final DeploymentRequest valideRequest2 = DeploymentManagement.deploymentRequest(targetId, dsId)
|
||||
.setWeight(Action.WEIGHT_MIN).build();
|
||||
final DeploymentRequest weightTooLow = DeploymentManagement.deploymentRequest(targetId, dsId)
|
||||
.setWeight(Action.WEIGHT_MIN - 1).build();
|
||||
final DeploymentRequest weightTooHigh = DeploymentManagement.deploymentRequest(targetId, dsId)
|
||||
.setWeight(Action.WEIGHT_MAX + 1).build();
|
||||
final DeploymentRequest valideRequest1 = DeploymentRequest.builder(targetId, dsId).weight(Action.WEIGHT_MAX).build();
|
||||
final DeploymentRequest valideRequest2 = DeploymentRequest.builder(targetId, dsId).weight(Action.WEIGHT_MIN).build();
|
||||
final DeploymentRequest weightTooLow = DeploymentRequest.builder(targetId, dsId).weight(Action.WEIGHT_MIN - 1).build();
|
||||
final DeploymentRequest weightTooHigh = DeploymentRequest.builder(targetId, dsId).weight(Action.WEIGHT_MAX + 1).build();
|
||||
enableMultiAssignments();
|
||||
final List<DeploymentRequest> deploymentRequestsTooLow = Collections.singletonList(weightTooLow);
|
||||
Assertions.assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
@@ -1613,8 +1606,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final List<DeploymentRequest> deploymentRequests = new ArrayList<>();
|
||||
for (int i = 0; i < quotaManagement.getMaxTargetDistributionSetAssignmentsPerManualAssignment(); i++) {
|
||||
final Target target = testdataFactory.createTarget("test-target-" + i, "test-target-" + i, targetType);
|
||||
final DeploymentRequest deployment = DeploymentManagement
|
||||
.deploymentRequest(target.getControllerId(), ds.getId()).build();
|
||||
final DeploymentRequest deployment = DeploymentRequest
|
||||
.builder(target.getControllerId(), ds.getId()).build();
|
||||
deploymentRequests.add(deployment);
|
||||
}
|
||||
|
||||
@@ -1637,8 +1630,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Target target1 = testdataFactory.createTarget("test-target1", "test-target1", targetType1);
|
||||
final Target target2 = testdataFactory.createTarget("test-target2", "test-target2", targetType2);
|
||||
|
||||
final DeploymentRequest deployment1 = DeploymentManagement.deploymentRequest(target1.getControllerId(), ds.getId()).build();
|
||||
final DeploymentRequest deployment2 = DeploymentManagement.deploymentRequest(target2.getControllerId(), ds.getId()).build();
|
||||
final DeploymentRequest deployment1 = DeploymentRequest.builder(target1.getControllerId(), ds.getId()).build();
|
||||
final DeploymentRequest deployment2 = DeploymentRequest.builder(target2.getControllerId(), ds.getId()).build();
|
||||
final List<DeploymentRequest> deploymentRequests = Arrays.asList(deployment1, deployment2);
|
||||
|
||||
deploymentManagement.assignDistributionSets(deploymentRequests);
|
||||
@@ -1663,7 +1656,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final TargetType targetType = testdataFactory.createTargetType("target-type", Set.of(dsType));
|
||||
final Target target = testdataFactory.createTarget("test-target", "test-target", targetType);
|
||||
|
||||
final DeploymentRequest deploymentRequest = DeploymentManagement.deploymentRequest(target.getControllerId(), ds.getId()).build();
|
||||
final DeploymentRequest deploymentRequest = DeploymentRequest.builder(target.getControllerId(), ds.getId()).build();
|
||||
final List<DeploymentRequest> deploymentRequests = List.of(deploymentRequest);
|
||||
|
||||
assertThatExceptionOfType(IncompatibleTargetTypeException.class)
|
||||
@@ -1679,8 +1672,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final TargetType emptyTargetType = testdataFactory.createTargetType("target-type", Set.of());
|
||||
final Target targetWithEmptyType = testdataFactory.createTarget("test-target", "test-target", emptyTargetType);
|
||||
|
||||
final DeploymentRequest deploymentRequestWithEmptyType = DeploymentManagement
|
||||
.deploymentRequest(targetWithEmptyType.getControllerId(), ds.getId()).build();
|
||||
final DeploymentRequest deploymentRequestWithEmptyType = DeploymentRequest
|
||||
.builder(targetWithEmptyType.getControllerId(), ds.getId()).build();
|
||||
final List<DeploymentRequest> deploymentRequests = Collections.singletonList(deploymentRequestWithEmptyType);
|
||||
assertThatExceptionOfType(IncompatibleTargetTypeException.class)
|
||||
.isThrownBy(() -> deploymentManagement.assignDistributionSets(deploymentRequests));
|
||||
@@ -1695,8 +1688,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Collection<Target> targets, final int weight, final boolean confirmationRequired) {
|
||||
final List<DeploymentRequest> deploymentRequests = new ArrayList<>();
|
||||
distributionSets.forEach(ds -> targets.forEach(target -> deploymentRequests
|
||||
.add(DeploymentManagement.deploymentRequest(target.getControllerId(), ds.getId()).setWeight(weight)
|
||||
.setConfirmationRequired(confirmationRequired).build())));
|
||||
.add(DeploymentRequest.builder(target.getControllerId(), ds.getId())
|
||||
.weight(weight).confirmationRequired(confirmationRequired).build())));
|
||||
return deploymentRequests;
|
||||
}
|
||||
|
||||
|
||||
@@ -340,8 +340,8 @@ public abstract class AbstractIntegrationTest {
|
||||
final boolean confirmationFlowActive = isConfirmationFlowActive();
|
||||
|
||||
final List<DeploymentRequest> deploymentRequests = controllerIds.stream()
|
||||
.map(id -> DeploymentManagement.deploymentRequest(id, dsId)
|
||||
.setActionType(actionType).setForceTime(forcedTime).setWeight(weight).setConfirmationRequired(confirmationFlowActive)
|
||||
.map(id -> DeploymentRequest.builder(id, dsId)
|
||||
.actionType(actionType).forceTime(forcedTime).weight(weight).confirmationRequired(confirmationFlowActive)
|
||||
.build())
|
||||
.toList();
|
||||
final List<DistributionSetAssignmentResult> results = deploymentManagement.assignDistributionSets(deploymentRequests);
|
||||
@@ -393,9 +393,9 @@ public abstract class AbstractIntegrationTest {
|
||||
final String controllerId, final String maintenanceWindowSchedule, final String maintenanceWindowDuration,
|
||||
final String maintenanceWindowTimeZone) {
|
||||
|
||||
return makeAssignment(DeploymentManagement.deploymentRequest(controllerId, dsID)
|
||||
.setMaintenance(maintenanceWindowSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone)
|
||||
.setConfirmationRequired(true).build());
|
||||
return makeAssignment(DeploymentRequest.builder(controllerId, dsID)
|
||||
.maintenance(maintenanceWindowSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone)
|
||||
.confirmationRequired(true).build());
|
||||
}
|
||||
|
||||
protected DistributionSetAssignmentResult assignDistributionSet(final DistributionSet pset, final Target target) {
|
||||
|
||||
Reference in New Issue
Block a user