Package com.box.boxjavalibv2.jsonparsing

Examples of com.box.boxjavalibv2.jsonparsing.BoxJSONParser


    }

    @Ignore("Developer account errors out with 'This does not currently support moving content into non-root folders'")
    @Test
    public void testMoveFolderToAnotherUser() throws Exception {
        final BoxUser enterpriseUser = createEnterpriseUser();

        try {
            final String toUserId = enterpriseUser.getId();
            moveTestFolder(testUserId, toUserId);
            moveTestFolder(toUserId, testUserId);
        } finally {
            deleteEnterpriseUser(enterpriseUser.getId());
        }
    }
View Full Code Here


        LOG.debug("moveFolderToAnotherUser: " + result);
    }

    @Test
    public void testUpdateUserInformaiton() throws Exception {
        final BoxUser enterpriseUser = createEnterpriseUser();

        try {
            final Map<String, Object> headers = new HashMap<String, Object>();
            // parameter type is String
            headers.put("CamelBox.userId", enterpriseUser.getId());
            // parameter type is com.box.boxjavalibv2.requests.requestobjects.BoxUserRequestObject
            final BoxUserRequestObject requestObject =
                    BoxUserRequestObject.updateUserInfoRequestObject(false);
            requestObject.setJobTitle(CAMEL_JOB_TITLE);
            headers.put("CamelBox.userRequest", requestObject);

            BoxUser result = requestBodyAndHeaders("direct://UPDATEUSERINFORMAITON", null, headers);

            assertNotNull("updateUserInformaiton result", result);
            assertEquals("updateUserInformaiton job title", CAMEL_JOB_TITLE, result.getJobTitle());
            LOG.debug("updateUserInformaiton: " + result);
        } finally {
            deleteEnterpriseUser(enterpriseUser.getId());
        }
    }
View Full Code Here

    }

    @Ignore("Requires multiple confirmed email aliases, do disabled by default")
    @Test
    public void testUpdateUserPrimaryLogin() throws Exception {
        final BoxUser enterpriseUser = createEnterpriseUser();

        try {
            final Map<String, Object> headers = new HashMap<String, Object>();
            // parameter type is String
            headers.put("CamelBox.userId", enterpriseUser.getId());
            // parameter type is com.box.boxjavalibv2.requests.requestobjects.BoxUserUpdateLoginRequestObject
            final BoxUserUpdateLoginRequestObject requestObject =
                    BoxUserUpdateLoginRequestObject.updateUserPrimaryLoginRequestObject(UPDATED_EMAIL_ALIAS);
            headers.put("CamelBox.userUpdateLoginRequest", requestObject);

            BoxUser result = requestBodyAndHeaders("direct://UPDATEUSERPRIMARYLOGIN", null, headers);

            assertNotNull("updateUserPrimaryLogin result", result);
            assertEquals("updateUserPrimaryLogin primary login", UPDATED_EMAIL_ALIAS, result.getLogin());
            LOG.debug("updateUserPrimaryLogin: " + result);
        } finally {
            deleteEnterpriseUser(enterpriseUser.getId());
        }
    }
View Full Code Here

        try {
            final Map<String, Object> headers = new HashMap<String, Object>();
            // parameter type is String
            headers.put("CamelBox.folderId", testFolder.getId());
            // parameter type is com.box.boxjavalibv2.requests.requestobjects.BoxSharedLinkRequestObject
            final BoxSharedLinkRequestEntity sharedLink = new BoxSharedLinkRequestEntity(
                    BoxSharedLinkAccess.COLLABORATORS);
            headers.put("CamelBox.sharedLinkRequest",
                    BoxSharedLinkRequestObject.createSharedLinkRequestObject(sharedLink));

            BoxFolder result = requestBodyAndHeaders("direct://CREATESHAREDLINK", null, headers);
View Full Code Here

        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

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

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

        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

        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

        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

    @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

TOP

Related Classes of com.box.boxjavalibv2.jsonparsing.BoxJSONParser

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.