use of org.guvnor.structure.repositories.impl.git.GitRepository in project kie-wb-common by kiegroup.
the class ExamplesServiceImplTest method testGetProjects_CustomDescription.
@Test
public void testGetProjects_CustomDescription() {
final Path moduleRoot = mock(Path.class);
final KieModule module = mock(KieModule.class);
when(module.getRootPath()).thenReturn(moduleRoot);
when(module.getModuleName()).thenReturn("module1");
when(moduleRoot.toURI()).thenReturn("default:///module1");
when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(true);
when(ioService.readAllString(any(org.uberfire.java.nio.file.Path.class))).thenReturn("This is custom description.\n\n This is a new line.");
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", "This is custom description. This is a new line.", Arrays.asList("tag1", "tag2"))));
}
use of org.guvnor.structure.repositories.impl.git.GitRepository in project kie-wb-common by kiegroup.
the class ExamplesServiceImplTest method resolveGitRepositoryClonedBefore.
@Test
public void resolveGitRepositoryClonedBefore() {
ExampleRepository playgroundRepository = new ExampleRepository("file:///home/user/folder/.kie-wb-playground");
service.setPlaygroundRepository(playgroundRepository);
GitRepository repository = mock(GitRepository.class);
Map<String, Object> repositoryEnvironment = new HashMap<>();
repositoryEnvironment.put("origin", playgroundRepository.getUrl());
when(repository.getEnvironment()).thenReturn(repositoryEnvironment);
service.getClonedRepositories().add(repository);
Repository result = service.resolveGitRepository(playgroundRepository);
assertEquals(repository, result);
verify(repositoryFactory, never()).newRepository(any(ConfigGroup.class));
}
use of org.guvnor.structure.repositories.impl.git.GitRepository in project kie-wb-common by kiegroup.
the class ExamplesServiceImplTest method testGetProjects_DefaultDescription.
@Test
public void testGetProjects_DefaultDescription() {
final Path moduleRoot = mock(Path.class);
final KieModule module = mock(KieModule.class);
when(module.getRootPath()).thenReturn(moduleRoot);
when(module.getModuleName()).thenReturn("module1");
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);
}
});
service.setPlaygroundRepository(mock(ExampleRepository.class));
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", "Example 'module1' module", Arrays.asList("tag1", "tag2"))));
}
use of org.guvnor.structure.repositories.impl.git.GitRepository in project kie-wb-common by kiegroup.
the class SocialEventModuleConstraintTest 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);
socialEventModuleConstraint = createSocialEventModuleConstraint();
}
Aggregations