use of com.google.idea.blaze.base.run.BlazeRunConfiguration in project intellij by bazelbuild.
the class BlazeJavaMainClassConfigurationProducerTest method testUniqueJavaBinaryChosen.
@Test
public void testUniqueJavaBinaryChosen() {
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setKind("java_binary").setLabel("//com/google/binary:UnrelatedName").addSource(sourceRoot("com/google/binary/MainClass.java")).build()).build());
registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
PsiFile javaClass = createAndIndexFile(WorkspacePath.createIfValid("com/google/binary/MainClass.java"), "package com.google.binary;", "import java.lang.String;", "public class MainClass {", " public static void main(java.lang.String[] args) {}", "}");
RunConfiguration config = createConfigurationFromLocation(javaClass);
assertThat(config).isInstanceOf(BlazeRunConfiguration.class);
BlazeRunConfiguration blazeConfig = (BlazeRunConfiguration) config;
assertThat(blazeConfig.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//com/google/binary:UnrelatedName"));
}
use of com.google.idea.blaze.base.run.BlazeRunConfiguration in project intellij by bazelbuild.
the class BlazeJavaMainClassConfigurationProducerTest method testJavaBinaryWithMatchingNameChosen.
@Test
public void testJavaBinaryWithMatchingNameChosen() {
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setKind("java_binary").setLabel("//com/google/binary:UnrelatedName").addSource(sourceRoot("com/google/binary/MainClass.java")).build()).addTarget(TargetIdeInfo.builder().setKind("java_binary").setLabel("//com/google/binary:MainClass").addSource(sourceRoot("com/google/binary/MainClass.java")).build()).build());
registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
PsiFile javaClass = createAndIndexFile(WorkspacePath.createIfValid("com/google/binary/MainClass.java"), "package com.google.binary;", "import java.lang.String;", "public class MainClass {", " public static void main(java.lang.String[] args) {}", "}");
RunConfiguration config = createConfigurationFromLocation(javaClass);
assertThat(config).isInstanceOf(BlazeRunConfiguration.class);
BlazeRunConfiguration blazeConfig = (BlazeRunConfiguration) config;
assertThat(blazeConfig.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//com/google/binary:MainClass"));
}
use of com.google.idea.blaze.base.run.BlazeRunConfiguration in project intellij by bazelbuild.
the class BlazeScalaMainClassConfigurationProducerTest method testUniqueScalaBinaryChosen.
@Test
public void testUniqueScalaBinaryChosen() {
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setKind("scala_binary").setLabel("//com/google/binary:UnrelatedName").addSource(sourceRoot("com/google/binary/MainClass.scala")).build()).build());
registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
PsiFile scalaFile = createAndIndexFile(WorkspacePath.createIfValid("com/google/binary/MainClass.scala"), "package com.google.binary {", " object MainClass {", " def main(args: Array[String]) {}", " }", "}", "package scala { final class Array[T] {} }", "package java.lang { public final class String {} }");
RunConfiguration config = createConfigurationFromLocation(scalaFile);
assertThat(config).isInstanceOf(BlazeRunConfiguration.class);
BlazeRunConfiguration blazeConfig = (BlazeRunConfiguration) config;
assertThat(blazeConfig).isNotNull();
assertThat(blazeConfig.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//com/google/binary:UnrelatedName"));
}
Aggregations