use of com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencyTest.ExpectedArtifactDependency in project android by JetBrains.
the class BuildScriptModelTest method testParseDependencies.
public void testParseDependencies() throws IOException {
String text = "buildscript {\n" + " dependencies {\n" + " classpath 'com.android.tools.build:gradle:2.0.0-alpha2'\n" + " }\n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
DependenciesModel dependenciesModel = buildModel.buildscript().dependencies();
List<ArtifactDependencyModel> dependencies = dependenciesModel.artifacts();
assertThat(dependencies).hasSize(1);
ExpectedArtifactDependency expected = new ExpectedArtifactDependency("classpath", "gradle", "com.android.tools.build", "2.0.0-alpha2");
expected.assertMatches(dependencies.get(0));
}
use of com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencyTest.ExpectedArtifactDependency in project android by JetBrains.
the class BuildScriptModelTest method testEditDependency.
public void testEditDependency() throws IOException {
String text = "buildscript {\n" + " dependencies {\n" + " classpath 'com.android.tools.build:gradle:2.0.0-alpha2'\n" + " }\n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
DependenciesModel dependenciesModel = buildModel.buildscript().dependencies();
List<ArtifactDependencyModel> dependencies = dependenciesModel.artifacts();
assertThat(dependencies).hasSize(1);
ExpectedArtifactDependency expected = new ExpectedArtifactDependency("classpath", "gradle", "com.android.tools.build", "2.0.0-alpha2");
ArtifactDependencyModel actual = dependencies.get(0);
expected.assertMatches(actual);
actual.setVersion("2.0.1");
expected = new ExpectedArtifactDependency("classpath", "gradle", "com.android.tools.build", "2.0.1");
expected.assertMatches(actual);
assertTrue(buildModel.isModified());
applyChanges(buildModel);
assertFalse(buildModel.isModified());
buildModel.reparse();
dependencies = buildModel.buildscript().dependencies().artifacts();
assertThat(dependencies).hasSize(1);
expected.assertMatches(dependencies.get(0));
}
use of com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencyTest.ExpectedArtifactDependency in project android by JetBrains.
the class BuildScriptModelTest method testAddDependency.
public void testAddDependency() throws IOException {
String text = "";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
BuildScriptModel buildScriptModel = buildModel.buildscript();
DependenciesModel dependenciesModel = buildScriptModel.dependencies();
assertFalse(buildScriptModel.hasValidPsiElement());
assertFalse(dependenciesModel.hasValidPsiElement());
assertThat(dependenciesModel.artifacts()).isEmpty();
dependenciesModel.addArtifact("classpath", "com.android.tools.build:gradle:2.0.0-alpha2");
List<ArtifactDependencyModel> dependencies = dependenciesModel.artifacts();
assertThat(dependencies).hasSize(1);
ExpectedArtifactDependency expected = new ExpectedArtifactDependency("classpath", "gradle", "com.android.tools.build", "2.0.0-alpha2");
expected.assertMatches(dependencies.get(0));
assertTrue(buildModel.isModified());
applyChanges(buildModel);
assertFalse(buildModel.isModified());
buildModel.reparse();
buildScriptModel = buildModel.buildscript();
dependenciesModel = buildScriptModel.dependencies();
assertTrue(buildScriptModel.hasValidPsiElement());
assertTrue(dependenciesModel.hasValidPsiElement());
dependencies = dependenciesModel.artifacts();
assertThat(dependencies).hasSize(1);
expected.assertMatches(dependencies.get(0));
}
Aggregations