@Override
    public Workspace duplicateWorkspace(Workspace workspace) {
        synchronized (this) {
            DuplicateTask duplicateTask = new DuplicateTask(workspace);
            Future<WorkspaceImpl> res = longTaskExecutor.execute(duplicateTask, () -> {
                WorkspaceImpl newWorkspace = duplicateTask.run();
                // Null if cancelled
                if (newWorkspace != null) {
                    newWorkspace.getLookup().lookup(WorkspaceInformationImpl.class).setName(
                        NbBundle.getMessage(ProjectControllerImpl.class, "Workspace.duplicated.name",
                            workspace.getName()));
                    fireWorkspaceEvent(EventType.INITIALIZE, newWorkspace);

                    openWorkspace(newWorkspace);
                }
                return newWorkspace;
            }, "", t -> handleException(workspace.getProject(), t));
            try {
                return res.get();
            } catch (InterruptedException | ExecutionException e) {
                throw new RuntimeException(e);
            }
        }
    }
@Test
    public void testDuplicateWorkspace() {
        MockServices.setServices(MockController.class);

        ProjectControllerImpl pc = new ProjectControllerImpl();
        pc.addWorkspaceListener(workspaceListener);
        pc.newProject();
        Workspace duplicate = pc.duplicateWorkspace(pc.getCurrentWorkspace());
        Assert.assertNotNull(duplicate);
        Assert.assertTrue(duplicate.isOpen());
        Assert.assertSame(duplicate, pc.getCurrentWorkspace());
        Assert.assertEquals(2, pc.getCurrentProject().getWorkspaces().size());
        Mockito.verify(workspaceListener).initialize(duplicate);
        Mockito.verify(workspaceListener).select(duplicate);
        Assert.assertNotNull(duplicate.getLookup().lookup(MockModel.class));
    }