Functions { public static List<OpenId> listMyOpenIds() throws IOException { String loginName = SecurityContextHolder.getContext().getAuthentication().getName(); List<OpenId> openIds = Lists.newArrayList(userStore.getUser(loginName).getOpenIds()); Collections.sort(openIds, new Comparator<OpenId>() { @Override public int compare(OpenId id1, OpenId id2) { return id1.getDelegateId().compareToIgnoreCase(id2.getDelegateId()); } }); return openIds; }  @PostConstruct void init(); static List<String> listProjects(); static List<String> listProjectBranches(String projectName); static List<String> listPageAttachments(String projectName, String branchName, String path); static String getPageTitle(String projectName, String branchName, String path); static List<String> getBranchesPageIsSharedWith(String projectName, String branchName, String path); static List<String> listUsers(); static String getPageHtml(String projectName, String branchName, String path); static String getPageHeaderHtml(String projectName, String branchName, String path); static List<String> getPagePathHierarchy(String projectName, String branchName, String pagePath); static PageMetadata getPageMetadata(String projectName, String branchName, String path); static PageMetadata getAttachmentMetadata(String projectName, String branchName, String pagePath,
			String name); static List<String> listRoles(); static List<RoleGrantedAuthority> getUserAuthorities(String loginName); static String formatSize(long size); static List<PageVersion> listPageVersions(String projectName, String branchName, String path); static List<OpenId> listMyOpenIds(); static List<JspMacroDescriptor> getMacros(); static int floor(double d); static String getLanguage(); static String escapeJavaScript(String s); static boolean pageExists(String projectName, String branchName, String path); static boolean isSubscribed(String projectName, String branchName, String path); static String getSystemSetting(String key); static String getLatestVersionForUpdate(); static List<String> getGroovyMacros(); static String substringBeforeLast(String s, String separator);  }
@Test public void listMyOpenIds() throws IOException { when(authentication.getName()).thenReturn("user"); User user = new User("user", "p", "email", true); Set<OpenId> openIds = Sets.newHashSet(); openIds.add(new OpenId("openId1", "realOpenId1")); openIds.add(new OpenId("openId2", "realOpenId2")); for (OpenId openId : openIds) { user.addOpenId(openId); } when(userStore.getUser("user")).thenReturn(user); List<OpenId> result = Functions.listMyOpenIds(); assertEquals(openIds, Sets.newHashSet(result)); }