FileInfo { public static FileInfo fromItemInfo(GoogleCloudStorageItemInfo itemInfo) { if (itemInfo.isRoot()) { return ROOT_INFO; } URI path = UriPaths.fromResourceId(itemInfo.getResourceId(), true); return new FileInfo(path, itemInfo); } private  FileInfo(URI path, GoogleCloudStorageItemInfo itemInfo); URI getPath(); boolean isDirectory(); boolean isGlobalRoot(); long getCreationTime(); long getSize(); long getModificationTime(); Map<String, byte[]> getAttributes(); boolean exists(); String toString(); GoogleCloudStorageItemInfo getItemInfo(); static StorageResourceId convertToDirectoryPath(StorageResourceId resourceId); static URI convertToDirectoryPath(URI path); static FileInfo fromItemInfo(GoogleCloudStorageItemInfo itemInfo); static List<FileInfo> fromItemInfos(List<GoogleCloudStorageItemInfo> itemInfos); static boolean isDirectoryPath(URI path); static final FileInfo ROOT_INFO; }
@Test public void fromItemInfo() throws Exception { GoogleCloudStorageItemInfo itemInfo = new GoogleCloudStorageItemInfo( new StorageResourceId("foo-test-bucket", "bar/test/object"), 10L, 15L, 200L, "us-east1", "nearline", "text/plain", "lzma", ImmutableMap.of("foo-meta", new byte[] {5, 66, 56}), 312432L, 2L); FileInfo fileInfo = FileInfo.fromItemInfo(itemInfo); assertThat(fileInfo.getPath()).isEqualTo(new URI("gs: assertThat(fileInfo.getCreationTime()).isEqualTo(10L); assertThat(fileInfo.getModificationTime()).isEqualTo(15L); assertThat(fileInfo.getSize()).isEqualTo(200); assertThat(fileInfo.getAttributes()) .<byte[], byte[]>comparingValuesUsing(Correspondence.from(Arrays::equals, "Arrays.equals")) .containsExactly("foo-meta", new byte[] {5, 66, 56}); assertThat(fileInfo.getItemInfo()).isEqualTo(itemInfo); }