re implement XmlRepositoryDAO

This commit is contained in:
Sebastian Sdorra
2018-11-28 19:49:55 +01:00
parent d4db39755f
commit e9401624a7
26 changed files with 1019 additions and 369 deletions

View File

@@ -45,6 +45,7 @@ public final class RepositoryTestData {
.type(type)
.contact("douglas.adams@hitchhiker.com")
.name("42Puzzle")
.namespace("hitchhiker")
.description("The 42 Puzzle")
.build();
}
@@ -59,6 +60,7 @@ public final class RepositoryTestData {
.type(type)
.contact("zaphod.beeblebrox@hitchhiker.com")
.name("happyVerticalPeopleTransporter")
.namespace("hitchhiker")
.description("Happy Vertical People Transporter")
.build();
}
@@ -72,6 +74,7 @@ public final class RepositoryTestData {
.type(type)
.contact("zaphod.beeblebrox@hitchhiker.com")
.name("HeartOfGold")
.namespace("hitchhiker")
.description(
"Heart of Gold is the first prototype ship to successfully utilise the revolutionary Infinite Improbability Drive")
.build();
@@ -87,6 +90,7 @@ public final class RepositoryTestData {
.type(type)
.contact("douglas.adams@hitchhiker.com")
.name("RestaurantAtTheEndOfTheUniverse")
.namespace("hitchhiker")
.description("The Restaurant at the End of the Universe")
.build();
}

View File

@@ -45,6 +45,7 @@ import java.nio.file.Path;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -63,7 +64,7 @@ public abstract class SimpleRepositoryHandlerTestBase extends AbstractTestBase {
protected abstract void checkDirectory(File directory);
protected abstract RepositoryHandler createRepositoryHandler(
ConfigurationStoreFactory factory, File directory) throws IOException, RepositoryPathNotFoundException;
ConfigurationStoreFactory factory, RepositoryLocationResolver locationResolver, File directory) throws IOException, RepositoryPathNotFoundException;
@Test
public void testCreate() {
@@ -75,7 +76,15 @@ public abstract class SimpleRepositoryHandlerTestBase extends AbstractTestBase {
InMemoryConfigurationStoreFactory storeFactory = new InMemoryConfigurationStoreFactory();
baseDirectory = new File(contextProvider.getBaseDirectory(), "repositories");
IOUtil.mkdirs(baseDirectory);
handler = createRepositoryHandler(storeFactory, baseDirectory);
locationResolver = mock(RepositoryLocationResolver.class);
when(locationResolver.getPath(anyString())).then(ic -> {
String id = ic.getArgument(0);
return baseDirectory.toPath().resolve(id);
});
handler = createRepositoryHandler(storeFactory, locationResolver, baseDirectory);
}
@Override
@@ -105,6 +114,7 @@ public abstract class SimpleRepositoryHandlerTestBase extends AbstractTestBase {
}
protected File baseDirectory;
protected RepositoryLocationResolver locationResolver;
private RepositoryHandler handler;
}

View File

@@ -55,6 +55,7 @@ import static org.mockito.Mockito.*;
import java.io.File;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
@@ -213,6 +214,10 @@ public final class MockUtil
SCMContextProvider provider = mock(SCMContextProvider.class);
when(provider.getBaseDirectory()).thenReturn(directory);
when(provider.resolve(any(Path.class))).then(ic -> {
Path p = ic.getArgument(0);
return directory.toPath().resolve(p);
});
return provider;
}