/**
 * Copyright 2017 Palantir Technologies
 *
 * Licensed under the BSD-3 License (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://opensource.org/licenses/BSD-3-Clause
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.palantir.atlasdb.config;

import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat;

import java.util.List;

import org.junit.Test;

import com.google.common.collect.ImmutableList;

public class TimeLockClientConfigTest {
    private static final String CLIENT = "testClient";
    private static final String SERVER_1 = "http://localhost:8080";
    private static final String SERVER_2 = "http://palantir.com:8080";

    private static final TimeLockClientConfig MULTIPLE_SERVER_CONFIG
            = getTimelockConfigForServers(ImmutableList.of(SERVER_1, SERVER_2));

    @Test
    public void canGetNamespacedConfigsFromTimelockBlock() {
        ServerListConfig namespacedConfig = MULTIPLE_SERVER_CONFIG.toNamespacedServerList();
        assertThat(namespacedConfig.servers(), hasItems(SERVER_1 + "/" + CLIENT, SERVER_2 + "/" + CLIENT));
    }

    private static TimeLockClientConfig getTimelockConfigForServers(List<String> servers) {
        return ImmutableTimeLockClientConfig.builder()
                .client(CLIENT)
                .serversList(ImmutableServerListConfig.builder()
                        .addAllServers(servers)
                        .build())
                .build();
    }
}

@@ -620,16 +620,61 @@
 onfig;%0A%0A
+import static org.hamcrest.Matchers.equalTo;%0A
 import s
@@ -753,16 +753,56 @@
 ertThat;
+%0Aimport static org.mockito.Mockito.mock;
 %0A%0Aimport
@@ -890,16 +890,107 @@
 bleList;
+%0Aimport com.google.common.base.Optional;%0Aimport com.palantir.remoting.ssl.SslConfiguration;
 %0A%0Apublic
@@ -1372,277 +1372,1515 @@
 ));%0A
-%0A    @Test%0A    public void canGetNamespacedConfigsFromTimelockBlock() %7B%0A        ServerListConfig namespacedConfig = MULTIPLE_SERVER_CONFIG.toNamespacedServerList();%0A        assertThat(namespacedConfig.servers(), hasItems(SERVER_1 + %22/%22 + CLIENT, SERVER_2 + %22/%22 + CLIENT
+    private static final SslConfiguration SSL_CONFIGURATION = mock(SslConfiguration.class);%0A    private static final ImmutableServerListConfig SERVERS_LIST = ImmutableServerListConfig.builder()%0A            .addServers(SERVER_1, SERVER_2)%0A            .sslConfiguration(SSL_CONFIGURATION)%0A            .build();%0A    private static final TimeLockClientConfig CLIENT_CONFIG = ImmutableTimeLockClientConfig.builder()%0A            .client(CLIENT)%0A            .serversList(SERVERS_LIST)%0A            .build();%0A%0A    @Test%0A    public void canGetNamespacedConfigsFromTimelockBlock() %7B%0A        ServerListConfig namespacedConfig = MULTIPLE_SERVER_CONFIG.toNamespacedServerList();%0A        assertThat(namespacedConfig.servers(), hasItems(SERVER_1 + %22/%22 + CLIENT, SERVER_2 + %22/%22 + CLIENT));%0A    %7D%0A%0A    @Test%0A    public void preservesSslOnConversionToNamespacedServerListIfPresent() %7B%0A        ServerListConfig namespacedConfig = CLIENT_CONFIG.toNamespacedServerList();%0A        assertThat(namespacedConfig.sslConfiguration(), equalTo(Optional.of(SSL_CONFIGURATION)));%0A    %7D%0A%0A    @Test%0A    public void preservesAbsenceOfSslOnConversionToNamespacedServerListIfAbsent() %7B%0A        TimeLockClientConfig config = ImmutableTimeLockClientConfig.copyOf(CLIENT_CONFIG)%0A                .withServersList(%0A                        ImmutableServerListConfig.copyOf(SERVERS_LIST)%0A                        .withSslConfiguration(Optional.absent()));%0A        assertThat(config.toNamespacedServerList().sslConfiguration(), equalTo(Optional.absent()
 ));%0A

Add additional client config tests