Mocking AmazonS3 listObjects function in scala

52 Views Asked by At

Im trying to mock listObjects function in AmazonS3 interface, in order to return specific objects when running tests without calling s3.

The code I want to test is doing this logic:

val objects = s3Client.listObjects(
      new ListObjectsRequest()
        .withBucketName(bucketName)
        .withMaxKeys(2000)
    )

    val latestSchemaKey = objects.getObjectSummaries.toList
      .map(s => s.getKey)
      .sorted(Ordering[String].reverse)
      .head

I wanted to create a new ObjectListing and add objectSummaries to it, but seems like there are not setters for objectSummaries.

Is there something Im missing out? Thanks for helping!

Looked into ObjectListing class functions and noticed its not possible to set objects :)

0

There are 0 best solutions below