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()))));
}
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()))));
}
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()))));
}
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()))));
}
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()))));
}
Aggregations