Search in sources :

Example 6 with ExampleRepository

use of org.kie.workbench.common.screens.examples.model.ExampleRepository in project kie-wb-common by kiegroup.

the class SourceRepositoryPage method isComplete.

@Override
public void isComplete(final Callback<Boolean> callback) {
    final ExampleRepository selectedRepository = model.getSelectedRepository();
    callback.callback(validateUrl(selectedRepository));
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository)

Example 7 with ExampleRepository

use of org.kie.workbench.common.screens.examples.model.ExampleRepository in project kie-wb-common by kiegroup.

the class SourceRepositoryPageTest method testIsComplete_ValidRepositoryUrl.

@Test
@SuppressWarnings("unchecked")
public void testIsComplete_ValidRepositoryUrl() {
    final ExampleRepository repository = new ExampleRepository(EXAMPLE_REPOSITORY);
    model.setSelectedRepository(repository);
    final Callback<Boolean> callback = mock(Callback.class);
    page.isComplete(callback);
    verify(callback, times(1)).callback(eq(true));
    verify(view, times(1)).setUrlGroupType(eq(ValidationState.NONE));
    verify(view, times(1)).hideUrlHelpMessage();
    assertTrue(repository.isUrlValid());
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Test(org.junit.Test)

Example 8 with ExampleRepository

use of org.kie.workbench.common.screens.examples.model.ExampleRepository in project kie-wb-common by kiegroup.

the class SourceRepositoryPageTest method testIsComplete_EmptyRepositoryUrl.

@Test
@SuppressWarnings("unchecked")
public void testIsComplete_EmptyRepositoryUrl() {
    final ExampleRepository repository = new ExampleRepository("");
    model.setSelectedRepository(repository);
    final Callback<Boolean> callback = mock(Callback.class);
    page.isComplete(callback);
    verify(callback, times(1)).callback(eq(false));
    verify(view, times(1)).setUrlGroupType(eq(ValidationState.ERROR));
    verify(view, times(1)).showUrlHelpMessage(any(String.class));
    assertFalse(repository.isUrlValid());
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Test(org.junit.Test)

Example 9 with ExampleRepository

use of org.kie.workbench.common.screens.examples.model.ExampleRepository in project kie-wb-common by kiegroup.

the class LibraryServiceImpl method getExampleProjects.

@Override
public Set<ExampleProject> getExampleProjects() {
    final String importProjectsUrl = getCustomImportProjectsUrl();
    final ExampleRepository repository = importProjectsUrl == null || importProjectsUrl.isEmpty() ? examplesService.getPlaygroundRepository() : new ExampleRepository(importProjectsUrl);
    final Set<ExampleProject> projects = examplesService.getProjects(repository);
    return projects;
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject)

Example 10 with ExampleRepository

use of org.kie.workbench.common.screens.examples.model.ExampleRepository in project kie-wb-common by kiegroup.

the class LibraryServiceImplTest method getCustomExampleProjectsTest.

@Test
public void getCustomExampleProjectsTest() {
    System.setProperty("org.kie.project.examples.repository.url", "importProjectsUrl");
    final Set<ExampleProject> exampleProjects = new HashSet<>();
    exampleProjects.add(mock(ExampleProject.class));
    doReturn(exampleProjects).when(examplesService).getProjects(new ExampleRepository("importProjectsUrl"));
    final Set<ExampleProject> loadedExampleProjects = libraryService.getExampleProjects();
    assertEquals(exampleProjects, loadedExampleProjects);
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)27 Test (org.junit.Test)19 ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)11 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)6 ConfigGroup (org.guvnor.structure.server.config.ConfigGroup)6 Module (org.guvnor.common.services.project.model.Module)4 Branch (org.guvnor.structure.repositories.Branch)3 Repository (org.guvnor.structure.repositories.Repository)3 KieModule (org.kie.workbench.common.services.shared.project.KieModule)3 Path (org.uberfire.backend.vfs.Path)3 HashSet (java.util.HashSet)2 ConfigType (org.guvnor.structure.server.config.ConfigType)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 ZipEntry (java.util.zip.ZipEntry)1 ZipInputStream (java.util.zip.ZipInputStream)1 PostConstruct (javax.annotation.PostConstruct)1 Git (org.eclipse.jgit.api.Git)1