use of org.kie.workbench.common.screens.examples.model.ExampleRepository in project kie-wb-common by kiegroup.
the class ExamplesServiceImplTest method testGetProjects_EmptyRepositoryUrl.
@Test
public void testGetProjects_EmptyRepositoryUrl() {
final Set<ExampleProject> modules = service.getProjects(new ExampleRepository(""));
assertNotNull(modules);
assertEquals(0, modules.size());
}
use of org.kie.workbench.common.screens.examples.model.ExampleRepository 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.kie.workbench.common.screens.examples.model.ExampleRepository 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.kie.workbench.common.screens.examples.model.ExampleRepository in project kie-wb-common by kiegroup.
the class ExamplesServiceImplTest method testGetProjects_WhiteSpaceRepositoryUrl.
@Test
public void testGetProjects_WhiteSpaceRepositoryUrl() {
final Set<ExampleProject> modules = service.getProjects(new ExampleRepository(" "));
assertNotNull(modules);
assertEquals(0, modules.size());
}
use of org.kie.workbench.common.screens.examples.model.ExampleRepository 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"))));
}
Aggregations