use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage in project android by JetBrains.
the class DependencySetupTest method WithUnresolvedDependencies.
// Fails in Bazel PSQ because of missing dependencies in the prebuilt Android SDK.
public void WithUnresolvedDependencies() throws Exception {
loadSimpleApplication();
File buildFilePath = getBuildFilePath("app");
VirtualFile buildFile = findFileByIoFile(buildFilePath, true);
assertNotNull(buildFile);
boolean versionChanged = false;
Project project = getProject();
GradleBuildModel buildModel = GradleBuildModel.parseBuildFile(buildFile, project);
for (ArtifactDependencyModel artifact : buildModel.dependencies().artifacts()) {
if ("com.android.support".equals(artifact.group().value()) && "appcompat-v7".equals(artifact.name().value())) {
artifact.setVersion("100.0.0");
versionChanged = true;
break;
}
}
assertTrue(versionChanged);
runWriteCommandAction(project, buildModel::applyChanges);
LocalFileSystem.getInstance().refresh(false);
SyncMessagesStub syncMessages = SyncMessagesStub.replaceSyncMessagesService(project);
requestSyncAndWait();
SyncMessage reportedMessage = syncMessages.getFirstReportedMessage();
assertNotNull(reportedMessage);
String[] text = reportedMessage.getText();
assertThat(text).isNotEmpty();
assertEquals("Failed to resolve: com.android.support:appcompat-v7:100.0.0", text[0]);
}
use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage in project android by JetBrains.
the class ProjectJdkSetupStepTest method testDoSetUpProjectWithAndroidStudioAndNoJdk.
public void testDoSetUpProjectWithAndroidStudioAndNoJdk() {
when(myIdeSdks.getJdk()).thenReturn(null);
Project project = getProject();
mySetupStep.doSetUpProject(project, true);
SyncMessage message = mySyncMessages.getFirstReportedMessage();
assertNotNull(message);
// @formatter:off
assertAbout(SyncMessageSubject.syncMessage()).that(message).hasMessageLine("Unable to find a JDK", 0).hasType(ERROR).hasGroup(DEFAULT_GROUP);
// @formatter:on
assertTrue(GradleSyncState.getInstance(project).getSummary().hasSyncErrors());
}
use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage in project android by JetBrains.
the class EncodingValidationStrategyTest method testFixAndReportFoundIssues.
public void testFixAndReportFoundIssues() {
SyncMessagesStub syncMessages = SyncMessagesStub.replaceSyncMessagesService(getProject());
String mismatchingEncoding = "UTF-8";
myStrategy.setMismatchingEncoding(mismatchingEncoding);
myStrategy.fixAndReportFoundIssues();
SyncMessage message = syncMessages.getFirstReportedMessage();
assertNotNull(message);
String[] text = message.getText();
assertThat(text).hasLength(2);
assertThat(text[0]).startsWith("The project encoding (ISO-8859-1) has been reset");
verify(myEncodings, times(1)).setDefaultCharsetName(mismatchingEncoding);
}
use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage in project android by JetBrains.
the class EncodingValidationStrategyTest method testFixAndReportFoundIssuesWithNoMismatch.
public void testFixAndReportFoundIssuesWithNoMismatch() {
SyncMessagesStub syncMessages = SyncMessagesStub.replaceSyncMessagesService(getProject());
myStrategy.setMismatchingEncoding(null);
myStrategy.fixAndReportFoundIssues();
SyncMessage message = syncMessages.getFirstReportedMessage();
assertNull(message);
verify(myEncodings, never()).setDefaultCharsetName(anyString());
}
use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage in project android by JetBrains.
the class UniquePathModuleValidatorStrategyTest method testFixAndReportFoundIssues.
public void testFixAndReportFoundIssues() throws Exception {
Project project = getProject();
SyncMessagesStub syncMessages = SyncMessagesStub.replaceSyncMessagesService(project);
ProjectSubset projectSubset = IdeComponents.replaceServiceWithMock(project, ProjectSubset.class);
when(projectSubset.isFeatureEnabled()).thenReturn(false);
Multimap<String, Module> modulesByPath = myStrategy.getModulesByPath();
modulesByPath.putAll("path", Lists.newArrayList(myModule1, myModule2));
when(myModule1.getName()).thenReturn("module1");
when(myModule2.getName()).thenReturn("module2");
myStrategy.fixAndReportFoundIssues();
SyncMessage message = syncMessages.getFirstReportedMessage();
assertNotNull(message);
assertAbout(syncMessage()).that(message).hasMessageLine("The modules ['module1', 'module2'] point to same directory in the file system.", 0);
}
Aggregations