From eccc2580bcacf9dc9b806cb5106d6e106ae791f5 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Wed, 22 Nov 2023 21:04:04 +0000 Subject: [PATCH] feat: temporarily remove handing exception --- aws-lambda-project/.localstack/01_init.sh | 3 ++- .../com/learning/awslambda/services/ActorService.java | 7 +------ .../src/main/resources/application.properties | 2 +- .../learning/awslambda/ApplicationIntegrationTest.java | 9 ++++++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/aws-lambda-project/.localstack/01_init.sh b/aws-lambda-project/.localstack/01_init.sh index 813d663e..0ab8fe9b 100755 --- a/aws-lambda-project/.localstack/01_init.sh +++ b/aws-lambda-project/.localstack/01_init.sh @@ -30,7 +30,8 @@ awslocal lambda create-function \ --handler org.springframework.cloud.function.adapter.aws.FunctionInvoker::handleRequest \ --role "$IAM_ROLE_ARN" \ --zip-file "fileb://$JAR_FILE" \ - --environment "$ENV_VARS" + --environment "$ENV_VARS" \ + --description "Spring Cloud Function AWS Adapter Example" echo -e "Lambda function created successfully!\n" diff --git a/aws-lambda-project/src/main/java/com/learning/awslambda/services/ActorService.java b/aws-lambda-project/src/main/java/com/learning/awslambda/services/ActorService.java index a20ea194..58fdf126 100644 --- a/aws-lambda-project/src/main/java/com/learning/awslambda/services/ActorService.java +++ b/aws-lambda-project/src/main/java/com/learning/awslambda/services/ActorService.java @@ -1,7 +1,6 @@ package com.learning.awslambda.services; import com.learning.awslambda.entities.Actor; -import com.learning.awslambda.exception.ActorNotFoundException; import com.learning.awslambda.mapper.ActorMapper; import com.learning.awslambda.model.response.ActorResponse; import com.learning.awslambda.repositories.ActorRepository; @@ -28,10 +27,6 @@ public ActorService(ActorRepository actorRepository, ActorMapper actorMapper) { public List findActorByName(String name) { LOGGER.info("Finding Actors By Name :{}", name); List actorList = actorRepository.findByNameLike(name); - if (actorList.isEmpty()) { - throw new ActorNotFoundException(name); - } else { - return actorMapper.toResponseList(actorList); - } + return actorMapper.toResponseList(actorList); } } diff --git a/aws-lambda-project/src/main/resources/application.properties b/aws-lambda-project/src/main/resources/application.properties index bf3a8759..7b6a1122 100644 --- a/aws-lambda-project/src/main/resources/application.properties +++ b/aws-lambda-project/src/main/resources/application.properties @@ -6,7 +6,7 @@ spring.jmx.enabled=false spring.mvc.problemdetails.enabled=true ################ Actuator ##################### -management.endpoints.web.exposure.include=configprops,env,health,info,logfile,loggers,metrics,prometheus +management.endpoints.web.exposure.include=configprops,env,health,info,logfile,loggers,metrics,prometheus,functions management.endpoint.health.show-details=always ################ Database ##################### diff --git a/aws-lambda-project/src/test/java/com/learning/awslambda/ApplicationIntegrationTest.java b/aws-lambda-project/src/test/java/com/learning/awslambda/ApplicationIntegrationTest.java index f97949b4..e6d65b24 100644 --- a/aws-lambda-project/src/test/java/com/learning/awslambda/ApplicationIntegrationTest.java +++ b/aws-lambda-project/src/test/java/com/learning/awslambda/ApplicationIntegrationTest.java @@ -59,7 +59,8 @@ class ApplicationIntegrationTest { @Container static PostgreSQLContainer postgres = new PostgreSQLContainer<>("postgres:16.1-alpine") .withNetwork(network) - .withNetworkAliases("postgres"); + .withNetworkAliases("postgres") + .withReuse(true); @Container static LocalStackContainer localstack = new LocalStackContainer( @@ -69,7 +70,8 @@ class ApplicationIntegrationTest { .withEnv("LAMBDA_DOCKER_NETWORK", ((Network.NetworkImpl) network).getName()) .withEnv("LAMBDA_RUNTIME_ENVIRONMENT_TIMEOUT", "30") .withNetworkAliases("localstack") - .withEnv("LAMBDA_DOCKER_FLAGS", testContainersLabels()); + .withEnv("LAMBDA_DOCKER_FLAGS", testContainersLabels()) + .withReuse(true); private static String testContainersLabels() { return Stream.of( @@ -103,6 +105,7 @@ void contextLoads() throws IOException { .timeout(10) .handler("org.springframework.cloud.function.adapter.aws.FunctionInvoker::handleRequest") .environment(Environment.builder().variables(envVars).build()) + .description("Spring Cloud Function AWS Adapter Example") .build(); LambdaClient lambdaClient = LambdaClient.builder() @@ -140,7 +143,7 @@ void contextLoads() throws IOException { .andReturn() .body(); assertThat(responseBody.asString()) - .isEqualTo( + .isEqualToIgnoringWhitespace( """ [{"id":1,"name":"profile-1"},{"id":2,"name":"profile-2"},{"id":3,"name":"profile-3"},{"id":4,"name":"profile-4"}] """);