Search in sources :

Example 6 with ComponentVersionReader

use of com.android.tools.idea.gradle.project.sync.compatibility.version.ComponentVersionReader in project android by JetBrains.

the class VersionIncompatibilityTest method testReportMessagesWithWarning.

public void testReportMessagesWithWarning() throws Exception {
    loadSimpleApplication();
    mySyncMessagesStub.clearReportedMessages();
    Module appModule = myModules.getAppModule();
    Component base = new Component("android-gradle-plugin", "2.1.3", null);
    Pair<ComponentVersionReader, String> baseReaderAndVersion = Pair.create(ANDROID_GRADLE_PLUGIN, "2.1.3");
    String failureMessage = "Wrong Gradle version";
    Component requirement = new Component("gradle", "2.14.1", failureMessage);
    base.addRequirement(requirement);
    CompatibilityCheck check = new CompatibilityCheck(base, WARNING);
    VersionIncompatibility incompatibility = new VersionIncompatibility(appModule, check, baseReaderAndVersion, requirement, GRADLE);
    incompatibility.reportMessages(getProject());
    SyncMessage message = mySyncMessagesStub.getFirstReportedMessage();
    assertNotNull(message);
    assertThat(message.getText()).hasLength(2);
    // @formatter:off
    assertAbout(syncMessage()).that(message).hasType(WARNING).hasMessageLine("Android Gradle plugin 2.1.3 requires Gradle 2.14.1 (or newer)", 0).hasMessageLine(failureMessage, 1);
// @formatter:on
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) Module(com.intellij.openapi.module.Module) ComponentVersionReader(com.android.tools.idea.gradle.project.sync.compatibility.version.ComponentVersionReader)

Aggregations

ComponentVersionReader (com.android.tools.idea.gradle.project.sync.compatibility.version.ComponentVersionReader)6 SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)3 Module (com.intellij.openapi.module.Module)2 VersionRange (com.android.tools.idea.gradle.project.sync.compatibility.version.VersionRange)1 MessageType (com.android.tools.idea.gradle.project.sync.messages.MessageType)1 PositionInFile (com.android.tools.idea.gradle.util.PositionInFile)1 Project (com.intellij.openapi.project.Project)1 JDOMUtil.loadDocument (com.intellij.openapi.util.JDOMUtil.loadDocument)1 Pair (com.intellij.openapi.util.Pair)1 ArrayList (java.util.ArrayList)1 Language (org.intellij.lang.annotations.Language)1 Document (org.jdom.Document)1 Nullable (org.jetbrains.annotations.Nullable)1 Test (org.junit.Test)1