Search in sources :

Example 16 with BlazeContentEntry

use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.

the class SourceDirectoryCalculatorTest method testCalculatesPackageForSimpleCase.

@Test
public void testCalculatesPackageForSimpleCase() throws Exception {
    mockInputStreamProvider.addFile("/root/java/com/google/Bla.java", "package com.google;\n public class Bla {}");
    List<SourceArtifact> sourceArtifacts = ImmutableList.of(SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/Bla.java").setIsSource(true)).build());
    ImmutableList<BlazeContentEntry> result = sourceDirectoryCalculator.calculateContentEntries(project, context, workspaceRoot, decoder, buildImportRoots(ImmutableList.of(new WorkspacePath("java/com/google")), ImmutableList.of()), sourceArtifacts, NO_MANIFESTS);
    assertThat(result).containsExactly(BlazeContentEntry.builder("/root/java/com/google").addSource(BlazeSourceDirectory.builder("/root/java/com/google").setPackagePrefix("com.google").build()).build());
    issues.assertNoIssues();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) Test(org.junit.Test)

Example 17 with BlazeContentEntry

use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.

the class SourceDirectoryCalculatorTest method testSourcesToSourceDirectories_packagesMatchPathButNotAtRoot.

@Test
public void testSourcesToSourceDirectories_packagesMatchPathButNotAtRoot() throws Exception {
    mockInputStreamProvider.addFile("/root/java/com/google/Bla.java", "package com.google.different;\n public class Bla {}").addFile("/root/java/com/google/subpackage/Bla.java", "package com.google.subpackage;\n public class Bla {}").addFile("/root/java/com/google/subpackage/subsubpackage/Bla.java", "package com.google.subpackage.subsubpackage;\n public class Bla {}");
    List<SourceArtifact> sourceArtifacts = ImmutableList.of(SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/Bla.java").setIsSource(true)).build(), SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/subpackage/Bla.java").setIsSource(true)).build(), SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/subpackage/subsubpackage/Bla.java").setIsSource(true)).build());
    ImmutableList<BlazeContentEntry> result = sourceDirectoryCalculator.calculateContentEntries(project, context, workspaceRoot, decoder, buildImportRoots(ImmutableList.of(new WorkspacePath("java/com/google")), ImmutableList.of()), sourceArtifacts, NO_MANIFESTS);
    issues.assertNoIssues();
    assertThat(result).containsExactly(BlazeContentEntry.builder("/root/java/com/google").addSource(BlazeSourceDirectory.builder("/root/java/com/google").setPackagePrefix("com.google.different").build()).addSource(BlazeSourceDirectory.builder("/root/java/com/google/subpackage").setPackagePrefix("com.google.subpackage").build()).build());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) Test(org.junit.Test)

Example 18 with BlazeContentEntry

use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.

the class SourceDirectoryCalculatorTest method testSourcesToSourceDirectories_testReturnsTest.

@Test
public void testSourcesToSourceDirectories_testReturnsTest() throws Exception {
    mockInputStreamProvider.addFile("/root/java/com/google/Bla.java", "package com.google;\n public class Bla {}");
    List<SourceArtifact> sourceArtifacts = ImmutableList.of(SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/Bla.java").setIsSource(true)).build());
    ImmutableList<BlazeContentEntry> result = sourceDirectoryCalculator.calculateContentEntries(project, context, workspaceRoot, decoder, buildImportRoots(ImmutableList.of(new WorkspacePath("java/com/google")), ImmutableList.of()), sourceArtifacts, NO_MANIFESTS);
    issues.assertNoIssues();
    assertThat(result).containsExactly(BlazeContentEntry.builder("/root/java/com/google").addSource(BlazeSourceDirectory.builder("/root/java/com/google").setPackagePrefix("com.google").build()).build());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) Test(org.junit.Test)

Example 19 with BlazeContentEntry

use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.

the class SourceDirectoryCalculatorTest method testSourcesToSourceDirectories_multipleNonMatchingPackagesAreNotMerged.

@Test
public void testSourcesToSourceDirectories_multipleNonMatchingPackagesAreNotMerged() throws Exception {
    mockInputStreamProvider.addFile("/root/java/com/google/Bla.java", "package com.google;\n public class Bla {}").addFile("/root/java/com/google/subpackage/Bla.java", "package com.google.different;\n public class Bla {}");
    List<SourceArtifact> sourceArtifacts = ImmutableList.of(SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/Bla.java").setIsSource(true)).build(), SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/subpackage/Bla.java").setIsSource(true)).build());
    ImmutableList<BlazeContentEntry> result = sourceDirectoryCalculator.calculateContentEntries(project, context, workspaceRoot, decoder, buildImportRoots(ImmutableList.of(new WorkspacePath("java/com/google")), ImmutableList.of()), sourceArtifacts, NO_MANIFESTS);
    issues.assertNoIssues();
    assertThat(result).containsExactly(BlazeContentEntry.builder("/root/java/com/google").addSource(BlazeSourceDirectory.builder("/root/java/com/google").setPackagePrefix("com.google").build()).addSource(BlazeSourceDirectory.builder("/root/java/com/google/subpackage").setPackagePrefix("com.google.different").build()).build());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) Test(org.junit.Test)

Example 20 with BlazeContentEntry

use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.

the class SourceDirectoryCalculatorTest method testSourcesToSourceDirectories_orderIsIrrelevant.

@Test
public void testSourcesToSourceDirectories_orderIsIrrelevant() throws Exception {
    mockInputStreamProvider.addFile("/root/java/com/google/Bla.java", "package com.google;\n public class Bla {}").addFile("/root/java/com/google/subpackage/Bla.java", "package com.google.different;\n public class Bla {}");
    List<SourceArtifact> sourceArtifacts = ImmutableList.of(SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/subpackage/Bla.java").setIsSource(true)).build(), SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/Bla.java").setIsSource(true)).build());
    ImmutableList<BlazeContentEntry> result = sourceDirectoryCalculator.calculateContentEntries(project, context, workspaceRoot, decoder, buildImportRoots(ImmutableList.of(new WorkspacePath("java/com/google")), ImmutableList.of()), sourceArtifacts, NO_MANIFESTS);
    issues.assertNoIssues();
    assertThat(result).containsExactly(BlazeContentEntry.builder("/root/java/com/google").addSource(BlazeSourceDirectory.builder("/root/java/com/google").setPackagePrefix("com.google").build()).addSource(BlazeSourceDirectory.builder("/root/java/com/google/subpackage").setPackagePrefix("com.google.different").build()).build());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) Test(org.junit.Test)

Aggregations

BlazeContentEntry (com.google.idea.blaze.java.sync.model.BlazeContentEntry)29 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)27 Test (org.junit.Test)26 BlazeJavaSyncData (com.google.idea.blaze.java.sync.model.BlazeJavaSyncData)6 BlazeSourceDirectory (com.google.idea.blaze.java.sync.model.BlazeSourceDirectory)5 File (java.io.File)5 BlazeJavaImportResult (com.google.idea.blaze.java.sync.model.BlazeJavaImportResult)4 SourceFolder (com.intellij.openapi.roots.SourceFolder)4 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)3 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)3 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)3 GlobSet (com.google.idea.blaze.base.projectview.section.Glob.GlobSet)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)2 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)2 BlazeSyncParams (com.google.idea.blaze.base.sync.BlazeSyncParams)2 Joiner (com.google.common.base.Joiner)1 Objects (com.google.common.base.Objects)1 Splitter (com.google.common.base.Splitter)1 Strings (com.google.common.base.Strings)1