
package org.apache.camel.component.google.drive;

import org.apache.camel.BindToRegistry;
import org.apache.camel.Endpoint;
import org.apache.camel.builder.RouteBuilder;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;

/**
 * Test class for com.google.api.services.drive.Drive$Files APIs.
 */
public class CustomClientFactoryTest extends AbstractGoogleDriveTestSupport {

    @BindToRegistry("myAuth")
    private MyClientFactory cf = new MyClientFactory();

    @Test
    public void testClientFactoryUpdated() throws Exception {
        Endpoint endpoint = context.getEndpoint("google-drive://drive-files/list?clientFactory=#myAuth");
        assertTrue(endpoint instanceof GoogleDriveEndpoint);
        assertTrue(((GoogleDriveEndpoint) endpoint).getClientFactory() instanceof MyClientFactory);
    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() {
                from("google-drive://drive-files/list?clientFactory=#myAuth").to("mock:result");
            }
        };
    }
}
