// Path: src/main/java/com/xti/jenkins/plugin/awslambda/service/LambdaPublishService.java
// public class LambdaPublishService {
//     private AWSLambdaClient client;
//     private JenkinsLogger logger;
// 
//     public LambdaPublishService(AWSLambdaClient client, JenkinsLogger logger) {
//         this.client = client;
//         this.logger = logger;
//     }
// 
//     public LambdaPublishServiceResponse publishLambda(PublishConfig config){
// 
//         GetAliasRequest getAliasRequest = new GetAliasRequest()
//                 .withName(config.getFunctionAlias())
//                 .withFunctionName(config.getFunctionARN());
// 
//         logger.log("Lambda function alias existence check:%n%s%n%s%n", config.getFunctionARN(), config.getFunctionAlias());
//         try {
//             GetAliasResult functionResult = client.getAlias(getAliasRequest);
//             logger.log("Lambda function alias exists:%n%s%n", functionResult.toString());
//         } catch (ResourceNotFoundException rnfe) {
//             return new LambdaPublishServiceResponse("", "", false);
//         }
// 
//         logger.log("Publishing new version");
// 
//         PublishVersionRequest publishVersionRequest = new PublishVersionRequest().withFunctionName(config.getFunctionARN()).withDescription(config.getVersionDescription());
//         PublishVersionResult publishVersionResult = client.publishVersion(publishVersionRequest);
// 
//         logger.log(publishVersionResult.toString());
// 
//         logger.log("Updating alias");
// 
//         UpdateAliasRequest updateAliasRequest = new UpdateAliasRequest().withName(config.getFunctionAlias());
//         updateAliasRequest.setFunctionName(config.getFunctionARN());
//         updateAliasRequest.setDescription(config.getVersionDescription());
//         updateAliasRequest.setFunctionVersion(publishVersionResult.getVersion());
// 
//         UpdateAliasResult updateAliasResult = client.updateAlias(updateAliasRequest);
// 
//         logger.log(updateAliasResult.toString());
// 
//         return new LambdaPublishServiceResponse(publishVersionResult.getVersion(), updateAliasResult.getName(), true);
//     }
// 
// }


import com.xti.jenkins.plugin.awslambda.service.JenkinsLogger;
import com.xti.jenkins.plugin.awslambda.service.LambdaPublishService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
package com.xti.jenkins.plugin.awslambda.publish;



/**
 * Created by Magnus Sulland on 4/08/2016.
 */

@RunWith(MockitoJUnitRunner.class)
public class LambdaPublishTest {

    @Mock
// Path: src/main/java/com/xti/jenkins/plugin/awslambda/service/LambdaPublishService.java
// public class LambdaPublishService {
//     private AWSLambdaClient client;
//     private JenkinsLogger logger;
// 
//     public LambdaPublishService(AWSLambdaClient client, JenkinsLogger logger) {
//         this.client = client;
//         this.logger = logger;
//     }
// 
//     public LambdaPublishServiceResponse publishLambda(PublishConfig config){
// 
//         GetAliasRequest getAliasRequest = new GetAliasRequest()
//                 .withName(config.getFunctionAlias())
//                 .withFunctionName(config.getFunctionARN());
// 
//         logger.log("Lambda function alias existence check:%n%s%n%s%n", config.getFunctionARN(), config.getFunctionAlias());
//         try {
//             GetAliasResult functionResult = client.getAlias(getAliasRequest);
//             logger.log("Lambda function alias exists:%n%s%n", functionResult.toString());
//         } catch (ResourceNotFoundException rnfe) {
//             return new LambdaPublishServiceResponse("", "", false);
//         }
// 
//         logger.log("Publishing new version");
// 
//         PublishVersionRequest publishVersionRequest = new PublishVersionRequest().withFunctionName(config.getFunctionARN()).withDescription(config.getVersionDescription());
//         PublishVersionResult publishVersionResult = client.publishVersion(publishVersionRequest);
// 
//         logger.log(publishVersionResult.toString());
// 
//         logger.log("Updating alias");
// 
//         UpdateAliasRequest updateAliasRequest = new UpdateAliasRequest().withName(config.getFunctionAlias());
//         updateAliasRequest.setFunctionName(config.getFunctionARN());
//         updateAliasRequest.setDescription(config.getVersionDescription());
//         updateAliasRequest.setFunctionVersion(publishVersionResult.getVersion());
// 
//         UpdateAliasResult updateAliasResult = client.updateAlias(updateAliasRequest);
// 
//         logger.log(updateAliasResult.toString());
// 
//         return new LambdaPublishServiceResponse(publishVersionResult.getVersion(), updateAliasResult.getName(), true);
//     }
// 
// }


// Path: src/test/java/com/xti/jenkins/plugin/awslambda/publish/LambdaPublishTest.java
import com.xti.jenkins.plugin.awslambda.service.JenkinsLogger;
import com.xti.jenkins.plugin.awslambda.service.LambdaPublishService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

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



/**
 * Created by Magnus Sulland on 4/08/2016.
 */

@RunWith(MockitoJUnitRunner.class)
public class LambdaPublishTest {

    @Mock
    private LambdaPublishService service;