Skip to content

Commit

Permalink
Merge pull request #91 from jenkinsci/small-changes
Browse files Browse the repository at this point in the history
Fix IDE warnings, and prevent WebDriver NPE on Windows
  • Loading branch information
kinow authored Oct 10, 2024
2 parents a6e65c7 + 02a3f87 commit 2251033
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void doUpdate(String parameters) {
final String[] nameValue = param.split(EQUALS);
if (nameValue.length == 1) {
final String name = nameValue[0].trim();
if (name.length() > 0)
if (!name.isEmpty())
getParameters().put(name, "");
} else if (nameValue.length == 2) {
final String name = nameValue[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public abstract class AbstractScriptableParameter extends AbstractUnoChoiceParam

/**
* Inherited constructor.
*
* {@inheritDoc}
*
* @param name name
Expand All @@ -119,7 +118,6 @@ protected AbstractScriptableParameter(String name, String description, Script sc

/**
* Inherited constructor.
*
* {@inheritDoc}
*
* @param name name
Expand Down Expand Up @@ -292,10 +290,9 @@ public ParameterValue getDefaultParameterValue() {
LOGGER.entering(AbstractUnoChoiceParameter.class.getName(), "getDefaultParameterValue");
}
final String name = getName();
String defaultValue = findDefaultValue(getChoices(Collections.<Object, Object> emptyMap()));
String defaultValue = findDefaultValue(getChoices(Collections.emptyMap()));
final String value = ObjectUtils.toString(defaultValue, ""); // Jenkins doesn't like null parameter values
final StringParameterValue stringParameterValue = new StringParameterValue(name, value);
return stringParameterValue;
return new StringParameterValue(name, value);
}

private static String findDefaultValue(Map<Object, Object> choices) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ public boolean getOmitValueField() {

@JavaScriptMethod
public String getChoicesAsStringForUI() {
String result = getChoicesAsString(getParameters());
return result;
return getChoicesAsString(getParameters());
}

// --- descriptor
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/biouno/unochoice/model/GroovyScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ public Object eval(Map<String, String> parameters) throws RuntimeException {
// @SuppressWarnings("unchecked")
final Map<String, String> envVars = System.getenv();
for (Entry<String, String> parameter : parameters.entrySet()) {
Object value = parameter.getValue();
String value = parameter.getValue();
if (value != null) {
if (value instanceof String) {
value = Util.replaceMacro((String) value, envVars);
value = Util.replaceMacro(value, envVars);
}
context.setVariable(parameter.getKey(), value);
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/org/biouno/unochoice/BaseUiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ public void setUp() throws Exception {

@After
public void tearDown() {
driver.quit();
if (driver != null) {
driver.quit();
}
}

protected static By radios(String paramName) {
Expand Down

0 comments on commit 2251033

Please sign in to comment.