use of com.dropbox.core.v2.users.SpaceUsage in project cyberduck by iterate-ch.
the class DropboxQuotaFeature method get.
@Override
public Space get() throws BackgroundException {
try {
final SpaceUsage usage = new DbxUserUsersRequests(session.getClient()).getSpaceUsage();
final SpaceAllocation allocation = usage.getAllocation();
if (allocation.isIndividual()) {
long remaining = allocation.getIndividualValue().getAllocated() - usage.getUsed();
return new Space(usage.getUsed(), remaining);
} else if (allocation.isTeam()) {
long remaining = allocation.getTeamValue().getAllocated() - usage.getUsed();
return new Space(usage.getUsed(), remaining);
}
return unknown;
} catch (DbxException e) {
throw new DropboxExceptionMappingService().map("Failure to read attributes of {0}", e, new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)));
}
}
use of com.dropbox.core.v2.users.SpaceUsage in project PrettySecureCloud by SandroGuerotto.
the class DropBoxServiceTest method getAvailableStorageSpace.
@Test
void getAvailableStorageSpace() throws DbxException {
cut = new DropBoxService(dbxClientV2Mock);
DbxUserUsersRequests DbxUserUsersRequestsMock = mock(DbxUserUsersRequests.class);
when(dbxClientV2Mock.users()).thenReturn(DbxUserUsersRequestsMock);
when(DbxUserUsersRequestsMock.getSpaceUsage()).thenReturn(new SpaceUsage(1_000_000_000_000L, SpaceAllocation.individual(new IndividualSpaceAllocation(5_000_000_000_000L))));
BigDecimal usedStorageSpace = cut.getUsedStorageSpace();
assertEquals(1_000_000_000_000L, usedStorageSpace.longValue());
}
Aggregations