ModelNodeResult extends ModelNode { public final ModelNodeResult forServer(String host, String server) { if (!isFromDomain()) { throw new IllegalArgumentException("Can't call forServer on a result that isn't from domain"); } List<Property> serverGroups = this.get(Constants.SERVER_GROUPS).asPropertyList(); for (Property serverGroup : serverGroups) { ModelNode response = serverGroup.getValue().get(Constants.HOST, host, server, Constants.RESPONSE); if (response.isDefined()) { return new ModelNodeResult(response); } } throw new IllegalArgumentException("No such host or server: host = " + host + ", server = " + server); } @Deprecated  ModelNodeResult();  ModelNodeResult(ModelNode original); final boolean isSuccess(); final boolean isFailed(); final void assertSuccess(); final void assertSuccess(String message); final void assertFailed(); final void assertFailed(String message); final boolean hasDefinedValue(); final void assertDefinedValue(); final void assertDefinedValue(String message); final void assertNotDefinedValue(); final void assertNotDefinedValue(String message); final ModelNode value(); final boolean booleanValue(); final boolean booleanValue(boolean defaultValue); final int intValue(); final int intValue(int defaultValue); final long longValue(); final long longValue(long defaultValue); final double doubleValue(); final double doubleValue(double defaultValue); final String stringValue(); final String stringValue(String defaultValue); final List<ModelNode> listValue(); final List<Boolean> booleanListValue(); final List<Boolean> booleanListValue(List<Boolean> defaultValue); final List<Integer> intListValue(); final List<Integer> intListValue(List<Integer> defaultValue); final List<Long> longListValue(); final List<Long> longListValue(List<Long> defaultValue); final List<Double> doubleListValue(); final List<Double> doubleListValue(List<Double> defaultValue); final List<String> stringListValue(); final List<String> stringListValue(List<String> defaultValue); final ModelNodeResult forBatchStep(int stepIndex); final Iterable<ModelNodeResult> forAllBatchSteps(); final ModelNode headers(); final boolean isReloadRequired(); final boolean isRestartRequired(); final boolean isFromDomain(); final ModelNodeResult forServer(String host, String server);  }
@Test public void forServer() { ModelNodeResult result = new ModelNodeResult(RESTART_REQUIRED_IN_DOMAIN); ModelNodeResult server1 = result.forServer("master", "server-one"); ModelNodeResult server2 = result.forServer("master", "server-two"); assertTrue(server1.isDefined()); assertTrue(server1.isSuccess()); assertTrue(server1.isRestartRequired()); assertTrue(server2.isDefined()); assertTrue(server2.isSuccess()); assertTrue(server2.isRestartRequired()); try { result.forServer("slave", "server-one"); fail(); } catch (IllegalArgumentException ignored) { } try { result.forServer("master", "server-three"); fail(); } catch (IllegalArgumentException ignored) { } }