use of org.pentaho.di.core.logging.JobLogTable in project pentaho-kettle by pentaho.
the class JobDelegateTest method testElementToDataNodeSavesAttributes.
@Test
public void testElementToDataNodeSavesAttributes() 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);
JobEntryBaseAndInterface mockJobEntry = mock(JobEntryBaseAndInterface.class);
when(mockJobEntry.getAttributesMap()).thenReturn(attributes);
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());
}
use of org.pentaho.di.core.logging.JobLogTable in project pentaho-kettle by pentaho.
the class JobDialog method getLogInfo.
private void getLogInfo(int previousLogTableIndex) {
if (previousLogTableIndex < 0) {
return;
}
// Remember the that was entered data...
//
LogTableInterface modifiedLogTable = logTables.get(previousLogTableIndex);
LogTableUserInterface logTableUserInterface = logTableUserInterfaces.get(previousLogTableIndex);
if (logTableUserInterface != null) {
logTableUserInterface.retrieveLogTableOptions(modifiedLogTable);
} else {
if (modifiedLogTable instanceof JobLogTable) {
getJobLogTableOptions((JobLogTable) modifiedLogTable);
} else if (modifiedLogTable instanceof ChannelLogTable) {
getChannelLogTableOptions((ChannelLogTable) modifiedLogTable);
} else if (modifiedLogTable instanceof JobEntryLogTable) {
getJobEntryLogTableOptions((JobEntryLogTable) modifiedLogTable);
}
}
}
use of org.pentaho.di.core.logging.JobLogTable in project pentaho-kettle by pentaho.
the class SpoonExportXmlTest method initTables.
private void initTables(JobMeta jobMeta) {
JobLogTable jobLogTable = JobLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
initTableWithSampleParams(jobLogTable);
jobLogTable.setLogInterval(GLOBAL_PARAM);
jobLogTable.setLogSizeLimit(GLOBAL_PARAM);
jobMeta.setJobLogTable(jobLogTable);
JobEntryLogTable jobEntryLogTable = JobEntryLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
initTableWithSampleParams(jobEntryLogTable);
jobMeta.setJobEntryLogTable(jobEntryLogTable);
ChannelLogTable channelLogTable = ChannelLogTable.getDefault(mockedVariableSpace, mockedHasDbInterface);
initTableWithSampleParams(channelLogTable);
jobMeta.setChannelLogTable(channelLogTable);
jobMeta.setExtraLogTables(null);
}
use of org.pentaho.di.core.logging.JobLogTable in project pentaho-kettle by pentaho.
the class Spoon method saveJobAsXmlFile.
private boolean saveJobAsXmlFile(JobMeta jobMeta, boolean export) {
JobLogTable origJobLogTable = jobMeta.getJobLogTable();
JobEntryLogTable originEntryLogTable = jobMeta.getJobEntryLogTable();
ChannelLogTable originChannelLogTable = jobMeta.getChannelLogTable();
List<LogTableInterface> originExtraLogTables = jobMeta.getExtraLogTables();
try {
XmlExportHelper.swapTables(jobMeta);
return saveXMLFile(jobMeta, export);
} finally {
jobMeta.setJobLogTable(origJobLogTable);
jobMeta.setJobEntryLogTable(originEntryLogTable);
jobMeta.setChannelLogTable(originChannelLogTable);
jobMeta.setExtraLogTables(originExtraLogTables);
}
}
use of org.pentaho.di.core.logging.JobLogTable in project pentaho-kettle by pentaho.
the class JobHasJobLogConfiguredImportRuleIT method testRule.
public void testRule() throws Exception {
JobMeta jobMeta = new JobMeta();
DatabaseMeta logDbMeta = new DatabaseMeta("LOGDB", "MYSQL", "JDBC", "localhost", "test", "3306", "foo", "bar");
jobMeta.addDatabase(logDbMeta);
JobLogTable logTable = jobMeta.getJobLogTable();
PluginRegistry registry = PluginRegistry.getInstance();
PluginInterface plugin = registry.findPluginWithId(ImportRulePluginType.class, "JobHasJobLogConfigured");
assertNotNull("The 'job has job log table configured' rule could not be found in the plugin registry!", plugin);
JobHasJobLogConfiguredImportRule rule = (JobHasJobLogConfiguredImportRule) registry.loadClass(plugin);
assertNotNull("The 'job has job log table configured' class could not be loaded by the plugin registry!", plugin);
rule.setEnabled(true);
List<ImportValidationFeedback> feedback = rule.verifyRule(jobMeta);
assertTrue("We didn't get any feedback from the 'job has job log table configured'", !feedback.isEmpty());
assertTrue("An error ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
logTable.setTableName("SCHEMA");
logTable.setTableName("LOGTABLE");
logTable.setConnectionName(logDbMeta.getName());
feedback = rule.verifyRule(jobMeta);
assertTrue("We didn't get any feedback from the 'job has description rule'", !feedback.isEmpty());
assertTrue("An approval ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.APPROVAL);
// Make the rules stricter!
//
rule.setTableName("SCHEMA");
rule.setTableName("LOGTABLE");
rule.setConnectionName(logDbMeta.getName());
feedback = rule.verifyRule(jobMeta);
assertTrue("We didn't get any feedback from the 'job has description rule'", !feedback.isEmpty());
assertTrue("An approval ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.APPROVAL);
// Break the rule
//
rule.setSchemaName("INCORRECT_SCHEMA");
rule.setTableName("LOGTABLE");
rule.setConnectionName(logDbMeta.getName());
feedback = rule.verifyRule(jobMeta);
assertTrue("We didn't get any feedback from the 'job has description rule'", !feedback.isEmpty());
assertTrue("An error ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
rule.setSchemaName("SCHEMA");
rule.setTableName("INCORRECT_LOGTABLE");
rule.setConnectionName(logDbMeta.getName());
feedback = rule.verifyRule(jobMeta);
assertTrue("We didn't get any feedback from the 'job has description rule'", !feedback.isEmpty());
assertTrue("An error ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
rule.setSchemaName("SCHEMA");
rule.setTableName("LOGTABLE");
rule.setConnectionName("INCORRECT_DATABASE");
feedback = rule.verifyRule(jobMeta);
assertTrue("We didn't get any feedback from the 'job has description rule'", !feedback.isEmpty());
assertTrue("An error ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
// No feedback expected!
//
rule.setEnabled(false);
feedback = rule.verifyRule(jobMeta);
assertTrue("We didn't expect any feedback from the 'job has job log table configured' since the rule is not enabled", feedback.isEmpty());
}
Aggregations