introduced open actionIds in MgmtTargetAssignmentResponseBody (#864)
* introduced open actionIds in MgmtTargetAssignmentResponseBody Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * fixed SonarQube issues Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * removed unused method parameter Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * updated documentation tests Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * added limit to the alreadyAssignedActions in the AssignmentResult Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * moved alreadyAssignedActions limitation to MgmtDistributionSetMapper Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * fixed review findings Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * removed alreadyAssignedActions Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * fixed sonarQube issues Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * fixed compilation error Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * fixed PR review findings Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * fixed PR review findings Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * Renamed AssignmentResult to AbstractAssignmentResult Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * fixed review findings Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * fixed formatting Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * reverted method visibility Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>
This commit is contained in:
committed by
Dominic Schabel
parent
973f1952c7
commit
d40b11d2ab
@@ -18,6 +18,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtMetadata;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionId;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetRequestBodyPost;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentResponseBody;
|
||||
@@ -137,9 +138,9 @@ public final class MgmtDistributionSetMapper {
|
||||
|
||||
static MgmtTargetAssignmentResponseBody toResponse(final DistributionSetAssignmentResult dsAssignmentResult) {
|
||||
final MgmtTargetAssignmentResponseBody result = new MgmtTargetAssignmentResponseBody();
|
||||
result.setAssigned(dsAssignmentResult.getAssigned());
|
||||
result.setAlreadyAssigned(dsAssignmentResult.getAlreadyAssigned());
|
||||
result.setTotal(dsAssignmentResult.getTotal());
|
||||
result.setAssignedActions(dsAssignmentResult.getAssignedEntity().stream()
|
||||
.map(a -> new MgmtActionId(a.getTarget().getControllerId(), a.getId())).collect(Collectors.toList()));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.rest.resource;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -286,7 +286,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
|
||||
if (offline) {
|
||||
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponse(
|
||||
deploymentManagement.offlineAssignedDistributionSet(dsId.getId(), Arrays.asList(targetId))));
|
||||
deploymentManagement.offlineAssignedDistributionSet(dsId.getId(),
|
||||
Collections.singletonList(targetId))));
|
||||
}
|
||||
|
||||
findTargetWithExceptionIfNotFound(targetId);
|
||||
@@ -294,7 +295,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
|
||||
if (maintenanceWindow == null) {
|
||||
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponse(this.deploymentManagement
|
||||
.assignDistributionSet(dsId.getId(), Arrays.asList(new TargetWithActionType(targetId,
|
||||
.assignDistributionSet(dsId.getId(), Collections.singletonList(new TargetWithActionType(targetId,
|
||||
MgmtRestModelMapper.convertActionType(dsId.getType()), dsId.getForcetime())))));
|
||||
}
|
||||
|
||||
@@ -306,7 +307,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
|
||||
return ResponseEntity
|
||||
.ok(MgmtDistributionSetMapper.toResponse(this.deploymentManagement.assignDistributionSet(dsId.getId(),
|
||||
Arrays.asList(new TargetWithActionType(targetId,
|
||||
Collections.singletonList(new TargetWithActionType(targetId,
|
||||
MgmtRestModelMapper.convertActionType(dsId.getType()), dsId.getForcetime(),
|
||||
cronSchedule, duration, timezone)))));
|
||||
|
||||
|
||||
@@ -1210,14 +1210,16 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
|
||||
// Update
|
||||
if (schedule == null) {
|
||||
final List<Target> updatedTargets = assignDistributionSet(one, Arrays.asList(target)).getAssignedEntity();
|
||||
final List<Target> updatedTargets = assignDistributionSet(one, Arrays.asList(target)).getAssignedEntity()
|
||||
.stream().map(Action::getTarget).collect(Collectors.toList());
|
||||
// 2nd update
|
||||
// sleep 10ms to ensure that we can sort by reportedAt
|
||||
Thread.sleep(10);
|
||||
assignDistributionSet(two, updatedTargets);
|
||||
} else {
|
||||
final List<Target> updatedTargets = assignDistributionSetWithMaintenanceWindow(one.getId(),
|
||||
target.getControllerId(), schedule, duration, timezone).getAssignedEntity();
|
||||
target.getControllerId(), schedule, duration, timezone).getAssignedEntity().stream()
|
||||
.map(Action::getTarget).collect(Collectors.toList());
|
||||
// 2nd update
|
||||
// sleep 10ms to ensure that we can sort by reportedAt
|
||||
Thread.sleep(10);
|
||||
@@ -1238,9 +1240,8 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
public void updateAction() throws Exception {
|
||||
final Target target = testdataFactory.createTarget();
|
||||
final DistributionSet set = testdataFactory.createDistributionSet();
|
||||
final Long actionId = deploymentManagement
|
||||
.assignDistributionSet(set.getId(), ActionType.SOFT, 0, Arrays.asList(target.getControllerId()))
|
||||
.getActionIds().get(0);
|
||||
final Long actionId = getFirstAssignedActionId(deploymentManagement.assignDistributionSet(set.getId(),
|
||||
ActionType.SOFT, 0, Collections.singletonList(target.getControllerId())));
|
||||
assertThat(deploymentManagement.findAction(actionId).get().getActionType()).isEqualTo(ActionType.SOFT);
|
||||
|
||||
final String body = new JSONObject().put("forceType", "forced").toString();
|
||||
|
||||
Reference in New Issue
Block a user