<commit_before>package com.youdevise.fbplugins.tdd4fb;

import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.collection.IsCollectionContaining.hasItem;

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import org.junit.Test;

import edu.umd.cs.findbugs.classfile.ICodeBaseLocator;
import edu.umd.cs.findbugs.classfile.impl.FilesystemCodeBaseLocator;

public class AuxCodeBaseLocatorProviderTest {

	private final AuxCodeBaseLocatorProvider provider = new AuxCodeBaseLocatorProvider();


	@SuppressWarnings("unchecked")
	@Test
	public void createsFileSystemCodeBaseLocatorForEachJarPathGiven() throws Exception {
		Iterable<String> auxilliaryCodeBasePaths = asList("/some/path/to/myFirstJar.jar",
														  "/some/path/to/mySecondJar.jar",
														  "/some/path/to/myDirectory/");
		Iterable<ICodeBaseLocator> codeBases = provider.get(auxilliaryCodeBasePaths);
		assertThat(codeBases, allOf(hasItem(auxilliaryCodeBaseFor("/some/path/to/myFirstJar.jar")),
									hasItem(auxilliaryCodeBaseFor("/some/path/to/mySecondJar.jar")),
									hasItem(auxilliaryCodeBaseFor("/some/path/to/myDirectory"))));
	}

	private Matcher<ICodeBaseLocator> auxilliaryCodeBaseFor(final String jarPath) {
		return new TypeSafeMatcher<ICodeBaseLocator>() {
			public void describeTo(Description description) {
				description.appendText("a FileSystemCodeBaseLocator ")
						   .appendText("with directory equal to ").appendValue(jarPath);
			}

			public boolean matchesSafely(ICodeBaseLocator codeBaseLocator) {
				return codeBaseLocator instanceof FilesystemCodeBaseLocator
						&& ((FilesystemCodeBaseLocator)codeBaseLocator).getPathName().equals(jarPath);
			}
		};
	}
	
}<commit_msg>Attempt a platform-independent unit test.<commit_after>package com.youdevise.fbplugins.tdd4fb;

import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.collection.IsCollectionContaining.hasItem;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import org.junit.Test;

import edu.umd.cs.findbugs.classfile.ICodeBaseLocator;
import edu.umd.cs.findbugs.classfile.impl.FilesystemCodeBaseLocator;

public class AuxCodeBaseLocatorProviderTest {

	private final AuxCodeBaseLocatorProvider provider = new AuxCodeBaseLocatorProvider();


	@SuppressWarnings("unchecked")
	@Test
	public void createsFileSystemCodeBaseLocatorForEachJarPathGiven() throws Exception {
		Iterable<String> auxilliaryCodeBasePaths = 
		        convertToFilePaths(asList("path/to/myFirstJar.jar",
										  "path/to/mySecondJar.jar",
										  "path/to/myDirectory/"));
		Iterable<ICodeBaseLocator> codeBases = provider.get(auxilliaryCodeBasePaths);
		assertThat(codeBases, allOf(hasItem(auxilliaryCodeBaseFor("path/to/myFirstJar.jar")),
									hasItem(auxilliaryCodeBaseFor("path/to/mySecondJar.jar")),
									hasItem(auxilliaryCodeBaseFor("path/to/myDirectory"))));
	}
	
	private Iterable<String> convertToFilePaths(Iterable<String> paths) {
	    List<String> files = new ArrayList<String>();
	    for (String path : paths) {
            files.add(absolutePath(path));
        }
	    return files;
	}

	private Matcher<ICodeBaseLocator> auxilliaryCodeBaseFor(final String codeBasePath) {
		return new TypeSafeMatcher<ICodeBaseLocator>() {
			public void describeTo(Description description) {
				description.appendText("a FileSystemCodeBaseLocator ")
						   .appendText("with directory equal to ").appendValue(absolutePath(codeBasePath));
			}

			public boolean matchesSafely(ICodeBaseLocator codeBaseLocator) {
				return codeBaseLocator instanceof FilesystemCodeBaseLocator
						&& ((FilesystemCodeBaseLocator)codeBaseLocator).getPathName().equals(absolutePath(codeBasePath));
			}
		};
	}
	
	private static String absolutePath(String path) {
	    return new File(path).getAbsolutePath();
	}
}
{'fraction_non_alphanumeric': 0.10137250180592343, 'fraction_numerical': 0.0004815795810257645, 'mean_word_length': 5.371165644171779, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4558737', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1285, 'n_words': 197}