@Override
 protected PanelTestingFrame getPanelTestingFrame() {
   defaultDataSource.DEFAULT = true;
   dataSourceDetailsPanel = mock(DataSourceDetailsPanel.class);
   panel = new TestingDataSourceListPanel(dataSourceDetailsPanel);
   return new PanelTestingFrame(panel);
 }
  @Test
  public void shouldPopulatePathList() {
    cfg.USER_DEFINED_LIBRARY_PATHS = asList(PATH_JAR, PATH_JAR);
    setUpPanelWithUserLibrary(ENABLED);

    String[] contents = window.list(PATH_LIST_NAME).contents();
    assertThat(contents.length, is(2));
    assertThat(contents[0], is(PATH_JAR));
    assertThat(contents[1], is(PATH_JAR));
  }
  @Test
  public void shouldReturnAllPaths() {
    cfg.USER_DEFINED_LIBRARY_PATHS = asList(PATH_JAR, PATH_JAR);
    setUpPanelWithUserLibrary(ENABLED);

    List<String> result = panel.getUserDefinedLibraryPaths();

    assertThat(result.size(), is(2));
    assertThat(result.get(0), is(PATH_JAR));
    assertThat(result.get(1), is(PATH_JAR));
  }
  @Test
  public void shouldRemoveSelectedPositionAfterActioningRemoveButton() {
    cfg.USER_DEFINED_LIBRARY_PATHS = asList(PATH_JAR);
    setUpPanelWithUserLibrary(ENABLED);
    final AnActionButton action = getAnActionButton(REMOVE);
    final AnActionEvent event = new TestActionEvent(action);
    panel.getPathList().setSelectedIndex(0);

    simulateAction(action, event);

    assertThat(window.list(PATH_LIST_NAME).contents().length, is(0));
  }
  @Test
  public void shouldInvokeChangeListenerAfterChangeOfPathListContents() {
    cfg.USER_DEFINED_LIBRARY_PATHS = asList(PATH_JAR);
    setUpPanelWithUserLibrary(ENABLED);
    panel.setUpChangeListeners(aggregatingPanel, listener);
    final AnActionButton action = getAnActionButton(REMOVE);
    final AnActionEvent event = new TestActionEvent(action);
    panel.getPathList().setSelectedIndex(0);

    simulateAction(action, event);

    verifyChangeListenerInvokedForCurrentConfigurationState();
  }
  @Test
  public void shouldRemoveSelectedPositionAfterActioningRemoveButton() {
    cfg.USER_DEFINED_LIBRARY_PATHS = asList(PATH_JAR);
    setUpPanelWithUserLibrary(ENABLED);
    final AnActionButton action = getAnActionButton(REMOVE);
    final AnActionEvent event = new TestActionEvent(action);
    panel.getPathList().setSelectedIndex(0);

    execute(
        new GuiTask() {
          @Override
          protected void executeInEDT() throws Throwable {
            action.actionPerformed(event);
          }
        });

    assertThat(window.list(PATH_LIST_NAME).contents().length, is(0));
  }
  @Test
  public void shouldInvokeChangeListenerAfterChangeOfPathListContents() {
    cfg.USER_DEFINED_LIBRARY_PATHS = asList(PATH_JAR);
    setUpPanelWithUserLibrary(ENABLED);
    panel.setUpChangeListeners(aggregatingPanel, listener);
    final AnActionButton action = getAnActionButton(REMOVE);
    final AnActionEvent event = new TestActionEvent(action);
    panel.getPathList().setSelectedIndex(0);

    execute(
        new GuiTask() {
          @Override
          protected void executeInEDT() throws Throwable {
            action.actionPerformed(event);
          }
        });

    verifyChangeListenerInvokedForCurrentConfigurationState();
  }
 private void setUpPanelWithUserLibrary(boolean enabled) {
   cfg.USER_DEFINED_LIBRARY_ENABLED = enabled;
   panel.init(cfg, aggregatingPanel, listener);
 }
  @Test
  public void shouldReturnTheSameValues() {
    XQueryDataSourceConfiguration currentConfig = panel.getCurrentConfigurationState();

    assertThat(currentConfig.equals(configuration), is(true));
  }
 public void updateConfigurationWithChanges(XQueryDataSourceConfiguration currentConfiguration) {
   currentConfiguration.USER_DEFINED_LIBRARY_ENABLED = isUserDefinedLibraryEnabled();
   currentConfiguration.USER_DEFINED_LIBRARY_PATHS = getUserDefinedLibraryPaths();
 }