public static ClassInfo make(final ClassIdentifier id) { return make(id, new DefaultClassPointer(null)); }
public static ClassInfo make(final ClassIdentifier id, final ClassInfo parent) { return make(id, new DefaultClassPointer(parent)); }
public static ClassInfo make(final ClassName name) { return make(new ClassIdentifier(1, name)); }
public static ClassInfo make(final ClassIdentifier id) { return make(id, new DefaultClassPointer(null)); }
public static ClassInfo make(final ClassName name) { return make(new ClassIdentifier(1, name)); }
public static ClassInfo make(final ClassIdentifier id, final ClassInfo parent) { return make(id, new DefaultClassPointer(parent)); }
private ClassInfo makeClassInfo(final String name) { final ClassInfo ci = ClassInfoMother.make(name); when(this.repository.fetchClass(ClassName.fromString(name))).thenReturn( Optional.ofNullable(ci)); return ci; }
private void setCurrentClassPath(final HierarchicalClassId currentId) { final ClassInfo currentClass = ClassInfoMother.make(currentId.getId()); when(this.classInfoSource.fetchClass(ClassName.fromString("foo"))) .thenReturn(Optional.ofNullable(currentClass)); }
@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", "")); }
public static ClassInfo make(final String name) { return make(new ClassIdentifier(1, ClassName.fromString(name))); } }
public static ClassInfo make(final String name) { return make(new ClassIdentifier(1, ClassName.fromString(name))); } }
@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")); }
@Test public void shouldTreatClassesWithModifiedParentAsChanged() { final long currentHash = 42; final ClassName foo = ClassName.fromString("foo"); final ClassInfo parent = ClassInfoMother.make("parent"); final ClassIdentifier currentId = new ClassIdentifier(currentHash, foo); final ClassInfo currentFoo = ClassInfoMother.make(currentId, parent); final ClassInfo modifiedParent = ClassInfoMother.make(new ClassIdentifier( parent.getHash().longValue() + 1, ClassName.fromString("parent"))); final ClassInfo modifiedFoo = ClassInfoMother.make(currentId, modifiedParent); setCurrentClassPath(currentFoo); this.historicClassPath.put(foo, makeHistory(modifiedFoo)); assertTrue(this.testee.hasClassChanged(foo)); }
@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); }
@Test public void shouldTreatClassesWithDifferentHashesAsChanged() { final long currentHash = 42; final ClassName foo = ClassName.fromString("foo"); final ClassIdentifier currentId = new ClassIdentifier(currentHash, foo); setCurrentClassPath(ClassInfoMother.make(currentId)); this.historicClassPath.put(foo, makeHistory(new HierarchicalClassId( currentHash + 1, foo, "0"))); assertTrue(this.testee.hasClassChanged(ClassName.fromString("foo"))); }