Examples of BoxJSONParser


Examples of com.box.boxjavalibv2.jsonparsing.BoxJSONParser

        return tmp;
    }

    @SuppressWarnings({"unchecked", "rawtypes"})
    public static BoxObject getFromJSON(String json, Class cls) throws BoxRestException {
        BoxJSONParser jsonParser = new BoxJSONParser(new BoxResourceHub());
        return jsonParser.parseIntoBoxObjectQuietly(json, (Class<BoxObject>) cls);
    }
View Full Code Here

Examples of com.box.boxjavalibv2.jsonparsing.BoxJSONParser

        BoxConfigBuilder builder = new BoxConfigBuilder();
        return builder.build();
    }

    public static IBoxJSONParser getJsonParser() {
        return new BoxJSONParser(new BoxResourceHub());
    }
View Full Code Here

Examples of com.box.boxjavalibv2.jsonparsing.BoxJSONParser

        entity.setUnshared_at(date);

        String accessStr = String.format(ACCESS_STR, access);
        String dateStr = String.format(UNSHARED_STR, ISO8601DateParser.toString(date));

        String entityStr = entity.toJSONString(new BoxJSONParser(new BoxResourceHub()));
        Assert.assertFalse(entityStr.contains(PERMISSIONS_STR));
        Assert.assertTrue(entityStr.contains(accessStr));
        Assert.assertTrue(entityStr.contains(dateStr));
    }
View Full Code Here

Examples of com.box.boxjavalibv2.jsonparsing.BoxJSONParser

        String access = BoxSharedLinkAccess.OPEN;
        BoxSharedLinkRequestEntity entity = new BoxSharedLinkRequestEntity(access);
        entity.setPermissions(true);
        String accessStr = String.format(ACCESS_STR, access);

        String entityStr = entity.toJSONString(new BoxJSONParser(new BoxResourceHub()));
        Assert.assertFalse(entityStr.contains(PERMISSIONS_STR));
        Assert.assertTrue(entityStr.contains(accessStr));
        Assert.assertFalse(entityStr.contains("\"unshared_at\":"));

    }
View Full Code Here

Examples of com.box.boxjavalibv2.jsonparsing.BoxJSONParser

        String name = "testname";
        String value = "testvalue";
        MapJSONStringEntity entity = new MapJSONStringEntity();

        entity.put(name, value);
        Assert.assertEquals(String.format(json, name, value), entity.toJSONString(new BoxJSONParser(new BoxResourceHub())));
    }
View Full Code Here

Examples of com.box.boxjavalibv2.jsonparsing.BoxJSONParser

    @Test
    public void testCanParseBoxObject() throws IllegalStateException, IOException, BoxRestException, BoxJSONException {
        BoxResourceHub hub = new BoxResourceHub();
        EasyMock.reset(boxResponse, response, entity);
        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

Examples of com.box.boxjavalibv2.jsonparsing.BoxJSONParser

        statusLine = EasyMock.createMock(StatusLine.class);
    }

    @Test
    public void testCanParseBoxServerError() throws BoxRestException, IllegalStateException, IOException, BoxJSONException {
        BoxJSONParser jsonParser = new BoxJSONParser(new BoxResourceHub());
        EasyMock.reset(boxResponse, response, entity);
        inputStream = new ByteArrayInputStream(jsonParser.convertBoxObjectToJSONString(error).getBytes());
        EasyMock.expect(boxResponse.getHttpResponse()).andStubReturn(response);
        EasyMock.expect(response.getEntity()).andStubReturn(entity);
        EasyMock.expect(entity.getContent()).andStubReturn(inputStream);
        EasyMock.expect(entity.isStreaming()).andStubReturn(false);

        EasyMock.expect(boxResponse.getHttpResponse()).andStubReturn(response);
        EasyMock.expect(response.getStatusLine()).andStubReturn(statusLine);
        EasyMock.expect(statusLine.getStatusCode()).andStubReturn(statusCode);

        EasyMock.replay(boxResponse, response, entity, statusLine);
        ErrorResponseParser parser = new ErrorResponseParser(jsonParser);
        Object object = parser.parse(boxResponse);
        Assert.assertEquals(BoxServerError.class, object.getClass());

        Assert.assertEquals(jsonParser.convertBoxObjectToJSONString(error), jsonParser.convertBoxObjectToJSONString(object));
        EasyMock.verify(boxResponse, response, entity, statusLine);
    }
View Full Code Here

Examples of com.box.boxjavalibv2.jsonparsing.BoxJSONParser

     *
     * @param resourceHub
     * @return
     */
    protected IBoxJSONParser createJSONParser(IBoxResourceHub resourceHub) {
        return new BoxJSONParser(resourceHub);
    }
View Full Code Here

Examples of com.box.boxjavalibv2.jsonparsing.BoxJSONParser

    }

    @Test
    public void prepareRequestTest() throws AuthFatalFailureException {
        try {
            DefaultBoxRequest request = new DefaultBoxRequest(config, new BoxJSONParser(new BoxResourceHub()), uri, restMethod, null);
            request.addQueryParam("a", "b");
            request.setEntity(requestEntity);
            request.prepareRequest();
            HttpRequestBase rawRequest = request.getRawRequest();
            Assert.assertEquals(HttpPost.class, rawRequest.getClass());
View Full Code Here

Examples of com.box.boxjavalibv2.jsonparsing.BoxJSONParser

        }
    }

    @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());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.