Search in sources :

Example 1 with CreateUserParams

use of com.box.sdk.CreateUserParams in project camel by apache.

the class BoxUsersManagerIntegrationTest method testCreateAppUser.

@Test
public void testCreateAppUser() throws Exception {
    com.box.sdk.BoxUser result = null;
    try {
        CreateUserParams params = new CreateUserParams();
        // 1 GB
        params.setSpaceAmount(1073741824);
        final Map<String, Object> headers = new HashMap<String, Object>();
        // parameter type is String
        headers.put("CamelBox.name", CAMEL_TEST_CREATE_APP_USER_NAME);
        // parameter type is com.box.sdk.CreateUserParams
        headers.put("CamelBox.params", params);
        result = requestBodyAndHeaders("direct://CREATEAPPUSER", null, headers);
        assertNotNull("createAppUser result", result);
        LOG.debug("createAppUser: " + result);
    } finally {
        if (result != null) {
            try {
                result.delete(false, true);
            } catch (Throwable t) {
            }
        }
    }
}
Also used : BoxUser(com.box.sdk.BoxUser) CreateUserParams(com.box.sdk.CreateUserParams) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 2 with CreateUserParams

use of com.box.sdk.CreateUserParams in project camel by apache.

the class BoxCollaborationsManagerIntegrationTest method testAddFolderCollaboration.

@Test
public void testAddFolderCollaboration() throws Exception {
    // delete collaborator created by setupTest
    deleteTestCollaborator();
    BoxUser user = null;
    try {
        // create test collaborator
        CreateUserParams params = new CreateUserParams();
        // 1 GB
        params.setSpaceAmount(1073741824);
        user = BoxUser.createAppUser(getConnection(), CAMEL_TEST_COLLABORATOR_NAME, params).getResource();
        final Map<String, Object> headers = new HashMap<String, Object>();
        // parameter type is String
        headers.put("CamelBox.folderId", testFolder.getID());
        // parameter type is String
        headers.put("CamelBox.collaborator", user);
        // parameter type is com.box.sdk.BoxCollaboration.Role
        headers.put("CamelBox.role", BoxCollaboration.Role.EDITOR);
        final com.box.sdk.BoxCollaboration result = requestBodyAndHeaders("direct://ADDFOLDERCOLLABORATION", testFolder.getID(), headers);
        assertNotNull("addFolderCollaboration result", result);
        LOG.debug("addFolderCollaboration: " + result);
    } catch (BoxAPIException e) {
        throw new RuntimeException(String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
    } finally {
        if (user != null) {
            user.delete(false, true);
        }
    }
}
Also used : CreateUserParams(com.box.sdk.CreateUserParams) HashMap(java.util.HashMap) BoxAPIException(com.box.sdk.BoxAPIException) BoxUser(com.box.sdk.BoxUser) BoxCollaboration(com.box.sdk.BoxCollaboration) Test(org.junit.Test)

Example 3 with CreateUserParams

use of com.box.sdk.CreateUserParams in project camel by apache.

the class BoxUsersManagerIntegrationTest method testCreateEnterpriseUser.

@Test
public void testCreateEnterpriseUser() throws Exception {
    com.box.sdk.BoxUser result = null;
    try {
        CreateUserParams params = new CreateUserParams();
        // 1 GB
        params.setSpaceAmount(1073741824);
        final Map<String, Object> headers = new HashMap<String, Object>();
        // parameter type is String
        headers.put("CamelBox.login", CAMEL_TEST_CREATE_ENTERPRISE_USER_LOGIN);
        // parameter type is String
        headers.put("CamelBox.name", CAMEL_TEST_CREATE_ENTERPRISE_USER_NAME);
        // parameter type is com.box.sdk.CreateUserParams
        headers.put("CamelBox.params", params);
        result = requestBodyAndHeaders("direct://CREATEENTERPRISEUSER", null, headers);
        assertNotNull("createEnterpriseUser result", result);
        LOG.debug("createEnterpriseUser: " + result);
    } finally {
        if (result != null) {
            try {
                result.delete(false, true);
            } catch (Throwable t) {
            }
        }
    }
}
Also used : BoxUser(com.box.sdk.BoxUser) CreateUserParams(com.box.sdk.CreateUserParams) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

BoxUser (com.box.sdk.BoxUser)3 CreateUserParams (com.box.sdk.CreateUserParams)3 HashMap (java.util.HashMap)3 Test (org.junit.Test)3 BoxAPIException (com.box.sdk.BoxAPIException)1 BoxCollaboration (com.box.sdk.BoxCollaboration)1