### Question:
SqlWorkspaceRepository extends WorkspaceRepository { @Override public Workspace add(String workspaceId, String title, User user) { Session session = sessionManager.getSession(); Transaction transaction = null; SqlWorkspace newWorkspace; try { transaction = session.beginTransaction(); newWorkspace = new SqlWorkspace(); newWorkspace.setDisplayTitle(title); if (user instanceof ProxyUser) { user = userRepository.findById(user.getUserId()); } newWorkspace.setWorkspaceCreator((SqlUser) user); newWorkspace.setWorkspaceId(workspaceId); SqlWorkspaceUser sqlWorkspaceUser = new SqlWorkspaceUser(); sqlWorkspaceUser.setWorkspaceAccess(WorkspaceAccess.WRITE); sqlWorkspaceUser.setUser((SqlUser) user); sqlWorkspaceUser.setWorkspace(newWorkspace); LOGGER.debug("add %s to workspace table", title); newWorkspace.getSqlWorkspaceUserList().add(sqlWorkspaceUser); session.save(newWorkspace); session.save(sqlWorkspaceUser); session.update(user); transaction.commit(); } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new RuntimeException(e); } return newWorkspace; } @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 testAdd() throws Exception { SqlWorkspace workspace = (SqlWorkspace) sqlWorkspaceRepository.add("test workspace", testUser); assertEquals(testUser.getUserId(), workspace.getWorkspaceCreator().getUserId()); assertEquals("test workspace", workspace.getDisplayTitle()); assertEquals(1, workspace.getSqlWorkspaceUserList().size()); SqlWorkspaceUser sqlWorkspaceUser = workspace.getSqlWorkspaceUserList().iterator().next(); assertEquals(WorkspaceAccess.WRITE.toString(), sqlWorkspaceUser.getWorkspaceAccess()); assertEquals(workspace.getWorkspaceId(), sqlWorkspaceUser.getWorkspace().getWorkspaceId()); }