package com.cadrlife.devsearch.agent.service; import static org.junit.Assert.*; import java.util.Properties; import com.cadrlife.devsearch.agent.service.filesystem.FileSystemService; import com.cadrlife.devsearch.agent.service.git.GithubOrgRepoService; //import com.cadrlife.devsearch.agent.service.sqlserver.SqlServerService; import com.cadrlife.devsearch.agent.service.git.GithubUserRepoService; import org.junit.Ignore; import org.junit.Test; import static org.mockito.Mockito.*; import com.cadrlife.devsearch.agent.service.cvs.CvsServiceProvider; import com.cadrlife.devsearch.agent.service.git.GitStashService; import com.cadrlife.devsearch.cvsnavigator.CvsCredentials; public class RepoCreatorTest { Properties properties = new Properties(); RepoCreator repoCreator = new RepoCreator(properties, "/checkout"); @Test public void parseCvsRepo() { repoCreator.cvsServiceProvider = mock(CvsServiceProvider.class); RepoService cvsService = mock(RepoService.class); when(repoCreator.cvsServiceProvider.provide(any(CvsCredentials.class), eq("/tmp"), eq("/checkout"), eq("mycvs"))) .thenReturn(cvsService); properties.setProperty("cvs.temp.dir", "/tmp"); properties.put("repo.mycvs.type", "cvs"); properties.put("repo.mycvs.cvsroot", "/myroot"); properties.put("repo.mycvs.password", "mypass"); assertSame(cvsService, repoCreator.createService("mycvs")); } // @Ignore // @Test // public void parseControlmRepo() { // properties.put("repo.controlm.type", "sqlserver"); // properties.put("repo.controlm.url", "myurl"); // properties.put("repo.controlm.username", "myuser"); // properties.put("repo.controlm.password", "mypass"); // SqlServerService service = (SqlServerService) repoCreator.createService("controlm"); // assertEquals("sqlserver", service.getSourceType()); // assertEquals("controlm", service.getRepoName()); // } @Test public void parseStashRepo() { properties.put("reposource.stash.type", "stash"); properties.put("reposource.stash.prefix", "Stash-"); properties.put("reposource.stash.username", "myuser"); properties.put("reposource.stash.password", "mypass"); properties.put("reposource.stash.api.base.url", "a.b.c"); GitStashService service = (GitStashService) repoCreator.createService("Stash-PS"); assertEquals("stash", service.getSourceType()); assertEquals("Stash-PS", service.getRepoName()); // assertEquals("PS", descriptor.getStashProjectKey()); } @Test public void parseGithubUserRepo() { properties.put("reposource.githubuser.type", "githubuser"); properties.put("reposource.githubuser.prefix", "GitHubUser-"); GithubUserRepoService service = (GithubUserRepoService) repoCreator.createService("GitHubUser-raymyers"); assertEquals("github", service.getSourceType()); assertEquals("GitHubUser-raymyers", service.getRepoName()); } @Test public void parseGithubOrgRepo() { properties.put("reposource.githubuser.type", "githuborg"); properties.put("reposource.githubuser.prefix", "GitHubOrg-"); GithubOrgRepoService service = (GithubOrgRepoService) repoCreator.createService("GitHubOrg-SpringSource"); assertEquals("github", service.getSourceType()); assertEquals("GitHubOrg-SpringSource", service.getRepoName()); } @Test public void parseFilesystemRepo() { properties.put("repo.PhoenixFitnesse.type", "filesystem"); properties.put("repo.PhoenixFitnesse.path", "\\\\carfax.cfx\\cfxgroups\\Product_Services\\Product_Web\\PhoenixFit"); properties.put("repo.PhoenixFitnesse.ignore", "ErrorLogs,testResults"); FileSystemService service = (FileSystemService) repoCreator.createService("PhoenixFitnesse"); assertEquals("filesystem", service.getSourceType()); assertEquals("PhoenixFitnesse", service.getRepoName()); // assertEquals("PS", descriptor.getStashProjectKey()); } }