Search in sources :

Example 11 with NullProgressMonitor

use of com.liferay.blade.util.NullProgressMonitor in project liferay-ide by liferay.

the class AppViewSearchEntryTagsTest 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/app-view-search-entry/"), new NullProgressMonitor());
    assertEquals(3, problems.size());
}
Also used : NullProgressMonitor(com.liferay.blade.util.NullProgressMonitor) Migration(com.liferay.blade.api.Migration) Problem(com.liferay.blade.api.Problem) File(java.io.File) Test(org.junit.Test)

Example 12 with NullProgressMonitor

use of com.liferay.blade.util.NullProgressMonitor 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();
    }
}
Also used : NullProgressMonitor(com.liferay.blade.util.NullProgressMonitor) Migration(com.liferay.blade.api.Migration) Problem(com.liferay.blade.api.Problem) File(java.io.File) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 13 with NullProgressMonitor

use of com.liferay.blade.util.NullProgressMonitor 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();
    }
}
Also used : NullProgressMonitor(com.liferay.blade.util.NullProgressMonitor) Migration(com.liferay.blade.api.Migration) Problem(com.liferay.blade.api.Problem) File(java.io.File) Test(org.junit.Test)

Example 14 with NullProgressMonitor

use of com.liferay.blade.util.NullProgressMonitor 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());
}
Also used : NullProgressMonitor(com.liferay.blade.util.NullProgressMonitor) Migration(com.liferay.blade.api.Migration) AutoMigrator(com.liferay.blade.api.AutoMigrator) Problem(com.liferay.blade.api.Problem) File(java.io.File) ServiceReference(org.osgi.framework.ServiceReference) Test(org.junit.Test)

Example 15 with NullProgressMonitor

use of com.liferay.blade.util.NullProgressMonitor 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();
    }
}
Also used : NullProgressMonitor(com.liferay.blade.util.NullProgressMonitor) Migration(com.liferay.blade.api.Migration) Problem(com.liferay.blade.api.Problem) File(java.io.File) Test(org.junit.Test)

Aggregations

Migration (com.liferay.blade.api.Migration)26 Problem (com.liferay.blade.api.Problem)26 NullProgressMonitor (com.liferay.blade.util.NullProgressMonitor)26 File (java.io.File)26 Test (org.junit.Test)26 Ignore (org.junit.Ignore)2 AutoMigrator (com.liferay.blade.api.AutoMigrator)1 HashSet (java.util.HashSet)1 ServiceReference (org.osgi.framework.ServiceReference)1