Search in sources :

Example 1 with TagDefinition

use of org.killbill.billing.util.tag.TagDefinition 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();
}
Also used : TagDefinition(org.killbill.billing.util.tag.TagDefinition) TenantContext(org.killbill.billing.util.callcontext.TenantContext) TagDefinitionJson(org.killbill.billing.jaxrs.json.TagDefinitionJson) AuditLog(org.killbill.billing.util.audit.AuditLog) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with TagDefinition

use of org.killbill.billing.util.tag.TagDefinition in project killbill by killbill.

the class TestTagEventBuilder method testNewUserTagCreationEvent.

@Test(groups = "fast")
public void testNewUserTagCreationEvent() throws Exception {
    final UUID tagId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = internalCallContext.getUserToken();
    final TagEventBuilder tagEventBuilder = new TagEventBuilder();
    final TagInternalEvent event = tagEventBuilder.newUserTagCreationEvent(tagId, objectId, objectType, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
    Assert.assertTrue(event instanceof UserTagCreationInternalEvent);
    Assert.assertEquals(event, new DefaultUserTagCreationEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(new DefaultUserTagCreationEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID())));
    verifyTagEvent(tagId, objectId, objectType, tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}
Also used : ObjectType(org.killbill.billing.ObjectType) TagDefinition(org.killbill.billing.util.tag.TagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) TagDefinitionModelDao(org.killbill.billing.util.tag.dao.TagDefinitionModelDao) UserTagCreationInternalEvent(org.killbill.billing.events.UserTagCreationInternalEvent) UUID(java.util.UUID) TagInternalEvent(org.killbill.billing.events.TagInternalEvent) Test(org.testng.annotations.Test)

Example 3 with TagDefinition

use of org.killbill.billing.util.tag.TagDefinition in project killbill by killbill.

the class TestTagEventBuilder method testNewUserTagDeletionEvent.

@Test(groups = "fast")
public void testNewUserTagDeletionEvent() throws Exception {
    final UUID tagId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = internalCallContext.getUserToken();
    final TagEventBuilder tagEventBuilder = new TagEventBuilder();
    final TagInternalEvent event = tagEventBuilder.newUserTagDeletionEvent(tagId, objectId, objectType, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
    Assert.assertTrue(event instanceof UserTagDeletionInternalEvent);
    Assert.assertEquals(event, new DefaultUserTagDeletionEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(new DefaultUserTagDeletionEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID())));
    verifyTagEvent(tagId, objectId, objectType, tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}
Also used : ObjectType(org.killbill.billing.ObjectType) TagDefinition(org.killbill.billing.util.tag.TagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) UserTagDeletionInternalEvent(org.killbill.billing.events.UserTagDeletionInternalEvent) TagDefinitionModelDao(org.killbill.billing.util.tag.dao.TagDefinitionModelDao) UUID(java.util.UUID) TagInternalEvent(org.killbill.billing.events.TagInternalEvent) Test(org.testng.annotations.Test)

Example 4 with TagDefinition

use of org.killbill.billing.util.tag.TagDefinition in project killbill by killbill.

the class TestTagEventBuilder method testNewUserTagDefinitionCreationEvent.

@Test(groups = "fast")
public void testNewUserTagDefinitionCreationEvent() throws Exception {
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = internalCallContext.getUserToken();
    final TagEventBuilder tagEventBuilder = new TagEventBuilder();
    final TagDefinitionInternalEvent event = tagEventBuilder.newUserTagDefinitionCreationEvent(tagDefinitionId, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
    Assert.assertTrue(event instanceof UserTagDefinitionCreationInternalEvent);
    Assert.assertEquals(event, new DefaultUserTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(new DefaultUserTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID())));
    verifyTagDefinitionEvent(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}
Also used : TagDefinition(org.killbill.billing.util.tag.TagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) TagDefinitionInternalEvent(org.killbill.billing.events.TagDefinitionInternalEvent) TagDefinitionModelDao(org.killbill.billing.util.tag.dao.TagDefinitionModelDao) UUID(java.util.UUID) UserTagDefinitionCreationInternalEvent(org.killbill.billing.events.UserTagDefinitionCreationInternalEvent) Test(org.testng.annotations.Test)

Example 5 with TagDefinition

use of org.killbill.billing.util.tag.TagDefinition in project killbill by killbill.

the class TestTagEventBuilder method testNewControlTagCreationEvent.

@Test(groups = "fast")
public void testNewControlTagCreationEvent() throws Exception {
    final UUID tagId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
    final UUID tagDefinitionId = ControlTagType.AUTO_PAY_OFF.getId();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = true;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = internalCallContext.getUserToken();
    final TagEventBuilder tagEventBuilder = new TagEventBuilder();
    final TagInternalEvent event = tagEventBuilder.newControlTagCreationEvent(tagId, objectId, objectType, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
    Assert.assertTrue(event instanceof ControlTagCreationInternalEvent);
    Assert.assertEquals(event, new DefaultControlTagCreationEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(new DefaultControlTagCreationEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID())));
    verifyTagEvent(tagId, objectId, objectType, tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}
Also used : ObjectType(org.killbill.billing.ObjectType) TagDefinition(org.killbill.billing.util.tag.TagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) TagDefinitionModelDao(org.killbill.billing.util.tag.dao.TagDefinitionModelDao) UUID(java.util.UUID) TagInternalEvent(org.killbill.billing.events.TagInternalEvent) ControlTagCreationInternalEvent(org.killbill.billing.events.ControlTagCreationInternalEvent) Test(org.testng.annotations.Test)

Aggregations

TagDefinition (org.killbill.billing.util.tag.TagDefinition)33 UUID (java.util.UUID)27 Test (org.testng.annotations.Test)26 DefaultTagDefinition (org.killbill.billing.util.tag.DefaultTagDefinition)24 ObjectType (org.killbill.billing.ObjectType)12 TagDefinitionModelDao (org.killbill.billing.util.tag.dao.TagDefinitionModelDao)9 ObjectMapper (org.killbill.billing.util.jackson.ObjectMapper)8 ApiOperation (io.swagger.annotations.ApiOperation)6 ApiResponses (io.swagger.annotations.ApiResponses)6 Produces (javax.ws.rs.Produces)6 TimedResource (org.killbill.commons.metrics.TimedResource)6 GET (javax.ws.rs.GET)5 TenantContext (org.killbill.billing.util.callcontext.TenantContext)5 Path (javax.ws.rs.Path)4 TagDefinitionInternalEvent (org.killbill.billing.events.TagDefinitionInternalEvent)4 TagInternalEvent (org.killbill.billing.events.TagInternalEvent)4 AuditLog (org.killbill.billing.util.audit.AuditLog)4 Tag (org.killbill.billing.util.tag.Tag)4 HashMap (java.util.HashMap)3 TagDefinitionJson (org.killbill.billing.jaxrs.json.TagDefinitionJson)3