Search in sources :

Example 56 with NotificationHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.

the class MissingPlatformErrorHandlerTest method testHandleError.

public void testHandleError() throws Exception {
    Throwable cause = new IllegalStateException("Failed to find target android-23");
    registerSyncErrorToSimulate(cause);
    loadProjectAndExpectSyncError(SIMPLE_APPLICATION);
    SyncMessagesStub.NotificationUpdate notificationUpdate = mySyncMessagesStub.getNotificationUpdate();
    assertNotNull(notificationUpdate);
    assertThat(notificationUpdate.getText()).contains("Failed to find target android-23");
    // Verify hyperlinks are correct.
    List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
    assertThat(quickFixes).hasSize(1);
    NotificationHyperlink quickFix = quickFixes.get(0);
    assertThat(quickFix).isInstanceOf(InstallPlatformHyperlink.class);
}
Also used : SyncMessagesStub(com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 57 with NotificationHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.

the class OldAndroidPluginErrorHandlerTest method runTestOnProject.

private void runTestOnProject(@NotNull String projectPath, @NotNull File expectedHyperlinkValue) throws Exception {
    loadProject(projectPath);
    String expectedNotificationMessage = "Plugin is too old, please update to a more recent version";
    registerSyncErrorToSimulate(expectedNotificationMessage);
    requestSyncAndGetExpectedFailure();
    SyncMessagesStub.NotificationUpdate notificationUpdate = mySyncMessagesStub.getNotificationUpdate();
    assertNotNull(notificationUpdate);
    assertThat(notificationUpdate.getText()).contains(expectedNotificationMessage);
    List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
    assertThat(quickFixes).hasSize(2);
    // Verify hyperlinks are correct.
    NotificationHyperlink quickFix = quickFixes.get(0);
    assertThat(quickFix).isInstanceOf(FixAndroidGradlePluginVersionHyperlink.class);
    NotificationHyperlink gotoFile = quickFixes.get(1);
    assertThat(gotoFile).isInstanceOf(OpenFileHyperlink.class);
    assertThat(new File(((OpenFileHyperlink) gotoFile).getFilePath())).isEqualTo(expectedHyperlinkValue);
}
Also used : SyncMessagesStub(com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub) File(java.io.File) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 58 with NotificationHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.

the class GradleDslMethodNotFoundErrorHandlerTest method testHandleErrorWithMethodNotFoundInBuildFile.

public void testHandleErrorWithMethodNotFoundInBuildFile() throws Exception {
    loadSimpleApplication();
    File topLevelBuildFile = new File(getBaseDirPath(getProject()), FN_BUILD_GRADLE);
    assertAbout(file()).that(topLevelBuildFile).isFile();
    String content = "asdf()" + getLineSeparator() + loadFile(topLevelBuildFile);
    writeToFile(topLevelBuildFile, content);
    requestSyncAndGetExpectedFailure();
    SyncMessagesStub.NotificationUpdate notificationUpdate = mySyncMessagesStub.getNotificationUpdate();
    assertNotNull(notificationUpdate);
    assertThat(notificationUpdate.getText()).contains("Gradle DSL method not found: 'asdf()'");
    // Verify hyperlinks are correct.
    List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
    assertThat(quickFixes).hasSize(3);
    assertThat(quickFixes.get(0)).isInstanceOf(NotificationHyperlink.class);
    assertThat(quickFixes.get(1)).isInstanceOf(NotificationHyperlink.class);
    assertThat(quickFixes.get(2)).isInstanceOf(FixAndroidGradlePluginVersionHyperlink.class);
}
Also used : SyncMessagesStub(com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub) FileUtil.loadFile(com.intellij.openapi.util.io.FileUtil.loadFile) FileUtil.writeToFile(com.intellij.openapi.util.io.FileUtil.writeToFile) File(java.io.File) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 59 with NotificationHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.

the class Jdk8RequiredErrorHandlerTest method testHandleError.

public void testHandleError() throws Exception {
    registerSyncErrorToSimulate("com/android/jack/api/ConfigNotSupportedException : Unsupported major.minor version 52.0");
    loadProjectAndExpectSyncError(SIMPLE_APPLICATION);
    SyncMessagesStub.NotificationUpdate notificationUpdate = mySyncMessagesStub.getNotificationUpdate();
    assertNotNull(notificationUpdate);
    assertThat(notificationUpdate.getText()).contains("Please use JDK 8 or newer.");
    boolean androidStudio = IdeInfo.getInstance().isAndroidStudio();
    // Verify hyperlinks are correct.
    List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
    int expectedQuickFixCount = 1;
    if (androidStudio) {
        // Android Studio has an extra quick-fix: "Use Embedded JDK".
        expectedQuickFixCount++;
    }
    assertThat(quickFixes).hasSize(expectedQuickFixCount);
    NotificationHyperlink quickFix;
    if (androidStudio) {
        quickFix = quickFixes.get(0);
        assertThat(quickFix).isInstanceOf(UseEmbeddedJdkHyperlink.class);
    }
    quickFix = quickFixes.get(expectedQuickFixCount - 1);
    assertThat(quickFix).isInstanceOf(DownloadJdk8Hyperlink.class);
}
Also used : SyncMessagesStub(com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 60 with NotificationHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.

the class UnresolvedDependenciesReporterTest method testReportWithAppCompat.

public void testReportWithAppCompat() throws Exception {
    loadSimpleApplication();
    mySyncMessagesStub.clearReportedMessages();
    Module appModule = myModules.getAppModule();
    when(mySyncIssue.getData()).thenReturn("com.android.support:appcompat-v7:24.1.1");
    myReporter.report(mySyncIssue, appModule, null);
    SyncMessage message = mySyncMessagesStub.getFirstReportedMessage();
    assertNotNull(message);
    // @formatter:off
    assertAbout(syncMessage()).that(message).hasGroup("Unresolved Android dependencies").hasMessageLine("Failed to resolve: com.android.support:appcompat-v7:24.1.1", 0);
    // @formatter:on
    List<NotificationHyperlink> quickFixes = message.getQuickFixes();
    int expectedSize = IdeInfo.getInstance().isAndroidStudio() ? 2 : 1;
    assertThat(quickFixes).hasSize(expectedSize);
    NotificationHyperlink quickFix = quickFixes.get(0);
    assertThat(quickFix).isInstanceOf(InstallRepositoryHyperlink.class);
    InstallRepositoryHyperlink hyperlink = (InstallRepositoryHyperlink) quickFix;
    assertSame(ANDROID, hyperlink.getRepository());
    if (IdeInfo.getInstance().isAndroidStudio()) {
        quickFix = quickFixes.get(1);
        assertThat(quickFix).isInstanceOf(ShowDependencyInProjectStructureHyperlink.class);
    }
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) InstallRepositoryHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.InstallRepositoryHyperlink) Module(com.intellij.openapi.module.Module) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Aggregations

NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)70 ArrayList (java.util.ArrayList)28 NotNull (org.jetbrains.annotations.NotNull)28 SyncMessagesStub (com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub)17 SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)11 Module (com.intellij.openapi.module.Module)11 OpenUrlHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenUrlHyperlink)10 FixAndroidGradlePluginVersionHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink)8 OpenFileHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenFileHyperlink)8 File (java.io.File)8 Project (com.intellij.openapi.project.Project)5 AndroidPluginInfo (com.android.tools.idea.gradle.plugin.AndroidPluginInfo)4 GradleVersion (com.android.ide.common.repository.GradleVersion)3 OpenAndroidSdkManagerHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 ProgressIndicator (com.android.repository.api.ProgressIndicator)2 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)2 NotificationMessage (com.android.tools.idea.gradle.project.AndroidGradleNotificationStub.NotificationMessage)2 CreateGradleWrapperHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.CreateGradleWrapperHyperlink)2 InstallBuildToolsHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.InstallBuildToolsHyperlink)2