src/test/java/edu/ucla/library/bucketeer/utils/FilesystemWriteCsvFfOnT.java
private void fakeLambda(final WebClient aWebClient, final int aPort, final String aHost,
            final Promise<Void> aPromise) {
        Future.<Void>future(s3BucketVerticleSwap -> {
            s3BucketVerticleSwap.complete();
        }).compose(success -> {
            return Future.<List<String>>future(getImageIds -> {
                aWebClient.get(aPort, aHost, "/batch/jobs/live-test-docker").send(get -> {
                    if (get.succeeded()) {
                        // Gets a list of the image IDs of the current jobs
                        final List<String> imageIds = get.result().bodyAsJsonObject().getJsonArray(Constants.JOBS)
                                .stream().map(JsonObject.class::cast)
                                .filter(job -> job.getString(Constants.STATUS).equals(Constants.EMPTY))
                                .map(job -> job.getString(Constants.IMAGE_ID)).collect(Collectors.toList());

                        getImageIds.complete(imageIds);
                    } else {
                        getImageIds.fail(get.cause());
                    }
                });
            });
        }).compose(imageIds -> {
            final List<Future> futures = imageIds.stream().map(imageId -> {
                return Future.<Void>future(finishJob -> {
                    final String urlEncodedImageId = URLEncoder.encode(imageId, StandardCharsets.UTF_8);
                    final String urlPath = "/batch/jobs/live-test-docker/" + urlEncodedImageId + "/true";

                    // Tell our Bucketeer instance to treat the job as completed
                    aWebClient.patch(aPort, aHost, urlPath).send(patch -> {
                        if (patch.succeeded()) {
                            finishJob.complete();
                        } else {
                            finishJob.fail(patch.cause());
                        }
                    });
                });
            }).collect(Collectors.toList());

            return CompositeFuture.all(futures);
        }).onSuccess(success -> {
            aPromise.complete();
        }).onFailure(failure -> {
            aPromise.fail(failure.getCause());
        });
    }
/**
     * Mock the response from AWS Lambda in order to complete the job.
     *
     * @param aWebClient A client used to send requests to our Bucketeer instance
     * @param aPort The port of our Bucketeer instance
     * @param aHost The host of our Bucketeer instance
     * @param aPromise A promise to complete upon job completion, or fail
     */
Mock the response from AWS Lambda in order to complete the job.
@param aWebClient A client used to send requests to our Bucketeer instance
@param aPort The port of our Bucketeer instance
@param aHost The host of our Bucketeer instance
@param aPromise A promise to complete upon job completion, or fail
Mock the response from AWS Lambda in order to complete the job . @param aWebClient A client used to send requests to our Bucketeer instance @param aPort The port of our Bucketeer instance @param aHost The host of our Bucketeer instance @param aPromise A promise to complete upon job completion or fail
private void fakeLambda(final WebClient aWebClient, final int aPort, final String aHost,
            final Promise<Void> aPromise) {
        Future.<Void>future(s3BucketVerticleSwap -> {
            s3BucketVerticleSwap.complete();
        }).compose(success -> {
            return Future.<List<String>>future(getImageIds -> {
                aWebClient.get(aPort, aHost, "/batch/jobs/live-test-docker").send(get -> {
                    if (get.succeeded()) {
                        final List<String> imageIds = get.result().bodyAsJsonObject().getJsonArray(Constants.JOBS)
                                .stream().map(JsonObject.class::cast)
                                .filter(job -> job.getString(Constants.STATUS).equals(Constants.EMPTY))
                                .map(job -> job.getString(Constants.IMAGE_ID)).collect(Collectors.toList());
                        getImageIds.complete(imageIds);
                    } else {
                        getImageIds.fail(get.cause());
                    }
                });
            });
        }).compose(imageIds -> {
            final List<Future> futures = imageIds.stream().map(imageId -> {
                return Future.<Void>future(finishJob -> {
                    final String urlEncodedImageId = URLEncoder.encode(imageId, StandardCharsets.UTF_8);
                    final String urlPath = "/batch/jobs/live-test-docker/" + urlEncodedImageId + "/true";
                    aWebClient.patch(aPort, aHost, urlPath).send(patch -> {
                        if (patch.succeeded()) {
                            finishJob.complete();
                        } else {
                            finishJob.fail(patch.cause());
                        }
                    });
                });
            }).collect(Collectors.toList());
            return CompositeFuture.all(futures);
        }).onSuccess(success -> {
            aPromise.complete();
        }).onFailure(failure -> {
            aPromise.fail(failure.getCause());
        });
    }
private void fakeLambda ( final WebClient aWebClient , final int aPort , final String aHost , final Promise < Void > aPromise ) { Future . < Void > future ( s3BucketVerticleSwap -> { s3BucketVerticleSwap . complete ( ) ; } ) . compose ( success -> { return Future . < List < String > > future ( getImageIds -> { aWebClient . get ( aPort , aHost , "/batch/jobs/live-test-docker" ) . send ( get -> { if ( get . succeeded ( ) ) { final List < String > imageIds = get . result ( ) . bodyAsJsonObject ( ) . getJsonArray ( Constants . JOBS ) . stream ( ) . map ( JsonObject . class :: cast ) . filter ( job -> job . getString ( Constants . STATUS ) . equals ( Constants . EMPTY ) ) . map ( job -> job . getString ( Constants . IMAGE_ID ) ) . collect ( Collectors . toList ( ) ) ; getImageIds . complete ( imageIds ) ; } else { getImageIds . fail ( get . cause ( ) ) ; } } ) ; } ) ; } ) . compose ( imageIds -> { final List < Future > futures = imageIds . stream ( ) . map ( imageId -> { return Future . < Void > future ( finishJob -> { final String urlEncodedImageId = URLEncoder . encode ( imageId , StandardCharsets . UTF_8 ) ; final String urlPath = "/batch/jobs/live-test-docker/" + urlEncodedImageId + "/true" ; aWebClient . patch ( aPort , aHost , urlPath ) . send ( patch -> { if ( patch . succeeded ( ) ) { finishJob . complete ( ) ; } else { finishJob . fail ( patch . cause ( ) ) ; } } ) ; } ) ; } ) . collect ( Collectors . toList ( ) ) ; return CompositeFuture . all ( futures ) ; } ) . onSuccess ( success -> { aPromise . complete ( ) ; } ) . onFailure ( failure -> { aPromise . fail ( failure . getCause ( ) ) ; } ) ; }
Mock the response from AWS Lambda in order to complete the job.
Mock the response from AWS Lambda in order to complete the job .
// Gets a list of the image IDs of the current jobs // Tell our Bucketeer instance to treat the job as completed