Feature add optional name to thing created (#888)

* First implementation pushed because of debugging purpose

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Add name field and tests regarding name field functionality in THING_CREATED

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* SonarQube realted changes in name field functionality in THING_CREATED

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Add name field and tests regarding name field functionality in UPDATE_ATTRIBUTES

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Adapt documentation due to name field in THING_CREATED and UPDATE_ATTRIBUTES

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Add integration tests regarding name field functionality in THING_CREATED

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Reformat after finding format bug regarding THING_CREATED

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Reformat after finding the real format bug regarding THING_CREATED

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Reformat regarding THING_CREATED

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Use constant in THING_CREATED

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Format in THING_CREATED

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Resolving peer review comments regarding THING_CREATED

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Resolving peer review comments (organize imports) regarding THING_CREATED

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Refactoring regarding THING_CREATED

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Refactoring due to peer review

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Refactoring due to peer review

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Excluding UPDATE_ATTRIBUTES changes and provide functionality of updating the name property in THING_CREATED message

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Refactoring due to peer review

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Refactoring due to peer review

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Fix SonarQube finding

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Merge master into current branch

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>

* Fix peer review findings

Signed-off-by: Ammar Bikic <ammar.bikic@bosch-si.com>
This commit is contained in:
Ammar Bikic
2019-10-24 12:13:35 +02:00
committed by Dominic Schabel
parent b50a82fc0f
commit af0f7ceb5a
10 changed files with 525 additions and 388 deletions

View File

@@ -1,6 +1,6 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -117,8 +117,8 @@ public class TestdataFactory {
public static final String SM_TYPE_RT = "runtime";
/**
* Key of test "application" {@link SoftwareModuleType} : optional software
* in {@link #DS_TYPE_DEFAULT}.
* Key of test "application" {@link SoftwareModuleType} : optional software in
* {@link #DS_TYPE_DEFAULT}.
*/
public static final String SM_TYPE_APP = "application";
@@ -160,14 +160,13 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link DistributionSet#isRequiredMigrationStep()} <code>false</code>.
*
*
* @param prefix
* for {@link SoftwareModule}s and {@link DistributionSet}s name,
* vendor and description.
*
* @return {@link DistributionSet} entity.
*/
public DistributionSet createDistributionSet(final String prefix) {
@@ -176,10 +175,10 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link DistributionSet#isRequiredMigrationStep()} <code>false</code>.
*
*
* @return {@link DistributionSet} entity.
*/
public DistributionSet createDistributionSet() {
@@ -188,13 +187,12 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link DistributionSet#isRequiredMigrationStep()} <code>false</code>.
*
*
* @param modules
* of {@link DistributionSet#getModules()}
*
* @return {@link DistributionSet} entity.
*/
public DistributionSet createDistributionSet(final Collection<SoftwareModule> modules) {
@@ -203,16 +201,15 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link DistributionSet#isRequiredMigrationStep()} <code>false</code>.
*
*
* @param modules
* of {@link DistributionSet#getModules()}
* @param prefix
* for {@link SoftwareModule}s and {@link DistributionSet}s name,
* vendor and description.
*
* @return {@link DistributionSet} entity.
*/
public DistributionSet createDistributionSet(final Collection<SoftwareModule> modules, final String prefix) {
@@ -221,15 +218,14 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION}.
*
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION}.
*
* @param prefix
* for {@link SoftwareModule}s and {@link DistributionSet}s name,
* vendor and description.
* @param isRequiredMigrationStep
* for {@link DistributionSet#isRequiredMigrationStep()}
*
* @return {@link DistributionSet} entity.
*/
public DistributionSet createDistributionSet(final String prefix, final boolean isRequiredMigrationStep) {
@@ -238,16 +234,15 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link DistributionSet#isRequiredMigrationStep()} <code>false</code>.
*
*
* @param prefix
* for {@link SoftwareModule}s and {@link DistributionSet}s name,
* vendor and description.
* @param tags
* {@link DistributionSet#getTags()}
*
* @return {@link DistributionSet} entity.
*/
public DistributionSet createDistributionSet(final String prefix, final Collection<DistributionSetTag> tags) {
@@ -256,19 +251,17 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP}.
*
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP}.
*
* @param prefix
* for {@link SoftwareModule}s and {@link DistributionSet}s name,
* vendor and description.
* @param version
* {@link DistributionSet#getVersion()} and
* {@link SoftwareModule#getVersion()} extended by a random
* number.
* {@link SoftwareModule#getVersion()} extended by a random number.
* @param isRequiredMigrationStep
* for {@link DistributionSet#isRequiredMigrationStep()}
*
* @return {@link DistributionSet} entity.
*/
public DistributionSet createDistributionSet(final String prefix, final String version,
@@ -302,7 +295,7 @@ public class TestdataFactory {
* {@link SoftwareModuleMetadata#isTargetVisible()} and
* {@link #INVISIBLE_SM_MD_KEY}, {@link #INVISIBLE_SM_MD_VALUE} without
* {@link SoftwareModuleMetadata#isTargetVisible()}
*
*
* @param set
* to add metadata to
*/
@@ -320,19 +313,17 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository.
*
*
* @param prefix
* for {@link SoftwareModule}s and {@link DistributionSet}s name,
* vendor and description.
* @param version
* {@link DistributionSet#getVersion()} and
* {@link SoftwareModule#getVersion()} extended by a random
* number.
* {@link SoftwareModule#getVersion()} extended by a random number.
* @param isRequiredMigrationStep
* for {@link DistributionSet#isRequiredMigrationStep()}
* @param modules
* for {@link DistributionSet#getModules()}
*
* @return {@link DistributionSet} entity.
*/
public DistributionSet createDistributionSet(final String prefix, final String version,
@@ -347,9 +338,9 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP}.
*
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP}.
*
* @param prefix
* for {@link SoftwareModule}s and {@link DistributionSet}s name,
* vendor and description.
@@ -359,7 +350,6 @@ public class TestdataFactory {
* number.updat
* @param tags
* {@link DistributionSet#getTags()}
*
* @return {@link DistributionSet} entity.
*/
public DistributionSet createDistributionSet(final String prefix, final String version,
@@ -375,14 +365,13 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet}s in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an
* iterative number and {@link DistributionSet#isRequiredMigrationStep()}
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an iterative
* number and {@link DistributionSet#isRequiredMigrationStep()}
* <code>false</code>.
*
*
* @param number
* of {@link DistributionSet}s to create
*
* @return {@link List} of {@link DistributionSet} entities
*/
public List<DistributionSet> createDistributionSets(final int number) {
@@ -391,9 +380,8 @@ public class TestdataFactory {
}
/**
* Create a list of {@link DistributionSet}s without modules, i.e.
* incomplete.
*
* Create a list of {@link DistributionSet}s without modules, i.e. incomplete.
*
* @param number
* of {@link DistributionSet}s to create
* @return {@link List} of {@link DistributionSet} entities
@@ -412,17 +400,16 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet}s in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an
* iterative number and {@link DistributionSet#isRequiredMigrationStep()}
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an iterative
* number and {@link DistributionSet#isRequiredMigrationStep()}
* <code>false</code>.
*
*
* @param prefix
* for {@link SoftwareModule}s and {@link DistributionSet}s name,
* vendor and description.
* @param number
* of {@link DistributionSet}s to create
*
* @return {@link List} of {@link DistributionSet} entities
*/
public List<DistributionSet> createDistributionSets(final String prefix, final int number) {
@@ -439,12 +426,11 @@ public class TestdataFactory {
* Creates {@link DistributionSet}s in repository with
* {@link #DEFAULT_DESCRIPTION} and
* {@link DistributionSet#isRequiredMigrationStep()} <code>false</code>.
*
*
* @param name
* {@link DistributionSet#getName()}
* @param version
* {@link DistributionSet#getVersion()}
*
* @return {@link DistributionSet} entity
*/
public DistributionSet createDistributionSetWithNoSoftwareModules(final String name, final String version) {
@@ -454,12 +440,11 @@ public class TestdataFactory {
}
/**
* Creates {@link Artifact}s for given {@link SoftwareModule} with a small
* text payload.
*
* Creates {@link Artifact}s for given {@link SoftwareModule} with a small text
* payload.
*
* @param moduleId
* the {@link Artifact}s belong to.
*
* @return {@link Artifact} entity.
*/
public List<Artifact> createArtifacts(final Long moduleId) {
@@ -473,18 +458,15 @@ public class TestdataFactory {
}
/**
* Create an {@link Artifact} for given {@link SoftwareModule} with a small
* text payload.
*
* Create an {@link Artifact} for given {@link SoftwareModule} with a small text
* payload.
*
* @param artifactData
* the {@link Artifact} Inputstream
*
* @param moduleId
* the {@link Artifact} belongs to
*
* @param filename
* that was provided during upload.
*
* @return {@link Artifact} entity.
*/
public Artifact createArtifact(final String artifactData, final Long moduleId, final String filename) {
@@ -494,36 +476,32 @@ public class TestdataFactory {
}
/**
* Create an {@link Artifact} for given {@link SoftwareModule} with a small
* text payload.
* Create an {@link Artifact} for given {@link SoftwareModule} with a small text
* payload.
*
* @param artifactData
* the {@link Artifact} Inputstream
*
* @param moduleId
* the {@link Artifact} belongs to
*
* @param filename
* that was provided during upload.
*
* @param fileSize
* the file size
*
* @return {@link Artifact} entity.
*/
public Artifact createArtifact(final byte[] artifactData, final Long moduleId, final String filename, final int fileSize) {
return artifactManagement
.create(new ArtifactUpload(new ByteArrayInputStream(artifactData), moduleId, filename, false, fileSize));
public Artifact createArtifact(final byte[] artifactData, final Long moduleId, final String filename,
final int fileSize) {
return artifactManagement.create(
new ArtifactUpload(new ByteArrayInputStream(artifactData), moduleId, filename, false, fileSize));
}
/**
* Creates {@link SoftwareModule} with {@link #DEFAULT_VENDOR} and
* {@link #DEFAULT_VERSION} and random generated
* {@link Target#getDescription()} in the repository.
*
* {@link #DEFAULT_VERSION} and random generated {@link Target#getDescription()}
* in the repository.
*
* @param typeKey
* of the {@link SoftwareModuleType}
*
* @return persisted {@link SoftwareModule}.
*/
public SoftwareModule createSoftwareModule(final String typeKey) {
@@ -531,12 +509,10 @@ public class TestdataFactory {
}
/**
* Creates {@link SoftwareModule} of type
* {@value Constants#SMT_DEFAULT_APP_KEY} with {@link #DEFAULT_VENDOR} and
* {@link #DEFAULT_VERSION} and random generated
* {@link Target#getDescription()} in the repository.
*
*
* Creates {@link SoftwareModule} of type {@value Constants#SMT_DEFAULT_APP_KEY}
* with {@link #DEFAULT_VENDOR} and {@link #DEFAULT_VERSION} and random
* generated {@link Target#getDescription()} in the repository.
*
* @return persisted {@link SoftwareModule}.
*/
public SoftwareModule createSoftwareModuleApp() {
@@ -544,15 +520,12 @@ public class TestdataFactory {
}
/**
* Creates {@link SoftwareModule} of type
* {@value Constants#SMT_DEFAULT_APP_KEY} with {@link #DEFAULT_VENDOR} and
* {@link #DEFAULT_VERSION} and random generated
* {@link Target#getDescription()} in the repository.
*
* Creates {@link SoftwareModule} of type {@value Constants#SMT_DEFAULT_APP_KEY}
* with {@link #DEFAULT_VENDOR} and {@link #DEFAULT_VERSION} and random
* generated {@link Target#getDescription()} in the repository.
*
* @param prefix
* added to name and version
*
*
* @return persisted {@link SoftwareModule}.
*/
public SoftwareModule createSoftwareModuleApp(final String prefix) {
@@ -560,12 +533,10 @@ public class TestdataFactory {
}
/**
* Creates {@link SoftwareModule} of type
* {@value Constants#SMT_DEFAULT_OS_KEY} with {@link #DEFAULT_VENDOR} and
* {@link #DEFAULT_VERSION} and random generated
* {@link Target#getDescription()} in the repository.
*
*
* Creates {@link SoftwareModule} of type {@value Constants#SMT_DEFAULT_OS_KEY}
* with {@link #DEFAULT_VENDOR} and {@link #DEFAULT_VERSION} and random
* generated {@link Target#getDescription()} in the repository.
*
* @return persisted {@link SoftwareModule}.
*/
public SoftwareModule createSoftwareModuleOs() {
@@ -573,15 +544,12 @@ public class TestdataFactory {
}
/**
* Creates {@link SoftwareModule} of type
* {@value Constants#SMT_DEFAULT_OS_KEY} with {@link #DEFAULT_VENDOR} and
* {@link #DEFAULT_VERSION} and random generated
* {@link Target#getDescription()} in the repository.
*
* Creates {@link SoftwareModule} of type {@value Constants#SMT_DEFAULT_OS_KEY}
* with {@link #DEFAULT_VENDOR} and {@link #DEFAULT_VERSION} and random
* generated {@link Target#getDescription()} in the repository.
*
* @param prefix
* added to name and version
*
*
* @return persisted {@link SoftwareModule}.
*/
public SoftwareModule createSoftwareModuleOs(final String prefix) {
@@ -590,14 +558,13 @@ public class TestdataFactory {
/**
* Creates {@link SoftwareModule} with {@link #DEFAULT_VENDOR} and
* {@link #DEFAULT_VERSION} and random generated
* {@link Target#getDescription()} in the repository.
*
* {@link #DEFAULT_VERSION} and random generated {@link Target#getDescription()}
* in the repository.
*
* @param typeKey
* of the {@link SoftwareModuleType}
* @param prefix
* added to name and version
*
* @return persisted {@link SoftwareModule}.
*/
public SoftwareModule createSoftwareModule(final String typeKey, final String prefix) {
@@ -619,28 +586,43 @@ public class TestdataFactory {
* @return persisted {@link Target}
*/
public Target createTarget(final String controllerId) {
final Target target = targetManagement.create(entityFactory.target().create().controllerId(controllerId));
return createTarget(controllerId, controllerId);
}
/**
* @param controllerId
* of the target
* @param targetName
* name of the target
* @return persisted {@link Target}
*/
public Target createTarget(final String controllerId, final String targetName) {
final Target target = targetManagement
.create(entityFactory.target().create().controllerId(controllerId).name(targetName));
assertTargetProperlyCreated(target);
return target;
}
private void assertTargetProperlyCreated(Target target) {
assertThat(target.getCreatedBy()).isNotNull();
assertThat(target.getCreatedAt()).isNotNull();
assertThat(target.getLastModifiedBy()).isNotNull();
assertThat(target.getLastModifiedAt()).isNotNull();
assertThat(target.getUpdateStatus()).isEqualTo(TargetUpdateStatus.UNKNOWN);
return target;
}
/**
* Creates {@link DistributionSet}s in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an
* iterative number and {@link DistributionSet#isRequiredMigrationStep()}
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an iterative
* number and {@link DistributionSet#isRequiredMigrationStep()}
* <code>false</code>.
*
* In addition it updates the created {@link DistributionSet}s and
* {@link SoftwareModule}s to ensure that
* {@link BaseEntity#getLastModifiedAt()} and
* {@link BaseEntity#getLastModifiedBy()} is filled.
*
* {@link SoftwareModule}s to ensure that {@link BaseEntity#getLastModifiedAt()}
* and {@link BaseEntity#getLastModifiedBy()} is filled.
*
* @return persisted {@link DistributionSet}.
*/
public DistributionSet createUpdatedDistributionSet() {
@@ -657,8 +639,8 @@ public class TestdataFactory {
/**
* @return {@link DistributionSetType} with key {@link #DS_TYPE_DEFAULT} and
* {@link SoftwareModuleType}s {@link #SM_TYPE_OS},
* {@link #SM_TYPE_RT} , {@link #SM_TYPE_APP}.
* {@link SoftwareModuleType}s {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP}.
*/
public DistributionSetType findOrCreateDefaultTestDsType() {
final List<SoftwareModuleType> mand = new ArrayList<>();
@@ -674,12 +656,11 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSetType} in repository.
*
*
* @param dsTypeKey
* {@link DistributionSetType#getKey()}
* @param dsTypeName
* {@link DistributionSetType#getName()}
*
* @return persisted {@link DistributionSetType}
*/
public DistributionSetType findOrCreateDistributionSetType(final String dsTypeKey, final String dsTypeName) {
@@ -691,7 +672,7 @@ public class TestdataFactory {
/**
* Finds {@link DistributionSetType} in repository with given
* {@link DistributionSetType#getKey()} or creates if it does not exist yet.
*
*
* @param dsTypeKey
* {@link DistributionSetType#getKey()}
* @param dsTypeName
@@ -700,7 +681,6 @@ public class TestdataFactory {
* {@link DistributionSetType#getMandatoryModuleTypes()}
* @param optional
* {@link DistributionSetType#getOptionalModuleTypes()}
*
* @return persisted {@link DistributionSetType}
*/
public DistributionSetType findOrCreateDistributionSetType(final String dsTypeKey, final String dsTypeName,
@@ -714,12 +694,11 @@ public class TestdataFactory {
/**
* Finds {@link SoftwareModuleType} in repository with given
* {@link SoftwareModuleType#getKey()} or creates if it does not exist yet
* with {@link SoftwareModuleType#getMaxAssignments()} = 1.
*
* {@link SoftwareModuleType#getKey()} or creates if it does not exist yet with
* {@link SoftwareModuleType#getMaxAssignments()} = 1.
*
* @param key
* {@link SoftwareModuleType#getKey()}
*
* @return persisted {@link SoftwareModuleType}
*/
public SoftwareModuleType findOrCreateSoftwareModuleType(final String key) {
@@ -729,12 +708,11 @@ public class TestdataFactory {
/**
* Finds {@link SoftwareModuleType} in repository with given
* {@link SoftwareModuleType#getKey()} or creates if it does not exist yet.
*
*
* @param key
* {@link SoftwareModuleType#getKey()}
* @param maxAssignments
* {@link SoftwareModuleType#getMaxAssignments()}
*
* @return persisted {@link SoftwareModuleType}
*/
public SoftwareModuleType findOrCreateSoftwareModuleType(final String key, final int maxAssignments) {
@@ -754,7 +732,6 @@ public class TestdataFactory {
* {@link DistributionSet#getType()}
* @param modules
* {@link DistributionSet#getModules()}
*
* @return the created {@link DistributionSet}
*/
public DistributionSet createDistributionSet(final String name, final String version,
@@ -777,7 +754,6 @@ public class TestdataFactory {
* {@link DistributionSet#getModules()}
* @param requiredMigrationStep
* {@link DistributionSet#isRequiredMigrationStep()}
*
* @return the created {@link DistributionSet}
*/
public DistributionSet generateDistributionSet(final String name, final String version,
@@ -799,7 +775,6 @@ public class TestdataFactory {
* {@link DistributionSet#getType()}
* @param modules
* {@link DistributionSet#getModules()}
*
* @return the created {@link DistributionSet}
*/
public DistributionSet generateDistributionSet(final String name, final String version,
@@ -812,7 +787,6 @@ public class TestdataFactory {
*
* @param name
* {@link DistributionSet#getName()}
*
* @return the generated {@link DistributionSet}
*/
public DistributionSet generateDistributionSet(final String name) {
@@ -821,13 +795,11 @@ public class TestdataFactory {
}
/**
* Creates {@link Target}s in repository and with
* {@link #DEFAULT_CONTROLLER_ID} as prefix for
* {@link Target#getControllerId()}.
*
* Creates {@link Target}s in repository and with {@link #DEFAULT_CONTROLLER_ID}
* as prefix for {@link Target#getControllerId()}.
*
* @param number
* of {@link Target}s to create
*
* @return {@link List} of {@link Target} entities
*/
public List<Target> createTargets(final int number) {
@@ -843,7 +815,7 @@ public class TestdataFactory {
/**
* Builds {@link Target} objects with given prefix for
* {@link Target#getControllerId()} followed by a number suffix.
*
*
* @param start
* value for the controllerId suffix
* @param numberOfTargets
@@ -863,9 +835,8 @@ public class TestdataFactory {
/**
* Builds {@link Target} objects with given prefix for
* {@link Target#getControllerId()} followed by a number suffix starting
* with 0.
*
* {@link Target#getControllerId()} followed by a number suffix starting with 0.
*
* @param numberOfTargets
* of {@link Target}s to generate
* @param controllerIdPrefix
@@ -955,10 +926,9 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSetTag}s in repository.
*
*
* @param number
* of {@link DistributionSetTag}s
*
* @return the persisted {@link DistributionSetTag}s
*/
public List<DistributionSetTag> createDistributionSetTags(final int number) {
@@ -980,16 +950,14 @@ public class TestdataFactory {
}
/**
* Append {@link ActionStatus} to all {@link Action}s of given
* {@link Target}s.
*
* Append {@link ActionStatus} to all {@link Action}s of given {@link Target}s.
*
* @param targets
* to add {@link ActionStatus}
* @param status
* to add
* @param message
* to add
*
* @return updated {@link Action}.
*/
public List<Action> sendUpdateActionStatusToTargets(final Collection<Target> targets, final Status status,
@@ -998,16 +966,14 @@ public class TestdataFactory {
}
/**
* Append {@link ActionStatus} to all {@link Action}s of given
* {@link Target}s.
*
* Append {@link ActionStatus} to all {@link Action}s of given {@link Target}s.
*
* @param targets
* to add {@link ActionStatus}
* @param status
* to add
* @param msgs
* to add
*
* @return updated {@link Action}.
*/
public List<Action> sendUpdateActionStatusToTargets(final Collection<Target> targets, final Status status,
@@ -1025,7 +991,7 @@ public class TestdataFactory {
/**
* Creates rollout based on given parameters.
*
*
* @param rolloutName
* of the {@link Rollout}
* @param rolloutDescription
@@ -1045,7 +1011,8 @@ public class TestdataFactory {
public Rollout createRolloutByVariables(final String rolloutName, final String rolloutDescription,
final int groupSize, final String filterQuery, final DistributionSet distributionSet,
final String successCondition, final String errorCondition) {
return createRolloutByVariables(rolloutName, rolloutDescription, groupSize, filterQuery, distributionSet, successCondition, errorCondition, Action.ActionType.FORCED);
return createRolloutByVariables(rolloutName, rolloutDescription, groupSize, filterQuery, distributionSet,
successCondition, errorCondition, Action.ActionType.FORCED);
}
/**
@@ -1077,9 +1044,10 @@ public class TestdataFactory {
.errorCondition(RolloutGroupErrorCondition.THRESHOLD, errorCondition)
.errorAction(RolloutGroupErrorAction.PAUSE, null).build();
final Rollout rollout = rolloutManagement.create(entityFactory.rollout().create().name(rolloutName)
.description(rolloutDescription).targetFilterQuery(filterQuery).set(distributionSet)
.actionType(actionType), groupSize, conditions);
final Rollout rollout = rolloutManagement.create(
entityFactory.rollout().create().name(rolloutName).description(rolloutDescription)
.targetFilterQuery(filterQuery).set(distributionSet).actionType(actionType),
groupSize, conditions);
// Run here, because Scheduler is disabled during tests
rolloutManagement.handleRollouts();
@@ -1090,10 +1058,10 @@ public class TestdataFactory {
/**
* Create {@link Rollout} with a new {@link DistributionSet} and
* {@link Target}s.
*
*
* @param prefix
* for rollouts name, description,
* {@link Target#getControllerId()} filter
* for rollouts name, description, {@link Target#getControllerId()}
* filter
* @return created {@link Rollout}
*/
public Rollout createRollout(final String prefix) {
@@ -1103,12 +1071,12 @@ public class TestdataFactory {
}
/**
* Create the soft deleted {@link Rollout} with a new
* {@link DistributionSet} and {@link Target}s.
*
* Create the soft deleted {@link Rollout} with a new {@link DistributionSet}
* and {@link Target}s.
*
* @param prefix
* for rollouts name, description,
* {@link Target#getControllerId()} filter
* for rollouts name, description, {@link Target#getControllerId()}
* filter
* @return created {@link Rollout}
*/
public Rollout createSoftDeletedRollout(final String prefix) {