Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActionInputsHelper: Add unit symbol to Quantity parameter description #4419

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public List<ConfigDescriptionParameter> mapActionInputsToConfigDescriptionParame
public ConfigDescriptionParameter mapActionInputToConfigDescriptionParameter(Input input)
throws IllegalArgumentException {
ConfigDescriptionParameter.Type parameterType = ConfigDescriptionParameter.Type.TEXT;
String description = input.getDescription();
String defaultValue = null;
Unit<?> unit = null;
boolean required = false;
Expand All @@ -107,6 +108,10 @@ public ConfigDescriptionParameter mapActionInputToConfigDescriptionParameter(Inp
parameterType = ConfigDescriptionParameter.Type.DECIMAL;
try {
unit = getDefaultUnit(matcher.group("dimension"));
String symbol = unit.getSymbol();
if (symbol != null) {
description += " (" + unit + ")";
}
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Input parameter '" + input.getName() + "' with type "
+ input.getType() + "cannot be converted into a config description parameter!", e);
Expand Down Expand Up @@ -167,9 +172,8 @@ public ConfigDescriptionParameter mapActionInputToConfigDescriptionParameter(Inp
}

ConfigDescriptionParameterBuilder builder = ConfigDescriptionParameterBuilder
.create(input.getName(), parameterType).withLabel(input.getLabel())
.withDescription(input.getDescription()).withReadOnly(false)
.withRequired(required || input.isRequired()).withContext(context);
.create(input.getName(), parameterType).withLabel(input.getLabel()).withDescription(description)
.withReadOnly(false).withRequired(required || input.isRequired()).withContext(context);
if (input.getDefaultValue() != null && !input.getDefaultValue().isEmpty()) {
builder = builder.withDefault(input.getDefaultValue());
} else if (defaultValue != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@ private void checkParameter(ConfigDescriptionParameter param, String name, Confi
@Nullable String unit) {
assertThat(param.getName(), is(name));
assertThat(param.getLabel(), is(label));
if (unit != null) {
description += " (" + unit + ")";
}
assertThat(param.getDescription(), is(description));
assertThat(param.getType(), is(type));
assertThat(param.isReadOnly(), is(false));
Expand Down