Skip to content

Commit 101f6df

Browse files
committed
---
yaml --- r: 4867 b: refs/heads/logging-alpha c: 1d5f171 h: refs/heads/master i: 4865: e875ce4 4863: 642b5f1
1 parent 470fb19 commit 101f6df

3 files changed

Lines changed: 27 additions & 122 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ refs/heads/compute-alpha: 969cba2627f1d53d352cc4a5ffe0879dacf65e6c
1212
refs/heads/dns-alpha: 2f90e7e338349287ace33375896907af0f032ca1
1313
refs/heads/dns-alpha-batch: 17442b07867021b85d0452f5f3eda29a3413288f
1414
refs/heads/gcs-nio: 283aeaf15efdcf3621eb6859f05e55ad7764375d
15-
refs/heads/logging-alpha: 9cf9309daa5406a23882b88fc5a32b9f51d37e83
15+
refs/heads/logging-alpha: 1d5f1716fd633b5d971c1e468dc336f79e21805b
1616
refs/tags/v0.1.0: a615317f7424ed58621b1f65d5c4d8cbbe8a6ed8
1717
refs/tags/v0.1.1: 7a7f6985fe465e9dd6a075af55493f42b4933be0
1818
refs/tags/v0.1.2: 3eb3fe866ba22487686048f45d927b8c8638ea3f

branches/logging-alpha/gcloud-java-compute/src/main/java/com/google/gcloud/compute/Operation.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
package com.google.gcloud.compute;
1818

1919
import static com.google.common.base.Preconditions.checkNotNull;
20-
import static com.google.gcloud.compute.OperationId.Type.REGION;
21-
import static com.google.gcloud.compute.OperationId.Type.ZONE;
2220

2321
import com.google.common.base.Function;
2422
import com.google.common.base.MoreObjects;

branches/logging-alpha/gcloud-java-compute/src/test/java/com/google/gcloud/compute/ComputeImplTest.java

Lines changed: 26 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,15 @@ public class ComputeImplTest {
319319
private static final Compute.AddressAggregatedListOption ADDRESS_AGGREGATED_LIST_FILTER =
320320
Compute.AddressAggregatedListOption.filter(ADDRESS_FILTER);
321321

322+
private static final Function<Operation, com.google.api.services.compute.model.Operation>
323+
OPERATION_TO_PB_FUNCTION = new Function<Operation,
324+
com.google.api.services.compute.model.Operation>() {
325+
@Override
326+
public com.google.api.services.compute.model.Operation apply(Operation operation) {
327+
return operation.toPb();
328+
}
329+
};
330+
322331
private ComputeOptions options;
323332
private ComputeRpcFactory rpcFactoryMock;
324333
private ComputeRpc computeRpcMock;
@@ -1130,13 +1139,7 @@ public void testListGlobalOperations() {
11301139
compute = options.service();
11311140
ImmutableList<Operation> operationList = ImmutableList.of(globalOperation, globalOperation);
11321141
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> result =
1133-
Tuple.of(cursor, Iterables.transform(operationList,
1134-
new Function<Operation, com.google.api.services.compute.model.Operation>() {
1135-
@Override
1136-
public com.google.api.services.compute.model.Operation apply(Operation operation) {
1137-
return operation.toPb();
1138-
}
1139-
}));
1142+
Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION));
11401143
EasyMock.expect(computeRpcMock.listGlobalOperations(EMPTY_RPC_OPTIONS)).andReturn(result);
11411144
EasyMock.replay(computeRpcMock);
11421145
Page<Operation> page = compute.listGlobalOperations();
@@ -1152,21 +1155,9 @@ public void testListGlobalOperationsNextPage() {
11521155
ImmutableList<Operation> operationList = ImmutableList.of(globalOperation, globalOperation);
11531156
ImmutableList<Operation> nextOperationList = ImmutableList.of(globalOperation);
11541157
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> result =
1155-
Tuple.of(cursor, Iterables.transform(operationList,
1156-
new Function<Operation, com.google.api.services.compute.model.Operation>() {
1157-
@Override
1158-
public com.google.api.services.compute.model.Operation apply(Operation operation) {
1159-
return operation.toPb();
1160-
}
1161-
}));
1158+
Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION));
11621159
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> nextResult =
1163-
Tuple.of(nextCursor, Iterables.transform(nextOperationList,
1164-
new Function<Operation, com.google.api.services.compute.model.Operation>() {
1165-
@Override
1166-
public com.google.api.services.compute.model.Operation apply(Operation operation) {
1167-
return operation.toPb();
1168-
}
1169-
}));
1160+
Tuple.of(nextCursor, Iterables.transform(nextOperationList, OPERATION_TO_PB_FUNCTION));
11701161
Map<ComputeRpc.Option, ?> nextOptions = ImmutableMap.of(PAGE_TOKEN, cursor);
11711162
EasyMock.expect(computeRpcMock.listGlobalOperations(EMPTY_RPC_OPTIONS)).andReturn(result);
11721163
EasyMock.expect(computeRpcMock.listGlobalOperations(nextOptions)).andReturn(nextResult);
@@ -1200,13 +1191,7 @@ public void testListGlobalOperationsWithOptions() {
12001191
compute = options.service();
12011192
ImmutableList<Operation> operationList = ImmutableList.of(globalOperation, globalOperation);
12021193
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> result =
1203-
Tuple.of(cursor, Iterables.transform(operationList,
1204-
new Function<Operation, com.google.api.services.compute.model.Operation>() {
1205-
@Override
1206-
public com.google.api.services.compute.model.Operation apply(Operation operation) {
1207-
return operation.toPb();
1208-
}
1209-
}));
1194+
Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION));
12101195
EasyMock.expect(computeRpcMock.listGlobalOperations(OPERATION_LIST_OPTIONS)).andReturn(result);
12111196
EasyMock.replay(computeRpcMock);
12121197
Page<Operation> page = compute.listGlobalOperations(OPERATION_LIST_PAGE_SIZE,
@@ -1278,13 +1263,7 @@ public void testListRegionOperations() {
12781263
compute = options.service();
12791264
ImmutableList<Operation> operationList = ImmutableList.of(regionOperation, regionOperation);
12801265
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> result =
1281-
Tuple.of(cursor, Iterables.transform(operationList,
1282-
new Function<Operation, com.google.api.services.compute.model.Operation>() {
1283-
@Override
1284-
public com.google.api.services.compute.model.Operation apply(Operation operation) {
1285-
return operation.toPb();
1286-
}
1287-
}));
1266+
Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION));
12881267
EasyMock.expect(
12891268
computeRpcMock.listRegionOperations(REGION_OPERATION_ID.region(), EMPTY_RPC_OPTIONS))
12901269
.andReturn(result);
@@ -1302,21 +1281,9 @@ public void testListRegionOperationsNextPage() {
13021281
ImmutableList<Operation> operationList = ImmutableList.of(regionOperation, regionOperation);
13031282
ImmutableList<Operation> nextOperationList = ImmutableList.of(regionOperation);
13041283
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> result =
1305-
Tuple.of(cursor, Iterables.transform(operationList,
1306-
new Function<Operation, com.google.api.services.compute.model.Operation>() {
1307-
@Override
1308-
public com.google.api.services.compute.model.Operation apply(Operation operation) {
1309-
return operation.toPb();
1310-
}
1311-
}));
1284+
Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION));
13121285
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> nextResult =
1313-
Tuple.of(nextCursor, Iterables.transform(nextOperationList,
1314-
new Function<Operation, com.google.api.services.compute.model.Operation>() {
1315-
@Override
1316-
public com.google.api.services.compute.model.Operation apply(Operation operation) {
1317-
return operation.toPb();
1318-
}
1319-
}));
1286+
Tuple.of(nextCursor, Iterables.transform(nextOperationList, OPERATION_TO_PB_FUNCTION));
13201287
Map<ComputeRpc.Option, ?> nextOptions = ImmutableMap.of(PAGE_TOKEN, cursor);
13211288
EasyMock.expect(computeRpcMock.listRegionOperations(REGION_OPERATION_ID.region(),
13221289
EMPTY_RPC_OPTIONS)).andReturn(result);
@@ -1354,13 +1321,7 @@ public void testListRegionOperationsWithOptions() {
13541321
compute = options.service();
13551322
ImmutableList<Operation> operationList = ImmutableList.of(regionOperation, regionOperation);
13561323
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> result =
1357-
Tuple.of(cursor, Iterables.transform(operationList,
1358-
new Function<Operation, com.google.api.services.compute.model.Operation>() {
1359-
@Override
1360-
public com.google.api.services.compute.model.Operation apply(Operation operation) {
1361-
return operation.toPb();
1362-
}
1363-
}));
1324+
Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION));
13641325
EasyMock.expect(
13651326
computeRpcMock.listRegionOperations(REGION_OPERATION_ID.region(), OPERATION_LIST_OPTIONS))
13661327
.andReturn(result);
@@ -1431,13 +1392,7 @@ public void testListZoneOperations() {
14311392
compute = options.service();
14321393
ImmutableList<Operation> operationList = ImmutableList.of(zoneOperation, zoneOperation);
14331394
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> result =
1434-
Tuple.of(cursor, Iterables.transform(operationList,
1435-
new Function<Operation, com.google.api.services.compute.model.Operation>() {
1436-
@Override
1437-
public com.google.api.services.compute.model.Operation apply(Operation operation) {
1438-
return operation.toPb();
1439-
}
1440-
}));
1395+
Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION));
14411396
EasyMock.expect(
14421397
computeRpcMock.listZoneOperations(ZONE_OPERATION_ID.zone(), EMPTY_RPC_OPTIONS))
14431398
.andReturn(result);
@@ -1455,21 +1410,9 @@ public void testListZoneOperationsNextPage() {
14551410
ImmutableList<Operation> operationList = ImmutableList.of(zoneOperation, zoneOperation);
14561411
ImmutableList<Operation> nextOperationList = ImmutableList.of(zoneOperation);
14571412
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> result =
1458-
Tuple.of(cursor, Iterables.transform(operationList,
1459-
new Function<Operation, com.google.api.services.compute.model.Operation>() {
1460-
@Override
1461-
public com.google.api.services.compute.model.Operation apply(Operation operation) {
1462-
return operation.toPb();
1463-
}
1464-
}));
1413+
Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION));
14651414
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> nextResult =
1466-
Tuple.of(nextCursor, Iterables.transform(nextOperationList,
1467-
new Function<Operation, com.google.api.services.compute.model.Operation>() {
1468-
@Override
1469-
public com.google.api.services.compute.model.Operation apply(Operation operation) {
1470-
return operation.toPb();
1471-
}
1472-
}));
1415+
Tuple.of(nextCursor, Iterables.transform(nextOperationList, OPERATION_TO_PB_FUNCTION));
14731416
Map<ComputeRpc.Option, ?> nextOptions = ImmutableMap.of(PAGE_TOKEN, cursor);
14741417
EasyMock.expect(computeRpcMock.listZoneOperations(ZONE_OPERATION_ID.zone(), EMPTY_RPC_OPTIONS))
14751418
.andReturn(result);
@@ -1507,13 +1450,7 @@ public void testListZoneOperationsWithOptions() {
15071450
compute = options.service();
15081451
ImmutableList<Operation> operationList = ImmutableList.of(zoneOperation, zoneOperation);
15091452
Tuple<String, Iterable<com.google.api.services.compute.model.Operation>> result =
1510-
Tuple.of(cursor, Iterables.transform(operationList,
1511-
new Function<Operation, com.google.api.services.compute.model.Operation>() {
1512-
@Override
1513-
public com.google.api.services.compute.model.Operation apply(Operation operation) {
1514-
return operation.toPb();
1515-
}
1516-
}));
1453+
Tuple.of(cursor, Iterables.transform(operationList, OPERATION_TO_PB_FUNCTION));
15171454
EasyMock.expect(
15181455
computeRpcMock.listZoneOperations(ZONE_OPERATION_ID.zone(), OPERATION_LIST_OPTIONS))
15191456
.andReturn(result);
@@ -1713,21 +1650,9 @@ public void testListGlobalAddressesNextPage() {
17131650
ImmutableList<Address> nextAddressList = ImmutableList.of(
17141651
new Address(compute, new AddressInfo.BuilderImpl(GLOBAL_ADDRESS)));
17151652
Tuple<String, Iterable<com.google.api.services.compute.model.Address>> result =
1716-
Tuple.of(cursor, Iterables.transform(addressList,
1717-
new Function<Address, com.google.api.services.compute.model.Address>() {
1718-
@Override
1719-
public com.google.api.services.compute.model.Address apply(Address address) {
1720-
return address.toPb();
1721-
}
1722-
}));
1653+
Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION));
17231654
Tuple<String, Iterable<com.google.api.services.compute.model.Address>> nextResult =
1724-
Tuple.of(nextCursor, Iterables.transform(nextAddressList,
1725-
new Function<Address, com.google.api.services.compute.model.Address>() {
1726-
@Override
1727-
public com.google.api.services.compute.model.Address apply(Address address) {
1728-
return address.toPb();
1729-
}
1730-
}));
1655+
Tuple.of(nextCursor, Iterables.transform(nextAddressList, AddressInfo.TO_PB_FUNCTION));
17311656
Map<ComputeRpc.Option, ?> nextOptions = ImmutableMap.of(PAGE_TOKEN, cursor);
17321657
EasyMock.expect(computeRpcMock.listGlobalAddresses(EMPTY_RPC_OPTIONS)).andReturn(result);
17331658
EasyMock.expect(computeRpcMock.listGlobalAddresses(nextOptions)).andReturn(nextResult);
@@ -1778,13 +1703,7 @@ public void testListRegionAddresses() {
17781703
new Address(compute, new AddressInfo.BuilderImpl(REGION_ADDRESS)),
17791704
new Address(compute, new AddressInfo.BuilderImpl(REGION_ADDRESS)));
17801705
Tuple<String, Iterable<com.google.api.services.compute.model.Address>> result =
1781-
Tuple.of(cursor, Iterables.transform(addressList,
1782-
new Function<Address, com.google.api.services.compute.model.Address>() {
1783-
@Override
1784-
public com.google.api.services.compute.model.Address apply(Address address) {
1785-
return address.toPb();
1786-
}
1787-
}));
1706+
Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION));
17881707
EasyMock.expect(
17891708
computeRpcMock.listRegionAddresses(REGION_ADDRESS_ID.region(), EMPTY_RPC_OPTIONS))
17901709
.andReturn(result);
@@ -1805,21 +1724,9 @@ public void testListRegionAddressesNextPage() {
18051724
ImmutableList<Address> nextAddressList = ImmutableList.of(
18061725
new Address(compute, new AddressInfo.BuilderImpl(REGION_ADDRESS)));
18071726
Tuple<String, Iterable<com.google.api.services.compute.model.Address>> result =
1808-
Tuple.of(cursor, Iterables.transform(addressList,
1809-
new Function<Address, com.google.api.services.compute.model.Address>() {
1810-
@Override
1811-
public com.google.api.services.compute.model.Address apply(Address address) {
1812-
return address.toPb();
1813-
}
1814-
}));
1727+
Tuple.of(cursor, Iterables.transform(addressList, AddressInfo.TO_PB_FUNCTION));
18151728
Tuple<String, Iterable<com.google.api.services.compute.model.Address>> nextResult =
1816-
Tuple.of(nextCursor, Iterables.transform(nextAddressList,
1817-
new Function<Address, com.google.api.services.compute.model.Address>() {
1818-
@Override
1819-
public com.google.api.services.compute.model.Address apply(Address address) {
1820-
return address.toPb();
1821-
}
1822-
}));
1729+
Tuple.of(nextCursor, Iterables.transform(nextAddressList, AddressInfo.TO_PB_FUNCTION));
18231730
Map<ComputeRpc.Option, ?> nextOptions = ImmutableMap.of(PAGE_TOKEN, cursor);
18241731
EasyMock.expect(
18251732
computeRpcMock.listRegionAddresses(REGION_ADDRESS_ID.region(), EMPTY_RPC_OPTIONS))

0 commit comments

Comments
 (0)