package com.microstar.tap3;

import java.util.HashMap;

import com.amazonaws.serverless.proxy.internal.model.ApiGatewayAuthorizerContext;
import com.amazonaws.serverless.proxy.internal.model.ApiGatewayRequestContext;
import com.amazonaws.serverless.proxy.internal.model.AwsProxyRequest;
import com.amazonaws.serverless.proxy.internal.model.CognitoAuthorizerClaims;
import com.amazonaws.services.lambda.runtime.ClientContext;
import com.amazonaws.services.lambda.runtime.CognitoIdentity;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;

/**
 * A simple mock implementation of the {@code Context} interface. Default
 * values are stubbed out, and setters are provided so you can customize
 * the context before passing it to your function.
 */
public class CommonTestContext implements Context {

    private String awsRequestId = "EXAMPLE";
    private ClientContext clientContext;
    private String functionName = "EXAMPLE";
    private CognitoIdentity identity;
    private String logGroupName = "EXAMPLE";
    private String logStreamName = "EXAMPLE";
    private LambdaLogger logger = new TestLogger();
    private int memoryLimitInMB = 128;
    private int remainingTimeInMillis = 15000;

    public static AwsProxyRequest getRequest()
    {
    	AwsProxyRequest ret = new AwsProxyRequest();
    	
        HashMap<String,String> headers = new HashMap<String, String>();
        headers.put("Accept", "application/json");
        headers.put("Authentication", "eyJraWQiOiIrK011UW01OXAxUEY5YlwvT0gwdloxREZUVmJxTHpSNHhocmpTeXF5NlY3Yz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJlNTMwODE0MS0wNjYwLTRjYzMtOTM5OC0xMmMyMDRiNGE3YWMiLCJ6b25laW5mbyI6Ik1TVCIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAudXMtd2VzdC0yLmFtYXpvbmF3cy5jb21cL3VzLXdlc3QtMl9jTUpGeFJEUnMiLCJwaG9uZV9udW1iZXJfdmVyaWZpZWQiOnRydWUsImNvZ25pdG86dXNlcm5hbWUiOiJkYXZpZG1jbzY1IiwiZ2l2ZW5fbmFtZSI6IkRhdmlkIiwiYXVkIjoiNnVoOW5kcmtxMWJoazNkZzlpcWtnMzlsODIiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTQ5ODA2MzYxNywicGhvbmVfbnVtYmVyIjoiKzE3MjAzNDE4MDA4IiwiZXhwIjoxNDk4MDY3MjE3LCJpYXQiOjE0OTgwNjM2MTcsImZhbWlseV9uYW1lIjoiTWNEYW5pZWwiLCJlbWFpbCI6ImRhdmlkQG1vYmlsZS0zNjAuY29tIn0.dMg53KqkdmZ021DgKoc4TrWFTiBBTfHZkYUFally5nzlubHPqbh61Nsz_-NEbjtWGs5hVgakJlXNt2PRg2WQRqfqKBsYYNOCZeF_2MDhM9AsA65bkET83oceYYs1Pmamy1qPRjcVs676HUj1BKpv9IkpXNTNvQr3apaWziVmd7Juhq3JR6Vc1H7uOSa1zLxWu1pSNKT2yyk4uNxtUnrl1HW0sHQmTuiabEgeJsI50pfuSOl0y7ubcqUoywTS_SwmTcz3ExHl9txQSojFvNDuzltnKQwnVn5Vrnv3AvER7ANjXsAKS_zWcDSeIfQFJRhhEQvaDZF4foS2FdJ8sFkvmw");
        ret.setHeaders(headers);
        
    	ret.setRequestContext(new ApiGatewayRequestContext());
    	ret.getRequestContext().setAuthorizer(new ApiGatewayAuthorizerContext());
    	
    	ret.getRequestContext().getAuthorizer().setClaims(new CognitoAuthorizerClaims());
    	
    	ret.getRequestContext().getAuthorizer().getClaims().setSubject("e5308141-0660-4cc3-9398-12c204b4a7ac");
    	
    	ret.setQueryStringParameters(new HashMap<>());
    	
    	return ret;
    }
    
    public String getAwsRequestId() {
        return awsRequestId;
    }

    public void setAwsRequestId(String value) {
        awsRequestId = value;
    }

    public ClientContext getClientContext() {
        return clientContext;
    }

    public void setClientContext(ClientContext value) {
        clientContext = value;
    }

    public String getFunctionName() {
        return functionName;
    }

    public void setFunctionName(String value) {
        functionName = value;
    }

    public CognitoIdentity getIdentity() {
        return identity;
    }

    public void setIdentity(CognitoIdentity value) {
        identity = value;
    }

    public String getLogGroupName() {
        return logGroupName;
    }

    public void setLogGroupName(String value) {
        logGroupName = value;
    }

    public String getLogStreamName() {
        return logStreamName;
    }

    public void setLogStreamName(String value) {
        logStreamName = value;
    }

    public LambdaLogger getLogger() {
        return logger;
    }

    public void setLogger(LambdaLogger value) {
        logger = value;
    }

    public int getMemoryLimitInMB() {
        return memoryLimitInMB;
    }

    public void setMemoryLimitInMB(int value) {
        memoryLimitInMB = value;
    }

    public int getRemainingTimeInMillis() {
        return remainingTimeInMillis;
    }

    public void setRemainingTimeInMillis(int value) {
        remainingTimeInMillis = value;
    }

    /**
     * A simple {@code LambdaLogger} that prints everything to stderr.
     */
    private static class TestLogger implements LambdaLogger {

        public void log(String message) {
            System.err.println(message);
        } 
    }

	public String getFunctionVersion()
	{
		// TODO Auto-generated method stub
		return null;
	}

	public String getInvokedFunctionArn()
	{
		// TODO Auto-generated method stub
		return null;
	}
}
