use of org.pentaho.di.repository.ObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTest method testInsertTransformationPartitionSchema.
@Test
public void testInsertTransformationPartitionSchema() 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());
doReturn(new LongObjectId(456)).when(repo.connectionDelegate).getNextTransformationPartitionSchemaID();
ObjectId result = repo.insertTransformationPartitionSchema(new LongObjectId(147), new LongObjectId(258));
RowMetaAndData insertRecord = argumentTableData.getValue();
assertEquals(KettleDatabaseRepository.TABLE_R_TRANS_PARTITION_SCHEMA, argumentTableName.getValue());
assertEquals(3, insertRecord.size());
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(0).getType());
assertEquals(KettleDatabaseRepository.FIELD_TRANS_PARTITION_SCHEMA_ID_TRANS_PARTITION_SCHEMA, insertRecord.getValueMeta(0).getName());
assertEquals(Long.valueOf(456), insertRecord.getInteger(0));
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(1).getType());
assertEquals(KettleDatabaseRepository.FIELD_TRANS_PARTITION_SCHEMA_ID_TRANSFORMATION, insertRecord.getValueMeta(1).getName());
assertEquals(Long.valueOf(147), insertRecord.getInteger(1));
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(2).getType());
assertEquals(KettleDatabaseRepository.FIELD_TRANS_PARTITION_SCHEMA_ID_PARTITION_SCHEMA, insertRecord.getValueMeta(2).getName());
assertEquals(Long.valueOf(258), insertRecord.getInteger(2));
assertEquals(new LongObjectId(456), result);
}
use of org.pentaho.di.repository.ObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTest method testInsertTransformationCluster.
@Test
public void testInsertTransformationCluster() 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());
doReturn(new LongObjectId(123)).when(repo.connectionDelegate).getNextTransformationClusterID();
ObjectId result = repo.insertTransformationCluster(new LongObjectId(456), new LongObjectId(789));
RowMetaAndData insertRecord = argumentTableData.getValue();
assertEquals(KettleDatabaseRepository.TABLE_R_TRANS_CLUSTER, argumentTableName.getValue());
assertEquals(3, insertRecord.size());
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(0).getType());
assertEquals(KettleDatabaseRepository.FIELD_TRANS_CLUSTER_ID_TRANS_CLUSTER, insertRecord.getValueMeta(0).getName());
assertEquals(Long.valueOf(123), insertRecord.getInteger(0));
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(1).getType());
assertEquals(KettleDatabaseRepository.FIELD_TRANS_CLUSTER_ID_TRANSFORMATION, insertRecord.getValueMeta(1).getName());
assertEquals(Long.valueOf(456), insertRecord.getInteger(1));
assertEquals(ValueMetaInterface.TYPE_INTEGER, insertRecord.getValueMeta(2).getType());
assertEquals(KettleDatabaseRepository.FIELD_TRANS_CLUSTER_ID_CLUSTER, insertRecord.getValueMeta(2).getName());
assertEquals(Long.valueOf(789), insertRecord.getInteger(2));
assertEquals(new LongObjectId(123), result);
}
use of org.pentaho.di.repository.ObjectId in project pentaho-kettle by pentaho.
the class KettleDatabaseRepository_DatabaseNames_Test method getDatabaseId_ExactMatch.
@Test
public void getDatabaseId_ExactMatch() throws Exception {
final String name = UUID.randomUUID().toString();
final ObjectId expectedId = new StringObjectId("expected");
doReturn(expectedId).when(databaseDelegate).getDatabaseID(name);
ObjectId id = repository.getDatabaseID(name);
assertEquals(expectedId, id);
}
use of org.pentaho.di.repository.ObjectId in project pentaho-kettle by pentaho.
the class RunJobServletTest method doGetWrongCredentialsRepoTest.
@Test
public void doGetWrongCredentialsRepoTest() throws Exception {
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
TransformationMap transformationMap = mock(TransformationMap.class);
SlaveServerConfig slaveServerConfig = mock(SlaveServerConfig.class);
Repository repository = mock(Repository.class);
RepositoryDirectoryInterface repDirInterface = mock(RepositoryDirectoryInterface.class);
ObjectId objId = mock(ObjectId.class);
Whitebox.setInternalState(runJobServlet, "transformationMap", transformationMap);
KettleLogStore.init();
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
when(mockHttpServletRequest.getParameter("job")).thenReturn("dummyJob");
when(mockHttpServletRequest.getParameter("level")).thenReturn("SomethingInvalid");
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
when(transformationMap.getSlaveServerConfig()).thenReturn(slaveServerConfig);
when(slaveServerConfig.getRepository()).thenReturn(repository);
when(repository.isConnected()).thenReturn(true);
when(repository.loadRepositoryDirectoryTree()).thenReturn(repDirInterface);
when(repDirInterface.findDirectory(anyString())).thenReturn(repDirInterface);
when(repository.getJobId("dummyJob", repDirInterface)).thenReturn(objId);
when(repository.loadJob(objId, null)).thenThrow(new KettleException("The server sent HTTP status code 401"));
runJobServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
verify(mockHttpServletResponse).setStatus(HttpServletResponse.SC_OK);
verify(mockHttpServletResponse).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
use of org.pentaho.di.repository.ObjectId in project pentaho-kettle by pentaho.
the class RunJobServletTest method doGetNonExistingJobTest.
@Test
public void doGetNonExistingJobTest() throws Exception {
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
TransformationMap transformationMap = mock(TransformationMap.class);
SlaveServerConfig slaveServerConfig = mock(SlaveServerConfig.class);
Repository repository = mock(Repository.class);
RepositoryDirectoryInterface repDirInterface = mock(RepositoryDirectoryInterface.class);
ObjectId objId = mock(ObjectId.class);
Whitebox.setInternalState(runJobServlet, "transformationMap", transformationMap);
KettleLogStore.init();
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
when(mockHttpServletRequest.getParameter("job")).thenReturn("dummyJob");
when(mockHttpServletRequest.getParameter("level")).thenReturn("SomethingInvalid");
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
when(transformationMap.getSlaveServerConfig()).thenReturn(slaveServerConfig);
when(slaveServerConfig.getRepository()).thenReturn(repository);
when(repository.isConnected()).thenReturn(true);
when(repository.loadRepositoryDirectoryTree()).thenReturn(repDirInterface);
when(repDirInterface.findDirectory(anyString())).thenReturn(repDirInterface);
when(repository.getJobId("dummyJob", repDirInterface)).thenReturn(objId);
when(repository.loadJob(objId, null)).thenThrow(new KettleException("Unable to load job"));
runJobServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
verify(mockHttpServletResponse).setStatus(HttpServletResponse.SC_OK);
verify(mockHttpServletResponse).setStatus(HttpServletResponse.SC_NOT_FOUND);
}
Aggregations