use of org.guvnor.structure.repositories.impl.git.GitRepository in project kie-wb-common by kiegroup.
the class SocialEventRepositoryConstraintTest method setUp.
@Before
public void setUp() throws Exception {
Collection<OrganizationalUnit> ous = new ArrayList<OrganizationalUnit>();
final OrganizationalUnitImpl ou = new OrganizationalUnitImpl("ouname", "owner", "groupid");
final OrganizationalUnitImpl ouSpy = spy(ou);
Collection<Repository> repositories = new ArrayList<Repository>();
repository = new GitRepository("repo", new Space("space"));
repositories.add(repository);
ous.add(ouSpy);
when(ouSpy.getRepositories()).thenReturn(repositories);
when(organizationalUnitService.getOrganizationalUnits()).thenReturn(ous);
when(authorizationManager.authorize(ou, user)).thenReturn(true);
when(authorizationManager.authorize(repository, user)).thenReturn(true);
when(userCDIContextHelper.getUser()).thenReturn(user);
when(userCDIContextHelper.thereIsALoggedUserInScope()).thenReturn(true);
socialEventRepositoryConstraint = createSocialEventRepositoryContraint();
}
use of org.guvnor.structure.repositories.impl.git.GitRepository in project kie-wb-common by kiegroup.
the class RepositoryListServiceImplTest method setup.
@Before
public void setup() {
Set<Repository> repositories = new HashSet<Repository>();
repositories.add(new GitRepository("dora", new Space("space")));
final SocialEventRepositoryConstraint socialEventRepositoryConstraint = mock(SocialEventRepositoryConstraint.class);
when(socialEventRepositoryConstraint.getAuthorizedRepositories()).thenReturn(repositories);
service.repositoryConstraint = socialEventRepositoryConstraint;
}
use of org.guvnor.structure.repositories.impl.git.GitRepository in project kie-wb-common by kiegroup.
the class ProjectExplorerContentResolverTest method getGitRepository.
private GitRepository getGitRepository() {
final GitRepository repository = new GitRepository("alias", space);
final HashMap<String, Branch> branches = new HashMap<>();
masterBranch = new Branch("master", PathFactory.newPath("/", "file://master@module/"));
devBranch = new Branch("dev-1.0.0", PathFactory.newPath("/", "file://dev-1.0.0@module/"));
branches.put("master", masterBranch);
branches.put("dev-1.0.0", devBranch);
repository.setBranches(branches);
return repository;
}
use of org.guvnor.structure.repositories.impl.git.GitRepository in project kie-wb-common by kiegroup.
the class ExamplesServiceImpl method getProjects.
@Override
public Set<ExampleProject> getProjects(final ExampleRepository repository) {
if (repository == null) {
return Collections.emptySet();
}
final String repositoryURL = repository.getUrl();
if (repositoryURL == null || repositoryURL.trim().isEmpty()) {
return Collections.emptySet();
}
// Avoid cloning playground repository multiple times
Repository gitRepository = resolveGitRepository(repository);
if (gitRepository == null) {
return Collections.emptySet();
}
final Set<Module> modules = moduleService.getAllModules(gitRepository.getBranch("master").get());
return convert(modules);
}
use of org.guvnor.structure.repositories.impl.git.GitRepository in project kie-wb-common by kiegroup.
the class ExamplesServiceImplTest method testGetProjects_PomDescription.
@Test
public void testGetProjects_PomDescription() {
final Path moduleRoot = mock(Path.class);
final POM pom = mock(POM.class);
final KieModule module = mock(KieModule.class);
when(pom.getDescription()).thenReturn("pom description");
when(module.getRootPath()).thenReturn(moduleRoot);
when(module.getModuleName()).thenReturn("module1");
when(module.getPom()).thenReturn(pom);
when(moduleRoot.toURI()).thenReturn("default:///module1");
when(metadataService.getTags(any(Path.class))).thenReturn(Arrays.asList("tag1", "tag2"));
final GitRepository repository = makeGitRepository();
when(repositoryFactory.newRepository(any(ConfigGroup.class))).thenReturn(repository);
when(moduleService.getAllModules(any(Branch.class))).thenReturn(new HashSet<Module>() {
{
add(module);
}
});
final Set<ExampleProject> modules = service.getProjects(new ExampleRepository("https://github.com/guvnorngtestuser1/guvnorng-playground.git"));
assertNotNull(modules);
assertEquals(1, modules.size());
assertTrue(modules.contains(new ExampleProject(moduleRoot, "module1", "pom description", Arrays.asList("tag1", "tag2"))));
}
Aggregations