Introduce abstraction for repository location

This commit is contained in:
René Pfeuffer
2019-05-09 14:08:18 +02:00
parent d29fa32c8e
commit c44d38cc61
15 changed files with 133 additions and 63 deletions

View File

@@ -2,6 +2,7 @@ package sonia.scm.protocolcommand.git;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
@@ -16,6 +17,7 @@ import java.io.IOException;
import java.nio.file.Path;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@@ -25,7 +27,7 @@ class GitRepositoryContextResolverTest {
@Mock
RepositoryManager repositoryManager;
@Mock
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
RepositoryLocationResolver locationResolver;
@InjectMocks
@@ -35,7 +37,7 @@ class GitRepositoryContextResolverTest {
void shouldResolveCorrectRepository() throws IOException {
when(repositoryManager.get(new NamespaceAndName("space", "X"))).thenReturn(REPOSITORY);
Path repositoryPath = File.createTempFile("test", "scm").toPath();
when(locationResolver.getPath("id")).thenReturn(repositoryPath);
when(locationResolver.forClass(any()).getLocation("id")).thenReturn(repositoryPath);
RepositoryContext context = resolver.resolve(new String[] {"git", "repo/space/X/something/else"});