src/test/java/edu/ucla/library/bucketeer/handlers/DeleteJobHandlerTest.java
@Test
    public final void testDeleteJobHandler(final TestContext aContext) {
        final Async asyncTask = aContext.async();
        final int port = aContext.get(Config.HTTP_PORT);
        final WebClient webClient = WebClient.create(myVertx);

        // Get our shared data store so we can insert a job we want to test against
        myVertx.sharedData().<String, Job>getLocalAsyncMap(Constants.LAMBDA_JOBS, getMap -> {
            if (getMap.succeeded()) {
                final List<Item> items = Arrays.asList(new Item().setWorkflowState(WorkflowState.SUCCEEDED));

                getMap.result().put(JOB_NAME, new Job(JOB_NAME).setItems(items), put -> {
                    if (put.succeeded()) {
                        // Once we've put the job into our shared data store, try to delete it
                        webClient.delete(port, Constants.UNSPECIFIED_HOST, TEST_URL).send(deletion -> {
                            if (deletion.succeeded()) {
                                final HttpResponse<Buffer> response = deletion.result();
                                final int statusCode = response.statusCode();

                                aContext.assertEquals(HTTP.OK, statusCode, LOGGER.getMessage(
                                        MessageCodes.BUCKETEER_114, statusCode, response.statusMessage()));

                                TestUtils.complete(asyncTask);
                            } else {
                                aContext.fail(deletion.cause());
                            }
                        });
                    } else {
                        aContext.fail(put.cause());
                    }
                });
            } else {
                aContext.fail(getMap.cause());
            }
        });
    }
/**
     * Tests deleting a job from the batch workflow.
     *
     * @param aContext A testing context
     */
Tests deleting a job from the batch workflow.
@param aContext A testing context
Tests deleting a job from the batch workflow . @param aContext A testing context
@Test
    public final void testDeleteJobHandler(final TestContext aContext) {
        final Async asyncTask = aContext.async();
        final int port = aContext.get(Config.HTTP_PORT);
        final WebClient webClient = WebClient.create(myVertx);
        myVertx.sharedData().<String, Job>getLocalAsyncMap(Constants.LAMBDA_JOBS, getMap -> {
            if (getMap.succeeded()) {
                final List<Item> items = Arrays.asList(new Item().setWorkflowState(WorkflowState.SUCCEEDED));
                getMap.result().put(JOB_NAME, new Job(JOB_NAME).setItems(items), put -> {
                    if (put.succeeded()) {
                        webClient.delete(port, Constants.UNSPECIFIED_HOST, TEST_URL).send(deletion -> {
                            if (deletion.succeeded()) {
                                final HttpResponse<Buffer> response = deletion.result();
                                final int statusCode = response.statusCode();
                                aContext.assertEquals(HTTP.OK, statusCode, LOGGER.getMessage(
                                        MessageCodes.BUCKETEER_114, statusCode, response.statusMessage()));
                                TestUtils.complete(asyncTask);
                            } else {
                                aContext.fail(deletion.cause());
                            }
                        });
                    } else {
                        aContext.fail(put.cause());
                    }
                });
            } else {
                aContext.fail(getMap.cause());
            }
        });
    }
@ Test public final void testDeleteJobHandler ( final TestContext aContext ) { final Async asyncTask = aContext . async ( ) ; final int port = aContext . get ( Config . HTTP_PORT ) ; final WebClient webClient = WebClient . create ( myVertx ) ; myVertx . sharedData ( ) . < String , Job > getLocalAsyncMap ( Constants . LAMBDA_JOBS , getMap -> { if ( getMap . succeeded ( ) ) { final List < Item > items = Arrays . asList ( new Item ( ) . setWorkflowState ( WorkflowState . SUCCEEDED ) ) ; getMap . result ( ) . put ( JOB_NAME , new Job ( JOB_NAME ) . setItems ( items ) , put -> { if ( put . succeeded ( ) ) { webClient . delete ( port , Constants . UNSPECIFIED_HOST , TEST_URL ) . send ( deletion -> { if ( deletion . succeeded ( ) ) { final HttpResponse < Buffer > response = deletion . result ( ) ; final int statusCode = response . statusCode ( ) ; aContext . assertEquals ( HTTP . OK , statusCode , LOGGER . getMessage ( MessageCodes . BUCKETEER_114 , statusCode , response . statusMessage ( ) ) ) ; TestUtils . complete ( asyncTask ) ; } else { aContext . fail ( deletion . cause ( ) ) ; } } ) ; } else { aContext . fail ( put . cause ( ) ) ; } } ) ; } else { aContext . fail ( getMap . cause ( ) ) ; } } ) ; }
Tests deleting a job from the batch workflow.
Tests deleting a job from the batch workflow .
// Get our shared data store so we can insert a job we want to test against // Once we've put the job into our shared data store, try to delete it