use of org.sonarsource.sonarlint.core.client.api.connected.ModuleStorageStatus in project sonarlint-core by SonarSource.
the class StorageAnalyzerTest method testStaleModuleStorage.
@Test
public void testStaleModuleStorage() {
when(globalReader.get()).thenReturn(mock(GlobalStorageStatus.class));
ModuleStorageStatus moduleStatus = mock(ModuleStorageStatus.class);
when(moduleStatus.isStale()).thenReturn(true);
when(moduleReader.apply("module1")).thenReturn(moduleStatus);
exception.expect(StorageException.class);
exception.expectMessage("Stored data for module 'module1' is stale");
analyzer.analyze(mock(StorageContainer.class), config, mock(IssueListener.class), new ProgressWrapper(null));
}
use of org.sonarsource.sonarlint.core.client.api.connected.ModuleStorageStatus in project sonarlint-intellij by SonarSource.
the class SonarLintEngineManager method checkConnectedEngineStatus.
private static void checkConnectedEngineStatus(ConnectedSonarLintEngine engine, SonarLintProjectNotifications notifications, String serverId, String projectKey) throws InvalidBindingException {
// Check if engine's global storage is OK
ConnectedSonarLintEngine.State state = engine.getState();
if (state != ConnectedSonarLintEngine.State.UPDATED) {
if (state != ConnectedSonarLintEngine.State.NEED_UPDATE) {
notifications.notifyServerNotUpdated();
} else if (state != ConnectedSonarLintEngine.State.NEVER_UPDATED) {
notifications.notifyServerStorageNeedsUpdate(serverId);
}
throw new InvalidBindingException("Server is not updated: " + serverId);
}
// Check if module's storage is OK. Global storage was updated and all project's binding that were open too,
// but we might have now opened a new project with a different binding.
ModuleStorageStatus moduleStorageStatus = engine.getModuleStorageStatus(projectKey);
if (moduleStorageStatus == null) {
notifications.notifyModuleInvalid();
throw new InvalidBindingException("Project is bound to a module that doesn't exist: " + projectKey);
} else if (moduleStorageStatus.isStale()) {
notifications.notifyModuleStale();
throw new InvalidBindingException("Stale module's storage: " + projectKey);
}
}
Aggregations