@Test public void testGet() throws Exception { final Quota.Space quota = new DriveQuotaFeature(session).get(); assertNotNull(quota.available); assertNotNull(quota.used); assertNotEquals(0L, quota.available, 0L); assertNotEquals(0L, quota.used, 0L); }
@Override public Space get() throws BackgroundException { if (new DriveHomeFinderService(session).find().isChild(DriveHomeFinderService.TEAM_DRIVES_NAME)) { return new Space(0L, Long.MAX_VALUE); } try { final About about = session.getClient().about().get().setFields("user, storageQuota").execute(); final Long used = null == about.getStorageQuota().getUsageInDrive() ? 0L : about.getStorageQuota().getUsageInDrive(); final Long available = (null == about.getStorageQuota().getLimit() ? Long.MAX_VALUE : about.getStorageQuota().getLimit()) - used; return new Space(used, available); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to read attributes of {0}", e, new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory))); } }
DriveQuotaFeature implements Quota { @Override public Space get() throws BackgroundException { if (new DriveHomeFinderService(session).find().isChild(DriveHomeFinderService.TEAM_DRIVES_NAME)) { return new Space(0L, Long.MAX_VALUE); } try { final About about = session.getClient().about().get().setFields("user, storageQuota").execute(); final Long used = null == about.getStorageQuota().getUsageInDrive() ? 0L : about.getStorageQuota().getUsageInDrive(); final Long available = (null == about.getStorageQuota().getLimit() ? Long.MAX_VALUE : about.getStorageQuota().getLimit()) - used; return new Space(used, available); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to read attributes of {0}", e, new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory))); } } }
DriveQuotaFeature implements Quota { @Override public Space get() throws BackgroundException { if (new DriveHomeFinderService(session).find().isChild(DriveHomeFinderService.TEAM_DRIVES_NAME)) { return new Space(0L, Long.MAX_VALUE); } try { final About about = session.getClient().about().get().setFields("user, storageQuota").execute(); final Long used = null == about.getStorageQuota().getUsageInDrive() ? 0L : about.getStorageQuota().getUsageInDrive(); final Long available = (null == about.getStorageQuota().getLimit() ? Long.MAX_VALUE : about.getStorageQuota().getLimit()) - used; return new Space(used, available); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to read attributes of {0}", e, new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory))); } } DriveQuotaFeature(final DriveSession session); }
DriveQuotaFeature implements Quota { @Override public Space get() throws BackgroundException { if (new DriveHomeFinderService(session).find().isChild(DriveHomeFinderService.TEAM_DRIVES_NAME)) { return new Space(0L, Long.MAX_VALUE); } try { final About about = session.getClient().about().get().setFields("user, storageQuota").execute(); final Long used = null == about.getStorageQuota().getUsageInDrive() ? 0L : about.getStorageQuota().getUsageInDrive(); final Long available = (null == about.getStorageQuota().getLimit() ? Long.MAX_VALUE : about.getStorageQuota().getLimit()) - used; return new Space(used, available); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to read attributes of {0}", e, new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory))); } } DriveQuotaFeature(final DriveSession session); @Override Space get(); }
DriveQuotaFeature implements Quota { @Override public Space get() throws BackgroundException { if (new DriveHomeFinderService(session).find().isChild(DriveHomeFinderService.TEAM_DRIVES_NAME)) { return new Space(0L, Long.MAX_VALUE); } try { final About about = session.getClient().about().get().setFields("user, storageQuota").execute(); final Long used = null == about.getStorageQuota().getUsageInDrive() ? 0L : about.getStorageQuota().getUsageInDrive(); final Long available = (null == about.getStorageQuota().getLimit() ? Long.MAX_VALUE : about.getStorageQuota().getLimit()) - used; return new Space(used, available); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to read attributes of {0}", e, new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory))); } } DriveQuotaFeature(final DriveSession session); @Override Space get();  }