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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations