Removed unused target parameter in method forceQuitAction and change assertEquals to assertThat
Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
@@ -572,7 +572,7 @@ public class DeploymentManagement {
|
|||||||
@Modifying
|
@Modifying
|
||||||
@Transactional
|
@Transactional
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
@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);
|
final Action mergedAction = entityManager.merge(action);
|
||||||
|
|
||||||
if (!mergedAction.isCancelingOrCanceled()) {
|
if (!mergedAction.isCancelingOrCanceled()) {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.repository;
|
|||||||
|
|
||||||
import static org.fest.assertions.api.Assertions.assertThat;
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -312,7 +311,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
deploymentManagement.cancelAction(assigningAction, target);
|
deploymentManagement.cancelAction(assigningAction, target);
|
||||||
assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId());
|
assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId());
|
||||||
|
|
||||||
deploymentManagement.forceQuitAction(assigningAction, target);
|
deploymentManagement.forceQuitAction(assigningAction);
|
||||||
|
|
||||||
assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId());
|
assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId());
|
||||||
|
|
||||||
@@ -350,8 +349,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
|
|
||||||
// force quit assignment
|
// force quit assignment
|
||||||
try {
|
try {
|
||||||
deploymentManagement.forceQuitAction(assigningAction,
|
deploymentManagement.forceQuitAction(assigningAction);
|
||||||
targetManagement.findTargetByControllerID(target.getControllerId()));
|
|
||||||
fail("expected ForceQuitActionNotAllowedException");
|
fail("expected ForceQuitActionNotAllowedException");
|
||||||
} catch (final ForceQuitActionNotAllowedException ex) {
|
} catch (final ForceQuitActionNotAllowedException ex) {
|
||||||
}
|
}
|
||||||
@@ -764,13 +762,16 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).getOptLockRevision());
|
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).getOptLockRevision());
|
||||||
|
|
||||||
// verifying that the assignment is correct
|
// verifying that the assignment is correct
|
||||||
assertEquals("Active target actions are wrong", 1, deploymentManagement.findActiveActionsByTarget(targ).size());
|
assertThat(deploymentManagement.findActiveActionsByTarget(targ).size()).as("Active target actions are wrong")
|
||||||
assertEquals("Target actions are wrong", 1, deploymentManagement.findActionsByTarget(targ).size());
|
.isEqualTo(1);
|
||||||
assertEquals("Target status is wrong", TargetUpdateStatus.PENDING, targ.getTargetInfo().getUpdateStatus());
|
assertThat(deploymentManagement.findActionsByTarget(targ).size()).as("Target actions are wrong").isEqualTo(1);
|
||||||
assertEquals("Assigned ds is wrong", dsA, targ.getAssignedDistributionSet());
|
assertThat(targ.getTargetInfo().getUpdateStatus()).as("UpdateStatus of target is wrong")
|
||||||
assertEquals("Active ds is wrong", dsA,
|
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet());
|
assertThat(targ.getAssignedDistributionSet()).as("Assigned distribution set of target is wrong").isEqualTo(dsA);
|
||||||
assertNull("Installed ds should be null", targ.getTargetInfo().getInstalledDistributionSet());
|
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<Action> updAct = actionRepository.findByDistributionSet(pageReq, dsA);
|
final Page<Action> updAct = actionRepository.findByDistributionSet(pageReq, dsA);
|
||||||
final Action action = updAct.getContent().get(0);
|
final Action action = updAct.getContent().get(0);
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ public class TargetResource implements TargetRestApi {
|
|||||||
final Action action = findActionWithExceptionIfNotFound(actionId);
|
final Action action = findActionWithExceptionIfNotFound(actionId);
|
||||||
|
|
||||||
if (force) {
|
if (force) {
|
||||||
this.deploymentManagement.forceQuitAction(action, target);
|
this.deploymentManagement.forceQuitAction(action);
|
||||||
} else {
|
} else {
|
||||||
this.deploymentManagement.cancelAction(action, target);
|
this.deploymentManagement.cancelAction(action, target);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -844,7 +844,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
|
|||||||
if (actionId != null) {
|
if (actionId != null) {
|
||||||
final Action activeAction = deploymentManagement.findAction(actionId);
|
final Action activeAction = deploymentManagement.findAction(actionId);
|
||||||
try {
|
try {
|
||||||
deploymentManagement.forceQuitAction(activeAction, target);
|
deploymentManagement.forceQuitAction(activeAction);
|
||||||
return true;
|
return true;
|
||||||
} catch (final CancelActionNotAllowedException e) {
|
} catch (final CancelActionNotAllowedException e) {
|
||||||
LOG.info("Force Cancel action not allowed exception :{}", e);
|
LOG.info("Force Cancel action not allowed exception :{}", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user