@Before public void prepare() throws Exception { basedir = temp.newFolder(); fs = new DefaultFileSystem(basedir.toPath()); }
@Before public void prepare() throws IOException { baseDir = temp.newFolder(); fs = new DefaultFileSystem(baseDir.toPath()); input = mock(BlameInput.class); when(input.fileSystem()).thenReturn(fs); }
private SensorContextTester(Path moduleBaseDir) { this.settings = new MapSettings(); this.fs = new DefaultFileSystem(moduleBaseDir).setEncoding(Charset.defaultCharset()); this.activeRules = new ActiveRulesBuilder().build(); this.sensorStorage = new InMemorySensorStorage(); this.project = new DefaultInputProject(ProjectDefinition.create().setKey("projectKey").setBaseDir(moduleBaseDir.toFile()).setWorkDir(moduleBaseDir.resolve(".sonar").toFile())); this.module = new DefaultInputModule(ProjectDefinition.create().setKey("projectKey").setBaseDir(moduleBaseDir.toFile()).setWorkDir(moduleBaseDir.resolve(".sonar").toFile())); this.runtime = SonarRuntimeImpl.forSonarQube(ApiVersion.load(System2.INSTANCE), SonarQubeSide.SCANNER); }
@Test public void testFs() throws Exception { DefaultFileSystem fs = new DefaultFileSystem(temp.newFolder()); tester.setFileSystem(fs); assertThat(tester.fileSystem().baseDir()).isNotEqualTo(baseDir); }
@Before public void prepare() throws Exception { activeRules = new ActiveRulesBuilder().build(); fs = new DefaultFileSystem(temp.newFolder().toPath()); MetricFinder metricFinder = mock(MetricFinder.class); when(metricFinder.<Integer>findByKey(CoreMetrics.NCLOC_KEY)).thenReturn(CoreMetrics.NCLOC); when(metricFinder.<String>findByKey(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION); settings = new MapSettings(); sensorStorage = mock(SensorStorage.class); analysisMode = mock(AnalysisMode.class); runtime = SonarRuntimeImpl.forSonarQube(Version.parse("5.5"), SonarQubeSide.SCANNER); hierarchy = new DefaultInputModuleHierarchy(new DefaultInputModule(ProjectDefinition.create() .setWorkDir(temp.newFolder()) .setBaseDir(temp.newFolder()).setKey("foo"))); adaptor = new ModuleSensorContext(mock(DefaultInputProject.class), mock(InputModule.class), settings.asConfig(), settings, fs, activeRules, analysisMode, sensorStorage, runtime); }
@Before public void prepare() throws Exception { fs = new DefaultFileSystem(temp.newFolder().toPath()); settings = new MapSettings(); optimizer = new ModuleSensorOptimizer(fs, new ActiveRulesBuilder().build(), settings.asConfig()); }
@Before public void before() throws Exception { moduleHierarchy = mock(InputModuleHierarchy.class); File projectBaseDir = temp.newFolder(); fs = new DefaultFileSystem(projectBaseDir.toPath()); SIMPLE_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+02:00")); when(server.getVersion()).thenReturn("3.6"); ProjectDefinition def = ProjectDefinition.create().setBaseDir(projectBaseDir).setWorkDir(temp.newFolder()).setKey("struts"); DefaultInputProject project = new DefaultInputProject(def, 1); InputComponentStore inputComponentStore = new InputComponentStore(mock(BranchConfiguration.class)); DefaultInputFile inputFile = new TestInputFileBuilder("struts", "src/main/java/org/apache/struts/Action.java") .setModuleBaseDir(projectBaseDir.toPath()).build(); inputFile.setStatus(InputFile.Status.CHANGED); inputFile.setPublished(true); inputComponentStore.put("struts", inputFile); RulesBuilder builder = new RulesBuilder(); builder.add(RuleKey.of("squid", "AvoidCycles")).setName("Avoid Cycles"); rules = builder.build(); jsonReport = new JSONReport(settings.asConfig(), fs, server, rules, issueCache, project, inputComponentStore); }
/** * Scan the given file with the given check. */ public SourceFile scanFile(String fileName, JavaScriptFileScanner check) { return JavaScriptAstScanner.scanSingleFile( new File(fileName), new VisitorsBridge(Lists.newArrayList(check), null, new DefaultFileSystem(), settings())); }
private SensorContextTester(Path moduleBaseDir) { this.settings = new MapSettings(); this.fs = new DefaultFileSystem(moduleBaseDir).setEncoding(Charset.defaultCharset()); this.activeRules = new ActiveRulesBuilder().build(); this.sensorStorage = new InMemorySensorStorage(); this.project = new DefaultInputProject(ProjectDefinition.create().setKey("projectKey").setBaseDir(moduleBaseDir.toFile()).setWorkDir(moduleBaseDir.resolve(".sonar").toFile())); this.module = new DefaultInputModule(ProjectDefinition.create().setKey("projectKey").setBaseDir(moduleBaseDir.toFile()).setWorkDir(moduleBaseDir.resolve(".sonar").toFile())); this.runtime = SonarRuntimeImpl.forSonarQube(ApiVersion.load(System2.INSTANCE), SonarQubeSide.SCANNER); }
private SensorContextTester(File moduleBaseDir) { this.settings = new Settings(); this.fs = new DefaultFileSystem(moduleBaseDir); this.activeRules = new ActiveRulesBuilder().build(); this.analysisMode = new MockAnalysisMode(); this.sensorStorage = new InMemorySensorStorage(); }
@Before public void setUp() throws IOException { fileSystem = new DefaultFileSystem(tempFolder.getRoot()); fileSystem.setEncoding(StandardCharsets.UTF_8); file = tempFolder.newFile(); }
@Before public void setUp() throws IOException { fileSystem = new DefaultFileSystem(tempFolder.getRoot()); fileSystem.setEncoding(StandardCharsets.UTF_8); file = tempFolder.newFile(); }