Search in sources :

Example 1 with StringObjectId

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();
}
Also used : UIDatabaseConnection(org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 2 with StringObjectId

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();
}
Also used : UIDatabaseConnection(org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 3 with StringObjectId

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());
}
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 4 with StringObjectId

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();
}
Also used : UIDatabaseConnection(org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 5 with StringObjectId

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();
}
Also used : UIDatabaseConnection(org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection) StringObjectId(org.pentaho.di.repository.StringObjectId)

Aggregations

StringObjectId (org.pentaho.di.repository.StringObjectId)123 KettleException (org.pentaho.di.core.exception.KettleException)49 ObjectId (org.pentaho.di.repository.ObjectId)38 Test (org.junit.Test)34 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)25 KettleFileException (org.pentaho.di.core.exception.KettleFileException)21 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)18 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)18 ArrayList (java.util.ArrayList)16 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)15 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)14 RepositoryObject (org.pentaho.di.repository.RepositoryObject)14 TransMeta (org.pentaho.di.trans.TransMeta)14 IdNotFoundException (org.pentaho.di.core.exception.IdNotFoundException)13 KettleSecurityException (org.pentaho.di.core.exception.KettleSecurityException)13 UnifiedRepositoryCreateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException)13 UnifiedRepositoryUpdateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryUpdateFileException)13 Repository (org.pentaho.di.repository.Repository)11 IOException (java.io.IOException)10 FileObject (org.apache.commons.vfs2.FileObject)10