use of org.pentaho.di.ui.core.events.dialog.extension.ExtensionPointWrapper in project pentaho-kettle by pentaho.
the class ConditionSelectionAdapterFileDialogTest method testWidgetSelectedHelper.
@Test
public void testWidgetSelectedHelper() {
// SETUP
LogChannelInterface log = mock(LogChannelInterface.class);
TextVar textVar = mock(TextVar.class);
AbstractMeta meta = mock(AbstractMeta.class);
RepositoryUtility repositoryUtility = mock(RepositoryUtility.class);
ExtensionPointWrapper extensionPointWrapper = mock(ExtensionPointWrapper.class);
SelectionAdapterOptions options = new SelectionAdapterOptions(SelectionOperation.FILE);
SelectionEvent event = mock(SelectionEvent.class);
String testPath = "/home/devuser/some/path";
when(meta.environmentSubstitute(testPath)).thenReturn(testPath);
when(textVar.getText()).thenReturn(testPath);
ArgumentCaptor textCapture = ArgumentCaptor.forClass(String.class);
doNothing().when(textVar).setText((String) textCapture.capture());
ConditionSelectionAdapterFileDialogTextVar testInstance = new ConditionSelectionAdapterFileDialogTextVar(log, textVar, meta, options, repositoryUtility, extensionPointWrapper, () -> SelectionOperation.FOLDER);
testInstance.widgetSelected(event);
assertTrue(testInstance.getSelectionOptions().getSelectionOperation() == SelectionOperation.FOLDER);
options = new SelectionAdapterOptions(SelectionOperation.FILE);
ConditionSelectionAdapterFileDialogTextVar testInstance2 = new ConditionSelectionAdapterFileDialogTextVar(log, textVar, meta, options, repositoryUtility, extensionPointWrapper, () -> SelectionOperation.FILE);
testInstance.widgetSelected(event);
assertTrue(testInstance2.getSelectionOptions().getSelectionOperation() == SelectionOperation.FILE);
}
use of org.pentaho.di.ui.core.events.dialog.extension.ExtensionPointWrapper in project pentaho-kettle by pentaho.
the class SelectionAdapterFileDialogTest method testIsConnectedToRepository.
@Test
public void testIsConnectedToRepository() {
// SETUP
LogChannelInterface log = mock(LogChannelInterface.class);
StringBuilder textVar = new StringBuilder();
AbstractMeta meta = mock(AbstractMeta.class);
ExtensionPointWrapper extensionPointWrapper = mock(ExtensionPointWrapper.class);
SelectionAdapterOptions options = new SelectionAdapterOptions(SelectionOperation.FILE);
// True case:
RepositoryUtility repositoryUtilityTrue = mock(RepositoryUtility.class);
when(repositoryUtilityTrue.isConnectedToRepository()).thenReturn(true);
SelectionAdapterFileDialog testInstance1 = createTestInstance(log, textVar, meta, options, repositoryUtilityTrue, extensionPointWrapper);
assertTrue(testInstance1.isConnectedToRepository());
// False case:
RepositoryUtility repositoryUtilityFalse = mock(RepositoryUtility.class);
when(repositoryUtilityFalse.isConnectedToRepository()).thenReturn(false);
SelectionAdapterFileDialog testInstance2 = createTestInstance(log, textVar, meta, options, repositoryUtilityFalse, extensionPointWrapper);
assertFalse(testInstance2.isConnectedToRepository());
}
use of org.pentaho.di.ui.core.events.dialog.extension.ExtensionPointWrapper in project pentaho-kettle by pentaho.
the class SelectionAdapterFileDialogTest method testApplyRelativePathEnvVar.
@Test
public void testApplyRelativePathEnvVar() throws IOException {
// SETUP
LogChannelInterface log = mock(LogChannelInterface.class);
StringBuilder textVar = new StringBuilder();
AbstractMeta meta = mock(AbstractMeta.class);
RepositoryUtility repositoryUtility = mock(RepositoryUtility.class);
ExtensionPointWrapper extensionPointWrapper = mock(ExtensionPointWrapper.class);
SelectionAdapterOptions options = new SelectionAdapterOptions(SelectionOperation.FILE);
File testFile = temporaryFolder.newFile("testFileName");
String testPath = testFile.getPath();
when(meta.environmentSubstitute(testPath)).thenReturn(testPath);
SelectionAdapterFileDialog testInstance1 = createTestInstance(log, textVar, meta, options, repositoryUtility, extensionPointWrapper);
testInstance1.setText(testPath);
String pathWithCurrentDirVar = testInstance1.applyRelativePathEnvVar(testPath);
assertEquals(testPath, pathWithCurrentDirVar);
when(meta.getFilename()).thenReturn(testPath);
pathWithCurrentDirVar = testInstance1.applyRelativePathEnvVar(testPath);
assertEquals("${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}/testFileName", pathWithCurrentDirVar);
}
use of org.pentaho.di.ui.core.events.dialog.extension.ExtensionPointWrapper in project pentaho-kettle by pentaho.
the class SelectionAdapterFileDialogTest method testWidgetSelectedHelper.
@Test
public void testWidgetSelectedHelper() {
// SETUP
LogChannelInterface log = mock(LogChannelInterface.class);
StringBuilder textVar = new StringBuilder();
AbstractMeta meta = mock(AbstractMeta.class);
RepositoryUtility repositoryUtility = mock(RepositoryUtility.class);
ExtensionPointWrapper extensionPointWrapper = mock(ExtensionPointWrapper.class);
SelectionAdapterOptions options = new SelectionAdapterOptions(SelectionOperation.FILE);
SelectionEvent event = mock(SelectionEvent.class);
String testPath = "/home/devuser/some/path";
when(meta.environmentSubstitute(testPath)).thenReturn(testPath);
SelectionAdapterFileDialog testInstance1 = createTestInstance(log, textVar, meta, options, repositoryUtility, extensionPointWrapper);
testInstance1.setText(testPath);
testInstance1.widgetSelected(event);
assertEquals(testInstance1.getText(), testPath);
}
use of org.pentaho.di.ui.core.events.dialog.extension.ExtensionPointWrapper in project pentaho-kettle by pentaho.
the class SelectionAdapterFileDialogTest method createTestInstance.
protected SelectionAdapterFileDialog createTestInstance() {
LogChannelInterface log = mock(LogChannelInterface.class);
StringBuilder textWidget = new StringBuilder();
AbstractMeta meta = mock(AbstractMeta.class);
RepositoryUtility repositoryUtility = mock(RepositoryUtility.class);
ExtensionPointWrapper extensionPointWrapper = mock(ExtensionPointWrapper.class);
SelectionAdapterOptions options = new SelectionAdapterOptions(SelectionOperation.FILE, new String[] {}, "");
return createTestInstance(log, textWidget, meta, options, repositoryUtility, extensionPointWrapper);
}
Aggregations