protected Collection<Tag> getTagsForAccount(final UUID accountId, final TenantContext context) throws OSGIServiceNotAvailable { final TagUserApi tagUserApi = getTagUserApi(); return tagUserApi.getTagsForAccount(accountId, false, context); }
@TimedResource @GET @Path("/{accountId:" + UUID_PATTERN + "}/" + ALL_TAGS) @Produces(APPLICATION_JSON) @ApiOperation(value = "Retrieve account tags", response = TagJson.class, responseContainer = "List") @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid account id supplied"), @ApiResponse(code = 404, message = "Account not found")}) public Response getAllTags(@PathParam(ID_PARAM_NAME) final UUID accountId, @QueryParam(QUERY_OBJECT_TYPE) final ObjectType objectType, @QueryParam(QUERY_INCLUDED_DELETED) @DefaultValue("false") final Boolean includedDeleted, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws TagDefinitionApiException { final TenantContext tenantContext = context.createTenantContextWithAccountId(accountId, request); final List<Tag> tags = objectType != null ? tagUserApi.getTagsForAccountType(accountId, objectType, includedDeleted, tenantContext) : tagUserApi.getTagsForAccount(accountId, includedDeleted, tenantContext); return createTagResponse(accountId, tags, auditMode, tenantContext); }
@Test(groups = "slow") public void testApiTagOnAccount() throws Exception { busHandler.pushExpectedEvents(NextEvent.TAG); tagUserApi.addTag(account.getId(), ObjectType.ACCOUNT, ControlTagType.AUTO_INVOICING_OFF.getId(), callContext); assertListenerStatus(); busHandler.pushExpectedEvents(NextEvent.TAG); tagUserApi.addTag(account.getId(), ObjectType.ACCOUNT, ControlTagType.AUTO_PAY_OFF.getId(), callContext); assertListenerStatus(); List<Tag> tags = tagUserApi.getTagsForAccount(account.getId(), false, callContext); Assert.assertEquals(tags.size(), 2); checkTagsExists(tags); tags = tagUserApi.getTagsForObject(account.getId(), ObjectType.ACCOUNT, false, callContext); Assert.assertEquals(tags.size(), 2); checkTagsExists(tags); tags = tagUserApi.getTagsForAccountType(account.getId(), ObjectType.ACCOUNT, false, callContext); Assert.assertEquals(tags.size(), 2); checkTagsExists(tags); }
Assert.assertTrue(tagUserApi.getTagsForAccount(accountId, true, callContext).isEmpty()); Assert.assertTrue(tagUserApi.getTagsForAccount(accountId, true, callContext).isEmpty()); final List<Tag> tags = tagUserApi.getTagsForAccount(accountId, false, callContext); Assert.assertEquals(tags.size(), 1); Assert.assertEquals(tags.get(0).getTagDefinitionId(), SystemTags.PARK_TAG_DEFINITION_ID); Assert.assertEquals(tagUserApi.getTagsForAccount(accountId, false, callContext), tags); Assert.assertEquals(invoiceDao.getInvoicesByAccount(false, context).size(), 0); Assert.assertEquals(tagUserApi.getTagsForAccount(accountId, false, callContext).size(), 1); Assert.assertEquals(invoiceDao.getInvoicesByAccount(false, context).size(), 1); Assert.assertEquals(tagUserApi.getTagsForAccount(accountId, false, callContext).size(), 0); Assert.assertEquals(tagUserApi.getTagsForAccount(accountId, true, callContext).size(), 1);
assertListenerStatus(); List<Tag> tags = tagUserApi.getTagsForAccount(account.getId(), false, callContext); Assert.assertEquals(tags.size(), 2); checkTagsExists(tags); assertListenerStatus(); tags = tagUserApi.getTagsForAccount(account.getId(), false, callContext); Assert.assertEquals(tags.size(), 3); checkTagsExists(tags);