Search in sources :

Example 1 with UIDatabaseConnection

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection in project pentaho-kettle by pentaho.

the class ConnectionsControllerTest method createSelectedConnectionList.

private List<UIDatabaseConnection> createSelectedConnectionList(String selectedDbName) {
    DatabaseMeta meta = new DatabaseMeta();
    meta.setName(selectedDbName);
    return singletonList(new UIDatabaseConnection(meta, repository));
}
Also used : UIDatabaseConnection(org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 2 with UIDatabaseConnection

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection in project pentaho-kettle by pentaho.

the class ConnectionsControllerTest method editConnection_NameDoesNotExist.

@Test
public void editConnection_NameDoesNotExist() throws Exception {
    final String dbName = "name";
    List<UIDatabaseConnection> selectedConnection = createSelectedConnectionList(dbName);
    when(connectionsTable.<UIDatabaseConnection>getSelectedItems()).thenReturn(selectedConnection);
    when(repository.getDatabaseID(dbName)).thenReturn(new StringObjectId("existing"));
    when(databaseDialog.open()).thenReturn("non-existing-name");
    controller.editConnection();
    assertRepositorySavedDb();
}
Also used : UIDatabaseConnection(org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 3 with UIDatabaseConnection

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection in project pentaho-kettle by pentaho.

the class ConnectionsControllerTest method editConnection_NameExists_Different.

@Test
public void editConnection_NameExists_Different() throws Exception {
    final String dbName = "name";
    List<UIDatabaseConnection> selectedConnection = createSelectedConnectionList(dbName);
    when(connectionsTable.<UIDatabaseConnection>getSelectedItems()).thenReturn(selectedConnection);
    final String anotherName = "anotherName";
    when(repository.getDatabaseID(dbName)).thenReturn(new StringObjectId("existing"));
    when(repository.getDatabaseID(anotherName)).thenReturn(new StringObjectId("another-existing"));
    when(databaseDialog.open()).thenReturn(anotherName);
    controller.editConnection();
    assertShowedAlreadyExistsMessage();
}
Also used : UIDatabaseConnection(org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 4 with UIDatabaseConnection

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection in project pentaho-kettle by pentaho.

the class ConnectionsControllerTest method editConnection_NameExists_SameWithSpaces.

@Test
public void editConnection_NameExists_SameWithSpaces() throws Exception {
    final String dbName = " name";
    DatabaseMeta dbmeta = spy(new DatabaseMeta());
    dbmeta.setName(dbName);
    List<UIDatabaseConnection> selectedConnection = singletonList(new UIDatabaseConnection(dbmeta, repository));
    when(connectionsTable.<UIDatabaseConnection>getSelectedItems()).thenReturn(selectedConnection);
    when(repository.getDatabaseID(dbName)).thenReturn(new StringObjectId("existing"));
    when(databaseDialog.open()).thenReturn(dbName);
    controller.editConnection();
    verify(dbmeta).setName(dbName.trim());
}
Also used : UIDatabaseConnection(org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 5 with UIDatabaseConnection

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection in project pentaho-kettle by pentaho.

the class ConnectionsControllerTest method editConnection_NameExists_Same.

@Test
public void editConnection_NameExists_Same() throws Exception {
    final String dbName = "name";
    List<UIDatabaseConnection> selectedConnection = createSelectedConnectionList(dbName);
    when(connectionsTable.<UIDatabaseConnection>getSelectedItems()).thenReturn(selectedConnection);
    when(repository.getDatabaseID(dbName)).thenReturn(new StringObjectId("existing"));
    when(databaseDialog.open()).thenReturn(dbName);
    controller.editConnection();
    assertRepositorySavedDb();
}
Also used : UIDatabaseConnection(org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Aggregations

UIDatabaseConnection (org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection)11 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)5 StringObjectId (org.pentaho.di.repository.StringObjectId)5 Test (org.junit.Test)4 KettleException (org.pentaho.di.core.exception.KettleException)3 ObjectId (org.pentaho.di.repository.ObjectId)3 ArrayList (java.util.ArrayList)2 MessageBox (org.eclipse.swt.widgets.MessageBox)2 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)2 IAclObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject)2 AccessDeniedException (org.pentaho.di.ui.repository.repositoryexplorer.AccessDeniedException)2 List (java.util.List)1 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)1 UIRepositoryObjectAcl (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectAcl)1 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)1 UIObjectCreationException (org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException)1 BindingConvertor (org.pentaho.ui.xul.binding.BindingConvertor)1