Search in sources :

Example 1 with GetMetadataError

use of com.dropbox.core.v2.files.GetMetadataError in project dropbox-sdk-java by dropbox.

the class DbxClientV2IT method testError409.

@Test(expectedExceptions = { GetMetadataErrorException.class })
public void testError409() throws Exception {
    DbxClientV2 client = ITUtil.newClientV2();
    String path = ITUtil.path(getClass(), "/testError409/" + ITUtil.format(new Date()));
    try {
        client.files().getMetadata(path);
    } catch (GetMetadataErrorException ex) {
        assertNotNull(ex.getRequestId());
        if (ex.getUserMessage() != null) {
            assertNotNull(ex.getUserMessage().getLocale());
            assertNotNull(ex.getUserMessage().getText());
            assertNotNull(ex.getUserMessage().toString());
        }
        GetMetadataError err = ex.errorValue;
        assertNotNull(err);
        assertEquals(err.tag(), GetMetadataError.Tag.PATH);
        assertTrue(err.isPath());
        LookupError lookup = err.getPathValue();
        assertNotNull(lookup);
        assertEquals(lookup.tag(), LookupError.Tag.NOT_FOUND);
        assertTrue(lookup.isNotFound());
        assertFalse(lookup.isNotFile());
        assertFalse(lookup.isOther());
        assertFalse(lookup.isMalformedPath());
        // raise so test can confirm an exception was thrown
        throw ex;
    }
}
Also used : GetMetadataError(com.dropbox.core.v2.files.GetMetadataError) Date(java.util.Date) LookupError(com.dropbox.core.v2.files.LookupError) GetMetadataErrorException(com.dropbox.core.v2.files.GetMetadataErrorException) Test(org.testng.annotations.Test)

Aggregations

GetMetadataError (com.dropbox.core.v2.files.GetMetadataError)1 GetMetadataErrorException (com.dropbox.core.v2.files.GetMetadataErrorException)1 LookupError (com.dropbox.core.v2.files.LookupError)1 Date (java.util.Date)1 Test (org.testng.annotations.Test)1