use of com.liferay.blade.api.Problem in project liferay-ide by liferay.
the class FileSetMigrationTest method findProblemsOnJustFileSet.
@Test
public void findProblemsOnJustFileSet() throws Exception {
ServiceReference<Migration> sr = context.getServiceReference(Migration.class);
Migration m = context.getService(sr);
Set<File> fileset = new HashSet<>();
fileset.add(new File("jsptests/app-view-search-entry/AppViewSearchEntryTagsTest.jsp"));
fileset.add(new File("jsptests/asset-preview/AssetPreviewTest.jsp"));
List<Problem> problems = m.findProblems(fileset, new NullProgressMonitor());
assertEquals(4, problems.size());
boolean found = false;
for (Problem problem : problems) {
if (problem.file.getName().endsWith("AssetPreviewTest.jsp") && problem.lineNumber == 7 && problem.startOffset >= 230 && problem.endOffset >= 310) {
found = true;
}
}
if (!found) {
fail();
}
}
use of com.liferay.blade.api.Problem in project liferay-ide by liferay.
the class InitJSPParseTest method initParseErrorCheck.
@Test
public void initParseErrorCheck() throws Exception {
ServiceReference<Migration> sr = context.getServiceReference(Migration.class);
Migration m = context.getService(sr);
List<Problem> problems = m.findProblems(new File("jsptests/jukebox-portlet/"), new NullProgressMonitor());
assertEquals(327, problems.size());
boolean found = false;
for (Problem problem : problems) {
if (problem.file.getName().endsWith("view_search.jsp")) {
if (problem.lineNumber == 109) {
found = true;
}
}
}
if (!found) {
fail();
}
}
use of com.liferay.blade.api.Problem in project liferay-ide by liferay.
the class JSPTagImportsTest method allProblems.
@Test
public void allProblems() throws Exception {
ServiceReference<Migration> sr = context.getServiceReference(Migration.class);
Migration migration = context.getService(sr);
File tempFolder = Files.createTempDirectory("autocorrect").toFile();
File testFile = new File(tempFolder, "jsptaglist.jsp");
tempFolder.deleteOnExit();
File originalTestfile = new File("jsptests/imports/view.jsp");
Files.copy(originalTestfile.toPath(), testFile.toPath());
List<Problem> problems = migration.findProblems(testFile, new NullProgressMonitor());
assertEquals(6, problems.size());
Collection<ServiceReference<AutoMigrator>> refs = context.getServiceReferences(AutoMigrator.class, "(auto.correct=import)");
for (ServiceReference<AutoMigrator> ref : refs) {
AutoMigrator autoMigrator = context.getService(ref);
autoMigrator.correctProblems(testFile, problems);
}
File dest = new File(tempFolder, "Updated.jsp");
assertTrue(testFile.renameTo(dest));
List<Problem> problems2 = migration.findProblems(dest, new NullProgressMonitor());
assertEquals(0, problems2.size());
}
use of com.liferay.blade.api.Problem in project liferay-ide by liferay.
the class LiferayUIFlagsTagsTest method findProblems.
@Test
public void findProblems() throws Exception {
ServiceReference<Migration> sr = context.getServiceReference(Migration.class);
Migration m = context.getService(sr);
List<Problem> problems = m.findProblems(new File("jsptests/liferayui-flags/"), new NullProgressMonitor());
assertEquals(1, problems.size());
boolean found = false;
for (Problem problem : problems) {
if (problem.file.getName().endsWith("LiferayUIFlagsTagsTest.jsp")) {
if (problem.lineNumber == 3 && problem.startOffset >= 65 && problem.endOffset >= 273) {
found = true;
}
}
}
if (!found) {
fail();
}
}
use of com.liferay.blade.api.Problem in project liferay-ide by liferay.
the class MVCPortletClassInPortletXMLAutoCorrectTest method testAutoCorrectPortletXmlBoth.
@Test
public void testAutoCorrectPortletXmlBoth() throws Exception {
assertNotNull(autoMigrator);
FileMigrator fileMigrator = (FileMigrator) autoMigrator;
File testfile = new File("target/test/MVCPortletClassInPortletXMLAutoCorrectTest/portlet.xml");
if (testfile.exists()) {
assertTrue(testfile.delete());
}
testfile.getParentFile().mkdirs();
Files.copy(new File("projects/test-portlet/docroot/WEB-INF/portlet.xml").toPath(), testfile.toPath());
List<Problem> problems = fileMigrator.analyze(testfile);
assertEquals(2, problems.size());
int corrected = autoMigrator.correctProblems(testfile, problems);
assertEquals(2, corrected);
problems = fileMigrator.analyze(testfile);
assertEquals(0, problems.size());
}
Aggregations