Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Update name to verify/isVerifyable and add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Jackson <chris@cd-jackson.com>
  • Loading branch information
cdjackson committed Mar 12, 2017
1 parent b86a4f9 commit 83ab3c1
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ConfigDescriptionParameterBuilderTest {
def max = new BigDecimal(4.0);
def stepSize = new BigDecimal(1.0);
def pattern = "pattern"
def verify = true;
def required = false
def readOnly = true
def multiple = false
Expand Down Expand Up @@ -67,6 +68,7 @@ class ConfigDescriptionParameterBuilderTest {
.withMultipleLimit(multipleLimit)
.withUnit(unit)
.withUnitLabel(unitLabel)
.withVerify(verify)
.build();
assertThat param.getMinimum(), is(min)
assertThat param.getMaximum(), is(max)
Expand All @@ -85,6 +87,7 @@ class ConfigDescriptionParameterBuilderTest {
assertFalse param.isRequired()
assertTrue param.isReadOnly()
assertFalse param.isMultiple()
assertTrue param.isVerifyable()
assertFalse param.isAdvanced()
assertTrue param.getLimitToOptions()

Expand All @@ -102,6 +105,7 @@ class ConfigDescriptionParameterBuilderTest {
.withRequired(null)
.withReadOnly(null)
.withMultiple(null)
.withVerify(null)
.withContext(null)
.withDefault(null)
.withLabel(null)
Expand Down Expand Up @@ -141,7 +145,7 @@ class ConfigDescriptionParameterBuilderTest {
null, null, null, null, null, null,
null, null, null, null,
null, null, null,null,
null, null, null)
null, null, null, null)
assertFalse param2.isRequired()
assertFalse param2.isReadOnly()
assertFalse param2.isMultiple()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @author Alex Tugarev - Added options, filter criteria, and more parameter
* attributes
* @author Chris Jackson - Added groupId, limitToOptions, advanced,
* multipleLimit, critical attributes
* multipleLimit, verify attributes
* @author Christoph Knauf - Added default constructor, changed Boolean
* getter to return primitive types
* @author Thomas Höfer - Added unit
Expand Down Expand Up @@ -90,7 +90,7 @@ public enum Type {

private boolean limitToOptions = false;
private boolean advanced = false;
private boolean critical = false;
private boolean verify = false;

private static final Set<String> UNITS = Collections
.unmodifiableSet(new HashSet<String>(Arrays.asList("A", "cd", "K", "kg", "m", "mol", "s", "g", "rad", "sr",
Expand Down Expand Up @@ -198,7 +198,7 @@ public ConfigDescriptionParameter(String name, Type type) throws IllegalArgument
String pattern, Boolean required, Boolean readOnly, Boolean multiple, String context, String defaultValue,
String label, String description, List<ParameterOption> options, List<FilterCriteria> filterCriteria,
String groupName, Boolean advanced, Boolean limitToOptions, Integer multipleLimit, String unit,
String unitLabel, Boolean critical) throws IllegalArgumentException {
String unitLabel, Boolean verify) throws IllegalArgumentException {

if ((name == null) || (name.isEmpty())) {
throw new IllegalArgumentException("The name must neither be null nor empty!");
Expand Down Expand Up @@ -230,8 +230,10 @@ public ConfigDescriptionParameter(String name, Type type) throws IllegalArgument
this.multipleLimit = multipleLimit;
this.unit = unit;
this.unitLabel = unitLabel;
this.critical = critical;

if (verify != null) {
this.verify = verify;
}
if (readOnly != null) {
this.readOnly = readOnly;
}
Expand Down Expand Up @@ -459,13 +461,13 @@ public String getUnitLabel() {
}

/**
* Returns the critical flag for this parameter. Critical parameters are considered dangerous and the user should be
* Returns the verify flag for this parameter. Verify parameters are considered dangerous and the user should be
* alerted with an "Are you sure" flag in the UI.
*
* @return true if the parameter is considered critical
* @return true if the parameter requires verification in the UI
*/
public Boolean isCritical() {
return critical;
public Boolean isVerifyable() {
return verify;
}

@Override
Expand Down Expand Up @@ -510,6 +512,10 @@ public String toString() {
sb.append("required=");
sb.append(required);

sb.append(", ");
sb.append("verify=");
sb.append(verify);

sb.append(", ");
sb.append("multiple=");
sb.append(multiple);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class ConfigDescriptionParameterBuilder {

private Boolean limitToOptions;
private Boolean advanced;
private Boolean critical;
private Boolean verify;

private List<ParameterOption> options = new ArrayList<ParameterOption>();
private List<FilterCriteria> filterCriteria = new ArrayList<FilterCriteria>();
Expand Down Expand Up @@ -207,12 +207,12 @@ public ConfigDescriptionParameterBuilder withAdvanced(Boolean advanced) {
}

/**
* Set the configuration parameter as a critical parameter
* Set the configuration parameter as a verifyable parameter
*
* @param critical flag
* @param verify flag
*/
public ConfigDescriptionParameterBuilder withCritical(Boolean critical) {
this.critical = critical;
public ConfigDescriptionParameterBuilder withVerify(Boolean verify) {
this.verify = verify;
return this;
}

Expand Down Expand Up @@ -278,7 +278,7 @@ public ConfigDescriptionParameterBuilder withUnitLabel(String unitLabel) {
public ConfigDescriptionParameter build() throws IllegalArgumentException {
return new ConfigDescriptionParameter(name, type, min, max, step, pattern, required, readOnly, multiple,
context, defaultValue, label, description, options, filterCriteria, groupName, advanced, limitToOptions,
multipleLimit, unit, unitLabel, critical);
multipleLimit, unit, unitLabel, verify);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private ConfigDescriptionParameter getConfigOptions(URI uri, ConfigDescriptionPa
parameter.getLabel(), parameter.getDescription(), options, parameter.getFilterCriteria(),
parameter.getGroupName(), parameter.isAdvanced(), parameter.getLimitToOptions(),
parameter.getMultipleLimit(), parameter.getUnit(), parameter.getUnitLabel(),
parameter.isCritical());
parameter.isVerifyable());
} else {
// Otherwise return the original parameter
return parameter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static List<ConfigDescriptionParameterDTO> mapParameters(List<ConfigDescr
configDescriptionParameter.getGroupName(), configDescriptionParameter.isAdvanced(),
configDescriptionParameter.getLimitToOptions(), configDescriptionParameter.getMultipleLimit(),
configDescriptionParameter.getUnit(), configDescriptionParameter.getUnitLabel(),
configDescriptionParameter.isCritical());
configDescriptionParameter.isVerifyable());
configDescriptionParameterBeans.add(configDescriptionParameterBean);
}
return configDescriptionParameterBeans;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Dennis Nobel - Initial contribution
* @author Alex Tugarev - Extended for options and filter criteria
* @author Chris Jackson - Added group, advanced, limitToOptions, multipleLimit, critical attributes
* @author Chris Jackson - Added group, advanced, limitToOptions, multipleLimit, verify attributes
* @author Thomas Höfer - Added unit
*/
public class ConfigDescriptionParameterDTO {
Expand All @@ -39,7 +39,7 @@ public class ConfigDescriptionParameterDTO {
public Integer multipleLimit;
public String groupName;
public Boolean advanced;
public Boolean critical;
public Boolean verify;
public Boolean limitToOptions;
public String unit;
public String unitLabel;
Expand All @@ -54,7 +54,7 @@ public ConfigDescriptionParameterDTO(String name, Type type, BigDecimal minimum,
BigDecimal stepsize, String pattern, Boolean required, Boolean readOnly, Boolean multiple, String context,
String defaultValue, String label, String description, List<ParameterOptionDTO> options,
List<FilterCriteriaDTO> filterCriteria, String groupName, Boolean advanced, Boolean limitToOptions,
Integer multipleLimit, String unit, String unitLabel, Boolean critical) {
Integer multipleLimit, String unit, String unitLabel, Boolean verify) {
this.name = name;
this.type = type;
this.min = minimum;
Expand All @@ -76,7 +76,7 @@ public ConfigDescriptionParameterDTO(String name, Type type, BigDecimal minimum,
this.multipleLimit = multipleLimit;
this.unit = unit;
this.unitLabel = unitLabel;
this.critical = critical;
this.verify = verify;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class ConfigDescriptionsTest extends OSGiTest {
assertThat min, is(8 as BigDecimal)
assertThat max, is(16 as BigDecimal)
assertThat required, is(true)
assertThat verify, is(true)
assertThat multiple, is(false)
assertThat readOnly, is(false)
assertThat context, is("password")
Expand Down Expand Up @@ -133,6 +134,7 @@ class ConfigDescriptionsTest extends OSGiTest {
assertThat max, is(3 as BigDecimal)
assertThat options, is(notNullValue())
assertThat advanced, is(false)
assertThat verify, is(false)
assertThat limitToOptions, is(true)
assertThat multipleLimit, is(null)
assertThat options.join(", "), is("ParameterOption [value=\"key1\", label=\"label1\"], ParameterOption [value=\"key2\", label=\"label2\"]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<context>password</context>
<label>Password</label>
<required>true</required><!-- deprecated -->
<verify>true</verify>
</parameter>

<!-- a static selection list allowing multiple selections with min 2 max 3 items -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<xs:element name="filter" type="config-description:filterType"
minOccurs="0" />
<xs:element name="advanced" type="xs:boolean" minOccurs="0" />
<xs:element name="critical" type="xs:boolean" minOccurs="0" />
<xs:element name="verify" type="xs:boolean" minOccurs="0" />
<xs:element name="multipleLimit" type="xs:integer" minOccurs="0" />
<xs:element name="unitLabel" type="xs:string" minOccurs="0" />
</xs:all>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext co
String description = valueMap.getString("description");

Boolean advanced = valueMap.getBoolean("advanced", false);
Boolean critical = valueMap.getBoolean("critical", false);
Boolean verify = valueMap.getBoolean("verify", false);
Boolean limitToOptions = valueMap.getBoolean("limitToOptions", true);
Integer multipleLimit = valueMap.getInteger("multipleLimit");
String unitLabel = null;
Expand All @@ -131,9 +131,8 @@ public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext co
.withStepSize(step).withPattern(patternString).withRequired(required).withReadOnly(readOnly)
.withMultiple(multiple).withContext(parameterContext).withDefault(defaultValue).withLabel(label)
.withDescription(description).withOptions(options).withFilterCriteria(filterCriteria)
.withGroupName(groupName).withAdvanced(advanced).withCritical(critical)
.withLimitToOptions(limitToOptions).withMultipleLimit(multipleLimit).withUnit(unit)
.withUnitLabel(unitLabel).build();
.withGroupName(groupName).withAdvanced(advanced).withVerify(verify).withLimitToOptions(limitToOptions)
.withMultipleLimit(multipleLimit).withUnit(unit).withUnitLabel(unitLabel).build();

return configDescriptionParam;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/documentation/development/bindings/xml-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ The following HTML tags are allowed -: ```<b>, <br>, <em>, <h1>, <h2>, <h3>, <h4
<tr><td>parameter.groupName</td><td>Sets a group name for this parameter (optional).</td></tr>
<tr><td>parameter.unit</td><td>Specifies the unit of measurements. The unit declaration in the parameter definition shown above contains the set of valid units. The unit must only be set if the type of the parameter is either integer or decimal (optional).</td></tr>
<tr><td>advanced</td><td>Specifies that this is an advanced parameter. Advanced parameters may be hidden by a UI (optional).</td></tr>
<tr><td>critical</td><td>Specifies that this is a critical parameter. Critical parameters may be considered dangerous and should be protected from accidental use by a UI - eg by adding an "Are you sure" prompt (optional).</td></tr>
<tr><td>verify</td><td>Specifies that this is parameter requires a verification stage with the user before sending. Parameters flagged with *verify=true* could be considered dangerous and should be protected from accidental use by a UI - eg by adding an "Are you sure" prompt (optional).</td></tr>
<tr><td>context</td><td>The context of the configuration parameter (optional).</td></tr>
<tr><td>required</td><td>The flag indicating if the configuration parameter has to be set or not (deprecated, optional, default: false).</td></tr>
<tr><td>default</td><td>The default value of the configuration parameter (optional).</td></tr>
Expand Down

0 comments on commit 83ab3c1

Please sign in to comment.