Search in sources :

Example 51 with MockBlazeProjectDataManager

use of com.google.idea.blaze.base.model.MockBlazeProjectDataManager in project intellij by bazelbuild.

the class CombinedTestHeuristicTest method doSetup.

@Before
public final void doSetup() {
    BlazeProjectData blazeProjectData = MockBlazeProjectDataBuilder.builder(workspaceRoot).build();
    registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(blazeProjectData));
    // required for IntelliJ to recognize annotations, JUnit version, etc.
    workspace.createPsiFile(new WorkspacePath("org/junit/runner/RunWith.java"), "package org.junit.runner;" + "public @interface RunWith {" + "    Class<? extends Runner> value();" + "}");
    workspace.createPsiFile(new WorkspacePath("org/junit/Test"), "package org.junit;", "public @interface Test {}");
    workspace.createPsiFile(new WorkspacePath("org/junit/runners/JUnit4"), "package org.junit.runners;", "public class JUnit4 {}");
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) Before(org.junit.Before)

Example 52 with MockBlazeProjectDataManager

use of com.google.idea.blaze.base.model.MockBlazeProjectDataManager in project intellij by bazelbuild.

the class ProjectViewIntegrationTestCase method doSetup.

@Before
public final void doSetup() {
    BlazeProjectDataManager mockProjectDataManager = new MockBlazeProjectDataManager(MockBlazeProjectDataBuilder.builder(workspaceRoot).build());
    registerProjectService(BlazeProjectDataManager.class, mockProjectDataManager);
    editorTest = new EditorTestHelper(getProject(), testFixture);
}
Also used : EditorTestHelper(com.google.idea.blaze.base.EditorTestHelper) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) BlazeProjectDataManager(com.google.idea.blaze.base.sync.data.BlazeProjectDataManager) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) Before(org.junit.Before)

Example 53 with MockBlazeProjectDataManager

use of com.google.idea.blaze.base.model.MockBlazeProjectDataManager in project intellij by bazelbuild.

the class BlazeCommandRunConfigurationGenericHandlerIntegrationTest method doSetup.

@Before
public final void doSetup() throws Exception {
    // Without BlazeProjectData, the configuration editor is always disabled.
    BlazeProjectDataManager mockProjectDataManager = new MockBlazeProjectDataManager(MockBlazeProjectDataBuilder.builder(workspaceRoot).build());
    registerProjectService(BlazeProjectDataManager.class, mockProjectDataManager);
    type = BlazeCommandRunConfigurationType.getInstance();
    configuration = type.getFactory().createTemplateConfiguration(getProject());
}
Also used : MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) BlazeProjectDataManager(com.google.idea.blaze.base.sync.data.BlazeProjectDataManager) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) Before(org.junit.Before)

Example 54 with MockBlazeProjectDataManager

use of com.google.idea.blaze.base.model.MockBlazeProjectDataManager in project intellij by bazelbuild.

the class TestTargetSourcesHeuristicTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    super.initTest(applicationServices, projectServices);
    BlazeProjectData blazeProjectData = MockBlazeProjectDataBuilder.builder(workspaceRoot).build();
    projectServices.register(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(blazeProjectData));
    ExtensionPointImpl<TestTargetHeuristic> ep = registerExtensionPoint(TestTargetHeuristic.EP_NAME, TestTargetHeuristic.class);
    ep.registerExtension(new TestTargetSourcesHeuristic());
}
Also used : BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager)

Example 55 with MockBlazeProjectDataManager

use of com.google.idea.blaze.base.model.MockBlazeProjectDataManager 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"));
}
Also used : BlazeRunConfiguration(com.google.idea.blaze.base.run.BlazeRunConfiguration) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) BlazeRunConfiguration(com.google.idea.blaze.base.run.BlazeRunConfiguration) MockBlazeProjectDataBuilder(com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder) PsiFile(com.intellij.psi.PsiFile) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) Test(org.junit.Test)

Aggregations

MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)68 Test (org.junit.Test)48 MockBlazeProjectDataBuilder (com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder)43 PsiFile (com.intellij.psi.PsiFile)37 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)34 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)27 BlazeCommandRunConfiguration (com.google.idea.blaze.base.run.BlazeCommandRunConfiguration)23 ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)21 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)14 Before (org.junit.Before)14 BlazeProjectDataManager (com.google.idea.blaze.base.sync.data.BlazeProjectDataManager)13 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)10 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)9 BlazeRunConfiguration (com.google.idea.blaze.base.run.BlazeRunConfiguration)8 PsiClass (com.intellij.psi.PsiClass)7 WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)6 WorkspacePathResolverImpl (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl)5 PsiDirectory (com.intellij.psi.PsiDirectory)5 GoFile (com.goide.psi.GoFile)4 EditorTestHelper (com.google.idea.blaze.base.EditorTestHelper)4