use of com.google.idea.blaze.base.sync.BlazeSyncParams in project intellij by bazelbuild.
the class JavaSyncTest method testExistingPackagePrefixRetainedForTestSources.
@Test
public void testExistingPackagePrefixRetainedForTestSources() {
setProjectView("directories:", " java/com/google", " javatests/com/google", "targets:", " //java/com/google:lib", "test_sources:", " javatests/*");
workspace.createDirectory(new WorkspacePath("java/com/google"));
VirtualFile javatestsRoot = workspace.createDirectory(new WorkspacePath("javatests/com/google"));
BlazeSyncParams syncParams = new BlazeSyncParams.Builder("Full Sync", BlazeSyncParams.SyncMode.FULL).addProjectViewTargets(true).build();
runBlazeSync(syncParams);
errorCollector.assertNoIssues();
ContentEntry testRoot = findContentEntry(javatestsRoot);
SourceFolder testRootSource = findSourceFolder(testRoot, javatestsRoot);
assertThat(testRootSource.isTestSource()).isTrue();
assertThat(testRootSource.getPackagePrefix()).isEqualTo("com.google");
}
use of com.google.idea.blaze.base.sync.BlazeSyncParams in project intellij by bazelbuild.
the class JavaSyncTest method testJavaClassesPresentInClassPath.
@Test
public void testJavaClassesPresentInClassPath() throws Exception {
setProjectView("directories:", " java/com/google", "targets:", " //java/com/google:lib");
workspace.createFile(new WorkspacePath("java/com/google/ClassWithUniqueName1.java"), "package com.google;", "public class ClassWithUniqueName1 {}");
workspace.createFile(new WorkspacePath("java/com/google/ClassWithUniqueName2.java"), "package com.google;", "public class ClassWithUniqueName2 {}");
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("java/com/google/BUILD")).setLabel("//java/com/google:lib").setKind("java_library").addSource(sourceRoot("java/com/google/ClassWithUniqueName1.java")).addSource(sourceRoot("java/com/google/ClassWithUniqueName2.java")).setJavaInfo(JavaIdeInfo.builder())).build();
setTargetMap(targetMap);
BlazeSyncParams syncParams = new BlazeSyncParams.Builder("Full Sync", BlazeSyncParams.SyncMode.FULL).addProjectViewTargets(true).build();
runBlazeSync(syncParams);
errorCollector.assertNoIssues();
BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData();
assertThat(blazeProjectData).isNotNull();
assertThat(blazeProjectData.targetMap).isEqualTo(targetMap);
assertThat(blazeProjectData.workspaceLanguageSettings.getWorkspaceType()).isEqualTo(WorkspaceType.JAVA);
BlazeJavaSyncData javaSyncData = blazeProjectData.syncState.get(BlazeJavaSyncData.class);
List<BlazeContentEntry> contentEntries = javaSyncData.importResult.contentEntries;
assertThat(contentEntries).hasSize(1);
BlazeContentEntry contentEntry = contentEntries.get(0);
assertThat(contentEntry.contentRoot.getPath()).isEqualTo(workspaceRoot.fileForPath(new WorkspacePath("java/com/google")).getPath());
assertThat(contentEntry.sources).hasSize(1);
BlazeSourceDirectory sourceDir = contentEntry.sources.get(0);
assertThat(sourceDir.getPackagePrefix()).isEqualTo("com.google");
assertThat(sourceDir.getDirectory().getPath()).isEqualTo(workspaceRoot.fileForPath(new WorkspacePath("java/com/google")).getPath());
}
use of com.google.idea.blaze.base.sync.BlazeSyncParams in project intellij by bazelbuild.
the class JavaSyncTest method testNestedTestSourcesAreAdded.
@Test
public void testNestedTestSourcesAreAdded() {
setProjectView("directories:", " java/com/google", "targets:", " //java/com/google:lib", "test_sources:", " java/com/google/tests/*", " java/com/google/moretests");
workspace.createDirectory(new WorkspacePath("java/com/google"));
VirtualFile testFile = workspace.createFile(new WorkspacePath("java/com/google/tests/ExampleTest.java"));
VirtualFile moreTestsFile = workspace.createFile(new WorkspacePath("java/com/google/moretests/AnotherExampleTest.java"));
BlazeSyncParams syncParams = new BlazeSyncParams.Builder("Full Sync", BlazeSyncParams.SyncMode.FULL).addProjectViewTargets(true).build();
runBlazeSync(syncParams);
errorCollector.assertNoIssues();
ImmutableList<ContentEntry> contentEntries = getWorkspaceContentEntries();
assertThat(contentEntries).hasSize(1);
SourceFolder testRoot = findSourceFolder(contentEntries.get(0), testFile.getParent());
SourceFolder moreTestsRoot = findSourceFolder(contentEntries.get(0), moreTestsFile.getParent());
assertThat(testRoot).isNotNull();
assertThat(testRoot.isTestSource()).isTrue();
assertThat(testRoot.getPackagePrefix()).isEqualTo("com.google.tests");
assertThat(moreTestsRoot).isNotNull();
assertThat(moreTestsRoot.isTestSource()).isTrue();
assertThat(moreTestsRoot.getPackagePrefix()).isEqualTo("com.google.moretests");
}
use of com.google.idea.blaze.base.sync.BlazeSyncParams in project intellij by bazelbuild.
the class ScalaSyncTest method testScalaClassesPresentInClassPath.
@Test
public void testScalaClassesPresentInClassPath() throws Exception {
setProjectView("directories:", " src/main/scala/com/google", "targets:", " //src/main/scala/com/google:lib", "additional_languages:", " scala");
workspace.createFile(new WorkspacePath("src/main/scala/com/google/ClassWithUniqueName1.scala"), "package com.google;", "public class ClassWithUniqueName1 {}");
workspace.createFile(new WorkspacePath("src/main/scala/com/google/ClassWithUniqueName2.scala"), "package com.google;", "public class ClassWithUniqueName2 {}");
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("src/main/scala/com/google/BUILD")).setLabel("//src/main/scala/com/google:lib").setKind("scala_library").addSource(sourceRoot("src/main/scala/com/google/ClassWithUniqueName1.scala")).addSource(sourceRoot("src/main/scala/com/google/ClassWithUniqueName2.scala")).setJavaInfo(JavaIdeInfo.builder())).build();
setTargetMap(targetMap);
BlazeSyncParams syncParams = new BlazeSyncParams.Builder("Full Sync", BlazeSyncParams.SyncMode.FULL).addProjectViewTargets(true).build();
runBlazeSync(syncParams);
errorCollector.assertNoIssues();
BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData();
assertThat(blazeProjectData).isNotNull();
assertThat(blazeProjectData.targetMap).isEqualTo(targetMap);
assertThat(blazeProjectData.workspaceLanguageSettings).isEqualTo(new WorkspaceLanguageSettings(WorkspaceType.JAVA, ImmutableSet.of(LanguageClass.GENERIC, LanguageClass.JAVA, LanguageClass.SCALA)));
BlazeJavaSyncData javaSyncData = blazeProjectData.syncState.get(BlazeJavaSyncData.class);
assertThat(javaSyncData).isNotNull();
List<BlazeContentEntry> contentEntries = javaSyncData.importResult.contentEntries;
assertThat(contentEntries).hasSize(1);
BlazeContentEntry contentEntry = contentEntries.get(0);
assertThat(contentEntry.contentRoot.getPath()).isEqualTo(workspaceRoot.fileForPath(new WorkspacePath("src/main/scala/com/google")).getPath());
assertThat(contentEntry.sources).hasSize(1);
BlazeSourceDirectory sourceDir = contentEntry.sources.get(0);
assertThat(sourceDir.getPackagePrefix()).isEqualTo("com.google");
assertThat(sourceDir.getDirectory().getPath()).isEqualTo(workspaceRoot.fileForPath(new WorkspacePath("src/main/scala/com/google")).getPath());
}
use of com.google.idea.blaze.base.sync.BlazeSyncParams in project intellij by bazelbuild.
the class JavascriptSyncTest method testTestSourcesMissingFromDirectoriesSectionAreAdded.
@Test
public void testTestSourcesMissingFromDirectoriesSectionAreAdded() {
TestUtils.setPlatformPrefix(getTestRootDisposable(), PlatformUtils.IDEA_PREFIX);
setProjectView("directories:", " common/jslayout", "targets:", " //common/jslayout/...:all", "test_sources:", " */tests", "workspace_type: javascript");
VirtualFile testDir = workspace.createDirectory(new WorkspacePath("common/jslayout/tests"));
BlazeSyncParams syncParams = new BlazeSyncParams.Builder("Full Sync", BlazeSyncParams.SyncMode.FULL).addProjectViewTargets(true).build();
runBlazeSync(syncParams);
errorCollector.assertNoIssues();
ImmutableList<ContentEntry> contentEntries = getWorkspaceContentEntries();
assertThat(contentEntries).hasSize(1);
SourceFolder root = findSourceFolder(contentEntries.get(0), testDir.getParent());
assertThat(root.isTestSource()).isFalse();
SourceFolder testRoot = findSourceFolder(contentEntries.get(0), testDir);
assertThat(testRoot).isNotNull();
assertThat(testRoot.isTestSource()).isTrue();
}
Aggregations