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

@@ -493,8 +493,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertThat(
controllerManagement.hasTargetArtifactAssigned(savedTarget.getControllerId(), artifact.getSha1Hash()))
.isFalse();
savedTarget = assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getAssignedEntity().iterator()
.next();
savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
assertThat(
controllerManagement.hasTargetArtifactAssigned(savedTarget.getControllerId(), artifact.getSha1Hash()))
.isTrue();
@@ -1056,7 +1055,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
final DistributionSet testDs = testdataFactory.createDistributionSet("1");
final List<Target> testTarget = testdataFactory.createTargets(1);
final Long actionId = assignDistributionSet(testDs, testTarget).getActionIds().get(0);
final Long actionId = getFirstAssignedActionId(assignDistributionSet(testDs, testTarget));
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId)
.status(Action.Status.RUNNING).messages(Lists.newArrayList("proceeding message 1")));
@@ -1084,8 +1083,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
final int maxStatusEntries = quotaManagement.getMaxStatusEntriesPerAction() - 1;
// test for informational status
final Long actionId1 = assignDistributionSet(testdataFactory.createDistributionSet("ds1"),
testdataFactory.createTargets(1, "t1")).getActionIds().get(0);
final Long actionId1 = getFirstAssignedActionId(assignDistributionSet(
testdataFactory.createDistributionSet("ds1"), testdataFactory.createTargets(1, "t1")));
assertThat(actionId1).isNotNull();
for (int i = 0; i < maxStatusEntries; ++i) {
controllerManagement.addInformationalActionStatus(entityFactory.actionStatus().create(actionId1)
@@ -1095,8 +1094,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
.addInformationalActionStatus(entityFactory.actionStatus().create(actionId1).status(Status.WARNING)));
// test for update status (and mixed case)
final Long actionId2 = assignDistributionSet(testdataFactory.createDistributionSet("ds2"),
testdataFactory.createTargets(1, "t2")).getActionIds().get(0);
final Long actionId2 = getFirstAssignedActionId(assignDistributionSet(
testdataFactory.createDistributionSet("ds2"), testdataFactory.createTargets(1, "t2")));
assertThat(actionId2).isNotEqualTo(actionId1);
for (int i = 0; i < maxStatusEntries; ++i) {
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId2)
@@ -1118,8 +1117,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
final int maxMessages = quotaManagement.getMaxMessagesPerActionStatus();
final Long actionId = assignDistributionSet(testdataFactory.createDistributionSet("ds1"),
testdataFactory.createTargets(1)).getActionIds().get(0);
final Long actionId = getFirstAssignedActionId(
assignDistributionSet(testdataFactory.createDistributionSet("ds1"), testdataFactory.createTargets(1)));
assertThat(actionId).isNotNull();
final List<String> messages = Lists.newArrayList();
@@ -1331,7 +1330,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
testdataFactory.createTarget(knownControllerId);
final DistributionSetAssignmentResult assignmentResult = deploymentManagement.assignDistributionSet(
knownDistributionSet.getId(), ActionType.FORCED, 0, Collections.singleton(knownControllerId));
final Long actionId = assignmentResult.getActionIds().get(0);
final Long actionId = getFirstAssignedActionId(assignmentResult);
controllerManagement.updateActionExternalRef(actionId, knownExternalref);
allExternalRef.add(knownExternalref);
@@ -1432,7 +1431,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
final Long forcedDistributionSetId = testdataFactory.createDistributionSet("forcedDs1").getId();
final DistributionSetAssignmentResult assignmentResult = assignDistributionSet(forcedDistributionSetId,
DEFAULT_CONTROLLER_ID, Action.ActionType.SOFT);
addUpdateActionStatus(assignmentResult.getActions().get(0).getId(), DEFAULT_CONTROLLER_ID, Status.FINISHED);
addUpdateActionStatus(getFirstAssignedActionId(assignmentResult), DEFAULT_CONTROLLER_ID, Status.FINISHED);
assertAssignedDistributionSetId(DEFAULT_CONTROLLER_ID, forcedDistributionSetId);
assertInstalledDistributionSetId(DEFAULT_CONTROLLER_ID, forcedDistributionSetId);
assertNoActiveActionsExistsForControllerId(DEFAULT_CONTROLLER_ID);
@@ -1472,4 +1471,4 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertThat(actionRepository.activeActionExistsForControllerId(controllerId)).isEqualTo(false);
}
}
}

View File

@@ -98,13 +98,14 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
final Target target = testdataFactory.createTarget();
final String dsName = "DistributionSet";
verifyThrownExceptionBy(() -> deploymentManagement.assignDistributionSet(NOT_EXIST_IDL,
Arrays.asList(new TargetWithActionType(target.getControllerId()))), "DistributionSet");
Collections.singletonList(new TargetWithActionType(target.getControllerId()))), dsName);
verifyThrownExceptionBy(() -> deploymentManagement.assignDistributionSet(NOT_EXIST_IDL,
Arrays.asList(new TargetWithActionType(target.getControllerId())), "xxx"), "DistributionSet");
Collections.singletonList(new TargetWithActionType(target.getControllerId())), "xxx"), dsName);
verifyThrownExceptionBy(() -> deploymentManagement.assignDistributionSet(NOT_EXIST_IDL, ActionType.FORCED,
System.currentTimeMillis(), Arrays.asList(target.getControllerId())), "DistributionSet");
System.currentTimeMillis(), Collections.singletonList(target.getControllerId())), dsName);
verifyThrownExceptionBy(() -> deploymentManagement.cancelAction(NOT_EXIST_IDL), "Action");
verifyThrownExceptionBy(() -> deploymentManagement.countActionsByTarget(NOT_EXIST_ID), "Target");
@@ -128,7 +129,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
new ArrayList<DistributionSetTag>());
final List<Target> testTarget = testdataFactory.createTargets(1);
// one action with one action status is generated
final Long actionId = assignDistributionSet(testDs, testTarget).getActionIds().get(0);
final Long actionId = getFirstAssignedActionId(assignDistributionSet(testDs, testTarget));
final Action action = deploymentManagement.findActionWithDetails(actionId).get();
assertThat(action.getDistributionSet()).as("DistributionSet in action").isNotNull();
@@ -145,7 +146,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
new ArrayList<DistributionSetTag>());
final List<Target> testTarget = testdataFactory.createTargets(1);
// one action with one action status is generated
final Long actionId = assignDistributionSet(testDs, testTarget).getActionIds().get(0);
final Long actionId = getFirstAssignedActionId(assignDistributionSet(testDs, testTarget));
// act
final Slice<Action> actions = deploymentManagement.findActionsByTarget(testTarget.get(0).getControllerId(),
@@ -190,11 +191,10 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test
@Description("Test verifies that action-states of an action are found by using id-based search.")
public void findActionStatusByActionId() {
final DistributionSet testDs = testdataFactory.createDistributionSet("TestDs", "1.0",
new ArrayList<DistributionSetTag>());
final DistributionSet testDs = testdataFactory.createDistributionSet("TestDs", "1.0", Collections.emptyList());
final List<Target> testTarget = testdataFactory.createTargets(1);
// one action with one action status is generated
final Long actionId = assignDistributionSet(testDs, testTarget).getActionIds().get(0);
final Long actionId = getFirstAssignedActionId(assignDistributionSet(testDs, testTarget));
final Slice<Action> actions = deploymentManagement.findActionsByTarget(testTarget.get(0).getControllerId(),
PAGE);
final ActionStatus expectedActionStatus = ((JpaAction) actions.getContent().get(0)).getActionStatus().get(0);
@@ -213,10 +213,10 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
new ArrayList<DistributionSetTag>());
final List<Target> testTarget = testdataFactory.createTargets(1);
// one action with one action status is generated
final Long actionId = assignDistributionSet(testDs, testTarget).getActionIds().get(0);
final Long actionId = getFirstAssignedActionId(assignDistributionSet(testDs, testTarget));
// create action-status entry with one message
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId)
.status(Action.Status.FINISHED).messages(Arrays.asList("finished message")));
.status(Action.Status.FINISHED).messages(Collections.singletonList("finished message")));
final Page<ActionStatus> actionStates = deploymentManagement.findActionStatusByAction(PAGE, actionId);
// find newly created action-status entry with message
@@ -465,12 +465,14 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
final long current = System.currentTimeMillis();
final List<Target> targets = deploymentManagement.offlineAssignedDistributionSet(ds.getId(), controllerIds)
.getAssignedEntity();
.getAssignedEntity().stream().map(Action::getTarget).collect(Collectors.toList());;
assertThat(actionRepository.count()).isEqualTo(20);
assertThat(actionRepository.findByDistributionSetId(PAGE, ds.getId())).as("Offline actions are not active")
.allMatch(action -> !action.isActive());
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, ds.getId()).getContent()).containsAll(targets)
.hasSize(10).containsAll(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId()))
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, ds.getId()).getContent())
.usingElementComparator(controllerIdComparator()).containsAll(targets).hasSize(10)
.containsAll(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId()))
.as("InstallationDate set").allMatch(target -> target.getInstallationDate() >= current)
.as("TargetUpdateStatus IN_SYNC")
.allMatch(target -> TargetUpdateStatus.IN_SYNC.equals(target.getUpdateStatus()))
@@ -630,7 +632,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
final SoftwareModule os = testdataFactory.createSoftwareModuleOs();
final DistributionSet incomplete = distributionSetManagement.create(entityFactory.distributionSet().create()
.name("incomplete").version("v1").type(standardDsType).modules(Arrays.asList(ah.getId())));
.name("incomplete").version("v1").type(standardDsType).modules(Collections.singletonList(ah.getId())));
try {
assignDistributionSet(incomplete, targets);
@@ -698,7 +700,9 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
// test the content of different lists
assertThat(allFoundTargets).as("content of founded target is wrong").containsAll(deployedTargetsFromDB)
.containsAll(undeployedTargetsFromDB);
assertThat(deployedTargetsFromDB).as("content of deployed target is wrong").containsAll(savedDeployedTargets)
assertThat(deployedTargetsFromDB).as("content of deployed target is wrong")
.usingElementComparator(controllerIdComparator()).containsAll(savedDeployedTargets)
.doesNotContain(Iterables.toArray(undeployedTargetsFromDB, JpaTarget.class));
assertThat(undeployedTargetsFromDB).as("content of undeployed target is wrong").containsAll(savedNakedTargets)
.doesNotContain(Iterables.toArray(deployedTargetsFromDB, JpaTarget.class));
@@ -769,15 +773,16 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
// remove updActB from
// activeActions, add a corresponding cancelAction and another
// UpdateAction for dsA
final Iterable<Target> deployed2DS = assignDistributionSet(dsA, deployResWithDsB.getDeployedTargets())
.getAssignedEntity();
final List<Target> deployed2DS = assignDistributionSet(dsA, deployResWithDsB.getDeployedTargets())
.getAssignedEntity().stream().map(Action::getTarget).collect(Collectors.toList());
actionRepository.findByDistributionSetId(pageRequest, dsA.getId()).getContent().get(1);
// get final updated version of targets
final List<Target> deployResWithDsBTargets = targetManagement.getByControllerID(deployResWithDsB
.getDeployedTargets().stream().map(Target::getControllerId).collect(Collectors.toList()));
assertThat(deployed2DS).as("deployed ds is wrong").containsAll(deployResWithDsBTargets);
assertThat(deployed2DS).as("deployed ds is wrong").usingElementComparator(controllerIdComparator())
.containsAll(deployResWithDsBTargets);
assertThat(deployed2DS).as("deployed ds is wrong").hasSameSizeAs(deployResWithDsBTargets);
for (final Target t_ : deployed2DS) {
@@ -892,10 +897,11 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
final DistributionSet dsA = testdataFactory.createDistributionSet("a");
final DistributionSet dsB = testdataFactory.createDistributionSet("b");
List<Target> targs = Arrays.asList(testdataFactory.createTarget("target-id-A"));
List<Target> targs = Collections.singletonList(testdataFactory.createTarget("target-id-A"));
// doing the assignment
targs = assignDistributionSet(dsA, targs).getAssignedEntity();
targs = assignDistributionSet(dsA, targs).getAssignedEntity().stream().map(Action::getTarget)
.collect(Collectors.toList());
Target targ = targetManagement.getByControllerID(targs.iterator().next().getControllerId()).get();
// checking the revisions of the created entities
@@ -934,7 +940,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
assertEquals("wrong installed ds", dsA,
deploymentManagement.getInstalledDistributionSet(targ.getControllerId()).get());
targs = assignDistributionSet(dsB.getId(), "target-id-A").getAssignedEntity();
targs = assignDistributionSet(dsB.getId(), "target-id-A").getAssignedEntity().stream().map(Action::getTarget)
.collect(Collectors.toList());
targ = targs.iterator().next();
@@ -962,7 +969,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong")
.isEqualTo(distributionSetManagement.getWithDetails(dsA.getId()).get().getOptLockRevision());
assignDistributionSet(dsA, Arrays.asList(targ));
assignDistributionSet(dsA, Collections.singletonList(targ));
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong")
.isEqualTo(distributionSetManagement.getWithDetails(dsA.getId()).get().getOptLockRevision());
@@ -978,8 +985,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement.assignDistributionSet(
ds.getId(), ActionType.SOFT,
org.eclipse.hawkbit.repository.model.RepositoryModelConstants.NO_FORCE_TIME,
Arrays.asList(target.getControllerId()));
final Long actionId = assignDistributionSet.getActionIds().get(0);
Collections.singletonList(target.getControllerId()));
final Long actionId = getFirstAssignedActionId(assignDistributionSet);
// verify preparation
Action findAction = deploymentManagement.findAction(actionId).get();
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.SOFT);
@@ -1002,8 +1009,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement.assignDistributionSet(
ds.getId(), ActionType.FORCED,
org.eclipse.hawkbit.repository.model.RepositoryModelConstants.NO_FORCE_TIME,
Arrays.asList(target.getControllerId()));
final Long actionId = assignDistributionSet.getActionIds().get(0);
Collections.singletonList(target.getControllerId()));
final Long actionId = getFirstAssignedActionId(assignDistributionSet);
// verify perparation
Action findAction = deploymentManagement.findAction(actionId).get();
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED);
@@ -1016,6 +1023,50 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
findAction = deploymentManagement.findAction(actionId).get();
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED);
}
@Test
@Description("Tests the computation of already assigned entities returned as a result of an assignment")
public void testAlreadyAssignedAndAssignedActionsInAssignmentResult(){
// create target1, distributionSet, assign ds to target1 and finish update (close all actions)
final Action action = prepareFinishedUpdate("target1", "ds", false);
final Target target2 = testdataFactory.createTarget("target2");
final Target target3 = testdataFactory.createTarget("target3");
// assign ds to target2, but don't finish update (actions should be still open)
assignDistributionSet(action.getDistributionSet().getId(), target2.getControllerId());
final DistributionSetAssignmentResult assignmentResult = deploymentManagement.assignDistributionSet(
action.getDistributionSet().getId(),
Arrays.asList(new TargetWithActionType(action.getTarget().getControllerId()),
new TargetWithActionType(target3.getControllerId())));
assertThat(assignmentResult).isNotNull();
assertThat(assignmentResult.getTotal()).as("Total count of assigned and already assigned targets").isEqualTo(2);
assertThat(assignmentResult.getAssigned()).as("Total count of assigned targets").isEqualTo(1);
assertThat(assignmentResult.getAlreadyAssigned()).as("Total count of already assigned targets").isEqualTo(1);
assertThat(assignmentResult.getAssignedEntity()).isNotEmpty();
assertThat(assignmentResult.getAssignedEntity()).allMatch(
a -> a.getTarget().equals(target3) && a.getDistributionSet().equals(action.getDistributionSet()));
assertThat(assignmentResult.getAssignedEntity())
.noneMatch(a -> a.getTarget().getControllerId().equals("target1"));
}
@Test
@Description("Verify that the DistributionSetAssignmentResult not contains already assigned targets.")
public void verifyDistributionSetAssignmentResultNotContainsAlreadyAssignedTargets() {
final DistributionSet dsToTargetAssigned = testdataFactory.createDistributionSet("ds-3");
// create assigned DS
final Target savedTarget = testdataFactory.createTarget();
DistributionSetAssignmentResult assignmentResult = assignDistributionSet(dsToTargetAssigned.getId(),
savedTarget.getControllerId());
assertThat(assignmentResult.getAssignedEntity()).hasSize(1);
assignmentResult = assignDistributionSet(dsToTargetAssigned.getId(), savedTarget.getControllerId());
assertThat(assignmentResult.getAssignedEntity()).hasSize(0);
assertThat(distributionSetRepository.findAll()).hasSize(1);
}
/**
* Helper methods that creates 2 lists of targets and a list of distribution
@@ -1059,7 +1110,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
// assigning all DistributionSet to the Target in the list
// deployedTargets
for (final DistributionSet ds : dsList) {
deployedTargets = assignDistributionSet(ds, deployedTargets).getAssignedEntity();
deployedTargets = assignDistributionSet(ds, deployedTargets).getAssignedEntity().stream()
.map(Action::getTarget).collect(Collectors.toList());
}
return new DeploymentResult(deployedTargets, nakedTargets, dsList, deployedTargetPrefix, undeployedTargetPrefix,

View File

@@ -40,7 +40,6 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult;
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
@@ -993,23 +992,6 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
assertThat(distributionSetManagement.findByCompleted(PAGE, true).getTotalElements()).isEqualTo(2);
}
@Test
@Description("Verify that the DistributionSetAssignmentResult not contains already assigned targets.")
public void verifyDistributionSetAssignmentResultNotContainsAlreadyAssignedTargets() {
final DistributionSet dsToTargetAssigned = testdataFactory.createDistributionSet("ds-3");
// create assigned DS
final Target savedTarget = testdataFactory.createTarget();
DistributionSetAssignmentResult assignmentResult = assignDistributionSet(dsToTargetAssigned.getId(),
savedTarget.getControllerId());
assertThat(assignmentResult.getAssignedEntity()).hasSize(1);
assignmentResult = assignDistributionSet(dsToTargetAssigned.getId(), savedTarget.getControllerId());
assertThat(assignmentResult.getAssignedEntity()).hasSize(0);
assertThat(distributionSetRepository.findAll()).hasSize(1);
}
@Test
@Description("Verify that the find all by ids contains the entities which are looking for")
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 12),

View File

@@ -104,7 +104,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
testdataFactory.createTarget(knownControllerId);
final DistributionSetAssignmentResult assignmentResult = deploymentManagement.assignDistributionSet(
knownDistributionSet.getId(), ActionType.FORCED, 0, Collections.singleton(knownControllerId));
final Long manuallyAssignedActionId = assignmentResult.getActionIds().get(0);
final Long manuallyAssignedActionId = getFirstAssignedActionId(assignmentResult);
// create rollout with the same distribution set already assigned
// start rollout
@@ -144,7 +144,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
testdataFactory.createTarget(knownControllerId);
final DistributionSetAssignmentResult assignmentResult = deploymentManagement.assignDistributionSet(
firstDistributionSet.getId(), ActionType.FORCED, 0, Collections.singleton(knownControllerId));
final Long manuallyAssignedActionId = assignmentResult.getActionIds().get(0);
final Long manuallyAssignedActionId = getFirstAssignedActionId(assignmentResult);
// create rollout with the same distribution set already assigned
// start rollout

View File

@@ -96,7 +96,7 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String assignedB = targBs.iterator().next().getControllerId();
assignDistributionSet(setA.getId(), assignedB);
final String installedC = targCs.iterator().next().getControllerId();
final Long actionId = assignDistributionSet(installedSet.getId(), assignedC).getActionIds().get(0);
final Long actionId = getFirstAssignedActionId(assignDistributionSet(installedSet.getId(), assignedC));
// add attributes to match against only attribute value or attribute
// value and name
@@ -578,8 +578,10 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final DistributionSet ds = testdataFactory.createDistributionSet("a");
targAssigned = Lists.newLinkedList(assignDistributionSet(ds, targAssigned).getAssignedEntity());
targInstalled = assignDistributionSet(ds, targInstalled).getAssignedEntity();
targAssigned = assignDistributionSet(ds, targAssigned).getAssignedEntity().stream().map(Action::getTarget)
.collect(Collectors.toList());
targInstalled = assignDistributionSet(ds, targInstalled).getAssignedEntity().stream().map(Action::getTarget)
.collect(Collectors.toList());
targInstalled = testdataFactory
.sendUpdateActionStatusToTargets(targInstalled, Status.FINISHED, Collections.singletonList("installed"))
.stream().map(Action::getTarget).collect(Collectors.toList());
@@ -598,7 +600,8 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
expected.addAll(targAssigned);
expected.addAll(notAssigned);
assertThat(result.getContent()).containsExactly(expected.toArray(new Target[0]));
assertThat(result.getContent()).usingElementComparator(controllerIdComparator())
.containsExactly(expected.toArray(new Target[0]));
}
@@ -628,8 +631,10 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final DistributionSet ds = testdataFactory.createDistributionSet("a");
targAssigned = assignDistributionSet(ds, targAssigned).getAssignedEntity();
targInstalled = assignDistributionSet(ds, targInstalled).getAssignedEntity();
targAssigned = assignDistributionSet(ds, targAssigned).getAssignedEntity().stream().map(Action::getTarget)
.collect(Collectors.toList());
targInstalled = assignDistributionSet(ds, targInstalled).getAssignedEntity().stream().map(Action::getTarget)
.collect(Collectors.toList());
targInstalled = testdataFactory
.sendUpdateActionStatusToTargets(targInstalled, Status.FINISHED, Collections.singletonList("installed"))
.stream().map(Action::getTarget).collect(Collectors.toList());
@@ -651,7 +656,8 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.filter(item -> lastTargetQueryAlwaysOverdue.equals(item.getLastTargetQuery()))
.collect(Collectors.toList()));
assertThat(result.getContent()).containsExactly(expected.toArray(new Target[0]));
assertThat(result.getContent()).usingElementComparator(controllerIdComparator())
.containsExactly(expected.toArray(new Target[0]));
}
@@ -701,8 +707,8 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
List<Target> installedtargets = testdataFactory.createTargets(10, "assigned", "assigned");
// set on installed and assign another one
assignDistributionSet(installedSet, installedtargets).getActionIds().forEach(actionId -> controllerManagement
.addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Status.FINISHED)));
assignDistributionSet(installedSet, installedtargets).getAssignedEntity().forEach(action -> controllerManagement
.addUpdateActionStatus(entityFactory.actionStatus().create(action.getId()).status(Status.FINISHED)));
assignDistributionSet(assignedSet, installedtargets);
// get final updated version of targets

View File

@@ -478,7 +478,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
final DistributionSetAssignmentResult result = assignDistributionSet(set.getId(), "4711");
controllerManagement.addUpdateActionStatus(
entityFactory.actionStatus().create(result.getActionIds().get(0)).status(Status.FINISHED));
entityFactory.actionStatus().create(getFirstAssignedActionId(result)).status(Status.FINISHED));
assignDistributionSet(set2.getId(), "4711");
target = targetManagement.getByControllerID("4711").get();

View File

@@ -59,7 +59,7 @@ public class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
testdataFactory.createTarget(knownControllerId);
final DistributionSetAssignmentResult assignmentResult = deploymentManagement.assignDistributionSet(
firstDistributionSet.getId(), ActionType.FORCED, 0, Collections.singleton(knownControllerId));
final Long manuallyAssignedActionId = assignmentResult.getActionIds().get(0);
final Long manuallyAssignedActionId = getFirstAssignedActionId(assignmentResult);
// target filter query that matches all targets
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement

View File

@@ -80,8 +80,8 @@ public class AutoActionCleanupTest extends AbstractJpaIntegrationTest {
final DistributionSet ds1 = testdataFactory.createDistributionSet("ds1");
final DistributionSet ds2 = testdataFactory.createDistributionSet("ds2");
final Long action1 = deploymentManagement.assignDistributionSet(ds1.getId(), ActionType.FORCED, 0,
Collections.singletonList(trg1.getControllerId())).getActionIds().get(0);
final Long action1 = getFirstAssignedActionId(deploymentManagement.assignDistributionSet(ds1.getId(),
ActionType.FORCED, 0, Collections.singletonList(trg1.getControllerId())));
deploymentManagement.assignDistributionSet(ds2.getId(), ActionType.FORCED, 0,
Collections.singletonList(trg2.getControllerId()));
@@ -109,12 +109,12 @@ public class AutoActionCleanupTest extends AbstractJpaIntegrationTest {
final DistributionSet ds1 = testdataFactory.createDistributionSet("ds1");
final DistributionSet ds2 = testdataFactory.createDistributionSet("ds2");
final Long action1 = deploymentManagement.assignDistributionSet(ds1.getId(), ActionType.FORCED, 0,
Collections.singletonList(trg1.getControllerId())).getActionIds().get(0);
final Long action2 = deploymentManagement.assignDistributionSet(ds2.getId(), ActionType.FORCED, 0,
Collections.singletonList(trg2.getControllerId())).getActionIds().get(0);
final Long action3 = deploymentManagement.assignDistributionSet(ds2.getId(), ActionType.FORCED, 0,
Collections.singletonList(trg3.getControllerId())).getActionIds().get(0);
final Long action1 = getFirstAssignedActionId(deploymentManagement.assignDistributionSet(ds1.getId(),
ActionType.FORCED, 0, Collections.singletonList(trg1.getControllerId())));
final Long action2 = getFirstAssignedActionId(deploymentManagement.assignDistributionSet(ds2.getId(),
ActionType.FORCED, 0, Collections.singletonList(trg2.getControllerId())));
final Long action3 = getFirstAssignedActionId(deploymentManagement.assignDistributionSet(ds2.getId(),
ActionType.FORCED, 0, Collections.singletonList(trg3.getControllerId())));
assertThat(actionRepository.count()).isEqualTo(3);
@@ -144,12 +144,12 @@ public class AutoActionCleanupTest extends AbstractJpaIntegrationTest {
final DistributionSet ds1 = testdataFactory.createDistributionSet("ds1");
final DistributionSet ds2 = testdataFactory.createDistributionSet("ds2");
final Long action1 = deploymentManagement.assignDistributionSet(ds1.getId(), ActionType.FORCED, 0,
Collections.singletonList(trg1.getControllerId())).getActionIds().get(0);
final Long action2 = deploymentManagement.assignDistributionSet(ds2.getId(), ActionType.FORCED, 0,
Collections.singletonList(trg2.getControllerId())).getActionIds().get(0);
final Long action3 = deploymentManagement.assignDistributionSet(ds2.getId(), ActionType.FORCED, 0,
Collections.singletonList(trg3.getControllerId())).getActionIds().get(0);
final Long action1 = getFirstAssignedActionId(deploymentManagement.assignDistributionSet(ds1.getId(),
ActionType.FORCED, 0, Collections.singletonList(trg1.getControllerId())));
final Long action2 = getFirstAssignedActionId(deploymentManagement.assignDistributionSet(ds2.getId(),
ActionType.FORCED, 0, Collections.singletonList(trg2.getControllerId())));
final Long action3 = getFirstAssignedActionId(deploymentManagement.assignDistributionSet(ds2.getId(),
ActionType.FORCED, 0, Collections.singletonList(trg3.getControllerId())));
assertThat(actionRepository.count()).isEqualTo(3);
@@ -181,12 +181,12 @@ public class AutoActionCleanupTest extends AbstractJpaIntegrationTest {
final DistributionSet ds1 = testdataFactory.createDistributionSet("ds1");
final DistributionSet ds2 = testdataFactory.createDistributionSet("ds2");
final Long action1 = deploymentManagement.assignDistributionSet(ds1.getId(), ActionType.FORCED, 0,
Collections.singletonList(trg1.getControllerId())).getActionIds().get(0);
final Long action2 = deploymentManagement.assignDistributionSet(ds2.getId(), ActionType.FORCED, 0,
Collections.singletonList(trg2.getControllerId())).getActionIds().get(0);
final Long action3 = deploymentManagement.assignDistributionSet(ds2.getId(), ActionType.FORCED, 0,
Collections.singletonList(trg3.getControllerId())).getActionIds().get(0);
final Long action1 = getFirstAssignedActionId(deploymentManagement.assignDistributionSet(ds1.getId(),
ActionType.FORCED, 0, Collections.singletonList(trg1.getControllerId())));
final Long action2 = getFirstAssignedActionId(deploymentManagement.assignDistributionSet(ds2.getId(),
ActionType.FORCED, 0, Collections.singletonList(trg2.getControllerId())));
final Long action3 = getFirstAssignedActionId(deploymentManagement.assignDistributionSet(ds2.getId(),
ActionType.FORCED, 0, Collections.singletonList(trg3.getControllerId())));
assertThat(actionRepository.count()).isEqualTo(3);