use of com.hedera.services.bdd.suites.utils.validation.ValidationScenarios.Scenario.SYS_FILES_DOWN in project hedera-services by hashgraph.
the class ValidationScenarios method parse.
private static void parse(String[] args) {
var KEY_VALUE_PATTERN = Pattern.compile("([\\w\\d]+)=([\\w\\d,.-]+)");
for (String arg : args) {
var matcher = KEY_VALUE_PATTERN.matcher(arg);
if (!matcher.matches()) {
log.warn(String.format("Ignoring command-line argument '%s'", arg));
} else {
if ("target".equals(keyOf(matcher))) {
params.setTargetNetwork(valueOf(matcher));
} else if ("defaultNodePayment".equals(keyOf(matcher))) {
try {
params.setDefaultNodePayment(Long.parseLong(valueOf(matcher)));
} catch (NumberFormatException ignore) {
}
} else if ("novel".equals(keyOf(matcher))) {
params.setNovelContent(valueOf(matcher).toLowerCase().equals("true"));
} else if ("revocation".equals(keyOf(matcher))) {
params.setRevocationService(valueOf(matcher).toLowerCase().equals("true"));
} else if ("scenarios".equals(keyOf(matcher))) {
Set<String> legal = Arrays.stream(Scenario.class.getEnumConstants()).map(Object::toString).collect(Collectors.toSet());
List<String> listed = Arrays.stream(valueOf(matcher).split(",")).map(name -> name.equals("fees") ? "FEE_SNAPSHOTS" : name).map(name -> name.equals("syskeys") ? "SYSTEM_KEYS" : name).map(name -> name.equals("xfers") ? "TRANSFERS_ONLY" : name).map(name -> name.equals("sysFilesDown") ? "SYS_FILES_DOWN" : name).map(name -> name.equals("sysFilesUp") ? "SYS_FILES_UP" : name).filter(v -> legal.contains(v.toUpperCase())).collect(toList());
if (listed.size() == 1) {
params.setScenarios(EnumSet.of(Scenario.valueOf(listed.get(0).toUpperCase())));
} else if (listed.size() > 1) {
params.setScenarios(EnumSet.of(Scenario.valueOf(listed.get(0).toUpperCase()), listed.subList(1, listed.size()).stream().map(String::toUpperCase).map(Scenario::valueOf).toArray(n -> new Scenario[n])));
}
} else if ("config".equals(keyOf(matcher))) {
params.setConfigLoc(valueOf(matcher));
} else {
log.warn(String.format("Ignoring unknown parameter key '%s'", keyOf(matcher)));
}
}
}
System.out.println(params.getScenarios());
}
Aggregations