Search in sources :

Example 1 with HttpDownloader

use of org.sonar.api.utils.HttpDownloader in project sonarqube by SonarSource.

the class PluginDownloaderTest method before.

@Before
public void before() throws Exception {
    updateCenterMatrixFactory = mock(UpdateCenterMatrixFactory.class);
    updateCenter = mock(UpdateCenter.class);
    when(updateCenterMatrixFactory.getUpdateCenter(anyBoolean())).thenReturn(Optional.of(updateCenter));
    httpDownloader = mock(HttpDownloader.class);
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock inv) throws Throwable {
            File toFile = (File) inv.getArguments()[1];
            touch(toFile);
            return null;
        }
    }).when(httpDownloader).download(any(URI.class), any(File.class));
    ServerFileSystem fs = mock(ServerFileSystem.class);
    downloadDir = testFolder.newFolder("downloads");
    when(fs.getDownloadedPluginsDir()).thenReturn(downloadDir);
    pluginDownloader = new PluginDownloader(updateCenterMatrixFactory, httpDownloader, fs);
}
Also used : ServerFileSystem(org.sonar.server.platform.ServerFileSystem) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) UpdateCenter(org.sonar.updatecenter.common.UpdateCenter) HttpDownloader(org.sonar.api.utils.HttpDownloader) InvocationOnMock(org.mockito.invocation.InvocationOnMock) File(java.io.File) URI(java.net.URI) Before(org.junit.Before)

Aggregations

File (java.io.File)1 URI (java.net.URI)1 Before (org.junit.Before)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1 HttpDownloader (org.sonar.api.utils.HttpDownloader)1 ServerFileSystem (org.sonar.server.platform.ServerFileSystem)1 UpdateCenter (org.sonar.updatecenter.common.UpdateCenter)1