diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java index b769c38d9081..cf3408307b46 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java @@ -19,15 +19,16 @@ import static com.google.cloud.RetryHelper.runWithRetries; import static com.google.common.base.Preconditions.checkArgument; +import com.google.api.gax.paging.Page; import com.google.api.services.bigquery.model.GetQueryResultsResponse; import com.google.api.services.bigquery.model.TableDataInsertAllRequest; import com.google.api.services.bigquery.model.TableDataInsertAllRequest.Rows; import com.google.api.services.bigquery.model.TableRow; import com.google.cloud.BaseService; -import com.google.api.gax.paging.Page; import com.google.cloud.PageImpl; import com.google.cloud.PageImpl.NextPageFetcher; import com.google.cloud.RetryHelper; +import com.google.cloud.Tuple; import com.google.cloud.bigquery.InsertAllRequest.RowToInsert; import com.google.cloud.bigquery.spi.v2.BigQueryRpc; import com.google.common.base.Function; @@ -36,7 +37,6 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; - import java.util.List; import java.util.Map; import java.util.concurrent.Callable; @@ -247,21 +247,30 @@ public Page listDatasets(String projectId, DatasetListOption... options return listDatasets(projectId, getOptions(), optionMap(options)); } - private static Page listDatasets(final String projectId, - final BigQueryOptions serviceOptions, final Map optionsMap) { + private static Page listDatasets( + final String projectId, + final BigQueryOptions serviceOptions, + final Map optionsMap) { try { - BigQueryRpc.Tuple> result = - runWithRetries(new Callable>>() { + Tuple> result = + runWithRetries( + new Callable< + Tuple>>() { @Override - public BigQueryRpc.Tuple> call() { + public Tuple> + call() { return serviceOptions.getBigQueryRpcV2().listDatasets(projectId, optionsMap); } - }, serviceOptions.getRetrySettings(), EXCEPTION_HANDLER, serviceOptions.getClock()); + }, + serviceOptions.getRetrySettings(), + EXCEPTION_HANDLER, + serviceOptions.getClock()); String cursor = result.x(); - return new PageImpl<>(new DatasetPageFetcher(projectId, serviceOptions, cursor, optionsMap), - cursor, Iterables.transform(result.y(), + return new PageImpl<>( + new DatasetPageFetcher(projectId, serviceOptions, cursor, optionsMap), + cursor, + Iterables.transform( + result.y(), new Function() { @Override public Dataset apply(com.google.api.services.bigquery.model.Dataset dataset) { @@ -391,11 +400,11 @@ public Page listTables(DatasetId datasetId, TableListOption... options) { private static Page
listTables(final DatasetId datasetId, final BigQueryOptions serviceOptions, final Map optionsMap) { try { - BigQueryRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public BigQueryRpc.Tuple> + public Tuple> call() { return serviceOptions.getBigQueryRpcV2().listTables( datasetId.getProject(), datasetId.getDataset(), optionsMap); @@ -450,10 +459,10 @@ private static Page> listTableData(final TableId tableId, final BigQueryOptions serviceOptions, final Map optionsMap) { try { final TableId completeTableId = tableId.setProjectId(serviceOptions.getProjectId()); - BigQueryRpc.Tuple> result = - runWithRetries(new Callable>>() { + Tuple> result = + runWithRetries(new Callable>>() { @Override - public BigQueryRpc.Tuple> call() { + public Tuple> call() { return serviceOptions.getBigQueryRpcV2() .listTableData(completeTableId.getProject(), completeTableId.getDataset(), completeTableId.getTable(), optionsMap); @@ -509,11 +518,11 @@ public Page listJobs(JobListOption... options) { private static Page listJobs(final BigQueryOptions serviceOptions, final Map optionsMap) { - BigQueryRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public BigQueryRpc.Tuple> + public Tuple> call() { return serviceOptions.getBigQueryRpcV2().listJobs(serviceOptions.getProjectId(), optionsMap); } diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/BigQueryRpc.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/BigQueryRpc.java index 0e682419f4b1..5a8b7677de57 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/BigQueryRpc.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/BigQueryRpc.java @@ -27,8 +27,8 @@ import com.google.api.services.bigquery.model.TableDataInsertAllResponse; import com.google.api.services.bigquery.model.TableRow; import com.google.cloud.ServiceRpc; +import com.google.cloud.Tuple; import com.google.cloud.bigquery.BigQueryException; - import java.util.Map; public interface BigQueryRpc extends ServiceRpc { @@ -73,29 +73,6 @@ Boolean getBoolean(Map options) { } } - class Tuple { - - private final X x; - private final Y y; - - private Tuple(X x, Y y) { - this.x = x; - this.y = y; - } - - public static Tuple of(X x, Y y) { - return new Tuple<>(x, y); - } - - public X x() { - return x; - } - - public Y y() { - return y; - } - } - /** * Returns the requested dataset or {@code null} if not found. * diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java index bc98bb1795d7..4092566fdabd 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java @@ -49,6 +49,7 @@ import com.google.api.services.bigquery.model.TableList; import com.google.api.services.bigquery.model.TableReference; import com.google.api.services.bigquery.model.TableRow; +import com.google.cloud.Tuple; import com.google.cloud.bigquery.BigQueryException; import com.google.cloud.bigquery.BigQueryOptions; import com.google.cloud.http.HttpTransportOptions; diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java index b9c59688f2a4..813a44aa6915 100644 --- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java +++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java @@ -26,19 +26,19 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import com.google.api.gax.paging.Page; import com.google.api.services.bigquery.model.ErrorProto; import com.google.api.services.bigquery.model.GetQueryResultsResponse; import com.google.api.services.bigquery.model.TableCell; import com.google.api.services.bigquery.model.TableDataInsertAllRequest; import com.google.api.services.bigquery.model.TableDataInsertAllResponse; import com.google.api.services.bigquery.model.TableRow; -import com.google.api.gax.paging.Page; import com.google.cloud.ServiceOptions; +import com.google.cloud.Tuple; import com.google.cloud.WriteChannel; import com.google.cloud.bigquery.InsertAllRequest.RowToInsert; -import com.google.cloud.bigquery.spi.v2.BigQueryRpc; -import com.google.cloud.bigquery.spi.v2.BigQueryRpc.Tuple; import com.google.cloud.bigquery.spi.BigQueryRpcFactory; +import com.google.cloud.bigquery.spi.v2.BigQueryRpc; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; diff --git a/google-cloud-compute/src/main/java/com/google/cloud/compute/ComputeImpl.java b/google-cloud-compute/src/main/java/com/google/cloud/compute/ComputeImpl.java index cfcd0834edc2..f67317b00638 100644 --- a/google-cloud-compute/src/main/java/com/google/cloud/compute/ComputeImpl.java +++ b/google-cloud-compute/src/main/java/com/google/cloud/compute/ComputeImpl.java @@ -19,11 +19,12 @@ import static com.google.cloud.RetryHelper.runWithRetries; import static com.google.common.base.Preconditions.checkArgument; -import com.google.cloud.BaseService; import com.google.api.gax.paging.Page; +import com.google.cloud.BaseService; import com.google.cloud.PageImpl; import com.google.cloud.PageImpl.NextPageFetcher; import com.google.cloud.RetryHelper; +import com.google.cloud.Tuple; import com.google.cloud.compute.AttachedDisk.PersistentDiskConfiguration; import com.google.cloud.compute.NetworkInterface.AccessConfig; import com.google.cloud.compute.spi.v1.ComputeRpc; @@ -31,7 +32,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; - import java.util.Map; import java.util.concurrent.Callable; @@ -491,11 +491,11 @@ public Page listDiskTypes(String zone, DiskTypeListOption... options) private static Page listDiskTypes(final String zone, final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listDiskTypes(zone, optionsMap); } @@ -525,11 +525,11 @@ public Page listDiskTypes(DiskTypeAggregatedListOption... options) { private static Page listDiskTypes(final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listDiskTypes(optionsMap); } @@ -580,11 +580,11 @@ public Page listMachineTypes(String zone, MachineTypeListOption... private static Page listMachineTypes(final String zone, final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listMachineTypes(zone, optionsMap); } @@ -615,11 +615,11 @@ public Page listMachineTypes(MachineTypeAggregatedListOption... opt private static Page listMachineTypes(final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listMachineTypes(optionsMap); } @@ -666,11 +666,11 @@ public Page listRegions(RegionListOption... options) { private static Page listRegions(final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listRegions(optionsMap); } @@ -717,11 +717,11 @@ public Page listZones(ZoneListOption... options) { private static Page listZones(final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listZones(optionsMap); } @@ -814,11 +814,11 @@ public Page listGlobalOperations(OperationListOption... options) { private static Page listGlobalOperations(final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listGlobalOperations(optionsMap); } @@ -842,11 +842,11 @@ public Page listRegionOperations(String region, OperationListOption.. private static Page listRegionOperations(final String region, final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listRegionOperations(region, optionsMap); } @@ -870,11 +870,11 @@ public Page listZoneOperations(String zone, OperationListOption... op private static Page listZoneOperations(final String zone, final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listZoneOperations(zone, optionsMap); } @@ -988,11 +988,11 @@ public Page
listGlobalAddresses(AddressListOption... options) { private static Page
listGlobalAddresses(final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listGlobalAddresses(optionsMap); } @@ -1016,11 +1016,11 @@ public Page
listRegionAddresses(String region, AddressListOption... opt private static Page
listRegionAddresses(final String region, final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listRegionAddresses(region, optionsMap); } @@ -1044,11 +1044,11 @@ public Page
listAddresses(AddressAggregatedListOption... options) { private static Page
listAddresses(final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listAddresses(optionsMap); } @@ -1142,11 +1142,11 @@ public Page listSnapshots(SnapshotListOption... options) { private static Page listSnapshots(final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listSnapshots(optionsMap); } @@ -1240,11 +1240,11 @@ public Page listImages(ImageListOption... options) { private static Page listImages(final String project, final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listImages(project, optionsMap); } @@ -1358,11 +1358,11 @@ public Page listDisks(String zone, DiskListOption... options) { private static Page listDisks(final String zone, final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listDisks(zone, optionsMap); } @@ -1386,11 +1386,11 @@ public Page listDisks(DiskAggregatedListOption... options) { private static Page listDisks(final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listDisks(optionsMap); } @@ -1495,11 +1495,11 @@ public Page listSubnetworks(String region, SubnetworkListOption... o private static Page listSubnetworks(final String region, final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listSubnetworks(region, optionsMap); } @@ -1523,11 +1523,11 @@ public Page listSubnetworks(SubnetworkAggregatedListOption... option private static Page listSubnetworks(final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listSubnetworks(optionsMap); } @@ -1604,11 +1604,11 @@ public Page listNetworks(NetworkListOption... options) { private static Page listNetworks(final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listNetworks(optionsMap); } @@ -1706,11 +1706,11 @@ public Page listInstances(String zone, InstanceListOption... options) private static Page listInstances(final String zone, final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listInstances(zone, optionsMap); } @@ -1734,11 +1734,11 @@ public Page listInstances(InstanceAggregatedListOption... options) { private static Page listInstances(final ComputeOptions serviceOptions, final Map optionsMap) { try { - ComputeRpc.Tuple> result = - runWithRetries(new Callable> result = + runWithRetries(new Callable>>() { @Override - public ComputeRpc.Tuple> call() { return serviceOptions.getComputeRpcV1().listInstances(optionsMap); } diff --git a/google-cloud-compute/src/main/java/com/google/cloud/compute/spi/v1/ComputeRpc.java b/google-cloud-compute/src/main/java/com/google/cloud/compute/spi/v1/ComputeRpc.java index 388c3b495a12..03e8bc753874 100644 --- a/google-cloud-compute/src/main/java/com/google/cloud/compute/spi/v1/ComputeRpc.java +++ b/google-cloud-compute/src/main/java/com/google/cloud/compute/spi/v1/ComputeRpc.java @@ -36,8 +36,8 @@ import com.google.api.services.compute.model.Tags; import com.google.api.services.compute.model.Zone; import com.google.cloud.ServiceRpc; +import com.google.cloud.Tuple; import com.google.cloud.compute.ComputeException; - import java.util.Map; public interface ComputeRpc extends ServiceRpc { @@ -77,29 +77,6 @@ Boolean getBoolean(Map options) { } } - class Tuple { - - private final X x; - private final Y y; - - private Tuple(X x, Y y) { - this.x = x; - this.y = y; - } - - public static Tuple of(X x, Y y) { - return new Tuple<>(x, y); - } - - public X x() { - return x; - } - - public Y y() { - return y; - } - } - /** * Returns the requested disk type or {@code null} if not found. * diff --git a/google-cloud-compute/src/main/java/com/google/cloud/compute/spi/v1/HttpComputeRpc.java b/google-cloud-compute/src/main/java/com/google/cloud/compute/spi/v1/HttpComputeRpc.java index 2b95d94750cd..f54a948e287f 100644 --- a/google-cloud-compute/src/main/java/com/google/cloud/compute/spi/v1/HttpComputeRpc.java +++ b/google-cloud-compute/src/main/java/com/google/cloud/compute/spi/v1/HttpComputeRpc.java @@ -68,9 +68,10 @@ import com.google.api.services.compute.model.Tags; import com.google.api.services.compute.model.Zone; import com.google.api.services.compute.model.ZoneList; -import com.google.cloud.http.HttpTransportOptions; +import com.google.cloud.Tuple; import com.google.cloud.compute.ComputeException; import com.google.cloud.compute.ComputeOptions; +import com.google.cloud.http.HttpTransportOptions; import com.google.common.collect.ImmutableList; import java.io.IOException; import java.util.Map; diff --git a/google-cloud-compute/src/test/java/com/google/cloud/compute/ComputeImplTest.java b/google-cloud-compute/src/test/java/com/google/cloud/compute/ComputeImplTest.java index 3882c575f22f..b868a63847c5 100644 --- a/google-cloud-compute/src/test/java/com/google/cloud/compute/ComputeImplTest.java +++ b/google-cloud-compute/src/test/java/com/google/cloud/compute/ComputeImplTest.java @@ -27,14 +27,16 @@ import com.google.api.gax.paging.Page; import com.google.cloud.ServiceOptions; +import com.google.cloud.Tuple; import com.google.cloud.compute.NetworkInterface.AccessConfig; -import com.google.cloud.compute.spi.v1.ComputeRpc; import com.google.cloud.compute.spi.ComputeRpcFactory; +import com.google.cloud.compute.spi.v1.ComputeRpc; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; - +import java.util.List; +import java.util.Map; import org.easymock.Capture; import org.easymock.EasyMock; import org.junit.After; @@ -43,9 +45,6 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -import java.util.List; -import java.util.Map; - public class ComputeImplTest { private static final String PROJECT = "project"; @@ -616,8 +615,8 @@ public void testListDiskTypes() { String cursor = "cursor"; compute = options.getService(); ImmutableList diskTypeList = ImmutableList.of(DISK_TYPE, DISK_TYPE); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(diskTypeList, DiskType.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(diskTypeList, DiskType.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listDiskTypes(DISK_TYPE_ID.getZone(), EMPTY_RPC_OPTIONS)) .andReturn(result); EasyMock.replay(computeRpcMock); @@ -632,11 +631,11 @@ public void testListDiskTypesNextPage() { String nextCursor = "nextCursor"; compute = options.getService(); ImmutableList diskTypeList = ImmutableList.of(DISK_TYPE, DISK_TYPE); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(diskTypeList, DiskType.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(diskTypeList, DiskType.TO_PB_FUNCTION)); ImmutableList nextDiskTypeList = ImmutableList.of(DISK_TYPE); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextDiskTypeList, DiskType.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listDiskTypes(DISK_TYPE_ID.getZone(), EMPTY_RPC_OPTIONS)) @@ -656,8 +655,8 @@ public void testListDiskTypesNextPage() { @Test public void testListEmptyDiskTypes() { ImmutableList diskTypes = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, diskTypes); EasyMock.expect(computeRpcMock.listDiskTypes(DISK_TYPE_ID.getZone(), EMPTY_RPC_OPTIONS)) .andReturn(result); @@ -673,8 +672,8 @@ public void testListDiskTypesWithOptions() { String cursor = "cursor"; compute = options.getService(); ImmutableList diskTypeList = ImmutableList.of(DISK_TYPE, DISK_TYPE); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(diskTypeList, DiskType.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(diskTypeList, DiskType.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listDiskTypes(DISK_TYPE_ID.getZone(), DISK_TYPE_LIST_OPTIONS)) .andReturn(result); EasyMock.replay(computeRpcMock); @@ -689,8 +688,8 @@ public void testAggregatedListDiskTypes() { String cursor = "cursor"; compute = options.getService(); ImmutableList diskTypeList = ImmutableList.of(DISK_TYPE, DISK_TYPE); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(diskTypeList, DiskType.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(diskTypeList, DiskType.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listDiskTypes(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listDiskTypes(); @@ -704,11 +703,11 @@ public void testAggregatedListDiskTypesNextPage() { String nextCursor = "nextCursor"; compute = options.getService(); ImmutableList diskTypeList = ImmutableList.of(DISK_TYPE, DISK_TYPE); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(diskTypeList, DiskType.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(diskTypeList, DiskType.TO_PB_FUNCTION)); ImmutableList nextDiskTypeList = ImmutableList.of(DISK_TYPE); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextDiskTypeList, DiskType.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listDiskTypes(EMPTY_RPC_OPTIONS)).andReturn(result); @@ -726,8 +725,8 @@ public void testAggregatedListDiskTypesNextPage() { @Test public void testAggregatedListEmptyDiskTypes() { ImmutableList diskTypes = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, diskTypes); EasyMock.expect(computeRpcMock.listDiskTypes(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); @@ -742,8 +741,8 @@ public void testAggregatedListDiskTypesWithOptions() { String cursor = "cursor"; compute = options.getService(); ImmutableList diskTypeList = ImmutableList.of(DISK_TYPE, DISK_TYPE); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(diskTypeList, DiskType.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(diskTypeList, DiskType.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listDiskTypes(DISK_TYPE_LIST_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listDiskTypes(DISK_TYPE_AGGREGATED_LIST_PAGE_SIZE, @@ -812,8 +811,8 @@ public void testListMachineTypes() { String cursor = "cursor"; compute = options.getService(); ImmutableList machineTypeList = ImmutableList.of(MACHINE_TYPE, MACHINE_TYPE); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(machineTypeList, MachineType.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listMachineTypes(MACHINE_TYPE_ID.getZone(), EMPTY_RPC_OPTIONS)) .andReturn(result); @@ -830,13 +829,13 @@ public void testListMachineTypesNextPage() { String nextCursor = "nextCursor"; compute = options.getService(); ImmutableList machineTypeList = ImmutableList.of(MACHINE_TYPE, MACHINE_TYPE); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(machineTypeList, MachineType.TO_PB_FUNCTION)); ImmutableList nextMachineTypeList = ImmutableList.of(MACHINE_TYPE); - ComputeRpc.Tuple> + Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, + Tuple.of(nextCursor, Iterables.transform(nextMachineTypeList, MachineType.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listMachineTypes(MACHINE_TYPE_ID.getZone(), EMPTY_RPC_OPTIONS)) @@ -858,8 +857,8 @@ public void testListMachineTypesNextPage() { public void testListEmptyMachineTypes() { ImmutableList machineTypes = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of( + Tuple> result = + Tuple.>of( null, machineTypes); EasyMock.expect(computeRpcMock.listMachineTypes(MACHINE_TYPE_ID.getZone(), EMPTY_RPC_OPTIONS)) @@ -877,8 +876,8 @@ public void testListMachineTypesWithOptions() { String cursor = "cursor"; compute = options.getService(); ImmutableList machineTypeList = ImmutableList.of(MACHINE_TYPE, MACHINE_TYPE); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(machineTypeList, MachineType.TO_PB_FUNCTION)); EasyMock.expect( computeRpcMock.listMachineTypes(MACHINE_TYPE_ID.getZone(), MACHINE_TYPE_LIST_OPTIONS)) @@ -896,8 +895,8 @@ public void testAggregatedListMachineTypes() { String cursor = "cursor"; compute = options.getService(); ImmutableList machineTypeList = ImmutableList.of(MACHINE_TYPE, MACHINE_TYPE); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(machineTypeList, MachineType.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listMachineTypes(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); @@ -913,13 +912,13 @@ public void testAggregatedListMachineTypesNextPage() { String nextCursor = "nextCursor"; compute = options.getService(); ImmutableList machineTypeList = ImmutableList.of(MACHINE_TYPE, MACHINE_TYPE); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(machineTypeList, MachineType.TO_PB_FUNCTION)); ImmutableList nextMachineTypeList = ImmutableList.of(MACHINE_TYPE); - ComputeRpc.Tuple> + Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, + Tuple.of(nextCursor, Iterables.transform(nextMachineTypeList, MachineType.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listMachineTypes(EMPTY_RPC_OPTIONS)).andReturn(result); @@ -939,8 +938,8 @@ public void testAggregatedListMachineTypesNextPage() { public void testAggregatedListEmptyMachineTypes() { ImmutableList machineTypes = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of( + Tuple> result = + Tuple.>of( null, machineTypes); EasyMock.expect(computeRpcMock.listMachineTypes(EMPTY_RPC_OPTIONS)).andReturn(result); @@ -957,8 +956,8 @@ public void testAggregatedListMachineTypesWithOptions() { String cursor = "cursor"; compute = options.getService(); ImmutableList machineTypeList = ImmutableList.of(MACHINE_TYPE, MACHINE_TYPE); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(machineTypeList, MachineType.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listMachineTypes(MACHINE_TYPE_LIST_OPTIONS)) .andReturn(result); @@ -1010,8 +1009,8 @@ public void testListRegions() { String cursor = "cursor"; compute = options.getService(); ImmutableList regionList = ImmutableList.of(REGION, REGION); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(regionList, Region.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(regionList, Region.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listRegions(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listRegions(); @@ -1026,10 +1025,10 @@ public void testListRegionsNextPage() { compute = options.getService(); ImmutableList regionList = ImmutableList.of(REGION, REGION); ImmutableList nextRegionList = ImmutableList.of(REGION); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(regionList, Region.TO_PB_FUNCTION)); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, Iterables.transform(nextRegionList, Region.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(regionList, Region.TO_PB_FUNCTION)); + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextRegionList, Region.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listRegions(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.expect(computeRpcMock.listRegions(nextOptions)).andReturn(nextResult); @@ -1045,8 +1044,8 @@ public void testListRegionsNextPage() { @Test public void testListEmptyRegions() { ImmutableList regions = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, regions); EasyMock.expect(computeRpcMock.listRegions(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); @@ -1061,8 +1060,8 @@ public void testListRegionsWithOptions() { String cursor = "cursor"; compute = options.getService(); ImmutableList regionList = ImmutableList.of(REGION, REGION); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(regionList, Region.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(regionList, Region.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listRegions(REGION_LIST_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listRegions(REGION_LIST_PAGE_SIZE, REGION_LIST_PAGE_TOKEN, @@ -1110,8 +1109,8 @@ public void testListZones() { String cursor = "cursor"; compute = options.getService(); ImmutableList zoneList = ImmutableList.of(ZONE, ZONE); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(zoneList, Zone.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(zoneList, Zone.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listZones(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listZones(); @@ -1126,10 +1125,10 @@ public void testListZonesNextPage() { compute = options.getService(); ImmutableList zoneList = ImmutableList.of(ZONE, ZONE); ImmutableList nextZoneList = ImmutableList.of(ZONE); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(zoneList, Zone.TO_PB_FUNCTION)); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, Iterables.transform(nextZoneList, Zone.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(zoneList, Zone.TO_PB_FUNCTION)); + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextZoneList, Zone.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listZones(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.expect(computeRpcMock.listZones(nextOptions)).andReturn(nextResult); @@ -1145,8 +1144,8 @@ public void testListZonesNextPage() { @Test public void testListEmptyZones() { ImmutableList zones = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, zones); EasyMock.expect(computeRpcMock.listZones(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); @@ -1161,8 +1160,8 @@ public void testListZonesWithOptions() { String cursor = "cursor"; compute = options.getService(); ImmutableList zoneList = ImmutableList.of(ZONE, ZONE); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(zoneList, Zone.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(zoneList, Zone.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listZones(ZONE_LIST_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = @@ -1290,8 +1289,8 @@ public void testListGlobalOperations() { String cursor = "cursor"; compute = options.getService(); ImmutableList operationList = ImmutableList.of(globalOperation, globalOperation); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listGlobalOperations(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listGlobalOperations(); @@ -1307,10 +1306,10 @@ public void testListGlobalOperationsNextPage() { compute = options.getService(); ImmutableList operationList = ImmutableList.of(globalOperation, globalOperation); ImmutableList nextOperationList = ImmutableList.of(globalOperation); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextOperationList, OPERATION_TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listGlobalOperations(EMPTY_RPC_OPTIONS)).andReturn(result); @@ -1329,8 +1328,8 @@ public void testListGlobalOperationsNextPage() { @Test public void testListEmptyGlobalOperations() { ImmutableList operations = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, operations); EasyMock.expect(computeRpcMock.listGlobalOperations(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); @@ -1345,8 +1344,8 @@ public void testListGlobalOperationsWithOptions() { String cursor = "cursor"; compute = options.getService(); ImmutableList operationList = ImmutableList.of(globalOperation, globalOperation); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listGlobalOperations(OPERATION_LIST_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listGlobalOperations(OPERATION_LIST_PAGE_SIZE, @@ -1419,8 +1418,8 @@ public void testListRegionOperations() { String cursor = "cursor"; compute = options.getService(); ImmutableList operationList = ImmutableList.of(regionOperation, regionOperation); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); EasyMock.expect( computeRpcMock.listRegionOperations(REGION_OPERATION_ID.getRegion(), EMPTY_RPC_OPTIONS)) .andReturn(result); @@ -1438,10 +1437,10 @@ public void testListRegionOperationsNextPage() { compute = options.getService(); ImmutableList operationList = ImmutableList.of(regionOperation, regionOperation); ImmutableList nextOperationList = ImmutableList.of(regionOperation); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextOperationList, OPERATION_TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listRegionOperations(REGION_OPERATION_ID.getRegion(), @@ -1462,8 +1461,8 @@ public void testListRegionOperationsNextPage() { @Test public void testListEmptyRegionOperations() { ImmutableList operations = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, operations); EasyMock.expect( computeRpcMock.listRegionOperations(REGION_OPERATION_ID.getRegion(), EMPTY_RPC_OPTIONS)) @@ -1480,8 +1479,8 @@ public void testListRegionOperationsWithOptions() { String cursor = "cursor"; compute = options.getService(); ImmutableList operationList = ImmutableList.of(regionOperation, regionOperation); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listRegionOperations( REGION_OPERATION_ID.getRegion(), OPERATION_LIST_OPTIONS)) .andReturn(result); @@ -1553,8 +1552,8 @@ public void testListZoneOperations() { String cursor = "cursor"; compute = options.getService(); ImmutableList operationList = ImmutableList.of(zoneOperation, zoneOperation); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); EasyMock.expect( computeRpcMock.listZoneOperations(ZONE_OPERATION_ID.getZone(), EMPTY_RPC_OPTIONS)) .andReturn(result); @@ -1572,10 +1571,10 @@ public void testListZoneOperationsNextPage() { compute = options.getService(); ImmutableList operationList = ImmutableList.of(zoneOperation, zoneOperation); ImmutableList nextOperationList = ImmutableList.of(zoneOperation); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextOperationList, OPERATION_TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listZoneOperations( @@ -1597,8 +1596,8 @@ public void testListZoneOperationsNextPage() { @Test public void testListEmptyZoneOperations() { ImmutableList operations = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, operations); EasyMock.expect( computeRpcMock.listZoneOperations(ZONE_OPERATION_ID.getZone(), EMPTY_RPC_OPTIONS)) @@ -1615,8 +1614,8 @@ public void testListZoneOperationsWithOptions() { String cursor = "cursor"; compute = options.getService(); ImmutableList operationList = ImmutableList.of(zoneOperation, zoneOperation); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION)); EasyMock.expect( computeRpcMock.listZoneOperations(ZONE_OPERATION_ID.getZone(), OPERATION_LIST_OPTIONS)) .andReturn(result); @@ -1801,8 +1800,8 @@ public void testListGlobalAddresses() { ImmutableList
addressList = ImmutableList.of( new Address(compute, new AddressInfo.BuilderImpl(GLOBAL_ADDRESS)), new Address(compute, new AddressInfo.BuilderImpl(GLOBAL_ADDRESS))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listGlobalAddresses(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page
page = compute.listGlobalAddresses(); @@ -1820,10 +1819,10 @@ public void testListGlobalAddressesNextPage() { new Address(compute, new AddressInfo.BuilderImpl(GLOBAL_ADDRESS))); ImmutableList
nextAddressList = ImmutableList.of( new Address(compute, new AddressInfo.BuilderImpl(GLOBAL_ADDRESS))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextAddressList, AddressInfo.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listGlobalAddresses(EMPTY_RPC_OPTIONS)).andReturn(result); @@ -1841,8 +1840,8 @@ public void testListGlobalAddressesNextPage() { @Test public void testListEmptyGlobalAddresses() { ImmutableList addresses = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, addresses); EasyMock.expect(computeRpcMock.listGlobalAddresses(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); @@ -1859,8 +1858,8 @@ public void testListGlobalAddressesWithOptions() { ImmutableList
addressList = ImmutableList.of( new Address(compute, new AddressInfo.BuilderImpl(GLOBAL_ADDRESS)), new Address(compute, new AddressInfo.BuilderImpl(GLOBAL_ADDRESS))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listGlobalAddresses(ADDRESS_LIST_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page
page = compute.listGlobalAddresses(ADDRESS_LIST_PAGE_SIZE, @@ -1876,8 +1875,8 @@ public void testListRegionAddresses() { ImmutableList
addressList = ImmutableList.of( new Address(compute, new AddressInfo.BuilderImpl(REGION_ADDRESS)), new Address(compute, new AddressInfo.BuilderImpl(REGION_ADDRESS))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); EasyMock.expect( computeRpcMock.listRegionAddresses(REGION_ADDRESS_ID.getRegion(), EMPTY_RPC_OPTIONS)) .andReturn(result); @@ -1897,10 +1896,10 @@ public void testListRegionAddressesNextPage() { new Address(compute, new AddressInfo.BuilderImpl(REGION_ADDRESS))); ImmutableList
nextAddressList = ImmutableList.of( new Address(compute, new AddressInfo.BuilderImpl(REGION_ADDRESS))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextAddressList, AddressInfo.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect( @@ -1922,8 +1921,8 @@ public void testListRegionAddressesNextPage() { @Test public void testListEmptyRegionAddresses() { ImmutableList addresses = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, addresses); EasyMock.expect( computeRpcMock.listRegionAddresses(REGION_ADDRESS_ID.getRegion(), EMPTY_RPC_OPTIONS)) @@ -1942,8 +1941,8 @@ public void testListRegionAddressesWithOptions() { ImmutableList
addressList = ImmutableList.of( new Address(compute, new AddressInfo.BuilderImpl(REGION_ADDRESS)), new Address(compute, new AddressInfo.BuilderImpl(REGION_ADDRESS))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); EasyMock.expect( computeRpcMock.listRegionAddresses(REGION_ADDRESS_ID.getRegion(), ADDRESS_LIST_OPTIONS)) .andReturn(result); @@ -1961,8 +1960,8 @@ public void testAggregatedListAddresses() { ImmutableList
addressList = ImmutableList.of( new Address(compute, new AddressInfo.BuilderImpl(REGION_ADDRESS)), new Address(compute, new AddressInfo.BuilderImpl(REGION_ADDRESS))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listAddresses(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page
page = compute.listAddresses(); @@ -1980,10 +1979,10 @@ public void testAggregatedListAddressesNextPage() { new Address(compute, new AddressInfo.BuilderImpl(REGION_ADDRESS))); ImmutableList
nextAddressList = ImmutableList.of( new Address(compute, new AddressInfo.BuilderImpl(REGION_ADDRESS))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextAddressList, AddressInfo.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listAddresses(EMPTY_RPC_OPTIONS)).andReturn(result); @@ -2001,8 +2000,8 @@ public void testAggregatedListAddressesNextPage() { @Test public void testAggregatedListEmptyAddresses() { ImmutableList addresses = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, addresses); EasyMock.expect(computeRpcMock.listAddresses(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); @@ -2019,8 +2018,8 @@ public void testAggregatedListAddressesWithOptions() { ImmutableList
addressList = ImmutableList.of( new Address(compute, new AddressInfo.BuilderImpl(REGION_ADDRESS)), new Address(compute, new AddressInfo.BuilderImpl(REGION_ADDRESS))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listAddresses(ADDRESS_LIST_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page
page = compute.listAddresses(ADDRESS_AGGREGATED_LIST_PAGE_SIZE, @@ -2194,8 +2193,8 @@ public void testListSnapshots() { ImmutableList snapshotList = ImmutableList.of( new Snapshot(compute, new SnapshotInfo.BuilderImpl(SNAPSHOT)), new Snapshot(compute, new SnapshotInfo.BuilderImpl(SNAPSHOT))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(snapshotList, SnapshotInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(snapshotList, SnapshotInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listSnapshots(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listSnapshots(); @@ -2213,10 +2212,10 @@ public void testListSnapshotsNextPage() { new Snapshot(compute, new SnapshotInfo.BuilderImpl(SNAPSHOT))); ImmutableList nextSnapshotList = ImmutableList.of( new Snapshot(compute, new SnapshotInfo.BuilderImpl(SNAPSHOT))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(snapshotList, SnapshotInfo.TO_PB_FUNCTION)); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(snapshotList, SnapshotInfo.TO_PB_FUNCTION)); + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextSnapshotList, SnapshotInfo.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listSnapshots(EMPTY_RPC_OPTIONS)).andReturn(result); @@ -2235,8 +2234,8 @@ public void testListSnapshotsNextPage() { public void testListEmptySnapshots() { compute = options.getService(); ImmutableList snapshots = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, snapshots); EasyMock.expect(computeRpcMock.listSnapshots(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); @@ -2252,8 +2251,8 @@ public void testListSnapshotsWithOptions() { ImmutableList snapshotList = ImmutableList.of( new Snapshot(compute, new SnapshotInfo.BuilderImpl(SNAPSHOT)), new Snapshot(compute, new SnapshotInfo.BuilderImpl(SNAPSHOT))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(snapshotList, SnapshotInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(snapshotList, SnapshotInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listSnapshots(SNAPSHOT_LIST_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listSnapshots(SNAPSHOT_LIST_PAGE_SIZE, SNAPSHOT_LIST_PAGE_TOKEN, @@ -2406,8 +2405,8 @@ public void testListImages() { ImmutableList imageList = ImmutableList.of( new Image(compute, new ImageInfo.BuilderImpl(IMAGE)), new Image(compute, new ImageInfo.BuilderImpl(IMAGE))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(imageList, ImageInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(imageList, ImageInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listImages(PROJECT, EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listImages(); @@ -2425,10 +2424,10 @@ public void testListImagesNextPage() { new Image(compute, new ImageInfo.BuilderImpl(IMAGE))); ImmutableList nextImageList = ImmutableList.of( new Image(compute, new ImageInfo.BuilderImpl(IMAGE))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(imageList, ImageInfo.TO_PB_FUNCTION)); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(imageList, ImageInfo.TO_PB_FUNCTION)); + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextImageList, ImageInfo.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listImages(PROJECT, EMPTY_RPC_OPTIONS)).andReturn(result); @@ -2449,8 +2448,8 @@ public void testListImagesForProject() { ImmutableList imageList = ImmutableList.of( new Image(compute, new ImageInfo.BuilderImpl(IMAGE)), new Image(compute, new ImageInfo.BuilderImpl(IMAGE))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(imageList, ImageInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(imageList, ImageInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listImages("otherProject", EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listImages("otherProject"); @@ -2462,8 +2461,8 @@ public void testListImagesForProject() { public void testListEmptyImages() { compute = options.getService(); ImmutableList images = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, images); EasyMock.expect(computeRpcMock.listImages(PROJECT, EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); @@ -2476,8 +2475,8 @@ public void testListEmptyImages() { public void testListEmptyImagesForProject() { compute = options.getService(); ImmutableList images = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, images); EasyMock.expect(computeRpcMock.listImages("otherProject", EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); @@ -2493,8 +2492,8 @@ public void testListImagesWithOptions() { ImmutableList imageList = ImmutableList.of( new Image(compute, new ImageInfo.BuilderImpl(IMAGE)), new Image(compute, new ImageInfo.BuilderImpl(IMAGE))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(imageList, ImageInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(imageList, ImageInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listImages(PROJECT, IMAGE_LIST_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listImages(IMAGE_LIST_PAGE_SIZE, IMAGE_LIST_PAGE_TOKEN, @@ -2510,8 +2509,8 @@ public void testListImagesForProjectWithOptions() { ImmutableList imageList = ImmutableList.of( new Image(compute, new ImageInfo.BuilderImpl(IMAGE)), new Image(compute, new ImageInfo.BuilderImpl(IMAGE))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(imageList, ImageInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(imageList, ImageInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listImages("other", IMAGE_LIST_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listImages("other", IMAGE_LIST_PAGE_SIZE, IMAGE_LIST_PAGE_TOKEN, @@ -2602,8 +2601,8 @@ public void testListDisks() { ImmutableList diskList = ImmutableList.of( new Disk(compute, new DiskInfo.BuilderImpl(DISK)), new Disk(compute, new DiskInfo.BuilderImpl(DISK))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(diskList, DiskInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(diskList, DiskInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listDisks(DISK_ID.getZone(), EMPTY_RPC_OPTIONS)) .andReturn(result); EasyMock.replay(computeRpcMock); @@ -2622,10 +2621,10 @@ public void testListDisksNextPage() { new Disk(compute, new DiskInfo.BuilderImpl(DISK))); ImmutableList nextDiskList = ImmutableList.of( new Disk(compute, new DiskInfo.BuilderImpl(DISK))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(diskList, DiskInfo.TO_PB_FUNCTION)); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, Iterables.transform(nextDiskList, DiskInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(diskList, DiskInfo.TO_PB_FUNCTION)); + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextDiskList, DiskInfo.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listDisks(DISK_ID.getZone(), EMPTY_RPC_OPTIONS)) .andReturn(result); @@ -2643,8 +2642,8 @@ public void testListDisksNextPage() { public void testListEmptyDisks() { compute = options.getService(); ImmutableList disks = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, disks); EasyMock.expect(computeRpcMock.listDisks(DISK_ID.getZone(), EMPTY_RPC_OPTIONS)) .andReturn(result); @@ -2661,8 +2660,8 @@ public void testListDisksWithOptions() { ImmutableList diskList = ImmutableList.of( new Disk(compute, new DiskInfo.BuilderImpl(DISK)), new Disk(compute, new DiskInfo.BuilderImpl(DISK))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(diskList, DiskInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(diskList, DiskInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listDisks(DISK_ID.getZone(), DISK_LIST_OPTIONS)) .andReturn(result); EasyMock.replay(computeRpcMock); @@ -2679,8 +2678,8 @@ public void testAggregatedListDisks() { ImmutableList diskList = ImmutableList.of( new Disk(compute, new DiskInfo.BuilderImpl(DISK)), new Disk(compute, new DiskInfo.BuilderImpl(DISK))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(diskList, DiskInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(diskList, DiskInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listDisks(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listDisks(); @@ -2698,10 +2697,10 @@ public void testAggregatedListDisksNextPage() { new Disk(compute, new DiskInfo.BuilderImpl(DISK))); ImmutableList nextDiskList = ImmutableList.of( new Disk(compute, new DiskInfo.BuilderImpl(DISK))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(diskList, DiskInfo.TO_PB_FUNCTION)); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, Iterables.transform(nextDiskList, DiskInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(diskList, DiskInfo.TO_PB_FUNCTION)); + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextDiskList, DiskInfo.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listDisks(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.expect(computeRpcMock.listDisks(nextOptions)).andReturn(nextResult); @@ -2718,8 +2717,8 @@ public void testAggregatedListDisksNextPage() { public void testAggregatedListEmptyDisks() { compute = options.getService(); ImmutableList diskList = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, diskList); EasyMock.expect(computeRpcMock.listDisks(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); @@ -2735,8 +2734,8 @@ public void testAggregatedListDisksWithOptions() { ImmutableList diskList = ImmutableList.of( new Disk(compute, new DiskInfo.BuilderImpl(DISK)), new Disk(compute, new DiskInfo.BuilderImpl(DISK))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(diskList, DiskInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(diskList, DiskInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listDisks(DISK_LIST_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listDisks(DISK_AGGREGATED_LIST_PAGE_SIZE, @@ -2894,8 +2893,8 @@ public void testListSubnetworks() { ImmutableList subnetworkList = ImmutableList.of( new Subnetwork(compute, new SubnetworkInfo.BuilderImpl(SUBNETWORK)), new Subnetwork(compute, new SubnetworkInfo.BuilderImpl(SUBNETWORK))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(subnetworkList, SubnetworkInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listSubnetworks(SUBNETWORK_ID.getRegion(), EMPTY_RPC_OPTIONS)) .andReturn(result); @@ -2916,11 +2915,11 @@ public void testListSubnetworksNextPage() { new Subnetwork(compute, new SubnetworkInfo.BuilderImpl(SUBNETWORK))); ImmutableList nextSubnetworkList = ImmutableList.of( new Subnetwork(compute, new SubnetworkInfo.BuilderImpl(SUBNETWORK))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(subnetworkList, SubnetworkInfo.TO_PB_FUNCTION)); - ComputeRpc.Tuple> - nextResult = ComputeRpc.Tuple.of(nextCursor, + Tuple> + nextResult = Tuple.of(nextCursor, Iterables.transform(nextSubnetworkList, SubnetworkInfo.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listSubnetworks(SUBNETWORK_ID.getRegion(), EMPTY_RPC_OPTIONS)) @@ -2943,8 +2942,8 @@ public void testListEmptySubnetworks() { compute = options.getService(); ImmutableList subnetworks = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of( + Tuple> result = + Tuple.>of( null, subnetworks); EasyMock.expect(computeRpcMock.listSubnetworks(SUBNETWORK_ID.getRegion(), EMPTY_RPC_OPTIONS)) @@ -2962,8 +2961,8 @@ public void testListSubnetworksWithOptions() { ImmutableList subnetworkList = ImmutableList.of( new Subnetwork(compute, new SubnetworkInfo.BuilderImpl(SUBNETWORK)), new Subnetwork(compute, new SubnetworkInfo.BuilderImpl(SUBNETWORK))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(subnetworkList, SubnetworkInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listSubnetworks( SUBNETWORK_ID.getRegion(), SUBNETWORK_LIST_OPTIONS)) @@ -2983,8 +2982,8 @@ public void testAggregatedListSubnetworks() { ImmutableList subnetworkList = ImmutableList.of( new Subnetwork(compute, new SubnetworkInfo.BuilderImpl(SUBNETWORK)), new Subnetwork(compute, new SubnetworkInfo.BuilderImpl(SUBNETWORK))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(subnetworkList, SubnetworkInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listSubnetworks(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); @@ -3004,11 +3003,11 @@ public void testAggregatedListSubnetworksNextPage() { new Subnetwork(compute, new SubnetworkInfo.BuilderImpl(SUBNETWORK))); ImmutableList nextSubnetworkList = ImmutableList.of( new Subnetwork(compute, new SubnetworkInfo.BuilderImpl(SUBNETWORK))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(subnetworkList, SubnetworkInfo.TO_PB_FUNCTION)); - ComputeRpc.Tuple> - nextResult = ComputeRpc.Tuple.of(nextCursor, + Tuple> + nextResult = Tuple.of(nextCursor, Iterables.transform(nextSubnetworkList, SubnetworkInfo.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listSubnetworks(EMPTY_RPC_OPTIONS)).andReturn(result); @@ -3029,8 +3028,8 @@ public void testAggregatedListEmptySubnetworks() { compute = options.getService(); ImmutableList subnetworks = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of( + Tuple> result = + Tuple.>of( null, subnetworks); EasyMock.expect(computeRpcMock.listSubnetworks(EMPTY_RPC_OPTIONS)).andReturn(result); @@ -3047,8 +3046,8 @@ public void testAggregatedListSubnetworksWithOptions() { ImmutableList subnetworkList = ImmutableList.of( new Subnetwork(compute, new SubnetworkInfo.BuilderImpl(SUBNETWORK)), new Subnetwork(compute, new SubnetworkInfo.BuilderImpl(SUBNETWORK))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(subnetworkList, SubnetworkInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listSubnetworks(SUBNETWORK_LIST_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); @@ -3169,8 +3168,8 @@ public void testListNetworks() { ImmutableList networkList = ImmutableList.of( new Network(compute, new NetworkInfo.BuilderImpl(NETWORK)), new Network(compute, new NetworkInfo.BuilderImpl(NETWORK))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(networkList, NetworkInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(networkList, NetworkInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listNetworks(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listNetworks(); @@ -3188,10 +3187,10 @@ public void testListNetworksNextPage() { new Network(compute, new NetworkInfo.BuilderImpl(NETWORK))); ImmutableList nextNetworkList = ImmutableList.of( new Network(compute, new NetworkInfo.BuilderImpl(NETWORK))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(networkList, NetworkInfo.TO_PB_FUNCTION)); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(networkList, NetworkInfo.TO_PB_FUNCTION)); + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextNetworkList, NetworkInfo.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listNetworks(EMPTY_RPC_OPTIONS)).andReturn(result); @@ -3210,8 +3209,8 @@ public void testListNetworksNextPage() { public void testListEmptyNetworks() { compute = options.getService(); ImmutableList networks = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, networks); EasyMock.expect(computeRpcMock.listNetworks(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); @@ -3227,8 +3226,8 @@ public void testListNetworksWithOptions() { ImmutableList networkList = ImmutableList.of( new Network(compute, new NetworkInfo.BuilderImpl(NETWORK)), new Network(compute, new NetworkInfo.BuilderImpl(NETWORK))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(networkList, NetworkInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(networkList, NetworkInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listNetworks(NETWORK_LIST_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listNetworks(NETWORK_LIST_PAGE_SIZE, NETWORK_LIST_PAGE_TOKEN, @@ -3345,8 +3344,8 @@ public void testListInstances() { ImmutableList instanceList = ImmutableList.of( new Instance(compute, new InstanceInfo.BuilderImpl(INSTANCE)), new Instance(compute, new InstanceInfo.BuilderImpl(INSTANCE))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(instanceList, InstanceInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(instanceList, InstanceInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listInstances(INSTANCE_ID.getZone(), EMPTY_RPC_OPTIONS)) .andReturn(result); EasyMock.replay(computeRpcMock); @@ -3365,10 +3364,10 @@ public void testListInstancesNextPage() { new Instance(compute, new InstanceInfo.BuilderImpl(INSTANCE))); ImmutableList nextInstanceList = ImmutableList.of( new Instance(compute, new InstanceInfo.BuilderImpl(INSTANCE))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(instanceList, InstanceInfo.TO_PB_FUNCTION)); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(instanceList, InstanceInfo.TO_PB_FUNCTION)); + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextInstanceList, InstanceInfo.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listInstances(INSTANCE_ID.getZone(), EMPTY_RPC_OPTIONS)) @@ -3389,8 +3388,8 @@ public void testListInstancesNextPage() { public void testListEmptyInstances() { compute = options.getService(); ImmutableList instances = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, instances); EasyMock.expect(computeRpcMock.listInstances(INSTANCE_ID.getZone(), EMPTY_RPC_OPTIONS)) .andReturn(result); @@ -3407,8 +3406,8 @@ public void testListInstancesWithOptions() { ImmutableList instanceList = ImmutableList.of( new Instance(compute, new InstanceInfo.BuilderImpl(INSTANCE)), new Instance(compute, new InstanceInfo.BuilderImpl(INSTANCE))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(instanceList, InstanceInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(instanceList, InstanceInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listInstances(INSTANCE_ID.getZone(), INSTANCE_LIST_OPTIONS)) .andReturn(result); EasyMock.replay(computeRpcMock); @@ -3425,8 +3424,8 @@ public void testAggregatedListInstances() { ImmutableList instanceList = ImmutableList.of( new Instance(compute, new InstanceInfo.BuilderImpl(INSTANCE)), new Instance(compute, new InstanceInfo.BuilderImpl(INSTANCE))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(instanceList, InstanceInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(instanceList, InstanceInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listInstances(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listInstances(); @@ -3444,10 +3443,10 @@ public void testAggregatedListInstancesNextPage() { new Instance(compute, new InstanceInfo.BuilderImpl(INSTANCE))); ImmutableList nextInstanceList = ImmutableList.of( new Instance(compute, new InstanceInfo.BuilderImpl(INSTANCE))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(instanceList, InstanceInfo.TO_PB_FUNCTION)); - ComputeRpc.Tuple> nextResult = - ComputeRpc.Tuple.of(nextCursor, + Tuple> result = + Tuple.of(cursor, Iterables.transform(instanceList, InstanceInfo.TO_PB_FUNCTION)); + Tuple> nextResult = + Tuple.of(nextCursor, Iterables.transform(nextInstanceList, InstanceInfo.TO_PB_FUNCTION)); Map nextOptions = ImmutableMap.of(ComputeRpc.Option.PAGE_TOKEN, cursor); EasyMock.expect(computeRpcMock.listInstances(EMPTY_RPC_OPTIONS)).andReturn(result); @@ -3466,8 +3465,8 @@ public void testAggregatedListInstancesNextPage() { public void testAggregatedListEmptyInstances() { compute = options.getService(); ImmutableList instanceList = ImmutableList.of(); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.>of(null, + Tuple> result = + Tuple.>of(null, instanceList); EasyMock.expect(computeRpcMock.listInstances(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); @@ -3483,8 +3482,8 @@ public void testAggregatedListInstancesWithOptions() { ImmutableList instanceList = ImmutableList.of( new Instance(compute, new InstanceInfo.BuilderImpl(INSTANCE)), new Instance(compute, new InstanceInfo.BuilderImpl(INSTANCE))); - ComputeRpc.Tuple> result = - ComputeRpc.Tuple.of(cursor, Iterables.transform(instanceList, InstanceInfo.TO_PB_FUNCTION)); + Tuple> result = + Tuple.of(cursor, Iterables.transform(instanceList, InstanceInfo.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listInstances(INSTANCE_LIST_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page page = compute.listInstances(INSTANCE_AGGREGATED_LIST_PAGE_SIZE, diff --git a/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java b/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java index a83a171c1d91..a5d1a281a724 100644 --- a/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java +++ b/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java @@ -22,11 +22,11 @@ import com.google.api.services.storage.model.Policy; import com.google.api.services.storage.model.StorageObject; import com.google.api.services.storage.model.TestIamPermissionsResponse; +import com.google.cloud.Tuple; import com.google.cloud.storage.Storage; import com.google.cloud.storage.StorageException; import com.google.cloud.storage.spi.v1.RpcBatch; import com.google.cloud.storage.spi.v1.StorageRpc; - import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; @@ -36,7 +36,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.annotation.concurrent.NotThreadSafe; /** diff --git a/google-cloud-core/src/main/java/com/google/cloud/Tuple.java b/google-cloud-core/src/main/java/com/google/cloud/Tuple.java new file mode 100644 index 000000000000..1536a5d271f0 --- /dev/null +++ b/google-cloud-core/src/main/java/com/google/cloud/Tuple.java @@ -0,0 +1,40 @@ +/* + * Copyright 2017 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +public class Tuple { + + private final X x; + private final Y y; + + private Tuple(X x, Y y) { + this.x = x; + this.y = y; + } + + public static Tuple of(X x, Y y) { + return new Tuple<>(x, y); + } + + public X x() { + return x; + } + + public Y y() { + return y; + } +} diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/GqlQuery.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/GqlQuery.java index 37efac93fb8e..57a0ff3b855f 100644 --- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/GqlQuery.java +++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/GqlQuery.java @@ -196,91 +196,199 @@ public Builder clearBindings() { return this; } + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param cursor a {@link Cursor} object that binds to a given name + */ public Builder setBinding(String name, Cursor cursor) { namedBindings.put(name, new Binding(cursor)); return this; } + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a String object or a list of String objects that binds to a + * given name + */ public Builder setBinding(String name, String... value) { namedBindings.put(name, toBinding(StringValue.MARSHALLER, Arrays.asList(value))); return this; } + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a long value or a list of long values that binds to a given name + */ public Builder setBinding(String name, long... value) { namedBindings.put(name, toBinding(LongValue.MARSHALLER, Longs.asList(value))); return this; } + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a double value or a list of double values that binds to a given name + */ public Builder setBinding(String name, double... value) { namedBindings.put(name, toBinding(DoubleValue.MARSHALLER, Doubles.asList(value))); return this; } + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a boolean value or a list of boolean values that binds to a given name + */ public Builder setBinding(String name, boolean... value) { namedBindings.put(name, toBinding(BooleanValue.MARSHALLER, Booleans.asList(value))); return this; } + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a {@link Timestamp} object or a list of {@link Timestamp} objects that binds to + * a given name + */ public Builder setBinding(String name, Timestamp... value) { namedBindings.put(name, toBinding(TimestampValue.MARSHALLER, Arrays.asList(value))); return this; } + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a {@link Key} object or a list of {@link Key} objects that binds to a given name + */ public Builder setBinding(String name, Key... value) { namedBindings.put(name, toBinding(KeyValue.MARSHALLER, Arrays.asList(value))); return this; } + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a {@link FullEntity} object or a list of {@link FullEntity} objects that binds + * to a given name + */ public Builder setBinding(String name, FullEntity... value) { namedBindings.put(name, toBinding(EntityValue.MARSHALLER, Arrays.asList(value))); return this; } + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a {@link Blob} object or list of {@link Blob} objects that binds to a given name + */ public Builder setBinding(String name, Blob... value) { namedBindings.put(name, toBinding(BlobValue.MARSHALLER, Arrays.asList(value))); return this; } + /** + * Sets a new positional binding. + * + * @param cursor a {@link Cursor} object to be set as a new positional binding + */ public Builder addBinding(Cursor cursor) { positionalBindings.add(new Binding(cursor)); return this; } + /** + * Sets a new positional binding. + * + * @param value a String object or a list of String objects to be set as a new + * positional binding + */ public Builder addBinding(String... value) { positionalBindings.add(toBinding(StringValue.MARSHALLER, Arrays.asList(value))); return this; } + /** + * Sets a new positional binding. + * + * @param value a long value or a list of long values to be set as a new positional binding + */ public Builder addBinding(long... value) { positionalBindings.add(toBinding(LongValue.MARSHALLER, Longs.asList(value))); return this; } + /** + * Sets a new positional binding. + * + * @param value a double value or a list of double values to be set as a new positional binding + */ public Builder addBinding(double... value) { positionalBindings.add(toBinding(DoubleValue.MARSHALLER, Doubles.asList(value))); return this; } + /** + * Sets a new positional binding. + * + * @param value a boolean value or a list of boolean values to be set as a new positional + * binding + */ public Builder addBinding(boolean... value) { positionalBindings.add(toBinding(BooleanValue.MARSHALLER, Booleans.asList(value))); return this; } + /** + * Sets a new positional binding. + * + * @param value a {@link Timestamp} object or a list of {@link Timestamp} objects to be set as a + * new positional binding + */ public Builder addBinding(Timestamp... value) { positionalBindings.add(toBinding(TimestampValue.MARSHALLER, Arrays.asList(value))); return this; } + /** + * Sets a new positional binding. + * + * @param value a {@link Key} object or a list of {@link Key} objects to be set as a new + * positional binding + */ public Builder addBinding(Key... value) { positionalBindings.add(toBinding(KeyValue.MARSHALLER, Arrays.asList(value))); return this; } + /** + * Sets a new positional binding. + * + * @param value a {@link FullEntity} object or a list of {@link FullEntity} objects to be set as + * a new positional binding + */ public Builder addBinding(FullEntity... value) { positionalBindings.add(toBinding(EntityValue.MARSHALLER, Arrays.asList(value))); return this; } + /** + * Sets a new positional binding. + * + * @param value a {@link Blob} object or a list of {@link Blob} objects to be set as a new + * positional binding + */ public Builder addBinding(Blob... value) { positionalBindings.add(toBinding(BlobValue.MARSHALLER, Arrays.asList(value))); return this; diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/bigquery/BigQueryExample.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/bigquery/BigQueryExample.java index b227315b8202..96ae2b5a8a37 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/bigquery/BigQueryExample.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/bigquery/BigQueryExample.java @@ -16,6 +16,7 @@ package com.google.cloud.examples.bigquery; +import com.google.cloud.Tuple; import com.google.cloud.WriteChannel; import com.google.cloud.bigquery.BigQuery; import com.google.cloud.bigquery.BigQueryError; @@ -42,9 +43,7 @@ import com.google.cloud.bigquery.TableInfo; import com.google.cloud.bigquery.ViewDefinition; import com.google.cloud.bigquery.WriteChannelConfiguration; -import com.google.cloud.bigquery.spi.v2.BigQueryRpc.Tuple; import com.google.common.collect.ImmutableMap; - import java.nio.channels.FileChannel; import java.nio.file.Paths; import java.util.Arrays; diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/ComputeExample.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/ComputeExample.java index 9e7291a0b6c1..1e2fc5a12dbb 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/ComputeExample.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/compute/ComputeExample.java @@ -17,6 +17,7 @@ package com.google.cloud.examples.compute; import com.google.api.gax.paging.Page; +import com.google.cloud.Tuple; import com.google.cloud.compute.Address; import com.google.cloud.compute.AddressId; import com.google.cloud.compute.AddressInfo; @@ -68,11 +69,9 @@ import com.google.cloud.compute.Zone; import com.google.cloud.compute.ZoneId; import com.google.cloud.compute.ZoneOperationId; -import com.google.cloud.compute.spi.v1.ComputeRpc.Tuple; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; - import java.util.Arrays; import java.util.HashMap; import java.util.List; diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/logging/LoggingExample.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/logging/LoggingExample.java index d9304f53ac6f..517a4a6b5ed9 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/logging/LoggingExample.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/logging/LoggingExample.java @@ -19,6 +19,7 @@ import com.google.api.gax.paging.Page; import com.google.cloud.MonitoredResource; import com.google.cloud.MonitoredResourceDescriptor; +import com.google.cloud.Tuple; import com.google.cloud.logging.LogEntry; import com.google.cloud.logging.Logging; import com.google.cloud.logging.Logging.EntryListOption; @@ -35,7 +36,6 @@ import com.google.cloud.logging.SinkInfo.Destination.TopicDestination; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; - import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -88,29 +88,6 @@ protected String params() { } } - private static class Tuple { - - private final X x; - private final Y y; - - private Tuple(X x, Y y) { - this.x = x; - this.y = y; - } - - public static Tuple of(X x, Y y) { - return new Tuple<>(x, y); - } - - X x() { - return x; - } - - Y y() { - return y; - } - } - private static class ParentAction extends LoggingAction> { private final Map subActions; diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/StorageExample.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/StorageExample.java index 350b7d10d45f..7d550477947d 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/StorageExample.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/StorageExample.java @@ -18,6 +18,7 @@ import com.google.auth.oauth2.ServiceAccountCredentials; import com.google.cloud.ReadChannel; +import com.google.cloud.Tuple; import com.google.cloud.WriteChannel; import com.google.cloud.storage.Acl; import com.google.cloud.storage.Blob; @@ -30,10 +31,7 @@ import com.google.cloud.storage.Storage.CopyRequest; import com.google.cloud.storage.Storage.SignUrlOption; import com.google.cloud.storage.StorageOptions; -import com.google.cloud.storage.spi.v1.StorageRpc; -import com.google.cloud.storage.spi.v1.StorageRpc.Tuple; import com.google.common.collect.ImmutableMap; - import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -120,7 +118,7 @@ public String params() { } } - private static class ParentAction extends StorageAction> { + private static class ParentAction extends StorageAction> { private final Map subActions; @@ -130,17 +128,17 @@ private static class ParentAction extends StorageAction subaction) throws Exception { + void run(Storage storage, Tuple subaction) throws Exception { subaction.x().run(storage, subaction.y()); } @Override - StorageRpc.Tuple parse(String... args) throws Exception { + Tuple parse(String... args) throws Exception { if (args.length >= 1) { StorageAction action = subActions.get(args[0]); if (action != null) { Object actionArguments = action.parse(Arrays.copyOfRange(args, 1, args.length)); - return StorageRpc.Tuple.of(action, actionArguments); + return Tuple.of(action, actionArguments); } else { throw new IllegalArgumentException("Unrecognized entity '" + args[0] + "'."); } diff --git a/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/ResourceManagerImpl.java b/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/ResourceManagerImpl.java index 65e05f51d9b6..15dcd6fea0bf 100644 --- a/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/ResourceManagerImpl.java +++ b/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/ResourceManagerImpl.java @@ -19,20 +19,19 @@ import static com.google.cloud.RetryHelper.runWithRetries; import static com.google.common.base.Preconditions.checkArgument; -import com.google.cloud.BaseService; import com.google.api.gax.paging.Page; +import com.google.cloud.BaseService; import com.google.cloud.PageImpl; import com.google.cloud.PageImpl.NextPageFetcher; import com.google.cloud.Policy; import com.google.cloud.RetryHelper.RetryHelperException; +import com.google.cloud.Tuple; import com.google.cloud.resourcemanager.spi.v1beta1.ResourceManagerRpc; -import com.google.cloud.resourcemanager.spi.v1beta1.ResourceManagerRpc.Tuple; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; - import java.util.List; import java.util.Map; import java.util.concurrent.Callable; diff --git a/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/spi/v1beta1/HttpResourceManagerRpc.java b/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/spi/v1beta1/HttpResourceManagerRpc.java index 2db5acde3420..8466bd047d7d 100644 --- a/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/spi/v1beta1/HttpResourceManagerRpc.java +++ b/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/spi/v1beta1/HttpResourceManagerRpc.java @@ -31,6 +31,7 @@ import com.google.api.services.cloudresourcemanager.model.SetIamPolicyRequest; import com.google.api.services.cloudresourcemanager.model.TestIamPermissionsRequest; import com.google.api.services.cloudresourcemanager.model.TestIamPermissionsResponse; +import com.google.cloud.Tuple; import com.google.cloud.http.HttpTransportOptions; import com.google.cloud.resourcemanager.ResourceManagerException; import com.google.cloud.resourcemanager.ResourceManagerOptions; diff --git a/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/spi/v1beta1/ResourceManagerRpc.java b/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/spi/v1beta1/ResourceManagerRpc.java index 5a23f038efb3..b2c09b319a73 100644 --- a/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/spi/v1beta1/ResourceManagerRpc.java +++ b/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/spi/v1beta1/ResourceManagerRpc.java @@ -19,8 +19,8 @@ import com.google.api.services.cloudresourcemanager.model.Policy; import com.google.api.services.cloudresourcemanager.model.Project; import com.google.cloud.ServiceRpc; +import com.google.cloud.Tuple; import com.google.cloud.resourcemanager.ResourceManagerException; - import java.util.List; import java.util.Map; @@ -56,28 +56,6 @@ Integer getInt(Map options) { } } - class Tuple { - private final X x; - private final Y y; - - private Tuple(X x, Y y) { - this.x = x; - this.y = y; - } - - public static Tuple of(X x, Y y) { - return new Tuple<>(x, y); - } - - public X x() { - return x; - } - - public Y y() { - return y; - } - } - /** * Creates a new project. * diff --git a/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/testing/LocalResourceManagerHelperTest.java b/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/testing/LocalResourceManagerHelperTest.java index ae58a57b86eb..ac9ea2e6ecfb 100644 --- a/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/testing/LocalResourceManagerHelperTest.java +++ b/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/testing/LocalResourceManagerHelperTest.java @@ -25,23 +25,21 @@ import static org.junit.Assert.fail; import com.google.api.services.cloudresourcemanager.model.Binding; +import com.google.cloud.Tuple; import com.google.cloud.resourcemanager.ResourceManagerException; import com.google.cloud.resourcemanager.spi.v1beta1.HttpResourceManagerRpc; import com.google.cloud.resourcemanager.spi.v1beta1.ResourceManagerRpc; -import com.google.cloud.resourcemanager.spi.v1beta1.ResourceManagerRpc.Tuple; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; - -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; public class LocalResourceManagerHelperTest { diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/Blob.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/Blob.java index 5f516acd1063..a46367a1525d 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/Blob.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/Blob.java @@ -24,6 +24,7 @@ import com.google.auth.ServiceAccountSigner; import com.google.auth.ServiceAccountSigner.SigningException; import com.google.cloud.ReadChannel; +import com.google.cloud.Tuple; import com.google.cloud.WriteChannel; import com.google.cloud.storage.Acl.Entity; import com.google.cloud.storage.Storage.BlobTargetOption; @@ -31,10 +32,8 @@ import com.google.cloud.storage.Storage.CopyRequest; import com.google.cloud.storage.Storage.SignUrlOption; import com.google.cloud.storage.spi.v1.StorageRpc; -import com.google.cloud.storage.spi.v1.StorageRpc.Tuple; import com.google.common.base.Function; import com.google.common.io.BaseEncoding; - import java.io.IOException; import java.io.ObjectInputStream; import java.net.URL; diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobReadChannel.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobReadChannel.java index eab0717a79f5..be7a4544dc90 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobReadChannel.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobReadChannel.java @@ -22,10 +22,9 @@ import com.google.cloud.ReadChannel; import com.google.cloud.RestorableState; import com.google.cloud.RetryHelper; +import com.google.cloud.Tuple; import com.google.cloud.storage.spi.v1.StorageRpc; -import com.google.cloud.storage.spi.v1.StorageRpc.Tuple; import com.google.common.base.MoreObjects; - import java.io.IOException; import java.io.Serializable; import java.nio.ByteBuffer; diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/Bucket.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/Bucket.java index 5b552c954eeb..12bb9e88876f 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/Bucket.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/Bucket.java @@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.api.gax.paging.Page; +import com.google.cloud.Tuple; import com.google.cloud.storage.Acl.Entity; import com.google.cloud.storage.Storage.BlobGetOption; import com.google.cloud.storage.Storage.BlobListOption; @@ -32,7 +33,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.io.BaseEncoding; - import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; @@ -148,30 +148,30 @@ private BlobTargetOption(StorageRpc.Option rpcOption, Object value) { super(rpcOption, value); } - private StorageRpc.Tuple toTargetOption(BlobInfo blobInfo) { + private Tuple toTargetOption(BlobInfo blobInfo) { BlobId blobId = blobInfo.getBlobId(); switch (getRpcOption()) { case PREDEFINED_ACL: - return StorageRpc.Tuple.of(blobInfo, + return Tuple.of(blobInfo, Storage.BlobTargetOption.predefinedAcl((Storage.PredefinedAcl) getValue())); case IF_GENERATION_MATCH: blobId = BlobId.of(blobId.getBucket(), blobId.getName(), (Long) getValue()); - return StorageRpc.Tuple.of(blobInfo.toBuilder().setBlobId(blobId).build(), + return Tuple.of(blobInfo.toBuilder().setBlobId(blobId).build(), Storage.BlobTargetOption.generationMatch()); case IF_GENERATION_NOT_MATCH: blobId = BlobId.of(blobId.getBucket(), blobId.getName(), (Long) getValue()); - return StorageRpc.Tuple.of(blobInfo.toBuilder().setBlobId(blobId).build(), + return Tuple.of(blobInfo.toBuilder().setBlobId(blobId).build(), Storage.BlobTargetOption.generationNotMatch()); case IF_METAGENERATION_MATCH: - return StorageRpc.Tuple.of( + return Tuple.of( blobInfo.toBuilder().setMetageneration((Long) getValue()).build(), Storage.BlobTargetOption.metagenerationMatch()); case IF_METAGENERATION_NOT_MATCH: - return StorageRpc.Tuple.of( + return Tuple.of( blobInfo.toBuilder().setMetageneration((Long) getValue()).build(), Storage.BlobTargetOption.metagenerationNotMatch()); case CUSTOMER_SUPPLIED_KEY: - return StorageRpc.Tuple.of(blobInfo, + return Tuple.of(blobInfo, Storage.BlobTargetOption.encryptionKey((String) getValue())); default: throw new AssertionError("Unexpected enum value"); @@ -249,7 +249,7 @@ public static BlobTargetOption encryptionKey(String key) { return new BlobTargetOption(StorageRpc.Option.CUSTOMER_SUPPLIED_KEY, key); } - static StorageRpc.Tuple toTargetOptions( + static Tuple toTargetOptions( BlobInfo info, BlobTargetOption... options) { Set optionSet = Sets.immutableEnumSet(Lists.transform(Arrays.asList(options), TO_ENUM)); @@ -263,12 +263,12 @@ static StorageRpc.Tuple toTargetOptions( BlobInfo targetInfo = info; int index = 0; for (BlobTargetOption option : options) { - StorageRpc.Tuple target = + Tuple target = option.toTargetOption(targetInfo); targetInfo = target.x(); convertedOptions[index++] = target.y(); } - return StorageRpc.Tuple.of(targetInfo, convertedOptions); + return Tuple.of(targetInfo, convertedOptions); } } @@ -289,34 +289,34 @@ public Storage.BlobWriteOption.Option apply(BlobWriteOption blobWriteOption) { private final Storage.BlobWriteOption.Option option; private final Object value; - private StorageRpc.Tuple toWriteOption(BlobInfo blobInfo) { + private Tuple toWriteOption(BlobInfo blobInfo) { BlobId blobId = blobInfo.getBlobId(); switch (option) { case PREDEFINED_ACL: - return StorageRpc.Tuple.of(blobInfo, + return Tuple.of(blobInfo, Storage.BlobWriteOption.predefinedAcl((Storage.PredefinedAcl) value)); case IF_GENERATION_MATCH: blobId = BlobId.of(blobId.getBucket(), blobId.getName(), (Long) value); - return StorageRpc.Tuple.of(blobInfo.toBuilder().setBlobId(blobId).build(), + return Tuple.of(blobInfo.toBuilder().setBlobId(blobId).build(), Storage.BlobWriteOption.generationMatch()); case IF_GENERATION_NOT_MATCH: blobId = BlobId.of(blobId.getBucket(), blobId.getName(), (Long) value); - return StorageRpc.Tuple.of(blobInfo.toBuilder().setBlobId(blobId).build(), + return Tuple.of(blobInfo.toBuilder().setBlobId(blobId).build(), Storage.BlobWriteOption.generationNotMatch()); case IF_METAGENERATION_MATCH: - return StorageRpc.Tuple.of(blobInfo.toBuilder().setMetageneration((Long) value).build(), + return Tuple.of(blobInfo.toBuilder().setMetageneration((Long) value).build(), Storage.BlobWriteOption.metagenerationMatch()); case IF_METAGENERATION_NOT_MATCH: - return StorageRpc.Tuple.of(blobInfo.toBuilder().setMetageneration((Long) value).build(), + return Tuple.of(blobInfo.toBuilder().setMetageneration((Long) value).build(), Storage.BlobWriteOption.metagenerationNotMatch()); case IF_MD5_MATCH: - return StorageRpc.Tuple.of(blobInfo.toBuilder().setMd5((String) value).build(), + return Tuple.of(blobInfo.toBuilder().setMd5((String) value).build(), Storage.BlobWriteOption.md5Match()); case IF_CRC32C_MATCH: - return StorageRpc.Tuple.of(blobInfo.toBuilder().setCrc32c((String) value).build(), + return Tuple.of(blobInfo.toBuilder().setCrc32c((String) value).build(), Storage.BlobWriteOption.crc32cMatch()); case CUSTOMER_SUPPLIED_KEY: - return StorageRpc.Tuple.of(blobInfo, + return Tuple.of(blobInfo, Storage.BlobWriteOption.encryptionKey((String) value)); default: throw new AssertionError("Unexpected enum value"); @@ -435,7 +435,7 @@ public static BlobWriteOption encryptionKey(String key) { return new BlobWriteOption(Storage.BlobWriteOption.Option.CUSTOMER_SUPPLIED_KEY, key); } - static StorageRpc.Tuple toWriteOptions( + static Tuple toWriteOptions( BlobInfo info, BlobWriteOption... options) { Set optionSet = Sets.immutableEnumSet(Lists.transform(Arrays.asList(options), TO_ENUM)); @@ -449,11 +449,11 @@ static StorageRpc.Tuple toWriteOptions( BlobInfo writeInfo = info; int index = 0; for (BlobWriteOption option : options) { - StorageRpc.Tuple write = option.toWriteOption(writeInfo); + Tuple write = option.toWriteOption(writeInfo); writeInfo = write.x(); convertedOptions[index++] = write.y(); } - return StorageRpc.Tuple.of(writeInfo, convertedOptions); + return Tuple.of(writeInfo, convertedOptions); } } @@ -784,7 +784,7 @@ public List get(Iterable blobNames) { public Blob create(String blob, byte[] content, String contentType, BlobTargetOption... options) { BlobInfo blobInfo = BlobInfo.newBuilder(BlobId.of(getName(), blob)).setContentType(contentType).build(); - StorageRpc.Tuple target = + Tuple target = BlobTargetOption.toTargetOptions(blobInfo, options); return storage.create(target.x(), content, target.y()); } @@ -812,7 +812,7 @@ public Blob create(String blob, InputStream content, String contentType, BlobWriteOption... options) { BlobInfo blobInfo = BlobInfo.newBuilder(BlobId.of(getName(), blob)).setContentType(contentType).build(); - StorageRpc.Tuple write = + Tuple write = BlobWriteOption.toWriteOptions(blobInfo, options); return storage.create(write.x(), content, write.y()); } @@ -837,7 +837,7 @@ public Blob create(String blob, InputStream content, String contentType, */ public Blob create(String blob, byte[] content, BlobTargetOption... options) { BlobInfo blobInfo = BlobInfo.newBuilder(BlobId.of(getName(), blob)).build(); - StorageRpc.Tuple target = + Tuple target = BlobTargetOption.toTargetOptions(blobInfo, options); return storage.create(target.x(), content, target.y()); } @@ -862,7 +862,7 @@ public Blob create(String blob, byte[] content, BlobTargetOption... options) { */ public Blob create(String blob, InputStream content, BlobWriteOption... options) { BlobInfo blobInfo = BlobInfo.newBuilder(BlobId.of(getName(), blob)).build(); - StorageRpc.Tuple write = + Tuple write = BlobWriteOption.toWriteOptions(blobInfo, options); return storage.create(write.x(), content, write.y()); } diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java index 3ebb9bc981c2..3ce120fcfc13 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java @@ -29,10 +29,10 @@ import com.google.cloud.Policy; import com.google.cloud.ReadChannel; import com.google.cloud.Service; +import com.google.cloud.Tuple; import com.google.cloud.WriteChannel; import com.google.cloud.storage.Acl.Entity; import com.google.cloud.storage.spi.v1.StorageRpc; -import com.google.cloud.storage.spi.v1.StorageRpc.Tuple; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java index 3d08dc01e191..dea0cb877b43 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java @@ -46,10 +46,10 @@ import com.google.cloud.Policy; import com.google.cloud.ReadChannel; import com.google.cloud.RetryHelper.RetryHelperException; +import com.google.cloud.Tuple; import com.google.cloud.storage.Acl.Entity; import com.google.cloud.storage.spi.v1.StorageRpc; import com.google.cloud.storage.spi.v1.StorageRpc.RewriteResponse; -import com.google.cloud.storage.spi.v1.StorageRpc.Tuple; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java index 9c732a544b42..137d96671904 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java @@ -52,6 +52,7 @@ import com.google.api.services.storage.model.StorageObject; import com.google.api.services.storage.model.TestIamPermissionsResponse; import com.google.cloud.BaseServiceException; +import com.google.cloud.Tuple; import com.google.cloud.http.HttpTransportOptions; import com.google.cloud.storage.StorageException; import com.google.cloud.storage.StorageOptions; diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/StorageRpc.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/StorageRpc.java index e1902dd77877..bb61eaa219cf 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/StorageRpc.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/StorageRpc.java @@ -23,6 +23,7 @@ import com.google.api.services.storage.model.StorageObject; import com.google.api.services.storage.model.TestIamPermissionsResponse; import com.google.cloud.ServiceRpc; +import com.google.cloud.Tuple; import com.google.cloud.storage.StorageException; import java.io.InputStream; import java.util.List; @@ -79,29 +80,6 @@ Boolean getBoolean(Map options) { } } - class Tuple { - - private final X x; - private final Y y; - - private Tuple(X x, Y y) { - this.x = x; - this.y = y; - } - - public static Tuple of(X x, Y y) { - return new Tuple<>(x, y); - } - - public X x() { - return x; - } - - public Y y() { - return y; - } - } - class RewriteRequest { public final StorageObject source; diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/BlobReadChannelTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/BlobReadChannelTest.java index 2c3ba4380117..aa820111e9d6 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/BlobReadChannelTest.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/BlobReadChannelTest.java @@ -29,20 +29,19 @@ import com.google.cloud.ReadChannel; import com.google.cloud.RestorableState; import com.google.cloud.ServiceOptions; -import com.google.cloud.storage.spi.v1.StorageRpc; +import com.google.cloud.Tuple; import com.google.cloud.storage.spi.StorageRpcFactory; +import com.google.cloud.storage.spi.v1.StorageRpc; import com.google.common.collect.ImmutableMap; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.ClosedChannelException; import java.util.Arrays; import java.util.Map; import java.util.Random; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; public class BlobReadChannelTest { @@ -91,7 +90,7 @@ public void testReadBuffered() throws IOException { ByteBuffer firstReadBuffer = ByteBuffer.allocate(42); ByteBuffer secondReadBuffer = ByteBuffer.allocate(42); expect(storageRpcMock.read(BLOB_ID.toPb(), EMPTY_RPC_OPTIONS, 0, DEFAULT_CHUNK_SIZE)) - .andReturn(StorageRpc.Tuple.of("etag", result)); + .andReturn(Tuple.of("etag", result)); replay(storageRpcMock); reader.read(firstReadBuffer); reader.read(secondReadBuffer); @@ -111,10 +110,10 @@ public void testReadBig() throws IOException { ByteBuffer firstReadBuffer = ByteBuffer.allocate(DEFAULT_CHUNK_SIZE); ByteBuffer secondReadBuffer = ByteBuffer.allocate(42); expect(storageRpcMock.read(BLOB_ID.toPb(), EMPTY_RPC_OPTIONS, 0, DEFAULT_CHUNK_SIZE)) - .andReturn(StorageRpc.Tuple.of("etag", firstResult)); + .andReturn(Tuple.of("etag", firstResult)); expect(storageRpcMock.read( BLOB_ID.toPb(), EMPTY_RPC_OPTIONS, DEFAULT_CHUNK_SIZE, CUSTOM_CHUNK_SIZE)) - .andReturn(StorageRpc.Tuple.of("etag", secondResult)); + .andReturn(Tuple.of("etag", secondResult)); replay(storageRpcMock); reader.read(firstReadBuffer); reader.read(secondReadBuffer); @@ -129,7 +128,7 @@ public void testReadFinish() throws IOException { byte[] result = {}; ByteBuffer readBuffer = ByteBuffer.allocate(DEFAULT_CHUNK_SIZE); expect(storageRpcMock.read(BLOB_ID.toPb(), EMPTY_RPC_OPTIONS, 0, DEFAULT_CHUNK_SIZE)) - .andReturn(StorageRpc.Tuple.of("etag", result)); + .andReturn(Tuple.of("etag", result)); replay(storageRpcMock); assertEquals(-1, reader.read(readBuffer)); } @@ -141,7 +140,7 @@ public void testSeek() throws IOException { byte[] result = randomByteArray(DEFAULT_CHUNK_SIZE); ByteBuffer readBuffer = ByteBuffer.allocate(DEFAULT_CHUNK_SIZE); expect(storageRpcMock.read(BLOB_ID.toPb(), EMPTY_RPC_OPTIONS, 42, DEFAULT_CHUNK_SIZE)) - .andReturn(StorageRpc.Tuple.of("etag", result)); + .andReturn(Tuple.of("etag", result)); replay(storageRpcMock); reader.read(readBuffer); assertArrayEquals(result, readBuffer.array()); @@ -179,10 +178,10 @@ public void testReadGenerationChanged() throws IOException { ByteBuffer firstReadBuffer = ByteBuffer.allocate(DEFAULT_CHUNK_SIZE); ByteBuffer secondReadBuffer = ByteBuffer.allocate(DEFAULT_CHUNK_SIZE); expect(storageRpcMock.read(blobId.toPb(), EMPTY_RPC_OPTIONS, 0, DEFAULT_CHUNK_SIZE)) - .andReturn(StorageRpc.Tuple.of("etag1", firstResult)); + .andReturn(Tuple.of("etag1", firstResult)); expect( storageRpcMock.read(blobId.toPb(), EMPTY_RPC_OPTIONS, DEFAULT_CHUNK_SIZE, - DEFAULT_CHUNK_SIZE)).andReturn(StorageRpc.Tuple.of("etag2", secondResult)); + DEFAULT_CHUNK_SIZE)).andReturn(Tuple.of("etag2", secondResult)); replay(storageRpcMock); reader.read(firstReadBuffer); try { @@ -202,9 +201,9 @@ public void testSaveAndRestore() throws IOException { ByteBuffer firstReadBuffer = ByteBuffer.allocate(42); ByteBuffer secondReadBuffer = ByteBuffer.allocate(DEFAULT_CHUNK_SIZE); expect(storageRpcMock.read(BLOB_ID.toPb(), EMPTY_RPC_OPTIONS, 0, DEFAULT_CHUNK_SIZE)) - .andReturn(StorageRpc.Tuple.of("etag", firstResult)); + .andReturn(Tuple.of("etag", firstResult)); expect(storageRpcMock.read(BLOB_ID.toPb(), EMPTY_RPC_OPTIONS, 42, DEFAULT_CHUNK_SIZE)) - .andReturn(StorageRpc.Tuple.of("etag", secondResult)); + .andReturn(Tuple.of("etag", secondResult)); replay(storageRpcMock); reader = new BlobReadChannel(options, BLOB_ID, EMPTY_RPC_OPTIONS); reader.read(firstReadBuffer); diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/StorageImplTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/StorageImplTest.java index 9373f88dd8e2..2be9d6e06d4a 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/StorageImplTest.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/StorageImplTest.java @@ -38,6 +38,7 @@ import com.google.cloud.Policy; import com.google.cloud.ReadChannel; import com.google.cloud.ServiceOptions; +import com.google.cloud.Tuple; import com.google.cloud.WriteChannel; import com.google.cloud.storage.Acl.Project; import com.google.cloud.storage.Acl.Project.ProjectRole; @@ -51,7 +52,6 @@ import com.google.cloud.storage.spi.StorageRpcFactory; import com.google.cloud.storage.spi.v1.RpcBatch; import com.google.cloud.storage.spi.v1.StorageRpc; -import com.google.cloud.storage.spi.v1.StorageRpc.Tuple; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; @@ -1293,7 +1293,7 @@ public void testReaderWithOptions() throws IOException { byte[] result = new byte[DEFAULT_CHUNK_SIZE]; EasyMock.expect( storageRpcMock.read(BLOB_INFO2.toPb(), BLOB_SOURCE_OPTIONS, 0, DEFAULT_CHUNK_SIZE)) - .andReturn(StorageRpc.Tuple.of("etag", result)); + .andReturn(Tuple.of("etag", result)); EasyMock.replay(storageRpcMock); initializeService(); ReadChannel channel = @@ -1309,7 +1309,7 @@ public void testReaderWithDecryptionKey() throws IOException { byte[] result = new byte[DEFAULT_CHUNK_SIZE]; EasyMock.expect( storageRpcMock.read(BLOB_INFO2.toPb(), ENCRYPTION_KEY_OPTIONS, 0, DEFAULT_CHUNK_SIZE)) - .andReturn(StorageRpc.Tuple.of("etag", result)) + .andReturn(Tuple.of("etag", result)) .times(2); EasyMock.replay(storageRpcMock); initializeService(); @@ -1330,7 +1330,7 @@ public void testReaderWithOptionsFromBlobId() throws IOException { EasyMock.expect( storageRpcMock.read( BLOB_INFO1.getBlobId().toPb(), BLOB_SOURCE_OPTIONS, 0, DEFAULT_CHUNK_SIZE)) - .andReturn(StorageRpc.Tuple.of("etag", result)); + .andReturn(Tuple.of("etag", result)); EasyMock.replay(storageRpcMock); initializeService(); ReadChannel channel =