mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 23:13:10 +00:00
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:
@@ -38,7 +38,9 @@ public class ScriptConverter implements DSpaceConverter<DSpaceRunnable, ScriptRe
|
|||||||
ParameterRest parameterRest = new ParameterRest();
|
ParameterRest parameterRest = new ParameterRest();
|
||||||
parameterRest.setDescription(option.getDescription());
|
parameterRest.setDescription(option.getDescription());
|
||||||
parameterRest.setName((option.getOpt() != null ? "-" + option.getOpt() : "--" + option.getLongOpt()));
|
parameterRest.setName((option.getOpt() != null ? "-" + option.getOpt() : "--" + option.getLongOpt()));
|
||||||
|
parameterRest.setNameLong(option.getLongOpt() != null ? "--" + option.getLongOpt() : null);
|
||||||
parameterRest.setType(((Class) option.getType()).getSimpleName());
|
parameterRest.setType(((Class) option.getType()).getSimpleName());
|
||||||
|
parameterRest.setMandatory(option.isRequired());
|
||||||
parameterRestList.add(parameterRest);
|
parameterRestList.add(parameterRest);
|
||||||
}
|
}
|
||||||
scriptRest.setParameterRestList(parameterRestList);
|
scriptRest.setParameterRestList(parameterRestList);
|
||||||
|
@@ -25,6 +25,16 @@ public class ParameterRest {
|
|||||||
*/
|
*/
|
||||||
private String type;
|
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() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -48,4 +58,36 @@ public class ParameterRest {
|
|||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
this.type = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,8 +22,10 @@ public class ParameterMatcher {
|
|||||||
public static Matcher<? super Object> matchParameter(Option option) {
|
public static Matcher<? super Object> matchParameter(Option option) {
|
||||||
return allOf(
|
return allOf(
|
||||||
hasJsonPath("$.name", is("-" + option.getOpt())),
|
hasJsonPath("$.name", is("-" + option.getOpt())),
|
||||||
|
hasJsonPath("$.nameLong", is("--" + option.getLongOpt())),
|
||||||
hasJsonPath("$.description", is(option.getDescription())),
|
hasJsonPath("$.description", is(option.getDescription())),
|
||||||
hasJsonPath("$.type", is(((Class) option.getType()).getSimpleName()))
|
hasJsonPath("$.type", is(((Class) option.getType()).getSimpleName())),
|
||||||
|
hasJsonPath("$.mandatory", is(option.isRequired()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user