Merge pull request #2715 from atmire/w2p-69710_port-longname-mandatory

[Scripts & processes] Adding mandatory / longname options to rest output
This commit is contained in:
Tim Donohue
2020-03-24 14:30:03 -05:00
committed by GitHub
3 changed files with 47 additions and 1 deletions

View File

@@ -38,7 +38,9 @@ public class ScriptConverter implements DSpaceConverter<DSpaceRunnable, ScriptRe
ParameterRest parameterRest = new ParameterRest();
parameterRest.setDescription(option.getDescription());
parameterRest.setName((option.getOpt() != null ? "-" + option.getOpt() : "--" + option.getLongOpt()));
parameterRest.setNameLong(option.getLongOpt() != null ? "--" + option.getLongOpt() : null);
parameterRest.setType(((Class) option.getType()).getSimpleName());
parameterRest.setMandatory(option.isRequired());
parameterRestList.add(parameterRest);
}
scriptRest.setParameterRestList(parameterRestList);

View File

@@ -25,6 +25,16 @@ public class ParameterRest {
*/
private String type;
/**
* The long name of the parameter
*/
private String nameLong;
/**
* Boolean indicating whether the parameter is mandatory or not
*/
private boolean mandatory;
public String getName() {
return name;
}
@@ -48,4 +58,36 @@ public class ParameterRest {
public void setType(String type) {
this.type = type;
}
/**
* Generic getter for the nameLong
* @return the nameLong value of this ParameterRest
*/
public String getNameLong() {
return nameLong;
}
/**
* Generic setter for the nameLong
* @param nameLong The nameLong to be set on this ParameterRest
*/
public void setNameLong(String nameLong) {
this.nameLong = nameLong;
}
/**
* Generic getter for the mandatory
* @return the mandatory value of this ParameterRest
*/
public boolean isMandatory() {
return mandatory;
}
/**
* Generic setter for the mandatory
* @param mandatory The mandatory to be set on this ParameterRest
*/
public void setMandatory(boolean mandatory) {
this.mandatory = mandatory;
}
}

View File

@@ -22,8 +22,10 @@ public class ParameterMatcher {
public static Matcher<? super Object> matchParameter(Option option) {
return allOf(
hasJsonPath("$.name", is("-" + option.getOpt())),
hasJsonPath("$.nameLong", is("--" + option.getLongOpt())),
hasJsonPath("$.description", is(option.getDescription())),
hasJsonPath("$.type", is(((Class) option.getType()).getSimpleName()))
hasJsonPath("$.type", is(((Class) option.getType()).getSimpleName())),
hasJsonPath("$.mandatory", is(option.isRequired()))
);
}
}