diff --git a/README.md b/README.md index 5127d90..02b7266 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,76 @@ functions: environment: FUNCTION_NAME: members ``` +### Test It Locally +Please run following command to invoke the function, +``` +$ sls invoke -f members -l --aws-profile --data '{"memberId":"1234567890"}' +``` +Or call POST API, +``` +URL: http://localhost:8080/members +BODY: {"memberId":"1234567890"} +``` +This will invoke the function by passing the Member ID. You would see console output with response MEDICAL as below. +``` +{ + "memberId": "1234567890", + "coverage": "MEDICAL" +} +-------------------------------------------------------------------- +START RequestId: ae39247a-7c6d-11e8-b022-eb1234c7df4f Version: $LATEST +13:58:36.347 [main] INFO org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer - Initializing: class com.healthfirst.memberfunction.MemberFunctionApplication + + . ____ _ __ _ _ + /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ +( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ + \\/ ___)| |_)| | | | | || (_| | ) ) ) ) + ' |____| .__|_| |_|_| |_\__, | / / / / + =========|_|==============|___/=/_/_/_/ + :: Spring Boot :: + +2018-06-30 13:58:39.013 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : Starting LambdaRTEntry on ip-10-22-39-231.ec2.internal with PID 1 (/var/runtime/lib/LambdaJavaRTEntry-1.0.jar started by sbx_user1060 in /) +2018-06-30 13:58:39.016 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : No active profile set, falling back to default profiles: default +2018-06-30 13:58:39.297 INFO 1 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@23fe1d71: startup date [Sat Jun 30 13:58:39 UTC 2018]; root of context hierarchy +2018-06-30 13:58:44.069 INFO 1 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup +2018-06-30 13:58:44.152 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : Started LambdaRTEntry in 7.536 seconds (JVM running for 8.879) +END RequestId: ae39247a-7c6d-11e8-b022-eb1234c7df4f +REPORT RequestId: ae39247a-7c6d-11e8-b022-eb1234c7df4f Duration: 8002.57 ms Billed Duration: 8100 ms Memory Size: 1024 MB Max Memory Used: 142 MB +``` +``` +$ sls invoke -f members -l --aws-profile --data '{"memberId":"1234567890"}' +``` +Or call POST API, +``` +URL: http://localhost:8080/members +BODY: {"memberId":"1234567890"} +``` +This will invoke the function by passing the Member ID. You would see console output with response MEDICAL as below. +``` +{ + "memberId": "1234567890", + "coverage": "MEDICAL" +} +-------------------------------------------------------------------- +START RequestId: ae39247a-7c6d-11e8-b022-eb1234c7df4f Version: $LATEST +13:58:36.347 [main] INFO org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer - Initializing: class com.healthfirst.memberfunction.MemberFunctionApplication + + . ____ _ __ _ _ + /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ +( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ + \\/ ___)| |_)| | | | | || (_| | ) ) ) ) + ' |____| .__|_| |_|_| |_\__, | / / / / + =========|_|==============|___/=/_/_/_/ + :: Spring Boot :: + +2018-06-30 13:58:39.013 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : Starting LambdaRTEntry on ip-10-22-39-231.ec2.internal with PID 1 (/var/runtime/lib/LambdaJavaRTEntry-1.0.jar started by sbx_user1060 in /) +2018-06-30 13:58:39.016 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : No active profile set, falling back to default profiles: default +2018-06-30 13:58:39.297 INFO 1 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@23fe1d71: startup date [Sat Jun 30 13:58:39 UTC 2018]; root of context hierarchy +2018-06-30 13:58:44.069 INFO 1 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup +2018-06-30 13:58:44.152 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : Started LambdaRTEntry in 7.536 seconds (JVM running for 8.879) +END RequestId: ae39247a-7c6d-11e8-b022-eb1234c7df4f +REPORT RequestId: ae39247a-7c6d-11e8-b022-eb1234c7df4f Duration: 8002.57 ms Billed Duration: 8100 ms Memory Size: 1024 MB Max Memory Used: 142 MB +``` ## Deployment ### Please run following command to deploy the project on AWS Lambda ``` @@ -115,39 +185,8 @@ functions: Stack Outputs MembersLambdaFunctionQualifiedArn: arn:aws:lambda:us-east-1:899022498951:function:sls-aws-java-spring-cloud-function-demo-dev-members:1 ServerlessDeploymentBucketName: sls-aws-java-spring-clou-serverlessdeploymentbuck-1qadcge7s5r27 - -``` -### Please run following command to invoke the function ``` -$ sls invoke -f members -l --aws-profile --data '{"memberId":"1234567890"}' -``` -This will invoke the function by passing the Member ID. You would see console output with response MEDICAL as below. -``` -{ - "memberId": "1234567890", - "coverage": "MEDICAL" -} --------------------------------------------------------------------- -START RequestId: ae39247a-7c6d-11e8-b022-eb1234c7df4f Version: $LATEST -13:58:36.347 [main] INFO org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer - Initializing: class com.healthfirst.memberfunction.MemberFunctionApplication - . ____ _ __ _ _ - /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ -( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ - \\/ ___)| |_)| | | | | || (_| | ) ) ) ) - ' |____| .__|_| |_|_| |_\__, | / / / / - =========|_|==============|___/=/_/_/_/ - :: Spring Boot :: - -2018-06-30 13:58:39.013 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : Starting LambdaRTEntry on ip-10-22-39-231.ec2.internal with PID 1 (/var/runtime/lib/LambdaJavaRTEntry-1.0.jar started by sbx_user1060 in /) -2018-06-30 13:58:39.016 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : No active profile set, falling back to default profiles: default -2018-06-30 13:58:39.297 INFO 1 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@23fe1d71: startup date [Sat Jun 30 13:58:39 UTC 2018]; root of context hierarchy -2018-06-30 13:58:44.069 INFO 1 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup -2018-06-30 13:58:44.152 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : Started LambdaRTEntry in 7.536 seconds (JVM running for 8.879) -END RequestId: ae39247a-7c6d-11e8-b022-eb1234c7df4f -REPORT RequestId: ae39247a-7c6d-11e8-b022-eb1234c7df4f Duration: 8002.57 ms Billed Duration: 8100 ms Memory Size: 1024 MB Max Memory Used: 142 MB - -``` ### Please run the following command to uninstall the project from AWS ``` $ sls remove --aws-profile diff --git a/pom.xml b/pom.xml index 16a2c95..8ceac2d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - 4.0.0 @@ -15,36 +16,36 @@ org.springframework.boot spring-boot-starter-parent 2.0.3.RELEASE - + UTF-8 UTF-8 1.8 - Finchley.RELEASE - 1.0.10.RELEASE - 1.1.0 - com.healthfirst.memberfunction.MemberFunctionApplication + Finchley.RELEASE + 1.0.10.RELEASE + 1.1.0 + com.healthfirst.memberfunction.MemberFunctionApplication org.springframework.cloud spring-cloud-starter-function-web - provided + provided - - org.springframework.cloud - spring-cloud-function-adapter-aws - - - com.amazonaws - aws-lambda-java-core - ${aws-lambda-core.version} - provided - - + + org.springframework.cloud + spring-cloud-function-adapter-aws + + + com.amazonaws + aws-lambda-java-core + ${aws-lambda-core.version} + provided + + org.projectlombok lombok true @@ -55,120 +56,113 @@ test - org.springframework.cloud - spring-cloud-contract-wiremock - test - + org.springframework.cloud + spring-cloud-contract-wiremock + test + org.springframework.restdocs spring-restdocs-mockmvc test - - org.springframework.restdocs - spring-restdocs-asciidoctor - + + org.springframework.restdocs + spring-restdocs-asciidoctor + - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + - - org.apache.maven.plugins - maven-deploy-plugin - - true - - + + org.apache.maven.plugins + maven-deploy-plugin + + true + + org.springframework.boot spring-boot-maven-plugin - - - org.springframework.boot.experimental - spring-boot-thin-layout - ${wrapper.version} - - + + + org.springframework.boot.experimental + spring-boot-thin-layout + ${wrapper.version} + + - - org.apache.maven.plugins - maven-shade-plugin - - false - true - aws - - + + org.apache.maven.plugins + maven-shade-plugin + + false + true + aws + + - - org.apache.maven.plugins - maven-assembly-plugin - - true - - ${project.basedir}/src/assembly/stub.xml - - - - - stub - prepare-package - - single - - false - - - + + org.apache.maven.plugins + maven-assembly-plugin + + true + + ${project.basedir}/src/assembly/stub.xml + + + + + stub + prepare-package + + single + + false + + + - - org.asciidoctor - asciidoctor-maven-plugin - - - generate-docs - prepare-package - - process-asciidoc - - - html - book - - ${project.build.directory}/snippets - - src/docs - - - - + + org.asciidoctor + asciidoctor-maven-plugin + + + generate-docs + prepare-package + + process-asciidoc + + + html + book + + ${project.build.directory}/snippets + + src/docs + + + + - + diff --git a/src/main/java/com/healthfirst/memberfunction/HealthFirstMemberRequest.java b/src/main/java/com/healthfirst/memberfunction/HealthFirstMemberRequest.java index fb7bb48..e344571 100644 --- a/src/main/java/com/healthfirst/memberfunction/HealthFirstMemberRequest.java +++ b/src/main/java/com/healthfirst/memberfunction/HealthFirstMemberRequest.java @@ -8,5 +8,13 @@ @NoArgsConstructor @AllArgsConstructor public class HealthFirstMemberRequest { - private String memberId; + private String memberId; + + public String getMemberId() { + return memberId; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } } diff --git a/src/main/java/com/healthfirst/memberfunction/HealthFirstMemberResponse.java b/src/main/java/com/healthfirst/memberfunction/HealthFirstMemberResponse.java index 785468a..1a98c61 100644 --- a/src/main/java/com/healthfirst/memberfunction/HealthFirstMemberResponse.java +++ b/src/main/java/com/healthfirst/memberfunction/HealthFirstMemberResponse.java @@ -8,10 +8,26 @@ @NoArgsConstructor @AllArgsConstructor public class HealthFirstMemberResponse { - private String memberId; - private Coverage coverage; + private String memberId; + private Coverage coverage; - public enum Coverage { - MEDICAL, DENTAL, VISION, NONE - } + public enum Coverage { + MEDICAL, DENTAL, VISION, NONE + } + + public String getMemberId() { + return memberId; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public Coverage getCoverage() { + return coverage; + } + + public void setCoverage(Coverage coverage) { + this.coverage = coverage; + } }