KieServerConnectionInfoProviderImpl implements KieServerConnectionInfoProvider { @Override public KieServerConnectionInfo verifiedConnectionInfo(RemoteDataSetDef def) { String name = def.getName(); String serverTemplateId = def.getServerTemplateId(); String missingConfigError = String.format(CONFIGURATION_NOT_FOUND_MESSAGE, name, serverTemplateId); String missingUrlError = String.format(MISSING_URL_MESSAGE, name, serverTemplateId); String missingAuthError = String.format(MISSING_AUTH_MESSAGE, name, serverTemplateId); KieServerConnectionInfo connectionInfo = get(name, serverTemplateId).orElseThrow(() -> new RuntimeException(missingConfigError)); if (!connectionInfo.getLocation().isPresent()) { throw new RuntimeException(missingUrlError); } if (!connectionInfo.getUser().isPresent() && !connectionInfo.getToken().isPresent()) { throw new RuntimeException(missingAuthError); } return connectionInfo; }  @Override List<String> serverTemplates(); @Override KieServerConnectionInfo verifiedConnectionInfo(RemoteDataSetDef def); @Override Optional<KieServerConnectionInfo> get(String name,
                                                 String serverTemplate); Optional<String> serverTemplateProperty(String serverTemplate,
                                                   KieServerConfigurationKey configurationKey); Optional<String> remoteDatasetProperty(String datasetUUID,
                                                  KieServerConfigurationKey configurationKey);  }
@Test(expected = RuntimeException.class) public void absentConfigurationErrorTest() { kieServerConnectionInfoProvider.verifiedConnectionInfo(def); }
@Test(expected = RuntimeException.class) public void testServerMissingAuth() { setServerProp(KieServerConfigurationKey.LOCATION, "somelocation"); kieServerConnectionInfoProvider.verifiedConnectionInfo(def); }
@Test(expected = RuntimeException.class) public void testDataSetMissingAuth() { setDataSetProp(KieServerConfigurationKey.LOCATION, "somelocation"); kieServerConnectionInfoProvider.verifiedConnectionInfo(def); }
@Test public void testReplaceQuery() { setServerProp(KieServerConfigurationKey.LOCATION, SERVER_LOCATION); setServerProp(KieServerConfigurationKey.USER, SERVER_USER); setServerProp(KieServerConfigurationKey.PASSWORD, SERVER_PASSWORD); setServerProp(KieServerConfigurationKey.REPLACE_QUERY, "True"); KieServerConnectionInfo connectionInfo = kieServerConnectionInfoProvider.verifiedConnectionInfo(def); assertTrue(connectionInfo.isReplaceQuery()); }
@Test public void testReplaceQueryFalse() { setServerProp(KieServerConfigurationKey.LOCATION, SERVER_LOCATION); setServerProp(KieServerConfigurationKey.USER, SERVER_USER); setServerProp(KieServerConfigurationKey.PASSWORD, SERVER_PASSWORD); setServerProp(KieServerConfigurationKey.REPLACE_QUERY, "false"); KieServerConnectionInfo connectionInfo = kieServerConnectionInfoProvider.verifiedConnectionInfo(def); assertFalse(connectionInfo.isReplaceQuery()); }