use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.
the class ProjectExplorerContentResolver method getSegmentSiblings.
private List<FolderItem> getSegmentSiblings(final Package pkg) {
final List<FolderItem> result = new ArrayList<>();
final Package parentPkg = moduleService.resolveParentPackage(pkg);
if (parentPkg == null) {
return emptyList();
}
final Set<Package> siblings = moduleService.resolvePackages(parentPkg);
if (siblings != null && !siblings.isEmpty()) {
for (final Package sibling : siblings) {
if (!sibling.equals(pkg)) {
result.add(explorerServiceHelper.toFolderItem(sibling));
}
}
}
return result;
}
use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.
the class ProjectScreenTestBase method getAssetInfo.
protected AssetInfo getAssetInfo(final String assetPathString, final FolderItemType itemType, final String itemName) {
final Path assetPath = mock(Path.class);
doReturn(assetPathString).when(assetPath).toURI();
final FolderItem asset = mock(FolderItem.class);
doReturn(itemType).when(asset).getType();
doReturn(itemName).when(asset).getFileName();
doReturn(assetPath).when(asset).getItem();
return new AssetInfo(asset, new Date(), new Date());
}
use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.
the class ExplorerServiceHelperTest method getPathSegmentsTest.
@Test
public void getPathSegmentsTest() {
doAnswer(invocationOnMock -> {
final Path p = Paths.convert((org.uberfire.java.nio.file.Path) invocationOnMock.getArguments()[0]);
return new FolderItem(p, p.getFileName(), FolderItemType.FOLDER);
}).when(helper).toFolderItem(any(org.uberfire.java.nio.file.Path.class));
Path path = PathFactory.newPath("myproject", "default://master@myproject/src/main/java/org/myproject");
final List<FolderItem> pathSegments = helper.getPathSegments(path);
assertEquals(5, pathSegments.size());
assertEquals("/", pathSegments.get(0).getFileName());
assertEquals("src", pathSegments.get(1).getFileName());
assertEquals("main", pathSegments.get(2).getFileName());
assertEquals("java", pathSegments.get(3).getFileName());
assertEquals("org", pathSegments.get(4).getFileName());
}
use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.
the class ProjectExplorerContentResolverTest method getSegmentSiblingsRootTest.
@Test
public void getSegmentSiblingsRootTest() {
doAnswer(invocationOnMock -> {
final Path p = Paths.convert((org.uberfire.java.nio.file.Path) invocationOnMock.getArguments()[0]);
return new FolderItem(p, p.getFileName(), FolderItemType.FOLDER);
}).when(explorerServiceHelper).toFolderItem(any(org.uberfire.java.nio.file.Path.class));
Path path = PathFactory.newPath("/", "default://master@myproject/");
final List<FolderItem> siblings = resolver.getSegmentSiblings(path);
assertEquals(1, siblings.size());
assertEquals("/", siblings.get(0).getFileName());
}
use of org.kie.workbench.common.screens.explorer.model.FolderItem in project kie-wb-common by kiegroup.
the class ProjectExplorerContentResolverTest method getSegmentSiblingsTest.
@Test
public void getSegmentSiblingsTest() {
doAnswer(invocationOnMock -> {
final Path p = Paths.convert((org.uberfire.java.nio.file.Path) invocationOnMock.getArguments()[0]);
return new FolderItem(p, p.getFileName(), FolderItemType.FOLDER);
}).when(explorerServiceHelper).toFolderItem(any(org.uberfire.java.nio.file.Path.class));
Path path = PathFactory.newPath("src", "default://master@myproject/src");
final List<org.uberfire.java.nio.file.Path> mockedSiblings = new ArrayList<>();
mockedSiblings.add(Paths.convert(path));
mockedSiblings.add(Paths.convert(PathFactory.newPath("src", "default://master@myproject/pom.xml")));
doReturn(mockedSiblings).when(resolver).getDirectoryIterator(any(org.uberfire.java.nio.file.Path.class));
final List<FolderItem> siblings = resolver.getSegmentSiblings(path);
assertEquals(2, siblings.size());
assertEquals("src", siblings.get(0).getFileName());
assertEquals("pom.xml", siblings.get(1).getFileName());
}
Aggregations