public Set<ClassName> getCodeUnderTestNames() { final Set<ClassName> codeClasses = new HashSet<>(); FCollection.mapTo(getCode(), ClassInfo.toClassName(), codeClasses); return codeClasses; }
public CoverageData(final CodeSource code, final LineMap lm, Map<BlockLocation, Set<TestInfo>> blockCoverage) { this.blockCoverage = blockCoverage; this.code = code; this.lm = lm; this.classesForFile = FCollection.bucket(this.code.getCode(), keyFromClassInfo()); }
@Test public void shouldNotThrowAnErrorWhenNoClassesFound() { when(this.code.getCode()).thenReturn(Collections.<ClassInfo> emptyList()); try { this.testee.verify(this.code); } catch (final PitHelpError e) { fail(); } }
private void setupClassPath(final ClassByteArraySource source, final String clazz) { final Repository repository = new Repository(source); final ClassInfo ci = repository.fetchClass(ClassName.fromString(clazz)) .get(); when(this.code.getCode()).thenReturn(Collections.singletonList(ci)); }
@Test public void shouldIdentifyAllNonTestCodeOnClassPathWhenNoTestsPresent() { when(this.classPath.code()).thenReturn( Arrays.asList(this.foo.getName(), this.bar.getName())); assertEquals(Arrays.asList(this.foo, this.bar), this.testee.getCode()); }
@Override public void verify(final CodeSource code) { final Collection<ClassInfo> codeClasses = FCollection.filter(code.getCode(), isNotSynthetic()); if (hasMutableCode(codeClasses)) { checkAtLeastOneClassHasLineNumbers(codeClasses); FCollection.forEach(codeClasses, throwErrorIfHasNoSourceFile()); } }
@Test public void shouldProvideListOfClassesForSourceFile() { final ClassInfo fooClass = ClassInfoMother.make(this.foo, "foo.java"); final ClassInfo barClass = ClassInfoMother.make(this.bar, "bar.java"); final Collection<ClassInfo> classes = Arrays.asList(fooClass, barClass); when(this.code.getCode()).thenReturn(classes); this.testee = new CoverageData(this.code, this.lm); assertEquals(Arrays.asList(barClass), this.testee.getClassesForFile("bar.java", "")); }
@Test public void shouldMatchPackageWhenFindingSources() { final ClassName foo1 = ClassName.fromString("a.b.c.foo"); final ClassName foo2 = ClassName.fromString("d.e.f.foo"); final ClassInfo foo1Class = ClassInfoMother.make(foo1, "foo.java"); final ClassInfo foo2Class = ClassInfoMother.make(foo2, "foo.java"); final Collection<ClassInfo> classes = Arrays.asList(foo1Class, foo2Class); when(this.code.getCode()).thenReturn(classes); this.testee = new CoverageData(this.code, this.lm); assertEquals(Arrays.asList(foo1Class), this.testee.getClassesForFile("foo.java", "a.b.c")); }
public Set<ClassName> getCodeUnderTestNames() { final Set<ClassName> codeClasses = new HashSet<>(); FCollection.mapTo(getCode(), ClassInfo.toClassName(), codeClasses); return codeClasses; }
final Collection<ClassName> codeClasses = FCollection.map(code.getCode(), ClassInfo.toClassName());