RunFlowCommand extends CommandLineFlowInputs implements Runnable { protected HubConfigImpl buildHubConfig() { HubConfigImpl hubConfig = new HubConfigImpl(host, username, password); if (ssl != null && ssl) { Stream.of(DatabaseKind.STAGING, DatabaseKind.FINAL, DatabaseKind.JOB).forEach(kind -> hubConfig.setSimpleSsl(kind, true)); } if (StringUtils.isNotEmpty(auth)) { Stream.of(DatabaseKind.STAGING, DatabaseKind.FINAL, DatabaseKind.JOB).forEach(kind -> hubConfig.setAuthMethod(kind, auth)); } if (params != null && !params.isEmpty()) { hubConfig.applyProperties(params::get); } else { hubConfig.applyProperties(new SimplePropertySource()); } return hubConfig; }  @Override void run(); String getHost(); void setHost(String host); String getUsername(); void setUsername(String username); String getPassword(); void setPassword(String password); Map<String, String> getParams(); void setParams(Map<String, String> params); void setSsl(Boolean ssl); void setAuth(String auth);  }
@Test void buildHubConfig() { RunFlowCommand command = new RunFlowCommand(); command.setHost("somewhere"); command.setUsername("someone"); command.setPassword("something"); command.setParams(new HashMap<>()); command.getParams().put("mlStagingPort", "8410"); command.getParams().put("mlStagingDbName", "my-STAGING"); HubConfigImpl config = command.buildHubConfig(); assertEquals("somewhere", config.getHost()); assertEquals("someone", config.getMlUsername()); assertEquals("something", config.getMlPassword()); assertEquals(8410, config.getPort(DatabaseKind.STAGING)); assertEquals("my-STAGING", config.getDbName(DatabaseKind.STAGING)); assertEquals("data-hub-FINAL", config.getDbName(DatabaseKind.FINAL), "Smoke-checking that the default properties " + "were set as well"); }
@Test void digestAuth() { HubConfigImpl config = new RunFlowCommand().buildHubConfig(); assertEquals("digest", config.getAuthMethod(DatabaseKind.STAGING)); assertEquals("digest", config.getAuthMethod(DatabaseKind.FINAL)); assertEquals("digest", config.getAuthMethod(DatabaseKind.JOB)); Stream.of(DatabaseKind.STAGING, DatabaseKind.FINAL, DatabaseKind.JOB).forEach(kind -> { assertFalse(config.getSimpleSsl(kind)); assertNull(config.getSslContext(kind)); assertNull(config.getSslHostnameVerifier(kind)); assertNull(config.getTrustManager(kind)); }); }