Fixing string out of bounds when description is empty
This commit is contained in:
Родитель
b11814e2ca
Коммит
ef9926b536
|
@ -100,7 +100,7 @@ public class VmOpsTool {
|
||||||
|
|
||||||
System.out.println("Parsing input parameters...");
|
System.out.println("Parsing input parameters...");
|
||||||
for (String arg : cmdArgs) {
|
for (String arg : cmdArgs) {
|
||||||
if (arg.charAt(0) == '-') {
|
if (!arg.equals("") && arg.charAt(0) == '-') {
|
||||||
key = arg;
|
key = arg;
|
||||||
} else if (!arg.equals(Constants.vmOpsTool)){
|
} else if (!arg.equals(Constants.vmOpsTool)){
|
||||||
value = arg;
|
value = arg;
|
||||||
|
|
|
@ -30,6 +30,18 @@ public class VmOpsToolUnitTests {
|
||||||
assertThat(argsMap.get(Constants.vCenterUrl)).isEqualTo(vCenterUrl);
|
assertThat(argsMap.get(Constants.vCenterUrl)).isEqualTo(vCenterUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parseCmdArgsWithEmptyDescription() {
|
||||||
|
String[] cmdArgs = { Constants.vmOpsTool, Constants.description, "" };
|
||||||
|
|
||||||
|
Map<String, String> argsMap = VmOpsTool.parseCmdLine(cmdArgs);
|
||||||
|
|
||||||
|
assertThat(argsMap.size()).isEqualTo(1);
|
||||||
|
assertThat(argsMap.containsKey(Constants.vmOpsTool)).isEqualTo(false);
|
||||||
|
assertThat(argsMap.containsKey(Constants.description)).isEqualTo(true);
|
||||||
|
assertThat(argsMap.get(Constants.description)).isEqualTo("");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void executeActionShouldSucceedForCreateAndDeleteSnapshotOperation() throws Exception {
|
public void executeActionShouldSucceedForCreateAndDeleteSnapshotOperation() throws Exception {
|
||||||
// Create snapshot operation validation
|
// Create snapshot operation validation
|
||||||
|
|
Загрузка…
Ссылка в новой задаче