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