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:
Ahmed Sayed
2019-08-20 11:31:20 +02:00
committed by Dominic Schabel
parent 973f1952c7
commit d40b11d2ab
43 changed files with 580 additions and 402 deletions

View File

@@ -52,8 +52,8 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
public void cancelActionCbor() throws Exception {
final DistributionSet ds = testdataFactory.createDistributionSet("");
testdataFactory.createTarget();
final Long actionId = assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActionIds()
.get(0);
final Long actionId = getFirstAssignedActionId(
assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID));
final Action cancelAction = deploymentManagement.cancelAction(actionId);
// check that we can get the cancel action as CBOR
@@ -80,7 +80,8 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
final DistributionSet ds = testdataFactory.createDistributionSet("");
final Target savedTarget = testdataFactory.createTarget();
final Long actionId = assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getActionIds().get(0);
final Long actionId = getFirstAssignedActionId(
assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
final Action cancelAction = deploymentManagement.cancelAction(actionId);
@@ -133,7 +134,8 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
final DistributionSet ds = testdataFactory.createDistributionSet("");
final Target savedTarget = testdataFactory.createTarget();
final Long actionId = assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getActionIds().get(0);
final Long actionId = getFirstAssignedActionId(
assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
long current = System.currentTimeMillis();
mvc.perform(get("/{tenant}/controller/v1/{controller}", tenantAware.getCurrentTenant(),
@@ -249,7 +251,7 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
final Target savedTarget = testdataFactory.createTarget(targetid);
final List<Target> toAssign = new ArrayList<>();
toAssign.add(savedTarget);
final Long actionId = assignDistributionSet(ds, toAssign).getActionIds().get(0);
final Long actionId = getFirstAssignedActionId(assignDistributionSet(ds, toAssign));
return deploymentManagement.cancelAction(actionId);
}
@@ -262,8 +264,8 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
final Target savedTarget = testdataFactory.createTarget();
final Long actionId = assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActionIds()
.get(0);
final Long actionId = getFirstAssignedActionId(
assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID));
// cancel action manually
final Action cancelAction = deploymentManagement.cancelAction(actionId);
@@ -337,12 +339,12 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
final Target savedTarget = testdataFactory.createTarget();
final Long actionId = assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActionIds()
.get(0);
final Long actionId2 = assignDistributionSet(ds2.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActionIds()
.get(0);
final Long actionId3 = assignDistributionSet(ds3.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActionIds()
.get(0);
final Long actionId = getFirstAssignedActionId(
assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID));
final Long actionId2 = getFirstAssignedActionId(
assignDistributionSet(ds2.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID));
final Long actionId3 = getFirstAssignedActionId(
assignDistributionSet(ds3.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID));
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(3);
@@ -451,8 +453,8 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
testdataFactory.createTarget();
final DistributionSet ds = testdataFactory.createDistributionSet("");
final Long actionId = assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActionIds()
.get(0);
final Long actionId = getFirstAssignedActionId(
assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID));
final Action cancelAction = deploymentManagement.cancelAction(actionId);

View File

@@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.commons.lang3.RandomUtils;
import org.assertj.core.api.Condition;
@@ -156,7 +157,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
final List<Target> targetsAssignedToDs = deploymentManagement
.assignDistributionSet(ds.getId(), ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME,
Collections.singletonList(savedTarget.getControllerId()))
.getAssignedEntity();
.getAssignedEntity().stream().map(Action::getTarget).collect(Collectors.toList());;
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
@@ -207,9 +208,9 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
final Target target = testdataFactory.createTarget(DEFAULT_CONTROLLER_ID);
final DistributionSet ds = testdataFactory.createDistributionSet("", true);
final Long actionId = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.TIMEFORCED,
System.currentTimeMillis() + 2_000, Collections.singletonList(target.getControllerId())).getActionIds()
.get(0);
final Long actionId = getFirstAssignedActionId(
deploymentManagement.assignDistributionSet(ds.getId(), ActionType.TIMEFORCED,
System.currentTimeMillis() + 2_000, Collections.singletonList(target.getControllerId())));
MvcResult mvcResult = performGet("/{tenant}/controller/v1/" + DEFAULT_CONTROLLER_ID, MediaTypes.HAL_JSON,
status().isOk(), tenantAware.getCurrentTenant()).andReturn();
@@ -258,7 +259,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
final List<Target> saved = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.SOFT,
RepositoryModelConstants.NO_FORCE_TIME, Collections.singletonList(savedTarget.getControllerId()))
.getAssignedEntity();
.getAssignedEntity().stream().map(Action::getTarget).collect(Collectors.toList());
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
@@ -318,7 +319,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
final List<Target> saved = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.TIMEFORCED,
System.currentTimeMillis(), Collections.singletonList(savedTarget.getControllerId()))
.getAssignedEntity();
.getAssignedEntity().stream().map(Action::getTarget).collect(Collectors.toList());
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
@@ -386,7 +387,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
final List<Target> saved = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.DOWNLOAD_ONLY,
RepositoryModelConstants.NO_FORCE_TIME, Collections.singletonList(savedTarget.getControllerId()))
.getAssignedEntity();
.getAssignedEntity().stream().map(Action::getTarget).collect(Collectors.toList());
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
@@ -528,7 +529,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
final List<Target> toAssign = Collections.singletonList(target);
final DistributionSet savedSet = testdataFactory.createDistributionSet("");
final Long actionId = assignDistributionSet(savedSet, toAssign).getActionIds().get(0);
final Long actionId = getFirstAssignedActionId(assignDistributionSet(savedSet, toAssign));
mvc.perform(MockMvcRequestBuilders.get(DEPLOYMENT_BASE + actionId, tenantAware.getCurrentTenant(),
DEFAULT_CONTROLLER_ID)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
mvc.perform(MockMvcRequestBuilders
@@ -591,9 +592,9 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true);
final DistributionSet ds3 = testdataFactory.createDistributionSet("3", true);
final Long actionId1 = assignDistributionSet(ds1.getId(), DEFAULT_CONTROLLER_ID).getActionIds().get(0);
final Long actionId2 = assignDistributionSet(ds2.getId(), DEFAULT_CONTROLLER_ID).getActionIds().get(0);
final Long actionId3 = assignDistributionSet(ds3.getId(), DEFAULT_CONTROLLER_ID).getActionIds().get(0);
final Long actionId1 = getFirstAssignedActionId(assignDistributionSet(ds1.getId(), DEFAULT_CONTROLLER_ID));
final Long actionId2 = getFirstAssignedActionId(assignDistributionSet(ds2.getId(), DEFAULT_CONTROLLER_ID));
final Long actionId3 = getFirstAssignedActionId(assignDistributionSet(ds3.getId(), DEFAULT_CONTROLLER_ID));
findTargetAndAssertUpdateStatus(Optional.of(ds3), TargetUpdateStatus.PENDING, 3, Optional.empty());
assertThat(targetManagement.findByUpdateStatus(PageRequest.of(0, 10), TargetUpdateStatus.UNKNOWN)).hasSize(2);
@@ -663,39 +664,39 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
@Description("Verifies that the controller can provided as much feedback entries as necessary as long as it is in the configured limits.")
public void rootRsSingleDeploymentActionFeedback() throws Exception {
final DistributionSet ds = testdataFactory.createDistributionSet("");
final Action action = assignDistributionSet(ds,
Collections.singletonList(testdataFactory.createTarget(DEFAULT_CONTROLLER_ID))).getActions().get(0);
final Long actionId = getFirstAssignedActionId(assignDistributionSet(ds,
Collections.singletonList(testdataFactory.createTarget(DEFAULT_CONTROLLER_ID))));
findTargetAndAssertUpdateStatus(Optional.of(ds), TargetUpdateStatus.PENDING, 1, Optional.empty());
// Now valid Feedback
for (int i = 0; i < 4; i++) {
postFeedback(MediaType.APPLICATION_JSON, DEFAULT_CONTROLLER_ID, action.getId(),
JsonBuilder.deploymentActionFeedback(action.getId().toString(), "proceeding"), status().isOk());
postFeedback(MediaType.APPLICATION_JSON, DEFAULT_CONTROLLER_ID, actionId,
JsonBuilder.deploymentActionFeedback(actionId.toString(), "proceeding"), status().isOk());
assertActionStatusCount(i + 2, i);
}
postFeedback(MediaType.APPLICATION_JSON, DEFAULT_CONTROLLER_ID, action.getId(),
JsonBuilder.deploymentActionFeedback(action.getId().toString(), "scheduled"), status().isOk());
postFeedback(MediaType.APPLICATION_JSON, DEFAULT_CONTROLLER_ID, actionId,
JsonBuilder.deploymentActionFeedback(actionId.toString(), "scheduled"), status().isOk());
assertActionStatusCount(6, 5);
postFeedback(MediaType.APPLICATION_JSON, DEFAULT_CONTROLLER_ID, action.getId(),
JsonBuilder.deploymentActionFeedback(action.getId().toString(), "resumed"), status().isOk());
postFeedback(MediaType.APPLICATION_JSON, DEFAULT_CONTROLLER_ID, actionId,
JsonBuilder.deploymentActionFeedback(actionId.toString(), "resumed"), status().isOk());
assertActionStatusCount(7, 6);
postFeedback(MediaType.APPLICATION_JSON, DEFAULT_CONTROLLER_ID, action.getId(),
JsonBuilder.deploymentActionFeedback(action.getId().toString(), "canceled"), status().isOk());
postFeedback(MediaType.APPLICATION_JSON, DEFAULT_CONTROLLER_ID, actionId,
JsonBuilder.deploymentActionFeedback(actionId.toString(), "canceled"), status().isOk());
assertStatusAndActiveActionsCount(TargetUpdateStatus.PENDING, 1);
assertActionStatusCount(8, 7, 0, 0, 1);
assertTargetCountByStatus(1, 0, 0);
postFeedback(MediaType.APPLICATION_JSON, DEFAULT_CONTROLLER_ID, action.getId(),
JsonBuilder.deploymentActionFeedback(action.getId().toString(), "rejected"), status().isOk());
postFeedback(MediaType.APPLICATION_JSON, DEFAULT_CONTROLLER_ID, actionId,
JsonBuilder.deploymentActionFeedback(actionId.toString(), "rejected"), status().isOk());
assertStatusAndActiveActionsCount(TargetUpdateStatus.PENDING, 1);
assertActionStatusCount(9, 6, 1, 0, 1);
postFeedback(MediaType.APPLICATION_JSON, DEFAULT_CONTROLLER_ID, action.getId(),
JsonBuilder.deploymentActionFeedback(action.getId().toString(), "closed"), status().isOk());
postFeedback(MediaType.APPLICATION_JSON, DEFAULT_CONTROLLER_ID, actionId,
JsonBuilder.deploymentActionFeedback(actionId.toString(), "closed"), status().isOk());
assertStatusAndActiveActionsCount(TargetUpdateStatus.IN_SYNC, 0);
assertActionStatusCount(10, 7, 1, 1, 1);
assertTargetCountByStatus(0, 0, 1);

View File

@@ -369,8 +369,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
public void tryToFinishAnUpdateProcessAfterItHasBeenFinished() throws Exception {
final DistributionSet ds = testdataFactory.createDistributionSet("");
Target savedTarget = testdataFactory.createTarget("911");
savedTarget = assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getAssignedEntity().iterator()
.next();
savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
.getContent().get(0);
sendDeploymentActionFeedback(savedTarget, savedAction, "proceeding", null).andDo(MockMvcResultPrinter.print())
@@ -413,7 +412,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
@Step
private void assertAttributesUpdateNotRequestedAfterFailedDeployment(Target target, final DistributionSet ds)
throws Exception {
target = assignDistributionSet(ds.getId(), target.getControllerId()).getAssignedEntity().iterator().next();
target = getFirstAssignedTarget(assignDistributionSet(ds.getId(), target.getControllerId()));
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId())
.getContent().get(0);
sendDeploymentActionFeedback(target, action, "closed", "failure").andExpect(status().isOk());
@@ -423,7 +422,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
@Step
private void assertAttributesUpdateRequestedAfterSuccessfulDeployment(Target target, final DistributionSet ds)
throws Exception {
target = assignDistributionSet(ds.getId(), target.getControllerId()).getAssignedEntity().iterator().next();
target = getFirstAssignedTarget(assignDistributionSet(ds.getId(), target.getControllerId()));
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId())
.getContent().get(0);
sendDeploymentActionFeedback(target, action, "closed", null).andExpect(status().isOk());
@@ -474,8 +473,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
public void testActionHistoryCount() throws Exception {
final DistributionSet ds = testdataFactory.createDistributionSet("");
Target savedTarget = testdataFactory.createTarget("911");
savedTarget = assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getAssignedEntity().iterator()
.next();
savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
.getContent().get(0);
@@ -510,8 +508,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
public void testActionHistoryZeroInput() throws Exception {
final DistributionSet ds = testdataFactory.createDistributionSet("");
Target savedTarget = testdataFactory.createTarget("911");
savedTarget = assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getAssignedEntity().iterator()
.next();
savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
.getContent().get(0);
@@ -542,8 +539,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
public void testActionHistoryNegativeInput() throws Exception {
final DistributionSet ds = testdataFactory.createDistributionSet("");
Target savedTarget = testdataFactory.createTarget("911");
savedTarget = assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getAssignedEntity().iterator()
.next();
savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
.getContent().get(0);
@@ -620,8 +616,8 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
public void downloadAndUpdateStatusBeforeMaintenanceWindowStartTime() throws Exception {
Target savedTarget = testdataFactory.createTarget("1911");
final DistributionSet ds = testdataFactory.createDistributionSet("");
savedTarget = assignDistributionSetWithMaintenanceWindow(ds.getId(), savedTarget.getControllerId(),
getTestSchedule(2), getTestDuration(1), getTestTimeZone()).getAssignedEntity().iterator().next();
savedTarget = getFirstAssignedTarget(assignDistributionSetWithMaintenanceWindow(ds.getId(),
savedTarget.getControllerId(), getTestSchedule(2), getTestDuration(1), getTestTimeZone()));
mvc.perform(get("/default-tenant/controller/v1/1911/")).andExpect(status().isOk());
@@ -640,8 +636,8 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
public void downloadAndUpdateStatusDuringMaintenanceWindow() throws Exception {
Target savedTarget = testdataFactory.createTarget("1911");
final DistributionSet ds = testdataFactory.createDistributionSet("");
savedTarget = assignDistributionSetWithMaintenanceWindow(ds.getId(), savedTarget.getControllerId(),
getTestSchedule(-5), getTestDuration(10), getTestTimeZone()).getAssignedEntity().iterator().next();
savedTarget = getFirstAssignedTarget(assignDistributionSetWithMaintenanceWindow(ds.getId(),
savedTarget.getControllerId(), getTestSchedule(-5), getTestDuration(10), getTestTimeZone()));
mvc.perform(get("/default-tenant/controller/v1/1911/")).andExpect(status().isOk());
@@ -662,12 +658,12 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
final Target target = testdataFactory.createTarget();
final DistributionSet ds1 = testdataFactory.createDistributionSet(UUID.randomUUID().toString());
final DistributionSet ds2 = testdataFactory.createDistributionSet(UUID.randomUUID().toString());
final Action action1 = assignDistributionSet(ds1, target).getActions().get(0);
final Action action2 = assignDistributionSet(ds2, target).getActions().get(0);
final Action action1 = getFirstAssignedAction(assignDistributionSet(ds1, target));
final Long action2Id = getFirstAssignedActionId(assignDistributionSet(ds2, target));
assertDeploymentActionIsExposedToTarget(target.getControllerId(), action1.getId());
sendDeploymentActionFeedback(target, action1, "closed", "success");
assertDeploymentActionIsExposedToTarget(target.getControllerId(), action2.getId());
assertDeploymentActionIsExposedToTarget(target.getControllerId(), action2Id);
}

View File

@@ -13,7 +13,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.eclipse.hawkbit.repository.model.Action;
@@ -156,9 +156,9 @@ public class DosFilterTest extends AbstractDDiApiIntegrationTest {
private Long prepareDeploymentBase() {
final DistributionSet ds = testdataFactory.createDistributionSet("test");
final Target target = testdataFactory.createTarget("4711");
final List<Target> toAssign = Arrays.asList(target);
final List<Target> toAssign = Collections.singletonList(target);
final Iterable<Target> saved = assignDistributionSet(ds, toAssign).getAssignedEntity();
assignDistributionSet(ds, toAssign);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId())).hasSize(1);
final Action uaction = deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId())

View File

@@ -0,0 +1,65 @@
/**
* Copyright (c) 2019 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.mgmt.json.model.distributionset;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi;
import org.springframework.hateoas.ResourceSupport;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects;
/**
* Representation of an Action Id as a Json Object with link to the Action resource
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtActionId extends ResourceSupport {
private long actionId;
public MgmtActionId() {
}
/**
* Constructor
* @param actionId
* the actionId
* @param controllerId
* the controller Id
*/
public MgmtActionId(final String controllerId, final long actionId) {
this.actionId = actionId;
add(linkTo(methodOn(MgmtTargetRestApi.class).getAction(controllerId, actionId)).withSelfRel());
}
@JsonProperty("id")
public long getActionId() {
return actionId;
}
public void setActionId(final long actionId) {
this.actionId = actionId;
}
@Override
public boolean equals(final Object obj) {
return super.equals(obj) && this.getClass().isInstance(obj) && actionId == ((MgmtActionId) obj).getActionId();
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), actionId);
}
}

View File

@@ -8,9 +8,14 @@
*/
package org.eclipse.hawkbit.mgmt.json.model.distributionset;
import java.util.List;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.hateoas.ResourceSupport;
/**
* Response Body of Target for assignment operations.
@@ -20,25 +25,17 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtTargetAssignmentResponseBody {
public class MgmtTargetAssignmentResponseBody extends ResourceSupport {
private int assigned;
private int alreadyAssigned;
private int total;
private List<MgmtActionId> assignedActions;
/**
* @return the assigned
* @return the count of assigned targets
*/
@JsonProperty("assigned")
public int getAssigned() {
return assigned;
}
/**
* @param assigned
* the assigned to set
*/
public void setAssigned(final int assigned) {
this.assigned = assigned;
return assignedActions == null ? 0 : assignedActions.size();
}
/**
@@ -59,15 +56,35 @@ public class MgmtTargetAssignmentResponseBody {
/**
* @return the total
*/
@JsonProperty("total")
public int getTotal() {
return total;
return getAssigned() + alreadyAssigned;
}
/**
* @param total
* the total to set
* @return the assignedActions
*/
public void setTotal(final int total) {
this.total = total;
public List<MgmtActionId> getAssignedActions() {
return assignedActions;
}
/**
* @param assignedActions
* the assigned actions to set
*/
public void setAssignedActions(final List<MgmtActionId> assignedActions) {
this.assignedActions = assignedActions;
}
@Override
public boolean equals(final Object obj) {
return super.equals(obj) && this.getClass().isInstance(obj)
&& ((MgmtTargetAssignmentResponseBody) obj).getAlreadyAssigned() == alreadyAssigned
&& Objects.equals(((MgmtTargetAssignmentResponseBody) obj).getAssignedActions(), assignedActions);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), alreadyAssigned, assignedActions);
}
}

View File

@@ -0,0 +1,79 @@
/**
* Copyright (c) 2019 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.mgmt.json.model.distributionset;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import io.qameta.allure.Story;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Description;
@Story("Retrieve all open action ids")
@Description("Tests for the MgmtTargetAssignmentResponseBody")
public class MgmtTargetAssignmentResponseBodyTest {
private static final List<Long> ASSIGNED_ACTIONS = Arrays.asList(4L, 5L, 6L);
private static final int ALREADY_ASSIGNED_COUNT = 3;
private static final String CONTROLLER_ID = "target";
@Test
@Description("Tests that the ActionIds are serialized correctly in MgmtTargetAssignmentResponseBody")
public void testActionIdsSerialization() throws IOException {
final MgmtTargetAssignmentResponseBody responseBody = generateResponseBody();
final ObjectMapper objectMapper = new ObjectMapper();
final String responseBodyAsString = objectMapper.writeValueAsString(responseBody);
final JsonNode jsonNode = objectMapper.readTree(responseBodyAsString);
assertThat(jsonNode.has("assigned")).as("the assigned targets count").isTrue();
assertThat(jsonNode.get("assigned").isNumber()).as("the assigned targets count").isTrue();
assertThat(jsonNode.get("assigned").asLong()).as("the assigned targets count")
.isEqualTo(ASSIGNED_ACTIONS.size());
assertThat(jsonNode.has("alreadyAssigned")).as("the already assigned targets count").isTrue();
assertThat(jsonNode.get("alreadyAssigned").isNumber()).as("the already assigned targets count").isTrue();
assertThat(jsonNode.get("alreadyAssigned").asLong()).as("the already assigned targets count")
.isEqualTo(ALREADY_ASSIGNED_COUNT);
assertThat(jsonNode.has("total")).as("the total targets count").isTrue();
assertThat(jsonNode.get("total").isNumber()).as("the total targets count").isTrue();
assertThat(jsonNode.get("total").asLong()).as("the total targets count")
.isEqualTo(ALREADY_ASSIGNED_COUNT + ASSIGNED_ACTIONS.size());
assertThat(jsonNode.has("assignedActions")).as("The created actions in result of this assignment").isTrue();
assertThat(jsonNode.get("assignedActions").isArray()).as("The created actions in result of this assignment")
.isTrue();
assertThat(jsonNode.get("assignedActions").size()).as("The created actions in result of this assignment")
.isEqualTo(3);
assertThat(jsonNode.get("assignedActions").get(0).isObject())
.as("A created action in result of this assignment").isTrue();
assertThat(jsonNode.get("assignedActions").get(0).has("id")).as("A created action in result of this assignment")
.isTrue();
assertThat(jsonNode.get("assignedActions").get(0).get("id").isNumber())
.as("A created action in result of this assignment").isTrue();
assertThat(ASSIGNED_ACTIONS).as("The expected action ids")
.contains(jsonNode.get("assignedActions").get(0).get("id").asLong());
}
private static MgmtTargetAssignmentResponseBody generateResponseBody() {
MgmtTargetAssignmentResponseBody response = new MgmtTargetAssignmentResponseBody();
response.setAssignedActions(
ASSIGNED_ACTIONS.stream().map(id -> new MgmtActionId(CONTROLLER_ID, id)).collect(Collectors.toList()));
response.setAlreadyAssigned(ALREADY_ASSIGNED_COUNT);
return response;
}
}

View File

@@ -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;
}

View File

@@ -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)))));

View File

@@ -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();

View File

@@ -577,6 +577,9 @@ include::{snippets}/targets/post-assign-distribution-set-to-target/http-request.
=== Response (Status 200)
==== Response fields
include::{snippets}/targets/post-assign-distribution-set-to-target/response-fields.adoc[]
==== Response example
include::{snippets}/targets/post-assign-distribution-set-to-target/http-response.adoc[]

View File

@@ -137,9 +137,8 @@ public class RootControllerDocumentationTest extends AbstractApiRestDocumentatio
});
final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID));
final Long actionId = deploymentManagement
.assignDistributionSet(set.getId(), Arrays.asList(target.getTargetWithActionType())).getActionIds()
.get(0);
final Long actionId = getFirstAssignedActionId(deploymentManagement.assignDistributionSet(set.getId(),
Arrays.asList(target.getTargetWithActionType())));
final Action cancelAction = deploymentManagement.cancelAction(actionId);
mockMvc.perform(
@@ -170,9 +169,8 @@ public class RootControllerDocumentationTest extends AbstractApiRestDocumentatio
final DistributionSet set = testdataFactory.createDistributionSet("one");
final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID));
final Long actionId = deploymentManagement
.assignDistributionSet(set.getId(), Arrays.asList(target.getTargetWithActionType())).getActionIds()
.get(0);
final Long actionId = getFirstAssignedActionId(deploymentManagement.assignDistributionSet(set.getId(),
Arrays.asList(target.getTargetWithActionType())));
final Action cancelAction = deploymentManagement.cancelAction(actionId);
mockMvc.perform(post(
@@ -264,8 +262,8 @@ public class RootControllerDocumentationTest extends AbstractApiRestDocumentatio
.key("aMetadataKey").value("Metadata value as defined in software module").targetVisible(true));
final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID));
final Long actionId = assignDistributionSetWithMaintenanceWindow(set.getId(), target.getControllerId(),
getTestSchedule(-5), getTestDuration(10), getTestTimeZone()).getActionIds().get(0);
final Long actionId = getFirstAssignedActionId(assignDistributionSetWithMaintenanceWindow(set.getId(),
target.getControllerId(), getTestSchedule(-5), getTestDuration(10), getTestTimeZone()));
controllerManagement.addInformationalActionStatus(
entityFactory.actionStatus().create(actionId).message("Started download").status(Status.DOWNLOAD));
@@ -348,8 +346,8 @@ public class RootControllerDocumentationTest extends AbstractApiRestDocumentatio
final DistributionSet set = testdataFactory.createDistributionSet("one");
final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID));
final Long actionId = assignDistributionSetWithMaintenanceWindow(set.getId(), target.getControllerId(),
getTestSchedule(2), getTestDuration(1), getTestTimeZone()).getActionIds().get(0);
final Long actionId = getFirstAssignedActionId(assignDistributionSetWithMaintenanceWindow(set.getId(),
target.getControllerId(), getTestSchedule(2), getTestDuration(1), getTestTimeZone()));
mockMvc.perform(get(
DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.DEPLOYMENT_BASE_ACTION
@@ -389,9 +387,8 @@ public class RootControllerDocumentationTest extends AbstractApiRestDocumentatio
final DistributionSet set = testdataFactory.createDistributionSet("one");
final Target target = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID));
final Long actionId = deploymentManagement
.assignDistributionSet(set.getId(), Arrays.asList(target.getTargetWithActionType())).getActionIds()
.get(0);
final Long actionId = getFirstAssignedActionId(deploymentManagement.assignDistributionSet(set.getId(),
Arrays.asList(target.getTargetWithActionType())));
mockMvc.perform(post(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/"
+ DdiRestConstants.DEPLOYMENT_BASE_ACTION + "/{actionId}/feedback", tenantAware.getCurrentTenant(),

View File

@@ -20,6 +20,7 @@ import static org.springframework.restdocs.snippet.Attributes.key;
import java.io.ByteArrayInputStream;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.RandomStringUtils;
import org.eclipse.hawkbit.ddi.rest.resource.DdiApiConfiguration;
@@ -167,20 +168,23 @@ public abstract class AbstractApiRestDocumentation extends AbstractRestIntegrati
private List<Target> assignWithoutMaintenanceWindow(final DistributionSet distributionSet, final Target savedTarget,
final boolean timeforced) {
return timeforced ? assignDistributionSetTimeForced(distributionSet, savedTarget).getAssignedEntity()
final List<Action> actions = timeforced
? assignDistributionSetTimeForced(distributionSet, savedTarget).getAssignedEntity()
: assignDistributionSet(distributionSet, savedTarget).getAssignedEntity();
return actions.stream().map(Action::getTarget).collect(Collectors.toList());
}
private List<Target> assignWithMaintenanceWindow(final DistributionSet distributionSet, final Target savedTarget,
final boolean timeforced, final String maintenanceWindowSchedule, final String maintenanceWindowDuration,
final String maintenanceWindowTimeZone) {
return timeforced
final List<Action> actions = timeforced
? assignDistributionSetWithMaintenanceWindowTimeForced(distributionSet.getId(),
savedTarget.getControllerId(), maintenanceWindowSchedule, maintenanceWindowDuration,
maintenanceWindowTimeZone).getAssignedEntity()
: assignDistributionSetWithMaintenanceWindow(distributionSet.getId(), savedTarget.getControllerId(),
maintenanceWindowSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone)
.getAssignedEntity();
return actions.stream().map(Action::getTarget).collect(Collectors.toList());
}
protected DistributionSet createDistributionSet() {

View File

@@ -211,4 +211,5 @@ public final class MgmtApiModelProperties {
public static final String CONFIG_GLOBAL = "true - if the current value is the global configuration value, false - if there is a tenant specific value configured.";
public static final String CONFIG_PARAM = "The name of the configuration parameter.";
public static final String DS_NEW_ASSIGNED_ACTIONS = "The newly created actions as a result of this assignment";
}

View File

@@ -23,9 +23,11 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.im.authentication.SpPermission;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
@@ -306,7 +308,8 @@ public class DistributionSetsDocumentationTest extends AbstractApiRestDocumentat
final DistributionSet set = testdataFactory.createUpdatedDistributionSet();
final List<Target> targets = assignDistributionSet(set,
testdataFactory.createTargets(5, "targetMisc", "Test targets for query")).getAssignedEntity();
testdataFactory.createTargets(5, "targetMisc", "Test targets for query")).getAssignedEntity().stream()
.map(Action::getTarget).collect(Collectors.toList());
testdataFactory.sendUpdateActionStatusToTargets(targets, Status.FINISHED, "some message");
mockMvc.perform(
@@ -396,6 +399,12 @@ public class DistributionSetsDocumentationTest extends AbstractApiRestDocumentat
fieldWithPath("assigned").description(MgmtApiModelProperties.DS_NEW_ASSIGNED_TARGETS),
fieldWithPath("alreadyAssigned").type(JsonFieldType.NUMBER)
.description(MgmtApiModelProperties.DS_ALREADY_ASSIGNED_TARGETS),
fieldWithPath("assignedActions").type(JsonFieldType.ARRAY)
.description(MgmtApiModelProperties.DS_NEW_ASSIGNED_ACTIONS),
fieldWithPath("assignedActions.[].id").type(JsonFieldType.NUMBER)
.description(MgmtApiModelProperties.ACTION_ID),
fieldWithPath("assignedActions.[]._links.self").type(JsonFieldType.OBJECT)
.description(MgmtApiModelProperties.LINK_TO_ACTION),
fieldWithPath("total").type(JsonFieldType.NUMBER)
.description(MgmtApiModelProperties.DS_TOTAL_ASSIGNED_TARGETS))));
}

View File

@@ -24,7 +24,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -395,9 +395,8 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
public void switchActionToForced() throws Exception {
final Target target = testdataFactory.createTarget(targetId);
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 Map<String, Object> body = new HashMap<>();
@@ -490,8 +489,12 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
@Test
@Description("Handles the POST request for assigning a distribution set to a specific target. Required Permission: READ_REPOSITORY and UPDATE_TARGET.")
public void postAssignDistributionSetToTarget() throws Exception {
testdataFactory.createTarget(targetId);
// create target and ds, and assign ds
testdataFactory.createTarget(targetId + "-old");
final DistributionSet set = testdataFactory.createDistributionSet("one");
assignDistributionSet(set.getId(), targetId + "-old");
testdataFactory.createTarget(targetId);
final long forceTime = System.currentTimeMillis();
final String body = new JSONObject().put("id", set.getId()).put("type", "timeforced")
@@ -502,7 +505,7 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
mockMvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/"
+ MgmtRestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET, targetId).content(body)
.contentType(MediaType.APPLICATION_JSON_UTF8))
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andDo(this.document.document(
pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)),
@@ -524,6 +527,12 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
fieldWithPath("assigned").description(MgmtApiModelProperties.DS_NEW_ASSIGNED_TARGETS),
fieldWithPath("alreadyAssigned").type(JsonFieldType.NUMBER)
.description(MgmtApiModelProperties.DS_ALREADY_ASSIGNED_TARGETS),
fieldWithPath("assignedActions").type(JsonFieldType.ARRAY)
.description(MgmtApiModelProperties.DS_NEW_ASSIGNED_ACTIONS),
fieldWithPath("assignedActions.[].id").type(JsonFieldType.NUMBER)
.description(MgmtApiModelProperties.ACTION_ID),
fieldWithPath("assignedActions.[]._links.self").type(JsonFieldType.OBJECT)
.description(MgmtApiModelProperties.LINK_TO_ACTION),
fieldWithPath("total").type(JsonFieldType.NUMBER)
.description(MgmtApiModelProperties.DS_TOTAL_ASSIGNED_TARGETS))));
}
@@ -630,7 +639,7 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
final String knownValue = "knownValue";
final Target testTarget = testdataFactory.createTarget(targetId);
targetManagement.createMetaData(testTarget.getControllerId(),
Arrays.asList(entityFactory.generateTargetMetadata(knownKey, knownValue)));
Collections.singletonList(entityFactory.generateTargetMetadata(knownKey, knownValue)));
mockMvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata/{metadatakey}",
testTarget.getControllerId(), knownKey)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
@@ -652,7 +661,7 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
final Target testTarget = testdataFactory.createTarget(targetId);
targetManagement.createMetaData(testTarget.getControllerId(),
Arrays.asList(entityFactory.generateTargetMetadata(knownKey, knownValue)));
Collections.singletonList(entityFactory.generateTargetMetadata(knownKey, knownValue)));
final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue);
@@ -679,7 +688,7 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
final Target testTarget = testdataFactory.createTarget(targetId);
targetManagement.createMetaData(testTarget.getControllerId(),
Arrays.asList(entityFactory.generateTargetMetadata(knownKey, knownValue)));
Collections.singletonList(entityFactory.generateTargetMetadata(knownKey, knownValue)));
mockMvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata/{key}",
testTarget.getControllerId(), knownKey)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())