Search in sources :

Example 66 with Problem

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

the class EmptyFileCheckingTest 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("projects/emptyfiles/"), new NullProgressMonitor());
    assertEquals(0, 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 67 with Problem

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

Example 68 with Problem

use of com.liferay.blade.api.Problem 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) {
        }
    }
}
Also used : FileMigrator(com.liferay.blade.api.FileMigrator) 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 69 with Problem

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

the class BackgroundTaskLegacyAPITest method testFull.

@Test
public void testFull() throws Exception {
    FileMigrator fmigrator = context.getService(fileMigrators[0]);
    List<Problem> problems = fmigrator.analyze(getTestFile());
    context.ungetService(fileMigrators[0]);
    assertNotNull(problems);
    assertEquals(2, problems.size());
    Problem problem = problems.get(0);
    assertEquals(18, problem.lineNumber);
    if (Util.isWindows()) {
        assertEquals(688, problem.startOffset);
        assertEquals(736, problem.endOffset);
    } else {
        assertEquals(671, problem.startOffset);
        assertEquals(719, problem.endOffset);
    }
    problem = problems.get(1);
    assertEquals(19, problem.lineNumber);
    if (Util.isWindows()) {
        assertEquals(746, problem.startOffset);
        assertEquals(801, problem.endOffset);
    } else {
        assertEquals(728, problem.startOffset);
        assertEquals(783, problem.endOffset);
    }
}
Also used : FileMigrator(com.liferay.blade.api.FileMigrator) Problem(com.liferay.blade.api.Problem) Test(org.junit.Test)

Example 70 with Problem

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

the class AUIButtonItemTagsTest 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/aui-button/"), new NullProgressMonitor());
    assertEquals(2, problems.size());
    boolean found = false;
    for (Problem problem : problems) {
        if (problem.file.getName().endsWith("AUIButtonItemTagTest.jsp")) {
            if (problem.lineNumber == 3 && problem.startOffset >= 94 && problem.endOffset >= 129) {
                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

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