use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-kettle by pentaho.
the class DatabaseDelegateTest method testExtraOptionEscapeWithInvalidCharInDatabaseType.
@Test
public void testExtraOptionEscapeWithInvalidCharInDatabaseType() throws KettleException {
DatabaseMeta dbMeta = mock(DatabaseMeta.class);
when(dbMeta.getPluginId()).thenReturn("pluginId");
when(dbMeta.getAccessTypeDesc()).thenReturn("Native");
when(dbMeta.getHostname()).thenReturn("AS/400Host");
when(dbMeta.getDatabaseName()).thenReturn("mainframeTable");
when(dbMeta.getDatabasePortNumberString()).thenReturn("1234");
when(dbMeta.getUsername()).thenReturn("testUser");
when(dbMeta.getPassword()).thenReturn("123");
when(dbMeta.getServername()).thenReturn("as400.dot.com");
when(dbMeta.getDataTablespace()).thenReturn("tableSpace");
when(dbMeta.getIndexTablespace()).thenReturn("123");
// Create an extra options that has an unsupported character like '/'
Properties extraOptions = new Properties();
extraOptions.setProperty("EXTRA_OPTION_AS/400.optionExtraOption", "true");
when(dbMeta.getAttributes()).thenReturn(extraOptions);
IUnifiedRepository purRepo = mock(IUnifiedRepository.class);
when(purRepo.getReservedChars()).thenReturn(Arrays.asList(new Character[] { '/' }));
when(mockPurRepository.getUnderlyingRepository()).thenReturn(purRepo);
DataNode escapedAttributes = dbDelegate.elementToDataNode(dbMeta);
// Should only be one option in list
for (Iterator<DataNode> iter = escapedAttributes.getNodes().iterator(); iter.hasNext(); ) {
DataNode options = iter.next();
assertTrue("Invalid escaped extra options", options.hasProperty("EXTRA_OPTION_AS%2F400.optionExtraOption"));
assertFalse("Should not contain un-escaped option", options.hasProperty("EXTRA_OPTION_AS/400.optionExtraOption"));
}
}
use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-kettle by pentaho.
the class DelegatesPrivateDatabasesTest method savesNode_IfSetIsEmpty.
@Test
public void savesNode_IfSetIsEmpty() throws Exception {
meta.setPrivateDatabases(Collections.<String>emptySet());
DataNode dataNode = element2node();
DataNode dbsNode = dataNode.getNode(privateDbsNodeName);
assertNotNull("Even if the set is empty, the node should be saved as an indicator", dbsNode);
DataNode databaseNode = Iterables.getFirst(dbsNode.getNodes(), null);
assertNull(databaseNode);
}
use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-kettle by pentaho.
the class DelegatesPrivateDatabasesTest method doesNotSaveNode_IfSetIsNull.
@Test
public void doesNotSaveNode_IfSetIsNull() throws Exception {
meta.setPrivateDatabases(null);
DataNode dataNode = element2node();
DataNode dbsNode = dataNode.getNode(privateDbsNodeName);
assertNull(dbsNode);
}
use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-kettle by pentaho.
the class DelegatesPrivateDatabasesTest method element2node.
private DataNode element2node() throws KettleException {
DataNode dataNode = delegate.elementToDataNode(meta);
assertNotNull(dataNode);
return dataNode;
}
use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-kettle by pentaho.
the class JobDelegateTest method testElementToDataNodeSavesCopyAttributes.
@Test
public void testElementToDataNodeSavesCopyAttributes() throws KettleException {
JobMeta mockJobMeta = mock(JobMeta.class);
IUnifiedRepository mockUnifiedRepository = mock(IUnifiedRepository.class);
JobDelegate jobDelegate = new JobDelegate(mockPurRepository, mockUnifiedRepository);
JobLogTable mockJobLogTable = mock(JobLogTable.class);
JobEntryCopy mockJobEntryCopy = mock(JobEntryCopy.class);
Map<String, Map<String, String>> attributes = new HashMap<String, Map<String, String>>();
Map<String, String> group = new HashMap<String, String>();
final String mockGroup = "MOCK_GROUP";
final String mockProperty = "MOCK_PROPERTY";
final String mockValue = "MOCK_VALUE";
group.put(mockProperty, mockValue);
attributes.put(mockGroup, group);
when(mockJobEntryCopy.getAttributesMap()).thenReturn(attributes);
JobEntryBaseAndInterface mockJobEntry = mock(JobEntryBaseAndInterface.class);
when(mockJobMeta.listParameters()).thenReturn(new String[] {});
when(mockJobMeta.getJobLogTable()).thenReturn(mockJobLogTable);
when(mockJobMeta.nrJobEntries()).thenReturn(1);
when(mockJobMeta.getJobEntry(0)).thenReturn(mockJobEntryCopy);
when(mockJobEntryCopy.getName()).thenReturn("MOCK_NAME");
when(mockJobEntryCopy.getLocation()).thenReturn(new Point(0, 0));
when(mockJobEntryCopy.getEntry()).thenReturn(mockJobEntry);
DataNode dataNode = jobDelegate.elementToDataNode(mockJobMeta);
DataNode groups = dataNode.getNode("entries").getNodes().iterator().next().getNode(AttributesMapUtil.NODE_ATTRIBUTE_GROUPS);
DataNode mockGroupNode = groups.getNode(mockGroup);
assertEquals(mockValue, mockGroupNode.getProperty(mockProperty).getString());
}
Aggregations