Signed-off-by: Dominic Schabel <dominic.schabel@bosch-si.com>
This commit is contained in:
committed by
Stefan Behl
parent
af0f7ceb5a
commit
80509158eb
@@ -453,15 +453,23 @@ public abstract class JsonBuilder {
|
||||
}
|
||||
|
||||
public static String rollout(final String name, final String description, final Integer groupSize,
|
||||
final long distributionSetId, final String targetFilterQuery, final RolloutGroupConditions conditions,
|
||||
final List<RolloutGroup> groups) {
|
||||
final long distributionSetId, final String targetFilterQuery, final RolloutGroupConditions conditions,
|
||||
final List<RolloutGroup> groups) {
|
||||
return rollout(name, description, groupSize, distributionSetId, targetFilterQuery, conditions, groups, null);
|
||||
}
|
||||
|
||||
public static String rollout(final String name, final String description, final Integer groupSize,
|
||||
final long distributionSetId, final String targetFilterQuery, final RolloutGroupConditions conditions,
|
||||
final List<RolloutGroup> groups, final String type) {
|
||||
final long distributionSetId, final String targetFilterQuery, final RolloutGroupConditions conditions,
|
||||
final String type) {
|
||||
return rollout(name, description, groupSize, distributionSetId, targetFilterQuery, conditions, null, type);
|
||||
}
|
||||
|
||||
public static String rollout(final String name, final String description, final Integer groupSize,
|
||||
final long distributionSetId, final String targetFilterQuery, final RolloutGroupConditions conditions,
|
||||
final List<RolloutGroup> groups, final String type) {
|
||||
|
||||
final JSONObject json = new JSONObject();
|
||||
|
||||
try {
|
||||
json.put("name", name);
|
||||
json.put("description", description);
|
||||
@@ -469,7 +477,7 @@ public abstract class JsonBuilder {
|
||||
json.put("distributionSetId", distributionSetId);
|
||||
json.put("targetFilterQuery", targetFilterQuery);
|
||||
|
||||
if(type != null){
|
||||
if (type != null) {
|
||||
json.put("type", type);
|
||||
}
|
||||
|
||||
@@ -536,7 +544,6 @@ public abstract class JsonBuilder {
|
||||
}
|
||||
|
||||
json.put("groups", jsonGroups);
|
||||
|
||||
}
|
||||
|
||||
} catch (final JSONException e) {
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
@@ -50,8 +52,6 @@ import org.springframework.restdocs.payload.FieldDescriptor;
|
||||
import org.springframework.restdocs.payload.JsonFieldType;
|
||||
import org.springframework.restdocs.snippet.Snippet;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
@@ -106,7 +106,7 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
||||
}
|
||||
|
||||
private Snippet getRolloutResponseFields(final boolean isArray, final boolean withDetails,
|
||||
final FieldDescriptor... descriptors) throws JsonProcessingException {
|
||||
final FieldDescriptor... descriptors) {
|
||||
final String arrayPrefix = getArrayPrefix(isArray);
|
||||
final List<FieldDescriptor> allFieldDescriptor = new ArrayList<>();
|
||||
allFieldDescriptor.addAll(Arrays.asList(descriptors));
|
||||
@@ -148,8 +148,8 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
||||
.description(MgmtApiModelProperties.ROLLOUT_LINKS_GROUPS));
|
||||
allFieldDescriptor.add(fieldWithPath(arrayPrefix + "_links.approve")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_LINKS_APPROVE));
|
||||
allFieldDescriptor.add(fieldWithPath(arrayPrefix + "_links.deny")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_LINKS_DENY));
|
||||
allFieldDescriptor.add(
|
||||
fieldWithPath(arrayPrefix + "_links.deny").description(MgmtApiModelProperties.ROLLOUT_LINKS_DENY));
|
||||
}
|
||||
|
||||
return new DocumenationResponseFieldsSnippet(allFieldDescriptor);
|
||||
@@ -176,55 +176,66 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
||||
testdataFactory.createTargets(20, "targets-");
|
||||
|
||||
final String name = "exampleRollout";
|
||||
final String type = "forced";
|
||||
final String description = "Rollout for all named targets";
|
||||
final int groupSize = 10;
|
||||
final Long dsId = testdataFactory.createDistributionSet().getId();
|
||||
final String targetFilter = "id==targets-*";
|
||||
|
||||
final RolloutGroupConditions rolloutGroupConditions = new RolloutGroupConditionBuilder()
|
||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "50")
|
||||
.successAction(RolloutGroupSuccessAction.NEXTGROUP, "")
|
||||
.errorCondition(RolloutGroupErrorCondition.THRESHOLD, "80")
|
||||
.errorAction(RolloutGroupErrorAction.PAUSE, "").build();
|
||||
mockMvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING)
|
||||
.content(JsonBuilder.rollout(name, description, groupSize, dsId, targetFilter, rolloutGroupConditions))
|
||||
.contentType(MediaTypes.HAL_JSON_UTF8).accept(MediaTypes.HAL_JSON_VALUE))
|
||||
|
||||
mockMvc.perform(
|
||||
post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING)
|
||||
.content(JsonBuilder.rollout(name, description, groupSize, dsId, targetFilter,
|
||||
rolloutGroupConditions, type))
|
||||
.contentType(MediaTypes.HAL_JSON_UTF8).accept(MediaTypes.HAL_JSON_VALUE))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
|
||||
.andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8))
|
||||
.andDo(this.document.document(requestFields(
|
||||
requestFieldWithPath("name").description(ApiModelPropertiesGeneric.NAME),
|
||||
requestFieldWithPath("distributionSetId").description(MgmtApiModelProperties.ROLLOUT_DS_ID),
|
||||
requestFieldWithPath("targetFilterQuery")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_FILTER_QUERY),
|
||||
requestFieldWithPath("amountGroups").description(MgmtApiModelProperties.ROLLOUT_AMOUNT_GROUPS),
|
||||
optionalRequestFieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION),
|
||||
optionalRequestFieldWithPath("successCondition")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION),
|
||||
optionalRequestFieldWithPath("successCondition.condition")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION_CONDITION)
|
||||
.attributes(key("value").value("['threshold']")),
|
||||
optionalRequestFieldWithPath("successCondition.expression")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION_EXP),
|
||||
optionalRequestFieldWithPath("successAction")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION),
|
||||
optionalRequestFieldWithPath("successAction.action")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION_ACTION)
|
||||
.attributes(key("value").value("['nextgroup']")),
|
||||
optionalRequestFieldWithPath("successAction.expression")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION_EXP),
|
||||
optionalRequestFieldWithPath("errorCondition")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION),
|
||||
optionalRequestFieldWithPath("errorCondition.condition")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION_CONDITION)
|
||||
.attributes(key("value").value("['threshold']")),
|
||||
optionalRequestFieldWithPath("errorCondition.expression")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION_EXP),
|
||||
optionalRequestFieldWithPath("errorAction")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION),
|
||||
optionalRequestFieldWithPath("errorAction.action")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION_ACTION)
|
||||
.attributes(key("value").value("['pause']")),
|
||||
optionalRequestFieldWithPath("errorAction.expression")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION_EXP)),
|
||||
.andDo(this.document.document(
|
||||
requestFields(requestFieldWithPath("name").description(ApiModelPropertiesGeneric.NAME),
|
||||
optionalRequestFieldWithPath("type").description(
|
||||
MgmtApiModelProperties.ROLLOUT_TYPE).attributes(
|
||||
key("value").value("['soft', 'forced', 'timeforced', 'downloadonly']")),
|
||||
requestFieldWithPath("distributionSetId")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_DS_ID),
|
||||
requestFieldWithPath("targetFilterQuery")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_FILTER_QUERY),
|
||||
requestFieldWithPath("amountGroups")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_AMOUNT_GROUPS),
|
||||
optionalRequestFieldWithPath("description")
|
||||
.description(ApiModelPropertiesGeneric.DESCRPTION),
|
||||
optionalRequestFieldWithPath("successCondition")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION),
|
||||
optionalRequestFieldWithPath("successCondition.condition")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION_CONDITION)
|
||||
.attributes(key("value").value("['threshold']")),
|
||||
optionalRequestFieldWithPath("successCondition.expression")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_SUCCESS_CONDITION_EXP),
|
||||
optionalRequestFieldWithPath("successAction")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION),
|
||||
optionalRequestFieldWithPath("successAction.action")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION_ACTION)
|
||||
.attributes(key("value").value("['nextgroup']")),
|
||||
optionalRequestFieldWithPath("successAction.expression")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_SUCCESS_ACTION_EXP),
|
||||
optionalRequestFieldWithPath("errorCondition")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION),
|
||||
optionalRequestFieldWithPath("errorCondition.condition")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION_CONDITION)
|
||||
.attributes(key("value").value("['threshold']")),
|
||||
optionalRequestFieldWithPath("errorCondition.expression")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_ERROR_CONDITION_EXP),
|
||||
optionalRequestFieldWithPath("errorAction")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION),
|
||||
optionalRequestFieldWithPath("errorAction.action")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION_ACTION)
|
||||
.attributes(key("value").value("['pause']")),
|
||||
optionalRequestFieldWithPath("errorAction.expression")
|
||||
.description(MgmtApiModelProperties.ROLLOUT_ERROR_ACTION_EXP)),
|
||||
|
||||
getRolloutResponseFields(false, true)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user