Search in sources :

Example 1 with Metadata

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

the class BoxFilesManagerIntegrationTest method testGetFileMetadata.

@Test
public void testGetFileMetadata() throws Exception {
    testFile.createMetadata(new Metadata());
    final Map<String, Object> headers = new HashMap<String, Object>();
    // parameter type is String
    headers.put("CamelBox.fileId", testFile.getID());
    // parameter type is String
    headers.put("CamelBox.typeName", null);
    final com.box.sdk.Metadata result = requestBodyAndHeaders("direct://GETFILEMETADATA", null, headers);
    assertNotNull("getFileMetadata result", result);
    LOG.debug("getFileMetadata: " + result);
}
Also used : HashMap(java.util.HashMap) Metadata(com.box.sdk.Metadata) Metadata(com.box.sdk.Metadata) Test(org.junit.Test)

Example 2 with Metadata

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

the class BoxFilesManagerIntegrationTest method testCreateFileMetadata.

@Test
public void testCreateFileMetadata() throws Exception {
    Metadata metadata = new Metadata();
    metadata.add("/foo", "bar");
    final Map<String, Object> headers = new HashMap<String, Object>();
    // parameter type is String
    headers.put("CamelBox.fileId", testFile.getID());
    // parameter type is com.box.sdk.Metadata
    headers.put("CamelBox.metadata", metadata);
    // parameter type is String
    headers.put("CamelBox.typeName", null);
    final com.box.sdk.Metadata result = requestBodyAndHeaders("direct://CREATEFILEMETADATA", null, headers);
    assertNotNull("createFileMetadata result", result);
    assertEquals("createFileMetadata result", "bar", result.get("/foo"));
    LOG.debug("createFileMetadata: " + result);
}
Also used : HashMap(java.util.HashMap) Metadata(com.box.sdk.Metadata) Metadata(com.box.sdk.Metadata) Test(org.junit.Test)

Example 3 with Metadata

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

the class BoxFilesManagerIntegrationTest method testDeleteFileMetadata.

@Test
public void testDeleteFileMetadata() throws Exception {
    testFile.createMetadata(new Metadata());
    // using String message body for single parameter "fileId"
    requestBody("direct://DELETEFILEMETADATA", testFile.getID());
    try {
        testFile.getMetadata();
    } catch (BoxAPIException e) {
        if (e.getResponseCode() == 404) {
            // Box API should return a
            return;
        }
    }
    fail("deleteFileMetadata metadata");
}
Also used : Metadata(com.box.sdk.Metadata) BoxAPIException(com.box.sdk.BoxAPIException) Test(org.junit.Test)

Example 4 with Metadata

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

the class BoxFilesManagerIntegrationTest method testUpdateFileMetadata.

@Test
public void testUpdateFileMetadata() throws Exception {
    Metadata metadata = new Metadata();
    // metadata.add("/foo", "bar");
    metadata = testFile.createMetadata(metadata);
    final Map<String, Object> headers = new HashMap<String, Object>();
    // parameter type is String
    headers.put("CamelBox.fileId", testFile.getID());
    // parameter type is com.box.sdk.Metadata
    headers.put("CamelBox.metadata", metadata);
    final com.box.sdk.Metadata result = requestBodyAndHeaders("direct://UPDATEFILEMETADATA", null, headers);
    assertNotNull("updateFileMetadata result", result);
    LOG.debug("updateFileMetadata: " + result);
}
Also used : HashMap(java.util.HashMap) Metadata(com.box.sdk.Metadata) Metadata(com.box.sdk.Metadata) Test(org.junit.Test)

Aggregations

Metadata (com.box.sdk.Metadata)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 BoxAPIException (com.box.sdk.BoxAPIException)1