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();
}
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());
}
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());
}
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());
}
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());
}
Aggregations