src/test/java/edu/ucla/library/bucketeer/handlers/GetJobsHandlerTest.java
@Test
    public final void testGetJobsRequest(final TestContext aContext) {
        final Async asyncTask = aContext.async();
        final int port = aContext.get(Config.HTTP_PORT);

        myVertx.sharedData().<String, Job>getLocalAsyncMap(Constants.LAMBDA_JOBS, getMap -> {
            if (getMap.succeeded()) {
                final AsyncMap<String, Job> jobMap = getMap.result();

                jobMap.put(JOB_NAME, new Job(JOB_NAME), put -> {
                    if (put.succeeded()) {
                        final WebClient webClient = WebClient.create(myVertx);

                        webClient.get(port, Constants.UNSPECIFIED_HOST, TEST_URL).send(get -> {
                            if (get.succeeded()) {
                                final HttpResponse<Buffer> response = get.result();
                                final int statusCode = response.statusCode();
                                final String message = response.statusMessage();

                                if (statusCode == HTTP.OK) {
                                    final JsonObject found = response.bodyAsJsonObject();
                                    final JsonObject expected = new JsonObject();

                                    expected.put(Constants.COUNT, 1);
                                    expected.put(Constants.JOBS, new JsonArray().add(JOB_NAME));

                                    aContext.assertEquals(expected, found);
                                    TestUtils.complete(asyncTask);
                                } else {
                                    aContext.fail(LOGGER.getMessage(MessageCodes.BUCKETEER_114, statusCode, message));
                                }
                            } else {
                                aContext.fail(get.cause());
                            }
                        });
                    } else {
                        aContext.fail(put.cause());
                    }
                });
            } else {
                aContext.fail(getMap.cause());
            }
        });
    }
/**
     * Tests getting the in-progress batch jobs.
     *
     * @param aContext A testing context
     */
Tests getting the in-progress batch jobs.
@param aContext A testing context
Tests getting the in - progress batch jobs . @param aContext A testing context
@Test
    public final void testGetJobsRequest(final TestContext aContext) {
        final Async asyncTask = aContext.async();
        final int port = aContext.get(Config.HTTP_PORT);
        myVertx.sharedData().<String, Job>getLocalAsyncMap(Constants.LAMBDA_JOBS, getMap -> {
            if (getMap.succeeded()) {
                final AsyncMap<String, Job> jobMap = getMap.result();
                jobMap.put(JOB_NAME, new Job(JOB_NAME), put -> {
                    if (put.succeeded()) {
                        final WebClient webClient = WebClient.create(myVertx);
                        webClient.get(port, Constants.UNSPECIFIED_HOST, TEST_URL).send(get -> {
                            if (get.succeeded()) {
                                final HttpResponse<Buffer> response = get.result();
                                final int statusCode = response.statusCode();
                                final String message = response.statusMessage();
                                if (statusCode == HTTP.OK) {
                                    final JsonObject found = response.bodyAsJsonObject();
                                    final JsonObject expected = new JsonObject();
                                    expected.put(Constants.COUNT, 1);
                                    expected.put(Constants.JOBS, new JsonArray().add(JOB_NAME));
                                    aContext.assertEquals(expected, found);
                                    TestUtils.complete(asyncTask);
                                } else {
                                    aContext.fail(LOGGER.getMessage(MessageCodes.BUCKETEER_114, statusCode, message));
                                }
                            } else {
                                aContext.fail(get.cause());
                            }
                        });
                    } else {
                        aContext.fail(put.cause());
                    }
                });
            } else {
                aContext.fail(getMap.cause());
            }
        });
    }
@ Test public final void testGetJobsRequest ( final TestContext aContext ) { final Async asyncTask = aContext . async ( ) ; final int port = aContext . get ( Config . HTTP_PORT ) ; myVertx . sharedData ( ) . < String , Job > getLocalAsyncMap ( Constants . LAMBDA_JOBS , getMap -> { if ( getMap . succeeded ( ) ) { final AsyncMap < String , Job > jobMap = getMap . result ( ) ; jobMap . put ( JOB_NAME , new Job ( JOB_NAME ) , put -> { if ( put . succeeded ( ) ) { final WebClient webClient = WebClient . create ( myVertx ) ; webClient . get ( port , Constants . UNSPECIFIED_HOST , TEST_URL ) . send ( get -> { if ( get . succeeded ( ) ) { final HttpResponse < Buffer > response = get . result ( ) ; final int statusCode = response . statusCode ( ) ; final String message = response . statusMessage ( ) ; if ( statusCode == HTTP . OK ) { final JsonObject found = response . bodyAsJsonObject ( ) ; final JsonObject expected = new JsonObject ( ) ; expected . put ( Constants . COUNT , 1 ) ; expected . put ( Constants . JOBS , new JsonArray ( ) . add ( JOB_NAME ) ) ; aContext . assertEquals ( expected , found ) ; TestUtils . complete ( asyncTask ) ; } else { aContext . fail ( LOGGER . getMessage ( MessageCodes . BUCKETEER_114 , statusCode , message ) ) ; } } else { aContext . fail ( get . cause ( ) ) ; } } ) ; } else { aContext . fail ( put . cause ( ) ) ; } } ) ; } else { aContext . fail ( getMap . cause ( ) ) ; } } ) ; }
Tests getting the in-progress batch jobs.
Tests getting the in - progress batch jobs .