Search in sources :

Example 1 with MockExperimentService

use of com.google.idea.common.experiments.MockExperimentService in project intellij by bazelbuild.

the class BlazeBuildServiceTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    BlazeImportSettingsManager importSettingsManager = new BlazeImportSettingsManager();
    importSettingsManager.setImportSettings(new BlazeImportSettings("", "", "", "", Blaze.BuildSystem.Blaze));
    projectServices.register(BlazeImportSettingsManager.class, importSettingsManager);
    applicationServices.register(ExperimentService.class, new MockExperimentService());
    ProjectView view = ProjectView.builder().add(ListSection.builder(TargetSection.KEY).add(TargetExpression.fromStringSafe("//view/target:one")).add(TargetExpression.fromStringSafe("//view/target:two"))).build();
    viewSet = ProjectViewSet.builder().add(new File("view/target/.blazeproject"), view).build();
    ProjectViewManager viewManager = new MockProjectViewManager(viewSet);
    projectServices.register(ProjectViewManager.class, viewManager);
    BlazeProjectData blazeProjectData = MockBlazeProjectDataBuilder.builder(workspaceRoot).build();
    projectServices.register(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(blazeProjectData));
    applicationServices.register(BlazeBuildService.class, spy(new BlazeBuildService()));
    service = BlazeBuildService.getInstance();
    assertThat(service).isNotNull();
    // Can't mock BlazeExecutor.submitTask.
    doNothing().when(service).buildTargetExpressions(any(), any(), any(), any());
}
Also used : BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) MockExperimentService(com.google.idea.common.experiments.MockExperimentService) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) File(java.io.File) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) ProjectViewManager(com.google.idea.blaze.base.projectview.ProjectViewManager)

Example 2 with MockExperimentService

use of com.google.idea.common.experiments.MockExperimentService in project intellij by bazelbuild.

the class BlazeIssueParserTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    super.initTest(applicationServices, projectServices);
    applicationServices.register(ExperimentService.class, new MockExperimentService());
    projectViewManager = mock(ProjectViewManager.class);
    projectServices.register(ProjectViewManager.class, projectViewManager);
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(new File(".blazeproject"), ProjectView.builder().add(ListSection.builder(TargetSection.KEY).add(TargetExpression.fromStringSafe("//tests/com/google/a/b/c/d/baz:baz")).add(TargetExpression.fromStringSafe("//package/path:hello4"))).build()).build();
    when(projectViewManager.getProjectViewSet()).thenReturn(projectViewSet);
    workspaceRoot = new WorkspaceRoot(new File("/root"));
    parsers = ImmutableList.of(new BlazeIssueParser.CompileParser(workspaceRoot), new BlazeIssueParser.TracebackParser(), new BlazeIssueParser.BuildParser(), new BlazeIssueParser.SkylarkErrorParser(), new BlazeIssueParser.LinelessBuildParser(), new BlazeIssueParser.ProjectViewLabelParser(projectViewSet), new BlazeIssueParser.InvalidTargetProjectViewPackageParser(projectViewSet, "no such package '(.*)': BUILD file not found on package path"), new BlazeIssueParser.InvalidTargetProjectViewPackageParser(projectViewSet, "no targets found beneath '(.*)'"), new BlazeIssueParser.InvalidTargetProjectViewPackageParser(projectViewSet, "ERROR: invalid target format '(.*)'"), new BlazeIssueParser.FileNotFoundBuildParser(workspaceRoot), BlazeIssueParser.GenericErrorParser.INSTANCE);
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) ProjectViewManager(com.google.idea.blaze.base.projectview.ProjectViewManager) File(java.io.File)

Example 3 with MockExperimentService

use of com.google.idea.common.experiments.MockExperimentService in project intellij by bazelbuild.

the class ProjectViewSetTest method initTest.

@Override
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
    super.initTest(applicationServices, projectServices);
    applicationServices.register(ExperimentService.class, new MockExperimentService());
    registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService)

Example 4 with MockExperimentService

use of com.google.idea.common.experiments.MockExperimentService in project intellij by bazelbuild.

the class ProjectViewParserTest method initTest.

@Override
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
    super.initTest(applicationServices, projectServices);
    context = new BlazeContext();
    errorCollector = new ErrorCollector();
    context.addOutputSink(IssueOutput.class, errorCollector);
    projectViewParser = new ProjectViewParser(context, new WorkspacePathResolverImpl(workspaceRoot));
    projectViewStorageManager = new MockProjectViewStorageManager();
    applicationServices.register(ProjectViewStorageManager.class, projectViewStorageManager);
    applicationServices.register(ExperimentService.class, new MockExperimentService());
    registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) ErrorCollector(com.google.idea.blaze.base.scope.ErrorCollector)

Example 5 with MockExperimentService

use of com.google.idea.common.experiments.MockExperimentService in project intellij by bazelbuild.

the class BlazeSyncManagerTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    super.initTest(applicationServices, projectServices);
    MockitoAnnotations.initMocks(this);
    applicationServices.register(BlazeUserSettings.class, mock(BlazeUserSettings.class));
    applicationServices.register(ExperimentService.class, new MockExperimentService());
    doNothing().when(manager).requestProjectSync(any());
    projectServices.register(BlazeSyncManager.class, manager);
    assertThat(BlazeSyncManager.getInstance(project)).isSameAs(manager);
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) BlazeUserSettings(com.google.idea.blaze.base.settings.BlazeUserSettings)

Aggregations

MockExperimentService (com.google.idea.common.experiments.MockExperimentService)25 BlazeImportSettingsManager (com.google.idea.blaze.base.settings.BlazeImportSettingsManager)8 MockBlazeExecutor (com.google.idea.blaze.base.async.executor.MockBlazeExecutor)6 Before (org.junit.Before)5 BuildSystemProvider (com.google.idea.blaze.base.bazel.BuildSystemProvider)4 BlazeExecutor (com.google.idea.blaze.base.async.executor.BlazeExecutor)3 BazelBuildSystemProvider (com.google.idea.blaze.base.bazel.BazelBuildSystemProvider)3 MockPrefetchService (com.google.idea.blaze.base.prefetch.MockPrefetchService)3 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)3 BlazeImportSettings (com.google.idea.blaze.base.settings.BlazeImportSettings)3 BlazeUserSettings (com.google.idea.blaze.base.settings.BlazeUserSettings)3 JavaLikeLanguage (com.google.idea.blaze.java.sync.source.JavaLikeLanguage)3 ExperimentService (com.google.idea.common.experiments.ExperimentService)3 VirtualFileSystemProvider (com.google.idea.blaze.base.io.VirtualFileSystemProvider)2 ProjectViewManager (com.google.idea.blaze.base.projectview.ProjectViewManager)2 BlazeCommandRunConfigurationHandlerProvider (com.google.idea.blaze.base.run.confighandler.BlazeCommandRunConfigurationHandlerProvider)2 TargetFinder (com.google.idea.blaze.base.run.targetfinder.TargetFinder)2 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)2 JavaSourcePackageReader (com.google.idea.blaze.java.sync.source.JavaSourcePackageReader)2 PackageManifestReader (com.google.idea.blaze.java.sync.source.PackageManifestReader)2