private void checkProject(boolean isIssueMode) { if (isIssueMode) { if (!project.exists()) { LOG.warn("Project doesn't exist on the server. All issues will be marked as 'new'."); } else if (project.lastAnalysisDate() == null) { LOG.warn("No analysis has been found on the server for this project. All issues will be marked as 'new'."); } } } }
@Test public void continueOnError() { when(wsClient.call(any(WsRequest.class))).thenThrow(IllegalStateException.class); ProjectRepositories proj = loader.load(PROJECT_KEY, false, null); assertThat(proj.exists()).isEqualTo(false); }
@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 testAssociated() { when(mode.isIssues()).thenReturn(false); when(loader.load(eq("key"), eq(false), any())).thenReturn(project); ProjectRepositories repo = provider.provide(loader, props, mode, branchConfiguration); assertThat(repo.exists()).isEqualTo(true); assertThat(repo.lastAnalysisDate()).isNotNull(); verify(mode, times(1)).isIssues(); verify(props).getKeyWithBranch(); verify(loader).load(eq("key"), eq(false), eq(null)); verifyNoMoreInteractions(loader, props, mode); } }
@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."); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); qualityProfileProvider = new QualityProfilesProvider(); when(props.getKeyWithBranch()).thenReturn("project"); when(projectRepo.exists()).thenReturn(true); response = new ArrayList<>(1); response.add(QualityProfile.newBuilder().setKey("profile").setName("profile").setLanguage("lang").setRulesUpdatedAt(DateUtils.formatDateTime(new Date())).build()); }
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; }
private void checkProject(boolean isIssueMode) { if (isIssueMode) { if (!project.exists()) { LOG.warn("Project doesn't exist on the server. All issues will be marked as 'new'."); } else if (project.lastAnalysisDate() == null) { LOG.warn("No analysis has been found on the server for this project. All issues will be marked as 'new'."); } } } }
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; }