### Question:
SqlWorkspaceRepository extends WorkspaceRepository { @Override public void delete(Workspace workspace, User user) { if (!hasWritePermissions(workspace.getWorkspaceId(), user)) { throw new LumifyAccessDeniedException("user " + user.getUserId() + " does not have write access to workspace " + workspace.getWorkspaceId(), user, workspace.getWorkspaceId()); } Session session = sessionManager.getSession(); Transaction transaction = null; try { transaction = session.beginTransaction(); String nullCurrentWorkspacesSql = "update " + SqlUser.class.getSimpleName() + " set current_workspace_id = null where current_workspace_id = :workspaceId"; Query query = session.createQuery(nullCurrentWorkspacesSql).setString("workspaceId", workspace.getWorkspaceId()); session.delete(workspace); query.executeUpdate(); transaction.commit(); } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new RuntimeException(e); } } @Inject  SqlWorkspaceRepository(final SqlUserRepository userRepository, final HibernateSessionManager sessionManager,
                                  final Graph graph); @Override void delete(Workspace workspace, User user); @Override Workspace findById(String workspaceId, boolean includeHidden, User user); @Override Workspace add(String workspaceId, String title, User user); @Override Iterable<Workspace> findAllForUser(User user); @Override void setTitle(Workspace workspace, String title, User user); @Override List<WorkspaceUser> findUsersWithAccess(String workspaceId, User user); @Override List<WorkspaceEntity> findEntities(Workspace workspace, User user); @Override void softDeleteEntitiesFromWorkspace(Workspace workspace, List<String> entityIdsToDelete, User authUser); @Override void updateEntitiesOnWorkspace(Workspace workspace, Iterable<Update> updates, User user); @Override void deleteUserFromWorkspace(Workspace workspace, String userId, User user); @Override void updateUserOnWorkspace(Workspace workspace, String userId, WorkspaceAccess workspaceAccess, User user); @Override ClientApiWorkspaceDiff getDiff(Workspace workspace, User user, Locale locale, String timeZone); @Override boolean hasCommentPermissions(String workspaceId, User user); @Override boolean hasWritePermissions(String workspaceId, User user); @Override boolean hasReadPermissions(String workspaceId, User user);  }### Answer:
@Test public void testDelete() throws Exception { SqlWorkspace workspace = (SqlWorkspace) sqlWorkspaceRepository.add("test workspace 1", testUser); sqlWorkspaceRepository.delete(workspace, testUser); assertNull(sqlWorkspaceRepository.findById("1", testUser)); }