@Test(expected = IOException.class) @SuppressWarnings("unchecked") public void error() throws IOException { ModelControllerClient mock = mock(ModelControllerClient.class); when(mock.execute(any(ModelNode.class))).thenThrow(IOException.class); OnlineServerVersion.discover(mock); }
static ServerVersion discover(ModelControllerClient client) throws IOException { ModelNode op = new ModelNode(); op.get(Constants.OP).set(Constants.READ_RESOURCE_OPERATION); op.get(Constants.OP_ADDR).setEmptyList(); ModelNodeResult result = new ModelNodeResult(client.execute(op)); result.assertSuccess(); ModelNode resultValue = result.get(Constants.RESULT); return ServerVersion.from( readPart(resultValue, ManagementVersionPart.MAJOR), readPart(resultValue, ManagementVersionPart.MINOR), readPart(resultValue, ManagementVersionPart.MICRO) ); }
OnlineServerVersion { static ServerVersion discover(ModelControllerClient client) throws IOException { ModelNode op = new ModelNode(); op.get(Constants.OP).set(Constants.READ_RESOURCE_OPERATION); op.get(Constants.OP_ADDR).setEmptyList(); ModelNodeResult result = new ModelNodeResult(client.execute(op)); result.assertSuccess(); ModelNode resultValue = result.get(Constants.RESULT); return ServerVersion.from( readPart(resultValue, ManagementVersionPart.MAJOR), readPart(resultValue, ManagementVersionPart.MINOR), readPart(resultValue, ManagementVersionPart.MICRO) ); } }
OnlineServerVersion { static ServerVersion discover(ModelControllerClient client) throws IOException { ModelNode op = new ModelNode(); op.get(Constants.OP).set(Constants.READ_RESOURCE_OPERATION); op.get(Constants.OP_ADDR).setEmptyList(); ModelNodeResult result = new ModelNodeResult(client.execute(op)); result.assertSuccess(); ModelNode resultValue = result.get(Constants.RESULT); return ServerVersion.from( readPart(resultValue, ManagementVersionPart.MAJOR), readPart(resultValue, ManagementVersionPart.MINOR), readPart(resultValue, ManagementVersionPart.MICRO) ); } private  OnlineServerVersion(); }
OnlineServerVersion { static ServerVersion discover(ModelControllerClient client) throws IOException { ModelNode op = new ModelNode(); op.get(Constants.OP).set(Constants.READ_RESOURCE_OPERATION); op.get(Constants.OP_ADDR).setEmptyList(); ModelNodeResult result = new ModelNodeResult(client.execute(op)); result.assertSuccess(); ModelNode resultValue = result.get(Constants.RESULT); return ServerVersion.from( readPart(resultValue, ManagementVersionPart.MAJOR), readPart(resultValue, ManagementVersionPart.MINOR), readPart(resultValue, ManagementVersionPart.MICRO) ); } private  OnlineServerVersion();  }
OnlineServerVersion { static ServerVersion discover(ModelControllerClient client) throws IOException { ModelNode op = new ModelNode(); op.get(Constants.OP).set(Constants.READ_RESOURCE_OPERATION); op.get(Constants.OP_ADDR).setEmptyList(); ModelNodeResult result = new ModelNodeResult(client.execute(op)); result.assertSuccess(); ModelNode resultValue = result.get(Constants.RESULT); return ServerVersion.from( readPart(resultValue, ManagementVersionPart.MAJOR), readPart(resultValue, ManagementVersionPart.MINOR), readPart(resultValue, ManagementVersionPart.MICRO) ); } private  OnlineServerVersion();   }