Source:
<code>public static void setup() { JavaConfiguration conf = new JavaConfiguration(Charset.forName("UTF-8")); Project project = mock(Project.class); ProjectFileSystem pfs = mock(ProjectFileSystem.class); <START> SuppressWarningsFilter swf = mock(SuppressWarningsFilter.class); <END> File baseDir = new File("src/test/files/bytecode/src"); when(project.getFileSystem()).thenReturn(pfs); when(pfs.getBasedir()).thenReturn(baseDir); DefaultJavaResourceLocator javaResourceLocator = new DefaultJavaResourceLocator(project, null, swf); JavaSquid squid = new JavaSquid(conf, javaResourceLocator); Collection<File> files = FileUtils.listFiles(baseDir, new String[] {"java"}, true); File binDir = new File("src/test/files/bytecode/bin"); squid.scan(files, Collections.<File>emptyList(), Collections.singleton(binDir)); graph = squid.getGraph(); resourceMapping = javaResourceLocator.getResourceMapping(); tag = findResource("tags/Tag.java"); tagFile = findResource("tags/Tag.java"); file = findResource("tags/File.java"); line = findResource("tags/Line.java"); tagName = findResource("tags/TagName.java"); tagException = findResource("tags/TagException.java"); language = findResource("tags/Language.java"); sourceFile = findResource("tags/SourceFile.java"); todo = findResource("tags/impl/Todo.java"); fixme = findResource("tags/impl/FixMe.java"); pacTag = findResource("tags"); pacImpl = findResource("tags/impl"); }</code><technical_language>a mock</technical_language>

Target:
public static void setup() { JavaConfiguration conf = new JavaConfiguration(Charset.forName("UTF-8")); Project project = mock(Project.class); ProjectFileSystem pfs = mock(ProjectFileSystem.class); File baseDir = new File("src/test/files/bytecode/src"); when(project.getFileSystem()).thenReturn(pfs); when(pfs.getBasedir()).thenReturn(baseDir); SensorContext sensorContext = mock(SensorContext.class); when(sensorContext.getResource(Matchers.any(org.sonar.api.resources.File.class))).thenAnswer(new Answer<org.sonar.api.resources.File>() { @Override public org.sonar.api.resources.File answer(InvocationOnMock invocation) throws Throwable { org.sonar.api.resources.File response = (org.sonar.api.resources.File) invocation.getArguments()[0]; response.setEffectiveKey(""); return response; } }); DefaultJavaResourceLocator javaResourceLocator = new DefaultJavaResourceLocator(project, null, new SuppressWarningsFilter()); javaResourceLocator.setSensorContext(sensorContext); JavaSquid squid = new JavaSquid(conf, javaResourceLocator); Collection<File> files = FileUtils.listFiles(baseDir, new String[] {"java"}, true); File binDir = new File("src/test/files/bytecode/bin"); squid.scan(files, Collections.<File>emptyList(), Collections.singleton(binDir)); graph = squid.getGraph(); resourceMapping = javaResourceLocator.getResourceMapping(); tag = findResource("tags/Tag.java"); tagFile = findResource("tags/Tag.java"); file = findResource("tags/File.java"); line = findResource("tags/Line.java"); tagName = findResource("tags/TagName.java"); tagException = findResource("tags/TagException.java"); language = findResource("tags/Language.java"); sourceFile = findResource("tags/SourceFile.java"); todo = findResource("tags/impl/Todo.java"); fixme = findResource("tags/impl/FixMe.java"); pacTag = findResource("tags"); pacImpl = findResource("tags/impl"); }