src/test/java/edu/ucla/library/iiif/auth/handlers/AccessLevelHandlerIT.java
@Test
    public void testGetAccessLevelUnknownItem(final Vertx aVertx, final VertxTestContext aContext) {
        final String id = "ark:/21198/unknown";
        final String requestUri =
                StringUtils.format(GET_ACCESS_LEVEL_PATH, URLEncoder.encode(id, StandardCharsets.UTF_8));
        final HttpRequest<?> getAccessLevel = myWebClient.get(myPort, TestConstants.INADDR_ANY, requestUri);

        getAccessLevel.send().onSuccess(response -> {
            final JsonObject responseBody = response.bodyAsJsonObject();
            final JsonObject expected =
                    new JsonObject().put(ResponseJsonKeys.ERROR, DatabaseServiceError.NOT_FOUND.toString())
                            .put(ResponseJsonKeys.MESSAGE, LOGGER.getMessage(MessageCodes.AUTH_004, id));

            assertEquals(HTTP.NOT_FOUND, response.statusCode());
            assertEquals(MediaType.APPLICATION_JSON.toString(), response.headers().get(HttpHeaders.CONTENT_TYPE));
            assertEquals(expected, responseBody);

            aContext.completeNow();
        }).onFailure(aContext::failNow);
    }
/**
     * Tests that a client gets the expected error response when requesting the access level of an unknown item.
     *
     * @param aVertx A Vert.x instance
     * @param aContext A test context
     */
Tests that a client gets the expected error response when requesting the access level of an unknown item.
@param aVertx A Vert.x instance
@param aContext A test context
Tests that a client gets the expected error response when requesting the access level of an unknown item . @param aVertx A Vert . x instance @param aContext A test context
@Test
    public void testGetAccessLevelUnknownItem(final Vertx aVertx, final VertxTestContext aContext) {
        final String id = "ark:/21198/unknown";
        final String requestUri =
                StringUtils.format(GET_ACCESS_LEVEL_PATH, URLEncoder.encode(id, StandardCharsets.UTF_8));
        final HttpRequest<?> getAccessLevel = myWebClient.get(myPort, TestConstants.INADDR_ANY, requestUri);
        getAccessLevel.send().onSuccess(response -> {
            final JsonObject responseBody = response.bodyAsJsonObject();
            final JsonObject expected =
                    new JsonObject().put(ResponseJsonKeys.ERROR, DatabaseServiceError.NOT_FOUND.toString())
                            .put(ResponseJsonKeys.MESSAGE, LOGGER.getMessage(MessageCodes.AUTH_004, id));
            assertEquals(HTTP.NOT_FOUND, response.statusCode());
            assertEquals(MediaType.APPLICATION_JSON.toString(), response.headers().get(HttpHeaders.CONTENT_TYPE));
            assertEquals(expected, responseBody);
            aContext.completeNow();
        }).onFailure(aContext::failNow);
    }
@ Test public void testGetAccessLevelUnknownItem ( final Vertx aVertx , final VertxTestContext aContext ) { final String id = "ark:/21198/unknown" ; final String requestUri = StringUtils . format ( GET_ACCESS_LEVEL_PATH , URLEncoder . encode ( id , StandardCharsets . UTF_8 ) ) ; final HttpRequest < ? > getAccessLevel = myWebClient . get ( myPort , TestConstants . INADDR_ANY , requestUri ) ; getAccessLevel . send ( ) . onSuccess ( response -> { final JsonObject responseBody = response . bodyAsJsonObject ( ) ; final JsonObject expected = new JsonObject ( ) . put ( ResponseJsonKeys . ERROR , DatabaseServiceError . NOT_FOUND . toString ( ) ) . put ( ResponseJsonKeys . MESSAGE , LOGGER . getMessage ( MessageCodes . AUTH_004 , id ) ) ; assertEquals ( HTTP . NOT_FOUND , response . statusCode ( ) ) ; assertEquals ( MediaType . APPLICATION_JSON . toString ( ) , response . headers ( ) . get ( HttpHeaders . CONTENT_TYPE ) ) ; assertEquals ( expected , responseBody ) ; aContext . completeNow ( ) ; } ) . onFailure ( aContext :: failNow ) ; }
Tests that a client gets the expected error response when requesting the access level of an unknown item.
Tests that a client gets the expected error response when requesting the access level of an unknown item .