fun canParseManifestFileAndLoadContent()

in core/tst/software/aws/toolkits/core/lambda/LambdaSampleEventProviderTest.kt [23:77]


    fun canParseManifestFileAndLoadContent() {
        val manifestFile = tempPath.newFile()
        val firstFile = tempPath.newFile()
        val secondFile = tempPath.newFile()

        manifestFile.writeText(
            """
            <requests>
                <request category="AWS">
                    <name>First Sample</name>
                    <filename>first.json</filename>
                </request>
                <request category="AWS">
                    <name>Second Sample</name>
                    <filename>second.json</filename>
                </request>
            </requests>
            """.trimIndent()
        )

        val firstContent =
            """
            {
                "hello": "world"
            }
            """.trimIndent()

        firstFile.writeText(firstContent)

        val secondContent =
            """
            ["hello"]
            """.trimIndent()

        secondFile.writeText(secondContent)

        val resourceResolver = mock<RemoteResourceResolver> {
            on { resolve(LambdaSampleEventManifestResource) }.thenReturn(CompletableFuture.completedFuture(manifestFile.toPath()))
            on { resolve(LambdaSampleEventResource("first.json")) }.thenReturn(CompletableFuture.completedFuture(firstFile.toPath()))
            on { resolve(LambdaSampleEventResource("second.json")) }.thenReturn(CompletableFuture.completedFuture(secondFile.toPath()))
        }
        val sut = LambdaSampleEventProvider(resourceResolver)

        val samples = sut.get().toCompletableFuture().get()

        assertThat(samples).hasSize(2)

        val first = samples[0]
        assertThat(first.name).isEqualTo("First Sample")
        assertThat(first.content.toCompletableFuture().get()).isEqualTo(firstContent)

        val second = samples[1]
        assertThat(second.name).isEqualTo("Second Sample")
        assertThat(second.content.toCompletableFuture().get()).isEqualTo(secondContent)
    }