use of org.pentaho.di.repository.StringObjectId 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.repository.StringObjectId 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.repository.StringObjectId 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.repository.StringObjectId 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();
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class ConnectionsControllerTest method testEditConnectionGetsWrongName.
private void testEditConnectionGetsWrongName(String wrongName) 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(wrongName);
controller.editConnection();
assertSaveWasNotInvoked();
}
Aggregations