use of com.liferay.blade.api.FileMigrator in project liferay-ide by liferay.
the class SocialNetworkingLegacyAPITest method testFull2.
@Test
public void testFull2() throws Exception {
FileMigrator fmigrator = context.getService(fileMigrators[0]);
List<Problem> problems = fmigrator.analyze(testFile2);
context.ungetService(fileMigrators[0]);
assertNotNull(problems);
assertEquals(6, problems.size());
Problem problem = problems.get(0);
assertEquals(24, problem.lineNumber);
if (Util.isWindows()) {
assertEquals(1005, problem.startOffset);
assertEquals(1070, problem.endOffset);
} else {
assertEquals(982, problem.startOffset);
assertEquals(1047, problem.endOffset);
}
problem = problems.get(1);
assertEquals(57, problem.lineNumber);
if (Util.isWindows()) {
assertEquals(1892, problem.startOffset);
assertEquals(1955, problem.endOffset);
} else {
assertEquals(1836, problem.startOffset);
assertEquals(1899, problem.endOffset);
}
problem = problems.get(2);
assertEquals(128, problem.lineNumber);
if (Util.isWindows()) {
assertEquals(4271, problem.startOffset);
assertEquals(4570, problem.endOffset);
} else {
assertEquals(4144, problem.startOffset);
assertEquals(4439, problem.endOffset);
}
problem = problems.get(3);
assertEquals(135, problem.lineNumber);
if (Util.isWindows()) {
assertEquals(4591, problem.startOffset);
assertEquals(4914, problem.endOffset);
} else {
assertEquals(4457, problem.startOffset);
assertEquals(4775, problem.endOffset);
}
problem = problems.get(4);
assertEquals(25, problem.lineNumber);
if (Util.isWindows()) {
assertEquals(1080, problem.startOffset);
assertEquals(1152, problem.endOffset);
} else {
assertEquals(1056, problem.startOffset);
assertEquals(1128, problem.endOffset);
}
problem = problems.get(5);
assertEquals(156, problem.lineNumber);
if (Util.isWindows()) {
assertEquals(5378, problem.startOffset);
assertEquals(5504, problem.endOffset);
} else {
assertEquals(5223, problem.startOffset);
assertEquals(5348, problem.endOffset);
}
}
use of com.liferay.blade.api.FileMigrator in project liferay-ide by liferay.
the class ProjectMigrationService method analyzeFile.
protected FileVisitResult analyzeFile(File file, final List<Problem> problems, ProgressMonitor monitor) {
Path path = file.toPath();
String fileName = path.getFileName().toString();
String extension = fileName.substring(fileName.lastIndexOf('.') + 1);
monitor.setTaskName("Analyzing file " + _count + "/" + _total + " " + fileName);
ServiceReference<FileMigrator>[] fileMigrators = _fileMigratorTracker.getServiceReferences();
if (ListUtil.isNotEmpty(fileMigrators)) {
Stream<ServiceReference<FileMigrator>> serviceStream = Arrays.asList(fileMigrators).stream();
List<ServiceReference<FileMigrator>> fileMigratorList = serviceStream.filter(predicate -> {
String fileExtensionString = (String) predicate.getProperty("file.extensions");
List<String> extensionList = Arrays.asList(fileExtensionString.split(","));
return extensionList.contains(extension);
}).collect(Collectors.toList());
if (ListUtil.isNotEmpty(fileMigratorList)) {
try {
Stream<ServiceReference<FileMigrator>> migratorStream = fileMigratorList.stream();
migratorStream.map(_context::getService).parallel().forEach(fm -> {
List<Problem> fileProlbems = fm.analyze(file);
if (ListUtil.isNotEmpty(fileProlbems)) {
problems.addAll(fileProlbems);
}
});
} catch (Exception e) {
}
}
_count++;
}
return FileVisitResult.CONTINUE;
}
Aggregations