// Path: src/test/java/com/xti/jenkins/plugin/awslambda/TestUtil.java
// public class TestUtil {
//     public File getResource(String resourcePath){
//         ClassLoader classLoader = getClass().getClassLoader();
//         URL resource = classLoader.getResource(resourcePath);
//         if(resource != null){
//             try {
//                 File tempEcho = File.createTempFile("aws-lambda-plugin", "echo.zip");
//                 FileUtils.copyFile(new File(resource.getFile()), tempEcho);
//                 tempEcho.deleteOnExit();
//                 return tempEcho;
//             } catch (IOException e) {
//                 throw new IllegalStateException("Could not load " + resourcePath);
//             }
// 
//         } else {
//             throw new IllegalStateException("Could not load " + resourcePath);
//         }
//     }
// }
// 
// 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.AmazonServiceException;
import com.amazonaws.services.lambda.AWSLambdaClient;
import com.amazonaws.services.lambda.model.*;
import com.xti.jenkins.plugin.awslambda.TestUtil;
import com.xti.jenkins.plugin.awslambda.util.LambdaClientConfig;
import hudson.Launcher;
import hudson.model.*;
import hudson.util.Secret;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.TestBuilder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
package com.xti.jenkins.plugin.awslambda.upload;




@RunWith(MockitoJUnitRunner.class)
public class LambdaUploadBuildStepTest {

    @Rule
    public JenkinsRule j = new JenkinsRule();

    private TestUtil testUtil = new TestUtil();

    @Test
    @Ignore
    public void testHtml() throws Exception {
        LambdaUploadBuildStepVariables variables = new LambdaUploadBuildStepVariables(false, "accessKeyId", Secret.fromString("secretKey"), "eu-west-1", "ziplocation", "description", "function", "handler", "1024", "role", "nodejs", "30", "full", false, null, false, "", "");

        FreeStyleProject p = j.createFreeStyleProject();
        LambdaUploadBuildStep before = new LambdaUploadBuildStep(variables);
        p.getBuildersList().add(before);

        j.submit(j.createWebClient().getPage(p,"configure").getFormByName("config"));

        LambdaUploadBuildStep after = p.getBuildersList().get(LambdaUploadBuildStep.class);

        assertEquals(before, after);
    }

    @Mock
    private LambdaUploadBuildStepVariables original;

    @Mock
// Path: src/test/java/com/xti/jenkins/plugin/awslambda/TestUtil.java
// public class TestUtil {
//     public File getResource(String resourcePath){
//         ClassLoader classLoader = getClass().getClassLoader();
//         URL resource = classLoader.getResource(resourcePath);
//         if(resource != null){
//             try {
//                 File tempEcho = File.createTempFile("aws-lambda-plugin", "echo.zip");
//                 FileUtils.copyFile(new File(resource.getFile()), tempEcho);
//                 tempEcho.deleteOnExit();
//                 return tempEcho;
//             } catch (IOException e) {
//                 throw new IllegalStateException("Could not load " + resourcePath);
//             }
// 
//         } else {
//             throw new IllegalStateException("Could not load " + resourcePath);
//         }
//     }
// }
// 
// 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/LambdaUploadBuildStepTest.java
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.lambda.AWSLambdaClient;
import com.amazonaws.services.lambda.model.*;
import com.xti.jenkins.plugin.awslambda.TestUtil;
import com.xti.jenkins.plugin.awslambda.util.LambdaClientConfig;
import hudson.Launcher;
import hudson.model.*;
import hudson.util.Secret;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.TestBuilder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;

package com.xti.jenkins.plugin.awslambda.upload;




@RunWith(MockitoJUnitRunner.class)
public class LambdaUploadBuildStepTest {

    @Rule
    public JenkinsRule j = new JenkinsRule();

    private TestUtil testUtil = new TestUtil();

    @Test
    @Ignore
    public void testHtml() throws Exception {
        LambdaUploadBuildStepVariables variables = new LambdaUploadBuildStepVariables(false, "accessKeyId", Secret.fromString("secretKey"), "eu-west-1", "ziplocation", "description", "function", "handler", "1024", "role", "nodejs", "30", "full", false, null, false, "", "");

        FreeStyleProject p = j.createFreeStyleProject();
        LambdaUploadBuildStep before = new LambdaUploadBuildStep(variables);
        p.getBuildersList().add(before);

        j.submit(j.createWebClient().getPage(p,"configure").getFormByName("config"));

        LambdaUploadBuildStep after = p.getBuildersList().get(LambdaUploadBuildStep.class);

        assertEquals(before, after);
    }

    @Mock
    private LambdaUploadBuildStepVariables original;

    @Mock
    private LambdaClientConfig clientConfig;