HubAppDeployer extends SimpleAppDeployer { @Override public void deploy(AppConfig appConfig) { this.completed = 0; onStatusChange(0, "Installing..."); super.deploy(appConfig); onStatusChange(100, "Installation Complete"); if (databaseClient != null) { ServerEvaluationCall eval = databaseClient.newServerEval(); String query = "xdmp:feature-metric-increment(xdmp:feature-metric-register(\"datahub.core.install.count\"))"; try { eval.xquery(query).eval().close(); } catch (FailedRequestException e) { logger.error("Failed to increment feature metric telemetry count: " + query, e); e.printStackTrace(); } } } HubAppDeployer(ManageClient manageClient, AdminManager adminManager, HubDeployStatusListener listener, DatabaseClient databaseClient); @Override void deploy(AppConfig appConfig); @Override void undeploy(AppConfig appConfig);  }
@Test public void test() { List<String> messages = new ArrayList<>(); List<Command> commands = new ArrayList<>(); commands.add(new TestCommand(20, messages)); commands.add(new TestCommand(30, messages)); commands.add(new TestCommand(10, messages)); TestListener testListener = new TestListener(); HubAppDeployer appDeployer = new HubAppDeployer(null, null, testListener, null); appDeployer.setCommands(commands); appDeployer.deploy(new AppConfig()); assertEquals("My sort order: 10", messages.get(0)); assertEquals("My sort order: 20", messages.get(1)); assertEquals("My sort order: 30", messages.get(2)); System.out.println(testListener.getMessages()); assertEquals("0:Installing...", testListener.getMessages().get(0)); assertEquals("0:[Step 1 of 3] com.marklogic.hub.deploy.TestCommand", testListener.getMessages().get(1)); assertEquals("33:[Step 2 of 3] com.marklogic.hub.deploy.TestCommand", testListener.getMessages().get(2)); assertEquals("66:[Step 3 of 3] com.marklogic.hub.deploy.TestCommand", testListener.getMessages().get(3)); assertEquals("100:Installation Complete", testListener.getMessages().get(4)); }