use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTest method testInsertJobNote.
@Test
public void testInsertJobNote() throws KettleException {
ArgumentCaptor<String> argumentTableName = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<RowMetaAndData> argumentTableData = ArgumentCaptor.forClass(RowMetaAndData.class);
doNothing().when(repo.connectionDelegate).insertTableRow(argumentTableName.capture(), argumentTableData.capture());
repo.insertJobNote(new LongObjectId(234), new LongObjectId(567));
RowMetaAndData insertRecord = argumentTableData.getValue();
assertEquals(KettleDatabaseRepository.TABLE_R_JOB_NOTE, argumentTableName.getValue());
assertEquals(2, insertRecord.size());
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(0).getType());
assertEquals(KettleDatabaseRepository.FIELD_JOB_NOTE_ID_JOB, insertRecord.getValueMeta(0).getName());
assertEquals(Long.valueOf(234), insertRecord.getInteger(0));
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(1).getType());
assertEquals(KettleDatabaseRepository.FIELD_JOB_NOTE_ID_NOTE, insertRecord.getValueMeta(1).getName());
assertEquals(Long.valueOf(567), insertRecord.getInteger(1));
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTest method testInsertLogEntry.
@Test
public void testInsertLogEntry() throws KettleException {
doReturn(new LongObjectId(123)).when(repo.connectionDelegate).getNextLogID();
doReturn("2.4").when(repo.connectionDelegate).getVersion();
doReturn(new UserInfo("John Doe")).when(repo).getUserInfo();
ArgumentCaptor<String> argumentTableName = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<RowMetaAndData> argumentTableData = ArgumentCaptor.forClass(RowMetaAndData.class);
doNothing().when(repo.connectionDelegate).insertTableRow(argumentTableName.capture(), argumentTableData.capture());
Date beforeLogEntryDate = Calendar.getInstance().getTime();
repo.insertLogEntry("testDescription");
Date afterLogEntryDate = Calendar.getInstance().getTime();
RowMetaAndData insertRecord = argumentTableData.getValue();
assertEquals(KettleDatabaseRepository.TABLE_R_REPOSITORY_LOG, argumentTableName.getValue());
assertEquals(5, insertRecord.size());
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(0).getType());
assertEquals(KettleDatabaseRepository.FIELD_REPOSITORY_LOG_ID_REPOSITORY_LOG, insertRecord.getValueMeta(0).getName());
assertEquals(Long.valueOf(123), insertRecord.getInteger(0));
assertEquals(ValueMetaInterface.TYPE_STRING, insertRecord.getValueMeta(1).getType());
assertEquals(KettleDatabaseRepository.FIELD_REPOSITORY_LOG_REP_VERSION, insertRecord.getValueMeta(1).getName());
assertEquals("2.4", insertRecord.getString(1, null));
assertEquals(ValueMetaInterface.TYPE_DATE, insertRecord.getValueMeta(2).getType());
assertEquals(KettleDatabaseRepository.FIELD_REPOSITORY_LOG_LOG_DATE, insertRecord.getValueMeta(2).getName());
assertTrue(beforeLogEntryDate.compareTo(insertRecord.getDate(2, new Date(Long.MIN_VALUE))) <= 0 && afterLogEntryDate.compareTo(insertRecord.getDate(2, new Date(Long.MIN_VALUE))) >= 0);
assertEquals(ValueMetaInterface.TYPE_STRING, insertRecord.getValueMeta(3).getType());
assertEquals(KettleDatabaseRepository.FIELD_REPOSITORY_LOG_LOG_USER, insertRecord.getValueMeta(3).getName());
assertEquals("John Doe", insertRecord.getString(3, null));
assertEquals(ValueMetaInterface.TYPE_STRING, insertRecord.getValueMeta(4).getType());
assertEquals(KettleDatabaseRepository.FIELD_REPOSITORY_LOG_OPERATION_DESC, insertRecord.getValueMeta(4).getName());
assertEquals("testDescription", insertRecord.getString(4, null));
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTest method testInsertStepDatabase.
@Test
public void testInsertStepDatabase() throws KettleException {
doReturn(getNullIntegerRow()).when(repo.connectionDelegate).getOneRow(anyString(), anyString(), any(ObjectId.class));
ArgumentCaptor<String> argumentTableName = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<RowMetaAndData> argumentTableData = ArgumentCaptor.forClass(RowMetaAndData.class);
doNothing().when(repo.connectionDelegate).insertTableRow(argumentTableName.capture(), argumentTableData.capture());
repo.insertStepDatabase(new LongObjectId(654), new LongObjectId(765), new LongObjectId(876));
RowMetaAndData insertRecord = argumentTableData.getValue();
assertEquals(KettleDatabaseRepository.TABLE_R_STEP_DATABASE, argumentTableName.getValue());
assertEquals(3, insertRecord.size());
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(0).getType());
assertEquals(KettleDatabaseRepository.FIELD_STEP_DATABASE_ID_TRANSFORMATION, insertRecord.getValueMeta(0).getName());
assertEquals(Long.valueOf(654), insertRecord.getInteger(0));
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(1).getType());
assertEquals(KettleDatabaseRepository.FIELD_STEP_DATABASE_ID_STEP, insertRecord.getValueMeta(1).getName());
assertEquals(Long.valueOf(765), insertRecord.getInteger(1));
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(2).getType());
assertEquals(KettleDatabaseRepository.FIELD_STEP_DATABASE_ID_DATABASE, insertRecord.getValueMeta(2).getName());
assertEquals(Long.valueOf(876), insertRecord.getInteger(2));
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTest method testInsertJobEntryDatabase.
@Test
public void testInsertJobEntryDatabase() throws KettleException {
doReturn(getNullIntegerRow()).when(repo.connectionDelegate).getOneRow(anyString(), anyString(), any(ObjectId.class));
ArgumentCaptor<String> argumentTableName = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<RowMetaAndData> argumentTableData = ArgumentCaptor.forClass(RowMetaAndData.class);
doNothing().when(repo.connectionDelegate).insertTableRow(argumentTableName.capture(), argumentTableData.capture());
repo.insertJobEntryDatabase(new LongObjectId(234), new LongObjectId(345), new LongObjectId(456));
RowMetaAndData insertRecord = argumentTableData.getValue();
assertEquals(KettleDatabaseRepository.TABLE_R_JOBENTRY_DATABASE, argumentTableName.getValue());
assertEquals(3, insertRecord.size());
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(0).getType());
assertEquals(KettleDatabaseRepository.FIELD_JOBENTRY_DATABASE_ID_JOB, insertRecord.getValueMeta(0).getName());
assertEquals(Long.valueOf(234), insertRecord.getInteger(0));
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(1).getType());
assertEquals(KettleDatabaseRepository.FIELD_JOBENTRY_DATABASE_ID_JOBENTRY, insertRecord.getValueMeta(1).getName());
assertEquals(Long.valueOf(345), insertRecord.getInteger(1));
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(2).getType());
assertEquals(KettleDatabaseRepository.FIELD_JOBENTRY_DATABASE_ID_DATABASE, insertRecord.getValueMeta(2).getName());
assertEquals(Long.valueOf(456), insertRecord.getInteger(2));
}
use of org.pentaho.di.repository.LongObjectId in project pentaho-kettle by pentaho.
the class RepositoryDirectoryUITest method testLoadRepositoryObjectsFilled.
@Test
public void testLoadRepositoryObjectsFilled() throws Exception {
RepositoryDirectory root = new RepositoryDirectory();
root.setObjectId(new LongObjectId(0L));
RepositoryDirectory dir = new RepositoryDirectory();
dir.setObjectId(new LongObjectId(1L));
root.addSubdirectory(dir);
RepositoryElementMetaInterface meta = mock(RepositoryElementMetaInterface.class);
when(meta.getObjectType()).thenReturn(RepositoryObjectType.TRANSFORMATION);
root.setRepositoryObjects(Collections.emptyList());
dir.setRepositoryObjects(Collections.singletonList(meta));
Repository repo = mock(Repository.class);
assertTrue(RepositoryDirectoryUI.loadRepositoryObjects(root, true, true, repo).isEmpty());
assertEquals(1, RepositoryDirectoryUI.loadRepositoryObjects(dir, true, true, repo).size());
verifyZeroInteractions(repo);
}
Aggregations