Complete repository refactoring - method renaming (#575)

* Split Tag management

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Repo method naming schame applied.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* findAll returns slice instead of page.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Complete javadoc.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Allow null values again.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Readability improvements.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Forgot a method.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fixed broken completed filter.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-09-22 08:22:41 +02:00
committed by GitHub
parent 68523cd8de
commit edae83a1b5
211 changed files with 3796 additions and 4160 deletions

View File

@@ -46,6 +46,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -97,15 +98,18 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
final Sort sorting = PagingUtility.sanitizeDistributionSetSortParam(sortParam);
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
final Page<DistributionSet> findDsPage;
final Slice<DistributionSet> findDsPage;
final long countModulesAll;
if (rsqlParam != null) {
findDsPage = distributionSetManagement.findDistributionSetsAll(rsqlParam, pageable, false);
findDsPage = distributionSetManagement.findByRsql(pageable, rsqlParam);
countModulesAll = ((Page<DistributionSet>) findDsPage).getTotalElements();
} else {
findDsPage = distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageable, false, null);
findDsPage = distributionSetManagement.findAll(pageable);
countModulesAll = distributionSetManagement.count();
}
final List<MgmtDistributionSet> rest = MgmtDistributionSetMapper.toResponseFromDsList(findDsPage.getContent());
return ResponseEntity.ok(new PagedList<>(rest, findDsPage.getTotalElements()));
return ResponseEntity.ok(new PagedList<>(rest, countModulesAll));
}
@Override
@@ -127,7 +131,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
sets.stream().filter(ds -> ds.getType() == null).forEach(ds -> ds.setType(defaultDsKey));
final Collection<DistributionSet> createdDSets = distributionSetManagement
.createDistributionSets(MgmtDistributionSetMapper.dsFromRequest(sets, entityFactory));
.create(MgmtDistributionSetMapper.dsFromRequest(sets, entityFactory));
LOG.debug("{} distribution sets created, return status {}", sets.size(), HttpStatus.CREATED);
return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDistributionSets(createdDSets),
@@ -136,7 +140,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
@Override
public ResponseEntity<Void> deleteDistributionSet(@PathVariable("distributionSetId") final Long distributionSetId) {
distributionSetManagement.deleteDistributionSet(distributionSetId);
distributionSetManagement.delete(distributionSetId);
return ResponseEntity.ok().build();
}
@@ -145,8 +149,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
@PathVariable("distributionSetId") final Long distributionSetId,
@RequestBody final MgmtDistributionSetRequestBodyPut toUpdate) {
return ResponseEntity.ok(MgmtDistributionSetMapper
.toResponse(distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
return ResponseEntity.ok(
MgmtDistributionSetMapper.toResponse(distributionSetManagement.update(entityFactory.distributionSet()
.update(distributionSetId).name(toUpdate.getName()).description(toUpdate.getDescription())
.version(toUpdate.getVersion()).requiredMigrationStep(toUpdate.isRequiredMigrationStep()))));
}
@@ -166,10 +170,10 @@ 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, rsqlParam,
pageable);
targetsAssignedDS = this.targetManagement.findByAssignedDistributionSetAndRsql(pageable, distributionSetId,
rsqlParam);
} else {
targetsAssignedDS = this.targetManagement.findTargetByAssignedDistributionSet(distributionSetId, pageable);
targetsAssignedDS = this.targetManagement.findByAssignedDistributionSet(pageable, distributionSetId);
}
return ResponseEntity.ok(new PagedList<>(MgmtTargetMapper.toResponse(targetsAssignedDS.getContent()),
@@ -194,11 +198,10 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
final Page<Target> targetsInstalledDS;
if (rsqlParam != null) {
targetsInstalledDS = this.targetManagement.findTargetByInstalledDistributionSet(distributionSetId,
rsqlParam, pageable);
targetsInstalledDS = this.targetManagement.findByInstalledDistributionSetAndRsql(pageable,
distributionSetId, rsqlParam);
} else {
targetsInstalledDS = this.targetManagement.findTargetByInstalledDistributionSet(distributionSetId,
pageable);
targetsInstalledDS = this.targetManagement.findByInstalledDistributionSet(pageable, distributionSetId);
}
return ResponseEntity.ok(new PagedList<>(MgmtTargetMapper.toResponse(targetsInstalledDS.getContent()),
@@ -218,7 +221,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
final Page<TargetFilterQuery> targetFilterQueries = targetFilterQueryManagement
.findTargetFilterQueryByAutoAssignDS(pageable, distributionSetId, rsqlParam);
.findByAutoAssignDSAndRsql(pageable, distributionSetId, rsqlParam);
return ResponseEntity
.ok(new PagedList<>(MgmtTargetFilterQueryMapper.toResponse(targetFilterQueries.getContent()),
@@ -262,11 +265,10 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
final Page<DistributionSetMetadata> metaDataPage;
if (rsqlParam != null) {
metaDataPage = distributionSetManagement.findDistributionSetMetadataByDistributionSetId(distributionSetId,
rsqlParam, pageable);
metaDataPage = distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(pageable, distributionSetId,
rsqlParam);
} else {
metaDataPage = distributionSetManagement.findDistributionSetMetadataByDistributionSetId(distributionSetId,
pageable);
metaDataPage = distributionSetManagement.findMetaDataByDistributionSetId(pageable, distributionSetId);
}
return ResponseEntity
@@ -282,7 +284,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
// check if distribution set exists otherwise throw exception
// immediately
final DistributionSetMetadata findOne = distributionSetManagement
.findDistributionSetMetadata(distributionSetId, metadataKey)
.getMetaDataByDistributionSetId(distributionSetId, metadataKey)
.orElseThrow(() -> new EntityNotFoundException(DistributionSetMetadata.class, distributionSetId,
metadataKey));
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDsMetadata(findOne));
@@ -293,8 +295,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
@PathVariable("metadataKey") final String metadataKey, @RequestBody final MgmtMetadata metadata) {
// check if distribution set exists otherwise throw exception
// immediately
final DistributionSetMetadata updated = distributionSetManagement.updateDistributionSetMetadata(
distributionSetId, entityFactory.generateMetadata(metadataKey, metadata.getValue()));
final DistributionSetMetadata updated = distributionSetManagement.updateMetaData(distributionSetId,
entityFactory.generateMetadata(metadataKey, metadata.getValue()));
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDsMetadata(updated));
}
@@ -303,7 +305,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
@PathVariable("metadataKey") final String metadataKey) {
// check if distribution set exists otherwise throw exception
// immediately
distributionSetManagement.deleteDistributionSetMetadata(distributionSetId, metadataKey);
distributionSetManagement.deleteMetaData(distributionSetId, metadataKey);
return ResponseEntity.ok().build();
}
@@ -313,8 +315,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
@RequestBody final List<MgmtMetadata> metadataRest) {
// check if distribution set exists otherwise throw exception
// immediately
final List<DistributionSetMetadata> created = distributionSetManagement.createDistributionSetMetadata(
distributionSetId, MgmtDistributionSetMapper.fromRequestDsMetadata(metadataRest, entityFactory));
final List<DistributionSetMetadata> created = distributionSetManagement.createMetaData(distributionSetId,
MgmtDistributionSetMapper.fromRequestDsMetadata(metadataRest, entityFactory));
return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDsMetadata(created), HttpStatus.CREATED);
}
@@ -347,14 +349,14 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
final Sort sorting = PagingUtility.sanitizeSoftwareModuleSortParam(sortParam);
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
final Page<SoftwareModule> softwaremodules = softwareModuleManagement.findSoftwareModuleByAssignedTo(pageable,
final Page<SoftwareModule> softwaremodules = softwareModuleManagement.findByAssignedTo(pageable,
distributionSetId);
return ResponseEntity.ok(new PagedList<>(MgmtSoftwareModuleMapper.toResponse(softwaremodules.getContent()),
softwaremodules.getTotalElements()));
}
private DistributionSet findDistributionSetWithExceptionIfNotFound(final Long distributionSetId) {
return distributionSetManagement.findDistributionSetById(distributionSetId)
return distributionSetManagement.get(distributionSetId)
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, distributionSetId));
}
}

View File

@@ -20,9 +20,9 @@ import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut;
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.DistributionSetTagManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
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;
@@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -50,7 +51,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
private static final Logger LOG = LoggerFactory.getLogger(MgmtDistributionSetTagResource.class);
@Autowired
private TagManagement tagManagement;
private DistributionSetTagManagement distributionSetTagManagement;
@Autowired
private DistributionSetManagement distributionSetManagement;
@@ -70,17 +71,21 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
final Sort sorting = PagingUtility.sanitizeTagSortParam(sortParam);
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
final Page<DistributionSetTag> findTargetsAll;
final Slice<DistributionSetTag> distributionSetTags;
final long count;
if (rsqlParam == null) {
findTargetsAll = tagManagement.findAllDistributionSetTags(pageable);
distributionSetTags = distributionSetTagManagement.findAll(pageable);
count = distributionSetTagManagement.count();
} else {
findTargetsAll = tagManagement.findAllDistributionSetTags(rsqlParam, pageable);
final Page<DistributionSetTag> page = distributionSetTagManagement.findByRsql(pageable, rsqlParam);
distributionSetTags = page;
count = page.getTotalElements();
}
final List<MgmtTag> rest = MgmtTagMapper.toResponseDistributionSetTag(findTargetsAll.getContent());
return ResponseEntity.ok(new PagedList<>(rest, findTargetsAll.getTotalElements()));
final List<MgmtTag> rest = MgmtTagMapper.toResponseDistributionSetTag(distributionSetTags.getContent());
return ResponseEntity.ok(new PagedList<>(rest, count));
}
@Override
@@ -95,8 +100,8 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
@RequestBody final List<MgmtTagRequestBodyPut> tags) {
LOG.debug("creating {} ds tags", tags.size());
final List<DistributionSetTag> createdTags = this.tagManagement
.createDistributionSetTags(MgmtTagMapper.mapTagFromRequest(entityFactory, tags));
final List<DistributionSetTag> createdTags = distributionSetTagManagement
.create(MgmtTagMapper.mapTagFromRequest(entityFactory, tags));
return new ResponseEntity<>(MgmtTagMapper.toResponseDistributionSetTag(createdTags), HttpStatus.CREATED);
}
@@ -106,8 +111,8 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
@PathVariable("distributionsetTagId") final Long distributionsetTagId,
@RequestBody final MgmtTagRequestBodyPut restDSTagRest) {
return ResponseEntity.ok(MgmtTagMapper.toResponse(tagManagement
.updateDistributionSetTag(entityFactory.tag().update(distributionsetTagId).name(restDSTagRest.getName())
return ResponseEntity.ok(MgmtTagMapper.toResponse(distributionSetTagManagement
.update(entityFactory.tag().update(distributionsetTagId).name(restDSTagRest.getName())
.description(restDSTagRest.getDescription()).colour(restDSTagRest.getColour()))));
}
@@ -117,7 +122,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
LOG.debug("Delete {} distribution set tag", distributionsetTagId);
final DistributionSetTag tag = findDistributionTagById(distributionsetTagId);
this.tagManagement.deleteDistributionSetTag(tag.getName());
distributionSetTagManagement.delete(tag.getName());
return ResponseEntity.ok().build();
}
@@ -126,7 +131,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
public ResponseEntity<List<MgmtDistributionSet>> getAssignedDistributionSets(
@PathVariable("distributionsetTagId") final Long distributionsetTagId) {
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDistributionSets(distributionSetManagement
.findDistributionSetsByTag(new PageRequest(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT),
.findByTag(new PageRequest(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT),
distributionsetTagId)
.getContent()));
}
@@ -145,11 +150,10 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
Page<DistributionSet> findDistrAll;
if (rsqlParam == null) {
findDistrAll = distributionSetManagement.findDistributionSetsByTag(pageable, distributionsetTagId);
findDistrAll = distributionSetManagement.findByTag(pageable, distributionsetTagId);
} else {
findDistrAll = distributionSetManagement.findDistributionSetsByTag(pageable, rsqlParam,
distributionsetTagId);
findDistrAll = distributionSetManagement.findByRsqlAndTag(pageable, rsqlParam, distributionsetTagId);
}
final List<MgmtDistributionSet> rest = MgmtDistributionSetMapper
@@ -202,7 +206,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
}
private DistributionSetTag findDistributionTagById(final Long distributionsetTagId) {
return tagManagement.findDistributionSetTagById(distributionsetTagId)
return distributionSetTagManagement.get(distributionsetTagId)
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, distributionsetTagId));
}

View File

@@ -70,13 +70,13 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
final Slice<DistributionSetType> findModuleTypessAll;
Long countModulesAll;
long countModulesAll;
if (rsqlParam != null) {
findModuleTypessAll = distributionSetTypeManagement.findDistributionSetTypesAll(rsqlParam, pageable);
findModuleTypessAll = distributionSetTypeManagement.findByRsql(pageable, rsqlParam);
countModulesAll = ((Page<DistributionSetType>) findModuleTypessAll).getTotalElements();
} else {
findModuleTypessAll = distributionSetTypeManagement.findDistributionSetTypesAll(pageable);
countModulesAll = distributionSetTypeManagement.countDistributionSetTypesAll();
findModuleTypessAll = distributionSetTypeManagement.findAll(pageable);
countModulesAll = distributionSetTypeManagement.count();
}
final List<MgmtDistributionSetType> rest = MgmtDistributionSetTypeMapper
@@ -95,7 +95,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
@Override
public ResponseEntity<Void> deleteDistributionSetType(
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId) {
distributionSetTypeManagement.deleteDistributionSetType(distributionSetTypeId);
distributionSetTypeManagement.delete(distributionSetTypeId);
return ResponseEntity.ok().build();
}
@@ -106,7 +106,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
@RequestBody final MgmtDistributionSetTypeRequestBodyPut restDistributionSetType) {
return ResponseEntity.ok(MgmtDistributionSetTypeMapper
.toResponse(distributionSetTypeManagement.updateDistributionSetType(entityFactory.distributionSetType()
.toResponse(distributionSetTypeManagement.update(entityFactory.distributionSetType()
.update(distributionSetTypeId).description(restDistributionSetType.getDescription())
.colour(restDistributionSetType.getColour()))));
}
@@ -116,15 +116,14 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
@RequestBody final List<MgmtDistributionSetTypeRequestBodyPost> distributionSetTypes) {
final List<DistributionSetType> createdSoftwareModules = distributionSetTypeManagement
.createDistributionSetTypes(
MgmtDistributionSetTypeMapper.smFromRequest(entityFactory, distributionSetTypes));
.create(MgmtDistributionSetTypeMapper.smFromRequest(entityFactory, distributionSetTypes));
return ResponseEntity.status(HttpStatus.CREATED)
.body(MgmtDistributionSetTypeMapper.toTypesResponse(createdSoftwareModules));
}
private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final Long distributionSetTypeId) {
return distributionSetTypeManagement.findDistributionSetTypeById(distributionSetTypeId)
return distributionSetTypeManagement.get(distributionSetTypeId)
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distributionSetTypeId));
}
@@ -213,7 +212,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
private SoftwareModuleType findSoftwareModuleTypeWithExceptionIfNotFound(final Long softwareModuleTypeId) {
return softwareModuleTypeManagement.findSoftwareModuleTypeById(softwareModuleTypeId)
return softwareModuleTypeManagement.get(softwareModuleTypeId)
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, softwareModuleTypeId));
}
}

View File

@@ -63,7 +63,7 @@ public class MgmtDownloadArtifactResource implements MgmtDownloadArtifactRestApi
public ResponseEntity<InputStream> downloadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("artifactId") final Long artifactId) {
final SoftwareModule module = softwareModuleManagement.findSoftwareModuleById(softwareModuleId)
final SoftwareModule module = softwareModuleManagement.get(softwareModuleId)
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
final Artifact artifact = module.getArtifact(artifactId)
.orElseThrow(() -> new EntityNotFoundException(Artifact.class, artifactId));

View File

@@ -81,7 +81,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
final Page<Rollout> findModulesAll;
if (rsqlParam != null) {
findModulesAll = this.rolloutManagement.findAllByPredicate(rsqlParam, pageable, false);
findModulesAll = this.rolloutManagement.findByRsql(pageable, rsqlParam, false);
} else {
findModulesAll = this.rolloutManagement.findAll(pageable, false);
}
@@ -92,7 +92,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
@Override
public ResponseEntity<MgmtRolloutResponseBody> getRollout(@PathVariable("rolloutId") final Long rolloutId) {
final Rollout findRolloutById = rolloutManagement.findRolloutWithDetailedStatus(rolloutId)
final Rollout findRolloutById = rolloutManagement.getWithDetailedStatus(rolloutId)
.orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId));
return ResponseEntity.ok(MgmtRolloutMapper.toResponseRollout(findRolloutById, true));
@@ -116,10 +116,10 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
final List<RolloutGroupCreate> rolloutGroups = rolloutRequestBody.getGroups().stream()
.map(mgmtRolloutGroup -> MgmtRolloutMapper.fromRequest(entityFactory, mgmtRolloutGroup))
.collect(Collectors.toList());
rollout = rolloutManagement.createRollout(create, rolloutGroups, rolloutGroupConditions);
rollout = rolloutManagement.create(create, rolloutGroups, rolloutGroupConditions);
} else if (rolloutRequestBody.getAmountGroups() != null) {
rollout = rolloutManagement.createRollout(create, rolloutRequestBody.getAmountGroups(),
rollout = rolloutManagement.create(create, rolloutRequestBody.getAmountGroups(),
rolloutGroupConditions);
} else {
@@ -131,7 +131,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
@Override
public ResponseEntity<Void> start(@PathVariable("rolloutId") final Long rolloutId) {
this.rolloutManagement.startRollout(rolloutId);
this.rolloutManagement.start(rolloutId);
return ResponseEntity.ok().build();
}
@@ -143,7 +143,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
@Override
public ResponseEntity<Void> delete(@PathVariable("rolloutId") final Long rolloutId) {
this.rolloutManagement.deleteRollout(rolloutId);
this.rolloutManagement.delete(rolloutId);
return ResponseEntity.ok().build();
}
@@ -168,9 +168,9 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
final Page<RolloutGroup> findRolloutGroupsAll;
if (rsqlParam != null) {
findRolloutGroupsAll = this.rolloutGroupManagement.findRolloutGroupsAll(rolloutId, rsqlParam, pageable);
findRolloutGroupsAll = this.rolloutGroupManagement.findByRolloutAndRsql(pageable, rolloutId, rsqlParam);
} else {
findRolloutGroupsAll = this.rolloutGroupManagement.findRolloutGroupsByRolloutId(rolloutId, pageable);
findRolloutGroupsAll = this.rolloutGroupManagement.findByRollout(pageable, rolloutId);
}
final List<MgmtRolloutGroupResponseBody> rest = MgmtRolloutMapper
@@ -183,7 +183,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
@PathVariable("groupId") final Long groupId) {
findRolloutOrThrowException(rolloutId);
final RolloutGroup rolloutGroup = rolloutGroupManagement.findRolloutGroupWithDetailedStatus(groupId)
final RolloutGroup rolloutGroup = rolloutGroupManagement.getWithDetailedStatus(groupId)
.orElseThrow(() -> new EntityNotFoundException(RolloutGroup.class, rolloutId));
return ResponseEntity.ok(MgmtRolloutMapper.toResponseRolloutGroup(rolloutGroup, true));
}
@@ -210,9 +210,9 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
final Page<Target> rolloutGroupTargets;
if (rsqlParam != null) {
rolloutGroupTargets = this.rolloutGroupManagement.findRolloutGroupTargets(groupId, rsqlParam, pageable);
rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(pageable, groupId, rsqlParam);
} else {
final Page<Target> pageTargets = this.rolloutGroupManagement.findRolloutGroupTargets(groupId, pageable);
final Page<Target> pageTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroup(pageable, groupId);
rolloutGroupTargets = pageTargets;
}
final List<MgmtTarget> rest = MgmtTargetMapper.toResponse(rolloutGroupTargets.getContent());
@@ -220,7 +220,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
}
private DistributionSet findDistributionSetOrThrowException(final MgmtRolloutRestRequestBody rolloutRequestBody) {
return this.distributionSetManagement.findDistributionSetById(rolloutRequestBody.getDistributionSetId())
return this.distributionSetManagement.get(rolloutRequestBody.getDistributionSetId())
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class,
rolloutRequestBody.getDistributionSetId()));

View File

@@ -79,7 +79,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
}
try {
final Artifact result = artifactManagement.createArtifact(file.getInputStream(), softwareModuleId, fileName,
final Artifact result = artifactManagement.create(file.getInputStream(), softwareModuleId, fileName,
md5Sum == null ? null : md5Sum.toLowerCase(), sha1Sum == null ? null : sha1Sum.toLowerCase(), false,
file.getContentType());
return ResponseEntity.status(HttpStatus.CREATED).body(MgmtSoftwareModuleMapper.toResponse(result));
@@ -117,7 +117,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
@PathVariable("artifactId") final Long artifactId) {
findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId);
artifactManagement.deleteArtifact(artifactId);
artifactManagement.delete(artifactId);
return ResponseEntity.ok().build();
}
@@ -136,13 +136,13 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
final Slice<SoftwareModule> findModulesAll;
Long countModulesAll;
long countModulesAll;
if (rsqlParam != null) {
findModulesAll = softwareModuleManagement.findSoftwareModulesByPredicate(rsqlParam, pageable);
findModulesAll = softwareModuleManagement.findByRsql(pageable, rsqlParam);
countModulesAll = ((Page<SoftwareModule>) findModulesAll).getTotalElements();
} else {
findModulesAll = softwareModuleManagement.findSoftwareModulesAll(pageable);
countModulesAll = softwareModuleManagement.countSoftwareModulesAll();
findModulesAll = softwareModuleManagement.findAll(pageable);
countModulesAll = softwareModuleManagement.count();
}
final List<MgmtSoftwareModule> rest = MgmtSoftwareModuleMapper.toResponse(findModulesAll.getContent());
@@ -163,7 +163,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
LOG.debug("creating {} softwareModules", softwareModules.size());
final Collection<SoftwareModule> createdSoftwareModules = softwareModuleManagement
.createSoftwareModule(MgmtSoftwareModuleMapper.smFromRequest(entityFactory, softwareModules));
.create(MgmtSoftwareModuleMapper.smFromRequest(entityFactory, softwareModules));
LOG.debug("{} softwareModules created, return status {}", softwareModules.size(), HttpStatus.CREATED);
return ResponseEntity.status(HttpStatus.CREATED)
@@ -175,8 +175,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
@PathVariable("softwareModuleId") final Long softwareModuleId,
@RequestBody final MgmtSoftwareModuleRequestBodyPut restSoftwareModule) {
return ResponseEntity.ok(MgmtSoftwareModuleMapper.toResponse(
softwareModuleManagement.updateSoftwareModule(entityFactory.softwareModule().update(softwareModuleId)
return ResponseEntity.ok(MgmtSoftwareModuleMapper
.toResponse(softwareModuleManagement.update(entityFactory.softwareModule().update(softwareModuleId)
.description(restSoftwareModule.getDescription()).vendor(restSoftwareModule.getVendor()))));
}
@@ -184,7 +184,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
public ResponseEntity<Void> deleteSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId) {
final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
softwareModuleManagement.deleteSoftwareModule(module.getId());
softwareModuleManagement.delete(module.getId());
return ResponseEntity.ok().build();
}
@@ -208,11 +208,9 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
final Page<SoftwareModuleMetadata> metaDataPage;
if (rsqlParam != null) {
metaDataPage = softwareModuleManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId,
rsqlParam, pageable);
metaDataPage = softwareModuleManagement.findMetaDataByRsql(pageable, softwareModuleId, rsqlParam);
} else {
metaDataPage = softwareModuleManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId,
pageable);
metaDataPage = softwareModuleManagement.findMetaDataBySoftwareModuleId(pageable, softwareModuleId);
}
return ResponseEntity
@@ -224,8 +222,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
public ResponseEntity<MgmtMetadata> getMetadataValue(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("metadataKey") final String metadataKey) {
final SoftwareModuleMetadata findOne = softwareModuleManagement
.findSoftwareModuleMetadata(softwareModuleId, metadataKey).orElseThrow(
final SoftwareModuleMetadata findOne = softwareModuleManagement.getMetaDataBySoftwareModuleId(softwareModuleId, metadataKey)
.orElseThrow(
() -> new EntityNotFoundException(SoftwareModuleMetadata.class, softwareModuleId, metadataKey));
return ResponseEntity.ok(MgmtSoftwareModuleMapper.toResponseSwMetadata(findOne));
@@ -234,7 +232,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
@Override
public ResponseEntity<MgmtMetadata> updateMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("metadataKey") final String metadataKey, @RequestBody final MgmtMetadata metadata) {
final SoftwareModuleMetadata updated = softwareModuleManagement.updateSoftwareModuleMetadata(softwareModuleId,
final SoftwareModuleMetadata updated = softwareModuleManagement.updateMetaData(softwareModuleId,
entityFactory.generateMetadata(metadataKey, metadata.getValue()));
return ResponseEntity.ok(MgmtSoftwareModuleMapper.toResponseSwMetadata(updated));
@@ -243,7 +241,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
@Override
public ResponseEntity<Void> deleteMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("metadataKey") final String metadataKey) {
softwareModuleManagement.deleteSoftwareModuleMetadata(softwareModuleId, metadataKey);
softwareModuleManagement.deleteMetaData(softwareModuleId, metadataKey);
return ResponseEntity.ok().build();
}
@@ -253,8 +251,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
@PathVariable("softwareModuleId") final Long softwareModuleId,
@RequestBody final List<MgmtMetadata> metadataRest) {
final List<SoftwareModuleMetadata> created = softwareModuleManagement.createSoftwareModuleMetadata(
softwareModuleId, MgmtSoftwareModuleMapper.fromRequestSwMetadata(entityFactory, metadataRest));
final List<SoftwareModuleMetadata> created = softwareModuleManagement.createMetaData(softwareModuleId,
MgmtSoftwareModuleMapper.fromRequestSwMetadata(entityFactory, metadataRest));
return ResponseEntity.status(HttpStatus.CREATED).body(MgmtSoftwareModuleMapper.toResponseSwMetadata(created));
}
@@ -262,7 +260,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
private SoftwareModule findSoftwareModuleWithExceptionIfNotFound(final Long softwareModuleId,
final Long artifactId) {
final SoftwareModule module = softwareModuleManagement.findSoftwareModuleById(softwareModuleId)
final SoftwareModule module = softwareModuleManagement.get(softwareModuleId)
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
if (artifactId != null && !module.getArtifact(artifactId).isPresent()) {

View File

@@ -64,11 +64,11 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
final Slice<SoftwareModuleType> findModuleTypessAll;
Long countModulesAll;
if (rsqlParam != null) {
findModuleTypessAll = softwareModuleTypeManagement.findSoftwareModuleTypesAll(rsqlParam, pageable);
findModuleTypessAll = softwareModuleTypeManagement.findByRsql(pageable, rsqlParam);
countModulesAll = ((Page<SoftwareModuleType>) findModuleTypessAll).getTotalElements();
} else {
findModuleTypessAll = softwareModuleTypeManagement.findSoftwareModuleTypesAll(pageable);
countModulesAll = softwareModuleTypeManagement.countSoftwareModuleTypesAll();
findModuleTypessAll = softwareModuleTypeManagement.findAll(pageable);
countModulesAll = softwareModuleTypeManagement.count();
}
final List<MgmtSoftwareModuleType> rest = MgmtSoftwareModuleTypeMapper
@@ -87,7 +87,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
@Override
public ResponseEntity<Void> deleteSoftwareModuleType(
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) {
softwareModuleTypeManagement.deleteSoftwareModuleType(softwareModuleTypeId);
softwareModuleTypeManagement.delete(softwareModuleTypeId);
return ResponseEntity.ok().build();
}
@@ -97,7 +97,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
@RequestBody final MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType) {
final SoftwareModuleType updatedSoftwareModuleType = softwareModuleTypeManagement
.updateSoftwareModuleType(entityFactory.softwareModuleType().update(softwareModuleTypeId)
.update(entityFactory.softwareModuleType().update(softwareModuleTypeId)
.description(restSoftwareModuleType.getDescription())
.colour(restSoftwareModuleType.getColour()));
@@ -108,7 +108,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
public ResponseEntity<List<MgmtSoftwareModuleType>> createSoftwareModuleTypes(
@RequestBody final List<MgmtSoftwareModuleTypeRequestBodyPost> softwareModuleTypes) {
final List<SoftwareModuleType> createdSoftwareModules = softwareModuleTypeManagement.createSoftwareModuleType(
final List<SoftwareModuleType> createdSoftwareModules = softwareModuleTypeManagement.create(
MgmtSoftwareModuleTypeMapper.smFromRequest(entityFactory, softwareModuleTypes));
return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toTypesResponse(createdSoftwareModules),
@@ -116,7 +116,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
}
private SoftwareModuleType findSoftwareModuleTypeWithExceptionIfNotFound(final Long softwareModuleTypeId) {
return softwareModuleTypeManagement.findSoftwareModuleTypeById(softwareModuleTypeId)
return softwareModuleTypeManagement.get(softwareModuleTypeId)
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, softwareModuleTypeId));
}

View File

@@ -74,13 +74,13 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA
final Slice<TargetFilterQuery> findTargetFiltersAll;
final Long countTargetsAll;
if (rsqlParam != null) {
final Page<TargetFilterQuery> findFilterPage = filterManagement.findTargetFilterQueryByFilter(pageable,
final Page<TargetFilterQuery> findFilterPage = filterManagement.findByRsql(pageable,
rsqlParam);
countTargetsAll = findFilterPage.getTotalElements();
findTargetFiltersAll = findFilterPage;
} else {
findTargetFiltersAll = filterManagement.findAllTargetFilterQuery(pageable);
countTargetsAll = filterManagement.countAllTargetFilterQuery();
findTargetFiltersAll = filterManagement.findAll(pageable);
countTargetsAll = filterManagement.count();
}
final List<MgmtTargetFilterQuery> rest = MgmtTargetFilterQueryMapper
@@ -92,7 +92,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA
public ResponseEntity<MgmtTargetFilterQuery> createFilter(
@RequestBody final MgmtTargetFilterQueryRequestBody filter) {
final TargetFilterQuery createdTarget = filterManagement
.createTargetFilterQuery(MgmtTargetFilterQueryMapper.fromRequest(entityFactory, filter));
.create(MgmtTargetFilterQueryMapper.fromRequest(entityFactory, filter));
return new ResponseEntity<>(MgmtTargetFilterQueryMapper.toResponse(createdTarget), HttpStatus.CREATED);
}
@@ -103,7 +103,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA
LOG.debug("updating target filter query {}", filterId);
final TargetFilterQuery updateFilter = filterManagement
.updateTargetFilterQuery(entityFactory.targetFilterQuery().update(filterId)
.update(entityFactory.targetFilterQuery().update(filterId)
.name(targetFilterRest.getName()).query(targetFilterRest.getQuery()));
return ResponseEntity.ok(MgmtTargetFilterQueryMapper.toResponse(updateFilter));
@@ -111,7 +111,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA
@Override
public ResponseEntity<Void> deleteFilter(@PathVariable("filterId") final Long filterId) {
filterManagement.deleteTargetFilterQuery(filterId);
filterManagement.delete(filterId);
LOG.debug("{} target filter query deleted, return status {}", filterId, HttpStatus.OK);
return ResponseEntity.ok().build();
}
@@ -120,7 +120,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA
public ResponseEntity<MgmtTargetFilterQuery> postAssignedDistributionSet(
@PathVariable("filterId") final Long filterId, @RequestBody final MgmtId dsId) {
final TargetFilterQuery updateFilter = filterManagement.updateTargetFilterQueryAutoAssignDS(filterId,
final TargetFilterQuery updateFilter = filterManagement.updateAutoAssignDS(filterId,
dsId.getId());
return ResponseEntity.ok(MgmtTargetFilterQueryMapper.toResponse(updateFilter));
@@ -138,13 +138,13 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA
@Override
public ResponseEntity<Void> deleteAssignedDistributionSet(@PathVariable("filterId") final Long filterId) {
filterManagement.updateTargetFilterQueryAutoAssignDS(filterId, null);
filterManagement.updateAutoAssignDS(filterId, null);
return ResponseEntity.noContent().build();
}
private TargetFilterQuery findFilterWithExceptionIfNotFound(final Long filterId) {
return filterManagement.findTargetFilterQueryById(filterId)
return filterManagement.get(filterId)
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, filterId));
}

View File

@@ -91,14 +91,14 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
final Slice<Target> findTargetsAll;
final Long countTargetsAll;
final long countTargetsAll;
if (rsqlParam != null) {
final Page<Target> findTargetPage = this.targetManagement.findTargetsAll(rsqlParam, pageable);
final Page<Target> findTargetPage = this.targetManagement.findByRsql(pageable, rsqlParam);
countTargetsAll = findTargetPage.getTotalElements();
findTargetsAll = findTargetPage;
} else {
findTargetsAll = this.targetManagement.findTargetsAll(pageable);
countTargetsAll = this.targetManagement.countTargetsAll();
findTargetsAll = this.targetManagement.findAll(pageable);
countTargetsAll = this.targetManagement.count();
}
final List<MgmtTarget> rest = MgmtTargetMapper.toResponse(findTargetsAll.getContent());
@@ -109,7 +109,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
public ResponseEntity<List<MgmtTarget>> createTargets(@RequestBody final List<MgmtTargetRequestBody> targets) {
LOG.debug("creating {} targets", targets.size());
final Collection<Target> createdTargets = this.targetManagement
.createTargets(MgmtTargetMapper.fromRequest(entityFactory, targets));
.create(MgmtTargetMapper.fromRequest(entityFactory, targets));
LOG.debug("{} targets created, return status {}", targets.size(), HttpStatus.CREATED);
return new ResponseEntity<>(MgmtTargetMapper.toResponse(createdTargets), HttpStatus.CREATED);
}
@@ -118,7 +118,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
public ResponseEntity<MgmtTarget> updateTarget(@PathVariable("controllerId") final String controllerId,
@RequestBody final MgmtTargetRequestBody targetRest) {
final Target updateTarget = this.targetManagement.updateTarget(entityFactory.target().update(controllerId)
final Target updateTarget = this.targetManagement.update(entityFactory.target().update(controllerId)
.name(targetRest.getName()).description(targetRest.getDescription()).address(targetRest.getAddress())
.securityToken(targetRest.getSecurityToken()));
@@ -127,7 +127,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
@Override
public ResponseEntity<Void> deleteTarget(@PathVariable("controllerId") final String controllerId) {
this.targetManagement.deleteTarget(controllerId);
this.targetManagement.deleteByControllerID(controllerId);
LOG.debug("{} target deleted, return status {}", controllerId, HttpStatus.OK);
return ResponseEntity.ok().build();
}
@@ -284,7 +284,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
}
private Target findTargetWithExceptionIfNotFound(final String controllerId) {
return targetManagement.findTargetByControllerID(controllerId)
return targetManagement.getByControllerID(controllerId)
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
}

View File

@@ -21,7 +21,7 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTagRestApi;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetTagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.Target;
@@ -50,7 +50,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
private static final Logger LOG = LoggerFactory.getLogger(MgmtTargetTagResource.class);
@Autowired
private TagManagement tagManagement;
private TargetTagManagement tagManagement;
@Autowired
private TargetManagement targetManagement;
@@ -72,10 +72,10 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
Page<TargetTag> findTargetsAll;
if (rsqlParam == null) {
findTargetsAll = this.tagManagement.findAllTargetTags(pageable);
findTargetsAll = this.tagManagement.findAll(pageable);
} else {
findTargetsAll = this.tagManagement.findAllTargetTags(rsqlParam, pageable);
findTargetsAll = this.tagManagement.findByRsql(pageable, rsqlParam);
}
final List<MgmtTag> rest = MgmtTagMapper.toResponse(findTargetsAll.getContent());
@@ -92,7 +92,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.mapTagFromRequest(entityFactory, tags));
.create(MgmtTagMapper.mapTagFromRequest(entityFactory, tags));
return new ResponseEntity<>(MgmtTagMapper.toResponse(createdTargetTags), HttpStatus.CREATED);
}
@@ -102,7 +102,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
LOG.debug("update {} target tag", restTargetTagRest);
final TargetTag updateTargetTag = tagManagement
.updateTargetTag(entityFactory.tag().update(targetTagId).name(restTargetTagRest.getName())
.update(entityFactory.tag().update(targetTagId).name(restTargetTagRest.getName())
.description(restTargetTagRest.getDescription()).colour(restTargetTagRest.getColour()));
LOG.debug("target tag updated");
@@ -115,7 +115,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
LOG.debug("Delete {} target tag", targetTagId);
final TargetTag targetTag = findTargetTagById(targetTagId);
this.tagManagement.deleteTargetTag(targetTag.getName());
this.tagManagement.delete(targetTag.getName());
return ResponseEntity.ok().build();
}
@@ -124,7 +124,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
public ResponseEntity<List<MgmtTarget>> getAssignedTargets(@PathVariable("targetTagId") final Long targetTagId) {
return ResponseEntity.ok(MgmtTargetMapper.toResponse(targetManagement
.findTargetsByTag(new PageRequest(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT), targetTagId)
.findByTag(new PageRequest(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT), targetTagId)
.getContent()));
}
@@ -142,10 +142,10 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
Page<Target> findTargetsAll;
if (rsqlParam == null) {
findTargetsAll = targetManagement.findTargetsByTag(pageable, targetTagId);
findTargetsAll = targetManagement.findByTag(pageable, targetTagId);
} else {
findTargetsAll = targetManagement.findTargetsByTag(pageable, rsqlParam, targetTagId);
findTargetsAll = targetManagement.findByRsqlAndTag(pageable, rsqlParam, targetTagId);
}
final Long countTargetsAll = findTargetsAll.getTotalElements();
@@ -188,7 +188,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
}
private TargetTag findTargetTagById(final Long targetTagId) {
return tagManagement.findTargetTagById(targetTagId)
return tagManagement.get(targetTagId)
.orElseThrow(() -> new EntityNotFoundException(TargetTag.class, targetTagId));
}

View File

@@ -220,7 +220,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
.andExpect(jsonPath("$.alreadyAssigned", equalTo(1)))
.andExpect(jsonPath("$.total", equalTo(targets.size())));
assertThat(targetManagement.findTargetByAssignedDistributionSet(createdDs.getId(), PAGE).getContent())
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, createdDs.getId()).getContent())
.as("Five targets in repository have DS assigned").hasSize(5);
}
@@ -241,11 +241,10 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
.andExpect(jsonPath("$.alreadyAssigned", equalTo(1)))
.andExpect(jsonPath("$.total", equalTo(targets.size())));
assertThat(targetManagement.findTargetByAssignedDistributionSet(createdDs.getId(), PAGE).getContent())
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, createdDs.getId()).getContent())
.as("Five targets in repository have DS assigned").hasSize(5);
assertThat(targetManagement.findTargetByInstalledDistributionSet(createdDs.getId(), PAGE).getContent())
.hasSize(4);
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, createdDs.getId()).getContent()).hasSize(4);
}
@Test
@@ -306,16 +305,14 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
final Set<DistributionSet> createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1);
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(
targetFilterQueryManagement.createTargetFilterQuery(
entityFactory.targetFilterQuery().create().name(knownFilterName).query("x==y")).getId(),
targetFilterQueryManagement.updateAutoAssignDS(
targetFilterQueryManagement
.create(entityFactory.targetFilterQuery().create().name(knownFilterName).query("x==y")).getId(),
createdDs.getId());
// create some dummy target filter queries
targetFilterQueryManagement
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name("b").query("x==y"));
targetFilterQueryManagement
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name("c").query("x==y"));
targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("b").query("x==y"));
targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("c").query("x==y"));
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId()
+ "/autoAssignTargetFilters")).andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(1)))
@@ -369,21 +366,17 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
private void prepareTestFilters(final String filterNamePrefix, final DistributionSet createdDs) {
// create target filter queries that should be found
targetFilterQueryManagement
.updateTargetFilterQueryAutoAssignDS(targetFilterQueryManagement
.createTargetFilterQuery(
entityFactory.targetFilterQuery().create().name(filterNamePrefix + "1").query("x==y"))
.getId(), createdDs.getId());
targetFilterQueryManagement
.updateTargetFilterQueryAutoAssignDS(targetFilterQueryManagement
.createTargetFilterQuery(
entityFactory.targetFilterQuery().create().name(filterNamePrefix + "2").query("x==y"))
.getId(), createdDs.getId());
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQueryManagement
.create(entityFactory.targetFilterQuery().create().name(filterNamePrefix + "1").query("x==y")).getId(),
createdDs.getId());
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQueryManagement
.create(entityFactory.targetFilterQuery().create().name(filterNamePrefix + "2").query("x==y")).getId(),
createdDs.getId());
// create some dummy target filter queries
targetFilterQueryManagement.createTargetFilterQuery(
entityFactory.targetFilterQuery().create().name(filterNamePrefix + "b").query("x==y"));
targetFilterQueryManagement.createTargetFilterQuery(
entityFactory.targetFilterQuery().create().name(filterNamePrefix + "c").query("x==y"));
targetFilterQueryManagement
.create(entityFactory.targetFilterQuery().create().name(filterNamePrefix + "b").query("x==y"));
targetFilterQueryManagement
.create(entityFactory.targetFilterQuery().create().name(filterNamePrefix + "c").query("x==y"));
}
@Test
@@ -433,16 +426,16 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
@Description("Ensures that multiple DS requested are listed with expected payload.")
public void getDistributionSets() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0);
DistributionSet set = testdataFactory.createDistributionSet("one");
set = distributionSetManagement.updateDistributionSet(entityFactory.distributionSet().update(set.getId())
set = distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
.version("anotherVersion").requiredMigrationStep(true));
// load also lazy stuff
set = distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).get();
set = distributionSetManagement.getWithDetails(set.getId()).get();
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(1);
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1);
// perform request
mvc.perform(get("/rest/v1/distributionsets").accept(MediaType.APPLICATION_JSON))
@@ -505,7 +498,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Ensures that multipe DS posted to API are created in the repository.")
public void createDistributionSets() throws Exception {
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0);
final SoftwareModule ah = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_APP);
final SoftwareModule jvm = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_RT);
@@ -522,14 +515,15 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
final MvcResult mvcResult = executeMgmtTargetPost(one, two, three);
one = distributionSetManagement.findDistributionSetByIdWithDetails(
distributionSetManagement.findDistributionSetsAll("name==one", PAGE, false).getContent().get(0).getId())
one = distributionSetManagement
.getWithDetails(distributionSetManagement.findByRsql(PAGE, "name==one").getContent().get(0).getId())
.get();
two = distributionSetManagement.findDistributionSetByIdWithDetails(
distributionSetManagement.findDistributionSetsAll("name==two", PAGE, false).getContent().get(0).getId())
two = distributionSetManagement
.getWithDetails(distributionSetManagement.findByRsql(PAGE, "name==two").getContent().get(0).getId())
.get();
three = distributionSetManagement
.getWithDetails(distributionSetManagement.findByRsql(PAGE, "name==three").getContent().get(0).getId())
.get();
three = distributionSetManagement.findDistributionSetByIdWithDetails(distributionSetManagement
.findDistributionSetsAll("name==three", PAGE, false).getContent().get(0).getId()).get();
assertThat(
JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
@@ -560,7 +554,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
.isEqualTo(String.valueOf(three.getId()));
// check in database
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(3);
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(3);
assertThat(one.isRequiredMigrationStep()).isEqualTo(false);
assertThat(two.isRequiredMigrationStep()).isEqualTo(false);
assertThat(three.isRequiredMigrationStep()).isEqualTo(true);
@@ -624,19 +618,19 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
@Description("Ensures that DS deletion request to API is reflected by the repository.")
public void deleteUnassignedistributionSet() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0);
final DistributionSet set = testdataFactory.createDistributionSet("one");
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(1);
assertThat(distributionSetManagement.findByCompleted(PAGE, 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.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).isEmpty();
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(0);
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty();
assertThat(distributionSetManagement.count()).isEqualTo(0);
}
@Test
@@ -650,21 +644,20 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
@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.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0);
final DistributionSet set = testdataFactory.createDistributionSet("one");
testdataFactory.createTarget("test");
assignDistributionSet(set.getId(), "test");
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(1);
assertThat(distributionSetManagement.findByCompleted(PAGE, 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.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, true, true)).hasSize(1);
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0);
}
@Test
@@ -672,18 +665,18 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
public void updateDistributionSet() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0);
final DistributionSet set = testdataFactory.createDistributionSet("one");
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(1);
assertThat(distributionSetManagement.count()).isEqualTo(1);
mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId())
.content("{\"version\":\"anotherVersion\",\"requiredMigrationStep\":\"true\"}")
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
final DistributionSet setupdated = distributionSetManagement.findDistributionSetById(set.getId()).get();
final DistributionSet setupdated = distributionSetManagement.get(set.getId()).get();
assertThat(setupdated.isRequiredMigrationStep()).isEqualTo(true);
assertThat(setupdated.getVersion()).isEqualTo("anotherVersion");
@@ -695,20 +688,20 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
public void updateRequiredMigrationStepFailsIfDistributionSetisInUse() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0);
final DistributionSet set = testdataFactory.createDistributionSet("one");
deploymentManagement.assignDistributionSet(set.getId(),
Arrays.asList(new TargetWithActionType(testdataFactory.createTarget().getControllerId())));
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(1);
assertThat(distributionSetManagement.count()).isEqualTo(1);
mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId())
.content("{\"version\":\"anotherVersion\",\"requiredMigrationStep\":\"true\"}")
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden());
final DistributionSet setupdated = distributionSetManagement.findDistributionSetById(set.getId()).get();
final DistributionSet setupdated = distributionSetManagement.get(set.getId()).get();
assertThat(setupdated.isRequiredMigrationStep()).isEqualTo(false);
assertThat(setupdated.getVersion()).isEqualTo(set.getVersion());
@@ -790,9 +783,9 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
.andExpect(jsonPath("[1]value", equalTo(knownValue2)));
final DistributionSetMetadata metaKey1 = distributionSetManagement
.findDistributionSetMetadata(testDS.getId(), knownKey1).get();
.getMetaDataByDistributionSetId(testDS.getId(), knownKey1).get();
final DistributionSetMetadata metaKey2 = distributionSetManagement
.findDistributionSetMetadata(testDS.getId(), knownKey2).get();
.getMetaDataByDistributionSetId(testDS.getId(), knownKey2).get();
assertThat(metaKey1.getValue()).isEqualTo(knownValue1);
assertThat(metaKey2.getValue()).isEqualTo(knownValue2);
@@ -818,7 +811,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
.andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue)));
final DistributionSetMetadata assertDS = distributionSetManagement
.findDistributionSetMetadata(testDS.getId(), knownKey).get();
.getMetaDataByDistributionSetId(testDS.getId(), knownKey).get();
assertThat(assertDS.getValue()).isEqualTo(updateValue);
}
@@ -836,7 +829,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
mvc.perform(delete("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(distributionSetManagement.findDistributionSetMetadata(testDS.getId(), knownKey)).isNotPresent();
assertThat(distributionSetManagement.getMetaDataByDistributionSetId(testDS.getId(), knownKey)).isNotPresent();
}
@Test
@@ -855,7 +848,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
mvc.perform(delete("/rest/v1/distributionsets/1234/metadata/{key}", knownKey))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
assertThat(distributionSetManagement.findDistributionSetMetadata(testDS.getId(), knownKey)).isPresent();
assertThat(distributionSetManagement.getMetaDataByDistributionSetId(testDS.getId(), knownKey)).isPresent();
}
@Test
@@ -918,8 +911,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
public void filterDistributionSetComplete() throws Exception {
final int amount = 10;
testdataFactory.createDistributionSets(amount);
distributionSetManagement.createDistributionSet(
entityFactory.distributionSet().create().name("incomplete").version("2").type("os"));
distributionSetManagement
.create(entityFactory.distributionSet().create().name("incomplete").version("2").type("os"));
final String rsqlFindLikeDs1OrDs2 = "complete==" + Boolean.TRUE;
@@ -937,8 +930,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
// prepare targets
final Collection<String> knownTargetIds = Arrays.asList("1", "2", "3", "4", "5");
knownTargetIds.forEach(controllerId -> targetManagement
.createTarget(entityFactory.target().create().controllerId(controllerId)));
knownTargetIds.forEach(
controllerId -> targetManagement.create(entityFactory.target().create().controllerId(controllerId)));
// assign already one target to DS
assignDistributionSet(createdDs.getId(), knownTargetIds.iterator().next());

View File

@@ -113,11 +113,11 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
final Tag createdOne = tagManagement.findAllDistributionSetTags("name==thetest1", PAGE).getContent().get(0);
final Tag createdOne = distributionSetTagManagement.findByRsql(PAGE, "name==thetest1").getContent().get(0);
assertThat(createdOne.getName()).isEqualTo(tagOne.getName());
assertThat(createdOne.getDescription()).isEqualTo(tagOne.getDescription());
assertThat(createdOne.getColour()).isEqualTo(tagOne.getColour());
final Tag createdTwo = tagManagement.findAllDistributionSetTags("name==thetest2", PAGE).getContent().get(0);
final Tag createdTwo = distributionSetTagManagement.findByRsql(PAGE, "name==thetest2").getContent().get(0);
assertThat(createdTwo.getName()).isEqualTo(tagTwo.getName());
assertThat(createdTwo.getDescription()).isEqualTo(tagTwo.getDescription());
assertThat(createdTwo.getColour()).isEqualTo(tagTwo.getColour());
@@ -143,7 +143,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
final Tag updated = tagManagement.findAllDistributionSetTags("name==updatedName", PAGE).getContent().get(0);
final Tag updated = distributionSetTagManagement.findByRsql(PAGE, "name==updatedName").getContent().get(0);
assertThat(updated.getName()).isEqualTo(update.getName());
assertThat(updated.getDescription()).isEqualTo(update.getDescription());
assertThat(updated.getColour()).isEqualTo(update.getColour());
@@ -162,7 +162,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + original.getId()))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(tagManagement.findDistributionSetTagById(original.getId())).isNotPresent();
assertThat(distributionSetTagManagement.get(original.getId())).isNotPresent();
}
@Test
@@ -242,8 +242,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
// 2 DistributionSetUpdateEvent
ResultActions result = toggle(tag, sets);
List<DistributionSet> updated = distributionSetManagement.findDistributionSetsByTag(PAGE, tag.getId())
.getContent();
List<DistributionSet> updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent();
assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList()))
.containsAll(sets.stream().map(DistributionSet::getId).collect(Collectors.toList()));
@@ -254,12 +253,12 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
// 2 DistributionSetUpdateEvent
result = toggle(tag, sets);
updated = distributionSetManagement.findDistributionSetsAll(PAGE, false).getContent();
updated = distributionSetManagement.findAll(PAGE).getContent();
result.andExpect(applyBaseEntityMatcherOnArrayResult(updated.get(0), "unassignedDistributionSets"))
.andExpect(applyBaseEntityMatcherOnArrayResult(updated.get(1), "unassignedDistributionSets"));
assertThat(distributionSetManagement.findDistributionSetsByTag(PAGE, tag.getId())).isEmpty();
assertThat(distributionSetManagement.findByTag(PAGE, tag.getId())).isEmpty();
}
private ResultActions toggle(final DistributionSetTag tag, final List<DistributionSet> sets) throws Exception {
@@ -291,8 +290,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
final List<DistributionSet> updated = distributionSetManagement.findDistributionSetsByTag(PAGE, tag.getId())
.getContent();
final List<DistributionSet> updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent();
assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList()))
.containsAll(sets.stream().map(DistributionSet::getId).collect(Collectors.toList()));
@@ -319,8 +317,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/"
+ unassigned.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
final List<DistributionSet> updated = distributionSetManagement.findDistributionSetsByTag(PAGE, tag.getId())
.getContent();
final List<DistributionSet> updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent();
assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList()))
.containsOnly(assigned.getId());

View File

@@ -59,9 +59,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
public void getDistributionSetTypes() throws Exception {
DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
.create(entityFactory.distributionSetType().create().key("test123")
.name("TestName123").description("Desc123").colour("col12"));
testType = distributionSetTypeManagement.updateDistributionSetType(
testType = distributionSetTypeManagement.update(
entityFactory.distributionSetType().update(testType.getId()).description("Desc1234"));
// 4 types overall (2 hawkbit tenant default, 1 test default and 1
@@ -100,9 +100,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
public void getDistributionSetTypesSortedByKey() throws Exception {
DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("zzzzz").name("TestName123")
.create(entityFactory.distributionSetType().create().key("zzzzz").name("TestName123")
.description("Desc123").colour("col12"));
testType = distributionSetTypeManagement.updateDistributionSetType(
testType = distributionSetTypeManagement.update(
entityFactory.distributionSetType().update(testType.getId()).description("Desc1234"));
// descending
@@ -148,11 +148,11 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@Step
private void verifyCreatedDistributionSetTypes(final MvcResult mvcResult) throws UnsupportedEncodingException {
final DistributionSetType created1 = distributionSetTypeManagement.findDistributionSetTypeByKey("testKey1")
final DistributionSetType created1 = distributionSetTypeManagement.getByKey("testKey1")
.get();
final DistributionSetType created2 = distributionSetTypeManagement.findDistributionSetTypeByKey("testKey2")
final DistributionSetType created2 = distributionSetTypeManagement.getByKey("testKey2")
.get();
final DistributionSetType created3 = distributionSetTypeManagement.findDistributionSetTypeByKey("testKey3")
final DistributionSetType created3 = distributionSetTypeManagement.getByKey("testKey3")
.get();
assertThat(created1.getMandatoryModuleTypes()).containsOnly(osType);
@@ -190,7 +190,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
.toString()).isEqualTo(
"http://localhost/rest/v1/distributionsettypes/" + created3.getId() + "/optionalmoduletypes");
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(6);
assertThat(distributionSetTypeManagement.count()).isEqualTo(6);
}
@Step
@@ -217,7 +217,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@Step
private List<DistributionSetType> createTestDistributionSetTestTypes() {
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES);
assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES);
return Arrays.asList(
entityFactory.distributionSetType().create().key("testKey1").name("TestName1").description("Desc1")
@@ -235,7 +235,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes POST requests.")
public void addMandatoryModuleToDistributionSetType() throws Exception {
DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
.create(entityFactory.distributionSetType().create().key("test123")
.name("TestName123").description("Desc123").colour("col12"));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
@@ -243,7 +243,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
.content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
testType = distributionSetTypeManagement.findDistributionSetTypeById(testType.getId()).get();
testType = distributionSetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2);
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
@@ -255,7 +255,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes POST requests.")
public void addOptionalModuleToDistributionSetType() throws Exception {
DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
.create(entityFactory.distributionSetType().create().key("test123")
.name("TestName123").description("Desc123").colour("col12"));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
@@ -263,7 +263,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
.content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
testType = distributionSetTypeManagement.findDistributionSetTypeById(testType.getId()).get();
testType = distributionSetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2);
assertThat(testType.getOptionalModuleTypes()).containsExactly(osType);
@@ -318,7 +318,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
}
private DistributionSetType generateTestType() {
final DistributionSetType testType = distributionSetTypeManagement.createDistributionSetType(entityFactory
final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory
.distributionSetType().create().key("test123").name("TestName123").description("Desc123").colour("col")
.mandatory(Arrays.asList(osType.getId())).optional(Arrays.asList(appType.getId())));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
@@ -354,7 +354,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
osType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
testType = distributionSetTypeManagement.findDistributionSetTypeById(testType.getId()).get();
testType = distributionSetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2);
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
@@ -371,7 +371,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
appType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
testType = distributionSetTypeManagement.findDistributionSetTypeById(testType.getId()).get();
testType = distributionSetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2);
assertThat(testType.getOptionalModuleTypes()).isEmpty();
@@ -384,9 +384,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
public void getDistributionSetType() throws Exception {
DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
.create(entityFactory.distributionSetType().create().key("test123")
.name("TestName123").description("Desc123").colour("col12"));
testType = distributionSetTypeManagement.updateDistributionSetType(
testType = distributionSetTypeManagement.update(
entityFactory.distributionSetType().update(testType.getId()).description("Desc1234"));
mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId()).accept(MediaType.APPLICATION_JSON))
@@ -404,15 +404,15 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@Description("Checks the correct behaviour of /rest/v1/DistributionSetTypes/{ID} DELETE requests (hard delete scenario).")
public void deleteDistributionSetTypeUnused() throws Exception {
final DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
.create(entityFactory.distributionSetType().create().key("test123")
.name("TestName123").description("Desc123").colour("col12"));
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES + 1);
assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES + 1);
mvc.perform(delete("/rest/v1/distributionsettypes/{dsId}", testType.getId()))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES);
assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES);
}
@Test
@@ -427,27 +427,27 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@Description("Checks the correct behaviour of /rest/v1/DistributionSetTypes/{ID} DELETE requests (soft delete scenario).")
public void deleteDistributionSetTypeUsed() throws Exception {
final DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
.create(entityFactory.distributionSetType().create().key("test123")
.name("TestName123").description("Desc123").colour("col12"));
distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create().name("sdfsd")
distributionSetManagement.create(entityFactory.distributionSet().create().name("sdfsd")
.description("dsfsdf").version("1").type(testType));
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES + 1);
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(1);
assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES + 1);
assertThat(distributionSetManagement.count()).isEqualTo(1);
mvc.perform(delete("/rest/v1/distributionsettypes/{smId}", testType.getId()))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(1);
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES);
assertThat(distributionSetManagement.count()).isEqualTo(1);
assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES);
}
@Test
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID} PUT requests.")
public void updateDistributionSetTypeOnlyDescriptionAndNameUntouched() throws Exception {
final DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
.create(entityFactory.distributionSetType().create().key("test123")
.name("TestName123").description("Desc123").colour("col"));
final String body = new JSONObject().put("id", testType.getId()).put("description", "foobardesc")
@@ -510,7 +510,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
// .createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
// .name("TestName123").description("Desc123").colour("col"));
final SoftwareModuleType testSmType = softwareModuleTypeManagement.createSoftwareModuleType(
final SoftwareModuleType testSmType = softwareModuleTypeManagement.create(
entityFactory.softwareModuleType().create().key("test123").name("TestName123"));
// DST does not exist
@@ -598,9 +598,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@Test
@Description("Search erquest of software module types.")
public void searchDistributionSetTypeRsql() throws Exception {
distributionSetTypeManagement.createDistributionSetType(
distributionSetTypeManagement.create(
entityFactory.distributionSetType().create().key("test123").name("TestName123"));
distributionSetTypeManagement.createDistributionSetType(
distributionSetTypeManagement.create(
entityFactory.distributionSetType().create().key("test1234").name("TestName1234"));
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
@@ -615,7 +615,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
char character = 'a';
for (int index = 0; index < amount; index++) {
final String str = String.valueOf(character);
softwareModuleManagement.createSoftwareModule(
softwareModuleManagement.create(
entityFactory.softwareModule().create().name(str).description(str).vendor(str).version(str));
character++;
}

View File

@@ -223,7 +223,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
final DistributionSet dsA = testdataFactory.createDistributionSet("");
// create rollout including the created targets with prefix 'rollout'
final Rollout rollout = rolloutManagement.createRollout(
final Rollout rollout = rolloutManagement.create(
entityFactory.rollout().create().name("rollout1").set(dsA.getId())
.targetFilterQuery("controllerId==rollout*"),
4, new RolloutGroupConditionBuilder().withDefaults()
@@ -254,7 +254,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
@Step
private void retrieveAndVerifyRolloutInStarting(final Rollout rollout) throws Exception {
rolloutManagement.startRollout(rollout.getId());
rolloutManagement.start(rollout.getId());
mvc.perform(get("/rest/v1/rollouts/" + rollout.getId()).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
@@ -592,17 +592,17 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
final DistributionSet dsA = testdataFactory.createDistributionSet("");
// create rollout including the created targets with prefix 'rollout'
final Rollout rollout = rolloutManagement.createRollout(
final Rollout rollout = rolloutManagement.create(
entityFactory.rollout().create().name("rollout1").set(dsA.getId())
.targetFilterQuery("controllerId==rollout*"),
4, new RolloutGroupConditionBuilder().withDefaults()
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "100").build());
final RolloutGroup firstGroup = rolloutGroupManagement
.findRolloutGroupsByRolloutId(rollout.getId(), new PageRequest(0, 1, Direction.ASC, "id")).getContent()
.findByRollout(new PageRequest(0, 1, Direction.ASC, "id"), rollout.getId()).getContent()
.get(0);
final RolloutGroup secondGroup = rolloutGroupManagement
.findRolloutGroupsByRolloutId(rollout.getId(), new PageRequest(1, 1, Direction.ASC, "id")).getContent()
.findByRollout(new PageRequest(1, 1, Direction.ASC, "id"), rollout.getId()).getContent()
.get(0);
retrieveAndVerifyRolloutGroupInCreating(rollout, firstGroup);
@@ -613,7 +613,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
@Step
private void retrieveAndVerifyRolloutGroupInRunningAndScheduled(final Rollout rollout,
final RolloutGroup firstGroup, final RolloutGroup secondGroup) throws Exception {
rolloutManagement.startRollout(rollout.getId());
rolloutManagement.start(rollout.getId());
rolloutManagement.handleRollouts();
mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}", rollout.getId(), firstGroup.getId())
.accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
@@ -696,7 +696,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*");
final RolloutGroup firstGroup = rolloutGroupManagement
.findRolloutGroupsByRolloutId(rollout.getId(), new PageRequest(0, 1, Direction.ASC, "id")).getContent()
.findByRollout(new PageRequest(0, 1, Direction.ASC, "id"), rollout.getId()).getContent()
.get(0);
// retrieve targets from the first rollout group with known ID
@@ -720,10 +720,10 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*");
final RolloutGroup firstGroup = rolloutGroupManagement
.findRolloutGroupsByRolloutId(rollout.getId(), new PageRequest(0, 1, Direction.ASC, "id")).getContent()
.findByRollout(new PageRequest(0, 1, Direction.ASC, "id"), rollout.getId()).getContent()
.get(0);
final String targetInGroup = rolloutGroupManagement.findRolloutGroupTargets(firstGroup.getId(), PAGE)
final String targetInGroup = rolloutGroupManagement.findTargetsOfRolloutGroup(PAGE, firstGroup.getId())
.getContent().get(0).getControllerId();
// retrieve targets from the first rollout group with known ID
@@ -746,13 +746,13 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
// create rollout including the created targets with prefix 'rollout'
final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*");
rolloutManagement.startRollout(rollout.getId());
rolloutManagement.start(rollout.getId());
// Run here, because scheduler is disabled during tests
rolloutManagement.handleRollouts();
final RolloutGroup firstGroup = rolloutGroupManagement
.findRolloutGroupsByRolloutId(rollout.getId(), new PageRequest(0, 1, Direction.ASC, "id")).getContent()
.findByRollout(new PageRequest(0, 1, Direction.ASC, "id"), rollout.getId()).getContent()
.get(0);
// retrieve targets from the first rollout group with known ID
@@ -945,7 +945,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
private Rollout createRollout(final String name, final int amountGroups, final long distributionSetId,
final String targetFilterQuery) {
final Rollout rollout = rolloutManagement.createRollout(
final Rollout rollout = rolloutManagement.create(
entityFactory.rollout().create().name(name).set(distributionSetId).targetFilterQuery(targetFilterQuery),
amountGroups, new RolloutGroupConditionBuilder().withDefaults()
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "100").build());
@@ -953,7 +953,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
// Run here, because Scheduler is disabled during tests
rolloutManagement.handleRollouts();
return rolloutManagement.findRolloutById(rollout.getId()).get();
return rolloutManagement.get(rollout.getId()).get();
}
protected boolean success(final Rollout result) {
@@ -961,7 +961,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
}
public Rollout getRollout(final Long rolloutId) throws Exception {
return rolloutManagement.findRolloutById(rolloutId).get();
return rolloutManagement.get(rolloutId).get();
}
}

View File

@@ -70,7 +70,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
@Before
public void assertPreparationOfRepo() {
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("no softwaremodule should be founded")
assertThat(softwareModuleManagement.findAll(PAGE)).as("no softwaremodule should be founded")
.hasSize(0);
}
@@ -87,7 +87,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final String updateDescription = "newDescription1";
SoftwareModule sm = softwareModuleManagement
.createSoftwareModule(entityFactory.softwareModule().create().type(osType).name(knownSWName)
.create(entityFactory.softwareModule().create().type(osType).name(knownSWName)
.version(knownSWVersion).description(knownSWDescription).vendor(knownSWVendor));
assertThat(sm.getName()).as("Wrong name of the software module").isEqualTo(knownSWName);
@@ -108,7 +108,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andExpect(jsonPath("$.description", equalTo(updateDescription)))
.andExpect(jsonPath("$.name", equalTo(knownSWName))).andReturn();
sm = softwareModuleManagement.findSoftwareModuleById(sm.getId()).get();
sm = softwareModuleManagement.get(sm.getId()).get();
assertThat(sm.getName()).isEqualTo(knownSWName);
assertThat(sm.getVendor()).isEqualTo(updateVendor);
assertThat(sm.getLastModifiedBy()).isEqualTo("smUpdateTester");
@@ -141,7 +141,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
// check rest of response compared to DB
final MgmtArtifact artResult = ResourceUtility
.convertArtifactResponse(mvcResult.getResponse().getContentAsString());
final Long artId = softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0)
final Long artId = softwareModuleManagement.get(sm.getId()).get().getArtifacts().get(0)
.getId();
assertThat(artResult.getArtifactId()).as("Wrong artifact id").isEqualTo(artId);
assertThat(JsonPath.compile("$._links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
@@ -157,34 +157,34 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
private void assertArtifact(final SoftwareModule sm, final byte[] random) throws IOException {
// check result in db...
// repo
assertThat(artifactManagement.countArtifactsAll()).as("Wrong artifact size").isEqualTo(1);
assertThat(artifactManagement.count()).as("Wrong artifact size").isEqualTo(1);
// binary
try (InputStream fileInputStream = artifactManagement.loadArtifactBinary(
softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0).getSha1Hash())
softwareModuleManagement.get(sm.getId()).get().getArtifacts().get(0).getSha1Hash())
.get().getFileInputStream()) {
assertTrue("Wrong artifact content",
IOUtils.contentEquals(new ByteArrayInputStream(random), fileInputStream));
}
// hashes
assertThat(artifactManagement.findArtifactByFilename("origFilename").get().getSha1Hash()).as("Wrong sha1 hash")
assertThat(artifactManagement.getByFilename("origFilename").get().getSha1Hash()).as("Wrong sha1 hash")
.isEqualTo(HashGeneratorUtils.generateSHA1(random));
assertThat(artifactManagement.findArtifactByFilename("origFilename").get().getMd5Hash()).as("Wrong md5 hash")
assertThat(artifactManagement.getByFilename("origFilename").get().getMd5Hash()).as("Wrong md5 hash")
.isEqualTo(HashGeneratorUtils.generateMD5(random));
// metadata
assertThat(
softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0).getFilename())
softwareModuleManagement.get(sm.getId()).get().getArtifacts().get(0).getFilename())
.as("wrong metadata of the filename").isEqualTo("origFilename");
}
@Test
@Description("Verfies that the system does not accept empty artifact uploads. Expected response: BAD REQUEST")
public void emptyUploadArtifact() throws Exception {
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(0);
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(0);
assertThat(artifactManagement.count()).isEqualTo(0);
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
@@ -220,7 +220,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
@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 {
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(0);
assertThat(artifactManagement.count()).isEqualTo(0);
// create test file
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
@@ -235,10 +235,10 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
// check result in db...
// repo
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(1);
assertThat(artifactManagement.count()).isEqualTo(1);
// hashes
assertThat(artifactManagement.findArtifactByFilename("customFilename")).as("Local artifact is wrong")
assertThat(artifactManagement.getByFilename("customFilename")).as("Local artifact is wrong")
.isPresent();
}
@@ -246,7 +246,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
@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 {
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(0);
assertThat(artifactManagement.count()).isEqualTo(0);
// create test file
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
@@ -292,16 +292,16 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(),
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(),
"file1", false);
final Artifact artifact2 = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(),
final Artifact artifact2 = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(),
"file2", false);
downloadAndVerify(sm, random, artifact);
downloadAndVerify(sm, random, artifact2);
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Softwaremodule size is wrong").hasSize(1);
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(2);
assertThat(softwareModuleManagement.findAll(PAGE)).as("Softwaremodule size is wrong").hasSize(1);
assertThat(artifactManagement.count()).isEqualTo(2);
}
private void downloadAndVerify(final SoftwareModule sm, final byte[] random, final Artifact artifact)
@@ -322,7 +322,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(),
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(),
"file1", false);
// perform test
@@ -348,9 +348,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(),
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(),
"file1", false);
final Artifact artifact2 = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(),
final Artifact artifact2 = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(),
"file2", false);
mvc.perform(get("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).accept(MediaType.APPLICATION_JSON))
@@ -394,7 +394,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
// SM does not exist
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false);
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file1", false);
mvc.perform(get("/rest/v1/softwaremodules/1234567890/artifacts")).andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound());
@@ -548,7 +548,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andExpect(jsonPath("$.content.[?(@.id==" + app.getId() + ")]._links.self.href",
contains("http://localhost/rest/v1/softwaremodules/" + app.getId())));
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Softwaremodule size is wrong").hasSize(2);
assertThat(softwareModuleManagement.findAll(PAGE)).as("Softwaremodule size is wrong").hasSize(2);
}
@Test
@@ -559,7 +559,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
testdataFactory.createSoftwareModuleOs("2");
final SoftwareModule app2 = testdataFactory.createSoftwareModuleApp("2");
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(4);
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(4);
// only by name, only one exists per name
mvc.perform(get("/rest/v1/softwaremodules?q=name==" + os1.getName()).accept(MediaType.APPLICATION_JSON))
@@ -649,7 +649,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andExpect(jsonPath("$._links.artifacts.href",
equalTo("http://localhost/rest/v1/softwaremodules/" + os.getId() + "/artifacts")));
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Softwaremodule size is wrong").hasSize(1);
assertThat(softwareModuleManagement.findAll(PAGE)).as("Softwaremodule size is wrong").hasSize(1);
}
@Test
@@ -684,9 +684,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andExpect(jsonPath("[1].createdAt", not(equalTo(0)))).andReturn();
final SoftwareModule osCreated = softwareModuleManagement
.findSoftwareModuleByNameAndVersion("name1", "version1", osType.getId()).get();
.getByNameAndVersionAndType("name1", "version1", osType.getId()).get();
final SoftwareModule appCreated = softwareModuleManagement
.findSoftwareModuleByNameAndVersion("name3", "version3", appType.getId()).get();
.getByNameAndVersionAndType("name3", "version3", appType.getId()).get();
assertThat(
JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
@@ -704,16 +704,16 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.toString()).as("Response contains invalid artifacts href")
.isEqualTo("http://localhost/rest/v1/softwaremodules/" + appCreated.getId() + "/artifacts");
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Wrong softwaremodule size").hasSize(2);
assertThat(softwareModuleManagement.findAll(PAGE)).as("Wrong softwaremodule size").hasSize(2);
assertThat(
softwareModuleManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0).getName())
softwareModuleManagement.findByType(PAGE, osType.getId()).getContent().get(0).getName())
.as("Softwaremoudle name is wrong").isEqualTo(os.getName());
assertThat(softwareModuleManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0)
assertThat(softwareModuleManagement.findByType(PAGE, osType.getId()).getContent().get(0)
.getCreatedBy()).as("Softwaremoudle created by is wrong").isEqualTo("uploadTester");
assertThat(softwareModuleManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0)
assertThat(softwareModuleManagement.findByType(PAGE, osType.getId()).getContent().get(0)
.getCreatedAt()).as("Softwaremoudle created at is wrong").isGreaterThanOrEqualTo(current);
assertThat(
softwareModuleManagement.findSoftwareModulesByType(PAGE, appType.getId()).getContent().get(0).getName())
softwareModuleManagement.findByType(PAGE, appType.getId()).getContent().get(0).getName())
.as("Softwaremoudle name is wrong").isEqualTo(ah.getName());
}
@@ -725,17 +725,17 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false);
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file1", false);
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Softwaremoudle size is wrong").hasSize(1);
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(1);
assertThat(softwareModuleManagement.findAll(PAGE)).as("Softwaremoudle size is wrong").hasSize(1);
assertThat(artifactManagement.count()).isEqualTo(1);
mvc.perform(delete("/rest/v1/softwaremodules/{smId}", sm.getId())).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE))
assertThat(softwareModuleManagement.findAll(PAGE))
.as("After delete no softwarmodule should be available").isEmpty();
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(0);
assertThat(artifactManagement.count()).isEqualTo(0);
}
@Test
@@ -745,11 +745,11 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
artifactManagement.createArtifact(new ByteArrayInputStream(random),
artifactManagement.create(new ByteArrayInputStream(random),
ds1.findFirstModuleByType(appType).get().getId(), "file1", false);
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(3);
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(1);
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(3);
assertThat(artifactManagement.count()).isEqualTo(1);
mvc.perform(delete("/rest/v1/softwaremodules/{smId}", ds1.findFirstModuleByType(appType).get().getId()))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
@@ -759,9 +759,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
// all 3 are now marked as deleted
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE).getNumber())
assertThat(softwareModuleManagement.findAll(PAGE).getNumber())
.as("After delete no softwarmodule should be available").isEqualTo(0);
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(1);
assertThat(artifactManagement.count()).isEqualTo(1);
}
@Test
@@ -773,25 +773,25 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
// Create 2 artifacts
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(),
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(),
"file1", false);
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file2", false);
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file2", false);
// check repo before delete
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(1);
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(1);
assertThat(softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts()).hasSize(2);
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(2);
assertThat(softwareModuleManagement.get(sm.getId()).get().getArtifacts()).hasSize(2);
assertThat(artifactManagement.count()).isEqualTo(2);
// delete
mvc.perform(delete("/rest/v1/softwaremodules/{smId}/artifacts/{artId}", sm.getId(), artifact.getId()))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
// check that only one artifact is still alive and still assigned
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("After the sm should be marked as deleted")
assertThat(softwareModuleManagement.findAll(PAGE)).as("After the sm should be marked as deleted")
.hasSize(1);
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(1);
assertThat(softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts())
assertThat(artifactManagement.count()).isEqualTo(1);
assertThat(softwareModuleManagement.get(sm.getId()).get().getArtifacts())
.as("After delete artifact should available for marked as deleted sm's").hasSize(1);
}
@@ -820,9 +820,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andExpect(jsonPath("[1]value", equalTo(knownValue2)));
final SoftwareModuleMetadata metaKey1 = softwareModuleManagement
.findSoftwareModuleMetadata(sm.getId(), knownKey1).get();
.getMetaDataBySoftwareModuleId(sm.getId(), knownKey1).get();
final SoftwareModuleMetadata metaKey2 = softwareModuleManagement
.findSoftwareModuleMetadata(sm.getId(), knownKey2).get();
.getMetaDataBySoftwareModuleId(sm.getId(), knownKey2).get();
assertThat(metaKey1.getValue()).as("Metadata key is wrong").isEqualTo(knownValue1);
assertThat(metaKey2.getValue()).as("Metadata key is wrong").isEqualTo(knownValue2);
@@ -837,7 +837,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final String updateValue = "valueForUpdate";
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
softwareModuleManagement.createSoftwareModuleMetadata(sm.getId(),
softwareModuleManagement.createMetaData(sm.getId(),
entityFactory.generateMetadata(knownKey, knownValue));
final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue);
@@ -849,7 +849,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue)));
final SoftwareModuleMetadata assertDS = softwareModuleManagement
.findSoftwareModuleMetadata(sm.getId(), knownKey).get();
.getMetaDataBySoftwareModuleId(sm.getId(), knownKey).get();
assertThat(assertDS.getValue()).as("Metadata is wrong").isEqualTo(updateValue);
}
@@ -861,13 +861,13 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final String knownValue = "knownValue";
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
softwareModuleManagement.createSoftwareModuleMetadata(sm.getId(),
softwareModuleManagement.createMetaData(sm.getId(),
entityFactory.generateMetadata(knownKey, knownValue));
mvc.perform(delete("/rest/v1/softwaremodules/{swId}/metadata/{key}", sm.getId(), knownKey))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(softwareModuleManagement.findSoftwareModuleMetadata(sm.getId(), knownKey)).isNotPresent();
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(sm.getId(), knownKey)).isNotPresent();
}
@Test
@@ -878,7 +878,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final String knownValue = "knownValue";
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
softwareModuleManagement.createSoftwareModuleMetadata(sm.getId(),
softwareModuleManagement.createMetaData(sm.getId(),
entityFactory.generateMetadata(knownKey, knownValue));
mvc.perform(delete("/rest/v1/softwaremodules/{swId}/metadata/XXX", sm.getId(), knownKey))
@@ -887,7 +887,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
mvc.perform(delete("/rest/v1/softwaremodules/1234/metadata/{key}", knownKey))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
assertThat(softwareModuleManagement.findSoftwareModuleMetadata(sm.getId(), knownKey)).isPresent();
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(sm.getId(), knownKey)).isPresent();
}
@Test
@@ -906,7 +906,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
for (int index = 0; index < totalMetadata; index++) {
softwareModuleManagement.createSoftwareModuleMetadata(sm.getId(),
softwareModuleManagement.createMetaData(sm.getId(),
entityFactory.generateMetadata(knownKeyPrefix + index, knownValuePrefix + index));
}
@@ -922,7 +922,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
char character = 'a';
for (int index = 0; index < amount; index++) {
final String str = String.valueOf(character);
softwareModuleManagement.createSoftwareModule(entityFactory.softwareModule().create().type(osType).name(str)
softwareModuleManagement.create(entityFactory.softwareModule().create().type(osType).name(str)
.description(str).vendor(str).version(str));
character++;
}

View File

@@ -91,9 +91,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
private SoftwareModuleType createTestType() {
SoftwareModuleType testType = softwareModuleTypeManagement
.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("test123").name("TestName123")
.create(entityFactory.softwareModuleType().create().key("test123").name("TestName123")
.description("Desc123").maxAssignments(5));
testType = softwareModuleTypeManagement.updateSoftwareModuleType(
testType = softwareModuleTypeManagement.update(
entityFactory.softwareModuleType().update(testType.getId()).description("Desc1234"));
return testType;
}
@@ -190,9 +190,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
.andExpect(jsonPath("[2].createdAt", not(equalTo(0))))
.andExpect(jsonPath("[2].maxAssignments", equalTo(3))).andReturn();
final SoftwareModuleType created1 = softwareModuleTypeManagement.findSoftwareModuleTypeByKey("test1").get();
final SoftwareModuleType created2 = softwareModuleTypeManagement.findSoftwareModuleTypeByKey("test2").get();
final SoftwareModuleType created3 = softwareModuleTypeManagement.findSoftwareModuleTypeByKey("test3").get();
final SoftwareModuleType created1 = softwareModuleTypeManagement.getByKey("test1").get();
final SoftwareModuleType created2 = softwareModuleTypeManagement.getByKey("test2").get();
final SoftwareModuleType created3 = softwareModuleTypeManagement.getByKey("test3").get();
assertThat(
JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
@@ -204,7 +204,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
.isEqualTo("http://localhost/rest/v1/softwaremoduletypes/" + created3.getId());
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).isEqualTo(6);
assertThat(softwareModuleTypeManagement.count()).isEqualTo(6);
}
@Test
@@ -231,12 +231,12 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
public void deleteSoftwareModuleTypeUnused() throws Exception {
final SoftwareModuleType testType = createTestType();
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
assertThat(softwareModuleTypeManagement.count()).isEqualTo(4);
mvc.perform(delete("/rest/v1/softwaremoduletypes/{smId}", testType.getId())).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).isEqualTo(3);
assertThat(softwareModuleTypeManagement.count()).isEqualTo(3);
}
@Test
@@ -251,15 +251,15 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} DELETE requests (soft delete scenario).")
public void deleteSoftwareModuleTypeUsed() throws Exception {
final SoftwareModuleType testType = createTestType();
softwareModuleManagement.createSoftwareModule(
softwareModuleManagement.create(
entityFactory.softwareModule().create().type(testType).name("name").version("version"));
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
assertThat(softwareModuleTypeManagement.count()).isEqualTo(4);
mvc.perform(delete("/rest/v1/softwaremoduletypes/{smId}", testType.getId())).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).isEqualTo(3);
assertThat(softwareModuleTypeManagement.count()).isEqualTo(3);
}
@Test
@@ -370,9 +370,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
@Test
@Description("Search erquest of software module types.")
public void searchSoftwareModuleTypeRsql() throws Exception {
softwareModuleTypeManagement.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("test123")
softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("test123")
.name("TestName123").description("Desc123").maxAssignments(5));
softwareModuleTypeManagement.createSoftwareModuleType(entityFactory.softwareModuleType().create()
softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create()
.key("test1234").name("TestName1234").description("Desc1234").maxAssignments(5));
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
@@ -388,7 +388,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
char character = 'a';
for (int index = 0; index < amount; index++) {
final String str = String.valueOf(character);
softwareModuleManagement.createSoftwareModule(entityFactory.softwareModule().create().type(osType).name(str)
softwareModuleManagement.create(entityFactory.softwareModule().create().type(osType).name(str)
.description(str).vendor(str).version(str));
character++;
}

View File

@@ -74,7 +74,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
mvc.perform(delete(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId()))
.andExpect(status().isOk());
assertThat(targetFilterQueryManagement.findTargetFilterQueryById(filterQuery.getId())).isNotPresent();
assertThat(targetFilterQueryManagement.get(filterQuery.getId())).isNotPresent();
}
@Test
@@ -112,7 +112,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
.andExpect(jsonPath("$.query", equalTo(filterQuery2)))
.andExpect(jsonPath("$.name", equalTo(filterName)));
final TargetFilterQuery tfqCheck = targetFilterQueryManagement.findTargetFilterQueryById(tfq.getId()).get();
final TargetFilterQuery tfqCheck = targetFilterQueryManagement.get(tfq.getId()).get();
assertThat(tfqCheck.getQuery()).isEqualTo(filterQuery2);
assertThat(tfqCheck.getName()).isEqualTo(filterName);
}
@@ -126,7 +126,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
final String body = new JSONObject().put("name", filterName2).toString();
// prepare
final TargetFilterQuery tfq = targetFilterQueryManagement.createTargetFilterQuery(
final TargetFilterQuery tfq = targetFilterQueryManagement.create(
entityFactory.targetFilterQuery().create().name(filterName).query(filterQuery));
mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId()).content(body)
@@ -135,7 +135,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
.andExpect(jsonPath("$.query", equalTo(filterQuery)))
.andExpect(jsonPath("$.name", equalTo(filterName2)));
final TargetFilterQuery tfqCheck = targetFilterQueryManagement.findTargetFilterQueryById(tfq.getId()).get();
final TargetFilterQuery tfqCheck = targetFilterQueryManagement.get(tfq.getId()).get();
assertThat(tfqCheck.getQuery()).isEqualTo(filterQuery);
assertThat(tfqCheck.getName()).isEqualTo(filterName2);
}
@@ -270,7 +270,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
assertThat(targetFilterQueryManagement.countAllTargetFilterQuery()).isEqualTo(0);
assertThat(targetFilterQueryManagement.count()).isEqualTo(0);
// verify response json exception message
final ExceptionInfo exceptionInfo = ResourceUtility
@@ -293,7 +293,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(
targetFilterQueryManagement.findTargetFilterQueryById(tfq.getId()).get().getAutoAssignDistributionSet())
targetFilterQueryManagement.get(tfq.getId()).get().getAutoAssignDistributionSet())
.isEqualTo(set);
final String hrefPrefix = "http://localhost" + MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/"
@@ -317,10 +317,10 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
final DistributionSet set = testdataFactory.createDistributionSet(dsName);
final TargetFilterQuery tfq = createSingleTargetFilterQuery(knownName, knownQuery);
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(tfq.getId(), set.getId());
targetFilterQueryManagement.updateAutoAssignDS(tfq.getId(), set.getId());
assertThat(
targetFilterQueryManagement.findTargetFilterQueryById(tfq.getId()).get().getAutoAssignDistributionSet())
targetFilterQueryManagement.get(tfq.getId()).get().getAutoAssignDistributionSet())
.isEqualTo(set);
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS"))
@@ -330,7 +330,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
.andExpect(status().isNoContent());
assertThat(
targetFilterQueryManagement.findTargetFilterQueryById(tfq.getId()).get().getAutoAssignDistributionSet())
targetFilterQueryManagement.get(tfq.getId()).get().getAutoAssignDistributionSet())
.isNull();
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS"))
@@ -340,7 +340,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
private TargetFilterQuery createSingleTargetFilterQuery(final String name, final String query) {
return targetFilterQueryManagement
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name(name).query(query));
.create(entityFactory.targetFilterQuery().create().name(name).query(query));
}
}

View File

@@ -183,7 +183,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
}
private void createTarget(final String controllerId) {
targetManagement.createTarget(entityFactory.target().create().controllerId(controllerId)
targetManagement.create(entityFactory.target().create().controllerId(controllerId)
.address(IpUtil.createHttpUri("127.0.0.1").toString()));
}
@@ -311,7 +311,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId))
.andExpect(status().isOk());
assertThat(targetManagement.findTargetByControllerID(knownControllerId)).isNotPresent();
assertThat(targetManagement.getByControllerID(knownControllerId)).isNotPresent();
}
@Test
@@ -341,8 +341,8 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
final String body = new JSONObject().put("description", knownNewDescription).toString();
// prepare
targetManagement.createTarget(entityFactory.target().create().controllerId(knownControllerId)
.name(knownNameNotModiy).description("old description"));
targetManagement.create(entityFactory.target().create().controllerId(knownControllerId).name(knownNameNotModiy)
.description("old description"));
mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body)
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
@@ -350,7 +350,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
.andExpect(jsonPath("$.description", equalTo(knownNewDescription)))
.andExpect(jsonPath("$.name", equalTo(knownNameNotModiy)));
final Target findTargetByControllerID = targetManagement.findTargetByControllerID(knownControllerId).get();
final Target findTargetByControllerID = targetManagement.getByControllerID(knownControllerId).get();
assertThat(findTargetByControllerID.getDescription()).isEqualTo(knownNewDescription);
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModiy);
}
@@ -364,14 +364,14 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
final String body = new JSONObject().put("description", knownNewDescription).toString();
// prepare
targetManagement.createTarget(entityFactory.target().create().controllerId(knownControllerId)
.name(knownNameNotModiy).description("old description"));
targetManagement.create(entityFactory.target().create().controllerId(knownControllerId).name(knownNameNotModiy)
.description("old description"));
mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body)
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
final Target findTargetByControllerID = targetManagement.findTargetByControllerID(knownControllerId).get();
final Target findTargetByControllerID = targetManagement.getByControllerID(knownControllerId).get();
assertThat(findTargetByControllerID.getDescription()).isEqualTo("old description");
}
@@ -385,7 +385,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
// prepare
targetManagement
.createTarget(entityFactory.target().create().controllerId(knownControllerId).name(knownNameNotModiy));
.create(entityFactory.target().create().controllerId(knownControllerId).name(knownNameNotModiy));
mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body)
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
@@ -393,7 +393,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
.andExpect(jsonPath("$.securityToken", equalTo(knownNewToken)))
.andExpect(jsonPath("$.name", equalTo(knownNameNotModiy)));
final Target findTargetByControllerID = targetManagement.findTargetByControllerID(knownControllerId).get();
final Target findTargetByControllerID = targetManagement.getByControllerID(knownControllerId).get();
assertThat(findTargetByControllerID.getSecurityToken()).isEqualTo(knownNewToken);
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModiy);
}
@@ -407,8 +407,8 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
final String body = new JSONObject().put("address", knownNewAddress).toString();
// prepare
targetManagement.createTarget(entityFactory.target().create().controllerId(knownControllerId)
.name(knownNameNotModiy).address(knownNewAddress));
targetManagement.create(entityFactory.target().create().controllerId(knownControllerId).name(knownNameNotModiy)
.address(knownNewAddress));
mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body)
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
@@ -416,7 +416,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
.andExpect(jsonPath("$.address", equalTo(knownNewAddress)))
.andExpect(jsonPath("$.name", equalTo(knownNameNotModiy)));
final Target findTargetByControllerID = targetManagement.findTargetByControllerID(knownControllerId).get();
final Target findTargetByControllerID = targetManagement.getByControllerID(knownControllerId).get();
assertThat(findTargetByControllerID.getAddress().toString()).isEqualTo(knownNewAddress);
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModiy);
}
@@ -665,7 +665,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
assertThat(targetManagement.count()).isEqualTo(0);
// verify response json exception message
final ExceptionInfo exceptionInfo = ResourceUtility
@@ -684,7 +684,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
assertThat(targetManagement.count()).isEqualTo(0);
// verify response json exception message
final ExceptionInfo exceptionInfo = ResourceUtility
@@ -701,7 +701,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
assertThat(targetManagement.count()).isEqualTo(0);
// verify response json exception message
final ExceptionInfo exceptionInfo = ResourceUtility
@@ -720,7 +720,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
.content(JsonBuilder.targets(Arrays.asList(test1), true)).contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
assertThat(targetManagement.count()).isEqualTo(0);
// verify response json exception message
final ExceptionInfo exceptionInfo = ResourceUtility
@@ -775,18 +775,18 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
.isEqualTo("http://localhost/rest/v1/targets/id3");
assertThat(targetManagement.findTargetByControllerID("id1")).isNotNull();
assertThat(targetManagement.findTargetByControllerID("id1").get().getName()).isEqualTo("testname1");
assertThat(targetManagement.findTargetByControllerID("id1").get().getDescription()).isEqualTo("testid1");
assertThat(targetManagement.findTargetByControllerID("id1").get().getSecurityToken()).isEqualTo("token");
assertThat(targetManagement.findTargetByControllerID("id1").get().getAddress().toString())
assertThat(targetManagement.getByControllerID("id1")).isNotNull();
assertThat(targetManagement.getByControllerID("id1").get().getName()).isEqualTo("testname1");
assertThat(targetManagement.getByControllerID("id1").get().getDescription()).isEqualTo("testid1");
assertThat(targetManagement.getByControllerID("id1").get().getSecurityToken()).isEqualTo("token");
assertThat(targetManagement.getByControllerID("id1").get().getAddress().toString())
.isEqualTo("amqp://test123/foobar");
assertThat(targetManagement.findTargetByControllerID("id2")).isNotNull();
assertThat(targetManagement.findTargetByControllerID("id2").get().getName()).isEqualTo("testname2");
assertThat(targetManagement.findTargetByControllerID("id2").get().getDescription()).isEqualTo("testid2");
assertThat(targetManagement.findTargetByControllerID("id3")).isNotNull();
assertThat(targetManagement.findTargetByControllerID("id3").get().getName()).isEqualTo("testname3");
assertThat(targetManagement.findTargetByControllerID("id3").get().getDescription()).isEqualTo("testid3");
assertThat(targetManagement.getByControllerID("id2")).isNotNull();
assertThat(targetManagement.getByControllerID("id2").get().getName()).isEqualTo("testname2");
assertThat(targetManagement.getByControllerID("id2").get().getDescription()).isEqualTo("testid2");
assertThat(targetManagement.getByControllerID("id3")).isNotNull();
assertThat(targetManagement.getByControllerID("id3").get().getName()).isEqualTo("testname3");
assertThat(targetManagement.getByControllerID("id3").get().getDescription()).isEqualTo("testid3");
}
@Test
@@ -801,9 +801,9 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().is2xxSuccessful());
final Slice<Target> findTargetsAll = targetManagement.findTargetsAll(new PageRequest(0, 100));
final Slice<Target> findTargetsAll = targetManagement.findAll(new PageRequest(0, 100));
final Target target = findTargetsAll.getContent().get(0);
assertThat(targetManagement.countTargetsAll()).isEqualTo(1);
assertThat(targetManagement.count()).isEqualTo(1);
assertThat(target.getControllerId()).isEqualTo(knownControllerId);
assertThat(target.getName()).isEqualTo(knownName);
assertThat(target.getDescription()).isEqualTo(knownDescription);
@@ -829,7 +829,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
.andExpect(status().is(HttpStatus.CONFLICT.value())).andReturn();
// verify only one entry
assertThat(targetManagement.countTargetsAll()).isEqualTo(1);
assertThat(targetManagement.count()).isEqualTo(1);
// verify response json exception message
final ExceptionInfo exceptionInfo = ResourceUtility
@@ -1151,7 +1151,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
.andExpect(jsonPath("total", equalTo(1)));
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(set);
target = targetManagement.findTargetByControllerID(target.getControllerId()).get();
target = targetManagement.getByControllerID(target.getControllerId()).get();
// repeating DS assignment leads again to OK
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS")
@@ -1161,7 +1161,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
.andExpect(jsonPath("total", equalTo(1)));
// ...but does not change the target
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).get()).isEqualTo(target);
assertThat(targetManagement.getByControllerID(target.getControllerId()).get()).isEqualTo(target);
}
@Test
@@ -1181,7 +1181,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(set);
assertThat(deploymentManagement.getInstalledDistributionSet(target.getControllerId()).get()).isEqualTo(set);
target = targetManagement.findTargetByControllerID(target.getControllerId()).get();
target = targetManagement.getByControllerID(target.getControllerId()).get();
assertThat(target.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
// repeating DS assignment leads again to OK
@@ -1193,7 +1193,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
.andExpect(jsonPath("total", equalTo(1)));
// ...but does not change the target
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).get()).isEqualTo(target);
assertThat(targetManagement.getByControllerID(target.getControllerId()).get()).isEqualTo(target);
}
@Test
@@ -1359,7 +1359,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
}
private Target createSingleTarget(final String controllerId, final String name) {
targetManagement.createTarget(entityFactory.target().create().controllerId(controllerId).name(name)
targetManagement.create(entityFactory.target().create().controllerId(controllerId).name(name)
.description(TARGET_DESCRIPTION_TEST));
return controllerManagement.findOrRegisterTargetIfItDoesNotexist(controllerId, LOCALHOST);
}
@@ -1376,7 +1376,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
char character = 'a';
for (int index = 0; index < amount; index++) {
final String str = String.valueOf(character);
targetManagement.createTarget(entityFactory.target().create().controllerId(str).name(str).description(str));
targetManagement.create(entityFactory.target().create().controllerId(str).name(str).description(str));
controllerManagement.findOrRegisterTargetIfItDoesNotexist(str, LOCALHOST);
character++;
}
@@ -1396,6 +1396,6 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
// verify active action
final Slice<Action> actionsByTarget = deploymentManagement.findActionsByTarget(tA.getControllerId(), PAGE);
assertThat(actionsByTarget.getContent()).hasSize(1);
return targetManagement.findTargetByControllerID(tA.getControllerId()).get();
return targetManagement.getByControllerID(tA.getControllerId()).get();
}
}

View File

@@ -113,11 +113,11 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
final Tag createdOne = tagManagement.findAllTargetTags("name==thetest1", PAGE).getContent().get(0);
final Tag createdOne = targetTagManagement.findByRsql(PAGE, "name==thetest1").getContent().get(0);
assertThat(createdOne.getName()).isEqualTo(tagOne.getName());
assertThat(createdOne.getDescription()).isEqualTo(tagOne.getDescription());
assertThat(createdOne.getColour()).isEqualTo(tagOne.getColour());
final Tag createdTwo = tagManagement.findAllTargetTags("name==thetest2", PAGE).getContent().get(0);
final Tag createdTwo = targetTagManagement.findByRsql(PAGE, "name==thetest2").getContent().get(0);
assertThat(createdTwo.getName()).isEqualTo(tagTwo.getName());
assertThat(createdTwo.getDescription()).isEqualTo(tagTwo.getDescription());
assertThat(createdTwo.getColour()).isEqualTo(tagTwo.getColour());
@@ -143,7 +143,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
final Tag updated = tagManagement.findAllTargetTags("name==updatedName", PAGE).getContent().get(0);
final Tag updated = targetTagManagement.findByRsql(PAGE, "name==updatedName").getContent().get(0);
assertThat(updated.getName()).isEqualTo(update.getName());
assertThat(updated.getDescription()).isEqualTo(update.getDescription());
assertThat(updated.getColour()).isEqualTo(update.getColour());
@@ -162,7 +162,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + original.getId()))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(tagManagement.findTargetTagById(original.getId())).isNotPresent();
assertThat(targetTagManagement.get(original.getId())).isNotPresent();
}
@Test
@@ -237,7 +237,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
ResultActions result = toggle(tag, targets);
List<Target> updated = targetManagement.findTargetsByTag(PAGE, tag.getId()).getContent();
List<Target> updated = targetManagement.findByTag(PAGE, tag.getId()).getContent();
assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList()))
.containsAll(targets.stream().map(Target::getControllerId).collect(Collectors.toList()));
@@ -247,12 +247,12 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
result = toggle(tag, targets);
updated = targetManagement.findTargetsAll(PAGE).getContent();
updated = targetManagement.findAll(PAGE).getContent();
result.andExpect(applyTargetEntityMatcherOnArrayResult(updated.get(0), "unassignedTargets"))
.andExpect(applyTargetEntityMatcherOnArrayResult(updated.get(1), "unassignedTargets"));
assertThat(targetManagement.findTargetsByTag(PAGE, tag.getId())).isEmpty();
assertThat(targetManagement.findByTag(PAGE, tag.getId())).isEmpty();
}
private ResultActions toggle(final TargetTag tag, final List<Target> targets) throws Exception {
@@ -283,7 +283,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
final List<Target> updated = targetManagement.findTargetsByTag(PAGE, tag.getId()).getContent();
final List<Target> updated = targetManagement.findByTag(PAGE, tag.getId()).getContent();
assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList()))
.containsAll(targets.stream().map(Target::getControllerId).collect(Collectors.toList()));
@@ -309,7 +309,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/"
+ unassigned.getControllerId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
final List<Target> updated = targetManagement.findTargetsByTag(PAGE, tag.getId()).getContent();
final List<Target> updated = targetManagement.findByTag(PAGE, tag.getId()).getContent();
assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList()))
.containsOnly(assigned.getControllerId());