use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.
the class SpoonTest method prepareSetShellTextTests.
private static Shell prepareSetShellTextTests(Spoon spoon, AbstractMeta abstractMeta, boolean versionEnabled, boolean isTransformation, boolean repIsNull, boolean revIsNull, boolean hasChanged, boolean nameIsNull, boolean filenameIsNull, boolean tabNameIsNull) {
Shell mockShell = mock(Shell.class);
ObjectRevision mockObjectRevision = revIsNull ? null : mock(ObjectRevision.class);
RepositoryDirectory mockRepDirectory = mock(RepositoryDirectory.class);
Repository mockRepository = repIsNull ? null : mock(Repository.class);
RepositorySecurityProvider mockRepSecurityProvider = mock(RepositorySecurityProvider.class);
SpoonDelegates mockDelegate = mock(SpoonDelegates.class);
SpoonTabsDelegate mockDelegateTabs = mock(SpoonTabsDelegate.class);
spoon.rep = mockRepository;
spoon.delegates = mockDelegate;
mockDelegate.tabs = mockDelegateTabs;
doCallRealMethod().when(spoon).openSpoon();
doCallRealMethod().when(spoon).setShellText();
doReturn(mockShell).when(spoon).getShell();
if (!tabNameIsNull) {
doReturn("tabName").when(spoon).getActiveTabText();
}
doReturn(false).when(mockShell).isDisposed();
setTransJobValues(abstractMeta, spoon, mockObjectRevision, mockRepDirectory, isTransformation, hasChanged, nameIsNull, filenameIsNull);
if (!revIsNull) {
doReturn("1.0").when(mockObjectRevision).getName();
}
doReturn("/admin").when(mockRepDirectory).getPath();
Mockito.doReturn(null).when(abstractMeta).getVersioningEnabled();
if (!repIsNull) {
doReturn(mockRepSecurityProvider).when(mockRepository).getSecurityProvider();
doReturn(versionEnabled).when(mockRepSecurityProvider).isVersioningEnabled(anyString());
}
doReturn("RepositoryName").when(spoon).getRepositoryName();
doReturn(new ArrayList<TabMapEntry>()).when(mockDelegateTabs).getTabs();
try {
spoon.openSpoon();
} catch (NullPointerException e) {
// ignore work is done
}
spoon.setShellText();
return mockShell;
}
use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.
the class SpoonTabsDelegate method makeTabName.
public String makeTabName(EngineMetaInterface transMeta, boolean showLocation) {
if (Utils.isEmpty(transMeta.getName()) && Utils.isEmpty(transMeta.getFilename())) {
return Spoon.STRING_TRANS_NO_NAME;
}
if (Utils.isEmpty(transMeta.getName()) || spoon.delegates.trans.isDefaultTransformationName(transMeta.getName())) {
transMeta.nameFromFilename();
}
String name = "";
if (showLocation) {
if (!Utils.isEmpty(transMeta.getFilename())) {
// Regular file...
//
name += transMeta.getFilename() + " : ";
} else {
// Repository object...
//
name += transMeta.getRepositoryDirectory().getPath() + " : ";
}
}
name += transMeta.getName();
if (showLocation) {
ObjectRevision version = transMeta.getObjectRevision();
if (version != null) {
name += " : r" + version.getName();
}
}
return name;
}
use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.
the class UIEEJobTest method testRevisions.
@Test
public void testRevisions() throws Exception {
final String revisionName = "revisionName";
final String commitMessage = "commitMessage";
ObjectRevision mockObjectRevision = mock(ObjectRevision.class);
when(mockObjectRevision.getName()).thenReturn(revisionName);
List<ObjectRevision> mockRevisions = Arrays.asList(new ObjectRevision[] { mockObjectRevision });
when(mockRevisionService.getRevisions(any(ObjectId.class))).thenReturn(mockRevisions);
uiJob.refreshRevisions();
verify(mockRevisionService, times(1)).getRevisions(mockObjectId);
UIRepositoryObjectRevisions revisions = uiJob.getRevisions();
assertEquals(1, revisions.size());
assertEquals("revisionName", revisions.get(0).getName());
verify(mockRevisionService, times(1)).getRevisions(mockObjectId);
uiJob.restoreRevision(revisions.get(0), commitMessage);
verify(mockRevisionService).restoreJob(mockObjectId, revisionName, commitMessage);
verify(mockParent, times(1)).fireCollectionChanged();
}
use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.
the class PurRepositoryRevisionBrowserDialog method getData.
/**
* Copy information from the meta-data input to the dialog fields.
*/
public void getData() {
wFields.clearAll(false);
for (ObjectRevision revision : revisions) {
wFields.add(revision.getName(), revision.getComment(), XMLHandler.date2string(revision.getCreationDate()), revision.getLogin());
}
wFields.removeEmptyRows();
wFields.setRowNums();
wFields.optWidth(true);
}
use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.
the class UIEEJob method getRevisions.
public UIRepositoryObjectRevisions getRevisions() throws KettleException {
if (revisions != null) {
return revisions;
}
revisions = new UIRepositoryObjectRevisions();
List<ObjectRevision> or = revisionService.getRevisions(getObjectId());
for (ObjectRevision rev : or) {
revisions.add(new UIRepositoryObjectRevision(rev));
}
return revisions;
}
Aggregations