Search in sources :

Example 16 with Migration

use of com.liferay.blade.api.Migration 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 17 with Migration

use of com.liferay.blade.api.Migration 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)

Example 18 with Migration

use of com.liferay.blade.api.Migration in project liferay-ide by liferay.

the class NavigationTagsTest 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/navigation-tags/"), new NullProgressMonitor());
    assertEquals(1, problems.size());
    boolean found = false;
    for (Problem problem : problems) {
        if (problem.file.getName().endsWith("NavigationTagsTest.jsp")) {
            if (problem.lineNumber == 3 && problem.startOffset >= 57 && problem.endOffset >= 374) {
                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 19 with Migration

use of com.liferay.blade.api.Migration in project liferay-ide by liferay.

the class RepositoryServiceUtilTest method repositoryServiceUtilTest.

@Test
public void repositoryServiceUtilTest() throws Exception {
    ServiceReference<Migration> sr = context.getServiceReference(Migration.class);
    Migration m = context.getService(sr);
    List<Problem> problems = m.findProblems(new File("jsptests/repository-service-util"), new NullProgressMonitor());
    assertEquals(1, problems.size());
    boolean found = false;
    for (Problem problem : problems) {
        if (problem.file.getName().endsWith("RepositoryServiceUtilTest.jsp")) {
            if (problem.lineNumber == 9 && problem.startOffset >= 104 && problem.endOffset >= 171) {
                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 20 with Migration

use of com.liferay.blade.api.Migration in project liferay-ide by liferay.

the class TrashEmptyTagsTest 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/liferay-ui-trash-empty/"), 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)

Aggregations

Migration (com.liferay.blade.api.Migration)28 Problem (com.liferay.blade.api.Problem)28 File (java.io.File)28 Test (org.junit.Test)27 NullProgressMonitor (com.liferay.blade.util.NullProgressMonitor)26 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Ignore (org.junit.Ignore)2 AutoMigrator (com.liferay.blade.api.AutoMigrator)1 ProgressMonitor (com.liferay.blade.api.ProgressMonitor)1 FileProblems (com.liferay.ide.project.core.upgrade.FileProblems)1 MigrationProblems (com.liferay.ide.project.core.upgrade.MigrationProblems)1 MigrationProblemsContainer (com.liferay.ide.project.core.upgrade.MigrationProblemsContainer)1 UpgradeProblems (com.liferay.ide.project.core.upgrade.UpgradeProblems)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IFile (org.eclipse.core.resources.IFile)1 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1