- Fix ds assignment result
- Fix drag and drop to assignment Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.AssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* A bean which holds a complex result of an service operation to combine the
|
||||
@@ -61,6 +62,10 @@ public class DistributionSetAssignmentResult extends AssignmentResult<Target> {
|
||||
|
||||
@Override
|
||||
public List<Target> getAssignedEntity() {
|
||||
if (CollectionUtils.isEmpty(assignedTargets)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return targetManagement.findTargetByControllerID(assignedTargets);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.exception.DistributionSetTypeUndefinedException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
@@ -818,6 +819,28 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
.isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Test different assignment results, after assign a ds")
|
||||
public void testAlreadyAssignedTargetsToDs() {
|
||||
DistributionSet dsToTargetAssigned = testdataFactory.createDistributionSet("ds-3");
|
||||
|
||||
// create assigned DS
|
||||
dsToTargetAssigned = distributionSetManagement.findDistributionSetByNameAndVersion(dsToTargetAssigned.getName(),
|
||||
dsToTargetAssigned.getVersion());
|
||||
final Target target = new JpaTarget("4712");
|
||||
final Target savedTarget = targetManagement.createTarget(target);
|
||||
final List<Target> toAssign = new ArrayList<>();
|
||||
toAssign.add(savedTarget);
|
||||
DistributionSetAssignmentResult assignmentResult = deploymentManagement
|
||||
.assignDistributionSet(dsToTargetAssigned, toAssign);
|
||||
assertThat(assignmentResult.getAssignedEntity()).hasSize(1);
|
||||
|
||||
assignmentResult = deploymentManagement.assignDistributionSet(dsToTargetAssigned, toAssign);
|
||||
assertThat(assignmentResult.getAssignedEntity()).hasSize(0);
|
||||
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(1);
|
||||
}
|
||||
|
||||
private Rollout createRolloutByVariables(final String rolloutName, final String rolloutDescription,
|
||||
final int groupSize, final String filterQuery, final DistributionSet distributionSet,
|
||||
final String successCondition, final String errorCondition) {
|
||||
|
||||
Reference in New Issue
Block a user