DistributionSetAssignmentResult contains actions that do not reflect the

status on the DB. Needs to be avoided by returning actions IDs only and
force the user to query an updated action entity.

Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-02-16 13:48:52 +01:00
parent 2ef04bb437
commit 38b750f674
9 changed files with 76 additions and 82 deletions

View File

@@ -73,7 +73,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
distributionSetManagement, new ArrayList<DistributionSetTag>());
final List<Target> testTarget = targetManagement.createTargets(TestDataUtil.generateTargets(1));
// one action with one action status is generated
final Action action = deploymentManagement.assignDistributionSet(testDs, testTarget).getActions().get(0);
final Action action = deploymentManagement.findActionWithDetails(
deploymentManagement.assignDistributionSet(testDs, testTarget).getActions().get(0));
// save 2 action status
actionStatusRepository.save(new ActionStatus(action, Status.RETRIEVED, System.currentTimeMillis()));
actionStatusRepository.save(new ActionStatus(action, Status.RUNNING, System.currentTimeMillis()));
@@ -349,7 +350,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
* test a simple deployment by calling the
* {@link TargetRepository#assignDistributionSet(DistributionSet, Iterable)}
* and checking the active action and the action history of the targets.
*
*
* @throws InterruptedException
*/
@Test
@@ -805,7 +806,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
// assign ds to create an action
final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement
.assignDistributionSet(ds.getId(), ActionType.SOFT, Action.NO_FORCE_TIME, target.getControllerId());
final Action action = assignDistributionSet.getActions().get(0);
final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0));
// verify preparation
Action findAction = deploymentManagement.findAction(action.getId());
assertThat(findAction.getActionType()).isEqualTo(ActionType.SOFT);
@@ -828,7 +829,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
// assign ds to create an action
final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement
.assignDistributionSet(ds.getId(), ActionType.FORCED, Action.NO_FORCE_TIME, target.getControllerId());
final Action action = assignDistributionSet.getActions().get(0);
final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0));
// verify perparation
Action findAction = deploymentManagement.findAction(action.getId());
assertThat(findAction.getActionType()).isEqualTo(ActionType.FORCED);
@@ -848,7 +849,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
* <p>
* <b>All created distribution sets are assigned to all targets of the
* target list deployedTargets.</b>
*
*
* @param undeployedTargetPrefix
* prefix to be used as target controller prefix
* @param noOfUndeployedTargets

View File

@@ -138,7 +138,8 @@ public class ReportManagementTest extends AbstractIntegrationTest {
final Target createTarget = targetManagement.createTarget(new Target("t" + month));
final DistributionSetAssignmentResult result = deploymentManagement.assignDistributionSet(distributionSet,
Lists.newArrayList(createTarget));
controllerManagament.registerRetrieved(result.getActions().get(0),
controllerManagament.registerRetrieved(
deploymentManagement.findActionWithDetails(result.getActions().get(0)),
"Controller retrieved update action and should start now the download.");
}
DataReportSeries<LocalDate> feedbackReceivedOverTime = reportManagement
@@ -158,7 +159,8 @@ public class ReportManagementTest extends AbstractIntegrationTest {
final Target createTarget = targetManagement.createTarget(new Target("t2" + month));
final DistributionSetAssignmentResult result = deploymentManagement.assignDistributionSet(distributionSet,
Lists.newArrayList(createTarget));
controllerManagament.registerRetrieved(result.getActions().get(0),
controllerManagament.registerRetrieved(
deploymentManagement.findActionWithDetails(result.getActions().get(0)),
"Controller retrieved update action and should start now the download.");
}
feedbackReceivedOverTime = reportManagement.feedbackReceivedOverTime(DateTypes.perMonth(), from, to);
@@ -572,7 +574,7 @@ public class ReportManagementTest extends AbstractIntegrationTest {
/*
* (non-Javadoc)
*
*
* @see org.springframework.data.auditing.DateTimeProvider#getNow()
*/
@Override

View File

@@ -174,7 +174,7 @@ public class TargetManagementTest extends AbstractIntegrationTest {
final DistributionSetAssignmentResult result = deploymentManagement.assignDistributionSet(set.getId(), "4711");
final Action action = result.getActions().get(0);
final Action action = deploymentManagement.findActionWithDetails(result.getActions().get(0));
action.setStatus(Status.FINISHED);
controllerManagament.addUpdateActionStatus(
new ActionStatus(action, Status.FINISHED, System.currentTimeMillis(), "message"), action);
@@ -221,7 +221,7 @@ public class TargetManagementTest extends AbstractIntegrationTest {
* verifies, that all {@link TargetTag} of parameter. NOTE: it's accepted
* that the target have additional tags assigned to them which are not
* contained within parameter tags.
*
*
* @param strict
* if true, the given targets MUST contain EXACTLY ALL given
* tags, AND NO OTHERS. If false, the given targets MUST contain

View File

@@ -199,13 +199,14 @@ public final class RepositoryDataGenerator {
}
private void createActionStatusHistory(final List<Action> actions, final int sizeMultiplikator) {
private void createActionStatusHistory(final List<Long> actions, final int sizeMultiplikator) {
final AtomicInteger counter = new AtomicInteger();
int index = 0;
for (final Action actionGiven : actions) {
for (final Long actionGiven : actions) {
// retrieved
Action action = controllerManagement.registerRetrieved(actionGiven,
Action action = controllerManagement.registerRetrieved(
deploymentManagement.findActionWithDetails(actionGiven),
"Controller retrieved update action and should start now the download.");
// download
@@ -260,10 +261,11 @@ public final class RepositoryDataGenerator {
}
}
private void createSimpleActionStatusHistory(final List<Action> actions) {
for (final Action actionGiven : actions) {
private void createSimpleActionStatusHistory(final List<Long> actions) {
for (final Long actionGiven : actions) {
// retrieved
Action action = controllerManagement.registerRetrieved(actionGiven,
Action action = controllerManagement.registerRetrieved(
deploymentManagement.findActionWithDetails(actionGiven),
"Controller retrieved update action and should start now the download.");
// close