Search in sources :

Example 1 with BlazeCommandRunConfigurationSettingsEditor

use of com.google.idea.blaze.base.run.BlazeCommandRunConfiguration.BlazeCommandRunConfigurationSettingsEditor in project intellij by bazelbuild.

the class BlazeCommandRunConfigurationRunManagerImplTest method getStateElementShouldMatchAfterEditorApplyToAndResetFrom.

@Test
public void getStateElementShouldMatchAfterEditorApplyToAndResetFrom() throws ConfigurationException {
    final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());
    final BlazeCommandRunConfigurationSettingsEditor editor = new BlazeCommandRunConfigurationSettingsEditor(configuration);
    configuration.setTarget(Label.create("//package:rule"));
    final Element initialElement = runManager.getState();
    editor.resetFrom(configuration);
    editor.applyEditorTo(configuration);
    final Element newElement = runManager.getState();
    assertThat(xmlOutputter.outputString(newElement)).isEqualTo(xmlOutputter.outputString(initialElement));
    Disposer.dispose(editor);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) BlazeCommandRunConfigurationSettingsEditor(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration.BlazeCommandRunConfigurationSettingsEditor) Element(org.jdom.Element) Test(org.junit.Test)

Example 2 with BlazeCommandRunConfigurationSettingsEditor

use of com.google.idea.blaze.base.run.BlazeCommandRunConfiguration.BlazeCommandRunConfigurationSettingsEditor in project intellij by bazelbuild.

the class BlazeCommandRunConfigurationSettingsEditorTest method testEditorApplyToAndResetFromMatches.

@Test
public void testEditorApplyToAndResetFromMatches() throws ConfigurationException {
    BlazeCommandRunConfigurationSettingsEditor editor = new BlazeCommandRunConfigurationSettingsEditor(configuration);
    Label label = Label.create("//package:rule");
    configuration.setTarget(label);
    editor.resetFrom(configuration);
    BlazeCommandRunConfiguration readConfiguration = type.getFactory().createTemplateConfiguration(getProject());
    editor.applyEditorTo(readConfiguration);
    assertThat(readConfiguration.getTarget()).isEqualTo(label);
    Disposer.dispose(editor);
}
Also used : BlazeCommandRunConfigurationSettingsEditor(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration.BlazeCommandRunConfigurationSettingsEditor) Label(com.google.idea.blaze.base.model.primitives.Label) Test(org.junit.Test)

Example 3 with BlazeCommandRunConfigurationSettingsEditor

use of com.google.idea.blaze.base.run.BlazeCommandRunConfiguration.BlazeCommandRunConfigurationSettingsEditor in project intellij by bazelbuild.

the class BlazeCommandRunConfigurationSettingsEditorTest method testEditorApplyToAndResetFromHandlesNulls.

@Test
public void testEditorApplyToAndResetFromHandlesNulls() throws ConfigurationException {
    BlazeCommandRunConfigurationSettingsEditor editor = new BlazeCommandRunConfigurationSettingsEditor(configuration);
    editor.resetFrom(configuration);
    BlazeCommandRunConfiguration readConfiguration = type.getFactory().createTemplateConfiguration(getProject());
    editor.applyEditorTo(readConfiguration);
    assertThat(readConfiguration.getTarget()).isEqualTo(configuration.getTarget());
    Disposer.dispose(editor);
}
Also used : BlazeCommandRunConfigurationSettingsEditor(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration.BlazeCommandRunConfigurationSettingsEditor) Test(org.junit.Test)

Example 4 with BlazeCommandRunConfigurationSettingsEditor

use of com.google.idea.blaze.base.run.BlazeCommandRunConfiguration.BlazeCommandRunConfigurationSettingsEditor in project intellij by bazelbuild.

the class BlazeCommandRunConfigurationGenericHandlerIntegrationTest method testEditorApplyToAndResetFromHandlesNulls.

@Test
public void testEditorApplyToAndResetFromHandlesNulls() throws ConfigurationException {
    BlazeCommandRunConfigurationSettingsEditor editor = new BlazeCommandRunConfigurationSettingsEditor(configuration);
    // Call setTarget to initialize a generic handler, or this won't apply anything.
    configuration.setTarget(null);
    assertThat(configuration.getTarget()).isNull();
    assertThat(configuration.getHandler()).isInstanceOf(BlazeCommandGenericRunConfigurationHandler.class);
    BlazeCommandRunConfigurationCommonState state = (BlazeCommandRunConfigurationCommonState) configuration.getHandler().getState();
    editor.resetFrom(configuration);
    BlazeCommandRunConfiguration readConfiguration = type.getFactory().createTemplateConfiguration(getProject());
    TargetExpression targetExpression = TargetExpression.fromStringSafe("//...");
    readConfiguration.setTarget(targetExpression);
    BlazeCommandRunConfigurationCommonState readState = (BlazeCommandRunConfigurationCommonState) readConfiguration.getHandler().getState();
    readState.getCommandState().setCommand(COMMAND);
    readState.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
    readState.getExeFlagsState().setRawFlags(ImmutableList.of("--exeFlag1"));
    readState.getBlazeBinaryState().setBlazeBinary("/usr/bin/blaze");
    editor.applyEditorTo(readConfiguration);
    assertThat(readConfiguration.getTarget()).isNull();
    assertThat(configuration.getHandler()).isInstanceOf(BlazeCommandGenericRunConfigurationHandler.class);
    readState = (BlazeCommandRunConfigurationCommonState) readConfiguration.getHandler().getState();
    assertThat(readState.getCommandState().getCommand()).isEqualTo(state.getCommandState().getCommand());
    assertThat(readState.getBlazeFlagsState().getRawFlags()).isEqualTo(state.getBlazeFlagsState().getRawFlags());
    assertThat(readState.getExeFlagsState().getRawFlags()).isEqualTo(state.getExeFlagsState().getRawFlags());
    assertThat(readState.getBlazeBinaryState().getBlazeBinary()).isEqualTo(state.getBlazeBinaryState().getBlazeBinary());
    Disposer.dispose(editor);
}
Also used : BlazeCommandRunConfigurationCommonState(com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState) BlazeCommandRunConfigurationSettingsEditor(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration.BlazeCommandRunConfigurationSettingsEditor) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) Test(org.junit.Test)

Example 5 with BlazeCommandRunConfigurationSettingsEditor

use of com.google.idea.blaze.base.run.BlazeCommandRunConfiguration.BlazeCommandRunConfigurationSettingsEditor in project intellij by bazelbuild.

the class BlazeCommandRunConfigurationGenericHandlerIntegrationTest method testEditorApplyToAndResetFromMatches.

@Test
public void testEditorApplyToAndResetFromMatches() throws ConfigurationException {
    BlazeCommandRunConfigurationSettingsEditor editor = new BlazeCommandRunConfigurationSettingsEditor(configuration);
    TargetExpression targetExpression = TargetExpression.fromStringSafe("//...");
    configuration.setTarget(targetExpression);
    BlazeCommandRunConfigurationCommonState state = (BlazeCommandRunConfigurationCommonState) configuration.getHandler().getState();
    state.getCommandState().setCommand(COMMAND);
    state.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
    state.getExeFlagsState().setRawFlags(ImmutableList.of("--exeFlag1"));
    state.getBlazeBinaryState().setBlazeBinary("/usr/bin/blaze");
    editor.resetFrom(configuration);
    BlazeCommandRunConfiguration readConfiguration = type.getFactory().createTemplateConfiguration(getProject());
    editor.applyEditorTo(readConfiguration);
    assertThat(readConfiguration.getTarget()).isEqualTo(targetExpression);
    assertThat(readConfiguration.getHandler()).isInstanceOf(BlazeCommandGenericRunConfigurationHandler.class);
    BlazeCommandRunConfigurationCommonState readState = (BlazeCommandRunConfigurationCommonState) readConfiguration.getHandler().getState();
    assertThat(readState.getCommandState().getCommand()).isEqualTo(state.getCommandState().getCommand());
    assertThat(readState.getBlazeFlagsState().getRawFlags()).isEqualTo(state.getBlazeFlagsState().getRawFlags());
    assertThat(readState.getExeFlagsState().getRawFlags()).isEqualTo(state.getExeFlagsState().getRawFlags());
    assertThat(readState.getBlazeBinaryState().getBlazeBinary()).isEqualTo(state.getBlazeBinaryState().getBlazeBinary());
    Disposer.dispose(editor);
}
Also used : BlazeCommandRunConfigurationCommonState(com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState) BlazeCommandRunConfigurationSettingsEditor(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration.BlazeCommandRunConfigurationSettingsEditor) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) Test(org.junit.Test)

Aggregations

BlazeCommandRunConfigurationSettingsEditor (com.google.idea.blaze.base.run.BlazeCommandRunConfiguration.BlazeCommandRunConfigurationSettingsEditor)5 Test (org.junit.Test)5 TargetExpression (com.google.idea.blaze.base.model.primitives.TargetExpression)2 BlazeCommandRunConfigurationCommonState (com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState)2 Label (com.google.idea.blaze.base.model.primitives.Label)1 Element (org.jdom.Element)1 XMLOutputter (org.jdom.output.XMLOutputter)1