making changes

This commit is contained in:
sahankj2000
2024-05-13 16:41:55 +05:30
parent e22c44e044
commit 92c9cf474c
2 changed files with 21 additions and 2 deletions

View File

@@ -201,4 +201,11 @@ public class NBCLIScenarioPreprocessorTest {
.isThrownBy(() -> new NBCLIOptions(new String[]{"scenario_test", "duplicate_param"}, NBCLIOptions.Mode.ParseAllOptions))
.withMessageContaining("Duplicate occurrence of parameter \"threads\"");
}
@Test
public void testThatSuggestionsAreShownForDirectStepNameUsage() {
assertThatExceptionOfType(BasicError.class)
.isThrownBy(() -> new NBCLIOptions(new String[]{"scenario_test", "schema"}, NBCLIOptions.Mode.ParseAllOptions))
.withMessageContainingAll("default.schema", "schema_only.schema");
}
}

View File

@@ -133,8 +133,20 @@ public class NBCLIScenarioPreprocessor {
if (nameparts.length==1) {
Map<String, String> namedScenario = scenarios.getNamedScenario(scenarioName);
if (namedScenario==null) {
throw new BasicError("Unable to find named scenario '" + scenarioName + "' in workload '" + workloadName
+ "', but you can pick from one of: " + String.join(", ", scenarios.getScenarioNames()));
List<String> matchingSteps = new LinkedList<>();
for (String scenario : scenarios.getScenarioNames()) {
Map<String, String> selectedScenario = scenarios.getNamedScenario(scenario);
if (selectedScenario.containsKey(scenarioName)) {
matchingSteps.add(scenario + "." + scenarioName);
}
}
if (matchingSteps.isEmpty()) {
throw new BasicError("Unable to find named scenario '" + scenarioName + "' in workload '" + workloadName
+ "', but you can pick from one of: " + String.join(", ", scenarios.getScenarioNames()));
} else {
throw new BasicError("Unable to find named scenario '" + scenarioName + "' in workload '" + workloadName
+ "', you might be looking for one of these scenario steps: " + String.join(", ", matchingSteps));
}
}
namedSteps.putAll(namedScenario);
} else {