@Test public void testDeleteWhenDeleteIsSuccessful() throws Exception { doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { Object[] arguments = invocation.getArguments(); AsyncRequestCallback<Void> callback = (AsyncRequestCallback<Void>)arguments[1]; GwtReflectionUtils.callOnSuccess(callback, (Void)null); return callback; } }).when(projectServiceClient).delete(anyString(), (AsyncRequestCallback<Void>)anyObject()); DeleteCallback callback = mock(DeleteCallback.class); projectNode.delete(callback); verify(projectServiceClient).delete(eq(ITEM_PATH), Matchers.<AsyncRequestCallback<Void>>anyObject()); verify(callback).onDeleted(); }
@Override public void delete(final DeleteCallback callback) { projectServiceClient.delete(getPath(), new AsyncRequestCallback<Void>() { @Override protected void onSuccess(Void result) { if (isRootProject()) { eventBus.fireEvent(new CloseCurrentProjectEvent()); } ProjectNode.super.delete(new DeleteCallback() { @Override public void onDeleted() { callback.onDeleted(); } @Override public void onFailure(Throwable caught) { callback.onFailure(caught); } }); } @Override protected void onFailure(Throwable exception) { callback.onFailure(exception); } }); }
ProjectNode extends AbstractTreeNode<ProjectDescriptor> implements StorableNode<ProjectDescriptor>, Openable,
                                                                                ProjectDescriptorChangedHandler { @Override public void delete(final DeleteCallback callback) { projectServiceClient.delete(getPath(), new AsyncRequestCallback<Void>() { @Override protected void onSuccess(Void result) { if (isRootProject()) { eventBus.fireEvent(new CloseCurrentProjectEvent()); } ProjectNode.super.delete(new DeleteCallback() { @Override public void onDeleted() { callback.onDeleted(); } @Override public void onFailure(Throwable caught) { callback.onFailure(caught); } }); } @Override protected void onFailure(Throwable exception) { callback.onFailure(exception); } }); } }
ProjectNode extends AbstractTreeNode<ProjectDescriptor> implements StorableNode<ProjectDescriptor>, Openable,
                                                                                ProjectDescriptorChangedHandler { @Override public void delete(final DeleteCallback callback) { projectServiceClient.delete(getPath(), new AsyncRequestCallback<Void>() { @Override protected void onSuccess(Void result) { if (isRootProject()) { eventBus.fireEvent(new CloseCurrentProjectEvent()); } ProjectNode.super.delete(new DeleteCallback() { @Override public void onDeleted() { callback.onDeleted(); } @Override public void onFailure(Throwable caught) { callback.onFailure(caught); } }); } @Override protected void onFailure(Throwable exception) { callback.onFailure(exception); } }); } @Inject  ProjectNode(@Assisted TreeNode<?> parent,
                       @Assisted ProjectDescriptor data,
                       @Assisted GenericTreeStructure treeStructure,
                       EventBus eventBus,
                       ProjectServiceClient projectServiceClient,
                       DtoUnmarshallerFactory dtoUnmarshallerFactory); }
ProjectNode extends AbstractTreeNode<ProjectDescriptor> implements StorableNode<ProjectDescriptor>, Openable,
                                                                                ProjectDescriptorChangedHandler { @Override public void delete(final DeleteCallback callback) { projectServiceClient.delete(getPath(), new AsyncRequestCallback<Void>() { @Override protected void onSuccess(Void result) { if (isRootProject()) { eventBus.fireEvent(new CloseCurrentProjectEvent()); } ProjectNode.super.delete(new DeleteCallback() { @Override public void onDeleted() { callback.onDeleted(); } @Override public void onFailure(Throwable caught) { callback.onFailure(caught); } }); } @Override protected void onFailure(Throwable exception) { callback.onFailure(exception); } }); } @Inject  ProjectNode(@Assisted TreeNode<?> parent,
                       @Assisted ProjectDescriptor data,
                       @Assisted GenericTreeStructure treeStructure,
                       EventBus eventBus,
                       ProjectServiceClient projectServiceClient,
                       DtoUnmarshallerFactory dtoUnmarshallerFactory); @Override String getName(); @Override String getPath(); @Override boolean canContainsFolder(); @Nonnull @Override String getId(); @Nonnull @Override ProjectNode getProject(); @Nonnull @Override String getDisplayName(); @Nonnull GenericTreeStructure getTreeStructure(); @Override boolean isLeaf(); @Override void refreshChildren(final AsyncCallback<TreeNode<?>> callback); @Override boolean isRenamable(); @Override void rename(String newName, RenameCallback callback); @Override boolean isDeletable(); @Override void delete(final DeleteCallback callback); String getProjectTypeId(); @Nullable String getAttributeValue(String attributeName); @Nullable List<String> getAttributeValues(String attributeName); @Override void close(); @Override boolean isOpened(); @Override void open(); @Override void onProjectDescriptorChanged(ProjectDescriptorChangedEvent event); }
ProjectNode extends AbstractTreeNode<ProjectDescriptor> implements StorableNode<ProjectDescriptor>, Openable,
                                                                                ProjectDescriptorChangedHandler { @Override public void delete(final DeleteCallback callback) { projectServiceClient.delete(getPath(), new AsyncRequestCallback<Void>() { @Override protected void onSuccess(Void result) { if (isRootProject()) { eventBus.fireEvent(new CloseCurrentProjectEvent()); } ProjectNode.super.delete(new DeleteCallback() { @Override public void onDeleted() { callback.onDeleted(); } @Override public void onFailure(Throwable caught) { callback.onFailure(caught); } }); } @Override protected void onFailure(Throwable exception) { callback.onFailure(exception); } }); } @Inject  ProjectNode(@Assisted TreeNode<?> parent,
                       @Assisted ProjectDescriptor data,
                       @Assisted GenericTreeStructure treeStructure,
                       EventBus eventBus,
                       ProjectServiceClient projectServiceClient,
                       DtoUnmarshallerFactory dtoUnmarshallerFactory); @Override String getName(); @Override String getPath(); @Override boolean canContainsFolder(); @Nonnull @Override String getId(); @Nonnull @Override ProjectNode getProject(); @Nonnull @Override String getDisplayName(); @Nonnull GenericTreeStructure getTreeStructure(); @Override boolean isLeaf(); @Override void refreshChildren(final AsyncCallback<TreeNode<?>> callback); @Override boolean isRenamable(); @Override void rename(String newName, RenameCallback callback); @Override boolean isDeletable(); @Override void delete(final DeleteCallback callback); String getProjectTypeId(); @Nullable String getAttributeValue(String attributeName); @Nullable List<String> getAttributeValues(String attributeName); @Override void close(); @Override boolean isOpened(); @Override void open(); @Override void onProjectDescriptorChanged(ProjectDescriptorChangedEvent event);  }