Package com.box.restclientv2.exceptions

Examples of com.box.restclientv2.exceptions.BoxSDKException


    @Test
    public void ConstructHttpUriRequestTest() {
        BoxJSONParser parser = new BoxJSONParser(new BoxResourceHub());
        try {
            Assert.assertEquals(HttpGet.class, (new DefaultBoxRequest(config, parser, uri, RestMethod.GET, null)).constructHttpUriRequest().getClass());
            Assert.assertEquals(HttpPut.class, (new DefaultBoxRequest(config, parser, uri, RestMethod.PUT, null)).constructHttpUriRequest().getClass());
            Assert.assertEquals(HttpPost.class, (new DefaultBoxRequest(config, parser, uri, RestMethod.POST, null)).constructHttpUriRequest().getClass());
            Assert.assertEquals(HttpDelete.class, (new DefaultBoxRequest(config, parser, uri, RestMethod.DELETE, null)).constructHttpUriRequest().getClass());
        }
        catch (BoxRestException e) {
            Assert.fail(e.getMessage());
        }
    }
View Full Code Here


public class DefaultAuthHeaderAuthTest {

    @Test
    public void testSetAuth() throws BoxRestException, AuthFatalFailureException {
        DefaultBoxRequest request = new DefaultBoxRequest(TestUtils.getConfig(), new BoxJSONParser(new BoxResourceHub()), "fakeuri", RestMethod.GET, null);
        String token = "test token";
        String apiKey = "test api key";
        String deviceId = "f9h30fhflzkhg84ghgzhgr534653";
        String deviceName = "Galaxy Death Star";
        DefaultAuthHeaderAuth auth = new DefaultAuthHeaderAuth(token, apiKey, deviceId, deviceName);
        auth.setAuth(request);
        request.prepareRequest();
        Assert.assertEquals(auth.getAuthString().toString(), request.getRawRequest().getHeaders(DefaultAuthHeaderAuth.AUTH_HEADER_NAME)[0].getValue());
    }
View Full Code Here

public class DefaultUsernamePasswordAuthTest {

    @Test
    public void testSetAuth() {
        try {
            DefaultBoxRequest request = new DefaultBoxRequest(TestUtils.getConfig(), new BoxJSONParser(new BoxResourceHub()), "/uri", RestMethod.GET, null);
            String userName = "testusername";
            String password = "testpassword";

            DefaultUsernamePasswordAuth auth = new DefaultUsernamePasswordAuth(userName, password);
            auth.setAuth(request);
            Map<String, String> queryParams = request.getQueryParams();
            Assert.assertEquals(userName, queryParams.get(DefaultUsernamePasswordAuth.LOGIN));
            Assert.assertEquals(password, queryParams.get(DefaultUsernamePasswordAuth.PASSWORD));

            request.prepareRequest();
            HttpRequestBase rawRequest = request.getRawRequest();
            String query = rawRequest.getURI().getQuery();
            Assert.assertTrue(query.contains(DefaultUsernamePasswordAuth.LOGIN + "=" + userName));
            Assert.assertTrue(query.contains(DefaultUsernamePasswordAuth.PASSWORD + "=" + password));
        }
        catch (Exception e) {
View Full Code Here

            public IBoxResponse execute(IBoxRequest boxRequest) throws BoxRestException {
                return response;
            }

        };
        request = new IBoxRequest() {

            @Override
            public IBoxRequestAuth getAuth() {
                return auth;
            }
View Full Code Here

            @Override
            public void setAuth(IBoxRequest request) throws BoxRestException {
            }
        };
        cookie = new ICookie() {

            @Override
            public void setCookie(IBoxRequest request) {
            }
View Full Code Here

        inputStream = new ByteArrayInputStream((new BoxJSONParser(hub)).convertBoxObjectToJSONString(file).getBytes());
        EasyMock.expect(boxResponse.getHttpResponse()).andReturn(response);
        EasyMock.expect(response.getEntity()).andReturn(entity);
        EasyMock.expect(entity.getContent()).andReturn(inputStream);
        EasyMock.replay(boxResponse, response, entity);
        DefaultBoxJSONResponseParser parser = new DefaultBoxJSONResponseParser(BoxFile.class, new BoxJSONParser(hub));
        Object object = parser.parse(boxResponse);
        Assert.assertEquals(BoxFile.class, object.getClass());
        Assert.assertEquals((new BoxJSONParser(hub)).convertBoxObjectToJSONString(file), (new BoxJSONParser(hub)).convertBoxObjectToJSONString(object));
        EasyMock.verify(boxResponse, response, entity);
    }
View Full Code Here

    public InputStream execute(final IBoxRequestAuth auth, ObjectMapper objectMapper, BoxDefaultRequestObject requestObject) throws BoxRestException,
        BoxServerException, AuthFatalFailureException {
        DownloadFileRequest request = new DownloadFileRequest(mConfig, objectMapper, mFileId, requestObject);
        request.setAuth(auth);
        DefaultBoxResponse response = (DefaultBoxResponse) mRestClient.execute(request);
        DefaultFileResponseParser parser = new DefaultFileResponseParser();
        ErrorResponseParser errorParser = new ErrorResponseParser(objectMapper);
        Object result = response.parseResponse(parser, errorParser);
        if (result instanceof BoxServerError) {
            throw new BoxServerException((BoxServerError) result);
        }
View Full Code Here

    public InputStream downloadThumbnail(final String fileId, final String extension, final BoxImageRequestObject requestObject) throws BoxRestException,
        BoxServerException, AuthFatalFailureException {
        ThumbnailRequest request = new ThumbnailRequest(getConfig(), getObjectMapper(), fileId, extension, requestObject);
        request.setAuth(getAuth());
        DefaultBoxResponse response = (DefaultBoxResponse) getRestClient().execute(request);
        return (InputStream) (new DefaultFileResponseParser()).parse(response);
    }
View Full Code Here

                else {
                    throw new BoxServerException((BoxServerError) o);
                }
            }
        }
        return (InputStream) (new DefaultFileResponseParser()).parse(response);
    }
View Full Code Here

        } else {
            request = new DownloadFileRequest(mConfig, parser, mFileId, requestObject);
        }
        request.setAuth(auth);
        DefaultBoxResponse response = (DefaultBoxResponse) mRestClient.execute(request);
        DefaultFileResponseParser responseParser = new DefaultFileResponseParser();
        ErrorResponseParser errorParser = new ErrorResponseParser(parser);
        Object result = response.parseResponse(responseParser, errorParser);
        if (result instanceof BoxServerError) {
            throw new BoxServerException((BoxServerError) result);
        }
View Full Code Here

TOP

Related Classes of com.box.restclientv2.exceptions.BoxSDKException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.