// Path: src/main/java/com/xti/jenkins/plugin/awslambda/util/LambdaClientConfig.java
// public class LambdaClientConfig implements Serializable {
//     private String region;
//     private String accessKeyId;
//     private String secretKey;
//     private Boolean useDefaultAWSCredentials;
//     private ProxyConfiguration proxyConfiguration;
// 
//     public LambdaClientConfig(String region, ProxyConfiguration proxyConfiguration){
//         this.region = region;
//         this.useDefaultAWSCredentials = true;
//         this.proxyConfiguration = proxyConfiguration;
//     }
// 
//     public LambdaClientConfig(String accessKeyId, String secretKey, String region, ProxyConfiguration proxyConfiguration) {
//         this.region = region;
//         this.accessKeyId = accessKeyId;
//         this.secretKey = secretKey;
//         this.useDefaultAWSCredentials = false;
//         this.proxyConfiguration = proxyConfiguration;
//     }
// 
//     public AWSLambdaClient getClient() {
//         if(useDefaultAWSCredentials){
//             return new AWSLambdaClient(new DefaultAWSCredentialsProviderChain(), getClientConfiguration())
//                     .withRegion(Region.getRegion(Regions.fromName(region)));
//         } else {
//             return new AWSLambdaClient(new BasicAWSCredentials(accessKeyId, secretKey), getClientConfiguration())
//                     .withRegion(Region.getRegion(Regions.fromName(region)));
//         }
//     }
// 
//     private ClientConfiguration getClientConfiguration() {
//         /*
//         Jenkins instance = Jenkins.getInstance();
// 
//         if (instance != null) {
//             ProxyConfiguration proxy = instance.proxy;
//         */
//         ClientConfiguration config = new ClientConfiguration();
// 
//         if (proxyConfiguration != null) {
//             config.setProxyHost(proxyConfiguration.name);
//             config.setProxyPort(proxyConfiguration.port);
//             if (proxyConfiguration.getUserName() != null) {
//                 config.setProxyUsername(proxyConfiguration.getUserName());
//                 config.setProxyPassword(proxyConfiguration.getPassword());
//             }
//             if (proxyConfiguration.noProxyHost != null) {
//                 config.setNonProxyHosts(proxyConfiguration.noProxyHost);
//             }
//         }
// 
//         return config;
// 
//     }
// }


import com.amazonaws.services.lambda.AWSLambda;
import com.xti.jenkins.plugin.awslambda.util.LambdaClientConfig;
import hudson.EnvVars;
import hudson.util.Secret;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import java.util.Arrays;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
        assertEquals(variables.getRole(), uploadConfig.getRole());
        assertEquals(variables.getUpdateMode(), uploadConfig.getUpdateMode());
        assertEquals(Arrays.asList("subnet1", "subnet2"), uploadConfig.getSubnets());
        assertEquals(Collections.singletonList("secgroup"), uploadConfig.getSecurityGroups());
        assertEquals(variables.getEnvironmentConfiguration().getKmsArn(), uploadConfig.getKmsArn());
        assertEquals(variables.getEnvironmentConfiguration().getEnvironment().get(0).getValue(), uploadConfig.getEnvironmentVariables().get("key"));
    }

    @Test
    public void testGetUploadConfigNullTimeoutAndMemory() throws Exception {
        LambdaUploadBuildStepVariables variables = new LambdaUploadBuildStepVariables(false, "ID", Secret.fromString("SECRET}"), "eu-west-1", "FILE", "description DESCRIPTION", "FUNCTION", "HANDLER", null, "ROLE", "RUNTIME", "", "full", false, null, false, "subnet1, subnet2", "secgroup");
        DeployConfig uploadConfig = variables.getUploadConfig();

        assertEquals(variables.getArtifactLocation(), uploadConfig.getArtifactLocation());
        assertEquals(variables.getDescription(), uploadConfig.getDescription());
        assertNull(uploadConfig.getMemorySize());
        assertNull(uploadConfig.getTimeout());
        assertEquals(variables.getHandler(), uploadConfig.getHandler());
        assertEquals(variables.getRuntime(), uploadConfig.getRuntime());
        assertEquals(variables.getFunctionName(), uploadConfig.getFunctionName());
        assertEquals(variables.getRole(), uploadConfig.getRole());
        assertEquals(variables.getUpdateMode(), uploadConfig.getUpdateMode());
        assertEquals(Arrays.asList("subnet1", "subnet2"), uploadConfig.getSubnets());
        assertEquals(Collections.singletonList("secgroup"), uploadConfig.getSecurityGroups());
    }

    @Test
    public void testGetLambdaClientConfig() throws Exception {
        LambdaUploadBuildStepVariables variables = new LambdaUploadBuildStepVariables(false, "ID", Secret.fromString("SECRET}"), "eu-west-1", "FILE", "description DESCRIPTION", "FUNCTION", "HANDLER", "1024", "ROLE", "RUNTIME", "30", "full", false, null, false, "subnet1, subnet2", "secgroup");
        variables.expandVariables(new EnvVars());
// Path: src/main/java/com/xti/jenkins/plugin/awslambda/util/LambdaClientConfig.java
// public class LambdaClientConfig implements Serializable {
//     private String region;
//     private String accessKeyId;
//     private String secretKey;
//     private Boolean useDefaultAWSCredentials;
//     private ProxyConfiguration proxyConfiguration;
// 
//     public LambdaClientConfig(String region, ProxyConfiguration proxyConfiguration){
//         this.region = region;
//         this.useDefaultAWSCredentials = true;
//         this.proxyConfiguration = proxyConfiguration;
//     }
// 
//     public LambdaClientConfig(String accessKeyId, String secretKey, String region, ProxyConfiguration proxyConfiguration) {
//         this.region = region;
//         this.accessKeyId = accessKeyId;
//         this.secretKey = secretKey;
//         this.useDefaultAWSCredentials = false;
//         this.proxyConfiguration = proxyConfiguration;
//     }
// 
//     public AWSLambdaClient getClient() {
//         if(useDefaultAWSCredentials){
//             return new AWSLambdaClient(new DefaultAWSCredentialsProviderChain(), getClientConfiguration())
//                     .withRegion(Region.getRegion(Regions.fromName(region)));
//         } else {
//             return new AWSLambdaClient(new BasicAWSCredentials(accessKeyId, secretKey), getClientConfiguration())
//                     .withRegion(Region.getRegion(Regions.fromName(region)));
//         }
//     }
// 
//     private ClientConfiguration getClientConfiguration() {
//         /*
//         Jenkins instance = Jenkins.getInstance();
// 
//         if (instance != null) {
//             ProxyConfiguration proxy = instance.proxy;
//         */
//         ClientConfiguration config = new ClientConfiguration();
// 
//         if (proxyConfiguration != null) {
//             config.setProxyHost(proxyConfiguration.name);
//             config.setProxyPort(proxyConfiguration.port);
//             if (proxyConfiguration.getUserName() != null) {
//                 config.setProxyUsername(proxyConfiguration.getUserName());
//                 config.setProxyPassword(proxyConfiguration.getPassword());
//             }
//             if (proxyConfiguration.noProxyHost != null) {
//                 config.setNonProxyHosts(proxyConfiguration.noProxyHost);
//             }
//         }
// 
//         return config;
// 
//     }
// }


// Path: src/test/java/com/xti/jenkins/plugin/awslambda/upload/LambdaUploadBuildStepVariablesTest.java
import com.amazonaws.services.lambda.AWSLambda;
import com.xti.jenkins.plugin.awslambda.util.LambdaClientConfig;
import hudson.EnvVars;
import hudson.util.Secret;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import java.util.Arrays;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

        assertEquals(variables.getRole(), uploadConfig.getRole());
        assertEquals(variables.getUpdateMode(), uploadConfig.getUpdateMode());
        assertEquals(Arrays.asList("subnet1", "subnet2"), uploadConfig.getSubnets());
        assertEquals(Collections.singletonList("secgroup"), uploadConfig.getSecurityGroups());
        assertEquals(variables.getEnvironmentConfiguration().getKmsArn(), uploadConfig.getKmsArn());
        assertEquals(variables.getEnvironmentConfiguration().getEnvironment().get(0).getValue(), uploadConfig.getEnvironmentVariables().get("key"));
    }

    @Test
    public void testGetUploadConfigNullTimeoutAndMemory() throws Exception {
        LambdaUploadBuildStepVariables variables = new LambdaUploadBuildStepVariables(false, "ID", Secret.fromString("SECRET}"), "eu-west-1", "FILE", "description DESCRIPTION", "FUNCTION", "HANDLER", null, "ROLE", "RUNTIME", "", "full", false, null, false, "subnet1, subnet2", "secgroup");
        DeployConfig uploadConfig = variables.getUploadConfig();

        assertEquals(variables.getArtifactLocation(), uploadConfig.getArtifactLocation());
        assertEquals(variables.getDescription(), uploadConfig.getDescription());
        assertNull(uploadConfig.getMemorySize());
        assertNull(uploadConfig.getTimeout());
        assertEquals(variables.getHandler(), uploadConfig.getHandler());
        assertEquals(variables.getRuntime(), uploadConfig.getRuntime());
        assertEquals(variables.getFunctionName(), uploadConfig.getFunctionName());
        assertEquals(variables.getRole(), uploadConfig.getRole());
        assertEquals(variables.getUpdateMode(), uploadConfig.getUpdateMode());
        assertEquals(Arrays.asList("subnet1", "subnet2"), uploadConfig.getSubnets());
        assertEquals(Collections.singletonList("secgroup"), uploadConfig.getSecurityGroups());
    }

    @Test
    public void testGetLambdaClientConfig() throws Exception {
        LambdaUploadBuildStepVariables variables = new LambdaUploadBuildStepVariables(false, "ID", Secret.fromString("SECRET}"), "eu-west-1", "FILE", "description DESCRIPTION", "FUNCTION", "HANDLER", "1024", "ROLE", "RUNTIME", "30", "full", false, null, false, "subnet1, subnet2", "secgroup");
        variables.expandVariables(new EnvVars());
        LambdaClientConfig lambdaClientConfig = variables.getLambdaClientConfig();