Worked on the interfaces and documentation.

Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-05-22 08:48:47 +02:00
parent f0a78369f2
commit 9301de096c
55 changed files with 971 additions and 506 deletions

View File

@@ -97,7 +97,7 @@ public final class MgmtDistributionSetMapper {
static DistributionSet fromRequest(final MgmtDistributionSetRequestBodyPost dsRest,
final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement) {
final DistributionSet result = new DistributionSet();
final DistributionSet result = distributionSetManagement.generateDistributionSet();
result.setDescription(dsRest.getDescription());
result.setName(dsRest.getName());
result.setType(findDistributionSetTypeWithExceptionIfNotFound(dsRest.getType(), distributionSetManagement));
@@ -135,13 +135,14 @@ public final class MgmtDistributionSetMapper {
* @return
*/
static List<DistributionSetMetadata> fromRequestDsMetadata(final DistributionSet ds,
final List<MgmtMetadata> metadata) {
final List<MgmtMetadata> metadata, final DistributionSetManagement distributionSetManagement) {
final List<DistributionSetMetadata> mappedList = new ArrayList<>(metadata.size());
for (final MgmtMetadata metadataRest : metadata) {
if (metadataRest.getKey() == null) {
throw new IllegalArgumentException("the key of the metadata must be present");
}
mappedList.add(new DistributionSetMetadata(metadataRest.getKey(), ds, metadataRest.getValue()));
mappedList.add(distributionSetManagement.generateDistributionSetMetadata(ds, metadataRest.getKey(),
metadataRest.getValue()));
}
return mappedList;
}
@@ -170,12 +171,11 @@ public final class MgmtDistributionSetMapper {
response.setRequiredMigrationStep(distributionSet.isRequiredMigrationStep());
response.add(
linkTo(methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(response.getDsId())).withRel("self"));
response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(response.getDsId()))
.withRel("self"));
response.add(linkTo(
methodOn(MgmtDistributionSetTypeRestApi.class).getDistributionSetType(distributionSet.getType().getId()))
.withRel("type"));
response.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class)
.getDistributionSetType(distributionSet.getType().getId())).withRel("type"));
response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getMetadata(response.getDsId(),
Integer.parseInt(MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET),
@@ -206,7 +206,7 @@ public final class MgmtDistributionSetMapper {
static MgmtMetadata toResponseDsMetadata(final DistributionSetMetadata metadata) {
final MgmtMetadata metadataRest = new MgmtMetadata();
metadataRest.setKey(metadata.getId().getKey());
metadataRest.setKey(metadata.getKey());
metadataRest.setValue(metadata.getValue());
return metadataRest;
}

View File

@@ -27,22 +27,18 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult;
import org.eclipse.hawkbit.repository.DistributionSetFields;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.DistributionSetMetadataFields;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.TargetFields;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.TargetWithActionType;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.jpa.TargetWithActionType;
import org.eclipse.hawkbit.repository.jpa.model.DsMetadataCompositeKey;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.DsMetadataCompositeKey;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
import org.eclipse.hawkbit.tenancy.TenantAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -96,10 +92,9 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
final Page<DistributionSet> findDsPage;
if (rsqlParam != null) {
findDsPage = this.distributionSetManagement.findDistributionSetsAll(
RSQLUtility.parse(rsqlParam, DistributionSetFields.class), pageable, false);
findDsPage = this.distributionSetManagement.findDistributionSetsAll(rsqlParam, pageable, false);
} else {
findDsPage = this.distributionSetManagement.findDistributionSetsAll(pageable, false, null);
findDsPage = this.distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageable, false, null);
}
final List<MgmtDistributionSet> rest = MgmtDistributionSetMapper.toResponseFromDsList(findDsPage.getContent());
@@ -181,8 +176,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
final Page<Target> targetsAssignedDS;
if (rsqlParam != null) {
targetsAssignedDS = this.targetManagement.findTargetByAssignedDistributionSet(distributionSetId,
RSQLUtility.parse(rsqlParam, TargetFields.class), pageable);
targetsAssignedDS = this.targetManagement.findTargetByAssignedDistributionSet(distributionSetId, rsqlParam,
pageable);
} else {
targetsAssignedDS = this.targetManagement.findTargetByAssignedDistributionSet(distributionSetId, pageable);
}
@@ -210,7 +205,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
final Page<Target> targetsInstalledDS;
if (rsqlParam != null) {
targetsInstalledDS = this.targetManagement.findTargetByInstalledDistributionSet(distributionSetId,
RSQLUtility.parse(rsqlParam, TargetFields.class), pageable);
rsqlParam, pageable);
} else {
targetsInstalledDS = this.targetManagement.findTargetByInstalledDistributionSet(distributionSetId,
pageable);
@@ -257,8 +252,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
final Page<DistributionSetMetadata> metaDataPage;
if (rsqlParam != null) {
metaDataPage = this.distributionSetManagement.findDistributionSetMetadataByDistributionSetId(
distributionSetId, RSQLUtility.parse(rsqlParam, DistributionSetMetadataFields.class), pageable);
metaDataPage = this.distributionSetManagement
.findDistributionSetMetadataByDistributionSetId(distributionSetId, rsqlParam, pageable);
} else {
metaDataPage = this.distributionSetManagement
.findDistributionSetMetadataByDistributionSetId(distributionSetId, pageable);
@@ -289,8 +284,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
// check if distribution set exists otherwise throw exception
// immediately
final DistributionSet ds = findDistributionSetWithExceptionIfNotFound(distributionSetId);
final DistributionSetMetadata updated = this.distributionSetManagement
.updateDistributionSetMetadata(new DistributionSetMetadata(metadataKey, ds, metadata.getValue()));
final DistributionSetMetadata updated = this.distributionSetManagement.updateDistributionSetMetadata(
distributionSetManagement.generateDistributionSetMetadata(ds, metadataKey, metadata.getValue()));
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDsMetadata(updated));
}
@@ -312,8 +307,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
// immediately
final DistributionSet ds = findDistributionSetWithExceptionIfNotFound(distributionSetId);
final List<DistributionSetMetadata> created = this.distributionSetManagement
.createDistributionSetMetadata(MgmtDistributionSetMapper.fromRequestDsMetadata(ds, metadataRest));
final List<DistributionSetMetadata> created = this.distributionSetManagement.createDistributionSetMetadata(
MgmtDistributionSetMapper.fromRequestDsMetadata(ds, metadataRest, distributionSetManagement));
return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDsMetadata(created), HttpStatus.CREATED);
}

View File

@@ -21,13 +21,11 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTagRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.TagFields;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -75,8 +73,8 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
countTargetsAll = this.tagManagement.countTargetTags();
} else {
final Page<DistributionSetTag> findTargetPage = this.tagManagement
.findAllDistributionSetTags(RSQLUtility.parse(rsqlParam, TagFields.class), pageable);
final Page<DistributionSetTag> findTargetPage = this.tagManagement.findAllDistributionSetTags(rsqlParam,
pageable);
countTargetsAll = findTargetPage.getTotalElements();
findTargetsAll = findTargetPage;
@@ -99,7 +97,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
LOG.debug("creating {} ds tags", tags.size());
final List<DistributionSetTag> createdTags = this.tagManagement
.createDistributionSetTags(MgmtTagMapper.mapDistributionSetTagFromRequest(tags));
.createDistributionSetTags(MgmtTagMapper.mapDistributionSetTagFromRequest(tagManagement, tags));
return new ResponseEntity<>(MgmtTagMapper.toResponseDistributionSetTag(createdTags), HttpStatus.CREATED);
}

View File

@@ -14,10 +14,11 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetType;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
@@ -35,21 +36,22 @@ final class MgmtDistributionSetTypeMapper {
}
static List<DistributionSetType> smFromRequest(final SoftwareManagement softwareManagement,
static List<DistributionSetType> smFromRequest(final DistributionSetManagement distributionSetManagement,
final SoftwareManagement softwareManagement,
final Iterable<MgmtDistributionSetTypeRequestBodyPost> smTypesRest) {
final List<DistributionSetType> mappedList = new ArrayList<>();
for (final MgmtDistributionSetTypeRequestBodyPost smRest : smTypesRest) {
mappedList.add(fromRequest(softwareManagement, smRest));
mappedList.add(fromRequest(distributionSetManagement, softwareManagement, smRest));
}
return mappedList;
}
static DistributionSetType fromRequest(final SoftwareManagement softwareManagement,
final MgmtDistributionSetTypeRequestBodyPost smsRest) {
static DistributionSetType fromRequest(final DistributionSetManagement distributionSetManagement,
final SoftwareManagement softwareManagement, final MgmtDistributionSetTypeRequestBodyPost smsRest) {
final DistributionSetType result = new DistributionSetType(smsRest.getKey(), smsRest.getName(),
smsRest.getDescription());
final DistributionSetType result = distributionSetManagement.generateDistributionSetType(smsRest.getKey(),
smsRest.getName(), smsRest.getDescription());
// Add mandatory
smsRest.getMandatorymodules().stream().map(mand -> {

View File

@@ -12,14 +12,13 @@ import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.MgmtId;
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetType;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPut;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetType;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.DistributionSetTypeFields;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
@@ -27,7 +26,6 @@ import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -71,8 +69,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
final Slice<DistributionSetType> findModuleTypessAll;
Long countModulesAll;
if (rsqlParam != null) {
findModuleTypessAll = distributionSetManagement.findDistributionSetTypesByPredicate(
RSQLUtility.parse(rsqlParam, DistributionSetTypeFields.class), pageable);
findModuleTypessAll = distributionSetManagement.findDistributionSetTypesAll(rsqlParam, pageable);
countModulesAll = ((Page<DistributionSetType>) findModuleTypessAll).getTotalElements();
} else {
findModuleTypessAll = distributionSetManagement.findDistributionSetTypesAll(pageable);
@@ -124,8 +121,9 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
public ResponseEntity<List<MgmtDistributionSetType>> createDistributionSetTypes(
@RequestBody final List<MgmtDistributionSetTypeRequestBodyPost> distributionSetTypes) {
final List<DistributionSetType> createdSoftwareModules = distributionSetManagement.createDistributionSetTypes(
MgmtDistributionSetTypeMapper.smFromRequest(softwareManagement, distributionSetTypes));
final List<DistributionSetType> createdSoftwareModules = distributionSetManagement
.createDistributionSetTypes(MgmtDistributionSetTypeMapper.smFromRequest(distributionSetManagement,
softwareManagement, distributionSetTypes));
return new ResponseEntity<>(MgmtDistributionSetTypeMapper.toTypesResponse(createdSoftwareModules),
HttpStatus.CREATED);

View File

@@ -22,6 +22,7 @@ import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutSuccessAction.Succ
import org.eclipse.hawkbit.mgmt.json.model.rolloutgroup.MgmtRolloutGroupResponseBody;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRolloutRestApi;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Rollout;
@@ -83,9 +84,9 @@ final class MgmtRolloutMapper {
return body;
}
static Rollout fromRequest(final MgmtRolloutRestRequestBody restRequest, final DistributionSet distributionSet,
final String filterQuery) {
final Rollout rollout = new Rollout();
static Rollout fromRequest(final RolloutManagement rolloutManagement, final MgmtRolloutRestRequestBody restRequest,
final DistributionSet distributionSet, final String filterQuery) {
final Rollout rollout = rolloutManagement.generateRollout();
rollout.setName(restRequest.getName());
rollout.setDescription(restRequest.getDescription());
rollout.setDistributionSet(distributionSet);

View File

@@ -19,8 +19,6 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRolloutRestApi;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.RolloutFields;
import org.eclipse.hawkbit.repository.RolloutGroupFields;
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.TargetFields;
@@ -28,18 +26,18 @@ import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupConditions;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorAction;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondition;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessAction;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
@@ -80,8 +78,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
final Page<Rollout> findModulesAll;
if (rsqlParam != null) {
findModulesAll = this.rolloutManagement
.findAllWithDetailedStatusByPredicate(RSQLUtility.parse(rsqlParam, RolloutFields.class), pageable);
findModulesAll = this.rolloutManagement.findAllWithDetailedStatusByPredicate(rsqlParam, pageable);
} else {
findModulesAll = this.rolloutManagement.findAll(pageable);
}
@@ -136,12 +133,12 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
errorActionExpr = rolloutRequestBody.getErrorAction().getExpression();
}
final RolloutGroupConditions rolloutGroupConditions = new RolloutGroup.RolloutGroupConditionBuilder()
final RolloutGroupConditions rolloutGroupConditions = new RolloutGroupConditionBuilder()
.successCondition(successCondition, successConditionExpr)
.successAction(successAction, successActionExpr).errorCondition(errorCondition, errorConditionExpr)
.errorAction(errorAction, errorActionExpr).build();
final Rollout rollout = this.rolloutManagement.createRollout(
MgmtRolloutMapper.fromRequest(rolloutRequestBody, distributionSet,
MgmtRolloutMapper.fromRequest(rolloutManagement, rolloutRequestBody, distributionSet,
rolloutRequestBody.getTargetFilterQuery()),
rolloutRequestBody.getAmountGroups(), rolloutGroupConditions);
@@ -191,8 +188,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
final Page<RolloutGroup> findRolloutGroupsAll;
if (rsqlParam != null) {
findRolloutGroupsAll = this.rolloutGroupManagement.findRolloutGroupsByPredicate(rollout,
RSQLUtility.parse(rsqlParam, RolloutGroupFields.class), pageable);
findRolloutGroupsAll = this.rolloutGroupManagement.findRolloutGroupsAll(rollout, rsqlParam, pageable);
} else {
findRolloutGroupsAll = this.rolloutGroupManagement.findRolloutGroupsByRolloutId(rolloutId, pageable);
}
@@ -228,8 +224,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
final Page<Target> rolloutGroupTargets;
if (rsqlParam != null) {
final Specification<Target> rsqlSpecification = RSQLUtility.parse(rsqlParam, TargetFields.class);
rolloutGroupTargets = this.rolloutGroupManagement.findRolloutGroupTargets(rolloutGroup, rsqlSpecification,
rolloutGroupTargets = this.rolloutGroupManagement.findRolloutGroupTargets(rolloutGroup, rsqlParam,
pageable);
} else {
final Page<Target> pageTargets = this.rolloutGroupManagement.findRolloutGroupTargets(rolloutGroup,

View File

@@ -54,18 +54,20 @@ public final class MgmtSoftwareModuleMapper {
static SoftwareModule fromRequest(final MgmtSoftwareModuleRequestBodyPost smsRest,
final SoftwareManagement softwareManagement) {
return new SoftwareModule(getSoftwareModuleTypeFromKeyString(smsRest.getType(), softwareManagement),
smsRest.getName(), smsRest.getVersion(), smsRest.getDescription(), smsRest.getVendor());
return softwareManagement.generateSoftwareModule(
getSoftwareModuleTypeFromKeyString(smsRest.getType(), softwareManagement), smsRest.getName(),
smsRest.getVersion(), smsRest.getDescription(), smsRest.getVendor());
}
static List<SoftwareModuleMetadata> fromRequestSwMetadata(final SoftwareModule sw,
final List<MgmtMetadata> metadata) {
static List<SoftwareModuleMetadata> fromRequestSwMetadata(final SoftwareManagement softwareManagement,
final SoftwareModule sw, final List<MgmtMetadata> metadata) {
final List<SoftwareModuleMetadata> mappedList = new ArrayList<>(metadata.size());
for (final MgmtMetadata metadataRest : metadata) {
if (metadataRest.getKey() == null) {
throw new IllegalArgumentException("the key of the metadata must be present");
}
mappedList.add(new SoftwareModuleMetadata(metadataRest.getKey(), sw, metadataRest.getValue()));
mappedList.add(softwareManagement.generateSoftwareModuleMetadata(sw, metadataRest.getKey(),
metadataRest.getValue()));
}
return mappedList;
}
@@ -116,7 +118,7 @@ public final class MgmtSoftwareModuleMapper {
static MgmtMetadata toResponseSwMetadata(final SoftwareModuleMetadata metadata) {
final MgmtMetadata metadataRest = new MgmtMetadata();
metadataRest.setKey(metadata.getId().getKey());
metadataRest.setKey(metadata.getKey());
metadataRest.setValue(metadata.getValue());
return metadataRest;
}

View File

@@ -22,14 +22,11 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SoftwareModuleFields;
import org.eclipse.hawkbit.repository.SoftwareModuleMetadataFields;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.jpa.model.SwMetadataCompositeKey;
import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey;
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -139,8 +136,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
final Slice<SoftwareModule> findModulesAll;
Long countModulesAll;
if (rsqlParam != null) {
findModulesAll = softwareManagement
.findSoftwareModulesByPredicate(RSQLUtility.parse(rsqlParam, SoftwareModuleFields.class), pageable);
findModulesAll = softwareManagement.findSoftwareModulesByPredicate(rsqlParam, pageable);
countModulesAll = ((Page<SoftwareModule>) findModulesAll).getTotalElements();
} else {
findModulesAll = softwareManagement.findSoftwareModulesAll(pageable);
@@ -217,8 +213,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
final Page<SoftwareModuleMetadata> metaDataPage;
if (rsqlParam != null) {
metaDataPage = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId,
RSQLUtility.parse(rsqlParam, SoftwareModuleMetadataFields.class), pageable);
metaDataPage = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, rsqlParam,
pageable);
} else {
metaDataPage = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, pageable);
}
@@ -233,8 +229,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
public ResponseEntity<MgmtMetadata> getMetadataValue(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("metadataKey") final String metadataKey) {
final SoftwareModule sw = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
final SoftwareModuleMetadata findOne = softwareManagement
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sw, metadataKey));
final SoftwareModuleMetadata findOne = softwareManagement.findSoftwareModuleMetadata(sw, metadataKey);
return ResponseEntity.<MgmtMetadata> ok(MgmtSoftwareModuleMapper.toResponseSwMetadata(findOne));
}
@@ -242,8 +237,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
public ResponseEntity<MgmtMetadata> updateMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("metadataKey") final String metadataKey, @RequestBody final MgmtMetadata metadata) {
final SoftwareModule sw = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
final SoftwareModuleMetadata updated = softwareManagement
.updateSoftwareModuleMetadata(new SoftwareModuleMetadata(metadataKey, sw, metadata.getValue()));
final SoftwareModuleMetadata updated = softwareManagement.updateSoftwareModuleMetadata(
softwareManagement.generateSoftwareModuleMetadata(sw, metadataKey, metadata.getValue()));
return ResponseEntity.ok(MgmtSoftwareModuleMapper.toResponseSwMetadata(updated));
}
@@ -261,8 +256,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
@RequestBody final List<MgmtMetadata> metadataRest) {
final SoftwareModule sw = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
final List<SoftwareModuleMetadata> created = softwareManagement
.createSoftwareModuleMetadata(MgmtSoftwareModuleMapper.fromRequestSwMetadata(sw, metadataRest));
final List<SoftwareModuleMetadata> created = softwareManagement.createSoftwareModuleMetadata(
MgmtSoftwareModuleMapper.fromRequestSwMetadata(softwareManagement, sw, metadataRest));
return new ResponseEntity<>(MgmtSoftwareModuleMapper.toResponseSwMetadata(created), HttpStatus.CREATED);

View File

@@ -18,6 +18,7 @@ import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
/**
@@ -35,18 +36,25 @@ final class MgmtSoftwareModuleTypeMapper {
}
static List<SoftwareModuleType> smFromRequest(final Iterable<MgmtSoftwareModuleTypeRequestBodyPost> smTypesRest) {
static List<SoftwareModuleType> smFromRequest(final SoftwareManagement softwareManagement,
final Iterable<MgmtSoftwareModuleTypeRequestBodyPost> smTypesRest) {
final List<SoftwareModuleType> mappedList = new ArrayList<>();
for (final MgmtSoftwareModuleTypeRequestBodyPost smRest : smTypesRest) {
mappedList.add(fromRequest(smRest));
mappedList.add(fromRequest(softwareManagement, smRest));
}
return mappedList;
}
static SoftwareModuleType fromRequest(final MgmtSoftwareModuleTypeRequestBodyPost smsRest) {
return new SoftwareModuleType(smsRest.getKey(), smsRest.getName(), smsRest.getDescription(),
smsRest.getMaxAssignments());
static SoftwareModuleType fromRequest(final SoftwareManagement softwareManagement,
final MgmtSoftwareModuleTypeRequestBodyPost smsRest) {
final SoftwareModuleType result = softwareManagement.generateSoftwareModuleType();
result.setName(smsRest.getName());
result.setKey(smsRest.getKey());
result.setDescription(smsRest.getDescription());
result.setMaxAssignments(smsRest.getMaxAssignments());
return result;
}
static List<MgmtSoftwareModuleType> toTypesResponse(final List<SoftwareModuleType> types) {

View File

@@ -18,12 +18,10 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SoftwareModuleTypeFields;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -62,8 +60,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
final Slice<SoftwareModuleType> findModuleTypessAll;
Long countModulesAll;
if (rsqlParam != null) {
findModuleTypessAll = this.softwareManagement.findSoftwareModuleTypesByPredicate(
RSQLUtility.parse(rsqlParam, SoftwareModuleTypeFields.class), pageable);
findModuleTypessAll = this.softwareManagement.findSoftwareModuleTypesAll(rsqlParam, pageable);
countModulesAll = ((Page<SoftwareModuleType>) findModuleTypessAll).getTotalElements();
} else {
findModuleTypessAll = this.softwareManagement.findSoftwareModuleTypesAll(pageable);
@@ -112,8 +109,8 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
public ResponseEntity<List<MgmtSoftwareModuleType>> createSoftwareModuleTypes(
@RequestBody final List<MgmtSoftwareModuleTypeRequestBodyPost> softwareModuleTypes) {
final List<SoftwareModuleType> createdSoftwareModules = this.softwareManagement
.createSoftwareModuleType(MgmtSoftwareModuleTypeMapper.smFromRequest(softwareModuleTypes));
final List<SoftwareModuleType> createdSoftwareModules = this.softwareManagement.createSoftwareModuleType(
MgmtSoftwareModuleTypeMapper.smFromRequest(softwareManagement, softwareModuleTypes));
return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toTypesResponse(createdSoftwareModules),
HttpStatus.CREATED);

View File

@@ -18,6 +18,7 @@ import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTagRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTagRestApi;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.Tag;
import org.eclipse.hawkbit.repository.model.TargetTag;
@@ -84,8 +85,9 @@ final class MgmtTagMapper {
mapTag(response, distributionSetTag);
response.add(linkTo(methodOn(MgmtDistributionSetTagRestApi.class).getDistributionSetTag(distributionSetTag.getId()))
.withRel("self"));
response.add(
linkTo(methodOn(MgmtDistributionSetTagRestApi.class).getDistributionSetTag(distributionSetTag.getId()))
.withRel("self"));
response.add(linkTo(
methodOn(MgmtDistributionSetTagRestApi.class).getAssignedDistributionSets(distributionSetTag.getId()))
@@ -94,20 +96,22 @@ final class MgmtTagMapper {
return response;
}
static List<TargetTag> mapTargeTagFromRequest(final Iterable<MgmtTagRequestBodyPut> tags) {
static List<TargetTag> mapTargeTagFromRequest(final TagManagement tagManagement,
final Iterable<MgmtTagRequestBodyPut> tags) {
final List<TargetTag> mappedList = new ArrayList<>();
for (final MgmtTagRequestBodyPut targetTagRest : tags) {
mappedList.add(
new TargetTag(targetTagRest.getName(), targetTagRest.getDescription(), targetTagRest.getColour()));
mappedList.add(tagManagement.generateTargetTag(targetTagRest.getName(), targetTagRest.getDescription(),
targetTagRest.getColour()));
}
return mappedList;
}
static List<DistributionSetTag> mapDistributionSetTagFromRequest(final Iterable<MgmtTagRequestBodyPut> tags) {
static List<DistributionSetTag> mapDistributionSetTagFromRequest(final TagManagement tagManagement,
final Iterable<MgmtTagRequestBodyPut> tags) {
final List<DistributionSetTag> mappedList = new ArrayList<>();
for (final MgmtTagRequestBodyPut targetTagRest : tags) {
mappedList.add(new DistributionSetTag(targetTagRest.getName(), targetTagRest.getDescription(),
targetTagRest.getColour()));
mappedList.add(tagManagement.generateDistributionSetTag(targetTagRest.getName(),
targetTagRest.getDescription(), targetTagRest.getColour()));
}
return mappedList;
}

View File

@@ -25,10 +25,11 @@ import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi;
import org.eclipse.hawkbit.repository.ActionFields;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.ActionStatus;
import org.eclipse.hawkbit.repository.model.PollStatus;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetInfo.PollStatus;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.rest.data.SortDirection;
@@ -168,16 +169,17 @@ public final class MgmtTargetMapper {
return targetRest;
}
static List<Target> fromRequest(final Iterable<MgmtTargetRequestBody> targetsRest) {
static List<Target> fromRequest(final TargetManagement targetManagement,
final Iterable<MgmtTargetRequestBody> targetsRest) {
final List<Target> mappedList = new ArrayList<>();
for (final MgmtTargetRequestBody targetRest : targetsRest) {
mappedList.add(fromRequest(targetRest));
mappedList.add(fromRequest(targetManagement, targetRest));
}
return mappedList;
}
static Target fromRequest(final MgmtTargetRequestBody targetRest) {
final Target target = new Target(targetRest.getControllerId());
static Target fromRequest(final TargetManagement targetManagement, final MgmtTargetRequestBody targetRest) {
final Target target = targetManagement.generateTarget(targetRest.getControllerId());
target.setDescription(targetRest.getDescription());
target.setName(targetRest.getName());
return target;

View File

@@ -26,18 +26,15 @@ import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi;
import org.eclipse.hawkbit.repository.ActionFields;
import org.eclipse.hawkbit.repository.ActionStatusFields;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.TargetFields;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.ActionStatus;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
import org.eclipse.hawkbit.rest.data.SortDirection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,7 +43,6 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
@@ -93,8 +89,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
final Slice<Target> findTargetsAll;
final Long countTargetsAll;
if (rsqlParam != null) {
final Page<Target> findTargetPage = this.targetManagement
.findTargetsAll(RSQLUtility.parse(rsqlParam, TargetFields.class), pageable);
final Page<Target> findTargetPage = this.targetManagement.findTargetsAll(rsqlParam, pageable);
countTargetsAll = findTargetPage.getTotalElements();
findTargetsAll = findTargetPage;
} else {
@@ -110,7 +105,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
public ResponseEntity<List<MgmtTarget>> createTargets(@RequestBody final List<MgmtTargetRequestBody> targets) {
LOG.debug("creating {} targets", targets.size());
final Iterable<Target> createdTargets = this.targetManagement
.createTargets(MgmtTargetMapper.fromRequest(targets));
.createTargets(MgmtTargetMapper.fromRequest(targetManagement, targets));
LOG.debug("{} targets created, return status {}", targets.size(), HttpStatus.CREATED);
return new ResponseEntity<>(MgmtTargetMapper.toResponse(createdTargets), HttpStatus.CREATED);
}
@@ -170,9 +165,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
final Slice<Action> activeActions;
final Long totalActionCount;
if (rsqlParam != null) {
final Specification<Action> parse = RSQLUtility.parse(rsqlParam, ActionFields.class);
activeActions = this.deploymentManagement.findActionsByTarget(parse, foundTarget, pageable);
totalActionCount = this.deploymentManagement.countActionsByTarget(parse, foundTarget);
activeActions = this.deploymentManagement.findActionsByTarget(rsqlParam, foundTarget, pageable);
totalActionCount = this.deploymentManagement.countActionsByTarget(rsqlParam, foundTarget);
} else {
activeActions = this.deploymentManagement.findActionsByTarget(foundTarget, pageable);
totalActionCount = this.deploymentManagement.countActionsByTarget(foundTarget);
@@ -250,8 +244,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
final Sort sorting = PagingUtility.sanitizeActionStatusSortParam(sortParam);
final Page<ActionStatus> statusList = this.deploymentManagement.findActionStatusByAction(
new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting), action, true);
final Page<ActionStatus> statusList = this.deploymentManagement.findActionStatusByActionWithMessages(
new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting), action);
return new ResponseEntity<>(
new PagedList<>(MgmtTargetMapper.toActionStatusRestResponse(statusList.getContent()),

View File

@@ -20,14 +20,12 @@ import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTagRestApi;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.TagFields;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -75,8 +73,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
countTargetsAll = this.tagManagement.countTargetTags();
} else {
final Page<TargetTag> findTargetPage = this.tagManagement
.findAllTargetTags(RSQLUtility.parse(rsqlParam, TagFields.class), pageable);
final Page<TargetTag> findTargetPage = this.tagManagement.findAllTargetTags(rsqlParam, pageable);
countTargetsAll = findTargetPage.getTotalElements();
findTargetsAll = findTargetPage;
@@ -96,7 +93,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
public ResponseEntity<List<MgmtTag>> createTargetTags(@RequestBody final List<MgmtTagRequestBodyPut> tags) {
LOG.debug("creating {} target tags", tags.size());
final List<TargetTag> createdTargetTags = this.tagManagement
.createTargetTags(MgmtTagMapper.mapTargeTagFromRequest(tags));
.createTargetTags(MgmtTagMapper.mapTargeTagFromRequest(tagManagement, tags));
return new ResponseEntity<>(MgmtTagMapper.toResponse(createdTargetTags), HttpStatus.CREATED);
}

View File

@@ -30,10 +30,10 @@ import org.eclipse.hawkbit.TestDataUtil;
import org.eclipse.hawkbit.WithUser;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.jpa.model.DsMetadataCompositeKey;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.DsMetadataCompositeKey;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
@@ -76,7 +76,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
final DistributionSet disSet = TestDataUtil.generateDistributionSetWithNoSoftwareModules("Eris", "560a",
distributionSetManagement);
final List<Long> smIDs = new ArrayList<Long>();
SoftwareModule sm = new SoftwareModule(osType, "Dysnomia ", "15,772", null, null);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "Dysnomia ", "15,772", null, null);
sm = softwareManagement.createSoftwareModule(sm);
smIDs.add(sm.getId());
final JSONArray smList = new JSONArray();
@@ -92,7 +92,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
final String[] knownTargetIds = new String[] { "1", "2" };
final JSONArray list = new JSONArray();
for (final String targetId : knownTargetIds) {
targetManagement.createTarget(new Target(targetId));
targetManagement.createTarget(targetManagement.generateTarget(targetId));
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
}
deploymentManagement.assignDistributionSet(disSet.getId(), knownTargetIds[0]);
@@ -120,7 +120,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
final DistributionSet disSet = TestDataUtil.generateDistributionSetWithNoSoftwareModules("Mars", "686,980",
distributionSetManagement);
final List<Long> smIDs = new ArrayList<>();
SoftwareModule sm = new SoftwareModule(osType, "Phobos", "0,3189", null, null);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "Phobos", "0,3189", null, null);
sm = softwareManagement.createSoftwareModule(sm);
smIDs.add(sm.getId());
final JSONArray smList = new JSONArray();
@@ -136,7 +136,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
final String[] knownTargetIds = new String[] { "1", "2" };
final JSONArray list = new JSONArray();
for (final String targetId : knownTargetIds) {
targetManagement.createTarget(new Target(targetId));
targetManagement.createTarget(targetManagement.generateTarget(targetId));
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
}
// assign DisSet to target and test assignment
@@ -150,8 +150,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
.andExpect(jsonPath("$.total", equalTo(knownTargetIds.length)));
// Create another SM and post assignment
final List<Long> smID2s = new ArrayList<Long>();
SoftwareModule sm2 = new SoftwareModule(appType, "Deimos", "1,262", null, null);
final List<Long> smID2s = new ArrayList<>();
SoftwareModule sm2 = softwareManagement.generateSoftwareModule(appType, "Deimos", "1,262", null, null);
sm2 = softwareManagement.createSoftwareModule(sm2);
smID2s.add(sm2.getId());
final JSONArray smList2 = new JSONArray();
@@ -178,13 +178,13 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
.andExpect(jsonPath("$.size", equalTo(disSet.getModules().size())));
// create Software Modules
final List<Long> smIDs = new ArrayList<Long>();
SoftwareModule sm = new SoftwareModule(osType, "Europa", "3,551", null, null);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "Europa", "3,551", null, null);
sm = softwareManagement.createSoftwareModule(sm);
smIDs.add(sm.getId());
SoftwareModule sm2 = new SoftwareModule(appType, "Ganymed", "7,155", null, null);
SoftwareModule sm2 = softwareManagement.generateSoftwareModule(appType, "Ganymed", "7,155", null, null);
sm2 = softwareManagement.createSoftwareModule(sm2);
smIDs.add(sm2.getId());
SoftwareModule sm3 = new SoftwareModule(runtimeType, "Kallisto", "16,689", null, null);
SoftwareModule sm3 = softwareManagement.generateSoftwareModule(runtimeType, "Kallisto", "16,689", null, null);
sm3 = softwareManagement.createSoftwareModule(sm3);
smIDs.add(sm3.getId());
final JSONArray list = new JSONArray();
@@ -234,7 +234,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
final String[] knownTargetIds = new String[] { "1", "2", "3", "4", "5" };
final JSONArray list = new JSONArray();
for (final String targetId : knownTargetIds) {
targetManagement.createTarget(new Target(targetId));
targetManagement.createTarget(targetManagement.generateTarget(targetId));
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
}
// assign already one target to DS
@@ -258,7 +258,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
final String knownTargetId = "knownTargetId1";
final Set<DistributionSet> createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1);
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
targetManagement.createTarget(new Target(knownTargetId));
targetManagement.createTarget(targetManagement.generateTarget(knownTargetId));
deploymentManagement.assignDistributionSet(createdDs.getId(), knownTargetId);
mvc.perform(get(
@@ -285,10 +285,10 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
final String knownTargetId = "knownTargetId1";
final Set<DistributionSet> createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1);
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
final Target createTarget = targetManagement.createTarget(new Target(knownTargetId));
final Target createTarget = targetManagement.createTarget(targetManagement.generateTarget(knownTargetId));
// create some dummy targets which are not assigned or installed
targetManagement.createTarget(new Target("dummy1"));
targetManagement.createTarget(new Target("dummy2"));
targetManagement.createTarget(targetManagement.generateTarget("dummy1"));
targetManagement.createTarget(targetManagement.generateTarget("dummy2"));
// assign knownTargetId to distribution set
deploymentManagement.assignDistributionSet(createdDs.getId(), knownTargetId);
// make it in install state
@@ -348,7 +348,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
@Description("Ensures that multiple DS requested are listed with expected payload.")
public void getDistributionSets() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
.hasSize(0);
DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
distributionSetManagement);
@@ -361,7 +362,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
// load also lazy stuff
set = distributionSetManagement.findDistributionSetByIdWithDetails(set.getId());
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(1);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
.hasSize(1);
// perform request
mvc.perform(get("/rest/v1/distributionsets").accept(MediaType.APPLICATION_JSON))
@@ -425,14 +427,15 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Ensures that multipe DS posted to API are created in the repository.")
public void createDistributionSets() throws JSONException, Exception {
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
.hasSize(0);
final SoftwareModule ah = softwareManagement
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
final SoftwareModule jvm = softwareManagement
.createSoftwareModule(new SoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, ""));
final SoftwareModule ah = softwareManagement.createSoftwareModule(
softwareManagement.generateSoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
final SoftwareModule jvm = softwareManagement.createSoftwareModule(
softwareManagement.generateSoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, ""));
final SoftwareModule os = softwareManagement
.createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2", null, ""));
.createSoftwareModule(softwareManagement.generateSoftwareModule(osType, "poky", "3.0.2", null, ""));
DistributionSet one = TestDataUtil.buildDistributionSet("one", "one", standardDsType, os, jvm, ah);
DistributionSet two = TestDataUtil.buildDistributionSet("two", "two", standardDsType, os, jvm, ah);
@@ -527,7 +530,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
.isEqualTo(String.valueOf(three.getId()));
// check in database
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(3);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
.hasSize(3);
assertThat(one.isRequiredMigrationStep()).isEqualTo(false);
assertThat(two.isRequiredMigrationStep()).isEqualTo(false);
assertThat(three.isRequiredMigrationStep()).isEqualTo(true);
@@ -541,19 +545,22 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
@Description("Ensures that DS deletion request to API is reflected by the repository.")
public void deleteUnassignedistributionSet() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
.hasSize(0);
final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
distributionSetManagement);
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(1);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
.hasSize(1);
// perform request
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
// check repository content
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).isEmpty();
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
.isEmpty();
assertThat(distributionSetRepository.findAll()).isEmpty();
}
@@ -561,22 +568,26 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
@Description("Ensures that assigned DS deletion request to API is reflected by the repository by means of deleted flag set.")
public void deleteAssignedDistributionSet() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
.hasSize(0);
final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
distributionSetManagement);
targetManagement.createTarget(new Target("test"));
targetManagement.createTarget(targetManagement.generateTarget("test"));
deploymentManagement.assignDistributionSet(set.getId(), "test");
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(1);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
.hasSize(1);
// perform request
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
// check repository content
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, true, true)).hasSize(1);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
.hasSize(0);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, true, true))
.hasSize(1);
}
@Test
@@ -584,14 +595,16 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
public void updateDistributionSet() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
.hasSize(0);
final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
distributionSetManagement);
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(1);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
.hasSize(1);
final DistributionSet update = new DistributionSet();
final DistributionSet update = distributionSetManagement.generateDistributionSet();
update.setVersion("anotherVersion");
update.setName(null);
update.setType(standardDsType);
@@ -600,11 +613,10 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true).getContent().get(0)
.getVersion()).isEqualTo("anotherVersion");
assertThat(
distributionSetManagement.findDistributionSetsAll(pageReq, false, true).getContent().get(0).getName())
.isEqualTo(set.getName());
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true)
.getContent().get(0).getVersion()).isEqualTo("anotherVersion");
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true)
.getContent().get(0).getName()).isEqualTo(set.getName());
}
@Test
@@ -692,8 +704,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement,
distributionSetManagement);
distributionSetManagement
.createDistributionSetMetadata(new DistributionSetMetadata(knownKey, testDS, knownValue));
distributionSetManagement.createDistributionSetMetadata(
distributionSetManagement.generateDistributionSetMetadata(testDS, knownKey, knownValue));
final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue);
@@ -718,8 +730,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement,
distributionSetManagement);
distributionSetManagement
.createDistributionSetMetadata(new DistributionSetMetadata(knownKey, testDS, knownValue));
distributionSetManagement.createDistributionSetMetadata(
distributionSetManagement.generateDistributionSetMetadata(testDS, knownKey, knownValue));
mvc.perform(delete("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
@@ -740,8 +752,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
final String knownValue = "knownValue";
final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement,
distributionSetManagement);
distributionSetManagement
.createDistributionSetMetadata(new DistributionSetMetadata(knownKey, testDS, knownValue));
distributionSetManagement.createDistributionSetMetadata(
distributionSetManagement.generateDistributionSetMetadata(testDS, knownKey, knownValue));
mvc.perform(get("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
@@ -760,8 +772,9 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement,
distributionSetManagement);
for (int index = 0; index < totalMetadata; index++) {
distributionSetManagement.createDistributionSetMetadata(new DistributionSetMetadata(knownKeyPrefix + index,
distributionSetManagement.findDistributionSetById(testDS.getId()), knownValuePrefix + index));
distributionSetManagement.createDistributionSetMetadata(distributionSetManagement
.generateDistributionSetMetadata(distributionSetManagement.findDistributionSetById(testDS.getId()),
knownKeyPrefix + index, knownValuePrefix + index));
}
mvc.perform(get("/rest/v1/distributionsets/{dsId}/metadata?offset=" + offsetParam + "&limit=" + limitParam,
@@ -795,8 +808,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
public void filterDistributionSetComplete() throws Exception {
final int amount = 10;
TestDataUtil.generateDistributionSets(amount, softwareManagement, distributionSetManagement);
distributionSetManagement.createDistributionSet(new DistributionSet("incomplete", "2", "incomplete",
distributionSetManagement.findDistributionSetTypeByKey("ecl_os"), null));
distributionSetManagement.createDistributionSet(distributionSetManagement.generateDistributionSet("incomplete",
"2", "incomplete", distributionSetManagement.findDistributionSetTypeByKey("ecl_os"), null));
final String rsqlFindLikeDs1OrDs2 = "complete==" + Boolean.TRUE;
@@ -815,7 +828,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
final String[] knownTargetIds = new String[] { "1", "2", "3", "4", "5" };
final JSONArray list = new JSONArray();
for (final String targetId : knownTargetIds) {
targetManagement.createTarget(new Target(targetId));
targetManagement.createTarget(targetManagement.generateTarget(targetId));
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
}
@@ -840,8 +853,9 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement,
distributionSetManagement);
for (int index = 0; index < totalMetadata; index++) {
distributionSetManagement.createDistributionSetMetadata(new DistributionSetMetadata(knownKeyPrefix + index,
distributionSetManagement.findDistributionSetById(testDS.getId()), knownValuePrefix + index));
distributionSetManagement.createDistributionSetMetadata(distributionSetManagement
.generateDistributionSetMetadata(distributionSetManagement.findDistributionSetById(testDS.getId()),
knownKeyPrefix + index, knownValuePrefix + index));
}
final String rsqlSearchValue1 = "value==knownValue1";

View File

@@ -25,7 +25,6 @@ import java.util.List;
import org.eclipse.hawkbit.WithUser;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@@ -58,8 +57,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes GET requests.")
public void getDistributionSetTypes() throws Exception {
DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
testType.setDescription("Desc1234");
testType = distributionSetManagement.updateDistributionSetType(testType);
@@ -96,8 +95,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes GET requests with sorting by KEY.")
public void getDistributionSetTypesSortedByKey() throws Exception {
DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("zzzzz", "TestName123", "Desc123"));
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("zzzzz", "TestName123", "Desc123"));
testType.setDescription("Desc1234");
testType = distributionSetManagement.updateDistributionSetType(testType);
@@ -136,12 +135,12 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(3);
final List<DistributionSetType> types = new ArrayList<>();
types.add(new DistributionSetType("test1", "TestName1", "Desc1").addMandatoryModuleType(osType)
.addOptionalModuleType(runtimeType));
types.add(new DistributionSetType("test2", "TestName2", "Desc2").addOptionalModuleType(osType)
.addOptionalModuleType(runtimeType).addOptionalModuleType(appType));
types.add(new DistributionSetType("test3", "TestName3", "Desc3").addMandatoryModuleType(osType)
.addMandatoryModuleType(runtimeType));
types.add(distributionSetManagement.generateDistributionSetType("test1", "TestName1", "Desc1")
.addMandatoryModuleType(osType).addOptionalModuleType(runtimeType));
types.add(distributionSetManagement.generateDistributionSetType("test2", "TestName2", "Desc2")
.addOptionalModuleType(osType).addOptionalModuleType(runtimeType).addOptionalModuleType(appType));
types.add(distributionSetManagement.generateDistributionSetType("test3", "TestName3", "Desc3")
.addMandatoryModuleType(osType).addMandatoryModuleType(runtimeType));
final MvcResult mvcResult = mvc
.perform(post("/rest/v1/distributionsettypes/").content(JsonBuilder.distributionSetTypes(types))
@@ -205,8 +204,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes POST requests.")
public void addMandatoryModuleToDistributionSetType() throws JSONException, Exception {
DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType.getId())
@@ -224,8 +223,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes POST requests.")
public void addOptionalModuleToDistributionSetType() throws JSONException, Exception {
DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId())
@@ -244,8 +243,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes GET requests.")
public void getMandatoryModulesOfDistributionSetType() throws JSONException, Exception {
final DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123")
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
@@ -263,8 +262,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes GET requests.")
public void getOptionalModulesOfDistributionSetType() throws JSONException, Exception {
final DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123")
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
@@ -283,8 +282,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes/{ID} GET requests.")
public void getMandatoryModuleOfDistributionSetType() throws JSONException, Exception {
final DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123")
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
@@ -305,8 +304,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes/{ID} GET requests.")
public void getOptionalModuleOfDistributionSetType() throws JSONException, Exception {
final DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123")
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
@@ -327,8 +326,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes/{ID} DELETE requests.")
public void removeMandatoryModuleToDistributionSetType() throws JSONException, Exception {
DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123")
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
@@ -349,8 +348,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes/{ID} DELETE requests.")
public void removeOptionalModuleToDistributionSetType() throws JSONException, Exception {
DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123")
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
@@ -372,8 +371,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID} GET requests.")
public void getDistributionSetType() throws Exception {
DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
testType.setDescription("Desc1234");
testType = distributionSetManagement.updateDistributionSetType(testType);
@@ -391,8 +390,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/DistributionSetTypes/{ID} DELETE requests (hard delete scenario).")
public void deleteDistributionSetTypeUnused() throws Exception {
final DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(4);
@@ -406,10 +405,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/DistributionSetTypes/{ID} DELETE requests (soft delete scenario).")
public void deleteDistributionSetTypeUsed() throws Exception {
final DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
distributionSetManagement
.createDistributionSet(new DistributionSet("sdfsd", "dsfsdf", "sdfsdf", testType, null));
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
distributionSetManagement.createDistributionSet(
distributionSetManagement.generateDistributionSet("sdfsd", "dsfsdf", "sdfsdf", testType, null));
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(4);
assertThat(distributionSetTypeRepository.count()).isEqualTo(4);
@@ -424,8 +423,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@Test
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID} PUT requests.")
public void updateDistributionSetTypeOnlyDescriptionAndNameUntouched() throws Exception {
final DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
final String body = new JSONObject().put("id", testType.getId()).put("description", "foobardesc")
.put("name", "nameShouldNotBeChanged").toString();
@@ -479,11 +478,11 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@Test
@Description("Ensures that the server is behaving as expected on invalid requests (wrong media type, wrong ID etc.).")
public void invalidRequestsOnDistributionSetTypesResource() throws Exception {
final DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
final SoftwareModuleType testSmType = softwareManagement
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
final SoftwareModuleType testSmType = softwareManagement.createSoftwareModuleType(
softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
final List<DistributionSetType> types = new ArrayList<>();
types.add(testType);
@@ -526,8 +525,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
// Modules types at creation time invalid
final DistributionSetType testNewType = new DistributionSetType("test123", "TestName123", "Desc123");
testNewType.addMandatoryModuleType(new SoftwareModuleType("foo", "bar", "test", Integer.MAX_VALUE));
final DistributionSetType testNewType = distributionSetManagement.generateDistributionSetType("test123",
"TestName123", "Desc123");
testNewType.addMandatoryModuleType(
softwareManagement.generateSoftwareModuleType("foo", "bar", "test", Integer.MAX_VALUE));
mvc.perform(post("/rest/v1/distributionsettypes")
.content(JsonBuilder.distributionSetTypes(Lists.newArrayList(testNewType)))
@@ -560,10 +561,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
@Test
@Description("Search erquest of software module types.")
public void searchDistributionSetTypeRsql() throws Exception {
final DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
final DistributionSetType testType2 = distributionSetManagement
.createDistributionSetType(new DistributionSetType("test1234", "TestName1234", "Desc123"));
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
final DistributionSetType testType2 = distributionSetManagement.createDistributionSetType(
distributionSetManagement.generateDistributionSetType("test1234", "TestName1234", "Desc123"));
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
@@ -577,7 +578,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
char character = 'a';
for (int index = 0; index < amount; index++) {
final String str = String.valueOf(character);
final SoftwareModule softwareModule = new SoftwareModule(osType, str, str, str, str);
final SoftwareModule softwareModule = softwareManagement.generateSoftwareModule(osType, str, str, str, str);
softwareManagement.createSoftwareModule(softwareModule);
character++;

View File

@@ -30,8 +30,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupConditionBuilder;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
import org.eclipse.hawkbit.rest.util.JsonBuilder;
@@ -577,7 +577,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
private Rollout createRollout(final String name, final int amountGroups, final long distributionSetId,
final String targetFilterQuery) {
final Rollout rollout = new Rollout();
final Rollout rollout = rolloutManagement.generateRollout();
rollout.setDistributionSet(distributionSetManagement.findDistributionSetById(distributionSetId));
rollout.setName(name);
rollout.setTargetFilterQuery(targetFilterQuery);

View File

@@ -44,7 +44,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.LocalArtifact;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey;
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTestWithMongoDB;
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
import org.eclipse.hawkbit.rest.util.JsonBuilder;
@@ -92,11 +91,15 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
final String updateVendor = "newVendor1";
final String updateDescription = "newDescription1";
softwareManagement.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
softwareManagement.createSoftwareModule(new SoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, ""));
softwareManagement.createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2", null, ""));
softwareManagement.createSoftwareModule(
softwareManagement.generateSoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
softwareManagement.createSoftwareModule(
softwareManagement.generateSoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, ""));
softwareManagement
.createSoftwareModule(softwareManagement.generateSoftwareModule(osType, "poky", "3.0.2", null, ""));
SoftwareModule sm = new SoftwareModule(osType, knownSWName, knownSWVersion, knownSWDescription, knownSWVendor);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, knownSWName, knownSWVersion,
knownSWDescription, knownSWVendor);
sm = softwareManagement.createSoftwareModule(sm);
assertThat(sm.getName()).as("Wrong name of the software module").isEqualTo(knownSWName);
@@ -122,7 +125,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
@Test
@Description("Tests the uppload of an artifact binary. The upload is executed and the content checked in the repository for completenes.")
public void uploadArtifact() throws Exception {
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
sm = softwareManagement.createSoftwareModule(sm);
assertThat(artifactRepository.findAll()).hasSize(0);
@@ -191,7 +194,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0);
assertThat(artifactRepository.findAll()).hasSize(0);
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
sm = softwareManagement.createSoftwareModule(sm);
final MockMultipartFile file = new MockMultipartFile("file", "orig", null, new byte[0]);
@@ -204,7 +207,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
@Test
@Description("Verfies that the system does not accept identical artifacts uploads for the same software module. Expected response: CONFLICT")
public void duplicateUploadArtifact() throws Exception {
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
sm = softwareManagement.createSoftwareModule(sm);
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
@@ -226,7 +229,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
@Test
@Description("verfies that option to upload artifacts with a custom defined by metadata, i.e. not the file name of the binary itself.")
public void uploadArtifactWithCustomName() throws Exception {
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
sm = softwareManagement.createSoftwareModule(sm);
assertThat(artifactRepository.findAll()).hasSize(0);
@@ -253,7 +256,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
@Test
@Description("Verfies that the system refuses upload of an artifact where the provided hash sums do not match. Expected result: BAD REQUEST")
public void uploadArtifactWithHashCheck() throws Exception {
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
sm = softwareManagement.createSoftwareModule(sm);
assertThat(artifactRepository.findAll()).hasSize(0);
@@ -297,7 +300,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
@Test
@Description("Tests binary download of an artifact including verfication that the downloaded binary is consistent and that the etag header is as expected identical to the SHA1 hash of the file.")
public void downloadArtifact() throws Exception {
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
sm = softwareManagement.createSoftwareModule(sm);
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
@@ -332,7 +335,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
@Description("Verifies the listing of one defined artifact assigned to a given software module. That includes the artifact metadata and download links.")
public void getArtifact() throws Exception {
// prepare data for test
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
sm = softwareManagement.createSoftwareModule(sm);
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
@@ -358,7 +361,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
@Test
@Description("Verifies the listing of all artifacts assigned to a software module. That includes the artifact metadata and download links.")
public void getArtifacts() throws Exception {
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
sm = softwareManagement.createSoftwareModule(sm);
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
@@ -401,7 +404,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
final MockMultipartFile file = new MockMultipartFile("file", "orig", null, random);
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
sm = softwareManagement.createSoftwareModule(sm);
// no artifact available
@@ -434,7 +437,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
@Test
@Description("Verfies that the system refuses unsupported request types and answers as defined to them, e.g. NOT FOUND on a non existing resource. Or a HTTP POST for updating a resource results in METHOD NOT ALLOWED etc.")
public void invalidRequestsOnSoftwaremodulesResource() throws Exception {
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
sm = softwareManagement.createSoftwareModule(sm);
final List<SoftwareModule> modules = new ArrayList<>();
@@ -516,13 +519,16 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Test retrieval of all software modules the user has access to.")
public void getSoftwareModules() throws Exception {
SoftwareModule os = new SoftwareModule(osType, "name1", "version1", "description1", "vendor1");
SoftwareModule os = softwareManagement.generateSoftwareModule(osType, "name1", "version1", "description1",
"vendor1");
os = softwareManagement.createSoftwareModule(os);
SoftwareModule jvm = new SoftwareModule(runtimeType, "name1", "version1", "description1", "vendor1");
SoftwareModule jvm = softwareManagement.generateSoftwareModule(runtimeType, "name1", "version1", "description1",
"vendor1");
jvm = softwareManagement.createSoftwareModule(jvm);
SoftwareModule ah = new SoftwareModule(appType, "name1", "version1", "description1", "vendor1");
SoftwareModule ah = softwareManagement.generateSoftwareModule(appType, "name1", "version1", "description1",
"vendor1");
ah = softwareManagement.createSoftwareModule(ah);
mvc.perform(get("/rest/v1/softwaremodules").accept(MediaType.APPLICATION_JSON))
@@ -584,22 +590,28 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
@Test
@Description("Test the various filter parameters, e.g. filter by name or type of the module.")
public void getSoftwareModulesWithFilterParameters() throws Exception {
SoftwareModule os1 = new SoftwareModule(osType, "osName1", "1.0.0", "description1", "vendor1");
SoftwareModule os1 = softwareManagement.generateSoftwareModule(osType, "osName1", "1.0.0", "description1",
"vendor1");
os1 = softwareManagement.createSoftwareModule(os1);
SoftwareModule jvm1 = new SoftwareModule(runtimeType, "runtimeName1", "2.0.0", "description1", "vendor1");
SoftwareModule jvm1 = softwareManagement.generateSoftwareModule(runtimeType, "runtimeName1", "2.0.0",
"description1", "vendor1");
jvm1 = softwareManagement.createSoftwareModule(jvm1);
SoftwareModule ah1 = new SoftwareModule(appType, "appName1", "3.0.0", "description1", "vendor1");
SoftwareModule ah1 = softwareManagement.generateSoftwareModule(appType, "appName1", "3.0.0", "description1",
"vendor1");
ah1 = softwareManagement.createSoftwareModule(ah1);
SoftwareModule os2 = new SoftwareModule(osType, "osName2", "1.0.1", "description2", "vendor2");
SoftwareModule os2 = softwareManagement.generateSoftwareModule(osType, "osName2", "1.0.1", "description2",
"vendor2");
os2 = softwareManagement.createSoftwareModule(os2);
SoftwareModule jvm2 = new SoftwareModule(runtimeType, "runtimeName2", "2.0.1", "description2", "vendor2");
SoftwareModule jvm2 = softwareManagement.generateSoftwareModule(runtimeType, "runtimeName2", "2.0.1",
"description2", "vendor2");
jvm2 = softwareManagement.createSoftwareModule(jvm2);
SoftwareModule ah2 = new SoftwareModule(appType, "appName2", "3.0.1", "description2", "vendor2");
SoftwareModule ah2 = softwareManagement.generateSoftwareModule(appType, "appName2", "3.0.1", "description2",
"vendor2");
ah2 = softwareManagement.createSoftwareModule(ah2);
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(6);
@@ -676,7 +688,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Tests GET request on /rest/v1/softwaremodules/{smId}.")
public void getSoftareModule() throws Exception {
SoftwareModule os = new SoftwareModule(osType, "name1", "version1", "description1", "vendor1");
SoftwareModule os = softwareManagement.generateSoftwareModule(osType, "name1", "version1", "description1",
"vendor1");
os = softwareManagement.createSoftwareModule(os);
mvc.perform(get("/rest/v1/softwaremodules/{smId}", os.getId()).accept(MediaType.APPLICATION_JSON))
@@ -695,7 +708,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
.andExpect(jsonPath("$_links.artifacts.href",
equalTo("http://localhost/rest/v1/softwaremodules/" + os.getId() + "/artifacts")));
SoftwareModule jvm = new SoftwareModule(runtimeType, "name1", "version1", "description1", "vendor1");
SoftwareModule jvm = softwareManagement.generateSoftwareModule(runtimeType, "name1", "version1", "description1",
"vendor1");
jvm = softwareManagement.createSoftwareModule(jvm);
mvc.perform(get("/rest/v1/softwaremodules/{smId}", jvm.getId()).accept(MediaType.APPLICATION_JSON))
@@ -714,7 +728,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
.andExpect(jsonPath("$_links.artifacts.href",
equalTo("http://localhost/rest/v1/softwaremodules/" + jvm.getId() + "/artifacts")));
SoftwareModule ah = new SoftwareModule(appType, "name1", "version1", "description1", "vendor1");
SoftwareModule ah = softwareManagement.generateSoftwareModule(appType, "name1", "version1", "description1",
"vendor1");
ah = softwareManagement.createSoftwareModule(ah);
mvc.perform(get("/rest/v1/softwaremodules/{smId}", ah.getId()).accept(MediaType.APPLICATION_JSON))
@@ -740,9 +755,12 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Verfies that the create request actually results in the creation of the modules in the repository.")
public void createSoftwareModules() throws JSONException, Exception {
final SoftwareModule os = new SoftwareModule(osType, "name1", "version1", "description1", "vendor1");
final SoftwareModule jvm = new SoftwareModule(runtimeType, "name2", "version1", "description1", "vendor1");
final SoftwareModule ah = new SoftwareModule(appType, "name3", "version1", "description1", "vendor1");
final SoftwareModule os = softwareManagement.generateSoftwareModule(osType, "name1", "version1", "description1",
"vendor1");
final SoftwareModule jvm = softwareManagement.generateSoftwareModule(runtimeType, "name2", "version1",
"description1", "vendor1");
final SoftwareModule ah = softwareManagement.generateSoftwareModule(appType, "name3", "version1",
"description1", "vendor1");
final List<SoftwareModule> modules = new ArrayList<>();
modules.add(os);
@@ -823,7 +841,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
@Description("Verifies successfull deletion of software modules that are not in use, i.e. assigned to a DS.")
public void deleteUnassignedSoftwareModule() throws Exception {
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
sm = softwareManagement.createSoftwareModule(sm);
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
@@ -879,7 +897,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
@Description("Tests the deletion of an artifact including verfication that the artifact is actually erased in the repository and removed from the software module.")
public void deleteArtifact() throws Exception {
// Create 1 SM
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
sm = softwareManagement.createSoftwareModule(sm);
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
@@ -918,8 +936,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
final String knownKey2 = "knownKey1";
final String knownValue2 = "knownValue1";
final SoftwareModule sm = softwareManagement
.createSoftwareModule(new SoftwareModule(osType, "name 1", "version 1", null, null));
final SoftwareModule sm = softwareManagement.createSoftwareModule(
softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null));
final JSONArray jsonArray = new JSONArray();
jsonArray.put(new JSONObject().put("key", knownKey1).put("value", knownValue1));
@@ -932,10 +950,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
.andExpect(jsonPath("[1]key", equalTo(knownKey2)))
.andExpect(jsonPath("[1]value", equalTo(knownValue2)));
final SoftwareModuleMetadata metaKey1 = softwareManagement
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey1));
final SoftwareModuleMetadata metaKey2 = softwareManagement
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey2));
final SoftwareModuleMetadata metaKey1 = softwareManagement.findSoftwareModuleMetadata(sm, knownKey1);
final SoftwareModuleMetadata metaKey2 = softwareManagement.findSoftwareModuleMetadata(sm, knownKey2);
assertThat(metaKey1.getValue()).as("Metadata key is wrong").isEqualTo(knownValue1);
assertThat(metaKey2.getValue()).as("Metadata key is wrong").isEqualTo(knownValue2);
@@ -949,9 +965,10 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
final String knownValue = "knownValue";
final String updateValue = "valueForUpdate";
final SoftwareModule sm = softwareManagement
.createSoftwareModule(new SoftwareModule(osType, "name 1", "version 1", null, null));
softwareManagement.createSoftwareModuleMetadata(new SoftwareModuleMetadata(knownKey, sm, knownValue));
final SoftwareModule sm = softwareManagement.createSoftwareModule(
softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null));
softwareManagement.createSoftwareModuleMetadata(
softwareManagement.generateSoftwareModuleMetadata(sm, knownKey, knownValue));
final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue);
@@ -961,8 +978,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue)));
final SoftwareModuleMetadata assertDS = softwareManagement
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey));
final SoftwareModuleMetadata assertDS = softwareManagement.findSoftwareModuleMetadata(sm, knownKey);
assertThat(assertDS.getValue()).as("Metadata is wrong").isEqualTo(updateValue);
}
@@ -973,15 +989,16 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
final String knownKey = "knownKey";
final String knownValue = "knownValue";
final SoftwareModule sm = softwareManagement
.createSoftwareModule(new SoftwareModule(osType, "name 1", "version 1", null, null));
softwareManagement.createSoftwareModuleMetadata(new SoftwareModuleMetadata(knownKey, sm, knownValue));
final SoftwareModule sm = softwareManagement.createSoftwareModule(
softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null));
softwareManagement.createSoftwareModuleMetadata(
softwareManagement.generateSoftwareModuleMetadata(sm, knownKey, knownValue));
mvc.perform(delete("/rest/v1/softwaremodules/{swId}/metadata/{key}", sm.getId(), knownKey))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
try {
softwareManagement.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey));
softwareManagement.findSoftwareModuleMetadata(sm, knownKey);
fail("expected EntityNotFoundException but didn't throw");
} catch (final EntityNotFoundException e) {
// ok as expected
@@ -994,12 +1011,13 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
final int totalMetadata = 10;
final String knownKeyPrefix = "knownKey";
final String knownValuePrefix = "knownValue";
final SoftwareModule sm = softwareManagement
.createSoftwareModule(new SoftwareModule(osType, "name 1", "version 1", null, null));
final SoftwareModule sm = softwareManagement.createSoftwareModule(
softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null));
for (int index = 0; index < totalMetadata; index++) {
softwareManagement.createSoftwareModuleMetadata(new SoftwareModuleMetadata(knownKeyPrefix + index,
softwareManagement.findSoftwareModuleById(sm.getId()), knownValuePrefix + index));
softwareManagement.createSoftwareModuleMetadata(softwareManagement.generateSoftwareModuleMetadata(
softwareManagement.findSoftwareModuleById(sm.getId()), knownKeyPrefix + index,
knownValuePrefix + index));
}
final String rsqlSearchValue1 = "value==knownValue1";
@@ -1014,7 +1032,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
char character = 'a';
for (int index = 0; index < amount; index++) {
final String str = String.valueOf(character);
final SoftwareModule softwareModule = new SoftwareModule(osType, str, str, str, str);
final SoftwareModule softwareModule = softwareManagement.generateSoftwareModule(osType, str, str, str, str);
softwareManagement.createSoftwareModule(softwareModule);
character++;

View File

@@ -54,8 +54,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes GET requests.")
public void getSoftwareModuleTypes() throws Exception {
SoftwareModuleType testType = softwareManagement
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
SoftwareModuleType testType = softwareManagement.createSoftwareModuleType(
softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
testType.setDescription("Desc1234");
testType = softwareManagement.updateSoftwareModuleType(testType);
@@ -97,7 +97,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes GET requests with sorting by MAXASSIGNMENTS field.")
public void getSoftwareModuleTypesSortedByMaxAssignments() throws Exception {
SoftwareModuleType testType = softwareManagement
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
testType.setDescription("Desc1234");
testType = softwareManagement.updateSoftwareModuleType(testType);
@@ -138,9 +138,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
public void createSoftwareModuleTypes() throws JSONException, Exception {
final List<SoftwareModuleType> types = new ArrayList<>();
types.add(new SoftwareModuleType("test1", "TestName1", "Desc1", 1));
types.add(new SoftwareModuleType("test2", "TestName2", "Desc2", 2));
types.add(new SoftwareModuleType("test3", "TestName3", "Desc3", 3));
types.add(softwareManagement.generateSoftwareModuleType("test1", "TestName1", "Desc1", 1));
types.add(softwareManagement.generateSoftwareModuleType("test2", "TestName2", "Desc2", 2));
types.add(softwareManagement.generateSoftwareModuleType("test3", "TestName3", "Desc3", 3));
final MvcResult mvcResult = mvc
.perform(post("/rest/v1/softwaremoduletypes/").content(JsonBuilder.softwareModuleTypes(types))
@@ -183,7 +183,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} GET requests.")
public void getSoftwareModuleType() throws Exception {
SoftwareModuleType testType = softwareManagement
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
testType.setDescription("Desc1234");
testType = softwareManagement.updateSoftwareModuleType(testType);
@@ -204,7 +204,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} DELETE requests (hard delete scenario).")
public void deleteSoftwareModuleTypeUnused() throws Exception {
final SoftwareModuleType testType = softwareManagement
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
assertThat(softwareManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
@@ -219,9 +219,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} DELETE requests (soft delete scenario).")
public void deleteSoftwareModuleTypeUsed() throws Exception {
final SoftwareModuleType testType = softwareManagement
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
softwareManagement
.createSoftwareModule(new SoftwareModule(testType, "name", "version", "description", "vendor"));
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
softwareManagement.createSoftwareModule(
softwareManagement.generateSoftwareModule(testType, "name", "version", "description", "vendor"));
assertThat(softwareManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
assertThat(softwareModuleTypeRepository.count()).isEqualTo(4);
@@ -237,7 +237,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} PUT requests.")
public void updateSoftwareModuleTypeOnlyDescriptionAndNameUntouched() throws Exception {
final SoftwareModuleType testType = softwareManagement
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
final String body = new JSONObject().put("id", testType.getId()).put("description", "foobardesc")
.put("name", "nameShouldNotBeChanged").toString();
@@ -293,7 +293,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
@Description("Ensures that the server is behaving as expected on invalid requests (wrong media type, wrong ID etc.).")
public void invalidRequestsOnSoftwaremoduleTypesResource() throws Exception {
final SoftwareModuleType testType = softwareManagement
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
final List<SoftwareModuleType> types = new ArrayList<>();
types.add(testType);
@@ -332,9 +332,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
@Description("Search erquest of software module types.")
public void searchSoftwareModuleTypeRsql() throws Exception {
final SoftwareModuleType testType = softwareManagement
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
final SoftwareModuleType testType2 = softwareManagement
.createSoftwareModuleType(new SoftwareModuleType("test1234", "TestName1234", "Desc123", 5));
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test1234", "TestName1234", "Desc123", 5));
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
@@ -349,7 +349,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
char character = 'a';
for (int index = 0; index < amount; index++) {
final String str = String.valueOf(character);
final SoftwareModule softwareModule = new SoftwareModule(osType, str, str, str, str);
final SoftwareModule softwareModule = softwareManagement.generateSoftwareModule(osType, str, str, str, str);
softwareManagement.createSoftwareModule(softwareModule);
character++;

View File

@@ -37,6 +37,9 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.ActionFields;
import org.eclipse.hawkbit.repository.ActionStatusFields;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetInfo;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.Action.Status;
@@ -44,7 +47,6 @@ import org.eclipse.hawkbit.repository.model.ActionStatus;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
import org.eclipse.hawkbit.rest.exception.MessageNotReadableException;
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
@@ -56,7 +58,6 @@ import org.json.JSONObject;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.http.HttpStatus;
@@ -110,9 +111,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
final String knownTargetId = "targetId";
final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
actions.get(0).setStatus(Status.FINISHED);
controllerManagament.addUpdateActionStatus(
new ActionStatus(actions.get(0), Status.FINISHED, System.currentTimeMillis(), "testmessage"),
actions.get(0));
controllerManagament.addUpdateActionStatus(controllerManagament.generateActionStatus(actions.get(0),
Status.FINISHED, System.currentTimeMillis(), "testmessage"));
final PageRequest pageRequest = new PageRequest(0, 1000, Direction.ASC, ActionFields.ID.getFieldName());
final ActionStatus status = deploymentManagement
@@ -141,7 +141,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
public void securityTokenIsNotInResponseIfMissingPermission() throws Exception {
final String knownControllerId = "knownControllerId";
targetManagement.createTarget(new Target(knownControllerId));
targetManagement.createTarget(targetManagement.generateTarget(knownControllerId));
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(jsonPath("securityToken").doesNotExist());
@@ -154,7 +154,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
public void securityTokenIsInResponseWithCorrectPermission() throws Exception {
final String knownControllerId = "knownControllerId";
final Target createTarget = targetManagement.createTarget(new Target(knownControllerId));
final Target createTarget = targetManagement.createTarget(targetManagement.generateTarget(knownControllerId));
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(jsonPath("securityToken", equalTo(createTarget.getSecurityToken())));
@@ -185,8 +185,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
}
private void createTarget(final String controllerId) {
final Target target = new Target(controllerId);
final TargetInfo targetInfo = new TargetInfo(target);
final JpaTarget target = (JpaTarget) targetManagement.generateTarget(controllerId);
final JpaTargetInfo targetInfo = new JpaTargetInfo(target);
targetInfo.setAddress(IpUtil.createHttpUri("127.0.0.1").toString());
target.setTargetInfo(targetInfo);
targetManagement.createTarget(target);
@@ -199,7 +199,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
// prepare test
final DistributionSet dsA = TestDataUtil.generateDistributionSet("", softwareManagement,
distributionSetManagement);
final Target createTarget = targetManagement.createTarget(new Target("knownTargetId"));
final Target createTarget = targetManagement.createTarget(targetManagement.generateTarget("knownTargetId"));
deploymentManagement.assignDistributionSet(dsA, Lists.newArrayList(createTarget));
@@ -306,7 +306,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
@Description("Ensures that deletion is executed if permitted.")
public void deleteTargetReturnsOK() throws Exception {
final String knownControllerId = "knownControllerIdDelete";
targetManagement.createTarget(new Target(knownControllerId));
targetManagement.createTarget(targetManagement.generateTarget(knownControllerId));
mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId))
.andExpect(status().isOk());
@@ -342,7 +342,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
final String body = new JSONObject().put("description", knownNewDescription).toString();
// prepare
final Target t = new Target(knownControllerId);
final Target t = targetManagement.generateTarget(knownControllerId);
t.setDescription("old description");
t.setName(knownNameNotModiy);
targetManagement.createTarget(t);
@@ -599,9 +599,10 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
distributionSetManagement);
// assign ds to target
deploymentManagement.assignDistributionSet(ds.getId(), knownControllerId);
final Long actionId = deploymentManagement.assignDistributionSet(ds.getId(), knownControllerId).getActions()
.get(0);
// give feedback, so installedDS is in SNYC
feedbackToByInSync(knownControllerId, ds);
feedbackToByInSync(actionId);
// test
final SoftwareModule os = ds.findFirstModuleByType(osType);
@@ -683,13 +684,13 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
@Test
public void createTargetsListReturnsSuccessful() throws Exception {
final Target test1 = new Target("id1");
final Target test1 = targetManagement.generateTarget("id1");
test1.setDescription("testid1");
test1.setName("testname1");
final Target test2 = new Target("id2");
final Target test2 = targetManagement.generateTarget("id2");
test2.setDescription("testid2");
test2.setName("testname2");
final Target test3 = new Target("id3");
final Target test3 = targetManagement.generateTarget("id3");
test3.setName("testname3");
test3.setDescription("testid3");
@@ -812,7 +813,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
@Test
public void getActionWithEmptyResult() throws Exception {
final String knownTargetId = "targetId";
final Target target = new Target(knownTargetId);
final Target target = targetManagement.generateTarget(knownTargetId);
targetManagement.createTarget(target);
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/"
@@ -1027,12 +1028,12 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
final PageRequest pageRequest = new PageRequest(0, 100, Direction.ASC, ActionStatusFields.ID.getFieldName());
Target target = new Target(knownTargetId);
Target target = targetManagement.generateTarget(knownTargetId);
target = targetManagement.createTarget(target);
final List<Target> targets = new ArrayList<>();
targets.add(target);
final Iterator<DistributionSet> sets = TestDataUtil
final Iterator<JpaDistributionSet> sets = TestDataUtil
.generateDistributionSets(2, softwareManagement, distributionSetManagement).iterator();
final DistributionSet one = sets.next();
final DistributionSet two = sets.next();
@@ -1045,8 +1046,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
Thread.sleep(10);
deploymentManagement.assignDistributionSet(two, updatedTargets);
// two updates, one cancelation
final List<Action> actions = actionRepository.findAll(pageRequest).getContent();
// two updates, one cancellation
final List<Action> actions = deploymentManagement.findActionsByTarget(target);
assertThat(actions).hasSize(2);
return actions;
@@ -1073,7 +1074,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
@Test
public void assignDistributionSetToTarget() throws Exception {
final Target target = targetManagement.createTarget(new Target("fsdfsd"));
final Target target = targetManagement.createTarget(targetManagement.generateTarget("fsdfsd"));
final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
distributionSetManagement);
@@ -1087,7 +1088,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
@Test
public void assignDistributionSetToTargetWithActionTimeForcedAndTime() throws Exception {
final Target target = targetManagement.createTarget(new Target("fsdfsd"));
final Target target = targetManagement.createTarget(targetManagement.generateTarget("fsdfsd"));
final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
distributionSetManagement);
@@ -1116,7 +1117,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
.content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
targetManagement.createTarget(new Target("fsdfsd"));
targetManagement.createTarget(targetManagement.generateTarget("fsdfsd"));
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS")
.content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON))
@@ -1206,7 +1207,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
final Map<String, String> knownControllerAttrs = new HashMap<>();
knownControllerAttrs.put("a", "1");
knownControllerAttrs.put("b", "2");
final Target target = new Target(knownTargetId);
final Target target = targetManagement.generateTarget(knownTargetId);
targetManagement.createTarget(target);
controllerManagament.updateControllerAttributes(knownTargetId, knownControllerAttrs);
@@ -1220,7 +1221,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
public void getControllerEmptyAttributesReturnsNoContent() throws Exception {
// create target with attributes
final String knownTargetId = "targetIdWithAttributes";
final Target target = new Target(knownTargetId);
final Target target = targetManagement.generateTarget(knownTargetId);
targetManagement.createTarget(target);
// test query target over rest resource
@@ -1254,7 +1255,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
}
private void createSingleTarget(final String controllerId, final String name) {
final Target target = new Target(controllerId);
final Target target = targetManagement.generateTarget(controllerId);
target.setName(name);
target.setDescription(TARGET_DESCRIPTION_TEST);
targetManagement.createTarget(target);
@@ -1271,7 +1272,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
char character = 'a';
for (int index = 0; index < amount; index++) {
final String str = String.valueOf(character);
final Target target = new Target(str);
final Target target = targetManagement.generateTarget(str);
target.setName(str);
target.setDescription(str);
final Target savedTarget = targetManagement.createTarget(target);
@@ -1283,20 +1284,12 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
/**
* helper method to give feedback mark an target IN_SNCY
*
* @param controllerId
* the controller id to give feedback to
* @param savedSet
* the distribution set
* @throws Exception
* @throws JSONException
*/
private void feedbackToByInSync(final String controllerId, final DistributionSet savedSet)
throws Exception, JSONException {
final Pageable pageReq = new PageRequest(0, 100);
final Action action = actionRepository.findByDistributionSet(pageReq, savedSet).getContent().get(0);
private void feedbackToByInSync(final Long actionId) {
final Action action = deploymentManagement.findAction(actionId);
final ActionStatus actionStatus = new ActionStatus(action, Status.FINISHED, 0l);
controllerManagement.addUpdateActionStatus(actionStatus, action);
final ActionStatus actionStatus = controllerManagement.generateActionStatus(action, Status.FINISHED, 0L);
controllerManagement.addUpdateActionStatus(actionStatus);
}
/**

View File

@@ -49,7 +49,7 @@ public class SMRessourceMisingMongoDbConnectionTest extends AbstractIntegrationT
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0);
assertThat(artifactRepository.findAll()).hasSize(0);
SoftwareModule sm = new SoftwareModule(softwareManagement.findSoftwareModuleTypeByKey("os"), "name 1",
SoftwareModule sm = softwareManagement.generateSoftwareModule(softwareManagement.findSoftwareModuleTypeByKey("os"), "name 1",
"version 1", null, null);
sm = softwareManagement.createSoftwareModule(sm);
assertThat(artifactRepository.findAll()).hasSize(0);