use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.
the class SourceDirectoryCalculatorTest method testSourcesToSourceDirectories_multipleSubdirectoriesAreNotMerged.
@Test
public void testSourcesToSourceDirectories_multipleSubdirectoriesAreNotMerged() throws Exception {
mockInputStreamProvider.addFile("/root/java/com/google/package0/Bla.java", "package com.google.packagewrong0;\n public class Bla {}").addFile("/root/java/com/google/package1/Bla.java", "package com.google.packagewrong1;\n public class Bla {}");
List<SourceArtifact> sourceArtifacts = ImmutableList.of(SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/package0/Bla.java").setIsSource(true)).build(), SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/package1/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/package0").setPackagePrefix("com.google.packagewrong0").build()).addSource(BlazeSourceDirectory.builder("/root/java/com/google/package1").setPackagePrefix("com.google.packagewrong1").build()).build());
}
use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.
the class SourceDirectoryCalculatorTest method testWorkspacePathIsAddedWithoutSources.
@Test
public void testWorkspacePathIsAddedWithoutSources() throws Exception {
List<SourceArtifact> sourceArtifacts = ImmutableList.of();
ImmutableList<BlazeContentEntry> result = sourceDirectoryCalculator.calculateContentEntries(project, context, workspaceRoot, decoder, buildImportRoots(ImmutableList.of(new WorkspacePath("java/com/google/app")), ImmutableList.of()), sourceArtifacts, NO_MANIFESTS);
issues.assertNoIssues();
assertThat(result).containsExactly(BlazeContentEntry.builder("/root/java/com/google/app").addSource(BlazeSourceDirectory.builder("/root/java/com/google/app").setPackagePrefix("com.google.app").build()).build());
}
use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.
the class SourceDirectoryCalculatorTest method testSourcesToSourceDirectories_packagesDoNotMatchPath.
@Test
public void testSourcesToSourceDirectories_packagesDoNotMatchPath() throws Exception {
mockInputStreamProvider.addFile("/root/java/com/google/Bla.java", "package com.facebook;\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.facebook").build()).build());
}
use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.
the class SourceDirectoryCalculatorTest method testSourcesToSourceDirectories_multipleMatchingPackagesAreMerged.
@Test
public void testSourcesToSourceDirectories_multipleMatchingPackagesAreMerged() 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.subpackage;\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()).build());
}
use of com.google.idea.blaze.java.sync.model.BlazeContentEntry in project intellij by bazelbuild.
the class SourceDirectoryCalculatorTest method testIncorrectPackageInMiddleOfTreeCausesMergePointHigherUp.
@Test
public void testIncorrectPackageInMiddleOfTreeCausesMergePointHigherUp() throws Exception {
mockInputStreamProvider.addFile("/root/java/com/google/idea/blaze/plugin/run/Run.java", "package com.google.idea.blaze.plugin.run;\n public class run {}").addFile("/root/java/com/google/idea/blaze/plugin/sync/Sync.java", "package com.google.idea.blaze.plugin.sync;\n public class Sync {}").addFile("/root/java/com/google/idea/blaze/Incorrect.java", "package com.google.idea.blaze.incorrect;\n public class Incorrect {}");
List<SourceArtifact> sourceArtifacts = ImmutableList.of(SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/idea/blaze/plugin/run/Run.java").setIsSource(true)).build(), SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/idea/blaze/plugin/sync/Sync.java").setIsSource(true)).build(), SourceArtifact.builder(TargetKey.forPlainTarget(LABEL)).setArtifactLocation(ArtifactLocation.builder().setRelativePath("java/com/google/idea/blaze/Incorrect.java").setIsSource(true)).build());
ImmutableList<BlazeContentEntry> result = sourceDirectoryCalculator.calculateContentEntries(project, context, workspaceRoot, decoder, buildImportRoots(ImmutableList.of(new WorkspacePath("")), ImmutableList.of()), sourceArtifacts, NO_MANIFESTS);
issues.assertNoIssues();
assertThat(result).containsExactly(BlazeContentEntry.builder("/root").addSource(BlazeSourceDirectory.builder("/root").setPackagePrefix("").build()).addSource(BlazeSourceDirectory.builder("/root/java").setPackagePrefix("").build()).addSource(BlazeSourceDirectory.builder("/root/java/com/google/idea/blaze").setPackagePrefix("com.google.idea.blaze.incorrect").build()).addSource(BlazeSourceDirectory.builder("/root/java/com/google/idea/blaze/plugin").setPackagePrefix("com.google.idea.blaze.plugin").build()).build());
}
Aggregations