private static boolean checkForGlobalUpdates(List<String> changelog, ConnectedSonarLintEngine engine, ServerConfiguration serverConfiguration) { StorageUpdateCheckResult checkForUpdateResult = engine.checkIfGlobalStorageNeedUpdate(serverConfiguration, null); if (checkForUpdateResult.needUpdate()) { changelog.addAll(checkForUpdateResult.changelog()); return true; } return false; }
@Test public void do_nothing_if_no_updates() { StorageUpdateCheckResult result = mock(StorageUpdateCheckResult.class); when(result.needUpdate()).thenReturn(false); when(engine.checkIfProjectStorageNeedUpdate(any(ServerConfiguration.class), anyString(), isNull())).thenReturn(result); when(engine.checkIfGlobalStorageNeedUpdate(any(ServerConfiguration.class), isNull())).thenReturn(result); updateChecker.checkForUpdate(); verify(engine).checkIfGlobalStorageNeedUpdate(any(ServerConfiguration.class), isNull()); verify(engine).checkIfProjectStorageNeedUpdate(any(ServerConfiguration.class), anyString(), isNull()); verifyZeroInteractions(notifications); }
private void checkForProjectUpdates(List<String> changelog, ConnectedSonarLintEngine engine, ServerConfiguration serverConfiguration) { StorageUpdateCheckResult projectUpdateCheckResult = engine.checkIfProjectStorageNeedUpdate(serverConfiguration, projectSettings.getProjectKey(), null); if (projectUpdateCheckResult.needUpdate()) { changelog.addAll(projectUpdateCheckResult.changelog()); } }
@Test public void global_changes() { StorageUpdateCheckResult result = mock(StorageUpdateCheckResult.class); when(result.needUpdate()).thenReturn(true); when(result.changelog()).thenReturn(Collections.singletonList("change1")); when(engine.checkIfProjectStorageNeedUpdate(any(ServerConfiguration.class), anyString(), isNull())).thenReturn(result); when(engine.checkIfGlobalStorageNeedUpdate(any(ServerConfiguration.class), isNull())).thenReturn(result); updateChecker.checkForUpdate(); verify(engine).checkIfGlobalStorageNeedUpdate(any(ServerConfiguration.class), isNull()); verify(engine).checkIfProjectStorageNeedUpdate(any(ServerConfiguration.class), anyString(), isNull()); verify(notifications).notifyServerHasUpdates("serverId", engine, server, false); verifyNoMoreInteractions(engine); verifyZeroInteractions(notifications); }
StorageUpdateCheckResult checkForUpdateResult = client.checkIfGlobalStorageNeedUpdate(getConfig(), new WrappedProgressMonitor(globalMonitor, "Check for configuration updates on server '" + getId() + "'")); if (checkForUpdateResult.needUpdate()) { this.hasUpdates = true; checkForUpdateResult.changelog().forEach(line -> SonarLintLogger.get().info(" - " + line)); StorageUpdateCheckResult projectUpdateCheckResult = client.checkIfProjectStorageNeedUpdate(getConfig(), projectKey, new WrappedProgressMonitor(projectMonitor, "Checking for binding data update for project '" + projectKey + "'")); if (projectUpdateCheckResult.needUpdate()) { this.hasUpdates = true; SonarLintLogger.get().info("For project '" + projectKey + "':"); projectUpdateCheckResult.changelog().forEach(line -> SonarLintLogger.get().info(" - " + line));