Search in sources :

Example 76 with LongObjectId

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));
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) Matchers.anyString(org.mockito.Matchers.anyString) LongObjectId(org.pentaho.di.repository.LongObjectId) Test(org.junit.Test)

Example 77 with LongObjectId

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));
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) UserInfo(org.pentaho.di.repository.UserInfo) LongObjectId(org.pentaho.di.repository.LongObjectId) Matchers.anyString(org.mockito.Matchers.anyString) Date(java.util.Date) Test(org.junit.Test)

Example 78 with LongObjectId

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));
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) Matchers.anyString(org.mockito.Matchers.anyString) LongObjectId(org.pentaho.di.repository.LongObjectId) Test(org.junit.Test)

Example 79 with LongObjectId

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));
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) Matchers.anyString(org.mockito.Matchers.anyString) LongObjectId(org.pentaho.di.repository.LongObjectId) Test(org.junit.Test)

Example 80 with LongObjectId

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);
}
Also used : Repository(org.pentaho.di.repository.Repository) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) LongObjectId(org.pentaho.di.repository.LongObjectId) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface) Test(org.junit.Test)

Aggregations

LongObjectId (org.pentaho.di.repository.LongObjectId)81 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)54 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)36 ObjectId (org.pentaho.di.repository.ObjectId)30 KettleException (org.pentaho.di.core.exception.KettleException)18 Test (org.junit.Test)17 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)17 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)14 Matchers.anyString (org.mockito.Matchers.anyString)10 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)10 ArrayList (java.util.ArrayList)9 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)9 RepositoryObject (org.pentaho.di.repository.RepositoryObject)8 MetaStoreDependenciesExistsException (org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException)8 MetaStoreElementExistException (org.pentaho.metastore.api.exceptions.MetaStoreElementExistException)8 MetaStoreElementTypeExistsException (org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)8 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)8 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)7 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)7 StringObjectId (org.pentaho.di.repository.StringObjectId)7