use of org.pentaho.di.repository.RepositorySecurityProvider 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.RepositorySecurityProvider in project pentaho-kettle by pentaho.
the class SpoonTest method testVersioningCheckingOnServer.
@Test
public void testVersioningCheckingOnServer() throws Exception {
Repository repository = Mockito.mock(Repository.class);
RepositorySecurityProvider securityProvider = Mockito.mock(RepositorySecurityProvider.class);
Mockito.doReturn(securityProvider).when(repository).getSecurityProvider();
EngineMetaInterface jobTransMeta = Mockito.spy(new TransMeta());
RepositoryDirectoryInterface repositoryDirectoryInterface = Mockito.mock(RepositoryDirectoryInterface.class);
Mockito.doReturn("/home").when(repositoryDirectoryInterface).toString();
Mockito.doReturn("trans").when(jobTransMeta).getName();
Mockito.doReturn(RepositoryObjectType.TRANSFORMATION).when(jobTransMeta).getRepositoryElementType();
Mockito.doReturn(true).when(securityProvider).isVersioningEnabled(Mockito.anyString());
boolean result = Spoon.isVersionEnabled(repository, jobTransMeta);
Assert.assertTrue(result);
}
use of org.pentaho.di.repository.RepositorySecurityProvider in project pentaho-kettle by pentaho.
the class SpoonTest method testVersioningDisabled.
@Test
public void testVersioningDisabled() throws Exception {
Repository repository = Mockito.mock(Repository.class);
RepositorySecurityProvider securityProvider = Mockito.mock(RepositorySecurityProvider.class);
Mockito.doReturn(securityProvider).when(repository).getSecurityProvider();
EngineMetaInterface jobTransMeta = Mockito.spy(new TransMeta());
RepositoryDirectoryInterface repositoryDirectoryInterface = Mockito.mock(RepositoryDirectoryInterface.class);
Mockito.doReturn("/home").when(repositoryDirectoryInterface).toString();
Mockito.doReturn("trans").when(jobTransMeta).getName();
Mockito.doReturn(RepositoryObjectType.TRANSFORMATION).when(jobTransMeta).getRepositoryElementType();
Mockito.doReturn(false).when(jobTransMeta).getVersioningEnabled();
boolean result = Spoon.isVersionEnabled(repository, jobTransMeta);
Assert.assertFalse(result);
Mockito.verify(securityProvider, Mockito.never()).isVersioningEnabled(Mockito.anyString());
}
use of org.pentaho.di.repository.RepositorySecurityProvider in project pentaho-kettle by pentaho.
the class RepositorySecurityUI method getVersionComment.
public static String getVersionComment(Shell shell, Repository repository, String operationDescription, String fullPath, boolean forceEntry) {
// removes a web service call per file.
if (repository == null) {
return null;
}
RepositorySecurityProvider provider = repository.getSecurityProvider();
if (forceEntry || provider.allowsVersionComments(fullPath)) {
String explanation = "Enter a comment ";
if (provider.isVersionCommentMandatory()) {
explanation += "(Mandatory) : ";
} else {
explanation += ": ";
}
String versionComment = "Checked in";
EnterStringDialog dialog = new EnterStringDialog(shell, versionComment, "Enter comment", explanation);
dialog.setManditory(provider.isVersionCommentMandatory());
versionComment = dialog.open();
return versionComment;
}
return null;
}
use of org.pentaho.di.repository.RepositorySecurityProvider in project pentaho-kettle by pentaho.
the class SpoonTest method testVersioningEnabled.
@Test
public void testVersioningEnabled() throws Exception {
Repository repository = Mockito.mock(Repository.class);
RepositorySecurityProvider securityProvider = Mockito.mock(RepositorySecurityProvider.class);
Mockito.doReturn(securityProvider).when(repository).getSecurityProvider();
EngineMetaInterface jobTransMeta = Mockito.spy(new TransMeta());
RepositoryDirectoryInterface repositoryDirectoryInterface = Mockito.mock(RepositoryDirectoryInterface.class);
Mockito.doReturn("/home").when(repositoryDirectoryInterface).toString();
Mockito.doReturn("trans").when(jobTransMeta).getName();
Mockito.doReturn(RepositoryObjectType.TRANSFORMATION).when(jobTransMeta).getRepositoryElementType();
Mockito.doReturn(true).when(jobTransMeta).getVersioningEnabled();
boolean result = Spoon.isVersionEnabled(repository, jobTransMeta);
Assert.assertTrue(result);
Mockito.verify(securityProvider, Mockito.never()).isVersioningEnabled(Mockito.anyString());
}
Aggregations