Remove dependency net._01001111:jlorem (#1350)
* Remove dependency jlorem * Minor optimization * Minor optimization
This commit is contained in:
@@ -78,13 +78,10 @@ import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net._01001111.text.LoremIpsum;
|
||||
|
||||
/**
|
||||
* Data generator utility for tests.
|
||||
*/
|
||||
public class TestdataFactory {
|
||||
private static final LoremIpsum LOREM = new LoremIpsum();
|
||||
|
||||
public static final String VISIBLE_SM_MD_KEY = "visibleMetdataKey";
|
||||
public static final String VISIBLE_SM_MD_VALUE = "visibleMetdataValue";
|
||||
@@ -109,7 +106,7 @@ public class TestdataFactory {
|
||||
/**
|
||||
* Default {@link NamedEntity#getDescription()}.
|
||||
*/
|
||||
public static final String DEFAULT_DESCRIPTION = "Desc: " + LOREM.words(10);
|
||||
public static final String DEFAULT_DESCRIPTION = "Desc: " + randomDescriptionShort();
|
||||
|
||||
/**
|
||||
* Key of test default {@link DistributionSetType}.
|
||||
@@ -129,8 +126,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";
|
||||
|
||||
@@ -186,8 +183,8 @@ 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
|
||||
@@ -202,8 +199,8 @@ 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.
|
||||
@@ -214,8 +211,8 @@ 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
|
||||
@@ -229,8 +226,8 @@ 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
|
||||
@@ -247,8 +244,8 @@ 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,
|
||||
@@ -264,8 +261,8 @@ 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
|
||||
@@ -282,15 +279,16 @@ 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()}
|
||||
*
|
||||
@@ -301,20 +299,20 @@ public class TestdataFactory {
|
||||
|
||||
final SoftwareModule appMod = softwareModuleManagement.create(entityFactory.softwareModule().create()
|
||||
.type(findOrCreateSoftwareModuleType(SM_TYPE_APP, Integer.MAX_VALUE)).name(prefix + SM_TYPE_APP)
|
||||
.version(version + "." + new SecureRandom().nextInt(100)).description(LOREM.words(20))
|
||||
.version(version + "." + new SecureRandom().nextInt(100)).description(randomDescriptionLong())
|
||||
.vendor(prefix + " vendor Limited, California"));
|
||||
final SoftwareModule runtimeMod = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(findOrCreateSoftwareModuleType(SM_TYPE_RT))
|
||||
.name(prefix + "app runtime").version(version + "." + new SecureRandom().nextInt(100))
|
||||
.description(LOREM.words(20)).vendor(prefix + " vendor GmbH, Stuttgart, Germany"));
|
||||
.description(randomDescriptionLong()).vendor(prefix + " vendor GmbH, Stuttgart, Germany"));
|
||||
final SoftwareModule osMod = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(findOrCreateSoftwareModuleType(SM_TYPE_OS))
|
||||
.name(prefix + " Firmware").version(version + "." + new SecureRandom().nextInt(100))
|
||||
.description(LOREM.words(20)).vendor(prefix + " vendor Limited Inc, California"));
|
||||
.description(randomDescriptionLong()).vendor(prefix + " vendor Limited Inc, California"));
|
||||
|
||||
return distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name(prefix != null && prefix.length() > 0 ? prefix : "DS")
|
||||
.version(version).description(LOREM.words(10)).type(findOrCreateDefaultTestDsType())
|
||||
.version(version).description(randomDescriptionShort()).type(findOrCreateDefaultTestDsType())
|
||||
.modules(Arrays.asList(osMod.getId(), runtimeMod.getId(), appMod.getId()))
|
||||
.requiredMigrationStep(isRequiredMigrationStep));
|
||||
}
|
||||
@@ -351,7 +349,8 @@ public class TestdataFactory {
|
||||
* 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
|
||||
@@ -364,15 +363,15 @@ public class TestdataFactory {
|
||||
|
||||
return distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name(prefix != null && prefix.length() > 0 ? prefix : "DS")
|
||||
.version(version).description(LOREM.words(10)).type(findOrCreateDefaultTestDsType())
|
||||
.version(version).description(randomDescriptionShort()).type(findOrCreateDefaultTestDsType())
|
||||
.modules(modules.stream().map(SoftwareModule::getId).collect(Collectors.toList()))
|
||||
.requiredMigrationStep(isRequiredMigrationStep));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,
|
||||
@@ -399,9 +398,9 @@ 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
|
||||
@@ -415,7 +414,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
|
||||
@@ -427,7 +427,7 @@ public class TestdataFactory {
|
||||
for (int i = 0; i < number; i++) {
|
||||
sets.add(distributionSetManagement
|
||||
.create(entityFactory.distributionSet().create().name("DS" + i).version(DEFAULT_VERSION + "." + i)
|
||||
.description(LOREM.words(10)).type(findOrCreateDefaultTestDsType())));
|
||||
.description(randomDescriptionShort()).type(findOrCreateDefaultTestDsType())));
|
||||
}
|
||||
|
||||
return sets;
|
||||
@@ -435,9 +435,9 @@ 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
|
||||
@@ -477,8 +477,8 @@ 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.
|
||||
@@ -496,8 +496,8 @@ 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
|
||||
@@ -517,8 +517,8 @@ 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
|
||||
@@ -542,8 +542,8 @@ 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}
|
||||
@@ -555,9 +555,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}.
|
||||
@@ -567,9 +568,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.
|
||||
*
|
||||
* @param prefix
|
||||
* added to name and version
|
||||
@@ -582,9 +584,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}.
|
||||
@@ -594,9 +597,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.
|
||||
*
|
||||
* @param prefix
|
||||
* added to name and version
|
||||
@@ -610,8 +614,8 @@ 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}
|
||||
@@ -623,7 +627,7 @@ public class TestdataFactory {
|
||||
public SoftwareModule createSoftwareModule(final String typeKey, final String prefix, final boolean encrypted) {
|
||||
return softwareModuleManagement.create(entityFactory.softwareModule().create()
|
||||
.type(findOrCreateSoftwareModuleType(typeKey)).name(prefix + typeKey).version(prefix + DEFAULT_VERSION)
|
||||
.description(LOREM.words(10)).vendor(DEFAULT_VENDOR).encrypted(encrypted));
|
||||
.description(randomDescriptionShort()).vendor(DEFAULT_VENDOR).encrypted(encrypted));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -651,7 +655,7 @@ public class TestdataFactory {
|
||||
*/
|
||||
public Target createTarget(final String controllerId, final String targetName) {
|
||||
final Target target = targetManagement
|
||||
.create(entityFactory.target().create().controllerId(controllerId).name(targetName));
|
||||
.create(entityFactory.target().create().controllerId(controllerId).name(targetName));
|
||||
assertTargetProperlyCreated(target);
|
||||
return target;
|
||||
}
|
||||
@@ -690,14 +694,15 @@ 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>.
|
||||
*
|
||||
* 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}.
|
||||
*/
|
||||
@@ -715,8 +720,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<>();
|
||||
@@ -743,7 +748,7 @@ public class TestdataFactory {
|
||||
public DistributionSetType findOrCreateDistributionSetType(final String dsTypeKey, final String dsTypeName) {
|
||||
return distributionSetTypeManagement.getByKey(dsTypeKey)
|
||||
.orElseGet(() -> distributionSetTypeManagement.create(entityFactory.distributionSetType().create()
|
||||
.key(dsTypeKey).name(dsTypeName).description(LOREM.words(10)).colour("black")));
|
||||
.key(dsTypeKey).name(dsTypeName).description(randomDescriptionShort()).colour("black")));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -765,15 +770,15 @@ public class TestdataFactory {
|
||||
final Collection<SoftwareModuleType> mandatory, final Collection<SoftwareModuleType> optional) {
|
||||
return distributionSetTypeManagement.getByKey(dsTypeKey)
|
||||
.orElseGet(() -> distributionSetTypeManagement.create(entityFactory.distributionSetType().create()
|
||||
.key(dsTypeKey).name(dsTypeName).description(LOREM.words(10)).colour("black")
|
||||
.key(dsTypeKey).name(dsTypeName).description(randomDescriptionShort()).colour("black")
|
||||
.optional(optional.stream().map(SoftwareModuleType::getId).collect(Collectors.toList()))
|
||||
.mandatory(mandatory.stream().map(SoftwareModuleType::getId).collect(Collectors.toList()))));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()}
|
||||
@@ -796,9 +801,10 @@ public class TestdataFactory {
|
||||
* @return persisted {@link SoftwareModuleType}
|
||||
*/
|
||||
public SoftwareModuleType findOrCreateSoftwareModuleType(final String key, final int maxAssignments) {
|
||||
return softwareModuleTypeManagement.getByKey(key).orElseGet(
|
||||
() -> softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key(key).name(key)
|
||||
.description(LOREM.words(10)).colour("#ffffff").maxAssignments(maxAssignments)));
|
||||
return softwareModuleTypeManagement.getByKey(key)
|
||||
.orElseGet(() -> softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create()
|
||||
.key(key).name(key).description(randomDescriptionShort()).colour("#ffffff")
|
||||
.maxAssignments(maxAssignments)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -817,9 +823,9 @@ public class TestdataFactory {
|
||||
*/
|
||||
public DistributionSet createDistributionSet(final String name, final String version,
|
||||
final DistributionSetType type, final Collection<SoftwareModule> modules) {
|
||||
return distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name(name).version(version).description(LOREM.words(10))
|
||||
.type(type).modules(modules.stream().map(SoftwareModule::getId).collect(Collectors.toList())));
|
||||
return distributionSetManagement.create(entityFactory.distributionSet().create().name(name).version(version)
|
||||
.description(randomDescriptionShort()).type(type)
|
||||
.modules(modules.stream().map(SoftwareModule::getId).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -841,8 +847,9 @@ public class TestdataFactory {
|
||||
public DistributionSet generateDistributionSet(final String name, final String version,
|
||||
final DistributionSetType type, final Collection<SoftwareModule> modules,
|
||||
final boolean requiredMigrationStep) {
|
||||
return entityFactory.distributionSet().create().name(name).version(version).description(LOREM.words(10))
|
||||
.type(type).modules(modules.stream().map(SoftwareModule::getId).collect(Collectors.toList()))
|
||||
return entityFactory.distributionSet().create().name(name).version(version)
|
||||
.description(randomDescriptionShort()).type(type)
|
||||
.modules(modules.stream().map(SoftwareModule::getId).collect(Collectors.toList()))
|
||||
.requiredMigrationStep(requiredMigrationStep).build();
|
||||
}
|
||||
|
||||
@@ -879,8 +886,9 @@ 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
|
||||
@@ -966,7 +974,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
|
||||
@@ -1014,7 +1023,8 @@ public class TestdataFactory {
|
||||
}
|
||||
|
||||
private List<Target> createTargets(final Collection<TargetCreate> targetCreates) {
|
||||
// init new instance of array list since the TargetManagement#create will
|
||||
// init new instance of array list since the TargetManagement#create
|
||||
// will
|
||||
// provide a unmodifiable list
|
||||
final List<Target> createdTargets = targetManagement.create(targetCreates);
|
||||
return new ArrayList<>(createdTargets);
|
||||
@@ -1091,7 +1101,8 @@ 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}
|
||||
@@ -1108,7 +1119,8 @@ 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}
|
||||
@@ -1187,8 +1199,8 @@ public class TestdataFactory {
|
||||
* @param weight
|
||||
* weight of the Rollout
|
||||
* @param confirmationRequired
|
||||
* if the confirmation is required (considered with confirmation flow
|
||||
* active)
|
||||
* if the confirmation is required (considered with confirmation
|
||||
* flow active)
|
||||
* @return created {@link Rollout}
|
||||
*/
|
||||
public Rollout createRolloutByVariables(final String rolloutName, final String rolloutDescription,
|
||||
@@ -1216,8 +1228,8 @@ public class TestdataFactory {
|
||||
* {@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) {
|
||||
@@ -1338,17 +1350,17 @@ public class TestdataFactory {
|
||||
createTargets(amountTargetsForRollout, "rollout-" + suffix + "-", "rollout");
|
||||
createTargets(amountOtherTargets, "others-" + suffix + "-", "rollout");
|
||||
final String filterQuery = "controllerId==rollout-" + suffix + "-*";
|
||||
return createRolloutByVariables("rollout-" + suffix, "test-rollout-description", amountOfGroups,
|
||||
filterQuery, rolloutDS, successCondition, errorCondition, actionType, weight, false);
|
||||
return createRolloutByVariables("rollout-" + suffix, "test-rollout-description", amountOfGroups, filterQuery,
|
||||
rolloutDS, successCondition, errorCondition, actionType, weight, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
@@ -1362,8 +1374,8 @@ public class TestdataFactory {
|
||||
|
||||
/**
|
||||
* Finds {@link TargetType} in repository with given
|
||||
* {@link TargetType#getName()} or creates if it does not exist yet. No ds types
|
||||
* are assigned on creation.
|
||||
* {@link TargetType#getName()} or creates if it does not exist yet. No ds
|
||||
* types are assigned on creation.
|
||||
*
|
||||
* @param targetTypeName
|
||||
* {@link TargetType#getName()}
|
||||
@@ -1378,8 +1390,8 @@ public class TestdataFactory {
|
||||
|
||||
/**
|
||||
* Creates {@link TargetType} in repository with given
|
||||
* {@link TargetType#getName()}. Compatible distribution set types are assigned
|
||||
* on creation
|
||||
* {@link TargetType#getName()}. Compatible distribution set types are
|
||||
* assigned on creation
|
||||
*
|
||||
* @param targetTypeName
|
||||
* {@link TargetType#getName()}
|
||||
@@ -1411,8 +1423,8 @@ public class TestdataFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a distribution set and directly invalidates it. No actions will be
|
||||
* canceled and no rollouts will be stopped with this invalidation.
|
||||
* Creates a distribution set and directly invalidates it. No actions will
|
||||
* be canceled and no rollouts will be stopped with this invalidation.
|
||||
*
|
||||
* @return created invalidated {@link DistributionSet}
|
||||
*/
|
||||
@@ -1424,14 +1436,27 @@ public class TestdataFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a distribution set that has no software modules assigned, so it is
|
||||
* incomplete.
|
||||
* Creates a distribution set that has no software modules assigned, so it
|
||||
* is incomplete.
|
||||
*
|
||||
* @return created incomplete {@link DistributionSet}
|
||||
*/
|
||||
public DistributionSet createIncompleteDistributionSet() {
|
||||
return distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name(UUID.randomUUID().toString()).version(DEFAULT_VERSION).description(LOREM.words(10))
|
||||
.name(UUID.randomUUID().toString()).version(DEFAULT_VERSION).description(randomDescriptionShort())
|
||||
.type(findOrCreateDefaultTestDsType()).requiredMigrationStep(false));
|
||||
}
|
||||
|
||||
private static String randomDescriptionShort() {
|
||||
return randomText(100);
|
||||
}
|
||||
|
||||
private static String randomDescriptionLong() {
|
||||
return randomText(200);
|
||||
}
|
||||
|
||||
private static String randomText(final int len) {
|
||||
return RandomStringUtils.randomAlphanumeric(len);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user