Search in sources :

Example 6 with FolderListing

use of org.kie.workbench.common.screens.explorer.model.FolderListing in project kie-wb-common by kiegroup.

the class ProjectExplorerContentResolverDefaultSelectionsTest method setUp.

@Before
public void setUp() throws Exception {
    // Ensure URLs use the default:// scheme
    fs.forceAsDefault();
    final KieModuleService moduleService = mock(KieModuleService.class);
    final ExplorerServiceHelper helper = mock(ExplorerServiceHelper.class);
    final ExplorerServiceHelper explorerServiceHelper = mock(ExplorerServiceHelper.class);
    repository1 = getGitRepository("repo1");
    repository2 = getGitRepository("repo2");
    repository1Module1 = createModule("master", "r1p1");
    repository1Modules = new HashSet<Module>() {

        {
            add(repository1Module1);
        }
    };
    repository2Module1 = createModule("master", "r2p1");
    repository2Modules = new HashSet<Module>() {

        {
            add(repository2Module1);
        }
    };
    userExplorerData = new UserExplorerData();
    helperWrapper = new HelperWrapper(helper);
    when(helper.getLastContent()).thenAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
            return helperWrapper.getUserExplorerLastData();
        }
    });
    when(helper.loadUserContent()).thenReturn(userExplorerData);
    when(helper.getFolderListing(any(FolderItem.class), any(Module.class), any(Package.class), any(ActiveOptions.class))).thenReturn(new FolderListing(createFileItem(), Collections.EMPTY_LIST, Collections.EMPTY_LIST));
    when(moduleService.getAllModules(repository1.getDefaultBranch().get())).thenReturn(repository1Modules);
    when(moduleService.getAllModules(repository2.getDefaultBranch().get())).thenReturn(repository2Modules);
    doReturn(createPackage("master", repository1Module1.getModuleName())).when(moduleService).resolveDefaultPackage(repository1Module1);
    doReturn(createPackage("master", repository2Module1.getModuleName())).when(moduleService).resolveDefaultPackage(repository2Module1);
    resolver = new ProjectExplorerContentResolver(moduleService, helper, explorerServiceHelper, projectService);
}
Also used : ActiveOptions(org.kie.workbench.common.screens.explorer.service.ActiveOptions) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) FolderListing(org.kie.workbench.common.screens.explorer.model.FolderListing) FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Package(org.guvnor.common.services.project.model.Package) Module(org.guvnor.common.services.project.model.Module) Before(org.junit.Before)

Example 7 with FolderListing

use of org.kie.workbench.common.screens.explorer.model.FolderListing in project kie-wb-common by kiegroup.

the class ProjectExplorerContentResolverTest method setUp.

@Before
public void setUp() throws Exception {
    // Ensure URLs use the default:// scheme
    fs.forceAsDefault();
    final KieModuleService moduleService = mock(KieModuleService.class);
    final ExplorerServiceHelper helper = mock(ExplorerServiceHelper.class);
    space = new Space("test-realm");
    repository = getGitRepository();
    final UserExplorerData userExplorerData = new UserExplorerData();
    masterModules = new HashSet<>();
    masterModules.add(createModule("master", masterBranch, "module 1"));
    masterModules.add(createModule("master", masterBranch, "module 2"));
    devModules = new HashSet<>();
    devModules.add(createModule("dev-1.0.0", devBranch, "module 1"));
    devModules.add(createModule("dev-1.0.0", devBranch, "module 2"));
    helperWrapper = new HelperWrapper(helper);
    when(helper.getLastContent()).thenAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
            return helperWrapper.getUserExplorerLastData();
        }
    });
    when(helper.loadUserContent()).thenReturn(userExplorerData);
    when(helper.getFolderListing(any(FolderItem.class), any(Module.class), any(Package.class), any(ActiveOptions.class))).thenReturn(new FolderListing(getFileItem(), Collections.EMPTY_LIST, Collections.EMPTY_LIST));
    when(moduleService.getAllModules(masterBranch)).thenReturn(masterModules);
    when(moduleService.getAllModules(devBranch)).thenReturn(devModules);
    when(moduleService.resolveDefaultPackage(any(Module.class))).thenReturn(new Package());
    resolver = spy(new ProjectExplorerContentResolver(moduleService, helper, explorerServiceHelper, projectService));
}
Also used : Space(org.uberfire.spaces.Space) ActiveOptions(org.kie.workbench.common.screens.explorer.service.ActiveOptions) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) FolderListing(org.kie.workbench.common.screens.explorer.model.FolderListing) FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Package(org.guvnor.common.services.project.model.Package) Module(org.guvnor.common.services.project.model.Module) Before(org.junit.Before)

Example 8 with FolderListing

use of org.kie.workbench.common.screens.explorer.model.FolderListing in project kie-wb-common by kiegroup.

the class BaseViewPresenter method filterByTag.

protected void filterByTag(String tag) {
    currentTag = tag;
    List<FolderItem> filteredItems = new ArrayList<FolderItem>();
    for (FolderItem item : activeContextItems.getActiveContent().getContent()) {
        if (tag == null || item.getTags().contains(tag) || item.getType().equals(FolderItemType.FOLDER)) {
            filteredItems.add(item);
        }
    }
    FolderListing filteredContent = new FolderListing(activeContextItems.getActiveContent().getItem(), filteredItems, activeContextItems.getActiveContent().getSegments());
    baseView.renderItems(filteredContent);
}
Also used : FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) ArrayList(java.util.ArrayList) FolderListing(org.kie.workbench.common.screens.explorer.model.FolderListing)

Example 9 with FolderListing

use of org.kie.workbench.common.screens.explorer.model.FolderListing in project kie-wb-common by kiegroup.

the class BaseBreadcrumbNavigatorTest method testLoadContentOnlyFile.

@Test
public void testLoadContentOnlyFile() {
    final BreadcrumbNavigator navigator = spy(new BreadcrumbNavigator(activeOptions, hiddenTypeDef, user));
    final FolderItem item = new FolderItem(path, "item1", FolderItemType.FILE);
    final List<FolderItem> content = new ArrayList<FolderItem>() {

        {
            add(new FolderItem(mock(Path.class), "File1", FolderItemType.FILE));
        }
    };
    final List<FolderItem> segments = new ArrayList<FolderItem>();
    final FolderListing listing = new FolderListing(item, content, segments);
    navigator.loadContent(listing);
    verify(navigator).setupBreadcrumb(listing);
    verify(navigator).setupUpFolder(listing);
    verify(navigator).setupContent(listing);
    verifyNavigatorPanelVisibility(navigator);
}
Also used : FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) ArrayList(java.util.ArrayList) FolderListing(org.kie.workbench.common.screens.explorer.model.FolderListing) Test(org.junit.Test)

Example 10 with FolderListing

use of org.kie.workbench.common.screens.explorer.model.FolderListing in project kie-wb-common by kiegroup.

the class BaseBreadcrumbNavigatorTest method testLoadContentEmpty.

@Test
public void testLoadContentEmpty() {
    final BreadcrumbNavigator navigator = spy(new BreadcrumbNavigator(activeOptions, hiddenTypeDef, user));
    final FolderItem item = new FolderItem(path, "item1", FolderItemType.FILE);
    final List<FolderItem> content = new ArrayList<FolderItem>();
    final List<FolderItem> segments = new ArrayList<FolderItem>();
    final FolderListing listing = new FolderListing(item, content, segments);
    navigator.loadContent(listing);
    verify(navigator).setupBreadcrumb(listing);
    verify(navigator).setupUpFolder(listing);
    verify(navigator).setupContent(listing);
    verifyNavigatorPanelVisibility(navigator);
}
Also used : FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) ArrayList(java.util.ArrayList) FolderListing(org.kie.workbench.common.screens.explorer.model.FolderListing) Test(org.junit.Test)

Aggregations

FolderListing (org.kie.workbench.common.screens.explorer.model.FolderListing)12 FolderItem (org.kie.workbench.common.screens.explorer.model.FolderItem)8 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)5 Package (org.guvnor.common.services.project.model.Package)4 Module (org.guvnor.common.services.project.model.Module)2 Before (org.junit.Before)2 ActiveOptions (org.kie.workbench.common.screens.explorer.service.ActiveOptions)2 KieModuleService (org.kie.workbench.common.services.shared.project.KieModuleService)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Path (org.uberfire.backend.vfs.Path)2 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)1 DescriptiveRunnable (org.uberfire.commons.async.DescriptiveRunnable)1 Space (org.uberfire.spaces.Space)1