<commit_before>package com.projectkaiser.scm.vcs.svn;

import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import org.junit.After;
import org.mockito.Mockito;
import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNDirEntry;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNLogEntry;
import org.tmatesoft.svn.core.SVNNodeKind;
import org.tmatesoft.svn.core.SVNProperties;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import org.tmatesoft.svn.core.wc.SVNWCClient;

import com.projectkaiser.scm.vcs.api.IVCS;
import com.projectkaiser.scm.vcs.api.abstracttest.VCSAbstractTest;
import com.projectkaiser.scm.vcs.api.workingcopy.IVCSLockedWorkingCopy;
import com.projectkaiser.scm.vcs.api.workingcopy.IVCSRepositoryWorkspace;

public class SVNVCSTest extends VCSAbstractTest {

	private SVNVCS svn;
	private SVNURL localRepoUrl;
	private SVNRepository svnRepo;
	private SVNWCClient mockedSVNRevertClient;
	private RuntimeException testSvnRevertException = new RuntimeException("test exeption on svn revert");
	
	@Override
	public void setUp() throws Exception {
		super.setUp();
		localRepoUrl = SVNRepositoryFactory.createLocalRepository(new File(repoUrl.replace("file://", "")), true, true);
		
		svnRepo = SVNRepositoryFactory.create(localRepoUrl);

		svn.createBranch("", MASTER_BRANCH, null);
	}

	@After
	public void tearDown() throws IOException {
		svnRepo.closeSession();
	}

	@Override
	public String getVCSTypeString() {
		return "svn";
	}

	@Override
	protected String getVCSRepoUrl() {
		return "file:///" + localVCSWorkspace.getHomeFolder().getPath().replace("\\", "/") + "/";
	}

	@Override
	protected IVCS getVCS(IVCSRepositoryWorkspace mockedVCSRepo) {
		// nulls as user and pwd because we using file repository, not server
		svn = Mockito.spy(new SVNVCS(mockedVCSRepo, null, null));
		return svn;
	}
	
	private void listEntries(Set<String> entries, String path) throws SVNException {
		@SuppressWarnings("unchecked")
		Collection<SVNDirEntry> subEntries = svnRepo.getDir(path, -1, null, (Collection<SVNDirEntry>) null);
		Iterator<SVNDirEntry> iterator = subEntries.iterator();
		while (iterator.hasNext()) {
			SVNDirEntry entry = iterator.next();
			entries.add((path.equals("") ? "" : path + "/") + entry.getName());<commit_msg>refactor<commit_after>package com.projectkaiser.scm.vcs.svn;

import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import org.junit.After;
import org.mockito.Mockito;
import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNDirEntry;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNLogEntry;
import org.tmatesoft.svn.core.SVNNodeKind;
import org.tmatesoft.svn.core.SVNProperties;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import org.tmatesoft.svn.core.wc.SVNWCClient;

import com.projectkaiser.scm.vcs.api.IVCS;
import com.projectkaiser.scm.vcs.api.abstracttest.VCSAbstractTest;
import com.projectkaiser.scm.vcs.api.workingcopy.IVCSLockedWorkingCopy;
import com.projectkaiser.scm.vcs.api.workingcopy.IVCSRepositoryWorkspace;

public class SVNVCSTest extends VCSAbstractTest {

	private SVNVCS svn;
	private SVNURL localRepoUrl;
	private SVNRepository svnRepo;
	private SVNWCClient mockedSVNRevertClient;
	private RuntimeException testSvnRevertException = new RuntimeException("test exeption on svn revert");
	
	@Override
	public void setUp() throws Exception {
		super.setUp();
		localRepoUrl = SVNRepositoryFactory.createLocalRepository(new File(repoUrl.replace("file://", "")), true, true);
		
		svnRepo = SVNRepositoryFactory.create(localRepoUrl);

		svn.createBranch("", MASTER_BRANCH, null);
	}

	@After
	public void tearDown() throws IOException {
		svnRepo.closeSession();
	}

	@Override
	public String getVCSTypeString() {
		return "svn";
	}

	@Override
	protected String getTestRepoUrl() {
		return "file:///" + localVCSWorkspace.getHomeFolder().getPath().replace("\\", "/") + "/";
	}

	@Override
	protected IVCS getVCS(IVCSRepositoryWorkspace mockedVCSRepo) {
		// nulls as user and pwd because we using file repository, not server
		svn = Mockito.spy(new SVNVCS(mockedVCSRepo, null, null));
		return svn;
	}
	
	private void listEntries(Set<String> entries, String path) throws SVNException {
		@SuppressWarnings("unchecked")
		Collection<SVNDirEntry> subEntries = svnRepo.getDir(path, -1, null, (Collection<SVNDirEntry>) null);
		Iterator<SVNDirEntry> iterator = subEntries.iterator();
		while (iterator.hasNext()) {
			SVNDirEntry entry = iterator.next();
			entries.add((path.equals("") ? "" : path + "/") + entry.getName());
{'fraction_non_alphanumeric': 0.12097407698350353, 'fraction_numerical': 0.00039277297721916735, 'mean_word_length': 5.571612903225806, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4667990', 'n_tokens_mistral': 1809, 'n_tokens_neox': 1774, 'n_words': 323}