Configuration { public static Configuration valueOf(String key, String value) { return valueOf(key + "=" + (value == null ? "" : value)); } private  Configuration(String rawInput, Setting setting, Scope level, Integer stripeId, Integer nodeId, String key, String value); Scope getLevel(); int getStripeId(); int getNodeId(); Setting getSetting(); String getKey(); Optional<String> getValue(); void validate(ClusterState clusterState, Operation operation); boolean duplicates(Configuration other); boolean matchConfigPropertyKey(String key); Collection<? extends PropertyHolder> apply(PropertyHolder propertyHolder); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); Stream<? extends PropertyHolder> findTargets(PropertyHolder from); static Configuration valueOf(String key, String value); static Configuration valueOf(String input); static Configuration valueOf(Setting setting); static Configuration valueOf(Setting setting, int stripeId); static Configuration valueOf(Setting setting, int stripeId, int nodeId);  }
@Test public void test_valueOf_with_invalid_string() { assertThat(() -> Configuration.valueOf((String) null), is(throwing(instanceOf(NullPointerException.class)))); Stream.of(".", ":").forEach(ns -> { rejectInput("", "Invalid input: ''. Reason: valid setting name not found"); rejectInput("stripe.1", "Invalid input: 'stripe.1'. Reason: valid setting name not found"); rejectInput("stripe.1.node.1", "Invalid input: 'stripe.1.node.1'. Reason: valid setting name not found"); rejectInput("foo", "Invalid input: 'foo'. Reason: Invalid setting name: 'foo'"); rejectInput("stripe.1" + ns + "foo", "Invalid input: 'stripe.1" + ns + "foo'. Reason: Invalid setting name: 'foo'"); rejectInput("stripe.1.node.1" + ns + "foo", "Invalid input: 'stripe.1.node.1" + ns + "foo'. Reason: Invalid setting name: 'foo'"); rejectInput("foo.stripe.1.node.1" + ns + "foo", "Invalid input: 'foo.stripe.1.node.1" + ns + "foo'. Reason: Invalid setting name: 'foo'"); rejectInput("stripe.1.foo.node.1" + ns + "foo", "Invalid input: 'stripe.1.foo.node.1" + ns + "foo'. Reason: Invalid setting name: 'foo'"); rejectInput("stripe.0" + ns + "backup-dir", "Invalid input: 'stripe.0" + ns + "backup-dir'. Reason: Expected stripe ID to be greater than 0"); rejectInput("stripe.-1" + ns + "backup-dir", "Invalid input: 'stripe.-1" + ns + "backup-dir'"); rejectInput("stripe.foo" + ns + "backup-dir", "Invalid input: 'stripe.foo" + ns + "backup-dir'"); rejectInput("stripe.1.node.0" + ns + "backup-dir", "Invalid input: 'stripe.1.node.0" + ns + "backup-dir'. Reason: Expected node ID to be greater than 0"); rejectInput("stripe.1.node.-1" + ns + "backup-dir", "Invalid input: 'stripe.1.node.-1" + ns + "backup-dir'"); rejectInput("stripe.1.node.foo" + ns + "backup-dir", "Invalid input: 'stripe.1.node.foo" + ns + "backup-dir'"); rejectInput("node.1.stripe.1" + ns + "backup-dir", "Invalid input: 'node.1.stripe.1" + ns + "backup-dir'"); rejectInput("stripe.1.stripe.1" + ns + "backup-dir", "Invalid input: 'stripe.1.stripe.1" + ns + "backup-dir'"); rejectInput("stripe.1.node.1.stripe.1" + ns + "backup-dir", "Invalid input: 'stripe.1.node.1.stripe.1" + ns + "backup-dir'"); rejectInput("stripe.1.node.1.node.1" + ns + "backup-dir", "Invalid input: 'stripe.1.node.1.node.1" + ns + "backup-dir'"); rejectInput("stripe" + ns + "backup-dir", "Invalid input: 'stripe" + ns + "backup-dir'"); rejectInput("backup-dir.key", "Invalid input: 'backup-dir.key'. Reason: Setting 'backup-dir' is not a map and must not have a key"); rejectInput("stripe.1.node.1.failover-priority", "Invalid input: 'stripe.1.node.1.failover-priority'. Reason: Setting 'failover-priority' does not allow any operation at node level"); }); }
@Test public void test_stripe_setting() { Configuration.valueOf("stripe.1.stripe-name=stripe1"); }