use of org.killbill.billing.util.audit.AuditLog in project killbill by killbill.
the class TestAccountDao method testAddRemoveAccountEmail.
@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);
}
use of org.killbill.billing.util.audit.AuditLog in project killbill by killbill.
the class TagDefinitionResource method getTagDefinitions.
@TimedResource
@GET
@Produces(APPLICATION_JSON)
@ApiOperation(value = "List tag definitions", response = TagDefinitionJson.class, responseContainer = "List")
@ApiResponses(value = {})
public Response getTagDefinitions(@javax.ws.rs.core.Context final HttpServletRequest request, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode) {
final TenantContext tenantContext = context.createContext(request);
final List<TagDefinition> tagDefinitions = tagUserApi.getTagDefinitions(tenantContext);
final Collection<TagDefinitionJson> result = new LinkedList<TagDefinitionJson>();
for (final TagDefinition tagDefinition : tagDefinitions) {
final List<AuditLog> auditLogs = auditUserApi.getAuditLogs(tagDefinition.getId(), ObjectType.TAG_DEFINITION, auditMode.getLevel(), tenantContext);
result.add(new TagDefinitionJson(tagDefinition, auditLogs));
}
return Response.status(Status.OK).entity(result).build();
}
use of org.killbill.billing.util.audit.AuditLog in project killbill by killbill.
the class TagDefinitionResource method getTagDefinition.
@TimedResource
@GET
@Path("/{tagDefinitionId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve a tag definition", response = TagDefinitionJson.class)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid tagDefinitionId supplied") })
public Response getTagDefinition(@PathParam("tagDefinitionId") final String tagDefId, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws TagDefinitionApiException {
final TenantContext tenantContext = context.createContext(request);
final TagDefinition tagDefinition = tagUserApi.getTagDefinition(UUID.fromString(tagDefId), tenantContext);
final List<AuditLog> auditLogs = auditUserApi.getAuditLogs(tagDefinition.getId(), ObjectType.TAG_DEFINITION, auditMode.getLevel(), tenantContext);
final TagDefinitionJson json = new TagDefinitionJson(tagDefinition, auditLogs);
return Response.status(Status.OK).entity(json).build();
}
use of org.killbill.billing.util.audit.AuditLog in project killbill by killbill.
the class JaxRsResourceBase method getCustomFields.
protected Response getCustomFields(final UUID id, final AuditMode auditMode, final TenantContext context) {
final List<CustomField> fields = customFieldUserApi.getCustomFieldsForObject(id, getObjectType(), context);
final List<CustomFieldJson> result = new LinkedList<CustomFieldJson>();
for (final CustomField cur : fields) {
// TODO PIERRE - Bulk API
final List<AuditLog> auditLogs = auditUserApi.getAuditLogs(cur.getId(), ObjectType.CUSTOM_FIELD, auditMode.getLevel(), context);
result.add(new CustomFieldJson(cur, auditLogs));
}
return Response.status(Response.Status.OK).entity(result).build();
}
use of org.killbill.billing.util.audit.AuditLog in project killbill by killbill.
the class TestDefaultAuditDao method testRetrieveAuditsDirectly.
@Test(groups = "slow")
public void testRetrieveAuditsDirectly() throws Exception {
addTag();
// Verify we get an audit entry for the tag_history table
final Handle handle = dbi.open();
final String tagHistoryString = (String) handle.select("select id from tag_history limit 1").get(0).get("id");
handle.close();
for (final AuditLevel level : AuditLevel.values()) {
final List<AuditLog> auditLogs = auditDao.getAuditLogsForId(TableName.TAG_HISTORY, UUID.fromString(tagHistoryString), level, internalCallContext);
verifyAuditLogsForTag(auditLogs, level);
}
}
Aggregations