Search in sources :

Example 81 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class KettleDatabaseRepository_DatabaseNames_Test method getDatabaseId_ReturnsExactMatch_PriorToCaseInsensitiveMatch.

@Test
public void getDatabaseId_ReturnsExactMatch_PriorToCaseInsensitiveMatch() throws Exception {
    final String exact = "databaseExactMatch";
    final String similar = exact.toLowerCase();
    assertNotSame(similar, exact);
    final ObjectId exactId = new StringObjectId("exactId");
    doReturn(exactId).when(databaseDelegate).getDatabaseID(exact);
    final ObjectId similarId = new StringObjectId("similarId");
    doReturn(similarId).when(databaseDelegate).getDatabaseID(similar);
    DatabaseMeta db = new DatabaseMeta();
    db.setName(exact);
    DatabaseMeta another = new DatabaseMeta();
    db.setName(similar);
    List<DatabaseMeta> dbs = Arrays.asList(another, db);
    doReturn(dbs).when(repository).getDatabases();
    ObjectId id = this.repository.getDatabaseID(exact);
    assertEquals(exactId, id);
}
Also used : ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Test(org.junit.Test)

Example 82 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class KettleDatabaseRepository_DatabaseNames_Test method getDatabaseId_InsensitiveMatch.

@Test
public void getDatabaseId_InsensitiveMatch() throws Exception {
    final String name = "databaseWithCamelCase";
    final String lookupName = name.toLowerCase();
    assertNotSame(lookupName, name);
    final ObjectId expected = new StringObjectId("expected");
    doReturn(expected).when(databaseDelegate).getDatabaseID(name);
    doReturn(null).when(databaseDelegate).getDatabaseID(lookupName);
    DatabaseMeta db = new DatabaseMeta();
    db.setName(name);
    db.setObjectId(expected);
    List<DatabaseMeta> dbs = Collections.singletonList(db);
    doReturn(dbs).when(repository).getDatabases();
    ObjectId id = repository.getDatabaseID(lookupName);
    assertEquals(expected, id);
}
Also used : ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Test(org.junit.Test)

Example 83 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class KettleDatabaseRepository_GetObjectInformation_Test method getObjectInformation_GetDatabaseInformation.

@Test
public void getObjectInformation_GetDatabaseInformation() throws Exception {
    KettleDatabaseRepositoryDatabaseDelegate databaseDelegate = spy(new KettleDatabaseRepositoryDatabaseDelegate(repository));
    repository.databaseDelegate = databaseDelegate;
    RowMeta meta = createMetaForDatabase();
    Object[] values = new Object[meta.size()];
    values[Arrays.asList(meta.getFieldNames()).indexOf(KettleDatabaseRepositoryBase.FIELD_DATABASE_NAME)] = EXISTING_ID;
    doReturn(new RowMetaAndData(meta, values)).when(databaseDelegate).getDatabase(new StringObjectId(EXISTING_ID));
    RepositoryObject actual = repository.getObjectInformation(new StringObjectId(EXISTING_ID), RepositoryObjectType.DATABASE);
    assertEquals(new StringObjectId(EXISTING_ID), actual.getObjectId());
    assertEquals(EXISTING_ID, actual.getName());
    assertEquals(RepositoryObjectType.DATABASE, actual.getObjectType());
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) RepositoryObject(org.pentaho.di.repository.RepositoryObject) RowMeta(org.pentaho.di.core.row.RowMeta) KettleDatabaseRepositoryDatabaseDelegate(org.pentaho.di.repository.kdr.delegates.KettleDatabaseRepositoryDatabaseDelegate) RepositoryObject(org.pentaho.di.repository.RepositoryObject) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 84 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class KettleDatabaseRepository_GetObjectInformation_Test method assertIsDeletedSet_ForAbsentObject.

private void assertIsDeletedSet_ForAbsentObject(KettleDatabaseRepositoryTransDelegate transDelegate, KettleDatabaseRepositoryJobDelegate jobDelegate, RepositoryObjectType objectType) throws Exception {
    repository.transDelegate = transDelegate;
    repository.jobDelegate = jobDelegate;
    when(directoryInterface.findDirectory(any(ObjectId.class))).thenReturn(null);
    RepositoryObject object = repository.getObjectInformation(new StringObjectId(ABSENT_ID), objectType);
    assertTrue(object.isDeleted());
}
Also used : RepositoryObject(org.pentaho.di.repository.RepositoryObject) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId)

Example 85 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class KettleDatabaseRepository_GetObjectInformation_Test method assertIsDeletedNotSet_ForExistingObject.

private void assertIsDeletedNotSet_ForExistingObject(KettleDatabaseRepositoryTransDelegate transDelegate, KettleDatabaseRepositoryJobDelegate jobDelegate, RepositoryObjectType objectType) throws Exception {
    repository.transDelegate = transDelegate;
    repository.jobDelegate = jobDelegate;
    when(directoryInterface.findDirectory(any(ObjectId.class))).thenReturn(null);
    RepositoryObject object = repository.getObjectInformation(new StringObjectId(EXISTING_ID), objectType);
    assertFalse(object.isDeleted());
}
Also used : RepositoryObject(org.pentaho.di.repository.RepositoryObject) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) 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