use of org.uberfire.io.IOService in project kie-wb-common by kiegroup.
the class BPMFinderServiceImplTest method initialize.
@Before
public void initialize() throws URISyntaxException, ClassNotFoundException {
when(ioService.newDirectoryStream(any(), any())).thenAnswer(invocationOnMock -> Files.newDirectoryStream((Path) invocationOnMock.getArguments()[0], (DirectoryStream.Filter<Path>) invocationOnMock.getArguments()[1]));
when(ioService.newInputStream(any())).thenAnswer(invocationOnMock -> new FileInputStream(((Path) invocationOnMock.getArguments()[0]).toFile()));
simpleFileSystemProvider = new SimpleFileSystemProvider();
simpleFileSystemProvider.forceAsDefault();
rootPath = simpleFileSystemProvider.getPath(this.getClass().getResource(RESOURCES_PATH).toURI());
when(moduleService.resolveModule(any())).thenReturn(module);
when(module.getRootPath()).thenReturn(Paths.convert(rootPath));
when(classLoader.loadClass(any())).thenAnswer((Answer<Class>) invocation -> String.class);
when(moduleClassLoaderHelper.getModuleClassLoader(any())).thenReturn(classLoader);
bpmnFormModelGenerator = new BPMNFormModelGeneratorImpl(moduleService, moduleClassLoaderHelper);
finderService = new BPMFinderServiceImpl(ioService, moduleService, bpmnFormModelGenerator);
finderService.init();
}
use of org.uberfire.io.IOService in project kie-wb-common by kiegroup.
the class FormsMigrationTool method systemMigrationWasExecuted.
private boolean systemMigrationWasExecuted() {
final IOService systemIoService = migrationServicesCDIWrapper.getSystemIoService();
final Repository systemRepository = migrationServicesCDIWrapper.getSystemRepository();
if (!systemIoService.exists(systemIoService.get(systemRepository.getUri()).resolve("spaces"))) {
system.err().println(String.format("The SYSTEM CONFIGURATION DIRECTORY STRUCTURE MIGRATION must be ran before this one."));
return false;
}
return true;
}
use of org.uberfire.io.IOService in project kie-wb-common by kiegroup.
the class ConfigGroupsMigrationServiceTest method mockIoService.
private IOService mockIoService() {
final IOService ioService = spy(fileSystemTestingUtils.getIoService());
doNothing().when(ioService).startBatch(any(FileSystem.class));
doNothing().when(ioService).endBatch();
return ioService;
}
use of org.uberfire.io.IOService in project kie-wb-common by kiegroup.
the class ModuleFormFinderServiceImpl method findForms.
private List<FormDefinition> findForms(final Path path, final Predicate<FormDefinition> predicate) {
KieModule module = moduleService.resolveModule(path);
org.uberfire.java.nio.file.Path nioPath = Paths.convert(module.getRootPath());
List<FormDefinition> moduleForms = VFSScanner.scan(ioService, nioPath, Collections.singleton(FormResourceTypeDefinition.EXTENSION), this::convert, predicate).stream().map(VFSScanner.ScanResult::getResource).filter(Objects::nonNull).collect(Collectors.toList());
List<String> moduleFormsIds = moduleForms.stream().map(FormDefinition::getId).collect(Collectors.toList());
Map<String, String> dependenciesForms = buildInfoService.getBuildInfo(module).getKieModuleMetaDataIgnoringErrors().getForms();
return dependenciesForms.values().stream().map(serializer::deserialize).filter(predicate).filter(formDefinition -> !moduleFormsIds.contains(formDefinition)).collect(Collectors.toCollection(() -> moduleForms));
}
use of org.uberfire.io.IOService in project kie-wb-common by kiegroup.
the class AbstractFormDefinitionHelperTest method init.
@Before
public void init() throws IOException {
simpleFileSystemProvider = new SimpleFileSystemProvider();
simpleFileSystemProvider.forceAsDefault();
serializer = spy(new FormDefinitionSerializerImpl(new FieldSerializer(), new FormModelSerializer(), new TestMetaDataEntryManager()));
when(originalPath.getFileName()).thenReturn(ORIGNAL_FORM_ASSET_NAME);
when(destinationPath.getFileName()).thenReturn(DESTINATION_FORM_ASSET_NAME);
when(destinationPath.toURI()).thenReturn(DESTINATION_FORM_PATH);
when(ioService.readAllString(any())).thenReturn(IOUtils.toString(new InputStreamReader(this.getClass().getResourceAsStream(ORIGINAL_FORM_PATH))));
doAnswer((Answer<FormDefinition>) invocationOnMock -> {
FormDefinition formDefinition = (FormDefinition) invocationOnMock.callRealMethod();
beforeProcess(formDefinition);
return formDefinition;
}).when(serializer).deserialize(Mockito.<String>any());
helper = getHelper(ioService, serializer, commentedOptionFactory);
}
Aggregations