<commit_before>package ut.com.cobalt.jira.plugin.epic.rest;

import com.atlassian.crowd.embedded.api.User;
import com.atlassian.event.api.EventPublisher;
import com.atlassian.jira.MockEventPublisher;
import com.atlassian.jira.avatar.Avatar;
import com.atlassian.jira.avatar.AvatarService;
import com.atlassian.jira.bc.issue.search.SearchService;
import com.atlassian.jira.bc.project.ProjectService;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.mock.component.MockComponentWorker;
import com.atlassian.jira.user.*;
import com.atlassian.jira.user.util.MockUserManager;
import com.atlassian.jira.user.util.UserUtil;
import com.atlassian.sal.api.user.UserManager;
import com.atlassian.sal.api.user.UserProfile;
import com.cobalt.jira.plugin.epic.data.*;
import com.cobalt.jira.plugin.epic.rest.RestResource;
import com.cobalt.jira.plugin.epic.rest.jaxb.*;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.Before;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;

import static org.mockito.Mockito.*;
import static org.junit.Assert.*;


public class RestResourceTest
{
    private static final String USERNAME = "USERNAME";

    private static final String USER_KEY = "testkey";
    private static final String USER_DISPLAY_NAME = "User, Test";
    private static final String USER_EMAIL = "<EMAIL>";
    private static final String USER_AVATAR_PATH = "MockAvatarURI";

	private SearchService searchService;
	private UserManager userManager;
	private com.atlassian.jira.user.util.UserManager jiraUserManager;
	private EventPublisher eventPublisher;
    private UserUtil userUtil;
    private ProjectService projectService;
    private AvatarService avatarService;

    private int count = 0;

    private List<IJiraData> projects;

    private MockUser mockUser;

    private class MockJiraData extends JiraData {
        private DataType type;

        public MockJiraData(DataType type) {
            this.type = type;
        }

        public DataType getType() {
            return type;
        }

        public String getName() {
            return null;
        }

        public String getDescription() {
            return null;
        }

        public long getId() {
            return 0;
        }

        public String getKey() {
            return null;
        }

        public boolean completed() {
            return true;
        }

        public User getAssignee() {
            return null;
        }

        public IJiraData getProject() {
            return null;
        }

        public IJiraData getEpic() {
            return null;
        }

        public IJiraData getStory() {
            return null;
        }
    }


    @Before
    public void setup() {
		searchService = mock(SearchService.class);
		userManager = mock(UserManager.class);
        userUtil = mock(UserUtil.class);

        eventPublisher = new MockEventPublisher() {
            public void register(Object o) {
                super.register(o);
                count++;
            }

            public void unregister(Object o) {
                super.unregister(o);
                count++;
            }
        };

        jiraUserManager = spy(new MockUserManager());
        projectService = mock(ProjectService.class);
        avatarService = mock(AvatarService.class);

        URI mockUri = URI.create(USER_AVATAR_PATH);

        when(avatarService.getAvatarUrlNoPermCheck(any(ApplicationUser.class), eq(Avatar.Size.NORMAL))).thenReturn(mockUri);

        UserKeyService mockUserKeyService = mock(UserKeyService.class);

        MockComponentWorker worker = new MockComponentWorker();
        worker.addMock(UserKeyService.class, mockUserKeyService);
        worker.addMock(com.atlassian.jira.user.util.UserManager.class, jiraUserManager);
        worker.init();

        mockUser = new MockUser(USERNAME, USER_DISPLAY_NAME, USER_EMAIL);
        MockApplicationUser mockApplicationUser = new MockApplicationUser(USER_KEY, USERNAME, USER_DISPLAY_NAME, USER_EMAIL);

        when(mockUserKeyService.getKeyForUser(any(User.class))).thenReturn(USER_KEY);
        when(jiraUserManager.getUserByKey(anyString())).thenReturn(mockApplicationUser);

        IJiraData subtask = new MockJiraData(IJiraData.DataType.SUBTASK) {
            public User getAssignee() {
                return mockUser;
            }
        };
        IJiraData story = new MockJiraData(IJiraData.DataType.STORY);
        IJiraData epic = new MockJiraData(IJiraData.DataType.EPIC);<commit_msg>Fixed the unit test for the new avatar size<commit_after>package ut.com.cobalt.jira.plugin.epic.rest;

import com.atlassian.crowd.embedded.api.User;
import com.atlassian.event.api.EventPublisher;
import com.atlassian.jira.MockEventPublisher;
import com.atlassian.jira.avatar.Avatar;
import com.atlassian.jira.avatar.AvatarService;
import com.atlassian.jira.bc.issue.search.SearchService;
import com.atlassian.jira.bc.project.ProjectService;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.mock.component.MockComponentWorker;
import com.atlassian.jira.user.*;
import com.atlassian.jira.user.util.MockUserManager;
import com.atlassian.jira.user.util.UserUtil;
import com.atlassian.sal.api.user.UserManager;
import com.atlassian.sal.api.user.UserProfile;
import com.cobalt.jira.plugin.epic.data.*;
import com.cobalt.jira.plugin.epic.rest.RestResource;
import com.cobalt.jira.plugin.epic.rest.jaxb.*;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.Before;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;

import static org.mockito.Mockito.*;
import static org.junit.Assert.*;


public class RestResourceTest
{
    private static final String USERNAME = "USERNAME";

    private static final String USER_KEY = "testkey";
    private static final String USER_DISPLAY_NAME = "User, Test";
    private static final String USER_EMAIL = "<EMAIL>";
    private static final String USER_AVATAR_PATH = "MockAvatarURI";

	private SearchService searchService;
	private UserManager userManager;
	private com.atlassian.jira.user.util.UserManager jiraUserManager;
	private EventPublisher eventPublisher;
    private UserUtil userUtil;
    private ProjectService projectService;
    private AvatarService avatarService;

    private int count = 0;

    private List<IJiraData> projects;

    private MockUser mockUser;

    private class MockJiraData extends JiraData {
        private DataType type;

        public MockJiraData(DataType type) {
            this.type = type;
        }

        public DataType getType() {
            return type;
        }

        public String getName() {
            return null;
        }

        public String getDescription() {
            return null;
        }

        public long getId() {
            return 0;
        }

        public String getKey() {
            return null;
        }

        public boolean completed() {
            return true;
        }

        public User getAssignee() {
            return null;
        }

        public IJiraData getProject() {
            return null;
        }

        public IJiraData getEpic() {
            return null;
        }

        public IJiraData getStory() {
            return null;
        }
    }


    @Before
    public void setup() {
		searchService = mock(SearchService.class);
		userManager = mock(UserManager.class);
        userUtil = mock(UserUtil.class);

        eventPublisher = new MockEventPublisher() {
            public void register(Object o) {
                super.register(o);
                count++;
            }

            public void unregister(Object o) {
                super.unregister(o);
                count++;
            }
        };

        jiraUserManager = spy(new MockUserManager());
        projectService = mock(ProjectService.class);
        avatarService = mock(AvatarService.class);

        URI mockUri = URI.create(USER_AVATAR_PATH);

        when(avatarService.getAvatarUrlNoPermCheck(any(ApplicationUser.class), eq(Avatar.Size.LARGE))).thenReturn(mockUri);

        UserKeyService mockUserKeyService = mock(UserKeyService.class);

        MockComponentWorker worker = new MockComponentWorker();
        worker.addMock(UserKeyService.class, mockUserKeyService);
        worker.addMock(com.atlassian.jira.user.util.UserManager.class, jiraUserManager);
        worker.init();

        mockUser = new MockUser(USERNAME, USER_DISPLAY_NAME, USER_EMAIL);
        MockApplicationUser mockApplicationUser = new MockApplicationUser(USER_KEY, USERNAME, USER_DISPLAY_NAME, USER_EMAIL);

        when(mockUserKeyService.getKeyForUser(any(User.class))).thenReturn(USER_KEY);
        when(jiraUserManager.getUserByKey(anyString())).thenReturn(mockApplicationUser);

        IJiraData subtask = new MockJiraData(IJiraData.DataType.SUBTASK) {
            public User getAssignee() {
                return mockUser;
            }
        };
        IJiraData story = new MockJiraData(IJiraData.DataType.STORY);
        IJiraData epic = new MockJiraData(IJiraData.DataType.EPIC);
{'fraction_non_alphanumeric': 0.09169493380019696, 'fraction_numerical': 0.000437684648210964, 'mean_word_length': 2.778420835055808, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3317565', 'n_tokens_mistral': 2748, 'n_tokens_neox': 2621, 'n_words': 531}