Search in sources :

Example 6 with BlazeSyncParams

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");
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) VirtualFile(com.intellij.openapi.vfs.VirtualFile) SourceFolder(com.intellij.openapi.roots.SourceFolder) ContentEntry(com.intellij.openapi.roots.ContentEntry) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) BlazeSyncParams(com.google.idea.blaze.base.sync.BlazeSyncParams) Test(org.junit.Test)

Example 7 with BlazeSyncParams

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());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) BlazeJavaSyncData(com.google.idea.blaze.java.sync.model.BlazeJavaSyncData) BlazeSourceDirectory(com.google.idea.blaze.java.sync.model.BlazeSourceDirectory) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) BlazeSyncParams(com.google.idea.blaze.base.sync.BlazeSyncParams) Test(org.junit.Test)

Example 8 with BlazeSyncParams

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");
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) VirtualFile(com.intellij.openapi.vfs.VirtualFile) SourceFolder(com.intellij.openapi.roots.SourceFolder) ContentEntry(com.intellij.openapi.roots.ContentEntry) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) BlazeSyncParams(com.google.idea.blaze.base.sync.BlazeSyncParams) Test(org.junit.Test)

Example 9 with BlazeSyncParams

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());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) BlazeJavaSyncData(com.google.idea.blaze.java.sync.model.BlazeJavaSyncData) BlazeSourceDirectory(com.google.idea.blaze.java.sync.model.BlazeSourceDirectory) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) BlazeSyncParams(com.google.idea.blaze.base.sync.BlazeSyncParams) Test(org.junit.Test)

Example 10 with BlazeSyncParams

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();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) SourceFolder(com.intellij.openapi.roots.SourceFolder) ContentEntry(com.intellij.openapi.roots.ContentEntry) BlazeSyncParams(com.google.idea.blaze.base.sync.BlazeSyncParams) Test(org.junit.Test)

Aggregations

WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)12 BlazeSyncParams (com.google.idea.blaze.base.sync.BlazeSyncParams)12 Test (org.junit.Test)12 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)8 BlazeContentEntry (com.google.idea.blaze.java.sync.model.BlazeContentEntry)8 ContentEntry (com.intellij.openapi.roots.ContentEntry)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 SourceFolder (com.intellij.openapi.roots.SourceFolder)6 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)3 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)3 BlazeJavaSyncData (com.google.idea.blaze.java.sync.model.BlazeJavaSyncData)3 BlazeSourceDirectory (com.google.idea.blaze.java.sync.model.BlazeSourceDirectory)3 WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)2