Codota Logo
AuditLog
Code IndexAdd Codota to your IDE (free)

How to use
AuditLog
in
org.killbill.billing.util.audit

Best Java code snippets using org.killbill.billing.util.audit.AuditLog (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: killbill/killbill

  protected AuditLog createAuditLog() {
    final AuditLog auditLog = Mockito.mock(AuditLog.class);
    final DateTime utcNow = clock.getUTCNow();
    Mockito.when(auditLog.getCreatedDate()).thenReturn(utcNow);
    Mockito.when(auditLog.getReasonCode()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(auditLog.getUserName()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(auditLog.getUserToken()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(auditLog.getComment()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(auditLog.getChangeType()).thenReturn(ChangeType.DELETE);

    return auditLog;
  }
}
origin: killbill/killbill

  @Override
  public boolean apply(final AuditLog auditLog) {
    // As we consume the data source, cache the entries
    cacheAuditLog(auditLog);
    return objectId.equals(auditLog.getAuditedEntityId()) &&
       // Given our ordering, this should always be true for the first entry
       ChangeType.INSERT.equals(auditLog.getChangeType());
  }
}).orNull();
origin: killbill/killbill

  @Override
  public boolean apply(final AuditLog auditLog) {
    return objectType.equals(auditLog.getAuditedObjectType());
  }
};
origin: org.kill-bill.billing/killbill-jaxrs

public AuditLogJson(final AuditLog auditLog) {
  this(auditLog.getChangeType().toString(), auditLog.getCreatedDate(), auditLog.getAuditedObjectType(), auditLog.getAuditedEntityId(), auditLog.getUserName(), auditLog.getReasonCode(),
     auditLog.getComment(), auditLog.getUserToken(), null);
}
origin: killbill/killbill

  private List<AuditLog> filterAuditLogs(final AuditLevel auditLevel, final List<AuditLog> auditLogs) {
    // TODO Do the filtering in the query
    if (AuditLevel.FULL.equals(auditLevel)) {
      return auditLogs;
    } else if (AuditLevel.MINIMAL.equals(auditLevel) && !auditLogs.isEmpty()) {
      if (ChangeType.INSERT.equals(auditLogs.get(0).getChangeType())) {
        return ImmutableList.<AuditLog>of(auditLogs.get(0));
      } else {
        // We may be coming here via the history code path - only a single mapped history record id
        // will be for the initial INSERT
        return ImmutableList.<AuditLog>of();
      }
    } else if (AuditLevel.NONE.equals(auditLevel)) {
      return ImmutableList.<AuditLog>of();
    } else {
      return auditLogs;
    }
  }
}
origin: org.kill-bill.billing/killbill-beatrix

private <T extends EntitySqlDao<M, E>, M extends EntityModelDao<E>, E extends Entity> void checkAuditLog(final ChangeType changeType, @Nullable final CallContext context, final AuditLog auditLog, final UUID entityId, Class<T> sqlDao,
                                                     boolean useHistory, boolean checkContext) {
  Assert.assertEquals(auditLog.getChangeType(), changeType);
  if (checkContext) {
    Assert.assertEquals(auditLog.getUserName(), context.getUserName());
    Assert.assertEquals(auditLog.getComment(), context.getComments());
    //Assert.assertEquals(auditLog.getCreatedDate().comparesTo(callcontext.getCreatedDate()));
    // We can't take userToken oustide of the 'if' because for instance NextBillingDate invoice will not have it.
    Assert.assertEquals(auditLog.getUserToken(), context.getUserToken().toString());
  }
  final M entityModel = extractEntityModelFromEntityWithTargetRecordId(entityId, auditLog.getId(), sqlDao, context, useHistory);
  Assert.assertEquals(entityModel.getId(), entityId);
}
origin: killbill/killbill

private void cacheAuditLog(final AuditLog auditLog) {
  initializeIfNeeded(auditLog.getAuditedEntityId());
  auditLogsCache.get(auditLog.getAuditedEntityId()).add(auditLog);
}
origin: killbill/killbill

@Test(groups = "slow")
public void testVerifyAuditCachesAreCleared() throws Exception {
  addTag();
  final List<AuditLog> firstAuditLogs = auditDao.getAuditLogsForId(TableName.TAG, tag.getId(), AuditLevel.FULL, internalCallContext);
  Assert.assertEquals(firstAuditLogs.size(), 1);
  Assert.assertEquals(firstAuditLogs.get(0).getChangeType(), ChangeType.INSERT);
  eventsListener.pushExpectedEvent(NextEvent.TAG);
  tagDao.deleteTag(tag.getObjectId(), tag.getObjectType(), tag.getTagDefinitionId(), internalCallContext);
  assertListenerStatus();
  final List<AuditLog> secondAuditLogs = auditDao.getAuditLogsForId(TableName.TAG, tag.getId(), AuditLevel.FULL, internalCallContext);
  Assert.assertEquals(secondAuditLogs.size(), 2);
  Assert.assertEquals(secondAuditLogs.get(0).getChangeType(), ChangeType.INSERT);
  Assert.assertEquals(secondAuditLogs.get(1).getChangeType(), ChangeType.DELETE);
}
origin: org.kill-bill.billing/killbill-util

private void cacheAuditLog(final AuditLog auditLog) {
  initializeIfNeeded(auditLog.getAuditedEntityId());
  auditLogsCache.get(auditLog.getAuditedEntityId()).add(auditLog);
}
origin: killbill/killbill

  private void verifyAuditLogsForTag(final List<AuditLog> auditLogs, final AuditLevel level) {
    if (AuditLevel.NONE.equals(level)) {
      Assert.assertEquals(auditLogs.size(), 0);
      return;
    }

    Assert.assertEquals(auditLogs.size(), 1);
    Assert.assertEquals(auditLogs.get(0).getUserToken(), internalCallContext.getUserToken().toString());
    Assert.assertEquals(auditLogs.get(0).getChangeType(), ChangeType.INSERT);
    Assert.assertEquals(auditLogs.get(0).getComment(), internalCallContext.getComments());
    Assert.assertEquals(auditLogs.get(0).getReasonCode(), internalCallContext.getReasonCode());
    Assert.assertEquals(auditLogs.get(0).getUserName(), internalCallContext.getCreatedBy());
    Assert.assertNotNull(auditLogs.get(0).getCreatedDate());
  }
}
origin: killbill/killbill

@Test(groups = "slow", description = "Test Account DAO: add and remove email")
public void testAddRemoveAccountEmail() throws AccountApiException {
  final UUID accountId = UUID.randomUUID();
  // Add a new e-mail
  final AccountEmail email = new DefaultAccountEmail(accountId, "test@gmail.com");
  accountDao.addEmail(new AccountEmailModelDao(email), internalCallContext);
  final List<AccountEmailModelDao> accountEmails = accountDao.getEmailsByAccountId(accountId, internalCallContext);
  Assert.assertEquals(accountEmails.size(), 1);
  Assert.assertEquals(accountEmails.get(0).getAccountId(), accountId);
  Assert.assertEquals(accountEmails.get(0).getEmail(), email.getEmail());
  // Verify audits
  final List<AuditLog> auditLogsForAccountEmail = auditDao.getAuditLogsForId(TableName.ACCOUNT_EMAIL, email.getId(), AuditLevel.FULL, internalCallContext);
  Assert.assertEquals(auditLogsForAccountEmail.size(), 1);
  Assert.assertEquals(auditLogsForAccountEmail.get(0).getChangeType(), ChangeType.INSERT);
  // Delete the e-mail
  accountDao.removeEmail(new AccountEmailModelDao(email), internalCallContext);
  Assert.assertEquals(accountDao.getEmailsByAccountId(accountId, internalCallContext).size(), 0);
}
origin: org.kill-bill.billing/killbill-util

  @Override
  public boolean apply(final AuditLog auditLog) {
    // As we consume the data source, cache the entries
    cacheAuditLog(auditLog);
    return objectId.equals(auditLog.getAuditedEntityId()) &&
       // Given our ordering, this should always be true for the first entry
       ChangeType.INSERT.equals(auditLog.getChangeType());
  }
}).orNull();
origin: org.kill-bill.billing/killbill-util

  @Override
  public boolean apply(final AuditLog auditLog) {
    return objectType.equals(auditLog.getAuditedObjectType());
  }
};
origin: killbill/killbill

@Test(groups = "fast")
public void testGetters() throws Exception {
  final TableName tableName = TableName.ACCOUNT_EMAIL_HISTORY;
  final long recordId = Long.MAX_VALUE;
  final ChangeType changeType = ChangeType.DELETE;
  final EntityAudit entityAudit = new EntityAudit(tableName, recordId, changeType, null);
  final UUID accountId = UUID.randomUUID();
  final UUID tenantId = UUID.randomUUID();
  final String userName = UUID.randomUUID().toString();
  final CallOrigin callOrigin = CallOrigin.EXTERNAL;
  final UserType userType = UserType.CUSTOMER;
  final UUID userToken = UUID.randomUUID();
  final DefaultCallContext callContext = new DefaultCallContext(accountId, tenantId, userName, callOrigin, userType, userToken, clock);
  final AuditLog auditLog = new DefaultAuditLog(new AuditLogModelDao(entityAudit, callContext), ObjectType.ACCOUNT_EMAIL, UUID.randomUUID());
  Assert.assertEquals(auditLog.getChangeType(), changeType);
  Assert.assertNull(auditLog.getComment());
  Assert.assertNotNull(auditLog.getCreatedDate());
  Assert.assertNull(auditLog.getReasonCode());
  Assert.assertEquals(auditLog.getUserName(), userName);
  Assert.assertEquals(auditLog.getUserToken(), userToken.toString());
}
origin: killbill/killbill

Assert.assertEquals(auditLogsForAccountEmail1.get(0).getChangeType(), ChangeType.INSERT);
Assert.assertEquals(auditLogsForAccountEmail1.get(1).getChangeType(), ChangeType.DELETE);
final List<AuditLog> auditLogsForAccountEmail2 = auditDao.getAuditLogsForId(TableName.ACCOUNT_EMAIL, accountEmail2.getId(), AuditLevel.FULL, internalCallContext);
Assert.assertEquals(auditLogsForAccountEmail2.size(), 1);
Assert.assertEquals(auditLogsForAccountEmail2.get(0).getChangeType(), ChangeType.INSERT);
origin: org.kill-bill.billing/killbill-util

  protected AuditLog createAuditLog() {
    final AuditLog auditLog = Mockito.mock(AuditLog.class);
    final DateTime utcNow = clock.getUTCNow();
    Mockito.when(auditLog.getCreatedDate()).thenReturn(utcNow);
    Mockito.when(auditLog.getReasonCode()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(auditLog.getUserName()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(auditLog.getUserToken()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(auditLog.getComment()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(auditLog.getChangeType()).thenReturn(ChangeType.DELETE);

    return auditLog;
  }
}
origin: killbill/killbill

@Test(groups = "slow", description = "Test Account: verify audits")
public void testAudits() throws AccountApiException {
  // Special test to verify audits - they are handled a bit differently due to the account record id (see EntitySqlDaoWrapperInvocationHandler#insertAudits)
  final AccountModelDao account1 = createTestAccount();
  accountDao.create(account1, internalCallContext);
  refreshCallContext(account1.getId());
  // Verify audits via account record id
  final DefaultAccountAuditLogs auditLogsForAccount1ViaAccountRecordId1 = auditDao.getAuditLogsForAccountRecordId(AuditLevel.FULL, internalCallContext);
  Assert.assertEquals(auditLogsForAccount1ViaAccountRecordId1.getAuditLogsForAccount().size(), 1);
  Assert.assertEquals(auditLogsForAccount1ViaAccountRecordId1.getAuditLogsForAccount().get(0).getChangeType(), ChangeType.INSERT);
  // Add an entry in the account_history table to make sure we pick up the right
  // record id / target record id / account record id in the audit_log table
  accountDao.updatePaymentMethod(account1.getId(), UUID.randomUUID(), internalCallContext);
  final AccountModelDao account2 = createTestAccount();
  accountDao.create(account2, internalCallContext);
  refreshCallContext(account2.getId());
  // Verify audits via account record id
  final DefaultAccountAuditLogs auditLogsForAccount2ViaAccountRecordId = auditDao.getAuditLogsForAccountRecordId(AuditLevel.FULL, internalCallContext);
  Assert.assertEquals(auditLogsForAccount2ViaAccountRecordId.getAuditLogsForAccount().size(), 1);
  Assert.assertEquals(auditLogsForAccount2ViaAccountRecordId.getAuditLogsForAccount().get(0).getChangeType(), ChangeType.INSERT);
  refreshCallContext(account1.getId());
  final DefaultAccountAuditLogs auditLogsForAccount1ViaAccountRecordId2 = auditDao.getAuditLogsForAccountRecordId(AuditLevel.FULL, internalCallContext);
  Assert.assertEquals(auditLogsForAccount1ViaAccountRecordId2.getAuditLogsForAccount().size(), 2);
  Assert.assertEquals(auditLogsForAccount1ViaAccountRecordId2.getAuditLogsForAccount().get(0).getChangeType(), ChangeType.INSERT);
  Assert.assertEquals(auditLogsForAccount1ViaAccountRecordId2.getAuditLogsForAccount().get(1).getChangeType(), ChangeType.UPDATE);
}
origin: org.kill-bill.billing/killbill-util

  private void verifyAuditLogsForTag(final List<AuditLog> auditLogs, final AuditLevel level) {
    if (AuditLevel.NONE.equals(level)) {
      Assert.assertEquals(auditLogs.size(), 0);
      return;
    }

    Assert.assertEquals(auditLogs.size(), 1);
    Assert.assertEquals(auditLogs.get(0).getUserToken(), internalCallContext.getUserToken().toString());
    Assert.assertEquals(auditLogs.get(0).getChangeType(), ChangeType.INSERT);
    Assert.assertEquals(auditLogs.get(0).getComment(), internalCallContext.getComments());
    Assert.assertEquals(auditLogs.get(0).getReasonCode(), internalCallContext.getReasonCode());
    Assert.assertEquals(auditLogs.get(0).getUserName(), internalCallContext.getCreatedBy());
    Assert.assertNotNull(auditLogs.get(0).getCreatedDate());
  }
}
origin: killbill/killbill

@Test(groups = "slow", description = "Test Account: basic DAO calls")
public void testBasic() throws AccountApiException {
  final AccountModelDao account = createTestAccount();
  accountDao.create(account, internalCallContext);
  refreshCallContext(account.getId());
  // Retrieve by key
  AccountModelDao retrievedAccount = accountDao.getAccountByKey(account.getExternalKey(), internalCallContext);
  checkAccountsEqual(retrievedAccount, account);
  // Retrieve by id
  retrievedAccount = accountDao.getById(retrievedAccount.getId(), internalCallContext);
  checkAccountsEqual(retrievedAccount, account);
  // Retrieve all
  final Pagination<AccountModelDao> allAccounts = accountDao.getAll(internalCallContext);
  final List<AccountModelDao> all = ImmutableList.<AccountModelDao>copyOf(allAccounts);
  Assert.assertNotNull(all);
  Assert.assertEquals(all.size(), 1);
  checkAccountsEqual(all.get(0), account);
  // Verify audits
  final List<AuditLog> auditLogsForAccount = auditDao.getAuditLogsForId(TableName.ACCOUNT, account.getId(), AuditLevel.FULL, internalCallContext);
  Assert.assertEquals(auditLogsForAccount.size(), 1);
  Assert.assertEquals(auditLogsForAccount.get(0).getChangeType(), ChangeType.INSERT);
}
origin: org.kill-bill.billing/killbill-util

@Test(groups = "fast")
public void testGetters() throws Exception {
  final TableName tableName = TableName.ACCOUNT_EMAIL_HISTORY;
  final long recordId = Long.MAX_VALUE;
  final ChangeType changeType = ChangeType.DELETE;
  final EntityAudit entityAudit = new EntityAudit(tableName, recordId, changeType, null);
  final UUID accountId = UUID.randomUUID();
  final UUID tenantId = UUID.randomUUID();
  final String userName = UUID.randomUUID().toString();
  final CallOrigin callOrigin = CallOrigin.EXTERNAL;
  final UserType userType = UserType.CUSTOMER;
  final UUID userToken = UUID.randomUUID();
  final DefaultCallContext callContext = new DefaultCallContext(accountId, tenantId, userName, callOrigin, userType, userToken, clock);
  final AuditLog auditLog = new DefaultAuditLog(new AuditLogModelDao(entityAudit, callContext), ObjectType.ACCOUNT_EMAIL, UUID.randomUUID());
  Assert.assertEquals(auditLog.getChangeType(), changeType);
  Assert.assertNull(auditLog.getComment());
  Assert.assertNotNull(auditLog.getCreatedDate());
  Assert.assertNull(auditLog.getReasonCode());
  Assert.assertEquals(auditLog.getUserName(), userName);
  Assert.assertEquals(auditLog.getUserToken(), userToken.toString());
}
org.killbill.billing.util.auditAuditLog

Most used methods

  • getChangeType
    Get the type of change for this log entry
  • getComment
    Get the comment for this change
  • getUserName
    Get the name of the requestor
  • getUserToken
    Get the user token of this change requestor
  • getAuditedEntityId
    Get the original Entity id for this log entry
  • getAuditedObjectType
    Get the original Entity object type for this log entry
  • getCreatedDate
    Get the time when this change was effective
  • getReasonCode
    Get the reason code for this change
  • getId

Popular in Java

  • Reading from database using SQL prepared statement
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getExternalFilesDir (Context)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • ObjectMapper (com.fasterxml.jackson.databind)
    This mapper (or, data binder, or codec) provides functionality for converting between Java objects (
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Logger (org.slf4j)
    The main user interface to logging. It is expected that logging takes place through concrete impleme
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now