当前位置: 首页>>代码示例>>Java>>正文


Java ConfigurationContext.getConfigurationsFromContext方法代码示例

本文整理汇总了Java中com.intellij.execution.actions.ConfigurationContext.getConfigurationsFromContext方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationContext.getConfigurationsFromContext方法的具体用法?Java ConfigurationContext.getConfigurationsFromContext怎么用?Java ConfigurationContext.getConfigurationsFromContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.execution.actions.ConfigurationContext的用法示例。


在下文中一共展示了ConfigurationContext.getConfigurationsFromContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testProducedFromFuncallExpression

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Test
public void testProducedFromFuncallExpression() {
  PsiFile buildFile =
      workspace.createPsiFile(
          new WorkspacePath("java/com/google/test/BUILD"), "java_test(name='unit_tests'");

  FuncallExpression target =
      PsiUtils.findFirstChildOfClassRecursive(buildFile, FuncallExpression.class);
  assertThat(target).isNotNull();

  ConfigurationContext context = createContextFromPsi(target);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(BlazeBuildFileRunConfigurationProducer.class)).isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(config.getTarget())
      .isEqualTo(TargetExpression.fromStringSafe("//java/com/google/test:unit_tests"));
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:25,代码来源:BlazeBuildFileRunConfigurationProducerTest.java

示例2: testProducedFromPsiDirectory

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Test
public void testProducedFromPsiDirectory() {
  PsiDirectory directory =
      workspace.createPsiDirectory(new WorkspacePath("java/com/google/test"));
  workspace.createPsiFile(
      new WorkspacePath("java/com/google/test/BUILD"), "java_test(name='unit_tests'");

  ConfigurationContext context = createContextFromPsi(directory);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(AllInPackageBlazeConfigurationProducer.class)).isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(config.getTarget())
      .isEqualTo(TargetExpression.fromStringSafe("//java/com/google/test/...:all"));
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:22,代码来源:AllInPackageBlazeConfigurationProducerTest.java

示例3: testProducedFromGoFile

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Test
public void testProducedFromGoFile() {
  PsiFile goFile =
      createAndIndexFile(
          new WorkspacePath("foo/bar/foo_test.go"),
          "package foo",
          "import \"testing\"",
          "func TestFoo(t *testing.T) {}");

  MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
  builder.setTargetMap(
      TargetMapBuilder.builder()
          .addTarget(
              TargetIdeInfo.builder()
                  .setKind("go_test")
                  .setLabel("//foo/bar:foo_test")
                  .addSource(sourceRoot("foo/bar/foo_test.go"))
                  .build())
          .build());
  registerProjectService(
      BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));

  ConfigurationContext context = createContextFromPsi(goFile);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).isNotNull();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(BlazeGoTestConfigurationProducer.class)).isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(config.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//foo/bar:foo_test"));
  assertThat(getTestFilterContents(config)).isNull();
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:38,代码来源:BlazeGoTestConfigurationProducerTest.java

示例4: testNoFilterIfDirectoryAtPackageRoot

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Test
public void testNoFilterIfDirectoryAtPackageRoot() {
  MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
  builder.setTargetMap(
      TargetMapBuilder.builder()
          .addTarget(
              TargetIdeInfo.builder()
                  .setKind("java_test")
                  .setLabel("//java/com/google/test:TestClass")
                  .addSource(sourceRoot("java/com/google/test/TestClass.java"))
                  .build())
          .build());
  registerProjectService(
      BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));

  PsiDirectory directory = workspace.createPsiDirectory(new WorkspacePath("java"));
  createAndIndexFile(
      new WorkspacePath("java/com/google/test/TestClass.java"),
      "package com.google.test;",
      "@org.junit.runner.RunWith(org.junit.runners.JUnit4.class)",
      "public class TestClass {",
      "  @org.junit.Test",
      "  public void testMethod() {}",
      "}");

  ConfigurationContext context = createContextFromPsi(directory);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(MultipleJavaClassesTestConfigurationProducer.class))
      .isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(getTestFilterContents(config)).isNull();
  assertThat(config.getName()).isEqualTo("Blaze test test:TestClass");
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:41,代码来源:MultipleJavaClassesTestConfigurationProducerTest.java

示例5: testProducedFromPyFile

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Test
public void testProducedFromPyFile() {
  PsiFile pyFile =
      createAndIndexFile(
          new WorkspacePath("py/test/unittest.py"),
          "class UnitTest(googletest.TestCase):",
          "  def testSomething():",
          "    return");

  MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
  builder.setTargetMap(
      TargetMapBuilder.builder()
          .addTarget(
              TargetIdeInfo.builder()
                  .setKind("py_test")
                  .setLabel("//py/test:unittests")
                  .addSource(sourceRoot("py/test/unittest.py"))
                  .build())
          .build());
  registerProjectService(
      BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));

  ConfigurationContext context = createContextFromPsi(pyFile);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(BlazePyTestConfigurationProducer.class)).isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(config.getTarget())
      .isEqualTo(TargetExpression.fromStringSafe("//py/test:unittests"));
  assertThat(getTestFilterContents(config)).isNull();
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:38,代码来源:BlazePyTestConfigurationProducerTest.java

示例6: testProducedFromPyClass

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Test
public void testProducedFromPyClass() {
  PsiFile pyFile =
      createAndIndexFile(
          new WorkspacePath("py/test/unittest.py"),
          "class UnitTest(googletest.TestCase):",
          "  def testSomething():",
          "    return");

  MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
  builder.setTargetMap(
      TargetMapBuilder.builder()
          .addTarget(
              TargetIdeInfo.builder()
                  .setKind("py_test")
                  .setLabel("//py/test:unittests")
                  .addSource(sourceRoot("py/test/unittest.py"))
                  .build())
          .build());
  registerProjectService(
      BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));

  PyClass pyClass = PsiUtils.findFirstChildOfClassRecursive(pyFile, PyClass.class);
  assertThat(pyClass).isNotNull();

  ConfigurationContext context = createContextFromPsi(pyClass);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(BlazePyTestConfigurationProducer.class)).isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(config.getTarget())
      .isEqualTo(TargetExpression.fromStringSafe("//py/test:unittests"));
  assertThat(getTestFilterContents(config)).isEqualTo("--test_filter=UnitTest");
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:41,代码来源:BlazePyTestConfigurationProducerTest.java

示例7: testProducedFromTestCase

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Test
public void testProducedFromTestCase() {
  PsiFile pyFile =
      createAndIndexFile(
          new WorkspacePath("py/test/unittest.py"),
          "class UnitTest(googletest.TestCase):",
          "  def testSomething():",
          "    return");

  MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
  builder.setTargetMap(
      TargetMapBuilder.builder()
          .addTarget(
              TargetIdeInfo.builder()
                  .setKind("py_test")
                  .setLabel("//py/test:unittests")
                  .addSource(sourceRoot("py/test/unittest.py"))
                  .build())
          .build());
  registerProjectService(
      BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));

  PyFunction function = PsiUtils.findFirstChildOfClassRecursive(pyFile, PyFunction.class);
  assertThat(function).isNotNull();

  ConfigurationContext context = createContextFromPsi(function);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(BlazePyTestConfigurationProducer.class)).isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(config.getTarget())
      .isEqualTo(TargetExpression.fromStringSafe("//py/test:unittests"));
  assertThat(getTestFilterContents(config)).isEqualTo("--test_filter=UnitTest.testSomething");
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:41,代码来源:BlazePyTestConfigurationProducerTest.java

示例8: testProducedFromPyFile

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Test
public void testProducedFromPyFile() {
  PsiFile pyFile =
      createAndIndexFile(
          new WorkspacePath("py/bin/main.py"),
          "def main():",
          "  return",
          "if __name__ == '__main__':",
          "  main()");

  workspace.createFile(new WorkspacePath("py/bin/BUILD"), "py_binary(name = 'main')");

  MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
  builder.setTargetMap(
      TargetMapBuilder.builder()
          .addTarget(
              TargetIdeInfo.builder()
                  .setKind("py_binary")
                  .setLabel("//py/bin:main")
                  .addSource(sourceRoot("py/bin/main.py"))
                  .build())
          .build());
  registerProjectService(
      BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));

  ConfigurationContext context = createContextFromPsi(pyFile);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(BlazePyBinaryConfigurationProducer.class)).isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(config.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//py/bin:main"));
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.RUN);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:39,代码来源:BlazePyBinaryConfigurationProducerTest.java

示例9: testProducedFromGoFile

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Test
public void testProducedFromGoFile() {
  PsiFile goFile =
      createAndIndexFile(new WorkspacePath("foo/bar/main.go"), "package main", "func main() {}");

  MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
  builder.setTargetMap(
      TargetMapBuilder.builder()
          .addTarget(
              TargetIdeInfo.builder()
                  .setKind("go_binary")
                  .setLabel("//foo/bar:main")
                  .addSource(sourceRoot("foo/bar/main.go"))
                  .build())
          .build());
  registerProjectService(
      BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));

  ConfigurationContext context = createContextFromPsi(goFile);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).isNotNull();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(BlazeGoBinaryConfigurationProducer.class)).isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(config.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//foo/bar:main"));
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.RUN);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:33,代码来源:BlazeGoBinaryConfigurationProducerTest.java

示例10: testProducedFromPsiFile

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Test
public void testProducedFromPsiFile() {
  PsiFile javaFile =
      createAndIndexFile(
          new WorkspacePath("java/com/google/test/TestClass.java"),
          "package com.google.test;",
          "@org.junit.runner.RunWith(org.junit.runners.JUnit4.class)",
          "public class TestClass {",
          "  @org.junit.Test",
          "  public void testMethod1() {}",
          "  @org.junit.Test",
          "  public void testMethod2() {}",
          "}");

  MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
  builder.setTargetMap(
      TargetMapBuilder.builder()
          .addTarget(
              TargetIdeInfo.builder()
                  .setKind("java_test")
                  .setLabel("//java/com/google/test:TestClass")
                  .addSource(sourceRoot("java/com/google/test/TestClass.java"))
                  .build())
          .build());
  registerProjectService(
      BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));

  ConfigurationContext context = createContextFromPsi(javaFile);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(BlazeJavaTestClassConfigurationProducer.class)).isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(config.getTarget())
      .isEqualTo(TargetExpression.fromStringSafe("//java/com/google/test:TestClass"));
  assertThat(getTestFilterContents(config)).isEqualTo("--test_filter=com.google.test.TestClass#");
  assertThat(config.getName()).isEqualTo("Blaze test TestClass");
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:44,代码来源:BlazeJavaTestClassConfigurationProducerTest.java

示例11: testProducedFromPsiClass

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Test
public void testProducedFromPsiClass() {
  PsiFile javaFile =
      createAndIndexFile(
          new WorkspacePath("java/com/google/test/TestClass.java"),
          "package com.google.test;",
          "@org.junit.runner.RunWith(org.junit.runners.JUnit4.class)",
          "public class TestClass {",
          "  @org.junit.Test",
          "  public void testMethod1() {}",
          "  @org.junit.Test",
          "  public void testMethod2() {}",
          "}");

  MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
  builder.setTargetMap(
      TargetMapBuilder.builder()
          .addTarget(
              TargetIdeInfo.builder()
                  .setKind("java_test")
                  .setLabel("//java/com/google/test:TestClass")
                  .addSource(sourceRoot("java/com/google/test/TestClass.java"))
                  .build())
          .build());
  registerProjectService(
      BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));

  PsiClass javaClass = ((PsiClassOwner) javaFile).getClasses()[0];
  assertThat(javaClass).isNotNull();

  ConfigurationContext context = createContextFromPsi(javaClass);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(BlazeJavaTestClassConfigurationProducer.class)).isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(config.getTarget())
      .isEqualTo(TargetExpression.fromStringSafe("//java/com/google/test:TestClass"));
  assertThat(getTestFilterContents(config)).isEqualTo("--test_filter=com.google.test.TestClass#");
  assertThat(config.getName()).isEqualTo("Blaze test TestClass");
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:47,代码来源:BlazeJavaTestClassConfigurationProducerTest.java

示例12: testProducedFromPsiClassWithInnerTestClass

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Test
public void testProducedFromPsiClassWithInnerTestClass() {
  PsiFile javaFile =
      createAndIndexFile(
          new WorkspacePath("java/com/google/test/OuterClass.java"),
          "package com.google.test;",
          "@org.junit.runner.RunWith(org.junit.runners.Suite.class)",
          "@org.junit.runners.Suite.SuiteClasses({OuterClass.InnerClass.class})",
          "public class OuterClass {",
          "  @org.junit.runner.RunWith(org.junit.runners.JUnit4.class)",
          "  public static class InnerClass {",
          "    @org.junit.Test",
          "    public void testMethod1() {}",
          "    @org.junit.Test",
          "    public void testMethod2() {}",
          "  }",
          "}");

  MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
  builder.setTargetMap(
      TargetMapBuilder.builder()
          .addTarget(
              TargetIdeInfo.builder()
                  .setKind("java_test")
                  .setLabel("//java/com/google/test:OuterClass")
                  .addSource(sourceRoot("java/com/google/test/OuterClass.java"))
                  .build())
          .build());
  registerProjectService(
      BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));

  PsiClass javaClass = ((PsiClassOwner) javaFile).getClasses()[0];
  assertThat(javaClass).isNotNull();

  ConfigurationContext context = createContextFromPsi(javaClass);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(BlazeJavaTestClassConfigurationProducer.class)).isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(config.getTarget())
      .isEqualTo(TargetExpression.fromStringSafe("//java/com/google/test:OuterClass"));
  assertThat(getTestFilterContents(config))
      .isEqualTo(
          "--test_filter=com.google.test.OuterClass#|com.google.test.OuterClass.InnerClass#");
  assertThat(config.getName()).isEqualTo("Blaze test OuterClass");
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:53,代码来源:BlazeJavaTestClassConfigurationProducerTest.java

示例13: testProducedFromDirectory

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Test
public void testProducedFromDirectory() {
  MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
  builder.setTargetMap(
      TargetMapBuilder.builder()
          .addTarget(
              TargetIdeInfo.builder()
                  .setKind("java_test")
                  .setLabel("//java/com/google/test:TestClass")
                  .addSource(sourceRoot("java/com/google/test/TestClass.java"))
                  .build())
          .build());
  registerProjectService(
      BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));

  PsiDirectory directory =
      workspace.createPsiDirectory(new WorkspacePath("java/com/google/test"));
  createAndIndexFile(
      new WorkspacePath("java/com/google/test/TestClass.java"),
      "package com.google.test;",
      "@org.junit.runner.RunWith(org.junit.runners.JUnit4.class)",
      "public class TestClass {",
      "  @org.junit.Test",
      "  public void testMethod() {}",
      "}");

  ConfigurationContext context = createContextFromPsi(directory);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(MultipleJavaClassesTestConfigurationProducer.class))
      .isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(config.getTarget())
      .isEqualTo(TargetExpression.fromStringSafe("//java/com/google/test:TestClass"));
  assertThat(getTestFilterContents(config)).isEqualTo("--test_filter=com.google.test");
  assertThat(config.getName()).isEqualTo("Blaze test all in directory 'test'");
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:44,代码来源:MultipleJavaClassesTestConfigurationProducerTest.java

示例14: testProducedFromDirectoryWithNestedTests

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Test
public void testProducedFromDirectoryWithNestedTests() {
  MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
  builder.setTargetMap(
      TargetMapBuilder.builder()
          .addTarget(
              TargetIdeInfo.builder()
                  .setKind("java_test")
                  .setLabel("//java/com/google/test:TestClass")
                  .addSource(sourceRoot("java/com/google/test/TestClass.java"))
                  .build())
          .build());
  registerProjectService(
      BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));

  PsiDirectory directory = workspace.createPsiDirectory(new WorkspacePath("java/com/google"));
  createAndIndexFile(
      new WorkspacePath("java/com/google/test/TestClass.java"),
      "package com.google.test;",
      "@org.junit.runner.RunWith(org.junit.runners.JUnit4.class)",
      "public class TestClass {",
      "  @org.junit.Test",
      "  public void testMethod() {}",
      "}");

  ConfigurationContext context = createContextFromPsi(directory);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(MultipleJavaClassesTestConfigurationProducer.class))
      .isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(config.getTarget())
      .isEqualTo(TargetExpression.fromStringSafe("//java/com/google/test:TestClass"));
  assertThat(getTestFilterContents(config)).isEqualTo("--test_filter=com.google");
  assertThat(config.getName()).isEqualTo("Blaze test all in directory 'google'");
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:43,代码来源:MultipleJavaClassesTestConfigurationProducerTest.java

示例15: testProducedFromTestCase

import com.intellij.execution.actions.ConfigurationContext; //导入方法依赖的package包/类
@Test
public void testProducedFromTestCase() {
  PsiFile goFile =
      createAndIndexFile(
          new WorkspacePath("foo/bar/foo_test.go"),
          "package foo",
          "import \"testing\"",
          "func TestFoo(t *testing.T) {}");

  MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
  builder.setTargetMap(
      TargetMapBuilder.builder()
          .addTarget(
              TargetIdeInfo.builder()
                  .setKind("go_test")
                  .setLabel("//foo/bar:foo_test")
                  .addSource(sourceRoot("foo/bar/foo_test.go"))
                  .build())
          .build());
  registerProjectService(
      BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));

  List<GoFunctionDeclaration> functions =
      PsiUtils.findAllChildrenOfClassRecursive(goFile, GoFunctionDeclaration.class);
  assertThat(functions).hasSize(1);

  GoFunctionDeclaration function = functions.get(0);
  ConfigurationContext context = createContextFromPsi(function);
  List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
  assertThat(configurations).isNotNull();
  assertThat(configurations).hasSize(1);

  ConfigurationFromContext fromContext = configurations.get(0);
  assertThat(fromContext.isProducedBy(BlazeGoTestConfigurationProducer.class)).isTrue();
  assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);

  BlazeCommandRunConfiguration config =
      (BlazeCommandRunConfiguration) fromContext.getConfiguration();
  assertThat(config.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//foo/bar:foo_test"));
  assertThat(getTestFilterContents(config)).isEqualTo("--test_filter=^TestFoo$");
  assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:43,代码来源:BlazeGoTestConfigurationProducerTest.java


注:本文中的com.intellij.execution.actions.ConfigurationContext.getConfigurationsFromContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。