Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute Operation: remove creationTimestamp field and fix isDone() #914

Merged
merged 2 commits into from
Apr 13, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove Compute Operation's creation timestamp field
  • Loading branch information
mziccard committed Apr 13, 2016
commit 246e5a7138e38c04e867b61dae28106be8569684
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ static String selector(LicenseField... fields) {
*/
enum OperationField {
CLIENT_OPERATION_ID("clientOperationId"),
CREATION_TIMESTAMP("creationTimestamp"),
DESCRIPTION("description"),
END_TIME("endTime"),
ERROR("error"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public class Operation implements Serializable {
private final ComputeOptions options;
private final String id;
private final OperationId operationId;
private final Long creationTimestamp;
private final String clientOperationId;
private final String operationType;
private final String targetLink;
Expand Down Expand Up @@ -296,7 +295,6 @@ static final class Builder {

private Compute compute;
private String id;
private Long creationTimestamp;
private OperationId operationId;
private String clientOperationId;
private String operationType;
Expand Down Expand Up @@ -324,9 +322,6 @@ static final class Builder {
if (operationPb.getId() != null) {
id = operationPb.getId().toString();
}
if (operationPb.getCreationTimestamp() != null) {
creationTimestamp = TIMESTAMP_FORMATTER.parseMillis(operationPb.getCreationTimestamp());
}
if (RegionOperationId.matchesUrl(operationPb.getSelfLink())) {
operationId = RegionOperationId.fromUrl(operationPb.getSelfLink());
} else if (ZoneOperationId.matchesUrl(operationPb.getSelfLink())) {
Expand Down Expand Up @@ -372,11 +367,6 @@ Builder id(String id) {
return this;
}

Builder creationTimestamp(Long creationTimestamp) {
this.creationTimestamp = creationTimestamp;
return this;
}

Builder operationId(OperationId operationId) {
this.operationId = checkNotNull(operationId);
return this;
Expand Down Expand Up @@ -471,7 +461,6 @@ private Operation(Builder builder) {
this.compute = checkNotNull(builder.compute);
this.options = compute.options();
this.id = builder.id;
this.creationTimestamp = builder.creationTimestamp;
this.operationId = checkNotNull(builder.operationId);
this.clientOperationId = builder.clientOperationId;
this.operationType = builder.operationType;
Expand Down Expand Up @@ -505,13 +494,6 @@ public String id() {
return id;
}

/**
* Returns the creation timestamp in milliseconds since epoch.
*/
public Long creationTimestamp() {
return creationTimestamp;
}

/**
* Returns the operation's identity. This method returns an {@link GlobalOperationId} for global
* operations, a {@link RegionOperationId} for region operations and a {@link ZoneOperationId} for
Expand Down Expand Up @@ -705,7 +687,6 @@ public String toString() {
return MoreObjects.toStringHelper(this)
.add("id", id)
.add("operationsId", operationId)
.add("creationTimestamp", creationTimestamp)
.add("clientOperationId", clientOperationId)
.add("operationType", operationType)
.add("targetLink", targetLink)
Expand Down Expand Up @@ -743,9 +724,6 @@ com.google.api.services.compute.model.Operation toPb() {
if (id != null) {
operationPb.setId(new BigInteger(id));
}
if (creationTimestamp != null) {
operationPb.setCreationTimestamp(TIMESTAMP_FORMATTER.print(creationTimestamp));
}
operationPb.setName(operationId.operation());
operationPb.setClientOperationId(clientOperationId);
switch (operationId.type()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ public void setUp() {
Compute otherService = options.toBuilder().build().service();
globalOperation = new Operation.Builder(otherService)
.id(ID)
.creationTimestamp(CREATION_TIMESTAMP)
.operationId(GLOBAL_OPERATION_ID)
.clientOperationId(CLIENT_OPERATION_ID)
.operationType(OPERATION_TYPE)
Expand All @@ -448,7 +447,6 @@ public void setUp() {
.build();
zoneOperation = new Operation.Builder(otherService)
.id(ID)
.creationTimestamp(CREATION_TIMESTAMP)
.operationId(ZONE_OPERATION_ID)
.clientOperationId(CLIENT_OPERATION_ID)
.operationType(OPERATION_TYPE)
Expand All @@ -469,7 +467,6 @@ public void setUp() {
.build();
regionOperation = new Operation.Builder(otherService)
.id(ID)
.creationTimestamp(CREATION_TIMESTAMP)
.operationId(REGION_OPERATION_ID)
.clientOperationId(CLIENT_OPERATION_ID)
.operationType(OPERATION_TYPE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ private void initializeExpectedOperation(int optionsCalls) {
replay(serviceMockReturnsOptions);
globalOperation = new Operation.Builder(serviceMockReturnsOptions)
.id(ID)
.creationTimestamp(CREATION_TIMESTAMP)
.operationId(GLOBAL_OPERATION_ID)
.clientOperationId(CLIENT_OPERATION_ID)
.operationType(OPERATION_TYPE)
Expand All @@ -110,7 +109,6 @@ private void initializeExpectedOperation(int optionsCalls) {
.build();
zoneOperation = new Operation.Builder(serviceMockReturnsOptions)
.id(ID)
.creationTimestamp(CREATION_TIMESTAMP)
.operationId(ZONE_OPERATION_ID)
.clientOperationId(CLIENT_OPERATION_ID)
.operationType(OPERATION_TYPE)
Expand All @@ -131,7 +129,6 @@ private void initializeExpectedOperation(int optionsCalls) {
.build();
regionOperation = new Operation.Builder(serviceMockReturnsOptions)
.id(ID)
.creationTimestamp(CREATION_TIMESTAMP)
.operationId(REGION_OPERATION_ID)
.clientOperationId(CLIENT_OPERATION_ID)
.operationType(OPERATION_TYPE)
Expand All @@ -157,7 +154,6 @@ private void initializeOperation() {
operation = new Operation.Builder(compute)
.id(ID)
.operationId(GLOBAL_OPERATION_ID)
.creationTimestamp(CREATION_TIMESTAMP)
.clientOperationId(CLIENT_OPERATION_ID)
.operationType(OPERATION_TYPE)
.targetLink(TARGET_LINK)
Expand All @@ -183,7 +179,6 @@ public void tearDown() throws Exception {
}

private void assertEqualsCommonFields(Operation operation) {
assertEquals(CREATION_TIMESTAMP, operation.creationTimestamp());
assertEquals(ID, operation.id());
assertEquals(CLIENT_OPERATION_ID, operation.clientOperationId());
assertEquals(OPERATION_TYPE, operation.operationType());
Expand All @@ -205,7 +200,6 @@ private void assertEqualsCommonFields(Operation operation) {
}

private void assertNullCommonFields(Operation operation) {
assertNull(operation.creationTimestamp());
assertNull(operation.id());
assertNull(operation.clientOperationId());
assertNull(operation.operationType());
Expand Down Expand Up @@ -401,7 +395,6 @@ public void testReloadWithOptions() throws Exception {
private void compareOperation(Operation expected, Operation value) {
assertEquals(expected, value);
assertEquals(expected.compute().options(), value.compute().options());
assertEquals(expected.creationTimestamp(), value.creationTimestamp());
assertEquals(expected.operationId(), value.operationId());
assertEquals(expected.clientOperationId(), value.clientOperationId());
assertEquals(expected.operationType(), value.operationType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@ public void testListGlobalOperationsWithSelectedFields() {
assertNull(operation.operationType());
assertNull(operation.targetLink());
assertNull(operation.targetId());
assertNull(operation.creationTimestamp());
assertNull(operation.operationType());
assertNull(operation.status());
assertNull(operation.statusMessage());
Expand Down Expand Up @@ -564,7 +563,6 @@ public void testListRegionOperationsWithSelectedFields() {
assertNull(operation.operationType());
assertNull(operation.targetLink());
assertNull(operation.targetId());
assertNull(operation.creationTimestamp());
assertNull(operation.operationType());
assertNull(operation.status());
assertNull(operation.statusMessage());
Expand Down Expand Up @@ -628,7 +626,6 @@ public void testListZoneOperationsWithSelectedFields() {
assertNull(operation.operationType());
assertNull(operation.targetLink());
assertNull(operation.targetId());
assertNull(operation.creationTimestamp());
assertNull(operation.operationType());
assertNull(operation.status());
assertNull(operation.statusMessage());
Expand Down