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