CouchbaseManager { protected static Pair<PasswordAuthenticator, List<String>> getConnectionObjectsFromConfigurationKey(String configurationKey) { Configuration couchbaseConfig = getKeyMap(configurationKey); Object username, password; if ((username = couchbaseConfig.getString(USERNAME_CONFIG_KEY)) == null || (password = couchbaseConfig.getString(PASSWORD_CONFIG_KEY)) == null) { throw new RuntimeException("Please check you 'apoc.couchbase." + configurationKey + "' configuration, username and password are missing"); } Object url; if ((url = couchbaseConfig.getString(URI_CONFIG_KEY)) == null) { throw new RuntimeException("Please check you 'apoc.couchbase." + configurationKey + "' configuration, url is missing"); } return Pair.of( new PasswordAuthenticator(username.toString(), password.toString()), Arrays.asList(url.toString().split(",")) ); } protected  CouchbaseManager(); static CouchbaseConnection getConnection(String hostOrKey, String bucketName); static String getConfig(String key);  }
@Test public void testIfSchemeIsNotDefineConsiderConfigurationKeyAndConfigurationKeyNotExists() { String hostOrKey = "localhost"; exceptionRule.expect(RuntimeException.class); exceptionRule.expectMessage("Please check apoc.conf file 'apoc.couchbase." + hostOrKey + "' is missing"); CouchbaseManager.getConnectionObjectsFromConfigurationKey(hostOrKey); }
@Test public void testIfSchemeIsNotDefineConsiderConfigurationKeyAndConfigurationExists() { String hostOrKey = COUCHBASE_CONFIG_KEY; Pair<PasswordAuthenticator, List<String>> connectionObjectsFromHostOrKey = CouchbaseManager.getConnectionObjectsFromConfigurationKey(hostOrKey); Assert.assertEquals(USERNAME, connectionObjectsFromHostOrKey.first().username()); Assert.assertEquals(PASSWORD, connectionObjectsFromHostOrKey.first().password()); Assert.assertEquals(Arrays.asList("localhost"), connectionObjectsFromHostOrKey.other()); }