public HierarchicalClassId(final long hash, final ClassName name, final String hierarchicalHash) { this(new ClassIdentifier(hash, name), hierarchicalHash); }
public static ClassInfo make(final ClassName name) { return make(new ClassIdentifier(1, name)); }
public static ClassInfo make(final ClassName name) { return make(new ClassIdentifier(1, name)); }
public static ClassInfoBuilder getClassInfo(final ClassName name, final byte[] bytes, final long hash) { final ClassReader reader = new ClassReader(bytes); final ClassVisitor writer = new NullVisitor(); final ClassInfoBuilder info = new ClassInfoBuilder(); info.id = new ClassIdentifier(hash, name); reader.accept(new ClassInfoVisitor(info, writer), 0); return info; }
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 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 shouldRecordAndRetrieveClassPath() { final ClassHistory foo = new ClassHistory(new HierarchicalClassId( new ClassIdentifier(0, ClassName.fromString("foo")), ""), COV); final ClassHistory bar = new ClassHistory(new HierarchicalClassId( new ClassIdentifier(0, ClassName.fromString("bar")), ""), COV); recordClassPathWithTestee(foo.getId(), bar.getId()); final Reader reader = new StringReader(this.output.toString()); this.testee = new ObjectOutputStreamHistoryStore(this.writerFactory, Optional.ofNullable(reader)); this.testee.initialize(); final Map<ClassName, ClassHistory> expected = new HashMap<>(); expected.put(foo.getName(), foo); expected.put(bar.getName(), bar); assertEquals(expected, this.testee.getHistoricClassPath()); }
@Before public void setUp() { this.data = new ClassInfoBuilder(); this.data.id = new ClassIdentifier(1, ClassName.fromString("foo")); }
@Before public void setUp() { this.data = new ClassInfoBuilder(); this.data.id = new ClassIdentifier(1, ClassName.fromString("foo")); }
@Test public void shouldReadCorruptFiles() throws IOException { final HierarchicalClassId foo = new HierarchicalClassId( new ClassIdentifier(0, ClassName.fromString("foo")), ""); recordClassPathWithTestee(foo); final MutationResult mr = new MutationResult( MutationTestResultMother.createDetails("foo"), new MutationStatusTestPair(1, DetectionStatus.KILLED, "testName")); this.testee.recordResult(mr); this.output.append("rubbish"); final Reader reader = new StringReader(this.output.toString()); this.testee = new ObjectOutputStreamHistoryStore(this.writerFactory, Optional.ofNullable(reader)); this.testee.initialize(); assertFalse(this.testee.getHistoricResults().isEmpty()); }
@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)); }
public HierarchicalClassId(final long hash, final ClassName name, final String hierarchicalHash) { this(new ClassIdentifier(hash, name), hierarchicalHash); }
public static ClassInfo make(final ClassName name, final String fileName) { final DefaultClassPointer parent = new DefaultClassPointer(null); final ClassInfoBuilder data = new ClassInfoBuilder(); data.id = new ClassIdentifier(1, name); data.sourceFile = fileName; return new ClassInfo(parent, new DefaultClassPointer(null), data); }
public static ClassInfo make(final ClassName name, final String fileName) { final DefaultClassPointer parent = new DefaultClassPointer(null); final ClassInfoBuilder data = new ClassInfoBuilder(); data.id = new ClassIdentifier(1, name); data.sourceFile = fileName; return new ClassInfo(parent, new DefaultClassPointer(null), data); }
@Test public void shouldRecordAndRetrieveResults() { final HierarchicalClassId foo = new HierarchicalClassId( new ClassIdentifier(0, ClassName.fromString("foo")), ""); recordClassPathWithTestee(foo); final MutationResult mr = new MutationResult( MutationTestResultMother.createDetails("foo"), new MutationStatusTestPair(1, DetectionStatus.KILLED, "testName")); this.testee.recordResult(mr); final Reader reader = new StringReader(this.output.toString()); this.testee = new ObjectOutputStreamHistoryStore(this.writerFactory, Optional.ofNullable(reader)); this.testee.initialize(); final Map<MutationIdentifier, MutationStatusTestPair> expected = new HashMap<>(); expected.put(mr.getDetails().getId(), mr.getStatusTestPair()); assertEquals(expected, this.testee.getHistoricResults()); }
@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"))); }
public static ClassInfoBuilder getClassInfo(final ClassName name, final byte[] bytes, final long hash) { final ClassReader reader = new ClassReader(bytes); final ClassVisitor writer = new NullVisitor(); final ClassInfoBuilder info = new ClassInfoBuilder(); info.id = new ClassIdentifier(hash, name); reader.accept(new ClassInfoVisitor(info, writer), 0); return info; }