use of org.pentaho.di.trans.step.StepMetaDataCombi in project pentaho-kettle by pentaho.
the class StepLogTable method getLogRecord.
/**
* This method calculates all the values that are required
*
* @param id
* the id to use or -1 if no id is needed
* @param status
* the log status to use
*/
public RowMetaAndData getLogRecord(LogStatus status, Object subject, Object parent) {
if (subject == null || subject instanceof StepMetaDataCombi) {
StepMetaDataCombi combi = (StepMetaDataCombi) subject;
RowMetaAndData row = new RowMetaAndData();
for (LogTableField field : fields) {
if (field.isEnabled()) {
Object value = null;
if (subject != null) {
switch(ID.valueOf(field.getId())) {
case ID_BATCH:
value = new Long(combi.step.getTrans().getBatchId());
break;
case CHANNEL_ID:
value = combi.step.getLogChannel().getLogChannelId();
break;
case LOG_DATE:
value = new Date();
break;
case TRANSNAME:
value = combi.step.getTrans().getName();
break;
case STEPNAME:
value = combi.stepname;
break;
case STEP_COPY:
value = new Long(combi.copy);
break;
case LINES_READ:
value = new Long(combi.step.getLinesRead());
break;
case LINES_WRITTEN:
value = new Long(combi.step.getLinesWritten());
break;
case LINES_UPDATED:
value = new Long(combi.step.getLinesUpdated());
break;
case LINES_INPUT:
value = new Long(combi.step.getLinesInput());
break;
case LINES_OUTPUT:
value = new Long(combi.step.getLinesOutput());
break;
case LINES_REJECTED:
value = new Long(combi.step.getLinesRejected());
break;
case ERRORS:
value = new Long(combi.step.getErrors());
break;
case LOG_FIELD:
value = getLogBuffer(combi.step, combi.step.getLogChannel().getLogChannelId(), status, null);
break;
default:
break;
}
}
row.addValue(field.getFieldName(), field.getDataType(), value);
row.getRowMeta().getValueMeta(row.size() - 1).setLength(field.getLength());
}
}
return row;
} else {
return null;
}
}
use of org.pentaho.di.trans.step.StepMetaDataCombi in project pentaho-kettle by pentaho.
the class MQTTProducerTest method testFeedbackSize.
@Test
public void testFeedbackSize() throws Exception {
StepMetaDataCombi combi = trans.getSteps().get(1);
MQTTProducer step = (MQTTProducer) combi.step;
when(logChannel.isBasic()).thenReturn(true);
step.getTransMeta().setFeedbackSize(1);
trans.startThreads();
trans.waitUntilFinished();
verify(logChannel).logBasic(eq("Linenr1"));
}
use of org.pentaho.di.trans.step.StepMetaDataCombi in project pentaho-kettle by pentaho.
the class MQTTProducerTest method testMQTTConnectException.
@Test
public void testMQTTConnectException() throws Exception {
StepMetaDataCombi combi = trans.getSteps().get(1);
MQTTProducer step = (MQTTProducer) combi.step;
step.first = true;
PowerMockito.mockStatic(MQTTClientBuilder.class);
MQTTClientBuilder clientBuilder = spy(MQTTClientBuilder.class);
MqttException mqttException = mock(MqttException.class);
when(mqttException.toString()).thenReturn("There was an error connecting");
doThrow(mqttException).when(clientBuilder).buildAndConnect();
PowerMockito.when(MQTTClientBuilder.builder()).thenReturn(clientBuilder);
trans.startThreads();
trans.waitUntilFinished();
verify(logChannel).logError("There was an error connecting");
}
use of org.pentaho.di.trans.step.StepMetaDataCombi in project pentaho-kettle by pentaho.
the class MQTTProducerTest method testInvalidQOS.
@Test
public void testInvalidQOS() throws Exception {
trans.setVariable("qos", "hello");
trans.prepareExecution(new String[] {});
// Need to set first = false again since prepareExecution was called with the new variable.
StepMetaDataCombi combi = trans.getSteps().get(1);
MQTTProducer step = (MQTTProducer) combi.step;
step.first = false;
trans.startThreads();
trans.waitUntilFinished();
verify(logChannel).logError(eq("Unexpected error"), any(KettleStepException.class));
verify(mqttClient, never()).publish(any(), any());
}
use of org.pentaho.di.trans.step.StepMetaDataCombi in project pentaho-kettle by pentaho.
the class MQTTProducerTest method testProcessFirstRow.
@Test
public void testProcessFirstRow() throws Exception {
StepMetaDataCombi combi = trans.getSteps().get(1);
MQTTProducer step = (MQTTProducer) combi.step;
step.first = true;
PowerMockito.mockStatic(MQTTClientBuilder.class);
MQTTClientBuilder clientBuilder = spy(MQTTClientBuilder.class);
MqttClient mqttClient = mock(MqttClient.class);
doReturn(mqttClient).when(clientBuilder).buildAndConnect();
PowerMockito.when(MQTTClientBuilder.builder()).thenReturn(clientBuilder);
trans.startThreads();
trans.waitUntilFinished();
assertFalse(step.first);
}
Aggregations