Search in sources :

Example 1 with MessageTypes

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();
}
Also used : SimpleContentItem(org.pentaho.platform.engine.core.output.SimpleContentItem) AuditHelper(org.pentaho.platform.engine.core.audit.AuditHelper) AuditEntry(org.pentaho.platform.engine.core.audit.AuditEntry) NullAuditEntry(org.pentaho.platform.engine.core.audit.NullAuditEntry) IAuditEntry(org.pentaho.platform.api.engine.IAuditEntry) StandaloneObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory) MessageTypes(org.pentaho.platform.engine.core.audit.MessageTypes) IAuditEntry(org.pentaho.platform.api.engine.IAuditEntry) BigDecimal(java.math.BigDecimal)

Aggregations

BigDecimal (java.math.BigDecimal)1 IAuditEntry (org.pentaho.platform.api.engine.IAuditEntry)1 AuditEntry (org.pentaho.platform.engine.core.audit.AuditEntry)1 AuditHelper (org.pentaho.platform.engine.core.audit.AuditHelper)1 MessageTypes (org.pentaho.platform.engine.core.audit.MessageTypes)1 NullAuditEntry (org.pentaho.platform.engine.core.audit.NullAuditEntry)1 SimpleContentItem (org.pentaho.platform.engine.core.output.SimpleContentItem)1 StandaloneObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory)1