Search in sources :

Example 1 with ClientContext

use of com.amazonaws.services.lambda.runtime.ClientContext in project quarkus by quarkusio.

the class ClientContextTest method testContextMarshalling.

@Test
public void testContextMarshalling() throws Exception {
    ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
    ObjectReader reader = mapper.readerFor(ClientContextImpl.class);
    ClientContext clientContext = reader.readValue(ctx);
    Assertions.assertNotNull(clientContext.getClient());
    Assertions.assertNotNull(clientContext.getCustom());
    Assertions.assertNotNull(clientContext.getEnvironment());
    Assertions.assertEquals("<client_id>", clientContext.getClient().getInstallationId());
    Assertions.assertEquals("<app_title>", clientContext.getClient().getAppTitle());
    Assertions.assertEquals("<app_version_name>", clientContext.getClient().getAppVersionName());
    Assertions.assertEquals("<app_version_code>", clientContext.getClient().getAppVersionCode());
    Assertions.assertEquals("<app_package_name>", clientContext.getClient().getAppPackageName());
    Assertions.assertEquals("world", clientContext.getCustom().get("hello"));
    Assertions.assertEquals("<platform>", clientContext.getEnvironment().get("platform"));
}
Also used : ClientContext(com.amazonaws.services.lambda.runtime.ClientContext) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 2 with ClientContext

use of com.amazonaws.services.lambda.runtime.ClientContext in project aws-java-serverless by hermanlintvelt.

the class RoadmapsHandlerTest method setUp.

@BeforeEach
public void setUp() {
    subject = new RoadmapsHandler();
    testContext = new Context() {

        @Override
        public String getAwsRequestId() {
            return null;
        }

        @Override
        public String getLogGroupName() {
            return null;
        }

        @Override
        public String getLogStreamName() {
            return null;
        }

        // implement all methods of this interface and setup your test context.
        // For instance, the function name:
        @Override
        public String getFunctionName() {
            return "ExampleAwsLambda";
        }

        @Override
        public String getFunctionVersion() {
            return null;
        }

        @Override
        public String getInvokedFunctionArn() {
            return null;
        }

        @Override
        public CognitoIdentity getIdentity() {
            return null;
        }

        @Override
        public ClientContext getClientContext() {
            return null;
        }

        @Override
        public int getRemainingTimeInMillis() {
            return 0;
        }

        @Override
        public int getMemoryLimitInMB() {
            return 0;
        }

        @Override
        public LambdaLogger getLogger() {
            return null;
        }
    };
}
Also used : Context(com.amazonaws.services.lambda.runtime.Context) ClientContext(com.amazonaws.services.lambda.runtime.ClientContext) ClientContext(com.amazonaws.services.lambda.runtime.ClientContext) CognitoIdentity(com.amazonaws.services.lambda.runtime.CognitoIdentity) LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with ClientContext

use of com.amazonaws.services.lambda.runtime.ClientContext in project aws-java-serverless by hermanlintvelt.

the class HandlerTest method setUp.

@BeforeEach
public void setUp() {
    subject = new Handler();
    testContext = new Context() {

        @Override
        public String getAwsRequestId() {
            return null;
        }

        @Override
        public String getLogGroupName() {
            return null;
        }

        @Override
        public String getLogStreamName() {
            return null;
        }

        // implement all methods of this interface and setup your test context.
        // For instance, the function name:
        @Override
        public String getFunctionName() {
            return "ExampleAwsLambda";
        }

        @Override
        public String getFunctionVersion() {
            return null;
        }

        @Override
        public String getInvokedFunctionArn() {
            return null;
        }

        @Override
        public CognitoIdentity getIdentity() {
            return null;
        }

        @Override
        public ClientContext getClientContext() {
            return null;
        }

        @Override
        public int getRemainingTimeInMillis() {
            return 0;
        }

        @Override
        public int getMemoryLimitInMB() {
            return 0;
        }

        @Override
        public LambdaLogger getLogger() {
            return null;
        }
    };
}
Also used : Context(com.amazonaws.services.lambda.runtime.Context) ClientContext(com.amazonaws.services.lambda.runtime.ClientContext) ClientContext(com.amazonaws.services.lambda.runtime.ClientContext) CognitoIdentity(com.amazonaws.services.lambda.runtime.CognitoIdentity) LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ClientContext

use of com.amazonaws.services.lambda.runtime.ClientContext in project amazon-neptune-tools by awslabs.

the class RunNeptuneExportSvc method run.

@Override
public void run() {
    InputStream input = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8));
    try {
        new NeptuneExportLambda(rootPath, cleanRootPath, maxFileDescriptorCount).handleRequest(input, System.out, new Context() {

            @Override
            public String getAwsRequestId() {
                throw new NotImplementedException();
            }

            @Override
            public String getLogGroupName() {
                throw new NotImplementedException();
            }

            @Override
            public String getLogStreamName() {
                throw new NotImplementedException();
            }

            @Override
            public String getFunctionName() {
                throw new NotImplementedException();
            }

            @Override
            public String getFunctionVersion() {
                throw new NotImplementedException();
            }

            @Override
            public String getInvokedFunctionArn() {
                throw new NotImplementedException();
            }

            @Override
            public CognitoIdentity getIdentity() {
                throw new NotImplementedException();
            }

            @Override
            public ClientContext getClientContext() {
                throw new NotImplementedException();
            }

            @Override
            public int getRemainingTimeInMillis() {
                throw new NotImplementedException();
            }

            @Override
            public int getMemoryLimitInMB() {
                throw new NotImplementedException();
            }

            @Override
            public LambdaLogger getLogger() {
                return new LambdaLogger() {

                    @Override
                    public void log(String s) {
                        System.out.println(s);
                    }

                    @Override
                    public void log(byte[] bytes) {
                        throw new NotImplementedException();
                    }
                };
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
        System.err.println("An error occurred while exporting from Neptune: " + e.getMessage());
        System.exit(-1);
    }
    System.exit(0);
}
Also used : Context(com.amazonaws.services.lambda.runtime.Context) ClientContext(com.amazonaws.services.lambda.runtime.ClientContext) NeptuneExportLambda(com.amazonaws.services.neptune.export.NeptuneExportLambda) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) NotImplementedException(sun.reflect.generics.reflectiveObjects.NotImplementedException) ClientContext(com.amazonaws.services.lambda.runtime.ClientContext) CognitoIdentity(com.amazonaws.services.lambda.runtime.CognitoIdentity) LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger) NotImplementedException(sun.reflect.generics.reflectiveObjects.NotImplementedException)

Example 5 with ClientContext

use of com.amazonaws.services.lambda.runtime.ClientContext in project aws-java-serverless by hermanlintvelt.

the class CreateRoadmapsHandlerTest method setUp.

@BeforeEach
public void setUp() {
    subject = new CreateRoadmapsHandler();
    testContext = new Context() {

        @Override
        public String getAwsRequestId() {
            return null;
        }

        @Override
        public String getLogGroupName() {
            return null;
        }

        @Override
        public String getLogStreamName() {
            return null;
        }

        // implement all methods of this interface and setup your test context.
        // For instance, the function name:
        @Override
        public String getFunctionName() {
            return "ExampleAwsLambda";
        }

        @Override
        public String getFunctionVersion() {
            return null;
        }

        @Override
        public String getInvokedFunctionArn() {
            return null;
        }

        @Override
        public CognitoIdentity getIdentity() {
            return null;
        }

        @Override
        public ClientContext getClientContext() {
            return null;
        }

        @Override
        public int getRemainingTimeInMillis() {
            return 0;
        }

        @Override
        public int getMemoryLimitInMB() {
            return 0;
        }

        @Override
        public LambdaLogger getLogger() {
            return null;
        }
    };
}
Also used : Context(com.amazonaws.services.lambda.runtime.Context) ClientContext(com.amazonaws.services.lambda.runtime.ClientContext) ClientContext(com.amazonaws.services.lambda.runtime.ClientContext) CognitoIdentity(com.amazonaws.services.lambda.runtime.CognitoIdentity) LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ClientContext (com.amazonaws.services.lambda.runtime.ClientContext)5 CognitoIdentity (com.amazonaws.services.lambda.runtime.CognitoIdentity)4 Context (com.amazonaws.services.lambda.runtime.Context)4 LambdaLogger (com.amazonaws.services.lambda.runtime.LambdaLogger)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 NeptuneExportLambda (com.amazonaws.services.neptune.export.NeptuneExportLambda)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 Test (org.junit.jupiter.api.Test)1 NotImplementedException (sun.reflect.generics.reflectiveObjects.NotImplementedException)1