@Override public Collection<ClassInfo> getClassInfo(final Collection<ClassName> classes) { return this.code.getClassInfo(classes); }
private BigInteger generateCoverageNumber( final Map<ClassLine, Set<TestInfo>> coverage) { BigInteger coverageNumber = BigInteger.ZERO; final Set<ClassName> testClasses = new HashSet<>(); FCollection.flatMapTo(coverage.values(), testsToClassName(), testClasses); for (final ClassInfo each : this.code.getClassInfo(testClasses)) { coverageNumber = coverageNumber.add(each.getDeepHash()); } return coverageNumber; }
private int numberOfLines() { return FCollection.fold(numberLines(), 0, this.code.getClassInfo(allClasses())); }
@Test public void shouldProvideAccessToClassData() { final Collection<ClassName> classes = Arrays.asList(ClassName .fromString("foo")); this.testee.getClassInfo(classes); verify(this.code).getClassInfo(classes); }
private void recordClassPath(final CoverageDatabase coverageData) { final Set<ClassName> allClassNames = getAllClassesAndTests(coverageData); final Collection<HierarchicalClassId> ids = FCollection.map( this.code.getClassInfo(allClassNames), ClassInfo.toFullClassId()); history().recordClassPath(ids, coverageData); }
@Test public void shouldProvideDetailsOfRequestedClasses() { when(this.repository.fetchClass(ClassName.fromString("Foo"))).thenReturn( Optional.ofNullable(this.foo)); when(this.repository.fetchClass(ClassName.fromString("Unknown"))) .thenReturn(Optional.<ClassInfo> empty()); assertEquals(Arrays.asList(this.foo), this.testee.getClassInfo(Arrays .asList(ClassName.fromString("Foo"), ClassName.fromString("Unknown")))); }
@Test public void shouldRecordClassPath() { final ClassName clazz = ClassName.fromClass(Foo.class); final HierarchicalClassId fooId = new HierarchicalClassId( new ClassIdentifier(0, clazz), "0"); final ClassInfo foo = ClassInfoMother.make(fooId.getId()); when(this.code.getCodeUnderTestNames()).thenReturn( Collections.singleton(clazz)); when(this.code.getClassInfo(any(List.class))).thenReturn( Collections.singletonList(foo)); createAndRunTestee(); verify(this.history).recordClassPath(Arrays.asList(fooId), this.coverageDb); }
@Test public void shouldReturnNonZeroCoverageIdWhenTestsCoverClass() { final ClassName foo = ClassName.fromString("Foo"); final ClassInfo ci = ClassInfoMother.make(foo); when(this.code.getClassInfo(any(Collection.class))).thenReturn( Collections.singletonList(ci)); final BlockLocationBuilder block = aBlockLocation().withLocation( aLocation().withClass(foo)); final HashMap<BlockLocation, Set<Integer>> map = makeCoverageMapForBlock(block, 42); when(this.lm.mapLines(any(ClassName.class))).thenReturn(map); this.testee.calculateClassCoverage(aCoverageResult().withVisitedBlocks( block.build(1)).build()); assertThat(this.testee.getCoverageIdForClass(foo).longValue()) .isNotEqualTo(0); }