From 951be77470c32e2ad16e1d5b37c57b7aea628c06 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Fri, 29 Jan 2016 08:59:11 -0800 Subject: [PATCH] Remove second replace method --- .../gcloud/resourcemanager/Project.java | 15 -------- .../gcloud/resourcemanager/ProjectTest.java | 36 +++++++------------ 2 files changed, 13 insertions(+), 38 deletions(-) diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java index 2db2602abe03..15e45f7e48fd 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java @@ -196,21 +196,6 @@ public void undelete() { resourceManager.undelete(projectId()); } - /** - * Replaces the attributes of the project with the attributes from the given {@code ProjectInfo}. - * - *

The caller must have modify permissions for this project. - * - * @see Cloud - * Resource Manager update - * @return the Project representing the new project metadata - * @throws ResourceManagerException upon failure - */ - public Project replace(ProjectInfo projectInfo) { - return resourceManager.replace(checkNotNull(projectInfo)); - } - /** * Replaces the attributes of the project with the attributes of this project. * diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java index ee648df76eda..a741963913c6 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java @@ -168,35 +168,26 @@ public void testUndelete() { } @Test - public void testReplaceWithProjectInfo() { + public void testReplace() { initializeExpectedProject(2); - ProjectInfo newInfo = PROJECT_INFO.toBuilder().addLabel("k3", "v3").build(); - Project expectedProject = - new Project(serviceMockReturnsOptions, new ProjectInfo.BuilderImpl(newInfo)); - expect(resourceManager.options()).andReturn(mockOptions); - expect(resourceManager.replace(newInfo)).andReturn(expectedProject); - replay(resourceManager); - initializeProject(); - Project newProject = project.replace(newInfo); - assertEquals(expectedProject, newProject); - } - - @Test - public void testReplaceWithoutProjectInfo() { - initializeExpectedProject(2); - ProjectInfo newInfo = PROJECT_INFO.toBuilder().addLabel("k3", "v3").build(); - Project expectedProject = - new Project(serviceMockReturnsOptions, new ProjectInfo.BuilderImpl(newInfo)); - expect(resourceManager.options()).andReturn(mockOptions); - expect(resourceManager.replace(anyObject(Project.class))).andReturn(expectedProject); + Project expectedReplacedProject = expectedProject.toBuilder().addLabel("k3", "v3").build(); + expect(resourceManager.options()).andReturn(mockOptions).times(2); + expect(resourceManager.replace(anyObject(Project.class))).andReturn(expectedReplacedProject); replay(resourceManager); initializeProject(); - Project newProject = project.replace(newInfo); - assertEquals(expectedProject, newProject); + Project newProject = + new Project(resourceManager, new ProjectInfo.BuilderImpl(expectedReplacedProject)); + Project actualReplacedProject = newProject.replace(); + compareProjectInfos(expectedReplacedProject, actualReplacedProject); } private void compareProjects(Project expected, Project value) { assertEquals(expected, value); + compareProjectInfos(expected, value); + assertEquals(expected.resourceManager().options(), value.resourceManager().options()); + } + + private void compareProjectInfos(ProjectInfo expected, ProjectInfo value) { assertEquals(expected.projectId(), value.projectId()); assertEquals(expected.name(), value.name()); assertEquals(expected.labels(), value.labels()); @@ -204,6 +195,5 @@ private void compareProjects(Project expected, Project value) { assertEquals(expected.createTimeMillis(), value.createTimeMillis()); assertEquals(expected.state(), value.state()); assertEquals(expected.parent(), value.parent()); - assertEquals(expected.resourceManager().options(), value.resourceManager().options()); } }