Introduce extension point for further protocol implementations

This commit is contained in:
René Pfeuffer
2018-09-13 10:35:10 +02:00
parent 7c76f7a699
commit 145502a7b8
19 changed files with 137 additions and 153 deletions

View File

@@ -30,8 +30,8 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static java.util.stream.Stream.of;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT;
@@ -281,7 +281,7 @@ public class RepositoryRootResourceTest {
@Test
public void shouldCreateArrayOfProtocolUrls() throws Exception {
mockRepository("space", "repo");
when(service.getSupportedProtocols()).thenReturn(asList(new MockScmProtocol("http", "http://"), new MockScmProtocol("ssh", "ssh://")));
when(service.getSupportedProtocols()).thenReturn(of(new MockScmProtocol("http", "http://"), new MockScmProtocol("ssh", "ssh://")));
MockHttpRequest request = MockHttpRequest.get("/" + RepositoryRootResource.REPOSITORIES_PATH_V2 + "space/repo");
MockHttpResponse response = new MockHttpResponse();

View File

@@ -20,9 +20,8 @@ import sonia.scm.repository.api.ScmProtocol;
import java.net.URI;
import static java.util.Arrays.asList;
import static java.util.Collections.emptySet;
import static java.util.Collections.singletonList;
import static java.util.stream.Stream.of;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -60,7 +59,7 @@ public class RepositoryToRepositoryDtoMapperTest {
initMocks(this);
when(serviceFactory.create(any(Repository.class))).thenReturn(repositoryService);
when(repositoryService.isSupported(any(Command.class))).thenReturn(true);
when(repositoryService.getSupportedProtocols()).thenReturn(emptySet());
when(repositoryService.getSupportedProtocols()).thenReturn(of());
when(scmPathInfoStore.get()).thenReturn(uriInfo);
when(uriInfo.getApiRestUri()).thenReturn(URI.create("/x/y"));
}
@@ -182,7 +181,7 @@ public class RepositoryToRepositoryDtoMapperTest {
@Test
public void shouldCreateCorrectProtocolLinks() {
when(repositoryService.getSupportedProtocols()).thenReturn(
asList(mockProtocol("http", "http://scm"), mockProtocol("other", "some://protocol"))
of(mockProtocol("http", "http://scm"), mockProtocol("other", "some://protocol"))
);
RepositoryDto dto = mapper.map(createTestRepository());
@@ -194,7 +193,7 @@ public class RepositoryToRepositoryDtoMapperTest {
@SubjectAware(username = "community")
public void shouldCreateProtocolLinksForPullPermission() {
when(repositoryService.getSupportedProtocols()).thenReturn(
asList(mockProtocol("http", "http://scm"), mockProtocol("other", "some://protocol"))
of(mockProtocol("http", "http://scm"), mockProtocol("other", "some://protocol"))
);
RepositoryDto dto = mapper.map(createTestRepository());
@@ -205,7 +204,7 @@ public class RepositoryToRepositoryDtoMapperTest {
@SubjectAware(username = "unpriv")
public void shouldNotCreateProtocolLinksWithoutPullPermission() {
when(repositoryService.getSupportedProtocols()).thenReturn(
asList(mockProtocol("http", "http://scm"), mockProtocol("other", "some://protocol"))
of(mockProtocol("http", "http://scm"), mockProtocol("other", "some://protocol"))
);
RepositoryDto dto = mapper.map(createTestRepository());