reduced empty collections. Fixed Ui eventbus memory leak.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
kaizimmerm
2016-09-20 13:40:51 +02:00
parent bacaed8482
commit 66297d7c27
92 changed files with 743 additions and 647 deletions

View File

@@ -12,7 +12,10 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.mgmt.json.model.MgmtMetadata;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet;
@@ -34,10 +37,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
/**
* A mapper which maps repository model to RESTful model representation and
* back.
*
*
*
*
*/
public final class MgmtDistributionSetMapper {
private MgmtDistributionSetMapper() {
@@ -75,15 +74,13 @@ public final class MgmtDistributionSetMapper {
* to use for conversion
* @return converted list of {@link DistributionSet}s
*/
static List<DistributionSet> dsFromRequest(final Iterable<MgmtDistributionSetRequestBodyPost> sets,
static List<DistributionSet> dsFromRequest(final Collection<MgmtDistributionSetRequestBodyPost> sets,
final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement,
final EntityFactory entityFactory) {
final List<DistributionSet> mappedList = new ArrayList<>();
for (final MgmtDistributionSetRequestBodyPost dsRest : sets) {
mappedList.add(fromRequest(dsRest, softwareManagement, distributionSetManagement, entityFactory));
}
return mappedList;
return sets.stream()
.map(dsRest -> fromRequest(dsRest, softwareManagement, distributionSetManagement, entityFactory))
.collect(Collectors.toList());
}
@@ -139,15 +136,12 @@ public final class MgmtDistributionSetMapper {
*/
static List<DistributionSetMetadata> fromRequestDsMetadata(final DistributionSet ds,
final List<MgmtMetadata> metadata, final EntityFactory entityFactory) {
final List<DistributionSetMetadata> mappedList = new ArrayList<>(metadata.size());
for (final MgmtMetadata metadataRest : metadata) {
if (metadataRest.getKey() == null) {
throw new IllegalArgumentException("the key of the metadata must be present");
}
mappedList.add(
entityFactory.generateDistributionSetMetadata(ds, metadataRest.getKey(), metadataRest.getValue()));
if (metadata == null) {
return Collections.emptyList();
}
return mappedList;
return metadata.stream().map(metadataRest -> entityFactory.generateDistributionSetMetadata(ds,
metadataRest.getKey(), metadataRest.getValue())).collect(Collectors.toList());
}
/**
@@ -196,15 +190,12 @@ public final class MgmtDistributionSetMapper {
return result;
}
static List<MgmtDistributionSet> toResponseDistributionSets(final Iterable<DistributionSet> sets) {
final List<MgmtDistributionSet> response = new ArrayList<>();
if (sets != null) {
for (final DistributionSet set : sets) {
response.add(toResponse(set));
}
static List<MgmtDistributionSet> toResponseDistributionSets(final Collection<DistributionSet> sets) {
if (sets == null) {
return Collections.emptyList();
}
return response;
return sets.stream().map(MgmtDistributionSetMapper::toResponse).collect(Collectors.toList());
}
static MgmtMetadata toResponseDsMetadata(final DistributionSetMetadata metadata) {
@@ -224,14 +215,10 @@ public final class MgmtDistributionSetMapper {
}
static List<MgmtDistributionSet> toResponseFromDsList(final List<DistributionSet> sets) {
final List<MgmtDistributionSet> mappedList = new ArrayList<>();
if (sets != null) {
for (final DistributionSet set : sets) {
final MgmtDistributionSet response = toResponse(set);
mappedList.add(response);
}
if (sets == null) {
return Collections.emptyList();
}
return mappedList;
return sets.stream().map(MgmtDistributionSetMapper::toResponse).collect(Collectors.toList());
}
}

View File

@@ -8,6 +8,7 @@
*/
package org.eclipse.hawkbit.mgmt.rest.resource;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -123,7 +124,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
.runAsSystem(() -> this.systemManagement.getTenantMetadata().getDefaultDsType().getKey());
sets.stream().filter(ds -> ds.getType() == null).forEach(ds -> ds.setType(defaultDsKey));
final Iterable<DistributionSet> createdDSets = this.distributionSetManagement
final Collection<DistributionSet> createdDSets = this.distributionSetManagement
.createDistributionSets(MgmtDistributionSetMapper.dsFromRequest(sets, this.softwareManagement,
this.distributionSetManagement, entityFactory));

View File

@@ -11,8 +11,10 @@ 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.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetType;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
@@ -39,13 +41,13 @@ final class MgmtDistributionSetTypeMapper {
static List<DistributionSetType> smFromRequest(final EntityFactory entityFactory,
final SoftwareManagement softwareManagement,
final Iterable<MgmtDistributionSetTypeRequestBodyPost> smTypesRest) {
final List<DistributionSetType> mappedList = new ArrayList<>();
for (final MgmtDistributionSetTypeRequestBodyPost smRest : smTypesRest) {
mappedList.add(fromRequest(entityFactory, softwareManagement, smRest));
final Collection<MgmtDistributionSetTypeRequestBodyPost> smTypesRest) {
if (smTypesRest == null) {
return Collections.emptyList();
}
return mappedList;
return smTypesRest.stream().map(smRest -> fromRequest(entityFactory, softwareManagement, smRest))
.collect(Collectors.toList());
}
static DistributionSetType fromRequest(final EntityFactory entityFactory,
@@ -91,19 +93,19 @@ final class MgmtDistributionSetTypeMapper {
}
static List<MgmtDistributionSetType> toTypesResponse(final List<DistributionSetType> types) {
final List<MgmtDistributionSetType> response = new ArrayList<>();
for (final DistributionSetType dsType : types) {
response.add(toResponse(dsType));
if (types == null) {
return Collections.emptyList();
}
return response;
return types.stream().map(MgmtDistributionSetTypeMapper::toResponse).collect(Collectors.toList());
}
static List<MgmtDistributionSetType> toListResponse(final List<DistributionSetType> types) {
final List<MgmtDistributionSetType> response = new ArrayList<>();
for (final DistributionSetType dsType : types) {
response.add(toResponse(dsType));
if (types == null) {
return Collections.emptyList();
}
return response;
return types.stream().map(MgmtDistributionSetTypeMapper::toResponse).collect(Collectors.toList());
}
static MgmtDistributionSetType toResponse(final DistributionSetType type) {

View File

@@ -146,7 +146,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId) {
final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId);
return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toListResponse(foundType.getMandatoryModuleTypes()),
return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toTypesResponse(foundType.getMandatoryModuleTypes()),
HttpStatus.OK);
}
@@ -190,7 +190,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId);
return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toListResponse(foundType.getOptionalModuleTypes()),
return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toTypesResponse(foundType.getOptionalModuleTypes()),
HttpStatus.OK);
}

View File

@@ -11,8 +11,9 @@ 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.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutCondition.Condition;
import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutErrorAction.ErrorAction;
@@ -48,9 +49,11 @@ final class MgmtRolloutMapper {
}
static List<MgmtRolloutResponseBody> toResponseRollout(final List<Rollout> rollouts) {
final List<MgmtRolloutResponseBody> result = new ArrayList<>(rollouts.size());
rollouts.forEach(r -> result.add(toResponseRollout(r)));
return result;
if (rollouts == null) {
return Collections.emptyList();
}
return rollouts.stream().map(MgmtRolloutMapper::toResponseRollout).collect(Collectors.toList());
}
static MgmtRolloutResponseBody toResponseRollout(final Rollout rollout) {
@@ -103,9 +106,11 @@ final class MgmtRolloutMapper {
}
static List<MgmtRolloutGroupResponseBody> toResponseRolloutGroup(final List<RolloutGroup> rollouts) {
final List<MgmtRolloutGroupResponseBody> result = new ArrayList<>(rollouts.size());
rollouts.forEach(r -> result.add(toResponseRolloutGroup(r)));
return result;
if (rollouts == null) {
return Collections.emptyList();
}
return rollouts.stream().map(MgmtRolloutMapper::toResponseRolloutGroup).collect(Collectors.toList());
}
static MgmtRolloutGroupResponseBody toResponseRolloutGroup(final RolloutGroup rolloutGroup) {

View File

@@ -11,8 +11,10 @@ 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.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.mgmt.json.model.MgmtMetadata;
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact;
@@ -65,60 +67,46 @@ public final class MgmtSoftwareModuleMapper {
}
static List<SoftwareModuleMetadata> fromRequestSwMetadata(final EntityFactory entityFactory,
final SoftwareModule sw, final List<MgmtMetadata> metadata) {
final List<SoftwareModuleMetadata> mappedList = new ArrayList<>(metadata.size());
for (final MgmtMetadata metadataRest : metadata) {
if (metadataRest.getKey() == null) {
throw new IllegalArgumentException("the key of the metadata must be present");
}
mappedList.add(
entityFactory.generateSoftwareModuleMetadata(sw, metadataRest.getKey(), metadataRest.getValue()));
final SoftwareModule sw, final Collection<MgmtMetadata> metadata) {
if (metadata == null) {
return Collections.emptyList();
}
return mappedList;
return metadata.stream().map(metadataRest -> entityFactory.generateSoftwareModuleMetadata(sw,
metadataRest.getKey(), metadataRest.getValue())).collect(Collectors.toList());
}
static List<SoftwareModule> smFromRequest(final EntityFactory entityFactory,
final Iterable<MgmtSoftwareModuleRequestBodyPost> smsRest, final SoftwareManagement softwareManagement) {
final List<SoftwareModule> mappedList = new ArrayList<>();
for (final MgmtSoftwareModuleRequestBodyPost smRest : smsRest) {
mappedList.add(fromRequest(entityFactory, smRest, softwareManagement));
final Collection<MgmtSoftwareModuleRequestBodyPost> smsRest, final SoftwareManagement softwareManagement) {
if (smsRest == null) {
return Collections.emptyList();
}
return mappedList;
return smsRest.stream().map(smRest -> fromRequest(entityFactory, smRest, softwareManagement))
.collect(Collectors.toList());
}
/**
* Create response for sw modules.
*
* @param baseSoftareModules
* @param softwareModules
* the modules
* @return the response
*/
public static List<MgmtSoftwareModule> toResponse(final List<SoftwareModule> baseSoftareModules) {
final List<MgmtSoftwareModule> mappedList = new ArrayList<>();
if (baseSoftareModules != null) {
for (final SoftwareModule target : baseSoftareModules) {
final MgmtSoftwareModule response = toResponse(target);
mappedList.add(response);
}
public static List<MgmtSoftwareModule> toResponse(final Collection<SoftwareModule> softwareModules) {
if (softwareModules == null) {
return Collections.emptyList();
}
return mappedList;
return softwareModules.stream().map(MgmtSoftwareModuleMapper::toResponse).collect(Collectors.toList());
}
static List<MgmtSoftwareModule> toResponseSoftwareModules(final Iterable<SoftwareModule> softwareModules) {
final List<MgmtSoftwareModule> response = new ArrayList<>();
for (final SoftwareModule softwareModule : softwareModules) {
response.add(toResponse(softwareModule));
static List<MgmtMetadata> toResponseSwMetadata(final Collection<SoftwareModuleMetadata> metadata) {
if (metadata == null) {
return Collections.emptyList();
}
return response;
}
static List<MgmtMetadata> toResponseSwMetadata(final List<SoftwareModuleMetadata> metadata) {
final List<MgmtMetadata> mappedList = new ArrayList<>(metadata.size());
for (final SoftwareModuleMetadata distributionSetMetadata : metadata) {
mappedList.add(toResponseSwMetadata(distributionSetMetadata));
}
return mappedList;
return metadata.stream().map(MgmtSoftwareModuleMapper::toResponseSwMetadata).collect(Collectors.toList());
}
static MgmtMetadata toResponseSwMetadata(final SoftwareModuleMetadata metadata) {
@@ -194,15 +182,11 @@ public final class MgmtSoftwareModuleMapper {
return artifactRest;
}
static List<MgmtArtifact> artifactsToResponse(final List<Artifact> artifacts) {
final List<MgmtArtifact> mappedList = new ArrayList<>();
if (artifacts != null) {
for (final Artifact artifact : artifacts) {
final MgmtArtifact response = toResponse(artifact);
mappedList.add(response);
}
static List<MgmtArtifact> artifactsToResponse(final Collection<Artifact> artifacts) {
if (artifacts == null) {
return Collections.emptyList();
}
return mappedList;
return artifacts.stream().map(MgmtSoftwareModuleMapper::toResponse).collect(Collectors.toList());
}
}

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.mgmt.rest.resource;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.MgmtMetadata;
@@ -158,12 +159,11 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
public ResponseEntity<List<MgmtSoftwareModule>> createSoftwareModules(
@RequestBody final List<MgmtSoftwareModuleRequestBodyPost> softwareModules) {
LOG.debug("creating {} softwareModules", softwareModules.size());
final Iterable<SoftwareModule> createdSoftwareModules = softwareManagement.createSoftwareModule(
final Collection<SoftwareModule> createdSoftwareModules = softwareManagement.createSoftwareModule(
MgmtSoftwareModuleMapper.smFromRequest(entityFactory, softwareModules, softwareManagement));
LOG.debug("{} softwareModules created, return status {}", softwareModules.size(), HttpStatus.CREATED);
return new ResponseEntity<>(MgmtSoftwareModuleMapper.toResponseSoftwareModules(createdSoftwareModules),
HttpStatus.CREATED);
return new ResponseEntity<>(MgmtSoftwareModuleMapper.toResponse(createdSoftwareModules), HttpStatus.CREATED);
}
@Override

View File

@@ -11,9 +11,10 @@ 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.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost;
@@ -25,9 +26,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
* A mapper which maps repository model to RESTful model representation and
* back.
*
*
*
*
*/
final class MgmtSoftwareModuleTypeMapper {
@@ -37,13 +35,12 @@ final class MgmtSoftwareModuleTypeMapper {
}
static List<SoftwareModuleType> smFromRequest(final EntityFactory entityFactory,
final Iterable<MgmtSoftwareModuleTypeRequestBodyPost> smTypesRest) {
final List<SoftwareModuleType> mappedList = new ArrayList<>();
for (final MgmtSoftwareModuleTypeRequestBodyPost smRest : smTypesRest) {
mappedList.add(fromRequest(entityFactory, smRest));
final Collection<MgmtSoftwareModuleTypeRequestBodyPost> smTypesRest) {
if (smTypesRest == null) {
return Collections.emptyList();
}
return mappedList;
return smTypesRest.stream().map(smRest -> fromRequest(entityFactory, smRest)).collect(Collectors.toList());
}
static SoftwareModuleType fromRequest(final EntityFactory entityFactory,
@@ -57,20 +54,12 @@ final class MgmtSoftwareModuleTypeMapper {
return result;
}
static List<MgmtSoftwareModuleType> toTypesResponse(final List<SoftwareModuleType> types) {
final List<MgmtSoftwareModuleType> response = new ArrayList<>();
for (final SoftwareModuleType softwareModule : types) {
response.add(toResponse(softwareModule));
static List<MgmtSoftwareModuleType> toTypesResponse(final Collection<SoftwareModuleType> types) {
if (types == null) {
return Collections.emptyList();
}
return response;
}
static List<MgmtSoftwareModuleType> toListResponse(final Collection<SoftwareModuleType> types) {
final List<MgmtSoftwareModuleType> response = new ArrayList<>();
for (final SoftwareModuleType softwareModule : types) {
response.add(toResponse(softwareModule));
}
return response;
return types.stream().map(MgmtSoftwareModuleTypeMapper::toResponse).collect(Collectors.toList());
}
static MgmtSoftwareModuleType toResponse(final SoftwareModuleType type) {

View File

@@ -72,7 +72,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
}
final List<MgmtSoftwareModuleType> rest = MgmtSoftwareModuleTypeMapper
.toListResponse(findModuleTypessAll.getContent());
.toTypesResponse(findModuleTypessAll.getContent());
return new ResponseEntity<>(new PagedList<>(rest, countModulesAll), HttpStatus.OK);
}

View File

@@ -13,9 +13,11 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import java.net.URI;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.mgmt.json.model.MgmtPollStatus;
import org.eclipse.hawkbit.mgmt.json.model.action.MgmtAction;
@@ -92,17 +94,17 @@ public final class MgmtTargetMapper {
* the targets
* @return the response
*/
public static List<MgmtTarget> toResponseWithLinksAndPollStatus(final Iterable<Target> targets) {
final List<MgmtTarget> mappedList = new ArrayList<>();
if (targets != null) {
for (final Target target : targets) {
final MgmtTarget response = toResponse(target);
addPollStatus(target, response);
addTargetLinks(response);
mappedList.add(response);
}
public static List<MgmtTarget> toResponseWithLinksAndPollStatus(final Collection<Target> targets) {
if (targets == null) {
return Collections.emptyList();
}
return mappedList;
return targets.stream().map(target -> {
final MgmtTarget response = toResponse(target);
addPollStatus(target, response);
addTargetLinks(response);
return response;
}).collect(Collectors.toList());
}
/**
@@ -112,15 +114,12 @@ public final class MgmtTargetMapper {
* list of targets
* @return the response
*/
public static List<MgmtTarget> toResponse(final Iterable<Target> targets) {
final List<MgmtTarget> mappedList = new ArrayList<>();
if (targets != null) {
for (final Target target : targets) {
final MgmtTarget response = toResponse(target);
mappedList.add(response);
}
public static List<MgmtTarget> toResponse(final Collection<Target> targets) {
if (targets == null) {
return Collections.emptyList();
}
return mappedList;
return targets.stream().map(MgmtTargetMapper::toResponse).collect(Collectors.toList());
}
/**
@@ -173,12 +172,13 @@ public final class MgmtTargetMapper {
}
static List<Target> fromRequest(final EntityFactory entityFactory,
final Iterable<MgmtTargetRequestBody> targetsRest) {
final List<Target> mappedList = new ArrayList<>();
for (final MgmtTargetRequestBody targetRest : targetsRest) {
mappedList.add(fromRequest(entityFactory, targetRest));
final Collection<MgmtTargetRequestBody> targetsRest) {
if (targetsRest == null) {
return Collections.emptyList();
}
return mappedList;
return targetsRest.stream().map(targetRest -> fromRequest(entityFactory, targetRest))
.collect(Collectors.toList());
}
static Target fromRequest(final EntityFactory entityFactory, final MgmtTargetRequestBody targetRest) {
@@ -190,17 +190,12 @@ public final class MgmtTargetMapper {
return target;
}
static List<MgmtActionStatus> toActionStatusRestResponse(final List<ActionStatus> actionStatus) {
final List<MgmtActionStatus> mappedList = new ArrayList<>();
if (actionStatus != null) {
for (final ActionStatus status : actionStatus) {
final MgmtActionStatus response = toResponse(status);
mappedList.add(response);
}
static List<MgmtActionStatus> toActionStatusRestResponse(final Collection<ActionStatus> actionStatus) {
if (actionStatus == null) {
return Collections.emptyList();
}
return mappedList;
return actionStatus.stream().map(MgmtTargetMapper::toResponse).collect(Collectors.toList());
}
static MgmtAction toResponse(final String targetId, final Action action, final boolean isActive) {
@@ -222,14 +217,13 @@ public final class MgmtTargetMapper {
return result;
}
static List<MgmtAction> toResponse(final String targetId, final List<Action> actions) {
final List<MgmtAction> mappedList = new ArrayList<>();
for (final Action action : actions) {
final MgmtAction response = toResponse(targetId, action, action.isActive());
mappedList.add(response);
static List<MgmtAction> toResponse(final String targetId, final Collection<Action> actions) {
if (actions == null) {
return Collections.emptyList();
}
return mappedList;
return actions.stream().map(action -> toResponse(targetId, action, action.isActive()))
.collect(Collectors.toList());
}
private static String getNameOfActionStatusType(final Action.Status type) {

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.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -108,7 +109,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
@Override
public ResponseEntity<List<MgmtTarget>> createTargets(@RequestBody final List<MgmtTargetRequestBody> targets) {
LOG.debug("creating {} targets", targets.size());
final Iterable<Target> createdTargets = this.targetManagement
final Collection<Target> createdTargets = this.targetManagement
.createTargets(MgmtTargetMapper.fromRequest(entityFactory, targets));
LOG.debug("{} targets created, return status {}", targets.size(), HttpStatus.CREATED);
return new ResponseEntity<>(MgmtTargetMapper.toResponse(createdTargets), HttpStatus.CREATED);

View File

@@ -26,6 +26,7 @@ import java.util.List;
import org.apache.commons.lang3.RandomStringUtils;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@@ -554,7 +555,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
final DistributionSetType missingName = entityFactory.generateDistributionSetType("test123", null, "Desc123");
final DistributionSetType missingName = new JpaDistributionSetType("test123", null, "Desc123");
mvc.perform(post("/rest/v1/distributionsettypes")
.content(JsonBuilder.distributionSetTypes(Lists.newArrayList(missingName)))
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())

View File

@@ -37,6 +37,7 @@ import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.LocalArtifact;
@@ -457,7 +458,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
final SoftwareModule missingName = entityFactory.generateSoftwareModule(osType, null, "version 1", null, null);
final SoftwareModule missingName = new JpaSoftwareModule(osType, null, "version 1", null, null);
mvc.perform(
post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(Lists.newArrayList(missingName)))
.contentType(MediaType.APPLICATION_JSON))

View File

@@ -26,6 +26,7 @@ import java.util.List;
import org.apache.commons.lang3.RandomStringUtils;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.test.util.WithUser;
@@ -337,7 +338,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
final SoftwareModuleType missingName = entityFactory.generateSoftwareModuleType("test123", null, "Desc123", 5);
final SoftwareModuleType missingName = new JpaSoftwareModuleType("test123", null, "Desc123", 5);
mvc.perform(post("/rest/v1/softwaremoduletypes")
.content(JsonBuilder.softwareModuleTypes(Lists.newArrayList(missingName)))
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())