@Test public void resolvesConfigIfKeyspaceAndNamespaceProvidedAndMatch() { CassandraKeyValueServiceConfig newConfig = CassandraAtlasDbFactory.preprocessKvsConfig(CONFIG_WITH_KEYSPACE, Optional::empty, Optional.of(KEYSPACE)); assertThat(newConfig.getKeyspaceOrThrow()).isEqualTo(KEYSPACE); }
@VisibleForTesting static CassandraKeyValueServiceConfig preprocessKvsConfig( KeyValueServiceConfig config, Supplier<Optional<KeyValueServiceRuntimeConfig>> runtimeConfig, Optional<String> namespace) { Preconditions.checkArgument(config instanceof CassandraKeyValueServiceConfig, "Invalid KeyValueServiceConfig. Expected a KeyValueServiceConfig of type" + " CassandraKeyValueServiceConfig, found %s.", config.getClass()); CassandraKeyValueServiceConfig cassandraConfig = (CassandraKeyValueServiceConfig) config; String desiredKeyspace = OptionalResolver.resolve(namespace, cassandraConfig.keyspace()); CassandraKeyValueServiceConfig configWithNamespace = CassandraKeyValueServiceConfigs .copyWithKeyspace(cassandraConfig, desiredKeyspace); return new CassandraReloadableKvsConfig(configWithNamespace, runtimeConfig); }
CassandraAtlasDbFactory implements AtlasDbFactory { @VisibleForTesting static CassandraKeyValueServiceConfig preprocessKvsConfig( KeyValueServiceConfig config, Supplier<Optional<KeyValueServiceRuntimeConfig>> runtimeConfig, Optional<String> namespace) { Preconditions.checkArgument(config instanceof CassandraKeyValueServiceConfig, "Invalid KeyValueServiceConfig. Expected a KeyValueServiceConfig of type" + " CassandraKeyValueServiceConfig, found %s.", config.getClass()); CassandraKeyValueServiceConfig cassandraConfig = (CassandraKeyValueServiceConfig) config; String desiredKeyspace = OptionalResolver.resolve(namespace, cassandraConfig.keyspace()); CassandraKeyValueServiceConfig configWithNamespace = CassandraKeyValueServiceConfigs .copyWithKeyspace(cassandraConfig, desiredKeyspace); return new CassandraReloadableKvsConfig(configWithNamespace, runtimeConfig); } }
CassandraAtlasDbFactory implements AtlasDbFactory { @VisibleForTesting static CassandraKeyValueServiceConfig preprocessKvsConfig( KeyValueServiceConfig config, Supplier<Optional<KeyValueServiceRuntimeConfig>> runtimeConfig, Optional<String> namespace) { Preconditions.checkArgument(config instanceof CassandraKeyValueServiceConfig, "Invalid KeyValueServiceConfig. Expected a KeyValueServiceConfig of type" + " CassandraKeyValueServiceConfig, found %s.", config.getClass()); CassandraKeyValueServiceConfig cassandraConfig = (CassandraKeyValueServiceConfig) config; String desiredKeyspace = OptionalResolver.resolve(namespace, cassandraConfig.keyspace()); CassandraKeyValueServiceConfig configWithNamespace = CassandraKeyValueServiceConfigs .copyWithKeyspace(cassandraConfig, desiredKeyspace); return new CassandraReloadableKvsConfig(configWithNamespace, runtimeConfig); }  }
CassandraAtlasDbFactory implements AtlasDbFactory { @VisibleForTesting static CassandraKeyValueServiceConfig preprocessKvsConfig( KeyValueServiceConfig config, Supplier<Optional<KeyValueServiceRuntimeConfig>> runtimeConfig, Optional<String> namespace) { Preconditions.checkArgument(config instanceof CassandraKeyValueServiceConfig, "Invalid KeyValueServiceConfig. Expected a KeyValueServiceConfig of type" + " CassandraKeyValueServiceConfig, found %s.", config.getClass()); CassandraKeyValueServiceConfig cassandraConfig = (CassandraKeyValueServiceConfig) config; String desiredKeyspace = OptionalResolver.resolve(namespace, cassandraConfig.keyspace()); CassandraKeyValueServiceConfig configWithNamespace = CassandraKeyValueServiceConfigs .copyWithKeyspace(cassandraConfig, desiredKeyspace); return new CassandraReloadableKvsConfig(configWithNamespace, runtimeConfig); }  @Override KeyValueService createRawKeyValueService(
            MetricsManager metricsManager,
            KeyValueServiceConfig config,
            Supplier<Optional<KeyValueServiceRuntimeConfig>> runtimeConfig,
            Optional<LeaderConfig> unused,
            Optional<String> namespace,
            LongSupplier freshTimestampSource,
            boolean initializeAsync); @Override ManagedTimestampService createManagedTimestampService(
            KeyValueService rawKvs,
            Optional<TableReference> timestampTable,
            boolean initializeAsync); @Override String getType(); @Override TimestampStoreInvalidator createTimestampStoreInvalidator(KeyValueService rawKvs); }
CassandraAtlasDbFactory implements AtlasDbFactory { @VisibleForTesting static CassandraKeyValueServiceConfig preprocessKvsConfig( KeyValueServiceConfig config, Supplier<Optional<KeyValueServiceRuntimeConfig>> runtimeConfig, Optional<String> namespace) { Preconditions.checkArgument(config instanceof CassandraKeyValueServiceConfig, "Invalid KeyValueServiceConfig. Expected a KeyValueServiceConfig of type" + " CassandraKeyValueServiceConfig, found %s.", config.getClass()); CassandraKeyValueServiceConfig cassandraConfig = (CassandraKeyValueServiceConfig) config; String desiredKeyspace = OptionalResolver.resolve(namespace, cassandraConfig.keyspace()); CassandraKeyValueServiceConfig configWithNamespace = CassandraKeyValueServiceConfigs .copyWithKeyspace(cassandraConfig, desiredKeyspace); return new CassandraReloadableKvsConfig(configWithNamespace, runtimeConfig); }  @Override KeyValueService createRawKeyValueService(
            MetricsManager metricsManager,
            KeyValueServiceConfig config,
            Supplier<Optional<KeyValueServiceRuntimeConfig>> runtimeConfig,
            Optional<LeaderConfig> unused,
            Optional<String> namespace,
            LongSupplier freshTimestampSource,
            boolean initializeAsync); @Override ManagedTimestampService createManagedTimestampService(
            KeyValueService rawKvs,
            Optional<TableReference> timestampTable,
            boolean initializeAsync); @Override String getType(); @Override TimestampStoreInvalidator createTimestampStoreInvalidator(KeyValueService rawKvs);  }