@Test public void getMacros() { when(descriptor1.getTitle(LOCALE)).thenReturn("title1"); when(descriptor1.getDescription(LOCALE)).thenReturn("description1"); when(descriptor1.getInsertText()).thenReturn("insertText1"); when(descriptor2.getTitle(LOCALE)).thenReturn("title2"); when(descriptor2.getDescription(LOCALE)).thenReturn("description2"); when(descriptor2.getInsertText()).thenReturn("insertText2"); Set<IMacroDescriptor> descs = Sets.newHashSet(descriptor1, descriptor2); when(macroFactory.getDescriptors()).thenReturn(descs); List<JspMacroDescriptor> result = Functions.getMacros(); assertEquals(2, result.size()); assertEquals(descriptor1.getTitle(LOCALE), result.get(0).getTitle()); assertEquals(descriptor1.getDescription(LOCALE), result.get(0).getDescription()); assertEquals(descriptor1.getInsertText(), result.get(0).getInsertText()); assertEquals(descriptor2.getTitle(LOCALE), result.get(1).getTitle()); assertEquals(descriptor2.getDescription(LOCALE), result.get(1).getDescription()); assertEquals(descriptor2.getInsertText(), result.get(1).getInsertText()); }
public static List<JspMacroDescriptor> getMacros() { List<IMacroDescriptor> descs = Lists.newArrayList(macroFactory.getDescriptors()); final Locale locale = LocaleContextHolder.getLocale(); final Collator collator = Collator.getInstance(locale); Collections.sort(descs, new Comparator<IMacroDescriptor>() { @Override public int compare(IMacroDescriptor d1, IMacroDescriptor d2) { String title1 = d1.getTitle(locale); String title2 = d2.getTitle(locale); return collator.compare(title1, title2); } }); Function<IMacroDescriptor, JspMacroDescriptor> function = new Function<IMacroDescriptor, JspMacroDescriptor>() { @Override public JspMacroDescriptor apply(IMacroDescriptor descriptor) { return new JspMacroDescriptor(descriptor, locale); } }; return Lists.transform(descs, function); }
Functions { public static List<JspMacroDescriptor> getMacros() { List<IMacroDescriptor> descs = Lists.newArrayList(macroFactory.getDescriptors()); final Locale locale = LocaleContextHolder.getLocale(); final Collator collator = Collator.getInstance(locale); Collections.sort(descs, new Comparator<IMacroDescriptor>() { @Override public int compare(IMacroDescriptor d1, IMacroDescriptor d2) { String title1 = d1.getTitle(locale); String title2 = d2.getTitle(locale); return collator.compare(title1, title2); } }); Function<IMacroDescriptor, JspMacroDescriptor> function = new Function<IMacroDescriptor, JspMacroDescriptor>() { @Override public JspMacroDescriptor apply(IMacroDescriptor descriptor) { return new JspMacroDescriptor(descriptor, locale); } }; return Lists.transform(descs, function); } }
Functions { public static List<JspMacroDescriptor> getMacros() { List<IMacroDescriptor> descs = Lists.newArrayList(macroFactory.getDescriptors()); final Locale locale = LocaleContextHolder.getLocale(); final Collator collator = Collator.getInstance(locale); Collections.sort(descs, new Comparator<IMacroDescriptor>() { @Override public int compare(IMacroDescriptor d1, IMacroDescriptor d2) { String title1 = d1.getTitle(locale); String title2 = d2.getTitle(locale); return collator.compare(title1, title2); } }); Function<IMacroDescriptor, JspMacroDescriptor> function = new Function<IMacroDescriptor, JspMacroDescriptor>() { @Override public JspMacroDescriptor apply(IMacroDescriptor descriptor) { return new JspMacroDescriptor(descriptor, locale); } }; return Lists.transform(descs, function); }  }
Functions { public static List<JspMacroDescriptor> getMacros() { List<IMacroDescriptor> descs = Lists.newArrayList(macroFactory.getDescriptors()); final Locale locale = LocaleContextHolder.getLocale(); final Collator collator = Collator.getInstance(locale); Collections.sort(descs, new Comparator<IMacroDescriptor>() { @Override public int compare(IMacroDescriptor d1, IMacroDescriptor d2) { String title1 = d1.getTitle(locale); String title2 = d2.getTitle(locale); return collator.compare(title1, title2); } }); Function<IMacroDescriptor, JspMacroDescriptor> function = new Function<IMacroDescriptor, JspMacroDescriptor>() { @Override public JspMacroDescriptor apply(IMacroDescriptor descriptor) { return new JspMacroDescriptor(descriptor, locale); } }; return Lists.transform(descs, function); }  @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); }
Functions { public static List<JspMacroDescriptor> getMacros() { List<IMacroDescriptor> descs = Lists.newArrayList(macroFactory.getDescriptors()); final Locale locale = LocaleContextHolder.getLocale(); final Collator collator = Collator.getInstance(locale); Collections.sort(descs, new Comparator<IMacroDescriptor>() { @Override public int compare(IMacroDescriptor d1, IMacroDescriptor d2) { String title1 = d1.getTitle(locale); String title2 = d2.getTitle(locale); return collator.compare(title1, title2); } }); Function<IMacroDescriptor, JspMacroDescriptor> function = new Function<IMacroDescriptor, JspMacroDescriptor>() { @Override public JspMacroDescriptor apply(IMacroDescriptor descriptor) { return new JspMacroDescriptor(descriptor, locale); } }; return Lists.transform(descs, function); }  @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);  }