src/test/java/edu/ucla/library/bucketeer/utils/FilesystemWriteCsvFfOnT.java
@Test
    public void testWriteCsv(final TestContext aContext) {
        final WebClient webClient = WebClient.create(myTestContext.vertx());
        final int port = Integer.parseInt(System.getProperty(Config.HTTP_PORT));
        final Async asyncTask = aContext.async();
        final MultipartForm form = MultipartForm.create()
                .attribute(Constants.SLACK_HANDLE, "bucketeer")
                .textFileUpload(Constants.CSV_DATA, TEST_CSV.getName(), TEST_CSV.getAbsolutePath(), Constants.CSV);

        webClient.post(port, Constants.UNSPECIFIED_HOST, "/batch/input/csv").sendMultipartForm(form, sendForm -> {
            if (sendForm.succeeded()) {
                // Complete the job
                final Promise<Void> jobCompletion = Promise.promise();

                jobCompletion.future().onComplete(fakeLambda -> {
                    if (fakeLambda.succeeded()) {
                        final Path srcDir = Path.of(System.getProperty(Config.FILESYSTEM_CSV_MOUNT));
                        final String srcDirName = srcDir.getFileName().toString();
                        final File tmpDestDir = new File(TestConstants.TMP_DEST_DIR);

                        final Path expectedFilePath = Path.of(tmpDestDir.getPath(), srcDirName, TEST_CSV.getName());
                        final File expectedFile = new File(expectedFilePath.toString());

                        // Confirm we can create our temporary test directory (or that it already exists)
                        aContext.assertTrue(tmpDestDir.exists() || tmpDestDir.mkdirs());

                        // Confirm we can copy the test container's files to the temporary test directory
                        aContext.assertTrue(
                                DockerUtils.copy(TestConstants.BUCKETEER_FF_ON, srcDir.toString(),
                                        tmpDestDir.toString()));

                        // Confirm the file we expect to exist actually does
                        aContext.assertTrue(expectedFile.exists());

                        FileUtils.delete(expectedFile);
                        TestUtils.complete(asyncTask);
                    } else {
                        aContext.fail(fakeLambda.cause());
                    }
                });
                fakeLambda(webClient, port, Constants.UNSPECIFIED_HOST, jobCompletion);
            } else {
                aContext.fail(sendForm.cause());
            }
        });
    }
/**
     * Tests writing a CSV to the local filesystem mount.
     *
     * This is an e2e test (although the AWS Lambda is mocked).
     *
     * @param aContext A test context
     */
Tests writing a CSV to the local filesystem mount.
This is an e2e test (although the AWS Lambda is mocked).

@param aContext A test context
Tests writing a CSV to the local filesystem mount . This is an e2e test ( although the AWS Lambda is mocked ) . @param aContext A test context
@Test
    public void testWriteCsv(final TestContext aContext) {
        final WebClient webClient = WebClient.create(myTestContext.vertx());
        final int port = Integer.parseInt(System.getProperty(Config.HTTP_PORT));
        final Async asyncTask = aContext.async();
        final MultipartForm form = MultipartForm.create()
                .attribute(Constants.SLACK_HANDLE, "bucketeer")
                .textFileUpload(Constants.CSV_DATA, TEST_CSV.getName(), TEST_CSV.getAbsolutePath(), Constants.CSV);
        webClient.post(port, Constants.UNSPECIFIED_HOST, "/batch/input/csv").sendMultipartForm(form, sendForm -> {
            if (sendForm.succeeded()) {
                final Promise<Void> jobCompletion = Promise.promise();
                jobCompletion.future().onComplete(fakeLambda -> {
                    if (fakeLambda.succeeded()) {
                        final Path srcDir = Path.of(System.getProperty(Config.FILESYSTEM_CSV_MOUNT));
                        final String srcDirName = srcDir.getFileName().toString();
                        final File tmpDestDir = new File(TestConstants.TMP_DEST_DIR);
                        final Path expectedFilePath = Path.of(tmpDestDir.getPath(), srcDirName, TEST_CSV.getName());
                        final File expectedFile = new File(expectedFilePath.toString());
                        aContext.assertTrue(tmpDestDir.exists() || tmpDestDir.mkdirs());
                        aContext.assertTrue(
                                DockerUtils.copy(TestConstants.BUCKETEER_FF_ON, srcDir.toString(),
                                        tmpDestDir.toString()));
                        aContext.assertTrue(expectedFile.exists());
                        FileUtils.delete(expectedFile);
                        TestUtils.complete(asyncTask);
                    } else {
                        aContext.fail(fakeLambda.cause());
                    }
                });
                fakeLambda(webClient, port, Constants.UNSPECIFIED_HOST, jobCompletion);
            } else {
                aContext.fail(sendForm.cause());
            }
        });
    }
@ Test public void testWriteCsv ( final TestContext aContext ) { final WebClient webClient = WebClient . create ( myTestContext . vertx ( ) ) ; final int port = Integer . parseInt ( System . getProperty ( Config . HTTP_PORT ) ) ; final Async asyncTask = aContext . async ( ) ; final MultipartForm form = MultipartForm . create ( ) . attribute ( Constants . SLACK_HANDLE , "bucketeer" ) . textFileUpload ( Constants . CSV_DATA , TEST_CSV . getName ( ) , TEST_CSV . getAbsolutePath ( ) , Constants . CSV ) ; webClient . post ( port , Constants . UNSPECIFIED_HOST , "/batch/input/csv" ) . sendMultipartForm ( form , sendForm -> { if ( sendForm . succeeded ( ) ) { final Promise < Void > jobCompletion = Promise . promise ( ) ; jobCompletion . future ( ) . onComplete ( fakeLambda -> { if ( fakeLambda . succeeded ( ) ) { final Path srcDir = Path . of ( System . getProperty ( Config . FILESYSTEM_CSV_MOUNT ) ) ; final String srcDirName = srcDir . getFileName ( ) . toString ( ) ; final File tmpDestDir = new File ( TestConstants . TMP_DEST_DIR ) ; final Path expectedFilePath = Path . of ( tmpDestDir . getPath ( ) , srcDirName , TEST_CSV . getName ( ) ) ; final File expectedFile = new File ( expectedFilePath . toString ( ) ) ; aContext . assertTrue ( tmpDestDir . exists ( ) || tmpDestDir . mkdirs ( ) ) ; aContext . assertTrue ( DockerUtils . copy ( TestConstants . BUCKETEER_FF_ON , srcDir . toString ( ) , tmpDestDir . toString ( ) ) ) ; aContext . assertTrue ( expectedFile . exists ( ) ) ; FileUtils . delete ( expectedFile ) ; TestUtils . complete ( asyncTask ) ; } else { aContext . fail ( fakeLambda . cause ( ) ) ; } } ) ; fakeLambda ( webClient , port , Constants . UNSPECIFIED_HOST , jobCompletion ) ; } else { aContext . fail ( sendForm . cause ( ) ) ; } } ) ; }
Tests writing a CSV to the local filesystem mount.
Tests writing a CSV to the local filesystem mount .
// Complete the job // Confirm we can create our temporary test directory (or that it already exists) // Confirm we can copy the test container's files to the temporary test directory // Confirm the file we expect to exist actually does