use of org.eclipse.winery.repository.backend.filebased.RepositoryProperties in project winery by eclipse.
the class MultiRepositoryManagerTest method testMultiRepositoryCreation.
/**
* Test whenever the initzialize method reconfigures the RepositoryFactory correctly.
*/
@Test
public void testMultiRepositoryCreation() {
ArrayList<RepositoryProperties> repositoryList = new ArrayList<>();
repositoryList.add(new RepositoryProperties("mainTestRepository", "https://github.com/winery/mulit-repo-test", "master"));
MultiRepositoryManager multiRepositoryManager = new MultiRepositoryManager();
multiRepositoryManager.initializeRepositoryListForMultiRepositoryAndReconfigureFactory(repositoryList);
assertTrue(RepositoryFactory.getRepository() instanceof MultiRepository);
}
use of org.eclipse.winery.repository.backend.filebased.RepositoryProperties in project winery by eclipse.
the class MultiRepositoryManagerTest method testGetRepositoriesAsList.
/**
* This test ckecks whenever the repository list is correctly retrieved from the json file.
*/
@Test
public void testGetRepositoriesAsList() {
writeDependencyFile();
MultiRepositoryManager multiRepositoryManager = new MultiRepositoryManager();
List<RepositoryProperties> dependencies = multiRepositoryManager.getRepositoriesAsList();
assertEquals(1, dependencies.size());
RepositoryProperties testRepoDependency = dependencies.get(0);
assertEquals("test", testRepoDependency.getName());
assertEquals("plain", testRepoDependency.getBranch());
assertEquals("https://github.com/winery/test-repository", testRepoDependency.getUrl());
}
use of org.eclipse.winery.repository.backend.filebased.RepositoryProperties in project winery by eclipse.
the class MultiRepositoryManagerTest method testRepositoryListImport.
/**
* This test checks whenever the repositories of the repositoryList are imported correctly, and whenever the
* dependencies of those repositories are also correctly imported
*/
@Test
public void testRepositoryListImport() throws UnsupportedEncodingException {
ArrayList<RepositoryProperties> repositoryList = new ArrayList<>();
repositoryList.add(new RepositoryProperties("mainTestRepository", "https://github.com/winery/mulit-repo-test", "master"));
repositoryList.add(new RepositoryProperties("standardTestRepository", "https://github.com/winery/test-repository", "plain"));
MultiRepositoryManager multiRepositoryManager = new MultiRepositoryManager();
multiRepositoryManager.addRepositoryToFile(repositoryList);
try {
assertTrue(Paths.get(Environments.getInstance().getRepositoryConfig().getRepositoryRoot(), URLEncoder.encode("https://github.com/winery", "UTF-8")).toFile().exists());
assertTrue(Paths.get(Environments.getInstance().getRepositoryConfig().getRepositoryRoot(), URLEncoder.encode("https://github.com/winery", "UTF-8"), "mulit-repo-test").toFile().exists());
assertTrue(Paths.get(Environments.getInstance().getRepositoryConfig().getRepositoryRoot(), URLEncoder.encode("https://github.com/winery", "UTF-8"), "multi-repo-dependency").toFile().exists());
assertTrue(Paths.get(Environments.getInstance().getRepositoryConfig().getRepositoryRoot(), URLEncoder.encode("https://github.com/winery", "UTF-8"), "test-repository").toFile().exists());
} catch (UnsupportedEncodingException e) {
LOGGER.error("Error while encoding.");
throw e;
}
}
use of org.eclipse.winery.repository.backend.filebased.RepositoryProperties in project winery by eclipse.
the class RepositoryAdminResource method deleteRepository.
/**
* Deletes given repository
*
* @param name of repository to delete.
*/
@DELETE
@Path("repositories/{repository}")
public Response deleteRepository(@PathParam("repository") String name) {
String repositoryUrl = "";
if (RepositoryFactory.getRepository() instanceof MultiRepository) {
IRepository gitRepo;
MultiRepositoryManager multiRepositoryManager = new MultiRepositoryManager();
for (RepositoryProperties repo : multiRepositoryManager.getRepositoriesAsList()) {
if (repo.getName().equals(name)) {
repositoryUrl = repo.getUrl();
break;
}
}
for (IRepository repo : ((MultiRepository) RepositoryFactory.getRepository()).getRepositories()) {
gitRepo = repo;
if (gitRepo instanceof GitBasedRepository) {
if (((GitBasedRepository) gitRepo).getRepositoryUrl() != null) {
if (((GitBasedRepository) gitRepo).getRepositoryUrl().equals(repositoryUrl)) {
((GitBasedRepository) gitRepo).forceClear();
((MultiRepository) RepositoryFactory.getRepository()).removeRepository(repositoryUrl);
break;
}
}
}
}
}
return Response.ok().build();
}
use of org.eclipse.winery.repository.backend.filebased.RepositoryProperties in project winery by eclipse.
the class MultiRepositoryManagerTest method testInitializeRepositoryList.
/**
* Tests whenever a file is created for the repository list in the root folder.
*/
@Test
public void testInitializeRepositoryList() throws IOException {
ArrayList<RepositoryProperties> repositoryList = new ArrayList<>();
repositoryList.add(new RepositoryProperties("mainTestRepository", "https://github.com/winery/mulit-repo-test", "master"));
MultiRepositoryManager multiRepositoryManager = new MultiRepositoryManager();
multiRepositoryManager.initializeRepositoryListForMultiRepositoryAndReconfigureFactory(repositoryList);
assertTrue(Paths.get(Environments.getInstance().getRepositoryConfig().getRepositoryRoot(), Filename.FILENAME_JSON_MUTLI_REPOSITORIES).toFile().exists());
ObjectMapper objectMapper = new ObjectMapper();
ObjectReader reader = objectMapper.readerFor(new TypeReference<List<RepositoryProperties>>() {
});
repositoryList = reader.readValue(Paths.get(Environments.getInstance().getRepositoryConfig().getRepositoryRoot(), Filename.FILENAME_JSON_MUTLI_REPOSITORIES).toFile());
assertEquals(1, repositoryList.size());
assertEquals("https://github.com/winery/mulit-repo-test", repositoryList.get(0).getUrl());
assertEquals("master", repositoryList.get(0).getBranch());
assertEquals("mainTestRepository", repositoryList.get(0).getName());
}
Aggregations