def main()

in lambda/input/src/main/scala/TestMain.scala [34:75]


  def main(args:Array[String]) = {
    implicit val system:ActorSystem = ActorSystem("root")
    implicit val mat:Materializer = Materializer.matFromSystem
    val m = new InputLambdaMain

    if(args.length<2) {
      println("Test program for input lambda. You must specify a bucket name for the first parameter and an object key for the second")
      System.exit(2)
    }
    val bucketName = args.head
    val objectKey = args(1)

    if(bucketName=="" || objectKey=="") {
      println("Test program for input lambda. You must specify a bucket name for the first parameter and an object key for the second")
      System.exit(2)
    }
    implicit val client = S3Client.create()

    getObjectInformation(bucketName, objectKey) match {
      case Some(record) =>
        val fakeEvents = Seq(
          new S3EventNotificationRecord("eu-west-1", "ObjectCreated:Put", "Test", LocalDateTime.now().toString, "1.0",
            null,
            null,
            new S3EventNotification.S3Entity(
              "fake-configuration",
              new S3EventNotification.S3BucketEntity(bucketName, new S3EventNotification.UserIdentityEntity("test"), ""),
              record,
              "unknown"
            ),
            new S3EventNotification.UserIdentityEntity("test")
          )
        )

        val evt = new S3Event(fakeEvents.asJava)
        m.handleRequest(evt, null)
        System.exit(0)
      case None=>
        println("Nothing was found")
        System.exit(1)
    }
  }