Search in sources :

Example 51 with Problem

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();
    }
}
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 52 with Problem

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();
    }
}
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 53 with Problem

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());
}
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 54 with Problem

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();
    }
}
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 55 with Problem

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

Aggregations

Problem (com.liferay.blade.api.Problem)92 Test (org.junit.Test)58 File (java.io.File)42 FileMigrator (com.liferay.blade.api.FileMigrator)31 Migration (com.liferay.blade.api.Migration)29 NullProgressMonitor (com.liferay.blade.util.NullProgressMonitor)26 ArrayList (java.util.ArrayList)16 FileProblems (com.liferay.ide.project.core.upgrade.FileProblems)9 IOException (java.io.IOException)9 ServiceReference (org.osgi.framework.ServiceReference)9 AutoMigrator (com.liferay.blade.api.AutoMigrator)8 IFile (org.eclipse.core.resources.IFile)8 List (java.util.List)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 AutoMigrateException (com.liferay.blade.api.AutoMigrateException)5 SearchResult (com.liferay.blade.api.SearchResult)5 MigrationProblems (com.liferay.ide.project.core.upgrade.MigrationProblems)5 MigrationProblemsContainer (com.liferay.ide.project.core.upgrade.MigrationProblemsContainer)5 HashSet (java.util.HashSet)5 CoreException (org.eclipse.core.runtime.CoreException)5