Search in sources :

Example 1 with FindDependenciesVisitor

use of com.liferay.ide.gradle.core.parser.FindDependenciesVisitor in project liferay-ide by liferay.

the class GradleParseTests method addDependenceInClosureLine.

@Test
public void addDependenceInClosureLine() throws IOException {
    final File inputFile = new File("projects/testParseInput/testParse5.gradle");
    GradleDependencyUpdater updater = new GradleDependencyUpdater(inputFile);
    FindDependenciesVisitor visitor = updater.insertDependency("\tcompile group: \"com.liferay\", name:\"com.liferay.bookmarks.api\", version:\"1.0.0\"");
    int dependenceLineNum = visitor.getDependenceLineNum();
    assertEquals(24, dependenceLineNum);
    Files.write(outputfile.toPath(), updater.getGradleFileContents(), StandardCharsets.UTF_8);
    final File expectedOutputFile = new File("projects/testParseOutput/testParse5.gradle");
    assertEquals(encoding(CoreUtil.readStreamToString(Files.newInputStream(expectedOutputFile.toPath()))), encoding(CoreUtil.readStreamToString(Files.newInputStream(outputfile.toPath()))));
}
Also used : GradleDependencyUpdater(com.liferay.ide.gradle.core.parser.GradleDependencyUpdater) FindDependenciesVisitor(com.liferay.ide.gradle.core.parser.FindDependenciesVisitor) File(java.io.File) Test(org.junit.Test)

Example 2 with FindDependenciesVisitor

use of com.liferay.ide.gradle.core.parser.FindDependenciesVisitor in project liferay-ide by liferay.

the class GradleParseTests method addDependenceInSameLine.

@Test
public void addDependenceInSameLine() throws IOException {
    final File inputFile = new File("projects/testParseInput/testParse4.gradle");
    GradleDependencyUpdater updater = new GradleDependencyUpdater(inputFile);
    FindDependenciesVisitor visitor = updater.insertDependency("\tcompile group: \"com.liferay\", name:\"com.liferay.bookmarks.api\", version:\"1.0.0\"");
    int dependenceLineNum = visitor.getDependenceLineNum();
    assertEquals(23, dependenceLineNum);
    Files.write(outputfile.toPath(), updater.getGradleFileContents(), StandardCharsets.UTF_8);
    final File expectedOutputFile = new File("projects/testParseOutput/testParse4.gradle");
    assertEquals(encoding(CoreUtil.readStreamToString(Files.newInputStream(expectedOutputFile.toPath()))), encoding(CoreUtil.readStreamToString(Files.newInputStream(outputfile.toPath()))));
}
Also used : GradleDependencyUpdater(com.liferay.ide.gradle.core.parser.GradleDependencyUpdater) FindDependenciesVisitor(com.liferay.ide.gradle.core.parser.FindDependenciesVisitor) File(java.io.File) Test(org.junit.Test)

Example 3 with FindDependenciesVisitor

use of com.liferay.ide.gradle.core.parser.FindDependenciesVisitor in project liferay-ide by liferay.

the class GradleParseTests method addDependenceIntoEmptyBlock.

@Test
public void addDependenceIntoEmptyBlock() throws IOException {
    final File inputFile = new File("projects/testParseInput/testParse2.gradle");
    GradleDependencyUpdater updater = new GradleDependencyUpdater(inputFile);
    FindDependenciesVisitor visitor = updater.insertDependency("\tcompile group: \"com.liferay\", name:\"com.liferay.bookmarks.api\", version:\"1.0.0\"");
    int dependenceLineNum = visitor.getDependenceLineNum();
    assertEquals(24, dependenceLineNum);
    Files.write(outputfile.toPath(), updater.getGradleFileContents(), StandardCharsets.UTF_8);
    final File expectedOutputFile = new File("projects/testParseOutput/testParse2.gradle");
    assertEquals(encoding(CoreUtil.readStreamToString(Files.newInputStream(expectedOutputFile.toPath()))), encoding(CoreUtil.readStreamToString(Files.newInputStream(outputfile.toPath()))));
}
Also used : GradleDependencyUpdater(com.liferay.ide.gradle.core.parser.GradleDependencyUpdater) FindDependenciesVisitor(com.liferay.ide.gradle.core.parser.FindDependenciesVisitor) File(java.io.File) Test(org.junit.Test)

Example 4 with FindDependenciesVisitor

use of com.liferay.ide.gradle.core.parser.FindDependenciesVisitor in project liferay-ide by liferay.

the class GradleParseTests method addDependenceWithoutDendendenceBlock.

@Test
public void addDependenceWithoutDendendenceBlock() throws IOException {
    final File inputFile = new File("projects/testParseInput/testParse3.gradle");
    GradleDependencyUpdater updater = new GradleDependencyUpdater(inputFile);
    FindDependenciesVisitor visitor = updater.insertDependency("\tcompile group: \"com.liferay\", name:\"com.liferay.bookmarks.api\", version:\"1.0.0\"");
    int dependenceLineNum = visitor.getDependenceLineNum();
    assertEquals(-1, dependenceLineNum);
    Files.write(outputfile.toPath(), updater.getGradleFileContents(), StandardCharsets.UTF_8);
    final File expectedOutputFile = new File("projects/testParseOutput/testParse3.gradle");
    assertEquals(encoding(CoreUtil.readStreamToString(Files.newInputStream(expectedOutputFile.toPath()))), encoding(CoreUtil.readStreamToString(Files.newInputStream(outputfile.toPath()))));
}
Also used : GradleDependencyUpdater(com.liferay.ide.gradle.core.parser.GradleDependencyUpdater) FindDependenciesVisitor(com.liferay.ide.gradle.core.parser.FindDependenciesVisitor) File(java.io.File) Test(org.junit.Test)

Example 5 with FindDependenciesVisitor

use of com.liferay.ide.gradle.core.parser.FindDependenciesVisitor in project liferay-ide by liferay.

the class GradleParseTests method addDependenceSkipComment.

@Test
public void addDependenceSkipComment() throws IOException {
    final File inputFile = new File("projects/testParseInput/testParse.gradle");
    GradleDependencyUpdater updater = new GradleDependencyUpdater(inputFile);
    FindDependenciesVisitor visitor = updater.insertDependency("\tcompile group: \"com.liferay\", name:\"com.liferay.bookmarks.api\", version:\"1.0.0\"");
    int dependenceLineNum = visitor.getDependenceLineNum();
    assertEquals(27, dependenceLineNum);
    Files.write(outputfile.toPath(), updater.getGradleFileContents(), StandardCharsets.UTF_8);
    final File expectedOutputFile = new File("projects/testParseOutput/testParse.gradle");
    assertEquals(encoding(CoreUtil.readStreamToString(Files.newInputStream(expectedOutputFile.toPath()))), encoding(CoreUtil.readStreamToString(Files.newInputStream(outputfile.toPath()))));
}
Also used : GradleDependencyUpdater(com.liferay.ide.gradle.core.parser.GradleDependencyUpdater) FindDependenciesVisitor(com.liferay.ide.gradle.core.parser.FindDependenciesVisitor) File(java.io.File) Test(org.junit.Test)

Aggregations

FindDependenciesVisitor (com.liferay.ide.gradle.core.parser.FindDependenciesVisitor)5 GradleDependencyUpdater (com.liferay.ide.gradle.core.parser.GradleDependencyUpdater)5 File (java.io.File)5 Test (org.junit.Test)5