From b1bc0f2eb73b71d9b17f87282d5f74aaa4179ea6 Mon Sep 17 00:00:00 2001 From: Annie Hawes Date: Fri, 26 Apr 2024 11:58:28 +0100 Subject: [PATCH 1/9] TDRD 88: Update draft metadata validator to consume json event from step function --- .../draftmetadatavalidator/Lambda.scala | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala index 2743f22..3601bc7 100644 --- a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala +++ b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala @@ -1,7 +1,7 @@ package uk.gov.nationalarchives.draftmetadatavalidator import cats.effect.IO -import com.amazonaws.services.lambda.runtime.Context +import com.amazonaws.services.lambda.runtime.{Context, RequestHandler} import com.amazonaws.services.lambda.runtime.events.{APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent} import graphql.codegen.GetCustomMetadata.customMetadata.CustomMetadata import graphql.codegen.GetCustomMetadata.{customMetadata => cm} @@ -33,7 +33,7 @@ import java.time.format.DateTimeFormatter import java.util.UUID import scala.concurrent.ExecutionContext.Implicits.global -class Lambda { +class Lambda[Input] extends RequestHandler[Input, APIGatewayProxyResponseEvent] { implicit val backend: SttpBackend[Identity, Any] = HttpURLConnectionBackend() implicit val keycloakDeployment: TdrKeycloakDeployment = TdrKeycloakDeployment(authUrl, "tdr", timeToLiveSecs) @@ -46,12 +46,11 @@ class Lambda { private val addOrUpdateBulkFileMetadataClient = new GraphQLClient[afm.Data, afm.Variables](apiUrl) private val graphQlApi: GraphQlApi = GraphQlApi(keycloakUtils, customMetadataClient, updateConsignmentStatusClient, addOrUpdateBulkFileMetadataClient, displayPropertiesClient) - def handleRequest(event: APIGatewayProxyRequestEvent, context: Context): APIGatewayProxyResponseEvent = { - val pathParam = event.getPathParameters - + def handleRequest(input: Input, context: Context): APIGatewayProxyResponseEvent = { + val consignmentId = extractConsignmentId(input) val s3Files = S3Files(S3Utils(s3Async(s3Endpoint))) for { - draftMetadata <- IO(DraftMetadata(UUID.fromString(pathParam.get("consignmentId")))) + draftMetadata <- IO(DraftMetadata(UUID.fromString(consignmentId))) _ <- s3Files.downloadFile(bucket, draftMetadata) hasErrors <- validateMetadata(draftMetadata) _ <- if (hasErrors) s3Files.uploadFile(bucket, draftMetadata) else IO.unit @@ -62,6 +61,13 @@ class Lambda { } }.unsafeRunSync()(cats.effect.unsafe.implicits.global) + private def extractConsignmentId(lambdaInput: Input): String = { + lambdaInput match { + case api: APIGatewayProxyRequestEvent => api.getPathParameters.get("consignmentId") + case json: Map[String, Any] => json("consignmentId").asInstanceOf[String] + case _ => throw new IllegalArgumentException("Unexpected lambda input type") + } + } private def validateMetadata(draftMetadata: DraftMetadata): IO[Boolean] = { val clientSecret = getClientSecret(clientSecretPath, endpoint) for { From 4b858409ab1eaeab6b42530fa6b0c6f79de2a54c Mon Sep 17 00:00:00 2001 From: Annie Hawes Date: Fri, 26 Apr 2024 12:04:20 +0100 Subject: [PATCH 2/9] scalafmt --- build.sbt | 10 +++++----- .../draftmetadatavalidator/Lambda.scala | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build.sbt b/build.sbt index 0a06cc0..c089143 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,8 @@ import Dependencies._ -ThisBuild / scalaVersion := "2.13.10" -ThisBuild / version := "0.1.0-SNAPSHOT" -ThisBuild / organization := "uk.gov.nationalarchives" +ThisBuild / scalaVersion := "2.13.10" +ThisBuild / version := "0.1.0-SNAPSHOT" +ThisBuild / organization := "uk.gov.nationalarchives" lazy val root = (project in file(".")) .settings( @@ -27,8 +27,8 @@ lazy val root = (project in file(".")) ) (assembly / assemblyMergeStrategy) := { - case PathList("META-INF", xs@_*) => MergeStrategy.discard - case _ => MergeStrategy.first + case PathList("META-INF", xs @ _*) => MergeStrategy.discard + case _ => MergeStrategy.first } (Test / fork) := true diff --git a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala index 3601bc7..5cbb653 100644 --- a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala +++ b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala @@ -64,8 +64,8 @@ class Lambda[Input] extends RequestHandler[Input, APIGatewayProxyResponseEvent] private def extractConsignmentId(lambdaInput: Input): String = { lambdaInput match { case api: APIGatewayProxyRequestEvent => api.getPathParameters.get("consignmentId") - case json: Map[String, Any] => json("consignmentId").asInstanceOf[String] - case _ => throw new IllegalArgumentException("Unexpected lambda input type") + case json: Map[String, Any] => json("consignmentId").asInstanceOf[String] + case _ => throw new IllegalArgumentException("Unexpected lambda input type") } } private def validateMetadata(draftMetadata: DraftMetadata): IO[Boolean] = { From be2b18bd377e3678f717e059805d5fc448561d96 Mon Sep 17 00:00:00 2001 From: Annie Hawes Date: Tue, 30 Apr 2024 15:32:51 +0100 Subject: [PATCH 3/9] Update lambda to consume step function input --- .../draftmetadatavalidator/Lambda.scala | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala index 5cbb653..1e0e299 100644 --- a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala +++ b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala @@ -33,7 +33,7 @@ import java.time.format.DateTimeFormatter import java.util.UUID import scala.concurrent.ExecutionContext.Implicits.global -class Lambda[Input] extends RequestHandler[Input, APIGatewayProxyResponseEvent] { +class Lambda extends RequestHandler[ConsignmentInput, APIGatewayProxyResponseEvent] { implicit val backend: SttpBackend[Identity, Any] = HttpURLConnectionBackend() implicit val keycloakDeployment: TdrKeycloakDeployment = TdrKeycloakDeployment(authUrl, "tdr", timeToLiveSecs) @@ -46,11 +46,10 @@ class Lambda[Input] extends RequestHandler[Input, APIGatewayProxyResponseEvent] private val addOrUpdateBulkFileMetadataClient = new GraphQLClient[afm.Data, afm.Variables](apiUrl) private val graphQlApi: GraphQlApi = GraphQlApi(keycloakUtils, customMetadataClient, updateConsignmentStatusClient, addOrUpdateBulkFileMetadataClient, displayPropertiesClient) - def handleRequest(input: Input, context: Context): APIGatewayProxyResponseEvent = { - val consignmentId = extractConsignmentId(input) + def handleRequest(input: ConsignmentInput, context: Context): APIGatewayProxyResponseEvent = { val s3Files = S3Files(S3Utils(s3Async(s3Endpoint))) for { - draftMetadata <- IO(DraftMetadata(UUID.fromString(consignmentId))) + draftMetadata <- IO(DraftMetadata(UUID.fromString(input.consignmentId))) _ <- s3Files.downloadFile(bucket, draftMetadata) hasErrors <- validateMetadata(draftMetadata) _ <- if (hasErrors) s3Files.uploadFile(bucket, draftMetadata) else IO.unit @@ -60,14 +59,7 @@ class Lambda[Input] extends RequestHandler[Input, APIGatewayProxyResponseEvent] response } }.unsafeRunSync()(cats.effect.unsafe.implicits.global) - - private def extractConsignmentId(lambdaInput: Input): String = { - lambdaInput match { - case api: APIGatewayProxyRequestEvent => api.getPathParameters.get("consignmentId") - case json: Map[String, Any] => json("consignmentId").asInstanceOf[String] - case _ => throw new IllegalArgumentException("Unexpected lambda input type") - } - } + private def validateMetadata(draftMetadata: DraftMetadata): IO[Boolean] = { val clientSecret = getClientSecret(clientSecretPath, endpoint) for { @@ -160,3 +152,5 @@ object Lambda { def getFolderPath(draftMetadata: DraftMetadata) = s"""${rootDirectory}/${draftMetadata.consignmentId}""" } + +case class ConsignmentInput(consignmentId: String) \ No newline at end of file From 71b405c86ae7e4f057258964a0062d72c0bb2214 Mon Sep 17 00:00:00 2001 From: Annie Hawes Date: Tue, 30 Apr 2024 15:36:25 +0100 Subject: [PATCH 4/9] Comment out old signatures --- .../draftmetadatavalidator/LambdaRunner.scala | 2 +- .../draftmetadatavalidator/LambdaSpec.scala | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaRunner.scala b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaRunner.scala index 8188394..893399b 100644 --- a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaRunner.scala +++ b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaRunner.scala @@ -8,5 +8,5 @@ object LambdaRunner extends App { val pathParams = Map("consignmentId" -> "f82af3bf-b742-454c-9771-bfd6c5eae749").asJava val event = new APIGatewayProxyRequestEvent() event.setPathParameters(pathParams) - new Lambda().handleRequest(event, null) + // new Lambda().handleRequest(event, null) } diff --git a/src/test/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaSpec.scala b/src/test/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaSpec.scala index 9c3484f..583f304 100644 --- a/src/test/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaSpec.scala +++ b/src/test/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaSpec.scala @@ -45,8 +45,8 @@ class LambdaSpec extends ExternalServicesSpec { val pathParams = Map("consignmentId" -> consignmentId).asJava val event = new APIGatewayProxyRequestEvent() event.setPathParameters(pathParams) - val response = new Lambda().handleRequest(createEvent, mockContext) - response.getStatusCode should equal(200) + //val response = new Lambda().handleRequest(createEvent, mockContext) + //response.getStatusCode should equal(200) } "handleRequest" should "download the draft metadata csv file, validate it and re-upload to s3 bucket if it has any errors" in { @@ -57,7 +57,7 @@ class LambdaSpec extends ExternalServicesSpec { val pathParams = Map("consignmentId" -> consignmentId).asJava val event = new APIGatewayProxyRequestEvent() event.setPathParameters(pathParams) - val response = new Lambda().handleRequest(createEvent, mockContext) - response.getStatusCode should equal(200) + //val response = new Lambda().handleRequest(createEvent, mockContext) + //response.getStatusCode should equal(200) } } From 4fd61da3f6880c7ee9dde6783f293729a20721fe Mon Sep 17 00:00:00 2001 From: Annie Hawes Date: Tue, 30 Apr 2024 15:44:45 +0100 Subject: [PATCH 5/9] Some logging for input received --- .../gov/nationalarchives/draftmetadatavalidator/Lambda.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala index 1e0e299..abeefab 100644 --- a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala +++ b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala @@ -46,10 +46,11 @@ class Lambda extends RequestHandler[ConsignmentInput, APIGatewayProxyResponseEve private val addOrUpdateBulkFileMetadataClient = new GraphQLClient[afm.Data, afm.Variables](apiUrl) private val graphQlApi: GraphQlApi = GraphQlApi(keycloakUtils, customMetadataClient, updateConsignmentStatusClient, addOrUpdateBulkFileMetadataClient, displayPropertiesClient) - def handleRequest(input: ConsignmentInput, context: Context): APIGatewayProxyResponseEvent = { + def handleRequest(input: String, context: Context): APIGatewayProxyResponseEvent = { + println(s"Input: Input") val s3Files = S3Files(S3Utils(s3Async(s3Endpoint))) for { - draftMetadata <- IO(DraftMetadata(UUID.fromString(input.consignmentId))) + draftMetadata <- IO(DraftMetadata(UUID.fromString("03175df5-3f61-4036-af05-e2ad9ae6364d"))) _ <- s3Files.downloadFile(bucket, draftMetadata) hasErrors <- validateMetadata(draftMetadata) _ <- if (hasErrors) s3Files.uploadFile(bucket, draftMetadata) else IO.unit From 4e724fbbbaa5ef533add97cb790f254b66428afb Mon Sep 17 00:00:00 2001 From: Annie Hawes Date: Tue, 30 Apr 2024 15:46:50 +0100 Subject: [PATCH 6/9] Fix signature issue --- .../uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala index abeefab..2c1dd82 100644 --- a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala +++ b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala @@ -33,7 +33,7 @@ import java.time.format.DateTimeFormatter import java.util.UUID import scala.concurrent.ExecutionContext.Implicits.global -class Lambda extends RequestHandler[ConsignmentInput, APIGatewayProxyResponseEvent] { +class Lambda extends RequestHandler[String, APIGatewayProxyResponseEvent] { implicit val backend: SttpBackend[Identity, Any] = HttpURLConnectionBackend() implicit val keycloakDeployment: TdrKeycloakDeployment = TdrKeycloakDeployment(authUrl, "tdr", timeToLiveSecs) From f189277cca160a17d79b1aceee660dc5e994aad8 Mon Sep 17 00:00:00 2001 From: Annie Hawes Date: Wed, 1 May 2024 12:07:28 +0100 Subject: [PATCH 7/9] Trying with new signature --- .../nationalarchives/draftmetadatavalidator/Lambda.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala index 2c1dd82..9f753ed 100644 --- a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala +++ b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala @@ -33,7 +33,7 @@ import java.time.format.DateTimeFormatter import java.util.UUID import scala.concurrent.ExecutionContext.Implicits.global -class Lambda extends RequestHandler[String, APIGatewayProxyResponseEvent] { +class Lambda extends RequestHandler[java.util.Map[String, Object], APIGatewayProxyResponseEvent] { implicit val backend: SttpBackend[Identity, Any] = HttpURLConnectionBackend() implicit val keycloakDeployment: TdrKeycloakDeployment = TdrKeycloakDeployment(authUrl, "tdr", timeToLiveSecs) @@ -46,8 +46,8 @@ class Lambda extends RequestHandler[String, APIGatewayProxyResponseEvent] { private val addOrUpdateBulkFileMetadataClient = new GraphQLClient[afm.Data, afm.Variables](apiUrl) private val graphQlApi: GraphQlApi = GraphQlApi(keycloakUtils, customMetadataClient, updateConsignmentStatusClient, addOrUpdateBulkFileMetadataClient, displayPropertiesClient) - def handleRequest(input: String, context: Context): APIGatewayProxyResponseEvent = { - println(s"Input: Input") + def handleRequest(input: java.util.Map[String, Object], context: Context): APIGatewayProxyResponseEvent = { + println(s"Input: $input") val s3Files = S3Files(S3Utils(s3Async(s3Endpoint))) for { draftMetadata <- IO(DraftMetadata(UUID.fromString("03175df5-3f61-4036-af05-e2ad9ae6364d"))) From f4060e6b803b905a17a1863e539e5bab8b2709c4 Mon Sep 17 00:00:00 2001 From: Annie Hawes Date: Wed, 1 May 2024 17:20:56 +0100 Subject: [PATCH 8/9] Enable processing of step function and api proxy event input --- .../draftmetadatavalidator/Lambda.scala | 18 ++++++++++--- .../draftmetadatavalidator/LambdaRunner.scala | 6 ++--- .../draftmetadatavalidator/LambdaSpec.scala | 25 ++++++------------- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala index 9f753ed..5fb9f9e 100644 --- a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala +++ b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala @@ -30,6 +30,7 @@ import java.net.URI import java.sql.Timestamp import java.time.LocalDate import java.time.format.DateTimeFormatter +import java.util import java.util.UUID import scala.concurrent.ExecutionContext.Implicits.global @@ -47,10 +48,10 @@ class Lambda extends RequestHandler[java.util.Map[String, Object], APIGatewayPro private val graphQlApi: GraphQlApi = GraphQlApi(keycloakUtils, customMetadataClient, updateConsignmentStatusClient, addOrUpdateBulkFileMetadataClient, displayPropertiesClient) def handleRequest(input: java.util.Map[String, Object], context: Context): APIGatewayProxyResponseEvent = { - println(s"Input: $input") + val consignmentId = extractConsignmentId(input) val s3Files = S3Files(S3Utils(s3Async(s3Endpoint))) for { - draftMetadata <- IO(DraftMetadata(UUID.fromString("03175df5-3f61-4036-af05-e2ad9ae6364d"))) + draftMetadata <- IO(DraftMetadata(UUID.fromString(consignmentId))) _ <- s3Files.downloadFile(bucket, draftMetadata) hasErrors <- validateMetadata(draftMetadata) _ <- if (hasErrors) s3Files.uploadFile(bucket, draftMetadata) else IO.unit @@ -60,7 +61,16 @@ class Lambda extends RequestHandler[java.util.Map[String, Object], APIGatewayPro response } }.unsafeRunSync()(cats.effect.unsafe.implicits.global) - + + private def extractConsignmentId(input: util.Map[String, Object]): String = { + val inputParameters = input match { + case stepFunctionInput if stepFunctionInput.containsKey("consignmentId") => stepFunctionInput + case apiProxyRequestInput if apiProxyRequestInput.containsKey("pathParameters") => + apiProxyRequestInput.get("pathParameters").asInstanceOf[util.Map[String, Object]] + } + inputParameters.get("consignmentId").toString + } + private def validateMetadata(draftMetadata: DraftMetadata): IO[Boolean] = { val clientSecret = getClientSecret(clientSecretPath, endpoint) for { @@ -154,4 +164,4 @@ object Lambda { def getFolderPath(draftMetadata: DraftMetadata) = s"""${rootDirectory}/${draftMetadata.consignmentId}""" } -case class ConsignmentInput(consignmentId: String) \ No newline at end of file +case class ConsignmentInput(consignmentId: String) diff --git a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaRunner.scala b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaRunner.scala index 893399b..fc95b81 100644 --- a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaRunner.scala +++ b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaRunner.scala @@ -5,8 +5,6 @@ import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent import scala.jdk.CollectionConverters.MapHasAsJava object LambdaRunner extends App { - val pathParams = Map("consignmentId" -> "f82af3bf-b742-454c-9771-bfd6c5eae749").asJava - val event = new APIGatewayProxyRequestEvent() - event.setPathParameters(pathParams) - // new Lambda().handleRequest(event, null) + val input = Map("consignmentId" -> "f82af3bf-b742-454c-9771-bfd6c5eae749".asInstanceOf[Object]).asJava + new Lambda().handleRequest(input, null) } diff --git a/src/test/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaSpec.scala b/src/test/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaSpec.scala index 583f304..0d250ab 100644 --- a/src/test/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaSpec.scala +++ b/src/test/scala/uk/gov/nationalarchives/draftmetadatavalidator/LambdaSpec.scala @@ -12,7 +12,7 @@ import scala.jdk.CollectionConverters.MapHasAsJava class LambdaSpec extends ExternalServicesSpec { - val consignmentId = "f82af3bf-b742-454c-9771-bfd6c5eae749" + val consignmentId: Object = "f82af3bf-b742-454c-9771-bfd6c5eae749" val mockContext: Context = mock[Context] def mockS3GetResponse(fileName: String): StubMapping = { @@ -31,22 +31,13 @@ class LambdaSpec extends ExternalServicesSpec { ) } - def createEvent: APIGatewayProxyRequestEvent = { - val pathParams = Map("consignmentId" -> consignmentId).asJava - val event = new APIGatewayProxyRequestEvent() - event.setPathParameters(pathParams) - event - } - "handleRequest" should "download the draft metadata csv file, validate and save to db if it has no errors" in { authOkJson() graphqlOkJson(true) mockS3GetResponse("sample.csv") - val pathParams = Map("consignmentId" -> consignmentId).asJava - val event = new APIGatewayProxyRequestEvent() - event.setPathParameters(pathParams) - //val response = new Lambda().handleRequest(createEvent, mockContext) - //response.getStatusCode should equal(200) + val input = Map("consignmentId" -> consignmentId).asJava + val response = new Lambda().handleRequest(input, mockContext) + response.getStatusCode should equal(200) } "handleRequest" should "download the draft metadata csv file, validate it and re-upload to s3 bucket if it has any errors" in { @@ -54,10 +45,8 @@ class LambdaSpec extends ExternalServicesSpec { graphqlOkJson() mockS3GetResponse("invalid-sample.csv") mockS3PutResponse() - val pathParams = Map("consignmentId" -> consignmentId).asJava - val event = new APIGatewayProxyRequestEvent() - event.setPathParameters(pathParams) - //val response = new Lambda().handleRequest(createEvent, mockContext) - //response.getStatusCode should equal(200) + val input = Map("consignmentId" -> consignmentId).asJava + val response = new Lambda().handleRequest(input, mockContext) + response.getStatusCode should equal(200) } } From fe347ecd9a8651f79ee545a72b2b6cc6e30f27de Mon Sep 17 00:00:00 2001 From: Annie Hawes Date: Wed, 1 May 2024 17:24:55 +0100 Subject: [PATCH 9/9] Remove redundant export and case class --- .../gov/nationalarchives/draftmetadatavalidator/Lambda.scala | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala index 5fb9f9e..0225229 100644 --- a/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala +++ b/src/main/scala/uk/gov/nationalarchives/draftmetadatavalidator/Lambda.scala @@ -2,7 +2,7 @@ package uk.gov.nationalarchives.draftmetadatavalidator import cats.effect.IO import com.amazonaws.services.lambda.runtime.{Context, RequestHandler} -import com.amazonaws.services.lambda.runtime.events.{APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent} +import com.amazonaws.services.lambda.runtime.events.{APIGatewayProxyResponseEvent} import graphql.codegen.GetCustomMetadata.customMetadata.CustomMetadata import graphql.codegen.GetCustomMetadata.{customMetadata => cm} import graphql.codegen.GetDisplayProperties.displayProperties.DisplayProperties @@ -163,5 +163,3 @@ object Lambda { def getFolderPath(draftMetadata: DraftMetadata) = s"""${rootDirectory}/${draftMetadata.consignmentId}""" } - -case class ConsignmentInput(consignmentId: String)