use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class StorageAnalyzerTest method testNoModuleStorage.
@Test
public void testNoModuleStorage() {
when(globalReader.get()).thenReturn(mock(GlobalStorageStatus.class));
when(moduleReader.apply("module1")).thenReturn(null);
exception.expect(StorageException.class);
exception.expectMessage("No data stored for module");
analyzer.analyze(mock(StorageContainer.class), config, mock(IssueListener.class), new ProgressWrapper(null));
}
use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class ModuleHierarchyDownloaderTest method testNoPaginationWhenJustUnderPageSize.
@Test
public void testNoPaginationWhenJustUnderPageSize() throws IOException {
TreeWsResponse.Builder responseBuilder = TreeWsResponse.newBuilder().setPaging(Paging.newBuilder().setTotal(PAGE_SIZE));
for (int i = 0; i < PAGE_SIZE; i++) {
responseBuilder.addComponents(Component.newBuilder().setId("id" + i).setKey("testRoot" + i));
WsClientTestUtils.addStreamResponse(wsClient, "api/components/show.protobuf?id=id" + i, "/update/show_module1.pb");
}
WsClientTestUtils.addResponse(wsClient, "api/components/tree.protobuf?qualifiers=BRC&baseComponentKey=testRoot&ps=500&p=1", responseBuilder.build());
Map<String, String> fetchModuleHierarchy = downloader.fetchModuleHierarchy("testRoot", new ProgressWrapper(null));
assertThat(fetchModuleHierarchy).hasSize(PAGE_SIZE + 1);
}
use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class ModuleHierarchyDownloaderTest method testPagination.
@Test
public void testPagination() throws IOException {
TreeWsResponse.Builder responseBuilder = TreeWsResponse.newBuilder().setPaging(Paging.newBuilder().setPageIndex(1).setTotal(501));
for (int i = 0; i < PAGE_SIZE; i++) {
responseBuilder.addComponents(Component.newBuilder().setId("id" + i).setKey("testRoot" + i));
WsClientTestUtils.addStreamResponse(wsClient, "api/components/show.protobuf?id=id" + i, "/update/show_module1.pb");
}
WsClientTestUtils.addResponse(wsClient, "api/components/tree.protobuf?qualifiers=BRC&baseComponentKey=testRoot&ps=500&p=1", responseBuilder.build());
responseBuilder = TreeWsResponse.newBuilder().setPaging(Paging.newBuilder().setPageIndex(2).setTotal(501));
for (int i = 501; i < 502; i++) {
responseBuilder.addComponents(Component.newBuilder().setId("id" + i).setKey("testRoot" + i));
WsClientTestUtils.addStreamResponse(wsClient, "api/components/show.protobuf?id=id" + i, "/update/show_module1.pb");
}
WsClientTestUtils.addResponse(wsClient, "api/components/tree.protobuf?qualifiers=BRC&baseComponentKey=testRoot&ps=500&p=2", responseBuilder.build());
Map<String, String> fetchModuleHierarchy = downloader.fetchModuleHierarchy("testRoot", new ProgressWrapper(null));
assertThat(fetchModuleHierarchy).hasSize(501 + 1);
}
use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class ModuleHierarchyDownloaderTest method testInvalidResponseContent.
@Test
public void testInvalidResponseContent() {
wsClient = mock(SonarLintWsClient.class);
WsClientTestUtils.addResponse(wsClient, "api/components/tree.protobuf?qualifiers=BRC&baseComponentKey=testRoot&ps=500&p=1", "invalid response stream");
downloader = new ModuleHierarchyDownloader(wsClient);
exception.expect(IllegalStateException.class);
exception.expectMessage("Failed to process paginated WS");
downloader.fetchModuleHierarchy("testRoot", new ProgressWrapper(null));
}
use of org.sonarsource.sonarlint.core.util.ProgressWrapper in project sonarlint-core by SonarSource.
the class ModuleHierarchyDownloaderTest method testIOException.
@Test
public void testIOException() {
wsClient = mock(SonarLintWsClient.class);
WsClientTestUtils.addFailedResponse(wsClient, "api/components/tree.protobuf?qualifiers=BRC&baseComponentKey=testRoot&ps=500&p=1", 503, "error");
downloader = new ModuleHierarchyDownloader(wsClient);
exception.expect(IllegalStateException.class);
exception.expectMessage("Error 503");
downloader.fetchModuleHierarchy("testRoot", new ProgressWrapper(null));
}
Aggregations