use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.
the class DaemonContextMismatchErrorHandlerTest method testHandleErrorWithErrorFromGradleForum.
public void testHandleErrorWithErrorFromGradleForum() throws Exception {
// Verify that the error handler was capable of handling the exception from gradle forum.
String text = "The newly created daemon process has a different context than expected.\n" + "It won't be possible to reconnect to this daemon. Context mismatch: \n" + "Java home is different.\n" + "Wanted: DefaultDaemonContext[uid=null,javaHome=/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home,daemonRegistryDir=/Users/Nikem/.gradle/daemon,pid=555]\n" + "Actual: DefaultDaemonContext[uid=0f3a0315-c1e6-44d6-962d-9a604d59a158,javaHome=/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home/jre,daemonRegistryDir=/Users/Nikem/.gradle/daemon,pid=568]";
String expectedNotificationMessage = "Expecting: '/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home' but was: '/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home/jre'.";
registerSyncErrorToSimulate(text);
loadProjectAndExpectSyncError(SIMPLE_APPLICATION);
SyncMessagesStub.NotificationUpdate notificationUpdate = mySyncMessagesStub.getNotificationUpdate();
assertNotNull(notificationUpdate);
assertThat(notificationUpdate.getText()).contains(expectedNotificationMessage);
// Verify hyperlinks are correct.
List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
assertThat(quickFixes).hasSize(1);
NotificationHyperlink quickFix = quickFixes.get(0);
assertThat(quickFix).isInstanceOf(OpenProjectStructureHyperlink.class);
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.
the class DaemonContextMismatchErrorHandlerTest method testHandleErrorWithErrorFromBugReport.
public void testHandleErrorWithErrorFromBugReport() throws Exception {
String text = "The newly created daemon process has a different context than expected.\n" + "It won't be possible to reconnect to this daemon. Context mismatch: \n" + "Java home is different.\n" + "javaHome=c:\\Program Files\\Java\\jdk,daemonRegistryDir=C:\\Users\\user.name\\.gradle\\daemon,pid=7868,idleTimeout=null]\n" + "javaHome=C:\\Program Files\\Java\\jdk\\jre,daemonRegistryDir=C:\\Users\\user.name\\.gradle\\daemon,pid=4792,idleTimeout=10800000]";
String expectedNotificationMessage = "Expecting: 'c:\\Program Files\\Java\\jdk' but was: 'C:\\Program Files\\Java\\jdk\\jre'.";
registerSyncErrorToSimulate(text);
loadProjectAndExpectSyncError(SIMPLE_APPLICATION);
SyncMessagesStub.NotificationUpdate notificationUpdate = mySyncMessagesStub.getNotificationUpdate();
assertNotNull(notificationUpdate);
assertThat(notificationUpdate.getText()).contains(expectedNotificationMessage);
// Verify hyperlinks are correct.
List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
assertThat(quickFixes).hasSize(1);
NotificationHyperlink quickFix = quickFixes.get(0);
assertThat(quickFix).isInstanceOf(OpenProjectStructureHyperlink.class);
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.
the class GradleDslMethodNotFoundErrorHandlerTest method testHandleErrorWithMethodNotFoundInSettingsFile.
public void testHandleErrorWithMethodNotFoundInSettingsFile() throws Exception {
loadSimpleApplication();
File settingsFile = new File(getBaseDirPath(getProject()), FN_SETTINGS_GRADLE);
assertAbout(file()).that(settingsFile).isFile();
writeToFile(settingsFile, "incude ':app'");
requestSyncAndGetExpectedFailure();
SyncMessagesStub.NotificationUpdate notificationUpdate = mySyncMessagesStub.getNotificationUpdate();
assertNotNull(notificationUpdate);
assertThat(notificationUpdate.getText()).contains("Gradle DSL method not found: 'incude()'");
// Verify hyperlinks are correct.
List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
assertThat(quickFixes).hasSize(1);
NotificationHyperlink quickFix = quickFixes.get(0);
assertThat(quickFix).isInstanceOf(OpenFileHyperlink.class);
// Ensure the error message contains the location of the error.
OpenFileHyperlink openFileQuickFix = (OpenFileHyperlink) quickFix;
assertEquals(settingsFile.getPath(), openFileQuickFix.getFilePath());
assertEquals(0, openFileQuickFix.getLineNumber());
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.
the class GradleVersionReaderTest method testGetQuickFixes.
public void testGetQuickFixes() throws Exception {
loadSimpleApplication();
Module appModule = myModules.getAppModule();
List<NotificationHyperlink> quickFixes = myVersionReader.getQuickFixes(appModule, null, null);
assertThat(quickFixes).hasSize(2);
NotificationHyperlink quickFix = quickFixes.get(0);
assertThat(quickFix).isInstanceOf(FixAndroidGradlePluginVersionHyperlink.class);
FixAndroidGradlePluginVersionHyperlink fixAndroidGradlePluginQuickFix = (FixAndroidGradlePluginVersionHyperlink) quickFix;
assertEquals(BuildEnvironment.getInstance().getGradlePluginVersion(), fixAndroidGradlePluginQuickFix.getPluginVersion().toString());
GradleVersion gradleVersion = fixAndroidGradlePluginQuickFix.getGradleVersion();
assertNotNull(gradleVersion);
assertEquals(GRADLE_LATEST_VERSION, gradleVersion.toString());
quickFix = quickFixes.get(1);
assertThat(quickFix).isInstanceOf(OpenUrlHyperlink.class);
OpenUrlHyperlink openUrlQuickFix = (OpenUrlHyperlink) quickFix;
assertEquals("https://developer.android.com/studio/releases/index.html#Revisions", openUrlQuickFix.getUrl());
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.
the class GenericErrorHandlerTest method testHandleErrorWithLocationInException.
public void testHandleErrorWithLocationInException() throws Exception {
File buildFile = new File(getProject().getBasePath(), FN_BUILD_GRADLE);
String errMsg = "Some error message.";
registerSyncErrorToSimulate(errMsg, buildFile);
loadProjectAndExpectSyncError(SIMPLE_APPLICATION);
SyncMessagesStub.NotificationUpdate notificationUpdate = mySyncMessagesStub.getNotificationUpdate();
assertNotNull(notificationUpdate);
assertThat(notificationUpdate.getText()).isEqualTo(errMsg);
// Verify hyperlinks are correct.
List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
assertThat(quickFixes).hasSize(1);
assertThat(quickFixes.get(0)).isInstanceOf(OpenFileHyperlink.class);
}
Aggregations