From 8f35b758571075349a4964341f2959576857a9e3 Mon Sep 17 00:00:00 2001 From: Jonathan Philip Knoblauch Date: Mon, 7 Mar 2016 14:44:34 +0100 Subject: [PATCH] Removed unused target parameter in method forceQuitAction and change assertEquals to assertThat Signed-off-by: Jonathan Philip Knoblauch --- .../repository/DeploymentManagement.java | 2 +- .../repository/DeploymentManagementTest.java | 23 ++++++++++--------- .../hawkbit/rest/resource/TargetResource.java | 2 +- .../actionhistory/ActionHistoryTable.java | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java index e1976c9a6..aad0839cd 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -572,7 +572,7 @@ public class DeploymentManagement { @Modifying @Transactional @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - public Action forceQuitAction(@NotNull final Action action, @NotNull final Target target) { + public Action forceQuitAction(@NotNull final Action action) { final Action mergedAction = entityManager.merge(action); if (!mergedAction.isCancelingOrCanceled()) { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java index 9530a61c3..ecf079c29 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java @@ -10,7 +10,6 @@ package org.eclipse.hawkbit.repository; import static org.fest.assertions.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; import java.util.ArrayList; @@ -312,7 +311,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { deploymentManagement.cancelAction(assigningAction, target); assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId()); - deploymentManagement.forceQuitAction(assigningAction, target); + deploymentManagement.forceQuitAction(assigningAction); assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId()); @@ -350,8 +349,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // force quit assignment try { - deploymentManagement.forceQuitAction(assigningAction, - targetManagement.findTargetByControllerID(target.getControllerId())); + deploymentManagement.forceQuitAction(assigningAction); fail("expected ForceQuitActionNotAllowedException"); } catch (final ForceQuitActionNotAllowedException ex) { } @@ -764,13 +762,16 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).getOptLockRevision()); // verifying that the assignment is correct - assertEquals("Active target actions are wrong", 1, deploymentManagement.findActiveActionsByTarget(targ).size()); - assertEquals("Target actions are wrong", 1, deploymentManagement.findActionsByTarget(targ).size()); - assertEquals("Target status is wrong", TargetUpdateStatus.PENDING, targ.getTargetInfo().getUpdateStatus()); - assertEquals("Assigned ds is wrong", dsA, targ.getAssignedDistributionSet()); - assertEquals("Active ds is wrong", dsA, - deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet()); - assertNull("Installed ds should be null", targ.getTargetInfo().getInstalledDistributionSet()); + assertThat(deploymentManagement.findActiveActionsByTarget(targ).size()).as("Active target actions are wrong") + .isEqualTo(1); + assertThat(deploymentManagement.findActionsByTarget(targ).size()).as("Target actions are wrong").isEqualTo(1); + assertThat(targ.getTargetInfo().getUpdateStatus()).as("UpdateStatus of target is wrong") + .isEqualTo(TargetUpdateStatus.PENDING); + assertThat(targ.getAssignedDistributionSet()).as("Assigned distribution set of target is wrong").isEqualTo(dsA); + assertThat(deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet()) + .as("Distribution set of actionn is wrong").isEqualTo(dsA); + assertThat(deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet()) + .as("Installed distribution set of action should be null").isNotNull(); final Page updAct = actionRepository.findByDistributionSet(pageReq, dsA); final Action action = updAct.getContent().get(0); diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java index 69a38f87d..faa31a7cc 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java @@ -209,7 +209,7 @@ public class TargetResource implements TargetRestApi { final Action action = findActionWithExceptionIfNotFound(actionId); if (force) { - this.deploymentManagement.forceQuitAction(action, target); + this.deploymentManagement.forceQuitAction(action); } else { this.deploymentManagement.cancelAction(action, target); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java index f8d53b1bf..c9fa8f39c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java @@ -844,7 +844,7 @@ public class ActionHistoryTable extends TreeTable implements Handler { if (actionId != null) { final Action activeAction = deploymentManagement.findAction(actionId); try { - deploymentManagement.forceQuitAction(activeAction, target); + deploymentManagement.forceQuitAction(activeAction); return true; } catch (final CancelActionNotAllowedException e) { LOG.info("Force Cancel action not allowed exception :{}", e);