// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.jdisc.messagebus;

import com.yahoo.cloud.config.SlobroksConfig;
import com.yahoo.container.jdisc.ContainerMbusConfig;
import com.yahoo.container.jdisc.config.SessionConfig;
import com.yahoo.container.jdisc.messagebus.MbusClientProvider;
import com.yahoo.container.jdisc.messagebus.SessionCache;
import com.yahoo.document.config.DocumentmanagerConfig;
import com.yahoo.documentapi.messagebus.protocol.DocumentProtocolPoliciesConfig;
import com.yahoo.messagebus.MessagebusConfig;
import com.yahoo.messagebus.network.NetworkMultiplexer;
import com.yahoo.messagebus.network.rpc.RPCNetwork;
import com.yahoo.messagebus.shared.NullNetwork;
import com.yahoo.vespa.config.content.DistributionConfig;
import com.yahoo.vespa.config.content.LoadTypeConfig;
import org.junit.Test;

import static org.junit.Assert.assertNotNull;

/**
 * @author Ulf Lilleengen
 */
public class MbusClientProviderTest {

    @Test
    public void testIntermediateClient() {
        SessionConfig.Builder builder = new SessionConfig.Builder();
        builder.name("foo");
        builder.type(SessionConfig.Type.Enum.INTERMEDIATE);
        testClient(new SessionConfig(builder));
    }

    @Test
    public void testSourceClient() {
        SessionConfig.Builder builder = new SessionConfig.Builder();
        builder.name("foo");
        builder.type(SessionConfig.Type.Enum.SOURCE);
        testClient(new SessionConfig(builder));
    }

    private void testClient(SessionConfig config) {
        SessionCache cache = new SessionCache(NetworkMultiplexer.dedicated(new NullNetwork()),
                                              new ContainerMbusConfig.Builder().build(),
                                              new DocumentmanagerConfig.Builder().build(),
                                              new LoadTypeConfig.Builder().build(),
                                              new MessagebusConfig.Builder().build(),
                                              new DocumentProtocolPoliciesConfig.Builder().build(),
                                              new DistributionConfig.Builder().build());
        MbusClientProvider p = new MbusClientProvider(cache, config);
        assertNotNull(p.get());
        p.deconstruct();
    }

}

@@ -163,54 +163,8 @@
 s;%0A%0A
-import com.yahoo.cloud.config.SlobroksConfig;%0A
 impo
@@ -272,130 +272,8 @@
 ig;%0A
-import com.yahoo.container.jdisc.messagebus.MbusClientProvider;%0Aimport com.yahoo.container.jdisc.messagebus.SessionCache;%0A
 impo
@@ -511,60 +511,8 @@
 er;%0A
-import com.yahoo.messagebus.network.rpc.RPCNetwork;%0A
 impo

Clean up imports