use of org.pentaho.di.ui.repository.pur.services.ILockService in project pentaho-kettle by pentaho.
the class RepositoryLockControllerTest method testBlockLock.
@Test
public void testBlockLock() throws Exception {
RepositoryLockController repositoryLockController = new RepositoryLockController();
List<UIRepositoryObject> selectedRepoObjects = new ArrayList<>();
UIEETransformation lockObject = Mockito.mock(UIEETransformation.class);
selectedRepoObjects.add(lockObject);
Mockito.when(lockObject.isLocked()).thenReturn(true);
ObjectId objectId = Mockito.mock(ObjectId.class);
Mockito.when(lockObject.getObjectId()).thenReturn(objectId);
XulMenuitem lockFileMenuItem = Mockito.mock(XulMenuitem.class);
Field lockFileMenuItemField = repositoryLockController.getClass().getDeclaredField("lockFileMenuItem");
lockFileMenuItemField.setAccessible(true);
lockFileMenuItemField.set(repositoryLockController, lockFileMenuItem);
XulMenuitem deleteFileMenuItem = Mockito.mock(XulMenuitem.class);
Field deleteFileMenuItemField = repositoryLockController.getClass().getDeclaredField("deleteFileMenuItem");
deleteFileMenuItemField.setAccessible(true);
deleteFileMenuItemField.set(repositoryLockController, deleteFileMenuItem);
XulMenuitem renameFileMenuItem = Mockito.mock(XulMenuitem.class);
Field renameFileMenuItemField = repositoryLockController.getClass().getDeclaredField("renameFileMenuItem");
renameFileMenuItemField.setAccessible(true);
renameFileMenuItemField.set(repositoryLockController, renameFileMenuItem);
Repository repository = Mockito.mock(Repository.class);
PurRepositoryMeta repositoryMeta = Mockito.mock(PurRepositoryMeta.class);
Mockito.when(repository.getRepositoryMeta()).thenReturn(repositoryMeta);
Field repositoryField = repositoryLockController.getClass().getDeclaredField("repository");
repositoryField.setAccessible(true);
repositoryField.set(repositoryLockController, repository);
ILockService service = Mockito.mock(ILockService.class);
Mockito.when(service.canUnlockFileById(objectId)).thenReturn(true);
Field serviceField = repositoryLockController.getClass().getDeclaredField("service");
serviceField.setAccessible(true);
serviceField.set(repositoryLockController, service);
repositoryLockController.setMenuItemEnabledState(selectedRepoObjects);
Assert.assertFalse(lockFileMenuItem.isDisabled());
Mockito.verify(lockFileMenuItem).setDisabled(false);
}
use of org.pentaho.di.ui.repository.pur.services.ILockService in project pentaho-kettle by pentaho.
the class SpoonMenuLockController method updateMenu.
public void updateMenu(Document doc) {
try {
Spoon spoon = Spoon.getInstance();
// If we are working with an Enterprise Repository
if ((spoon != null) && (spoon.getRepository() != null) && (spoon.getRepository() instanceof PurRepository)) {
ILockService service = getService(spoon.getRepository());
EngineMetaInterface meta = spoon.getActiveMeta();
// If (meta is not null) and (meta is either a Transformation or Job)
if ((meta != null) && (meta instanceof ILockable)) {
RepositoryLock repoLock = null;
if (service != null && meta.getObjectId() != null) {
if (meta instanceof EEJobMeta) {
repoLock = service.getJobLock(meta.getObjectId());
} else {
repoLock = service.getTransformationLock(meta.getObjectId());
}
}
// If (there is a lock on this item) and (the UserInfo does not have permission to unlock this file)
if (repoLock != null) {
if (!service.canUnlockFileById(meta.getObjectId())) {
// User does not have modify permissions on this file
// $NON-NLS-1$
((XulToolbarbutton) doc.getElementById("toolbar-file-save")).setDisabled(true);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("file-save")).setDisabled(true);
}
}
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.pentaho.di.ui.repository.pur.services.ILockService in project pentaho-kettle by pentaho.
the class RepositoryLockController method init.
public void init(Repository rep) throws ControllerInitializationException {
try {
if (rep != null && rep.hasService(ILockService.class)) {
repository = rep;
service = (ILockService) rep.getService(ILockService.class);
} else {
throw new ControllerInitializationException(BaseMessages.getString(PKG, "RepositoryLockController.ERROR_0001_UNABLE_TO_INITIAL_REPOSITORY_SERVICE", // $NON-NLS-1$
ILockService.class));
}
bindingFactory = new DefaultBindingFactory();
bindingFactory.setDocument(getXulDomContainer().getDocumentRoot());
// $NON-NLS-1$
XulEventHandler eventHandler = getXulDomContainer().getEventHandler("browseController");
if (eventHandler instanceof BrowseController) {
browseController = (BrowseController) eventHandler;
}
// Disable row dragging if it is locked and the user does not have permissions
// $NON-NLS-1$
fileTable = (XulTree) getXulDomContainer().getDocumentRoot().getElementById("file-table");
// $NON-NLS-1$
folderTree = (XulTree) document.getElementById("folder-tree");
// $NON-NLS-1$
lockFileMenuItem = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById("file-context-lock");
// $NON-NLS-1$
deleteFileMenuItem = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById("file-context-delete");
// $NON-NLS-1$
renameFileMenuItem = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById("file-context-rename");
// $NON-NLS-1$
messageBox = (XulMessageBox) document.createElement("messagebox");
createBindings();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.pentaho.di.ui.repository.pur.services.ILockService in project pentaho-kettle by pentaho.
the class RepositoryTestBase method testJobs.
/**
* save(job) loadJob() exists() deleteJob() getJobNames() getJobObjects() getJobId() getJobLock() lockJob()
* unlockJob()
*/
// @Ignore
@Test
public void testJobs() throws Exception {
ILockService service = (ILockService) repository.getService(ILockService.class);
RepositoryDirectoryInterface rootDir = initRepo();
JobMeta jobMeta = createJobMeta(EXP_JOB_NAME);
RepositoryDirectoryInterface jobsDir = rootDir.findDirectory(DIR_JOBS);
repository.save(jobMeta, VERSION_COMMENT_V1, null);
deleteStack.push(jobMeta);
assertNotNull(jobMeta.getObjectId());
ObjectRevision version = jobMeta.getObjectRevision();
assertNotNull(version);
assertTrue(hasVersionWithComment(jobMeta, VERSION_COMMENT_V1));
assertTrue(repository.exists(EXP_JOB_NAME, jobsDir, RepositoryObjectType.JOB));
JobMeta fetchedJob = repository.loadJob(EXP_JOB_NAME, jobsDir, null, null);
assertEquals(EXP_JOB_NAME, fetchedJob.getName());
assertEquals(EXP_JOB_DESC, fetchedJob.getDescription());
assertEquals(EXP_JOB_EXTENDED_DESC, fetchedJob.getExtendedDescription());
assertEquals(jobsDir.getPath(), fetchedJob.getRepositoryDirectory().getPath());
assertEquals(EXP_JOB_VERSION, fetchedJob.getJobversion());
assertEquals(EXP_JOB_STATUS, fetchedJob.getJobstatus());
assertEquals(EXP_JOB_CREATED_USER, fetchedJob.getCreatedUser());
assertEquals(EXP_JOB_CREATED_DATE, fetchedJob.getCreatedDate());
assertEquals(EXP_JOB_MOD_USER, fetchedJob.getModifiedUser());
assertEquals(EXP_JOB_MOD_DATE, fetchedJob.getModifiedDate());
assertEquals(1, fetchedJob.listParameters().length);
assertEquals(EXP_JOB_PARAM_1_DEF, fetchedJob.getParameterDefault(EXP_JOB_PARAM_1_NAME));
assertEquals(EXP_JOB_PARAM_1_DESC, fetchedJob.getParameterDescription(EXP_JOB_PARAM_1_NAME));
// JobLogTable jobLogTable = fetchedJob.getJobLogTable();
// TODO mlowery why doesn't this work?
// assertEquals(EXP_LOG_TABLE_CONN_NAME, jobLogTable.getConnectionName());
// assertEquals(EXP_JOB_LOG_TABLE_INTERVAL, jobLogTable.getLogInterval());
// assertEquals(EXP_LOG_TABLE_SCHEMA_NAME, jobLogTable.getSchemaName());
// assertEquals(EXP_LOG_TABLE_SIZE_LIMIT, jobLogTable.getLogSizeLimit());
// assertEquals(EXP_LOG_TABLE_TABLE_NAME, jobLogTable.getTableName());
// assertEquals(EXP_LOG_TABLE_TIMEOUT_IN_DAYS, jobLogTable.getTimeoutInDays());
// JobEntryLogTable jobEntryLogTable = fetchedJob.getJobEntryLogTable();
// TODO mlowery why doesn't this work?
// assertEquals(EXP_LOG_TABLE_CONN_NAME, jobEntryLogTable.getConnectionName());
// assertEquals(EXP_LOG_TABLE_SCHEMA_NAME, jobEntryLogTable.getSchemaName());
// assertEquals(EXP_LOG_TABLE_TABLE_NAME, jobEntryLogTable.getTableName());
// assertEquals(EXP_LOG_TABLE_TIMEOUT_IN_DAYS, jobEntryLogTable.getTimeoutInDays());
// ChannelLogTable channelLogTable = fetchedJob.getChannelLogTable();
// TODO mlowery why doesn't this work?
// assertEquals(EXP_LOG_TABLE_CONN_NAME, channelLogTable.getConnectionName());
// assertEquals(EXP_LOG_TABLE_SCHEMA_NAME, channelLogTable.getSchemaName());
// assertEquals(EXP_LOG_TABLE_TABLE_NAME, channelLogTable.getTableName());
// assertEquals(EXP_LOG_TABLE_TIMEOUT_IN_DAYS, channelLogTable.getTimeoutInDays());
assertEquals(EXP_JOB_BATCH_ID_PASSED, fetchedJob.isBatchIdPassed());
assertEquals(EXP_JOB_SHARED_OBJECTS_FILE, fetchedJob.getSharedObjectsFile());
assertEquals(2, fetchedJob.getJobCopies().size());
assertEquals("JobEntryAttributeTester", fetchedJob.getJobEntry(0).getEntry().getPluginId());
assertEquals(EXP_JOB_ENTRY_1_COPY_X_LOC, fetchedJob.getJobEntry(0).getLocation().x);
assertEquals(EXP_JOB_ENTRY_1_COPY_Y_LOC, fetchedJob.getJobEntry(0).getLocation().y);
assertEquals("JobEntryAttributeTester", fetchedJob.getJobEntry(1).getEntry().getPluginId());
assertEquals(EXP_JOB_ENTRY_2_COPY_X_LOC, fetchedJob.getJobEntry(1).getLocation().x);
assertEquals(EXP_JOB_ENTRY_2_COPY_Y_LOC, fetchedJob.getJobEntry(1).getLocation().y);
assertEquals(1, fetchedJob.getJobhops().size());
assertEquals(EXP_JOB_ENTRY_1_NAME, fetchedJob.getJobHop(0).getFromEntry().getEntry().getName());
assertEquals("JobEntryAttributeTester", fetchedJob.getJobHop(0).getFromEntry().getEntry().getPluginId());
assertEquals(EXP_JOB_ENTRY_2_NAME, fetchedJob.getJobHop(0).getToEntry().getEntry().getName());
assertEquals("JobEntryAttributeTester", fetchedJob.getJobHop(0).getToEntry().getEntry().getPluginId());
assertEquals(1, fetchedJob.getNotes().size());
assertTrue(fetchedJob.getNote(0).getNote().startsWith(EXP_NOTEPAD_NOTE));
assertEquals(EXP_NOTEPAD_X, fetchedJob.getNote(0).getLocation().x);
assertEquals(EXP_NOTEPAD_Y, fetchedJob.getNote(0).getLocation().y);
assertEquals(EXP_NOTEPAD_WIDTH, fetchedJob.getNote(0).getWidth());
assertEquals(EXP_NOTEPAD_HEIGHT, fetchedJob.getNote(0).getHeight());
JobMeta jobMetaById = repository.loadJob(jobMeta.getObjectId(), null);
// assertEquals( fetchedJob, jobMetaById ); broken by BACKLOG-20809; probably ok
assertNull(service.getJobLock(jobMeta.getObjectId()));
service.lockJob(jobMeta.getObjectId(), EXP_JOB_LOCK_MSG);
assertEquals(EXP_JOB_LOCK_MSG, service.getJobLock(jobMeta.getObjectId()).getMessage());
assertEquals(getDate(new Date()), getDate(service.getJobLock(jobMeta.getObjectId()).getLockDate()));
assertEquals(EXP_LOGIN_PLUS_TENANT, service.getJobLock(jobMeta.getObjectId()).getLogin());
// TODO mlowery currently PUR lock only stores "login"; why do we need username too?
// assertEquals(EXP_USERNAME, repository.getJobLock(jobMeta.getObjectId()).getUsername());
assertEquals(jobMeta.getObjectId(), service.getJobLock(jobMeta.getObjectId()).getObjectId());
service.unlockJob(jobMeta.getObjectId());
assertNull(service.getJobLock(jobMeta.getObjectId()));
jobMeta.setDescription(EXP_JOB_DESC_V2);
repository.save(jobMeta, VERSION_COMMENT_V2, null);
assertEquals(VERSION_COMMENT_V2, jobMeta.getObjectRevision().getComment());
fetchedJob = repository.loadJob(EXP_JOB_NAME, jobsDir, null, null);
assertEquals(EXP_JOB_DESC_V2, fetchedJob.getDescription());
fetchedJob = repository.loadJob(EXP_JOB_NAME, jobsDir, null, VERSION_LABEL_V1);
assertEquals(EXP_JOB_DESC, fetchedJob.getDescription());
jobMetaById = repository.loadJob(jobMeta.getObjectId(), VERSION_LABEL_V1);
// assertEquals( fetchedJob, jobMetaById ); broken by BACKLOG-20809; probably ok
assertEquals(jobMeta.getObjectId(), repository.getJobId(EXP_JOB_NAME, jobsDir));
assertEquals(1, repository.getJobObjects(jobsDir.getObjectId(), false).size());
assertEquals(1, repository.getJobObjects(jobsDir.getObjectId(), true).size());
assertEquals(jobMeta.getName(), repository.getJobObjects(jobsDir.getObjectId(), false).get(0).getName());
assertEquals(1, repository.getJobNames(jobsDir.getObjectId(), false).length);
assertEquals(1, repository.getJobNames(jobsDir.getObjectId(), true).length);
assertEquals(jobMeta.getName(), repository.getJobNames(jobsDir.getObjectId(), false)[0]);
repository.deleteJob(jobMeta.getObjectId());
assertFalse(repository.exists(EXP_JOB_NAME, jobsDir, RepositoryObjectType.JOB));
assertEquals(0, repository.getJobObjects(jobsDir.getObjectId(), false).size());
assertEquals(1, repository.getJobObjects(jobsDir.getObjectId(), true).size());
assertEquals(jobMeta.getName(), repository.getJobObjects(jobsDir.getObjectId(), true).get(0).getName());
assertEquals(0, repository.getJobNames(jobsDir.getObjectId(), false).length);
assertEquals(1, repository.getJobNames(jobsDir.getObjectId(), true).length);
assertEquals(jobMeta.getName(), repository.getJobNames(jobsDir.getObjectId(), true)[0]);
}
use of org.pentaho.di.ui.repository.pur.services.ILockService in project pentaho-kettle by pentaho.
the class RepositoryTestBase method testTransformations.
/**
* save(trans) loadTransformation() exists() getTransformationLock() lockTransformation() unlockTransformation()
* getTransformationID() getTransformationObjects() getTransformationNames()
*/
@Test
public void testTransformations() throws Exception {
ILockService service = (ILockService) repository.getService(ILockService.class);
RepositoryDirectoryInterface rootDir = initRepo();
String uniqueTransName = EXP_TRANS_NAME.concat(EXP_DBMETA_NAME);
TransMeta transMeta = createTransMeta(EXP_DBMETA_NAME);
// Create a database association
DatabaseMeta dbMeta = createDatabaseMeta(EXP_DBMETA_NAME);
repository.save(dbMeta, VERSION_COMMENT_V1, null);
TableInputMeta tableInputMeta = new TableInputMeta();
tableInputMeta.setDatabaseMeta(dbMeta);
transMeta.addStep(new StepMeta(EXP_TRANS_STEP_1_NAME, tableInputMeta));
RepositoryDirectoryInterface transDir = rootDir.findDirectory(DIR_TRANSFORMATIONS);
repository.save(transMeta, VERSION_COMMENT_V1, null);
deleteStack.push(transMeta);
assertNotNull(transMeta.getObjectId());
ObjectRevision version = transMeta.getObjectRevision();
assertNotNull(version);
assertTrue(hasVersionWithComment(transMeta, VERSION_COMMENT_V1));
assertTrue(repository.exists(uniqueTransName, transDir, RepositoryObjectType.TRANSFORMATION));
TransMeta fetchedTrans = repository.loadTransformation(uniqueTransName, transDir, null, false, null);
assertEquals(uniqueTransName, fetchedTrans.getName());
assertEquals(EXP_TRANS_DESC, fetchedTrans.getDescription());
assertEquals(EXP_TRANS_EXTENDED_DESC, fetchedTrans.getExtendedDescription());
assertEquals(transDir.getPath(), fetchedTrans.getRepositoryDirectory().getPath());
assertEquals(EXP_TRANS_VERSION, fetchedTrans.getTransversion());
assertEquals(EXP_TRANS_STATUS, fetchedTrans.getTransstatus());
assertEquals(EXP_TRANS_CREATED_USER, fetchedTrans.getCreatedUser());
assertEquals(EXP_TRANS_CREATED_DATE, fetchedTrans.getCreatedDate());
assertEquals(EXP_TRANS_MOD_USER, fetchedTrans.getModifiedUser());
assertEquals(EXP_TRANS_MOD_DATE, fetchedTrans.getModifiedDate());
assertEquals(1, fetchedTrans.listParameters().length);
assertEquals(EXP_TRANS_PARAM_1_DEF, fetchedTrans.getParameterDefault(EXP_TRANS_PARAM_1_NAME));
assertEquals(EXP_TRANS_PARAM_1_DESC, fetchedTrans.getParameterDescription(EXP_TRANS_PARAM_1_NAME));
// Test reference to database connection
String[] transformations = repository.getTransformationsUsingDatabase(dbMeta.getObjectId());
assertNotNull(transformations);
assertEquals(1, transformations.length);
assertTrue(transformations[0].contains(fetchedTrans.getName()));
// TransLogTable transLogTable = fetchedTrans.getTransLogTable();
// TODO mlowery why doesn't this work?
// assertEquals(EXP_TRANS_LOG_TABLE_CONN_NAME, transLogTable.getConnectionName());
// assertEquals(EXP_TRANS_LOG_TABLE_INTERVAL, transLogTable.getLogInterval());
// assertEquals(EXP_TRANS_LOG_TABLE_SCHEMA_NAME, transLogTable.getSchemaName());
// assertEquals(EXP_TRANS_LOG_TABLE_SIZE_LIMIT, transLogTable.getLogSizeLimit());
// assertEquals(EXP_TRANS_LOG_TABLE_TABLE_NAME, transLogTable.getTableName());
// assertEquals(EXP_TRANS_LOG_TABLE_TIMEOUT_IN_DAYS, transLogTable.getTimeoutInDays());
// PerformanceLogTable perfLogTable = fetchedTrans.getPerformanceLogTable();
// TODO mlowery why doesn't this work?
// assertEquals(EXP_TRANS_LOG_TABLE_CONN_NAME, perfLogTable.getConnectionName());
// assertEquals(EXP_TRANS_LOG_TABLE_INTERVAL, perfLogTable.getLogInterval());
// assertEquals(EXP_TRANS_LOG_TABLE_SCHEMA_NAME, perfLogTable.getSchemaName());
// assertEquals(EXP_TRANS_LOG_TABLE_TABLE_NAME, perfLogTable.getTableName());
// assertEquals(EXP_TRANS_LOG_TABLE_TIMEOUT_IN_DAYS, perfLogTable.getTimeoutInDays());
// ChannelLogTable channelLogTable = fetchedTrans.getChannelLogTable();
// TODO mlowery why doesn't this work?
// assertEquals(EXP_TRANS_LOG_TABLE_CONN_NAME, channelLogTable.getConnectionName());
// assertEquals(EXP_TRANS_LOG_TABLE_SCHEMA_NAME, channelLogTable.getSchemaName());
// assertEquals(EXP_TRANS_LOG_TABLE_TABLE_NAME, channelLogTable.getTableName());
// assertEquals(EXP_TRANS_LOG_TABLE_TIMEOUT_IN_DAYS, channelLogTable.getTimeoutInDays());
// StepLogTable stepLogTable = fetchedTrans.getStepLogTable();
// TODO mlowery why doesn't this work?
// assertEquals(EXP_TRANS_LOG_TABLE_CONN_NAME, stepLogTable.getConnectionName());
// assertEquals(EXP_TRANS_LOG_TABLE_SCHEMA_NAME, stepLogTable.getSchemaName());
// assertEquals(EXP_TRANS_LOG_TABLE_TABLE_NAME, stepLogTable.getTableName());
// assertEquals(EXP_TRANS_LOG_TABLE_TIMEOUT_IN_DAYS, stepLogTable.getTimeoutInDays());
assertEquals(EXP_DBMETA_NAME, fetchedTrans.getMaxDateConnection().getName());
assertEquals(EXP_TRANS_MAX_DATE_TABLE, fetchedTrans.getMaxDateTable());
assertEquals(EXP_TRANS_MAX_DATE_FIELD, fetchedTrans.getMaxDateField());
assertEquals(EXP_TRANS_MAX_DATE_OFFSET, fetchedTrans.getMaxDateOffset(), 0);
assertEquals(EXP_TRANS_MAX_DATE_DIFF, fetchedTrans.getMaxDateDifference(), 0);
assertEquals(EXP_TRANS_SIZE_ROWSET, fetchedTrans.getSizeRowset());
// TODO mlowery why don't next two sleep fields work?
// assertEquals(EXP_TRANS_SLEEP_TIME_EMPTY, fetchedTrans.getSleepTimeEmpty());
// assertEquals(EXP_TRANS_SLEEP_TIME_FULL, fetchedTrans.getSleepTimeFull());
assertEquals(EXP_TRANS_USING_UNIQUE_CONN, fetchedTrans.isUsingUniqueConnections());
assertEquals(EXP_TRANS_FEEDBACK_SHOWN, fetchedTrans.isFeedbackShown());
assertEquals(EXP_TRANS_FEEDBACK_SIZE, fetchedTrans.getFeedbackSize());
assertEquals(EXP_TRANS_USING_THREAD_PRIORITY_MGMT, fetchedTrans.isUsingThreadPriorityManagment());
assertEquals(EXP_TRANS_SHARED_OBJECTS_FILE, fetchedTrans.getSharedObjectsFile());
assertEquals(EXP_TRANS_CAPTURE_STEP_PERF_SNAPSHOTS, fetchedTrans.isCapturingStepPerformanceSnapShots());
assertEquals(EXP_TRANS_STEP_PERF_CAP_DELAY, fetchedTrans.getStepPerformanceCapturingDelay());
assertEquals(1, fetchedTrans.getDependencies().size());
assertEquals(EXP_DBMETA_NAME, fetchedTrans.getDependency(0).getDatabase().getName());
assertEquals(EXP_TRANS_DEP_TABLE_NAME, fetchedTrans.getDependency(0).getTablename());
assertEquals(EXP_TRANS_DEP_FIELD_NAME, fetchedTrans.getDependency(0).getFieldname());
assertEquals(3, fetchedTrans.getSteps().size());
assertEquals(EXP_TRANS_STEP_1_NAME, fetchedTrans.getStep(0).getName());
assertEquals(EXP_TRANS_STEP_ERROR_META_1_ENABLED, fetchedTrans.getStep(0).getStepErrorMeta().isEnabled());
assertEquals(EXP_TRANS_STEP_ERROR_META_1_NR_ERRORS_VALUE_NAME, fetchedTrans.getStep(0).getStepErrorMeta().getNrErrorsValuename());
assertEquals(EXP_TRANS_STEP_ERROR_META_1_DESC_VALUE_NAME, fetchedTrans.getStep(0).getStepErrorMeta().getErrorDescriptionsValuename());
assertEquals(EXP_TRANS_STEP_ERROR_META_1_FIELDS_VALUE_NAME, fetchedTrans.getStep(0).getStepErrorMeta().getErrorFieldsValuename());
assertEquals(EXP_TRANS_STEP_ERROR_META_1_CODES_VALUE_NAME, fetchedTrans.getStep(0).getStepErrorMeta().getErrorCodesValuename());
assertEquals(EXP_TRANS_STEP_ERROR_META_1_MAX_ERRORS, fetchedTrans.getStep(0).getStepErrorMeta().getMaxErrors());
assertEquals(EXP_TRANS_STEP_ERROR_META_1_MAX_PERCENT_ERRORS, fetchedTrans.getStep(0).getStepErrorMeta().getMaxPercentErrors());
assertEquals(EXP_TRANS_STEP_ERROR_META_1_MIN_PERCENT_ROWS, fetchedTrans.getStep(0).getStepErrorMeta().getMinPercentRows());
assertEquals(EXP_TRANS_STEP_2_NAME, fetchedTrans.getStep(1).getName());
assertEquals(EXP_TRANS_STEP_1_NAME, fetchedTrans.getTransHop(0).getFromStep().getName());
assertEquals(EXP_TRANS_STEP_2_NAME, fetchedTrans.getTransHop(0).getToStep().getName());
assertEquals(1, transMeta.getSlaveStepCopyPartitionDistribution().getOriginalPartitionSchemas().size());
assertTrue(transMeta.getSlaveStepCopyPartitionDistribution().getOriginalPartitionSchemas().get(0).getName().startsWith(EXP_PART_SCHEMA_NAME));
assertTrue(-1 != transMeta.getSlaveStepCopyPartitionDistribution().getPartition(EXP_SLAVE_NAME, EXP_PART_SCHEMA_NAME, 0));
assertEquals(EXP_TRANS_SLAVE_TRANSFORMATION, transMeta.isSlaveTransformation());
TransMeta transMetaById = repository.loadTransformation(transMeta.getObjectId(), null);
// assertEquals( fetchedTrans, transMetaById ); broken by BACKLOG-20809; probably ok
assertNull(service.getTransformationLock(transMeta.getObjectId()));
service.lockTransformation(transMeta.getObjectId(), EXP_TRANS_LOCK_MSG);
assertEquals(EXP_TRANS_LOCK_MSG, service.getTransformationLock(transMeta.getObjectId()).getMessage());
assertEquals(getDate(new Date()), getDate(service.getTransformationLock(transMeta.getObjectId()).getLockDate()));
assertEquals(EXP_LOGIN_PLUS_TENANT, service.getTransformationLock(transMeta.getObjectId()).getLogin());
// TODO mlowery currently PUR lock only stores "login"; why do we need username too?
// assertEquals(EXP_USERNAME, repository.getTransformationLock(transMeta.getObjectId()).getUsername());
assertEquals(transMeta.getObjectId(), service.getTransformationLock(transMeta.getObjectId()).getObjectId());
service.unlockTransformation(transMeta.getObjectId());
assertNull(service.getTransformationLock(transMeta.getObjectId()));
transMeta.setDescription(EXP_TRANS_DESC_V2);
repository.save(transMeta, VERSION_COMMENT_V2, null);
assertTrue(hasVersionWithComment(transMeta, VERSION_COMMENT_V2));
fetchedTrans = repository.loadTransformation(uniqueTransName, transDir, null, false, null);
assertEquals(EXP_TRANS_DESC_V2, fetchedTrans.getDescription());
fetchedTrans = repository.loadTransformation(uniqueTransName, transDir, null, false, VERSION_LABEL_V1);
assertEquals(EXP_TRANS_DESC, fetchedTrans.getDescription());
transMetaById = repository.loadTransformation(transMeta.getObjectId(), VERSION_LABEL_V1);
// assertEquals( fetchedTrans, transMetaById ); broken by BACKLOG-20809; probably ok
assertEquals(transMeta.getObjectId(), repository.getTransformationID(uniqueTransName, transDir));
assertEquals(1, repository.getTransformationObjects(transDir.getObjectId(), false).size());
assertEquals(1, repository.getTransformationObjects(transDir.getObjectId(), true).size());
assertEquals(transMeta.getName(), repository.getTransformationObjects(transDir.getObjectId(), false).get(0).getName());
assertEquals(1, repository.getTransformationNames(transDir.getObjectId(), false).length);
assertEquals(1, repository.getTransformationNames(transDir.getObjectId(), true).length);
assertEquals(transMeta.getName(), repository.getTransformationNames(transDir.getObjectId(), false)[0]);
repository.deleteTransformation(transMeta.getObjectId());
assertFalse(repository.exists(uniqueTransName, transDir, RepositoryObjectType.TRANSFORMATION));
assertEquals(0, repository.getTransformationObjects(transDir.getObjectId(), false).size());
assertEquals(1, repository.getTransformationObjects(transDir.getObjectId(), true).size());
assertEquals(transMeta.getName(), repository.getTransformationObjects(transDir.getObjectId(), true).get(0).getName());
assertEquals(0, repository.getTransformationNames(transDir.getObjectId(), false).length);
assertEquals(1, repository.getTransformationNames(transDir.getObjectId(), true).length);
assertEquals(transMeta.getName(), repository.getTransformationNames(transDir.getObjectId(), true)[0]);
}
Aggregations