use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class SingleThreaderDialog method loadTransformation.
private void loadTransformation() throws KettleException {
String filename = wPath.getText();
if (repository != null) {
specificationMethod = ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME;
} else {
specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
}
switch(specificationMethod) {
case FILENAME:
if (Utils.isEmpty(filename)) {
return;
}
if (!filename.endsWith(".ktr")) {
filename = filename + ".ktr";
wPath.setText(filename);
}
loadFileTrans(filename);
break;
case REPOSITORY_BY_NAME:
if (Utils.isEmpty(filename)) {
return;
}
if (filename.endsWith(".ktr")) {
filename = filename.replace(".ktr", "");
wPath.setText(filename);
}
String transPath = transMeta.environmentSubstitute(filename);
String realTransname = transPath;
String realDirectory = "";
int index = transPath.lastIndexOf("/");
if (index != -1) {
realTransname = transPath.substring(index + 1);
realDirectory = transPath.substring(0, index);
}
if (Utils.isEmpty(realDirectory) || Utils.isEmpty(realTransname)) {
throw new KettleException(BaseMessages.getString(PKG, "SingleThreaderDialog.Exception.NoValidMappingDetailsFound"));
}
RepositoryDirectoryInterface repdir = repository.findDirectory(realDirectory);
if (repdir == null) {
throw new KettleException(BaseMessages.getString(PKG, "SingleThreaderDialog.Exception.UnableToFindRepositoryDirectory)"));
}
loadRepositoryTrans(realTransname, repdir);
break;
case REPOSITORY_BY_REFERENCE:
// load the last version
mappingTransMeta = repository.loadTransformation(referenceObjectId, null);
mappingTransMeta.clearChanged();
break;
default:
break;
}
wInjectStep.setText(getInjectorStep(mappingTransMeta));
}
use of org.pentaho.di.repository.RepositoryDirectoryInterface 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.RepositoryDirectoryInterface 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.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class DialogUtilsTest method testPathAndName.
private void testPathAndName(String path, String name, String expected) {
RepositoryElementMetaInterface object = mock(RepositoryElementMetaInterface.class);
RepositoryDirectoryInterface directory = mock(RepositoryDirectoryInterface.class);
when(directory.getPath()).thenReturn(path);
when(object.getRepositoryDirectory()).thenReturn(directory);
when(object.getName()).thenReturn(name);
assertEquals(expected, getPathOf(object));
}
use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class DialogUtilsTest method nullDirectoryPath.
@Test
public void nullDirectoryPath() {
RepositoryElementMetaInterface object = mock(RepositoryElementMetaInterface.class);
RepositoryDirectoryInterface directory = mock(RepositoryDirectoryInterface.class);
when(object.getRepositoryDirectory()).thenReturn(directory);
assertNull(getPathOf(object));
}
Aggregations