use of org.pentaho.platform.engine.core.audit.MessageTypes in project pentaho-platform by pentaho.
the class AuditEntryTest method testAuditEntry.
public void testAuditEntry() throws Exception {
StandaloneObjectFactory factory = new StandaloneObjectFactory();
PentahoSystem.registerObjectFactory(factory);
String jobId = "testjobid";
String instId = "testinstid";
String objId = "testobjid";
String objType = "testobjtype";
String actor = "testactor";
String messageType = "testtype";
String messageName = "testname";
String messageTxtValue = MessageTypes.INSTANCE_END;
BigDecimal messageNumValue = new BigDecimal(99);
float duration = (float) 1.23;
// this should not complain
AuditEntry.auditJobDuration(jobId, instId, objId, objType, actor, messageType, messageName, messageTxtValue, duration);
TestOutputHandler.contentItem = new SimpleContentItem();
factory.defineObject(IAuditEntry.class.getSimpleName(), TestAuditEntry.class.getName(), StandaloneObjectFactory.Scope.GLOBAL);
// this should not complain
AuditEntry.auditJobDuration(jobId, instId, objId, objType, actor, messageType, messageName, messageTxtValue, duration);
TestAuditEntry entry = (TestAuditEntry) factory.get(IAuditEntry.class, null);
assertEquals(jobId, entry.jobId);
assertEquals("1.23", Double.toString(entry.duration).substring(0, 4));
assertEquals(null, entry.messageNumValue);
assertEquals(messageType, entry.messageType);
assertEquals(messageName, entry.messageName);
assertEquals(messageTxtValue, entry.messageTxtValue);
AuditEntry.auditJobNumValue(jobId, instId, objId, objType, actor, messageType, messageName, messageNumValue);
assertEquals("0", Double.toString(entry.duration).substring(0, 1));
assertEquals(messageNumValue, entry.messageNumValue);
assertEquals(null, entry.messageTxtValue);
AuditEntry.auditJobTxtValue(jobId, instId, objId, objType, actor, messageType, messageName, messageTxtValue);
assertEquals("0", Double.toString(entry.duration).substring(0, 1));
assertEquals(null, entry.messageNumValue);
assertEquals(messageTxtValue, entry.messageTxtValue);
new MessageTypes();
new AuditHelper();
new AuditEntry();
}
Aggregations