Skip to content

Commit a2b6573

Browse files
author
Ajay Kannan
committed
Add list/get options serialization tests + other small fixes
1 parent 4107bbe commit a2b6573

File tree

6 files changed

+12
-10
lines changed

6 files changed

+12
-10
lines changed

gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ProjectInfo.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private Builder() {
132132
Builder(ProjectInfo info) {
133133
this.name = info.name;
134134
this.projectId = info.projectId;
135-
this.labels = Maps.newHashMap(checkNotNull(info.labels));
135+
this.labels.putAll(info.labels);
136136
this.projectNumber = info.projectNumber;
137137
this.state = info.state;
138138
this.createTimeMillis = info.createTimeMillis;
@@ -159,7 +159,7 @@ public Builder name(String name) {
159159
* project.
160160
*/
161161
public Builder projectId(String projectId) {
162-
this.projectId = projectId;
162+
this.projectId = checkNotNull(projectId);
163163
return this;
164164
}
165165

@@ -230,7 +230,7 @@ public ProjectInfo build() {
230230

231231
ProjectInfo(Builder builder) {
232232
this.name = builder.name;
233-
this.projectId = checkNotNull(builder.projectId);
233+
this.projectId = builder.projectId;
234234
this.labels = ImmutableMap.copyOf(builder.labels);
235235
this.projectNumber = builder.projectNumber;
236236
this.state = builder.state;

gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public interface ResourceManager extends Service<ResourceManagerOptions> {
3636
/**
3737
* The fields of a project.
3838
*
39-
* These values can be used to specify the fields to include of in a partial response when calling
39+
* These values can be used to specify the fields to include in a partial response when calling
4040
* {@link ResourceManager#get} or {@link ResourceManager#list}. Project ID is always returned,
4141
* even if not specified.
4242
*/

gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/DefaultResourceManagerRpc.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void delete(String projectId) throws ResourceManagerException {
6363
}
6464

6565
@Override
66-
public Project get(String projectId) throws ResourceManagerException {
66+
public Project get(String projectId, Map<Option, ?> options) throws ResourceManagerException {
6767
// TODO(ajaykannan): fix me!
6868
return null;
6969
}

gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/ResourceManagerRpc.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public Y y() {
7777

7878
void delete(String projectId) throws ResourceManagerException;
7979

80-
Project get(String projectId) throws ResourceManagerException;
80+
Project get(String projectId, Map<Option, ?> options) throws ResourceManagerException;
8181

8282
Tuple<String, Iterable<Project>> list(Map<Option, ?> options) throws ResourceManagerException;
8383

gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java

-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import static org.easymock.EasyMock.createStrictMock;
2020
import static org.easymock.EasyMock.expect;
21-
import static org.easymock.EasyMock.expectLastCall;
2221
import static org.easymock.EasyMock.replay;
2322
import static org.easymock.EasyMock.verify;
2423
import static org.junit.Assert.assertEquals;
@@ -94,15 +93,13 @@ public void testResourceManager() {
9493
@Test
9594
public void testDelete() {
9695
resourceManager.delete(PROJECT_INFO.projectId());
97-
expectLastCall();
9896
replay(resourceManager);
9997
project.delete();
10098
}
10199

102100
@Test
103101
public void testUndelete() {
104102
resourceManager.undelete(PROJECT_INFO.projectId());
105-
expectLastCall();
106103
replay(resourceManager);
107104
project.undelete();
108105
}

gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public class SerializationTest {
4646
.build();
4747
private static final PageImpl<ProjectInfo> PAGE_RESULT =
4848
new PageImpl<>(null, "c", Collections.singletonList(PARTIAL_PROJECT_INFO));
49+
private static final ResourceManager.ProjectGetOption PROJECT_GET_OPTION =
50+
ResourceManager.ProjectGetOption.fields(ResourceManager.ProjectField.NAME);
51+
private static final ResourceManager.ProjectListOption PROJECT_LIST_OPTION =
52+
ResourceManager.ProjectListOption.filter("name:*");
4953

5054
@Test
5155
public void testServiceOptions() throws Exception {
@@ -63,7 +67,8 @@ public void testServiceOptions() throws Exception {
6367

6468
@Test
6569
public void testModelAndRequests() throws Exception {
66-
Serializable[] objects = {PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, PAGE_RESULT};
70+
Serializable[] objects = {PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, PAGE_RESULT,
71+
PROJECT_GET_OPTION, PROJECT_LIST_OPTION};
6772
for (Serializable obj : objects) {
6873
Object copy = serializeAndDeserialize(obj);
6974
assertEquals(obj, obj);

0 commit comments

Comments
 (0)