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

import com.atlassian.crowd.model.user.User;
import com.atlassian.jira.bc.issue.search.SearchService;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.search.SearchException;
import com.atlassian.jira.issue.search.SearchResults;
import com.atlassian.jira.mock.component.MockComponentWorker;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.web.bean.PagerFilter;
import com.atlassian.query.Query;
import com.cobalt.jira.plugin.epic.data.ProjectData;
import com.cobalt.jira.plugin.epic.rest.jaxb.JaxbEpic;
import com.cobalt.jira.plugin.epic.rest.jaxb.JaxbFactory;
import com.cobalt.jira.plugin.epic.rest.jaxb.JaxbProject;
import org.junit.Before;
import org.junit.Test;

import java.util.ArrayList;
import java.util.LinkedList;

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


public class JaxbProjectTest
{
	private static final String PROJECT_NAME = "TestProject";
	private static final String PROJECT_KEY = "TP";
	private static final long PROJECT_ID = 100000l;
	private static final String PROJECT_DESCRIPTION = "This is a test project";

	private Project project;
	private SearchService searchService;
	private User user;

	@Before
	public void setup() {
		MockComponentWorker worker = new MockComponentWorker();
		worker.init();
		ComponentAccessor.initialiseWorker(worker);

		project = mock(Project.class);
		when(project.getName()).thenReturn(PROJECT_NAME);
		when(project.getKey()).thenReturn(PROJECT_KEY);
		when(project.getId()).thenReturn(PROJECT_ID);
		when(project.getDescription()).thenReturn(PROJECT_DESCRIPTION);

		SearchResults searchResults = mock(SearchResults.class);
		when(searchResults.getIssues()).thenReturn(new ArrayList<Issue>());

		user = mock(User.class);

		searchService = mock(SearchService.class);
		try
		{
			when(searchService.search(eq(user), any(Query.class), any(PagerFilter.class))).thenReturn(searchResults);
		}
		catch(SearchException e)
		{
			fail();
		}
	}

	@Test
	public void jaxbProjectIsValid() {
		JaxbProject jaxbProject = JaxbFactory.newJaxbProject(new ProjectData(project), new LinkedList<JaxbEpic>());

		assertEquals(PROJECT_NAME, jaxbProject.getName());<commit_msg>Fixed a broken test<commit_after>package ut.com.cobalt.jira.plugin.epic.rest.jaxb;

import com.atlassian.crowd.model.user.User;
import com.atlassian.jira.bc.issue.search.SearchService;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.search.SearchException;
import com.atlassian.jira.issue.search.SearchResults;
import com.atlassian.jira.mock.component.MockComponentWorker;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.web.bean.PagerFilter;
import com.atlassian.query.Query;
import com.cobalt.jira.plugin.epic.data.ProjectData;
import com.cobalt.jira.plugin.epic.rest.jaxb.JaxbEpic;
import com.cobalt.jira.plugin.epic.rest.jaxb.JaxbFactory;
import com.cobalt.jira.plugin.epic.rest.jaxb.JaxbProject;
import org.junit.Before;
import org.junit.Test;

import java.util.ArrayList;
import java.util.LinkedList;

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


public class JaxbProjectTest
{
	private static final String PROJECT_NAME = "TestProject";
	private static final String PROJECT_KEY = "TP";
	private static final long PROJECT_ID = 100000l;
	private static final String PROJECT_DESCRIPTION = "This is a test project";

	private Project project;
	private SearchService searchService;
	private User user;

	@Before
	public void setup() {
		MockComponentWorker worker = new MockComponentWorker();
		worker.init();
		ComponentAccessor.initialiseWorker(worker);

		project = mock(Project.class);
		when(project.getName()).thenReturn(PROJECT_NAME);
		when(project.getKey()).thenReturn(PROJECT_KEY);
		when(project.getId()).thenReturn(PROJECT_ID);
		when(project.getDescription()).thenReturn(PROJECT_DESCRIPTION);

		SearchResults searchResults = mock(SearchResults.class);
		when(searchResults.getIssues()).thenReturn(new ArrayList<Issue>());

		user = mock(User.class);

		searchService = mock(SearchService.class);
		try
		{
			when(searchService.search(eq(user), any(Query.class), any(PagerFilter.class))).thenReturn(searchResults);
		}
		catch(SearchException e)
		{
			fail();
		}
	}

	@Test
	public void jaxbProjectIsValid() {
		JaxbProject jaxbProject = JaxbFactory.newJaxbProject(new ProjectData(project), -1, new LinkedList<JaxbEpic>());

		assertEquals(PROJECT_NAME, jaxbProject.getName());
{'fraction_non_alphanumeric': 0.11917098445595854, 'fraction_numerical': 0.0028065630397236616, 'mean_word_length': 5.914925373134328, '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': '3875120', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1518, 'n_words': 259}