Skip to content

Commit

Permalink
Remove second replace method
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajay Kannan committed Jan 29, 2016
1 parent ce8ae4b commit 34fe23c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,21 +196,6 @@ public void undelete() {
resourceManager.undelete(projectId());
}

/**
* Replaces the attributes of the project with the attributes from the given {@code ProjectInfo}.
*
* <p>The caller must have modify permissions for this project.
*
* @see <a
* href="https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/update">Cloud
* Resource Manager update</a>
* @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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,31 +168,16 @@ 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);
Project expectedReplacedProject = expectedProject.toBuilder().addLabel("k3", "v3").build();
expect(resourceManager.options()).andReturn(mockOptions).times(2);
expect(resourceManager.replace(anyObject(Project.class))).andReturn(expectedProject);
replay(resourceManager);
initializeProject();
Project newProject = project.replace(newInfo);
assertEquals(expectedProject, newProject);
Project newProject =
new Project(resourceManager, new ProjectInfo.BuilderImpl(expectedReplacedProject));
newProject.replace();
}

private void compareProjects(Project expected, Project value) {
Expand Down

0 comments on commit 34fe23c

Please sign in to comment.