Split repository API for module and DS management. Refactor utility usage (#524)

* Split DS management and reduce util usage.

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

* Split sw module and type management.

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

* Sonar issues.

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

* Make sonar listen to the exception!

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

* Register both beans.

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

* Split JPA implementations.

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

* Revert user details change.

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

* Fix compilation errors.

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

* Fix bean queries. Fix image path.

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

* Document preferred utility usage.

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

* Fix exmaples and revert unintended checkin.

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

* Code cleanup.

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

* Typos, readibility.

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

* Remove unused reference.

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

* Rollouts cache delete aware.

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

* Fix rolloutgroup delete event.

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

* Add new RolloutGroupDeletedEvent event

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-06-01 06:28:59 +02:00
committed by GitHub
parent 0ab995d1a4
commit 67a4677ef6
203 changed files with 2738 additions and 2320 deletions

View File

@@ -39,6 +39,10 @@
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>

View File

@@ -29,7 +29,7 @@ import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
@@ -63,7 +63,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
private static final Logger LOG = LoggerFactory.getLogger(MgmtDistributionSetResource.class);
@Autowired
private SoftwareManagement softwareManagement;
private SoftwareModuleManagement softwareModuleManagement;
@Autowired
private TargetManagement targetManagement;
@@ -346,7 +346,7 @@ 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 = softwareManagement.findSoftwareModuleByAssignedTo(pageable,
final Page<SoftwareModule> softwaremodules = softwareModuleManagement.findSoftwareModuleByAssignedTo(pageable,
distributionSetId);
return new ResponseEntity<>(new PagedList<>(MgmtSoftwareModuleMapper.toResponse(softwaremodules.getContent()),
softwaremodules.getTotalElements()), HttpStatus.OK);

View File

@@ -8,6 +8,7 @@
*/
package org.eclipse.hawkbit.mgmt.rest.resource;
import java.util.Arrays;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.MgmtId;
@@ -18,10 +19,10 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionS
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.SoftwareModuleTypeNotInDistributionSetTypeException;
import org.eclipse.hawkbit.repository.model.Artifact;
@@ -40,8 +41,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.google.common.collect.Lists;
/**
* REST Resource handling for {@link SoftwareModule} and related
* {@link Artifact} CRUD operations.
@@ -50,10 +49,10 @@ import com.google.common.collect.Lists;
public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeRestApi {
@Autowired
private SoftwareManagement softwareManagement;
private SoftwareModuleTypeManagement softwareModuleTypeManagement;
@Autowired
private DistributionSetManagement distributionSetManagement;
private DistributionSetTypeManagement distributionSetTypeManagement;
@Autowired
private EntityFactory entityFactory;
@@ -73,11 +72,11 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
final Slice<DistributionSetType> findModuleTypessAll;
Long countModulesAll;
if (rsqlParam != null) {
findModuleTypessAll = distributionSetManagement.findDistributionSetTypesAll(rsqlParam, pageable);
findModuleTypessAll = distributionSetTypeManagement.findDistributionSetTypesAll(rsqlParam, pageable);
countModulesAll = ((Page<DistributionSetType>) findModuleTypessAll).getTotalElements();
} else {
findModuleTypessAll = distributionSetManagement.findDistributionSetTypesAll(pageable);
countModulesAll = distributionSetManagement.countDistributionSetTypesAll();
findModuleTypessAll = distributionSetTypeManagement.findDistributionSetTypesAll(pageable);
countModulesAll = distributionSetTypeManagement.countDistributionSetTypesAll();
}
final List<MgmtDistributionSetType> rest = MgmtDistributionSetTypeMapper
@@ -96,7 +95,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
@Override
public ResponseEntity<Void> deleteDistributionSetType(
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId) {
distributionSetManagement.deleteDistributionSetType(distributionSetTypeId);
distributionSetTypeManagement.deleteDistributionSetType(distributionSetTypeId);
return ResponseEntity.ok().build();
}
@@ -107,7 +106,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
@RequestBody final MgmtDistributionSetTypeRequestBodyPut restDistributionSetType) {
return ResponseEntity.ok(MgmtDistributionSetTypeMapper
.toResponse(distributionSetManagement.updateDistributionSetType(entityFactory.distributionSetType()
.toResponse(distributionSetTypeManagement.updateDistributionSetType(entityFactory.distributionSetType()
.update(distributionSetTypeId).description(restDistributionSetType.getDescription())
.colour(restDistributionSetType.getColour()))));
}
@@ -116,15 +115,16 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
public ResponseEntity<List<MgmtDistributionSetType>> createDistributionSetTypes(
@RequestBody final List<MgmtDistributionSetTypeRequestBodyPost> distributionSetTypes) {
final List<DistributionSetType> createdSoftwareModules = distributionSetManagement.createDistributionSetTypes(
MgmtDistributionSetTypeMapper.smFromRequest(entityFactory, distributionSetTypes));
final List<DistributionSetType> createdSoftwareModules = distributionSetTypeManagement
.createDistributionSetTypes(
MgmtDistributionSetTypeMapper.smFromRequest(entityFactory, distributionSetTypes));
return ResponseEntity.status(HttpStatus.CREATED)
.body(MgmtDistributionSetTypeMapper.toTypesResponse(createdSoftwareModules));
}
private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final Long distributionSetTypeId) {
return distributionSetManagement.findDistributionSetTypeById(distributionSetTypeId)
return distributionSetTypeManagement.findDistributionSetTypeById(distributionSetTypeId)
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distributionSetTypeId));
}
@@ -178,7 +178,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
public ResponseEntity<Void> removeMandatoryModule(
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId,
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) {
distributionSetManagement.unassignSoftwareModuleType(distributionSetTypeId, softwareModuleTypeId);
distributionSetTypeManagement.unassignSoftwareModuleType(distributionSetTypeId, softwareModuleTypeId);
return ResponseEntity.ok().build();
}
@@ -195,8 +195,8 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
public ResponseEntity<Void> addMandatoryModule(
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @RequestBody final MgmtId smtId) {
distributionSetManagement.assignMandatorySoftwareModuleTypes(distributionSetTypeId,
Lists.newArrayList(smtId.getId()));
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(distributionSetTypeId,
Arrays.asList(smtId.getId()));
return ResponseEntity.ok().build();
}
@@ -205,15 +205,15 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
public ResponseEntity<Void> addOptionalModule(
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @RequestBody final MgmtId smtId) {
distributionSetManagement.assignOptionalSoftwareModuleTypes(distributionSetTypeId,
Lists.newArrayList(smtId.getId()));
distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(distributionSetTypeId,
Arrays.asList(smtId.getId()));
return ResponseEntity.ok().build();
}
private SoftwareModuleType findSoftwareModuleTypeWithExceptionIfNotFound(final Long softwareModuleTypeId) {
return softwareManagement.findSoftwareModuleTypeById(softwareModuleTypeId)
return softwareModuleTypeManagement.findSoftwareModuleTypeById(softwareModuleTypeId)
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, softwareModuleTypeId));
}
}

View File

@@ -15,7 +15,7 @@ import javax.servlet.http.HttpServletRequest;
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDownloadArtifactRestApi;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
import org.eclipse.hawkbit.repository.exception.ArtifactBinaryNotFoundException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.Artifact;
@@ -39,7 +39,7 @@ import org.springframework.web.context.WebApplicationContext;
public class MgmtDownloadArtifactResource implements MgmtDownloadArtifactRestApi {
@Autowired
private SoftwareManagement softwareManagement;
private SoftwareModuleManagement softwareModuleManagement;
@Autowired
private ArtifactManagement artifactManagement;
@@ -61,7 +61,7 @@ public class MgmtDownloadArtifactResource implements MgmtDownloadArtifactRestApi
@ResponseBody
public ResponseEntity<InputStream> downloadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("artifactId") final Long artifactId) {
final SoftwareModule module = softwareManagement.findSoftwareModuleById(softwareModuleId)
final SoftwareModule module = softwareModuleManagement.findSoftwareModuleById(softwareModuleId)
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
final Artifact artifact = module.getArtifact(artifactId)
.orElseThrow(() -> new EntityNotFoundException(Artifact.class, artifactId));

View File

@@ -18,9 +18,6 @@ import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
/**
* A mapper which maps repository model to RESTful model representation and
* back.
*
*
*
*
*/
final class MgmtRestModelMapper {

View File

@@ -16,7 +16,6 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.hawkbit.mgmt.json.model.MgmtMetadata;
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact;
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifactHash;
@@ -116,8 +115,8 @@ public final class MgmtSoftwareModuleMapper {
response.add(linkTo(methodOn(MgmtSoftwareModuleResource.class).getMetadata(response.getModuleId(),
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE,
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null, null))
.withRel("metadata").expand(ArrayUtils.toArray()));
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null, null)).withRel("metadata")
.expand());
return response;
}

View File

@@ -23,7 +23,7 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
@@ -57,7 +57,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
private ArtifactManagement artifactManagement;
@Autowired
private SoftwareManagement softwareManagement;
private SoftwareModuleManagement softwareModuleManagement;
@Autowired
private EntityFactory entityFactory;
@@ -138,11 +138,11 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
final Slice<SoftwareModule> findModulesAll;
Long countModulesAll;
if (rsqlParam != null) {
findModulesAll = softwareManagement.findSoftwareModulesByPredicate(rsqlParam, pageable);
findModulesAll = softwareModuleManagement.findSoftwareModulesByPredicate(rsqlParam, pageable);
countModulesAll = ((Page<SoftwareModule>) findModulesAll).getTotalElements();
} else {
findModulesAll = softwareManagement.findSoftwareModulesAll(pageable);
countModulesAll = softwareManagement.countSoftwareModulesAll();
findModulesAll = softwareModuleManagement.findSoftwareModulesAll(pageable);
countModulesAll = softwareModuleManagement.countSoftwareModulesAll();
}
final List<MgmtSoftwareModule> rest = MgmtSoftwareModuleMapper.toResponse(findModulesAll.getContent());
@@ -162,7 +162,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
@RequestBody final List<MgmtSoftwareModuleRequestBodyPost> softwareModules) {
LOG.debug("creating {} softwareModules", softwareModules.size());
final Collection<SoftwareModule> createdSoftwareModules = softwareManagement
final Collection<SoftwareModule> createdSoftwareModules = softwareModuleManagement
.createSoftwareModule(MgmtSoftwareModuleMapper.smFromRequest(entityFactory, softwareModules));
LOG.debug("{} softwareModules created, return status {}", softwareModules.size(), HttpStatus.CREATED);
@@ -176,7 +176,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
@RequestBody final MgmtSoftwareModuleRequestBodyPut restSoftwareModule) {
return ResponseEntity.ok(MgmtSoftwareModuleMapper.toResponse(
softwareManagement.updateSoftwareModule(entityFactory.softwareModule().update(softwareModuleId)
softwareModuleManagement.updateSoftwareModule(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);
softwareManagement.deleteSoftwareModule(module.getId());
softwareModuleManagement.deleteSoftwareModule(module.getId());
return ResponseEntity.ok().build();
}
@@ -208,10 +208,10 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
final Page<SoftwareModuleMetadata> metaDataPage;
if (rsqlParam != null) {
metaDataPage = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, rsqlParam,
metaDataPage = softwareModuleManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, rsqlParam,
pageable);
} else {
metaDataPage = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, pageable);
metaDataPage = softwareModuleManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, pageable);
}
return ResponseEntity
@@ -223,7 +223,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
public ResponseEntity<MgmtMetadata> getMetadataValue(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("metadataKey") final String metadataKey) {
final SoftwareModuleMetadata findOne = softwareManagement
final SoftwareModuleMetadata findOne = softwareModuleManagement
.findSoftwareModuleMetadata(softwareModuleId, metadataKey).orElseThrow(
() -> new EntityNotFoundException(SoftwareModuleMetadata.class, softwareModuleId, metadataKey));
@@ -233,7 +233,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 = softwareManagement.updateSoftwareModuleMetadata(softwareModuleId,
final SoftwareModuleMetadata updated = softwareModuleManagement.updateSoftwareModuleMetadata(softwareModuleId,
entityFactory.generateMetadata(metadataKey, metadata.getValue()));
return ResponseEntity.ok(MgmtSoftwareModuleMapper.toResponseSwMetadata(updated));
@@ -242,7 +242,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
@Override
public ResponseEntity<Void> deleteMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("metadataKey") final String metadataKey) {
softwareManagement.deleteSoftwareModuleMetadata(softwareModuleId, metadataKey);
softwareModuleManagement.deleteSoftwareModuleMetadata(softwareModuleId, metadataKey);
return ResponseEntity.ok().build();
}
@@ -252,7 +252,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
@PathVariable("softwareModuleId") final Long softwareModuleId,
@RequestBody final List<MgmtMetadata> metadataRest) {
final List<SoftwareModuleMetadata> created = softwareManagement.createSoftwareModuleMetadata(softwareModuleId,
final List<SoftwareModuleMetadata> created = softwareModuleManagement.createSoftwareModuleMetadata(softwareModuleId,
MgmtSoftwareModuleMapper.fromRequestSwMetadata(entityFactory, metadataRest));
return ResponseEntity.status(HttpStatus.CREATED).body(MgmtSoftwareModuleMapper.toResponseSwMetadata(created));
@@ -261,7 +261,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
private SoftwareModule findSoftwareModuleWithExceptionIfNotFound(final Long softwareModuleId,
final Long artifactId) {
final SoftwareModule module = softwareManagement.findSoftwareModuleById(softwareModuleId)
final SoftwareModule module = softwareModuleManagement.findSoftwareModuleById(softwareModuleId)
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
if (artifactId != null && !module.getArtifact(artifactId).isPresent()) {

View File

@@ -18,7 +18,7 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
@@ -43,7 +43,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRestApi {
@Autowired
private SoftwareManagement softwareManagement;
private SoftwareModuleTypeManagement softwareModuleTypeManagement;
@Autowired
private EntityFactory entityFactory;
@@ -64,11 +64,11 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
final Slice<SoftwareModuleType> findModuleTypessAll;
Long countModulesAll;
if (rsqlParam != null) {
findModuleTypessAll = softwareManagement.findSoftwareModuleTypesAll(rsqlParam, pageable);
findModuleTypessAll = softwareModuleTypeManagement.findSoftwareModuleTypesAll(rsqlParam, pageable);
countModulesAll = ((Page<SoftwareModuleType>) findModuleTypessAll).getTotalElements();
} else {
findModuleTypessAll = softwareManagement.findSoftwareModuleTypesAll(pageable);
countModulesAll = softwareManagement.countSoftwareModuleTypesAll();
findModuleTypessAll = softwareModuleTypeManagement.findSoftwareModuleTypesAll(pageable);
countModulesAll = softwareModuleTypeManagement.countSoftwareModuleTypesAll();
}
final List<MgmtSoftwareModuleType> rest = MgmtSoftwareModuleTypeMapper
@@ -87,7 +87,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
@Override
public ResponseEntity<Void> deleteSoftwareModuleType(
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) {
softwareManagement.deleteSoftwareModuleType(softwareModuleTypeId);
softwareModuleTypeManagement.deleteSoftwareModuleType(softwareModuleTypeId);
return new ResponseEntity<>(HttpStatus.OK);
}
@@ -96,7 +96,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId,
@RequestBody final MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType) {
final SoftwareModuleType updatedSoftwareModuleType = softwareManagement.updateSoftwareModuleType(entityFactory
final SoftwareModuleType updatedSoftwareModuleType = softwareModuleTypeManagement.updateSoftwareModuleType(entityFactory
.softwareModuleType().update(softwareModuleTypeId).description(restSoftwareModuleType.getDescription())
.colour(restSoftwareModuleType.getColour()));
@@ -107,7 +107,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
public ResponseEntity<List<MgmtSoftwareModuleType>> createSoftwareModuleTypes(
@RequestBody final List<MgmtSoftwareModuleTypeRequestBodyPost> softwareModuleTypes) {
final List<SoftwareModuleType> createdSoftwareModules = softwareManagement.createSoftwareModuleType(
final List<SoftwareModuleType> createdSoftwareModules = softwareModuleTypeManagement.createSoftwareModuleType(
MgmtSoftwareModuleTypeMapper.smFromRequest(entityFactory, softwareModuleTypes));
return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toTypesResponse(createdSoftwareModules),
@@ -115,7 +115,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
}
private SoftwareModuleType findSoftwareModuleTypeWithExceptionIfNotFound(final Long softwareModuleTypeId) {
return softwareManagement.findSoftwareModuleTypeById(softwareModuleTypeId)
return softwareModuleTypeManagement.findSoftwareModuleTypeById(softwareModuleTypeId)
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, softwareModuleTypeId));
}

View File

@@ -19,7 +19,6 @@ import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.hawkbit.mgmt.json.model.MgmtPollStatus;
import org.eclipse.hawkbit.mgmt.json.model.action.MgmtAction;
import org.eclipse.hawkbit.mgmt.json.model.action.MgmtActionStatus;
@@ -67,7 +66,7 @@ public final class MgmtTargetMapper {
response.add(linkTo(methodOn(MgmtTargetRestApi.class).getActionHistory(response.getControllerId(), 0,
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE,
ActionFields.ID.getFieldName() + ":" + SortDirection.DESC, null))
.withRel(MgmtRestConstants.TARGET_V1_ACTIONS).expand(ArrayUtils.toArray()));
.withRel(MgmtRestConstants.TARGET_V1_ACTIONS).expand());
}
static void addPollStatus(final Target target, final MgmtTarget targetRest) {

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.mgmt.rest.resource;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -51,8 +52,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.google.common.collect.Lists;
/**
* REST Resource handling target CRUD operations.
*/
@@ -281,7 +280,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
final ActionType type = (dsId.getType() != null) ? MgmtRestModelMapper.convertActionType(dsId.getType())
: ActionType.FORCED;
this.deploymentManagement.assignDistributionSet(dsId.getId(), type, dsId.getForcetime(),
Lists.newArrayList(controllerId));
Arrays.asList(controllerId));
return new ResponseEntity<>(HttpStatus.OK);
}

View File

@@ -21,6 +21,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -45,7 +46,6 @@ import org.junit.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.jayway.jsonpath.JsonPath;
@@ -167,7 +167,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(jsonPath("$.size", equalTo(disSet.getModules().size())));
// create Software Modules
final List<Long> smIDs = Lists.newArrayList(testdataFactory.createSoftwareModuleOs().getId(),
final List<Long> smIDs = Arrays.asList(testdataFactory.createSoftwareModuleOs().getId(),
testdataFactory.createSoftwareModuleApp().getId());
// post assignment
@@ -270,7 +270,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
// assign knownTargetId to distribution set
assignDistributionSet(createdDs.getId(), knownTargetId);
// make it in install state
testdataFactory.sendUpdateActionStatusToTargets(Lists.newArrayList(createTarget), Status.FINISHED,
testdataFactory.sendUpdateActionStatusToTargets(Arrays.asList(createTarget), Status.FINISHED,
Collections.singletonList("some message"));
mvc.perform(get(
@@ -414,8 +414,7 @@ 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.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
DistributionSet set = testdataFactory.createDistributionSet("one");
set = distributionSetManagement.updateDistributionSet(entityFactory.distributionSet().update(set.getId())
@@ -424,8 +423,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
// load also lazy stuff
set = distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).get();
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true))
.hasSize(1);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(1);
// perform request
mvc.perform(get("/rest/v1/distributionsets").accept(MediaType.APPLICATION_JSON))
@@ -488,28 +486,29 @@ 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.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
final SoftwareModule ah = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_APP);
final SoftwareModule jvm = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_RT);
final SoftwareModule os = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_OS);
DistributionSet one = testdataFactory.generateDistributionSet("one", "one", standardDsType,
Lists.newArrayList(os, jvm, ah));
Arrays.asList(os, jvm, ah));
DistributionSet two = testdataFactory.generateDistributionSet("two", "two", standardDsType,
Lists.newArrayList(os, jvm, ah));
Arrays.asList(os, jvm, ah));
DistributionSet three = testdataFactory.generateDistributionSet("three", "three", standardDsType,
Lists.newArrayList(os, jvm, ah), true);
Arrays.asList(os, jvm, ah), true);
final long current = System.currentTimeMillis();
final MvcResult mvcResult = executeMgmtTargetPost(one, two, three);
one = distributionSetManagement.findDistributionSetByIdWithDetails(distributionSetManagement
.findDistributionSetsAll("name==one", PAGE, false).getContent().get(0).getId()).get();
two = distributionSetManagement.findDistributionSetByIdWithDetails(distributionSetManagement
.findDistributionSetsAll("name==two", PAGE, false).getContent().get(0).getId()).get();
one = distributionSetManagement.findDistributionSetByIdWithDetails(
distributionSetManagement.findDistributionSetsAll("name==one", PAGE, false).getContent().get(0).getId())
.get();
two = distributionSetManagement.findDistributionSetByIdWithDetails(
distributionSetManagement.findDistributionSetsAll("name==two", PAGE, false).getContent().get(0).getId())
.get();
three = distributionSetManagement.findDistributionSetByIdWithDetails(distributionSetManagement
.findDistributionSetsAll("name==three", PAGE, false).getContent().get(0).getId()).get();
@@ -542,8 +541,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
.isEqualTo(String.valueOf(three.getId()));
// check in database
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true))
.hasSize(3);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(3);
assertThat(one.isRequiredMigrationStep()).isEqualTo(false);
assertThat(two.isRequiredMigrationStep()).isEqualTo(false);
assertThat(three.isRequiredMigrationStep()).isEqualTo(true);
@@ -558,7 +556,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
final DistributionSet three) throws Exception {
return mvc
.perform(post("/rest/v1/distributionsets/")
.content(JsonBuilder.distributionSets(Lists.newArrayList(one, two, three)))
.content(JsonBuilder.distributionSets(Arrays.asList(one, two, three)))
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
@@ -607,21 +605,18 @@ 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.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
final DistributionSet set = testdataFactory.createDistributionSet("one");
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true))
.hasSize(1);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(1);
// perform request
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
// check repository content
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true))
.isEmpty();
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).isEmpty();
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(0);
}
@@ -636,25 +631,21 @@ 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.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, 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.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(1);
// perform request
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
// check repository content
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true))
.hasSize(0);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, true, true))
.hasSize(1);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, true, true)).hasSize(1);
}
@Test
@@ -662,8 +653,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
public void updateDistributionSet() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true))
.hasSize(0);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
final DistributionSet set = testdataFactory.createDistributionSet("one");
@@ -686,12 +676,11 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
public void updateRequiredMigrationStepFailsIfDistributionSetisInUse() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true))
.hasSize(0);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
final DistributionSet set = testdataFactory.createDistributionSet("one");
deploymentManagement.assignDistributionSet(set.getId(),
Lists.newArrayList(new TargetWithActionType(testdataFactory.createTarget().getControllerId())));
Arrays.asList(new TargetWithActionType(testdataFactory.createTarget().getControllerId())));
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(1);
@@ -732,16 +721,14 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
.andExpect(status().isBadRequest());
final DistributionSet missingName = entityFactory.distributionSet().create().build();
mvc.perform(
post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(Lists.newArrayList(missingName)))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest());
mvc.perform(post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(Arrays.asList(missingName)))
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
final DistributionSet toLongName = testdataFactory.generateDistributionSet(RandomStringUtils.randomAscii(80));
mvc.perform(
post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(Lists.newArrayList(toLongName)))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest());
mvc.perform(post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(Arrays.asList(toLongName)))
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
// unsupported media type
mvc.perform(post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(sets))
@@ -929,7 +916,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
final Set<DistributionSet> createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1);
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
// prepare targets
final Collection<String> knownTargetIds = Lists.newArrayList("1", "2", "3", "4", "5");
final Collection<String> knownTargetIds = Arrays.asList("1", "2", "3", "4", "5");
knownTargetIds.forEach(controllerId -> targetManagement
.createTarget(entityFactory.target().create().controllerId(controllerId)));

View File

@@ -22,6 +22,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -37,7 +38,6 @@ import org.junit.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import com.google.common.collect.Lists;
import com.jayway.jsonpath.JsonPath;
import ru.yandex.qatools.allure.annotations.Description;
@@ -58,10 +58,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes GET requests.")
public void getDistributionSetTypes() throws Exception {
DistributionSetType testType = distributionSetManagement
DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
.name("TestName123").description("Desc123").colour("col12"));
testType = distributionSetManagement.updateDistributionSetType(
testType = distributionSetTypeManagement.updateDistributionSetType(
entityFactory.distributionSetType().update(testType.getId()).description("Desc1234"));
// 4 types overall (2 hawkbit tenant default, 1 test default and 1
@@ -99,10 +99,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes GET requests with sorting by KEY.")
public void getDistributionSetTypesSortedByKey() throws Exception {
DistributionSetType testType = distributionSetManagement
DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("zzzzz").name("TestName123")
.description("Desc123").colour("col12"));
testType = distributionSetManagement.updateDistributionSetType(
testType = distributionSetTypeManagement.updateDistributionSetType(
entityFactory.distributionSetType().update(testType.getId()).description("Desc1234"));
// descending
@@ -148,9 +148,12 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@Step
private void verifyCreatedDistributionSetTypes(final MvcResult mvcResult) throws UnsupportedEncodingException {
final DistributionSetType created1 = distributionSetManagement.findDistributionSetTypeByKey("testKey1").get();
final DistributionSetType created2 = distributionSetManagement.findDistributionSetTypeByKey("testKey2").get();
final DistributionSetType created3 = distributionSetManagement.findDistributionSetTypeByKey("testKey3").get();
final DistributionSetType created1 = distributionSetTypeManagement.findDistributionSetTypeByKey("testKey1")
.get();
final DistributionSetType created2 = distributionSetTypeManagement.findDistributionSetTypeByKey("testKey2")
.get();
final DistributionSetType created3 = distributionSetTypeManagement.findDistributionSetTypeByKey("testKey3")
.get();
assertThat(created1.getMandatoryModuleTypes()).containsOnly(osType);
assertThat(created1.getOptionalModuleTypes()).containsOnly(runtimeType);
@@ -187,7 +190,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
.toString()).isEqualTo(
"http://localhost/rest/v1/distributionsettypes/" + created3.getId() + "/optionalmoduletypes");
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(6);
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(6);
}
@Step
@@ -214,24 +217,24 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@Step
private List<DistributionSetType> createTestDistributionSetTestTypes() {
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES);
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES);
return Lists.newArrayList(
return Arrays.asList(
entityFactory.distributionSetType().create().key("testKey1").name("TestName1").description("Desc1")
.colour("col").mandatory(Lists.newArrayList(osType.getId()))
.optional(Lists.newArrayList(runtimeType.getId())).build(),
.colour("col").mandatory(Arrays.asList(osType.getId()))
.optional(Arrays.asList(runtimeType.getId())).build(),
entityFactory.distributionSetType().create().key("testKey2").name("TestName2").description("Desc2")
.colour("col")
.optional(Lists.newArrayList(runtimeType.getId(), osType.getId(), appType.getId())).build(),
.colour("col").optional(Arrays.asList(runtimeType.getId(), osType.getId(), appType.getId()))
.build(),
entityFactory.distributionSetType().create().key("testKey3").name("TestName3").description("Desc3")
.colour("col").mandatory(Lists.newArrayList(runtimeType.getId(), osType.getId())).build());
.colour("col").mandatory(Arrays.asList(runtimeType.getId(), osType.getId())).build());
}
@Test
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes POST requests.")
public void addMandatoryModuleToDistributionSetType() throws Exception {
DistributionSetType testType = distributionSetManagement
DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
.name("TestName123").description("Desc123").colour("col12"));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
@@ -240,7 +243,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
.content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
testType = distributionSetManagement.findDistributionSetTypeById(testType.getId()).get();
testType = distributionSetTypeManagement.findDistributionSetTypeById(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2);
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
@@ -251,7 +254,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes POST requests.")
public void addOptionalModuleToDistributionSetType() throws Exception {
DistributionSetType testType = distributionSetManagement
DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
.name("TestName123").description("Desc123").colour("col12"));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
@@ -260,7 +263,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
.content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
testType = distributionSetManagement.findDistributionSetTypeById(testType.getId()).get();
testType = distributionSetTypeManagement.findDistributionSetTypeById(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2);
assertThat(testType.getOptionalModuleTypes()).containsExactly(osType);
@@ -315,9 +318,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
}
private DistributionSetType generateTestType() {
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(entityFactory
final DistributionSetType testType = distributionSetTypeManagement.createDistributionSetType(entityFactory
.distributionSetType().create().key("test123").name("TestName123").description("Desc123").colour("col")
.mandatory(Lists.newArrayList(osType.getId())).optional(Lists.newArrayList(appType.getId())));
.mandatory(Arrays.asList(osType.getId())).optional(Arrays.asList(appType.getId())));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
@@ -351,7 +354,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
osType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
testType = distributionSetManagement.findDistributionSetTypeById(testType.getId()).get();
testType = distributionSetTypeManagement.findDistributionSetTypeById(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2);
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
@@ -368,7 +371,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
appType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
testType = distributionSetManagement.findDistributionSetTypeById(testType.getId()).get();
testType = distributionSetTypeManagement.findDistributionSetTypeById(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2);
assertThat(testType.getOptionalModuleTypes()).isEmpty();
@@ -380,10 +383,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID} GET requests.")
public void getDistributionSetType() throws Exception {
DistributionSetType testType = distributionSetManagement
DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
.name("TestName123").description("Desc123").colour("col12"));
testType = distributionSetManagement.updateDistributionSetType(
testType = distributionSetTypeManagement.updateDistributionSetType(
entityFactory.distributionSetType().update(testType.getId()).description("Desc1234"));
mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId()).accept(MediaType.APPLICATION_JSON))
@@ -400,16 +403,16 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/DistributionSetTypes/{ID} DELETE requests (hard delete scenario).")
public void deleteDistributionSetTypeUnused() throws Exception {
final DistributionSetType testType = distributionSetManagement
final DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
.name("TestName123").description("Desc123").colour("col12"));
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES + 1);
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES + 1);
mvc.perform(delete("/rest/v1/distributionsettypes/{dsId}", testType.getId()))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES);
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES);
}
@Test
@@ -423,27 +426,27 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/DistributionSetTypes/{ID} DELETE requests (soft delete scenario).")
public void deleteDistributionSetTypeUsed() throws Exception {
final DistributionSetType testType = distributionSetManagement
final DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
.name("TestName123").description("Desc123").colour("col12"));
distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create().name("sdfsd")
.description("dsfsdf").version("1").type(testType));
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES + 1);
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES + 1);
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(1);
mvc.perform(delete("/rest/v1/distributionsettypes/{smId}", testType.getId()))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(1);
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES);
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).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 = distributionSetManagement
final DistributionSetType testType = distributionSetTypeManagement
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
.name("TestName123").description("Desc123").colour("col"));
@@ -507,7 +510,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
// .createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
// .name("TestName123").description("Desc123").colour("col"));
final SoftwareModuleType testSmType = softwareManagement.createSoftwareModuleType(
final SoftwareModuleType testSmType = softwareModuleTypeManagement.createSoftwareModuleType(
entityFactory.softwareModuleType().create().key("test123").name("TestName123"));
// DST does not exist
@@ -549,11 +552,11 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
// Modules types at creation time invalid
final DistributionSetType testNewType = entityFactory.distributionSetType().create().key("test123")
.name("TestName123").description("Desc123").colour("col").mandatory(Lists.newArrayList(osType.getId()))
.name("TestName123").description("Desc123").colour("col").mandatory(Arrays.asList(osType.getId()))
.optional(Collections.emptyList()).build();
mvc.perform(post("/rest/v1/distributionsettypes")
.content(JsonBuilder.distributionSetTypes(Lists.newArrayList(testNewType)))
.content(JsonBuilder.distributionSetTypes(Arrays.asList(testNewType)))
.contentType(MediaType.APPLICATION_OCTET_STREAM)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isUnsupportedMediaType());
@@ -574,7 +577,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
final DistributionSetType toLongName = entityFactory.distributionSetType().create().key("test123")
.name(RandomStringUtils.randomAscii(80)).build();
mvc.perform(post("/rest/v1/distributionsettypes")
.content(JsonBuilder.distributionSetTypes(Lists.newArrayList(toLongName)))
.content(JsonBuilder.distributionSetTypes(Arrays.asList(toLongName)))
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
@@ -595,9 +598,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
@Test
@Description("Search erquest of software module types.")
public void searchDistributionSetTypeRsql() throws Exception {
distributionSetManagement.createDistributionSetType(
distributionSetTypeManagement.createDistributionSetType(
entityFactory.distributionSetType().create().key("test123").name("TestName123"));
distributionSetManagement.createDistributionSetType(
distributionSetTypeManagement.createDistributionSetType(
entityFactory.distributionSetType().create().key("test1234").name("TestName1234"));
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
@@ -612,7 +615,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
char character = 'a';
for (int index = 0; index < amount; index++) {
final String str = String.valueOf(character);
softwareManagement.createSoftwareModule(
softwareModuleManagement.createSoftwareModule(
entityFactory.softwareModule().create().name(str).description(str).vendor(str).version(str));
character++;
}

View File

@@ -23,6 +23,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
@@ -47,8 +48,6 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.http.MediaType;
import com.google.common.collect.Lists;
import ru.yandex.qatools.allure.annotations.Description;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Step;
@@ -144,7 +143,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
final float percentTargetsInGroup1 = 20;
final float percentTargetsInGroup2 = 100;
final List<RolloutGroup> rolloutGroups = Lists.newArrayList(
final List<RolloutGroup> rolloutGroups = Arrays.asList(
entityFactory.rolloutGroup().create().name("Group1").description("Group1desc")
.targetPercentage(percentTargetsInGroup1).build(),
entityFactory.rolloutGroup().create().name("Group2").description("Group2desc")
@@ -168,7 +167,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
final int amountTargets = 10;
testdataFactory.createTargets(amountTargets, "ro-target", "rollout");
final List<RolloutGroup> rolloutGroups = Lists.newArrayList(
final List<RolloutGroup> rolloutGroups = Arrays.asList(
entityFactory.rolloutGroup().create().name("Group1").description("Group1desc").targetPercentage(0F)
.build(),
entityFactory.rolloutGroup().create().name("Group2").description("Group2desc").targetPercentage(100F)
@@ -193,7 +192,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
final int amountTargets = 10;
testdataFactory.createTargets(amountTargets, "ro-target", "rollout");
final List<RolloutGroup> rolloutGroups = Lists.newArrayList(
final List<RolloutGroup> rolloutGroups = Arrays.asList(
entityFactory.rolloutGroup().create().name("Group1").description("Group1desc").targetPercentage(1F)
.build(),
entityFactory.rolloutGroup().create().name("Group2").description("Group2desc").targetPercentage(101F)

View File

@@ -54,7 +54,6 @@ import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.web.bind.annotation.RestController;
import com.google.common.collect.Lists;
import com.jayway.jsonpath.JsonPath;
import ru.yandex.qatools.allure.annotations.Description;
@@ -71,7 +70,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
@Before
public void assertPreparationOfRepo() {
assertThat(softwareManagement.findSoftwareModulesAll(PAGE)).as("no softwaremodule should be founded")
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("no softwaremodule should be founded")
.hasSize(0);
}
@@ -87,7 +86,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final String updateVendor = "newVendor1";
final String updateDescription = "newDescription1";
SoftwareModule sm = softwareManagement.createSoftwareModule(entityFactory.softwareModule().create().type(osType)
SoftwareModule sm = softwareModuleManagement.createSoftwareModule(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 +107,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andExpect(jsonPath("$.description", equalTo(updateDescription)))
.andExpect(jsonPath("$.name", equalTo(knownSWName))).andReturn();
sm = softwareManagement.findSoftwareModuleById(sm.getId()).get();
sm = softwareModuleManagement.findSoftwareModuleById(sm.getId()).get();
assertThat(sm.getName()).isEqualTo(knownSWName);
assertThat(sm.getVendor()).isEqualTo(updateVendor);
assertThat(sm.getLastModifiedBy()).isEqualTo("smUpdateTester");
@@ -141,7 +140,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
// check rest of response compared to DB
final MgmtArtifact artResult = ResourceUtility
.convertArtifactResponse(mvcResult.getResponse().getContentAsString());
final Long artId = softwareManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0).getId();
final Long artId = softwareModuleManagement.findSoftwareModuleById(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())
.as("Link contains no self url")
@@ -161,7 +160,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
// binary
try (InputStream fileInputStream = artifactManagement
.loadArtifactBinary(
softwareManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0).getSha1Hash())
softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0).getSha1Hash())
.get().getFileInputStream()) {
assertTrue("Wrong artifact content",
IOUtils.contentEquals(new ByteArrayInputStream(random), fileInputStream));
@@ -175,14 +174,14 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.isEqualTo(HashGeneratorUtils.generateMD5(random));
// metadata
assertThat(softwareManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0).getFilename())
assertThat(softwareModuleManagement.findSoftwareModuleById(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(softwareManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(0);
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
@@ -313,7 +312,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
assertTrue("Response has wrong response content",
Arrays.equals(result2.getResponse().getContentAsByteArray(), random));
assertThat(softwareManagement.findSoftwareModulesAll(PAGE)).as("Softwaremodule size is wrong").hasSize(1);
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Softwaremodule size is wrong").hasSize(1);
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(2);
}
@@ -420,7 +419,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
public void invalidRequestsOnSoftwaremodulesResource() throws Exception {
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
final List<SoftwareModule> modules = Lists.newArrayList(sm);
final List<SoftwareModule> modules = Arrays.asList(sm);
// SM does not exist
mvc.perform(get("/rest/v1/softwaremodules/12345678")).andDo(MockMvcResultPrinter.print())
@@ -446,7 +445,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final SoftwareModule toLongName = entityFactory.softwareModule().create().type(osType)
.name(RandomStringUtils.randomAscii(80)).build();
mvc.perform(
post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(Lists.newArrayList(toLongName)))
post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(Arrays.asList(toLongName)))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest());
@@ -551,7 +550,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andExpect(jsonPath("$.content.[?(@.id==" + app.getId() + ")]._links.self.href",
contains("http://localhost/rest/v1/softwaremodules/" + app.getId())));
assertThat(softwareManagement.findSoftwareModulesAll(PAGE)).as("Softwaremodule size is wrong").hasSize(2);
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Softwaremodule size is wrong").hasSize(2);
}
@Test
@@ -562,7 +561,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
testdataFactory.createSoftwareModuleOs("2");
final SoftwareModule app2 = testdataFactory.createSoftwareModuleApp("2");
assertThat(softwareManagement.findSoftwareModulesAll(PAGE)).hasSize(4);
assertThat(softwareModuleManagement.findSoftwareModulesAll(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))
@@ -652,7 +651,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andExpect(jsonPath("$._links.artifacts.href",
equalTo("http://localhost/rest/v1/softwaremodules/" + os.getId() + "/artifacts")));
assertThat(softwareManagement.findSoftwareModulesAll(PAGE)).as("Softwaremodule size is wrong").hasSize(1);
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Softwaremodule size is wrong").hasSize(1);
}
@Test
@@ -664,7 +663,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final SoftwareModule ah = entityFactory.softwareModule().create().name("name3").type(appType)
.version("version3").vendor("vendor3").description("description3").build();
final List<SoftwareModule> modules = Lists.newArrayList(os, ah);
final List<SoftwareModule> modules = Arrays.asList(os, ah);
final long current = System.currentTimeMillis();
@@ -686,9 +685,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andExpect(jsonPath("[1].createdBy", equalTo("uploadTester")))
.andExpect(jsonPath("[1].createdAt", not(equalTo(0)))).andReturn();
final SoftwareModule osCreated = softwareManagement
final SoftwareModule osCreated = softwareModuleManagement
.findSoftwareModuleByNameAndVersion("name1", "version1", osType.getId()).get();
final SoftwareModule appCreated = softwareManagement
final SoftwareModule appCreated = softwareModuleManagement
.findSoftwareModuleByNameAndVersion("name3", "version3", appType.getId()).get();
assertThat(
@@ -707,14 +706,14 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.toString()).as("Response contains invalid artifacts href")
.isEqualTo("http://localhost/rest/v1/softwaremodules/" + appCreated.getId() + "/artifacts");
assertThat(softwareManagement.findSoftwareModulesAll(PAGE)).as("Wrong softwaremodule size").hasSize(2);
assertThat(softwareManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0).getName())
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Wrong softwaremodule size").hasSize(2);
assertThat(softwareModuleManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0).getName())
.as("Softwaremoudle name is wrong").isEqualTo(os.getName());
assertThat(softwareManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0)
assertThat(softwareModuleManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0)
.getCreatedBy()).as("Softwaremoudle created by is wrong").isEqualTo("uploadTester");
assertThat(softwareManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0)
assertThat(softwareModuleManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0)
.getCreatedAt()).as("Softwaremoudle created at is wrong").isGreaterThanOrEqualTo(current);
assertThat(softwareManagement.findSoftwareModulesByType(PAGE, appType.getId()).getContent().get(0).getName())
assertThat(softwareModuleManagement.findSoftwareModulesByType(PAGE, appType.getId()).getContent().get(0).getName())
.as("Softwaremoudle name is wrong").isEqualTo(ah.getName());
}
@@ -728,13 +727,13 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false);
assertThat(softwareManagement.findSoftwareModulesAll(PAGE)).as("Softwaremoudle size is wrong").hasSize(1);
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Softwaremoudle size is wrong").hasSize(1);
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(1);
mvc.perform(delete("/rest/v1/softwaremodules/{smId}", sm.getId())).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
assertThat(softwareManagement.findSoftwareModulesAll(PAGE))
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE))
.as("After delete no softwarmodule should be available").isEmpty();
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(0);
}
@@ -749,7 +748,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
artifactManagement.createArtifact(new ByteArrayInputStream(random),
ds1.findFirstModuleByType(appType).get().getId(), "file1", false);
assertThat(softwareManagement.findSoftwareModulesAll(PAGE)).hasSize(3);
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(3);
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(1);
mvc.perform(delete("/rest/v1/softwaremodules/{smId}", ds1.findFirstModuleByType(appType).get().getId()))
@@ -760,7 +759,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
// all 3 are now marked as deleted
assertThat(softwareManagement.findSoftwareModulesAll(PAGE).getNumber())
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE).getNumber())
.as("After delete no softwarmodule should be available").isEqualTo(0);
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(1);
}
@@ -779,9 +778,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file2", false);
// check repo before delete
assertThat(softwareManagement.findSoftwareModulesAll(PAGE)).hasSize(1);
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(1);
assertThat(softwareManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts()).hasSize(2);
assertThat(softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts()).hasSize(2);
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(2);
// delete
@@ -789,10 +788,10 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
// check that only one artifact is still alive and still assigned
assertThat(softwareManagement.findSoftwareModulesAll(PAGE)).as("After the sm should be marked as deleted")
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("After the sm should be marked as deleted")
.hasSize(1);
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(1);
assertThat(softwareManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts())
assertThat(softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts())
.as("After delete artifact should available for marked as deleted sm's").hasSize(1);
}
@@ -820,9 +819,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andExpect(jsonPath("[1]key", equalTo(knownKey2)))
.andExpect(jsonPath("[1]value", equalTo(knownValue2)));
final SoftwareModuleMetadata metaKey1 = softwareManagement.findSoftwareModuleMetadata(sm.getId(), knownKey1)
final SoftwareModuleMetadata metaKey1 = softwareModuleManagement.findSoftwareModuleMetadata(sm.getId(), knownKey1)
.get();
final SoftwareModuleMetadata metaKey2 = softwareManagement.findSoftwareModuleMetadata(sm.getId(), knownKey2)
final SoftwareModuleMetadata metaKey2 = softwareModuleManagement.findSoftwareModuleMetadata(sm.getId(), knownKey2)
.get();
assertThat(metaKey1.getValue()).as("Metadata key is wrong").isEqualTo(knownValue1);
@@ -838,7 +837,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final String updateValue = "valueForUpdate";
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
softwareManagement.createSoftwareModuleMetadata(sm.getId(),
softwareModuleManagement.createSoftwareModuleMetadata(sm.getId(),
entityFactory.generateMetadata(knownKey, knownValue));
final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue);
@@ -849,7 +848,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue)));
final SoftwareModuleMetadata assertDS = softwareManagement.findSoftwareModuleMetadata(sm.getId(), knownKey)
final SoftwareModuleMetadata assertDS = softwareModuleManagement.findSoftwareModuleMetadata(sm.getId(), knownKey)
.get();
assertThat(assertDS.getValue()).as("Metadata is wrong").isEqualTo(updateValue);
}
@@ -862,13 +861,13 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final String knownValue = "knownValue";
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
softwareManagement.createSoftwareModuleMetadata(sm.getId(),
softwareModuleManagement.createSoftwareModuleMetadata(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(softwareManagement.findSoftwareModuleMetadata(sm.getId(), knownKey)).isNotPresent();
assertThat(softwareModuleManagement.findSoftwareModuleMetadata(sm.getId(), knownKey)).isNotPresent();
}
@Test
@@ -879,7 +878,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final String knownValue = "knownValue";
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
softwareManagement.createSoftwareModuleMetadata(sm.getId(),
softwareModuleManagement.createSoftwareModuleMetadata(sm.getId(),
entityFactory.generateMetadata(knownKey, knownValue));
mvc.perform(delete("/rest/v1/softwaremodules/{swId}/metadata/XXX", sm.getId(), knownKey))
@@ -888,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(softwareManagement.findSoftwareModuleMetadata(sm.getId(), knownKey)).isPresent();
assertThat(softwareModuleManagement.findSoftwareModuleMetadata(sm.getId(), knownKey)).isPresent();
}
@Test
@@ -907,7 +906,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
for (int index = 0; index < totalMetadata; index++) {
softwareManagement.createSoftwareModuleMetadata(sm.getId(),
softwareModuleManagement.createSoftwareModuleMetadata(sm.getId(),
entityFactory.generateMetadata(knownKeyPrefix + index, knownValuePrefix + index));
}
@@ -923,7 +922,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
char character = 'a';
for (int index = 0; index < amount; index++) {
final String str = String.valueOf(character);
softwareManagement.createSoftwareModule(entityFactory.softwareModule().create().type(osType).name(str)
softwareModuleManagement.createSoftwareModule(entityFactory.softwareModule().create().type(osType).name(str)
.description(str).vendor(str).version(str));
character++;
}

View File

@@ -22,6 +22,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang3.RandomStringUtils;
@@ -35,7 +36,6 @@ import org.junit.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import com.google.common.collect.Lists;
import com.jayway.jsonpath.JsonPath;
import ru.yandex.qatools.allure.annotations.Description;
@@ -90,9 +90,10 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
}
private SoftwareModuleType createTestType() {
SoftwareModuleType testType = softwareManagement.createSoftwareModuleType(entityFactory.softwareModuleType()
.create().key("test123").name("TestName123").description("Desc123").maxAssignments(5));
testType = softwareManagement.updateSoftwareModuleType(
SoftwareModuleType testType = softwareModuleTypeManagement
.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("test123").name("TestName123")
.description("Desc123").maxAssignments(5));
testType = softwareModuleTypeManagement.updateSoftwareModuleType(
entityFactory.softwareModuleType().update(testType.getId()).description("Desc1234"));
return testType;
}
@@ -162,7 +163,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes POST requests.")
public void createSoftwareModuleTypes() throws Exception {
final List<SoftwareModuleType> types = Lists.newArrayList(
final List<SoftwareModuleType> types = Arrays.asList(
entityFactory.softwareModuleType().create().key("test1").name("TestName1").description("Desc1")
.colour("col1").maxAssignments(1).build(),
entityFactory.softwareModuleType().create().key("test2").name("TestName2").description("Desc2")
@@ -189,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 = softwareManagement.findSoftwareModuleTypeByKey("test1").get();
final SoftwareModuleType created2 = softwareManagement.findSoftwareModuleTypeByKey("test2").get();
final SoftwareModuleType created3 = softwareManagement.findSoftwareModuleTypeByKey("test3").get();
final SoftwareModuleType created1 = softwareModuleTypeManagement.findSoftwareModuleTypeByKey("test1").get();
final SoftwareModuleType created2 = softwareModuleTypeManagement.findSoftwareModuleTypeByKey("test2").get();
final SoftwareModuleType created3 = softwareModuleTypeManagement.findSoftwareModuleTypeByKey("test3").get();
assertThat(
JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
@@ -203,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(softwareManagement.countSoftwareModuleTypesAll()).isEqualTo(6);
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).isEqualTo(6);
}
@Test
@@ -230,12 +231,12 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
public void deleteSoftwareModuleTypeUnused() throws Exception {
final SoftwareModuleType testType = createTestType();
assertThat(softwareManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
mvc.perform(delete("/rest/v1/softwaremoduletypes/{smId}", testType.getId())).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
assertThat(softwareManagement.countSoftwareModuleTypesAll()).isEqualTo(3);
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).isEqualTo(3);
}
@Test
@@ -250,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();
softwareManagement.createSoftwareModule(
softwareModuleManagement.createSoftwareModule(
entityFactory.softwareModule().create().type(testType).name("name").version("version"));
assertThat(softwareManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
mvc.perform(delete("/rest/v1/softwaremoduletypes/{smId}", testType.getId())).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
assertThat(softwareManagement.countSoftwareModuleTypesAll()).isEqualTo(3);
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).isEqualTo(3);
}
@Test
@@ -321,7 +322,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
public void invalidRequestsOnSoftwaremoduleTypesResource() throws Exception {
final SoftwareModuleType testType = createTestType();
final List<SoftwareModuleType> types = Lists.newArrayList(testType);
final List<SoftwareModuleType> types = Arrays.asList(testType);
// SM does not exist
mvc.perform(get("/rest/v1/softwaremoduletypes/12345678")).andDo(MockMvcResultPrinter.print())
@@ -347,10 +348,10 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
final SoftwareModuleType toLongName = entityFactory.softwareModuleType().create().key("test123")
.name(RandomStringUtils.randomAscii(80)).build();
mvc.perform(post("/rest/v1/softwaremoduletypes")
.content(JsonBuilder.softwareModuleTypes(Lists.newArrayList(toLongName)))
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
mvc.perform(
post("/rest/v1/softwaremoduletypes").content(JsonBuilder.softwareModuleTypes(Arrays.asList(toLongName)))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest());
// unsupported media type
mvc.perform(post("/rest/v1/softwaremoduletypes").content(JsonBuilder.softwareModuleTypes(types))
@@ -369,10 +370,10 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
@Test
@Description("Search erquest of software module types.")
public void searchSoftwareModuleTypeRsql() throws Exception {
softwareManagement.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("test123")
softwareModuleTypeManagement.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("test123")
.name("TestName123").description("Desc123").maxAssignments(5));
softwareManagement.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("test1234")
.name("TestName1234").description("Desc1234").maxAssignments(5));
softwareModuleTypeManagement.createSoftwareModuleType(entityFactory.softwareModuleType().create()
.key("test1234").name("TestName1234").description("Desc1234").maxAssignments(5));
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
@@ -387,7 +388,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
char character = 'a';
for (int index = 0; index < amount; index++) {
final String str = String.valueOf(character);
softwareManagement.createSoftwareModule(entityFactory.softwareModule().create().type(osType).name(str)
softwareModuleManagement.createSoftwareModule(entityFactory.softwareModule().create().type(osType).name(str)
.description(str).vendor(str).version(str));
character++;
}

View File

@@ -24,6 +24,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -59,7 +60,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import com.google.common.collect.Lists;
import com.jayway.jsonpath.JsonPath;
import ru.yandex.qatools.allure.annotations.Description;
@@ -192,7 +192,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
final DistributionSet dsA = testdataFactory.createDistributionSet("");
final Target createTarget = testdataFactory.createTarget("knownTargetId");
assignDistributionSet(dsA, Lists.newArrayList(createTarget));
assignDistributionSet(dsA, Arrays.asList(createTarget));
final String rsqlPendingStatus = "status==pending";
final String rsqlFinishedStatus = "status==finished";
@@ -230,8 +230,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNoContent());
final Action action = deploymentManagement.findAction(
deploymentManagement.findActionsByTarget(tA.getControllerId(), PAGE).getContent().get(0).getId())
.get();
deploymentManagement.findActionsByTarget(tA.getControllerId(), PAGE).getContent().get(0).getId()).get();
// still active because in "canceling" state and waiting for controller
// feedback
assertThat(action.isActive()).isTrue();
@@ -695,7 +694,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
.build();
final MvcResult mvcResult = mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)
.content(JsonBuilder.targets(Lists.newArrayList(test1), true)).contentType(MediaType.APPLICATION_JSON))
.content(JsonBuilder.targets(Arrays.asList(test1), true)).contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
@@ -717,7 +716,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
final Target test3 = entityFactory.target().create().controllerId("id3").name("testname3")
.description("testid3").build();
final List<Target> targets = Lists.newArrayList(test1, test2, test3);
final List<Target> targets = Arrays.asList(test1, test2, test3);
final MvcResult mvcResult = mvc
.perform(post("/rest/v1/targets/").content(JsonBuilder.targets(targets, true))
@@ -1044,7 +1043,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
throws InterruptedException {
final Target target = testdataFactory.createTarget(knownTargetId);
final List<Target> targets = Lists.newArrayList(target);
final List<Target> targets = Arrays.asList(target);
final Iterator<DistributionSet> sets = testdataFactory.createDistributionSets(2).iterator();
final DistributionSet one = sets.next();
@@ -1300,7 +1299,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
final DistributionSet dsA = testdataFactory.createDistributionSet("");
final Target tA = testdataFactory.createTarget("target-id-A");
// assign a distribution set so we get an active update action
assignDistributionSet(dsA, Lists.newArrayList(tA));
assignDistributionSet(dsA, Arrays.asList(tA));
// verify active action
final Slice<Action> actionsByTarget = deploymentManagement.findActionsByTarget(tA.getControllerId(), PAGE);
assertThat(actionsByTarget.getContent()).hasSize(1);