public QualityProfiles provide(QualityProfileLoader loader, ProjectRepositories projectRepositories, ScannerProperties props) { if (this.profiles == null) { List<QualityProfile> profileList; Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG); if (!projectRepositories.exists()) { profileList = loader.loadDefault(getSonarProfile(props)); } else { profileList = loader.load(props.getKeyWithBranch(), getSonarProfile(props)); } profiler.stopInfo(); profiles = new QualityProfiles(profileList); } return profiles; }
@Test public void testProjectDoesntExist() { when(projectRepo.exists()).thenReturn(false); when(loader.loadDefault(anyString())).thenReturn(response); when(props.property(QualityProfiles.SONAR_PROFILE_PROP)).thenReturn("profile"); QualityProfiles qps = qualityProfileProvider.provide(loader, projectRepo, props); assertResponse(qps); verify(loader).loadDefault(anyString()); verifyNoMoreInteractions(loader); }
@Test public void testProfilePropDefault() { when(projectRepo.exists()).thenReturn(false); when(loader.loadDefault(eq("custom"))).thenReturn(response); when(props.property(QualityProfiles.SONAR_PROFILE_PROP)).thenReturn("custom"); when(props.properties()).thenReturn(ImmutableMap.of(QualityProfiles.SONAR_PROFILE_PROP, "custom")); QualityProfiles qps = qualityProfileProvider.provide(loader, projectRepo, props); assertResponse(qps); verify(loader).loadDefault(eq("custom")); verifyNoMoreInteractions(loader); assertThat(logTester.logs(LoggerLevel.WARN)).contains("Ability to set quality profile from command line using '" + QualityProfiles.SONAR_PROFILE_PROP + "' is deprecated and will be dropped in a future SonarQube version. Please configure quality profile used by your project on SonarQube server."); }
@Test public void testProfileProp() { when(loader.load(eq("project"), eq("custom"))).thenReturn(response); when(props.property(QualityProfiles.SONAR_PROFILE_PROP)).thenReturn("custom"); when(props.properties()).thenReturn(ImmutableMap.of(QualityProfiles.SONAR_PROFILE_PROP, "custom")); QualityProfiles qps = qualityProfileProvider.provide(loader, projectRepo, props); assertResponse(qps); verify(loader).load(eq("project"), eq("custom")); verifyNoMoreInteractions(loader); assertThat(logTester.logs(LoggerLevel.WARN)).contains("Ability to set quality profile from command line using '" + QualityProfiles.SONAR_PROFILE_PROP + "' is deprecated and will be dropped in a future SonarQube version. Please configure quality profile used by your project on SonarQube server."); }
public QualityProfiles provide(QualityProfileLoader loader, ProjectRepositories projectRepositories, ScannerProperties props) { if (this.profiles == null) { List<QualityProfile> profileList; Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG); if (!projectRepositories.exists()) { profileList = loader.loadDefault(getSonarProfile(props)); } else { profileList = loader.load(props.getKeyWithBranch(), getSonarProfile(props)); } profiler.stopInfo(); profiles = new QualityProfiles(profileList); } return profiles; }