*/
@Test
public void testDoUpdateTreeWithReplace() throws Exception {
TreeNodeMetadataValue path = TreeStructureUtil.createPath("Bobby", "description", "owner", "name");
TreeStructureUtil.addValue(path, "Admin", "What is the owner", "type");
MetadataJobProperty myContainer = spy(new MetadataJobProperty());
when(myContainer.getACL()).thenReturn(acl);
myContainer.addChild(path);
String replace = TreeStructureUtil.createPath("Tomas", "description", "owner", "name").toJson().toString();
JSONObject expectedJson = new JSONObject();
expectedJson.put("type", "ok");
expectedJson.put("errorCode", 0);
expectedJson.put("message", "OK");
when(request.getParameter(eq("job"))).thenReturn(job);
when(request.getParameter(eq("data"))).thenReturn(replace);
when(request.getParameter(eq("replace"))).thenReturn("true");
PowerMockito.when(CliUtils.getContainer(null, job, null, true)).thenReturn(myContainer);
action.doUpdate(request, response);
verify(response, atLeastOnce()).setContentType(eq(CONTENT_TYPE));
verify(out).print(eq(expectedJson.toString()));
assertEquals(1, myContainer.getChildren().size());
assertEquals(2, ((TreeNodeMetadataValue)myContainer.getChild("owner")).getChildren().size());
assertEquals("Tomas", TreeStructureUtil.getPath(myContainer, "owner", "name").getValue());
}