use of com.liferay.blade.api.FileMigrator in project liferay-ide by liferay.
the class APITestBase method test2.
@Test
public void test2() throws Exception {
FileMigrator fmigrator = context.getService(fileMigrators[0]);
List<Problem> problems = fmigrator.analyze(getTestFile());
problems = fmigrator.analyze(getTestFile());
context.ungetService(fileMigrators[0]);
assertNotNull(problems);
assertEquals(getExpectedNumber(), problems.size());
}
use of com.liferay.blade.api.FileMigrator in project liferay-ide by liferay.
the class APITestBase method beforeTest.
@Before
public void beforeTest() throws Exception {
Filter filter = context.createFilter("(implName=" + getImplClassName() + ")");
ServiceTracker<FileMigrator, FileMigrator> fileMigratorTracker = new ServiceTracker<FileMigrator, FileMigrator>(context, filter, null);
fileMigratorTracker.open();
fileMigrators = fileMigratorTracker.getServiceReferences();
assertNotNull(fileMigrators);
assertEquals(1, fileMigrators.length);
}
use of com.liferay.blade.api.FileMigrator in project liferay-ide by liferay.
the class ContactNameExceptionImportAutoCorrectTest method autoCorrectProblems.
@Test
public void autoCorrectProblems() throws Exception {
File tempFolder = Files.createTempDirectory("autocorrect").toFile();
File testFile = new File(tempFolder, "ContactNameExceptionImport.java");
tempFolder.deleteOnExit();
File originalTestfile = new File("javatests/ContactNameExceptionImport.java");
Files.copy(originalTestfile.toPath(), testFile.toPath());
List<Problem> problems = null;
FileMigrator migrator = null;
Collection<ServiceReference<FileMigrator>> mrefs = context.getServiceReferences(FileMigrator.class, null);
for (ServiceReference<FileMigrator> mref : mrefs) {
migrator = context.getService(mref);
if (migrator.getClass().getName().contains("ContactNameExceptionImport")) {
problems = migrator.analyze(testFile);
break;
}
}
assertEquals(3, problems.size());
int problemsFixed = ((AutoMigrator) migrator).correctProblems(testFile, problems);
assertEquals(3, problemsFixed);
File dest = new File(tempFolder, "Updated.java");
assertTrue(testFile.renameTo(dest));
problems = migrator.analyze(dest);
assertEquals(0, problems.size());
}
use of com.liferay.blade.api.FileMigrator in project liferay-ide by liferay.
the class AssetTagPropertiesTest method assetTageProperties.
@Test
public void assetTageProperties() {
FileMigrator fmigrator = context.getService(fileMigrators[0]);
List<Problem> problems = fmigrator.analyze(testFile2);
context.ungetService(fileMigrators[0]);
assertNotNull(problems);
assertEquals(4, problems.size());
}
use of com.liferay.blade.api.FileMigrator in project liferay-ide by liferay.
the class AutoCorrectJSPTagTestBase method autoCorrectProblems.
@Test
public void autoCorrectProblems() throws Exception {
File tempFolder = Files.createTempDirectory("autocorrect").toFile();
File testFile = new File(tempFolder, "test.jsp");
tempFolder.deleteOnExit();
Files.copy(getOriginalTestFile().toPath(), testFile.toPath());
List<Problem> problems = null;
FileMigrator migrator = null;
Collection<ServiceReference<FileMigrator>> mrefs = context.getServiceReferences(FileMigrator.class, null);
for (ServiceReference<FileMigrator> mref : mrefs) {
migrator = context.getService(mref);
if (migrator.getClass().getName().contains(getImplClassName())) {
problems = migrator.analyze(testFile);
break;
}
}
assertEquals(getExpectedNumber(), problems.size());
int problemsFixed = ((AutoMigrator) migrator).correctProblems(testFile, problems);
assertEquals(getExpectedFixedNumber(), problemsFixed);
File dest = new File(tempFolder, "Updated.jsp");
assertTrue(testFile.renameTo(dest));
problems = migrator.analyze(dest);
assertEquals(0, problems.size());
for (String checkPoint : getCheckPoints()) {
int lineNumber = Integer.parseInt(checkPoint.split(",")[0]);
String lineContent = checkPoint.split(",")[1];
try {
String[] lines = _readLines(Files.newInputStream(dest.toPath()));
assertTrue(lines[lineNumber - 1].trim().equals(lineContent));
} catch (Exception e) {
}
}
}
Aggregations