@Test public void testUpdatingContentWhenUpdateContentIsSuccessful() throws Exception { final String newContent = "new content"; doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { Object[] arguments = invocation.getArguments(); AsyncRequestCallback<Void> callback = (AsyncRequestCallback<Void>)arguments[3]; GwtReflectionUtils.callOnSuccess(callback, (Void)null); return callback; } }).when(projectServiceClient).updateFile(anyString(), anyString(), anyString(), (AsyncRequestCallback<Void>)anyObject()); AsyncCallback<Void> callback = mock(AsyncCallback.class); fileNode.updateContent(newContent, callback); verify(projectServiceClient).updateFile(eq(ITEM_PATH), eq(newContent), anyString(), Matchers.<AsyncRequestCallback<Void>>anyObject()); verify(callback).onSuccess(Matchers.<Void>anyObject()); }
public void updateContent(String content, final AsyncCallback<Void> callback) { projectServiceClient.updateFile(getPath(), content, null, new AsyncRequestCallback<Void>() { @Override protected void onSuccess(Void result) { callback.onSuccess(result); } @Override protected void onFailure(Throwable exception) { callback.onFailure(exception); } }); }
FileNode extends ItemNode implements VirtualFile { public void updateContent(String content, final AsyncCallback<Void> callback) { projectServiceClient.updateFile(getPath(), content, null, new AsyncRequestCallback<Void>() { @Override protected void onSuccess(Void result) { callback.onSuccess(result); } @Override protected void onFailure(Throwable exception) { callback.onFailure(exception); } }); } }
FileNode extends ItemNode implements VirtualFile { public void updateContent(String content, final AsyncCallback<Void> callback) { projectServiceClient.updateFile(getPath(), content, null, new AsyncRequestCallback<Void>() { @Override protected void onSuccess(Void result) { callback.onSuccess(result); } @Override protected void onFailure(Throwable exception) { callback.onFailure(exception); } }); } @Inject  FileNode(@Assisted TreeNode<?> parent,
                    @Assisted ItemReference data,
                    @Assisted TreeStructure treeStructure,
                    EventBus eventBus,
                    ProjectServiceClient projectServiceClient,
                    DtoUnmarshallerFactory dtoUnmarshallerFactory); }
FileNode extends ItemNode implements VirtualFile { public void updateContent(String content, final AsyncCallback<Void> callback) { projectServiceClient.updateFile(getPath(), content, null, new AsyncRequestCallback<Void>() { @Override protected void onSuccess(Void result) { callback.onSuccess(result); } @Override protected void onFailure(Throwable exception) { callback.onFailure(exception); } }); } @Inject  FileNode(@Assisted TreeNode<?> parent,
                    @Assisted ItemReference data,
                    @Assisted TreeStructure treeStructure,
                    EventBus eventBus,
                    ProjectServiceClient projectServiceClient,
                    DtoUnmarshallerFactory dtoUnmarshallerFactory); @Override boolean isLeaf(); @Override void processNodeAction(); @Override void delete(final DeleteCallback callback); @Nullable @Override String getMediaType(); @Override boolean isReadOnly(); @Override String getContentUrl(); void getContent(final AsyncCallback<String> callback); void updateContent(String content, final AsyncCallback<Void> callback); @Override boolean equals(Object o); @Override int hashCode(); @Override boolean canContainsFolder(); }
FileNode extends ItemNode implements VirtualFile { public void updateContent(String content, final AsyncCallback<Void> callback) { projectServiceClient.updateFile(getPath(), content, null, new AsyncRequestCallback<Void>() { @Override protected void onSuccess(Void result) { callback.onSuccess(result); } @Override protected void onFailure(Throwable exception) { callback.onFailure(exception); } }); } @Inject  FileNode(@Assisted TreeNode<?> parent,
                    @Assisted ItemReference data,
                    @Assisted TreeStructure treeStructure,
                    EventBus eventBus,
                    ProjectServiceClient projectServiceClient,
                    DtoUnmarshallerFactory dtoUnmarshallerFactory); @Override boolean isLeaf(); @Override void processNodeAction(); @Override void delete(final DeleteCallback callback); @Nullable @Override String getMediaType(); @Override boolean isReadOnly(); @Override String getContentUrl(); void getContent(final AsyncCallback<String> callback); void updateContent(String content, final AsyncCallback<Void> callback); @Override boolean equals(Object o); @Override int hashCode(); @Override boolean canContainsFolder();  }