use of org.uberfire.java.nio.file.SimpleFileVisitor in project kie-wb-common by kiegroup.
the class AbstractVFSDiagramServiceTest method testGetAll.
@Test
public void testGetAll() {
ArgumentCaptor<SimpleFileVisitor> visitorArgumentCaptor = ArgumentCaptor.forClass(SimpleFileVisitor.class);
org.uberfire.java.nio.file.Path root = mock(org.uberfire.java.nio.file.Path.class);
D diagram = mockDiagram();
List<Pair<Path, org.uberfire.java.nio.file.Path>> visitedPaths = new ArrayList<>();
for (int i = 0; i < 10; i++) {
Path diagramPath = mock(Path.class);
org.uberfire.java.nio.file.Path nioDiagramPath = mock(org.uberfire.java.nio.file.Path.class);
doReturn(nioDiagramPath).when(diagramService).convertToNioPath(diagramPath);
doReturn(diagramPath).when(diagramService).convertToBackendPath(nioDiagramPath);
visitedPaths.add(new Pair<>(diagramPath, nioDiagramPath));
when(resourceType.accept(diagramPath)).thenReturn(true);
doReturn(diagram).when(diagramService).getDiagramByPath(diagramPath);
}
BasicFileAttributes attrs = mock(BasicFileAttributes.class);
when(ioService.exists(root)).thenReturn(true);
doNothing().when(diagramService).walkFileTree(eq(root), visitorArgumentCaptor.capture());
diagramService.getDiagramsByPath(root);
visitedPaths.forEach(pair -> {
visitorArgumentCaptor.getValue().visitFile(pair.getK2(), attrs);
verify(diagramService, times(1)).getDiagramByPath(pair.getK1());
});
}
Aggregations