@Test public void shouldReturnAllConfigurations() { panel.populateWithConfigurations(asList(notDefaultDataSource, defaultDataSource)); Set<XQueryDataSourceConfiguration> result = new HashSet<XQueryDataSourceConfiguration>(panel.getCurrentConfigurations()); assertThat(result.size(), is(2)); assertThat(result.contains(notDefaultDataSource), is(true)); assertThat(result.contains(defaultDataSource), is(true)); }
@Test public void shouldDisplayDataSourceNameAsListEntry() { panel.populateWithConfigurations(asList(defaultDataSource)); JListFixture result = window.list(); result.cellReader(new DataSourceListCellReader()); assertThat(result.item(0).value(), is(defaultDataSource.NAME)); }
@Test public void shouldCleanupDetailsPanelAndDisplayNewConfigAfterSelectionChanged() { panel.populateWithConfigurations(asList(notDefaultDataSource, defaultDataSource)); window.list().selectItem(1); verify(dataSourceDetailsPanel, times(2)).stopDisplayingDetails(); verify(dataSourceDetailsPanel, times(1)) .displayDetails(eq(defaultDataSource), isA(ConfigurationChangeListener.class)); }
@Test public void shouldReturnSelectedDataSource() { panel.populateWithConfigurations(asList(notDefaultDataSource, defaultDataSource)); GuiActionRunner.execute( new GuiTask() { @Override protected void executeInEDT() throws Throwable { assertThat(panel.getSelectedDataSource(), is(notDefaultDataSource)); } }); }
@Test public void shouldOnlySwapObjectsInModelIfUpdatedWithNotDefault() { panel.populateWithConfigurations(asList(defaultDataSource)); window.list().selectItem(0); execute( new GuiTask() { @Override protected void executeInEDT() throws Throwable { panel.updateCurrentlySelectedItemWithData(notDefaultDataSource); assertThat(panel.getSelectedDataSource(), is(notDefaultDataSource)); assertThat(panel.getSelectedDataSource().DEFAULT, is(false)); } }); }
@Test public void shouldRemoveEntryAfterRemoveButtonClicked() { panel.populateWithConfigurations(asList(defaultDataSource)); final AnActionButton action = getAnActionButton(REMOVE); final AnActionEvent event = new TestActionEvent(action); execute( new GuiTask() { @Override protected void executeInEDT() throws Throwable { action.actionPerformed(event); } }); window.list().requireNoSelection(); assertThat(window.list().contents().length, is(0)); }
@Test public void shouldAddNewDataSourceAfterExecutionInvoked() { panel.populateWithConfigurations(asList(notDefaultDataSource)); clickAdd(); GuiActionRunner.execute( new GuiTask() { @Override protected void executeInEDT() throws Throwable { addDataSourceActionExecutor.execute(XQueryDataSourceType.SAXON); } }); JListFixture list = window.list().cellReader(new DataSourceListCellReader()); list.requireSelection(1); assertThat(list.contents()[1], is(XQueryDataSourceType.SAXON.getPresentableName())); }
@Test public void shouldShowPanelWhenOneDataSourceAvailable() { panel.populateWithConfigurations(asList(defaultDataSource)); window.panel(DATA_SOURCE_LIST_PANEL).requireVisible(); }
private AnActionButton getAnActionButton(CommonActionsPanel.Buttons button) { return panel.getToolbarDecorator().getActionsPanel().getAnActionButton(button); }
private void preparePanelWithEmptyList() { panel.populateWithConfigurations(Collections.<XQueryDataSourceConfiguration>emptyList()); }
@Test public void shouldHaveFirstItemSelectedItemWhenTwoDataSourcesAvailable() { panel.populateWithConfigurations(asList(notDefaultDataSource, defaultDataSource)); window.list().requireSelection(0); }
@Test public void shouldHaveSelectedItemWhenOneDataSourceAvailable() { panel.populateWithConfigurations(asList(defaultDataSource)); window.list().requireSelection(0); }