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