Configurable basic scenario.

Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-06-10 08:37:56 +02:00
parent ec25f2961e
commit d5e591a4a6
11 changed files with 264 additions and 177 deletions

View File

@@ -84,32 +84,48 @@ public class DistributionSetBuilder {
* @return a single entry list of {@link MgmtDistributionSetRequestBodyPost}
*/
public List<MgmtDistributionSetRequestBodyPost> build() {
return Lists.newArrayList(doBuild(name));
return Lists.newArrayList(doBuild(""));
}
/**
* Builds a list of multiple {@link MgmtDistributionSetRequestBodyPost} to
* create multiple distribution sets at once. An increasing number will be
* added to the name of the distribution set. The version and type will
* remain the same.
* used for version of the distribution set. The name and type will remain
* the same.
*
* @param count
* the amount of distribution sets body which should be created
* @return a list of {@link MgmtDistributionSetRequestBodyPost}
*/
public List<MgmtDistributionSetRequestBodyPost> buildAsList(final int count) {
return buildAsList(0, count);
}
/**
* Builds a list of multiple {@link MgmtDistributionSetRequestBodyPost} to
* create multiple distribution sets at once. An increasing number will be
* used for version of the distribution set starting from given offset. The
* name and type will remain the same.
*
* @param count
* the amount of distribution sets body which should be created
* @param offset
* for for index start
* @return a list of {@link MgmtDistributionSetRequestBodyPost}
*/
public List<MgmtDistributionSetRequestBodyPost> buildAsList(final int offset, final int count) {
final ArrayList<MgmtDistributionSetRequestBodyPost> bodyList = Lists.newArrayList();
for (int index = 0; index < count; index++) {
bodyList.add(doBuild(name + index));
for (int index = offset; index < count + offset; index++) {
bodyList.add(doBuild(String.valueOf(index)));
}
return bodyList;
}
private MgmtDistributionSetRequestBodyPost doBuild(final String prefixName) {
private MgmtDistributionSetRequestBodyPost doBuild(final String suffix) {
final MgmtDistributionSetRequestBodyPost body = new MgmtDistributionSetRequestBodyPost();
body.setName(prefixName);
body.setVersion(version);
body.setName(name);
body.setVersion(version + suffix);
body.setType(type);
body.setDescription(description);
body.setModules(modules);

View File

@@ -101,7 +101,7 @@ public class DistributionSetTypeBuilder {
* {@link MgmtDistributionSetTypeRequestBodyPost}
*/
public List<MgmtDistributionSetTypeRequestBodyPost> build() {
return Lists.newArrayList(doBuild(name, key));
return Lists.newArrayList(doBuild(""));
}
/**
@@ -118,16 +118,16 @@ public class DistributionSetTypeBuilder {
public List<MgmtDistributionSetTypeRequestBodyPost> buildAsList(final int count) {
final ArrayList<MgmtDistributionSetTypeRequestBodyPost> bodyList = Lists.newArrayList();
for (int index = 0; index < count; index++) {
bodyList.add(doBuild(name + index, key + index));
bodyList.add(doBuild(String.valueOf(index)));
}
return bodyList;
}
private MgmtDistributionSetTypeRequestBodyPost doBuild(final String prefixName, final String prefixKey) {
private MgmtDistributionSetTypeRequestBodyPost doBuild(final String suffix) {
final MgmtDistributionSetTypeRequestBodyPost body = new MgmtDistributionSetTypeRequestBodyPost();
body.setKey(prefixKey);
body.setName(prefixName);
body.setKey(key + suffix);
body.setName(name + suffix);
body.setDescription(description);
body.setMandatorymodules(mandatorymodules);
body.setOptionalmodules(optionalmodules);

View File

@@ -96,7 +96,7 @@ public class SoftwareModuleBuilder {
/**
* Builds a list of multiple {@link MgmtSoftwareModuleRequestBodyPost} to
* create multiple software module at once. An increasing number will be
* added to the name of the software module. The version and type will
* added to the version of the software module. The name and type will
* remain the same.
*
* @param count
@@ -106,16 +106,16 @@ public class SoftwareModuleBuilder {
public List<MgmtSoftwareModuleRequestBodyPost> buildAsList(final int count) {
final ArrayList<MgmtSoftwareModuleRequestBodyPost> bodyList = Lists.newArrayList();
for (int index = 0; index < count; index++) {
bodyList.add(doBuild(name + index));
bodyList.add(doBuild(String.valueOf(index)));
}
return bodyList;
}
private MgmtSoftwareModuleRequestBodyPost doBuild(final String prefixName) {
private MgmtSoftwareModuleRequestBodyPost doBuild(final String suffix) {
final MgmtSoftwareModuleRequestBodyPost body = new MgmtSoftwareModuleRequestBodyPost();
body.setName(prefixName);
body.setVersion(version);
body.setName(name);
body.setVersion(version + suffix);
body.setType(type);
body.setVendor(vendor);
body.setDescription(description);

View File

@@ -69,7 +69,7 @@ public class SoftwareModuleTypeBuilder {
* {@link MgmtSoftwareModuleTypeRequestBodyPost}
*/
public List<MgmtSoftwareModuleTypeRequestBodyPost> build() {
return Lists.newArrayList(doBuild(key, name));
return Lists.newArrayList(doBuild(""));
}
/**
@@ -85,15 +85,15 @@ public class SoftwareModuleTypeBuilder {
public List<MgmtSoftwareModuleTypeRequestBodyPost> buildAsList(final int count) {
final ArrayList<MgmtSoftwareModuleTypeRequestBodyPost> bodyList = Lists.newArrayList();
for (int index = 0; index < count; index++) {
bodyList.add(doBuild(key + index, name + index));
bodyList.add(doBuild(String.valueOf(index)));
}
return bodyList;
}
private MgmtSoftwareModuleTypeRequestBodyPost doBuild(final String prefixKey, final String prefixName) {
private MgmtSoftwareModuleTypeRequestBodyPost doBuild(final String suffix) {
final MgmtSoftwareModuleTypeRequestBodyPost body = new MgmtSoftwareModuleTypeRequestBodyPost();
body.setKey(prefixKey);
body.setName(prefixName);
body.setKey(key + suffix);
body.setName(name + suffix);
body.setDescription(description);
body.setMaxAssignments(maxAssignments);
return body;

View File

@@ -8,7 +8,6 @@
*/
package org.eclipse.hawkbit.mgmt.client.resource.builder;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost;
@@ -65,32 +64,62 @@ public class TargetBuilder {
*
* @return a single entry list of {@link MgmtTargetRequestBody}
*/
public List<MgmtTargetRequestBody> build() {
return Lists.newArrayList(doBuild(controllerId));
public List<MgmtTargetRequestBody> buildAsList() {
return Lists.newArrayList(doBuild(""));
}
/**
* Builds a single {@link MgmtTargetRequestBody}.
*
* @return build {@link MgmtTargetRequestBody}
*/
public MgmtTargetRequestBody build() {
return doBuild("");
}
/**
* Builds a list of multiple {@link MgmtTargetRequestBody} to create
* multiple targets at once. An increasing number will be added to the
* controllerId of the target. The name and description will remain.
* controllerId and name of the target. The description will remain.
*
* @param count
* the amount of software module type bodies which should be
* created
* the amount of target bodies which should be created
* @param offset
* for
* @return a list of {@link MgmtSoftwareModuleTypeRequestBodyPost}
*/
public List<MgmtTargetRequestBody> buildAsList(final int count) {
final ArrayList<MgmtTargetRequestBody> bodyList = Lists.newArrayList();
for (int index = 0; index < count; index++) {
bodyList.add(doBuild(controllerId + index));
return buildAsList(0, count);
}
/**
* Builds a list of multiple {@link MgmtTargetRequestBody} to create
* multiple targets at once. An increasing number will be added to the
* controllerId and name of the target starting from the provided offset.
* The description will remain.
*
* @param count
* the amount of target bodies which should be created
* @param offset
* for for index start
* @return a list of {@link MgmtSoftwareModuleTypeRequestBodyPost}
*/
public List<MgmtTargetRequestBody> buildAsList(final int offset, final int count) {
final List<MgmtTargetRequestBody> bodyList = Lists.newArrayList();
for (int index = offset; index < count + offset; index++) {
bodyList.add(doBuild(String.valueOf(index)));
}
return bodyList;
}
private MgmtTargetRequestBody doBuild(final String prefixControllerId) {
private MgmtTargetRequestBody doBuild(final String suffix) {
final MgmtTargetRequestBody body = new MgmtTargetRequestBody();
body.setControllerId(prefixControllerId);
body.setName(name);
body.setControllerId(controllerId + suffix);
if (name == null) {
name = controllerId;
}
body.setName(name + suffix);
body.setDescription(description);
return body;
}