@Test @PrepareForTest(User.class) public void testIsAuthorFalse() throws Exception { mockStatic(User.class); User user = createMock(User.class); expect(user.getId()).andReturn(USER); expect(User.current()).andReturn(user); Job job = createMock(FreeStyleProject.class); expect(job.getCreatedBy()).andReturn("user").times(2); replay(User.class, user, job); boolean result = Functions.isAuthor(job); verify(User.class, user, job); assertFalse(result); }
public static boolean isAuthor(Job job) { User user = User.current(); return !(user == null || job == null || job.getCreatedBy() == null) && job.getCreatedBy().equals(user.getId()); }
Functions { public static boolean isAuthor(Job job) { User user = User.current(); return !(user == null || job == null || job.getCreatedBy() == null) && job.getCreatedBy().equals(user.getId()); } }
Functions { public static boolean isAuthor(Job job) { User user = User.current(); return !(user == null || job == null || job.getCreatedBy() == null) && job.getCreatedBy().equals(user.getId()); } Functions(); }
Functions { public static boolean isAuthor(Job job) { User user = User.current(); return !(user == null || job == null || job.getCreatedBy() == null) && job.getCreatedBy().equals(user.getId()); } Functions(); String generateId(); static boolean isModel(Object o); static String xsDate(Calendar cal); static String rfc822Date(Calendar cal); static Class getTypeParameter(Class<? extends B> c, Class<B> base, int n); JDK.DescriptorImpl getJDKDescriptor(); static String getDiffString(int i); static String getDiffString2(int i); static String getDiffString2(String prefix, int i, String suffix); static String addSuffix(int n, String singular, String plural); static RunUrl decompose(StaplerRequest req); static Area getScreenResolution(); static Node.Mode[] getNodeModes(); static String getProjectListString(List<Project> projects); static Object ifThenElse(boolean cond, Object thenValue, Object elseValue); static String appendIfNotNull(String text, String suffix, String nullText); static Map getSystemProperties(); static Map getEnvVars(); static boolean isWindows(); static List<LogRecord> getLogRecords(); static String printLogRecord(LogRecord r); static Cookie getCookie(HttpServletRequest req,String name); static String getCookie(HttpServletRequest req,String name, String defaultValue); static String getYuiSuffix(); static SortedMap<Integer,V> filter(SortedMap<Integer,V> map, String from, String to); static void configureAutoRefresh(HttpServletRequest request, HttpServletResponse response, boolean noAutoRefresh); static boolean isAutoRefresh(HttpServletRequest request); static String getNearestAncestorUrl(StaplerRequest req,Object it); static String getSearchURL(); static String appendSpaceIfNotNull(String n); static String nbspIndent(String size); static String getWin32ErrorMessage(IOException e); static boolean isMultiline(String s); static String encode(String s); static String escape(String s); static String xmlEscape(String s); static String xmlUnescape(String s); static void checkPermission(Permission permission); static void checkPermission(AccessControlled object, Permission permission); static void checkPermission(Object object, Permission permission); static boolean hasPermission(Permission permission); static boolean hasPermission(Object object, Permission permission); static void adminCheck(StaplerRequest req, StaplerResponse rsp, Object required, Permission permission); static String inferHudsonURL(StaplerRequest req); static List<JobPropertyDescriptor> getJobPropertyDescriptors(Class<? extends Job> clazz); static List<Descriptor<BuildWrapper>> getBuildWrapperDescriptors(AbstractProject<?,?> project); static List<Descriptor<SecurityRealm>> getSecurityRealmDescriptors(); static List<Descriptor<AuthorizationStrategy>> getAuthorizationStrategyDescriptors(); static List<Descriptor<Builder>> getBuilderDescriptors(AbstractProject<?,?> project); static List<Descriptor<Publisher>> getPublisherDescriptors(AbstractProject<?,?> project); static List<SCMDescriptor<?>> getSCMDescriptors(AbstractProject<?,?> project); static List<Descriptor<ComputerLauncher>> getComputerLauncherDescriptors(); static List<Descriptor<RetentionStrategy<?>>> getRetentionStrategyDescriptors(); static List<ParameterDescriptor> getParameterDescriptors(); static List<Descriptor<ViewsTabBar>> getViewsTabBarDescriptors(); static List<Descriptor<MyViewsTabBar>> getMyViewsTabBarDescriptors(); static List<NodePropertyDescriptor> getNodePropertyDescriptors(Class<? extends Node> clazz); static Set<String> getGlobalConfigIgnoredDescriptors(); static Collection<Descriptor> getSortedDescriptorsForGlobalConfig(); static String getIconFilePath(Action a); static int size2(Object o); static String getRelativeLinkTo(Item p); static Map<Thread,StackTraceElement[]> dumpAllThreads(); @IgnoreJRERequirement static ThreadInfo[] getThreadInfos(); static ThreadGroupMap sortThreadsAndGetGroupMap(ThreadInfo[] list); @IgnoreJRERequirement static boolean isMustangOrAbove(); @IgnoreJRERequirement static String dumpThreadInfo(ThreadInfo ti, ThreadGroupMap map); static Collection<T> emptyList(); static String jsStringEscape(String s); static String capitalize(String s); static String getVersion(); static String getResourcePath(); static String getViewResource(Object it, String path); static boolean hasView(Object it, String path); static boolean defaultToTrue(Boolean b); static T defaulted(T value, T defaultValue); static String printThrowable(Throwable t); static int determineRows(String s); static String toCCStatus(Item i); static boolean isAnonymous(); static JellyContext getCurrentJellyContext(); static String runScript(Script script); static List<T> subList(List<T> base, int maxSize); static String getActionUrl(String itUrl,Action action); static String toEmailSafeString(String projectName); String getSystemProperty(String key); String getServerName(); String getCheckUrl(String userDefined, Object descriptor, String field); boolean hyperlinkMatchesCurrentPage(String href); List<T> singletonList(T t); static List<PageDecorator> getPageDecorators(); static List<Descriptor<Cloud>> getCloudDescriptors(); String prepend(String prefix, String body); static List<Descriptor<CrumbIssuer>> getCrumbIssuerDescriptors(); static String getCrumb(StaplerRequest req); static String getCrumbRequestField(); static Date getCurrentTime(); static Locale getClientLocale(); static Locale getServerLocale(); static String generateConsoleAnnotationScriptAndStylesheet(); List<String> getLoggerNames(); String getPasswordValue(Object o); List filterDescriptors(Object context, Iterable descriptors); static boolean getIsUnitTest(); static boolean isArtifactsPermissionEnabled(); static boolean isAuthor(Job job); static Object resolveStaplerObject(final Object obj); static boolean isWipeOutPermissionEnabled(); static T getItemByName(List<T> items, final String name); static Object rawHtml(Object o); }
Functions { public static boolean isAuthor(Job job) { User user = User.current(); return !(user == null || job == null || job.getCreatedBy() == null) && job.getCreatedBy().equals(user.getId()); } Functions(); String generateId(); static boolean isModel(Object o); static String xsDate(Calendar cal); static String rfc822Date(Calendar cal); static Class getTypeParameter(Class<? extends B> c, Class<B> base, int n); JDK.DescriptorImpl getJDKDescriptor(); static String getDiffString(int i); static String getDiffString2(int i); static String getDiffString2(String prefix, int i, String suffix); static String addSuffix(int n, String singular, String plural); static RunUrl decompose(StaplerRequest req); static Area getScreenResolution(); static Node.Mode[] getNodeModes(); static String getProjectListString(List<Project> projects); static Object ifThenElse(boolean cond, Object thenValue, Object elseValue); static String appendIfNotNull(String text, String suffix, String nullText); static Map getSystemProperties(); static Map getEnvVars(); static boolean isWindows(); static List<LogRecord> getLogRecords(); static String printLogRecord(LogRecord r); static Cookie getCookie(HttpServletRequest req,String name); static String getCookie(HttpServletRequest req,String name, String defaultValue); static String getYuiSuffix(); static SortedMap<Integer,V> filter(SortedMap<Integer,V> map, String from, String to); static void configureAutoRefresh(HttpServletRequest request, HttpServletResponse response, boolean noAutoRefresh); static boolean isAutoRefresh(HttpServletRequest request); static String getNearestAncestorUrl(StaplerRequest req,Object it); static String getSearchURL(); static String appendSpaceIfNotNull(String n); static String nbspIndent(String size); static String getWin32ErrorMessage(IOException e); static boolean isMultiline(String s); static String encode(String s); static String escape(String s); static String xmlEscape(String s); static String xmlUnescape(String s); static void checkPermission(Permission permission); static void checkPermission(AccessControlled object, Permission permission); static void checkPermission(Object object, Permission permission); static boolean hasPermission(Permission permission); static boolean hasPermission(Object object, Permission permission); static void adminCheck(StaplerRequest req, StaplerResponse rsp, Object required, Permission permission); static String inferHudsonURL(StaplerRequest req); static List<JobPropertyDescriptor> getJobPropertyDescriptors(Class<? extends Job> clazz); static List<Descriptor<BuildWrapper>> getBuildWrapperDescriptors(AbstractProject<?,?> project); static List<Descriptor<SecurityRealm>> getSecurityRealmDescriptors(); static List<Descriptor<AuthorizationStrategy>> getAuthorizationStrategyDescriptors(); static List<Descriptor<Builder>> getBuilderDescriptors(AbstractProject<?,?> project); static List<Descriptor<Publisher>> getPublisherDescriptors(AbstractProject<?,?> project); static List<SCMDescriptor<?>> getSCMDescriptors(AbstractProject<?,?> project); static List<Descriptor<ComputerLauncher>> getComputerLauncherDescriptors(); static List<Descriptor<RetentionStrategy<?>>> getRetentionStrategyDescriptors(); static List<ParameterDescriptor> getParameterDescriptors(); static List<Descriptor<ViewsTabBar>> getViewsTabBarDescriptors(); static List<Descriptor<MyViewsTabBar>> getMyViewsTabBarDescriptors(); static List<NodePropertyDescriptor> getNodePropertyDescriptors(Class<? extends Node> clazz); static Set<String> getGlobalConfigIgnoredDescriptors(); static Collection<Descriptor> getSortedDescriptorsForGlobalConfig(); static String getIconFilePath(Action a); static int size2(Object o); static String getRelativeLinkTo(Item p); static Map<Thread,StackTraceElement[]> dumpAllThreads(); @IgnoreJRERequirement static ThreadInfo[] getThreadInfos(); static ThreadGroupMap sortThreadsAndGetGroupMap(ThreadInfo[] list); @IgnoreJRERequirement static boolean isMustangOrAbove(); @IgnoreJRERequirement static String dumpThreadInfo(ThreadInfo ti, ThreadGroupMap map); static Collection<T> emptyList(); static String jsStringEscape(String s); static String capitalize(String s); static String getVersion(); static String getResourcePath(); static String getViewResource(Object it, String path); static boolean hasView(Object it, String path); static boolean defaultToTrue(Boolean b); static T defaulted(T value, T defaultValue); static String printThrowable(Throwable t); static int determineRows(String s); static String toCCStatus(Item i); static boolean isAnonymous(); static JellyContext getCurrentJellyContext(); static String runScript(Script script); static List<T> subList(List<T> base, int maxSize); static String getActionUrl(String itUrl,Action action); static String toEmailSafeString(String projectName); String getSystemProperty(String key); String getServerName(); String getCheckUrl(String userDefined, Object descriptor, String field); boolean hyperlinkMatchesCurrentPage(String href); List<T> singletonList(T t); static List<PageDecorator> getPageDecorators(); static List<Descriptor<Cloud>> getCloudDescriptors(); String prepend(String prefix, String body); static List<Descriptor<CrumbIssuer>> getCrumbIssuerDescriptors(); static String getCrumb(StaplerRequest req); static String getCrumbRequestField(); static Date getCurrentTime(); static Locale getClientLocale(); static Locale getServerLocale(); static String generateConsoleAnnotationScriptAndStylesheet(); List<String> getLoggerNames(); String getPasswordValue(Object o); List filterDescriptors(Object context, Iterable descriptors); static boolean getIsUnitTest(); static boolean isArtifactsPermissionEnabled(); static boolean isAuthor(Job job); static Object resolveStaplerObject(final Object obj); static boolean isWipeOutPermissionEnabled(); static T getItemByName(List<T> items, final String name); static Object rawHtml(Object o); static boolean DEBUG_YUI; }