Fix unit tests after rebase

This commit is contained in:
René Pfeuffer
2021-02-25 14:25:37 +01:00
parent e2cd0a8eeb
commit d4c5436c4c
4 changed files with 9 additions and 33 deletions

View File

@@ -134,5 +134,6 @@ class IndexDtoGeneratorTest {
when(resourceLinks.namespaceStrategies()).thenReturn(new ResourceLinks.NamespaceStrategiesLinks(scmPathInfo));
when(resourceLinks.namespaceCollection()).thenReturn(new ResourceLinks.NamespaceCollectionLinks(scmPathInfo));
when(resourceLinks.me()).thenReturn(new ResourceLinks.MeLinks(scmPathInfo, new ResourceLinks.UserLinks(scmPathInfo)));
when(resourceLinks.repository()).thenReturn(new ResourceLinks.RepositoryLinks(scmPathInfo));
}
}

View File

@@ -517,7 +517,6 @@ public class RepositoryRootResourceTest extends RepositoryTestBase {
BundleCommandBuilder bundleCommandBuilder = mock(BundleCommandBuilder.class);
when(service.getBundleCommand()).thenReturn(bundleCommandBuilder);
when(bundleCommandBuilder.getFileExtension()).thenReturn(".bundle");
MockHttpRequest request = MockHttpRequest
.get("/" + RepositoryRootResource.REPOSITORIES_PATH_V2 + "space/repo/export/svn");
@@ -539,7 +538,6 @@ public class RepositoryRootResourceTest extends RepositoryTestBase {
BundleCommandBuilder bundleCommandBuilder = mock(BundleCommandBuilder.class);
when(service.getBundleCommand()).thenReturn(bundleCommandBuilder);
when(bundleCommandBuilder.getFileExtension()).thenReturn(".bundle");
MockHttpRequest request = MockHttpRequest
.get("/" + RepositoryRootResource.REPOSITORIES_PATH_V2 + "space/repo/export/svn?compressed=true");
@@ -577,9 +575,6 @@ public class RepositoryRootResourceTest extends RepositoryTestBase {
when(manager.get(new NamespaceAndName(namespace, name))).thenReturn(repository);
mockRepositoryHandler(ImmutableSet.of(Command.BUNDLE));
BundleCommandBuilder bundleCommandBuilder = mock(BundleCommandBuilder.class);
when(service.getBundleCommand()).thenReturn(bundleCommandBuilder);
MockHttpRequest request = MockHttpRequest
.post("/" + RepositoryRootResource.REPOSITORIES_PATH_V2 + "space/repo/export/full")
.contentType(VndMediaType.REPOSITORY_EXPORT)
@@ -602,9 +597,6 @@ public class RepositoryRootResourceTest extends RepositoryTestBase {
when(manager.get(new NamespaceAndName(namespace, name))).thenReturn(repository);
mockRepositoryHandler(ImmutableSet.of(Command.BUNDLE));
BundleCommandBuilder bundleCommandBuilder = mock(BundleCommandBuilder.class);
when(service.getBundleCommand()).thenReturn(bundleCommandBuilder);
MockHttpRequest request = MockHttpRequest
.post("/" + RepositoryRootResource.REPOSITORIES_PATH_V2 + "space/repo/export/full")
.contentType(VndMediaType.REPOSITORY_EXPORT)
@@ -625,9 +617,6 @@ public class RepositoryRootResourceTest extends RepositoryTestBase {
when(manager.get(new NamespaceAndName(namespace, name))).thenReturn(repository);
mockRepositoryHandler(ImmutableSet.of(Command.BUNDLE));
BundleCommandBuilder bundleCommandBuilder = mock(BundleCommandBuilder.class);
when(service.getBundleCommand()).thenReturn(bundleCommandBuilder);
when(exportService.isExporting(repository)).thenReturn(true);
MockHttpRequest request = MockHttpRequest
@@ -642,19 +631,13 @@ public class RepositoryRootResourceTest extends RepositoryTestBase {
}
@Test
public void shouldDeleteRepositoryExport() throws URISyntaxException, IOException {
public void shouldDeleteRepositoryExport() throws URISyntaxException {
String namespace = "space";
String name = "repo";
Repository repository = createRepository(namespace, name, "svn");
when(manager.get(new NamespaceAndName(namespace, name))).thenReturn(repository);
mockRepositoryHandler(ImmutableSet.of(Command.BUNDLE));
BundleCommandBuilder bundleCommandBuilder = mock(BundleCommandBuilder.class);
when(service.getBundleCommand()).thenReturn(bundleCommandBuilder);
when(exportService.isExporting(repository)).thenReturn(false);
when(exportService.getData(repository)).thenReturn(new ByteArrayInputStream("".getBytes()));
MockHttpRequest request = MockHttpRequest
.delete("/" + RepositoryRootResource.REPOSITORIES_PATH_V2 + "space/repo/export");
MockHttpResponse response = new MockHttpResponse();
@@ -673,9 +656,6 @@ public class RepositoryRootResourceTest extends RepositoryTestBase {
when(manager.get(new NamespaceAndName(namespace, name))).thenReturn(repository);
mockRepositoryHandler(ImmutableSet.of(Command.BUNDLE));
BundleCommandBuilder bundleCommandBuilder = mock(BundleCommandBuilder.class);
when(service.getBundleCommand()).thenReturn(bundleCommandBuilder);
when(exportService.isExporting(repository)).thenReturn(false);
doThrow(NotFoundException.class).when(exportService).checkExportIsAvailable(repository);
@@ -697,9 +677,6 @@ public class RepositoryRootResourceTest extends RepositoryTestBase {
when(manager.get(new NamespaceAndName(namespace, name))).thenReturn(repository);
mockRepositoryHandler(ImmutableSet.of(Command.BUNDLE));
BundleCommandBuilder bundleCommandBuilder = mock(BundleCommandBuilder.class);
when(service.getBundleCommand()).thenReturn(bundleCommandBuilder);
when(exportService.isExporting(repository)).thenReturn(true);
MockHttpRequest request = MockHttpRequest
@@ -719,9 +696,6 @@ public class RepositoryRootResourceTest extends RepositoryTestBase {
when(manager.get(new NamespaceAndName(namespace, name))).thenReturn(repository);
mockRepositoryHandler(ImmutableSet.of(Command.BUNDLE));
BundleCommandBuilder bundleCommandBuilder = mock(BundleCommandBuilder.class);
when(service.getBundleCommand()).thenReturn(bundleCommandBuilder);
when(exportService.isExporting(repository)).thenReturn(false);
when(exportService.getData(repository)).thenReturn(new ByteArrayInputStream("content".getBytes()));
when(exportService.getFileExtension(repository)).thenReturn("tar.gz.enc");
@@ -744,9 +718,6 @@ public class RepositoryRootResourceTest extends RepositoryTestBase {
when(manager.get(new NamespaceAndName(namespace, name))).thenReturn(repository);
mockRepositoryHandler(ImmutableSet.of(Command.BUNDLE));
BundleCommandBuilder bundleCommandBuilder = mock(BundleCommandBuilder.class);
when(service.getBundleCommand()).thenReturn(bundleCommandBuilder);
RepositoryExportInformationDto dto = new RepositoryExportInformationDto();
dto.setExporterName("trillian");
dto.setCreated(Instant.ofEpochMilli(100));

View File

@@ -164,6 +164,7 @@ class FromUrlImporterTest {
PullCommandBuilder pullCommandBuilder = mock(PullCommandBuilder.class, RETURNS_SELF);
when(service.getPullCommand()).thenReturn(pullCommandBuilder);
doThrow(TestException.class).when(pullCommandBuilder).pull(anyString());
when(logger.started()).thenReturn(true);
FromUrlImporter.RepositoryImportParameters parameters = new FromUrlImporter.RepositoryImportParameters();
parameters.setImportUrl("https://scm-manager.org/scm/repo/scmadmin/scm-manager.git");

View File

@@ -38,6 +38,7 @@ import sonia.scm.store.InMemoryBlobStoreFactory;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -125,9 +126,11 @@ class RepositoryImportLoggerFactoryTest {
@SuppressWarnings("UnstableApiUsage")
private void createLog() throws IOException {
Blob blob = store.create("42");
Resources.copy(
Resources.getResource("sonia/scm/importexport/importLog.blob"),
blob.getOutputStream());
try (OutputStream outputStream = blob.getOutputStream()) {
Resources.copy(
Resources.getResource("sonia/scm/importexport/importLog.blob"),
outputStream);
}
blob.commit();
}
}