killbill-memoizeit

util: add system tag definition support to tag search Signed-off-by:

1/29/2014 2:43:39 PM

Details

pom.xml 2(+1 -1)

diff --git a/pom.xml b/pom.xml
index 3d6021d..54045ea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@
     <parent>
         <artifactId>killbill-oss-parent</artifactId>
         <groupId>com.ning.billing</groupId>
-        <version>0.5.21</version>
+        <version>0.5.22</version>
     </parent>
     <artifactId>killbill</artifactId>
     <version>0.8.11-SNAPSHOT</version>
diff --git a/server/src/test/java/com/ning/billing/jaxrs/TestTag.java b/server/src/test/java/com/ning/billing/jaxrs/TestTag.java
index 3ea5658..50f0b4c 100644
--- a/server/src/test/java/com/ning/billing/jaxrs/TestTag.java
+++ b/server/src/test/java/com/ning/billing/jaxrs/TestTag.java
@@ -30,6 +30,8 @@ import com.ning.billing.client.model.Account;
 import com.ning.billing.client.model.Tag;
 import com.ning.billing.client.model.TagDefinition;
 import com.ning.billing.client.model.Tags;
+import com.ning.billing.util.tag.ControlTag;
+import com.ning.billing.util.tag.ControlTagType;
 
 import com.google.common.collect.ImmutableList;
 
@@ -92,6 +94,22 @@ public class TestTag extends TestJaxrsBase {
         assertEquals(objFromJson.size(), 3 + sizeSystemTag);
     }
 
+    @Test(groups = "slow", description = "Can search system tags")
+    public void testSystemTagsPagination() throws Exception {
+        final Account account = createAccount();
+        for (final ControlTagType controlTagType : ControlTagType.values()) {
+            killBillClient.createAccountTag(account.getAccountId(), controlTagType.getId(), createdBy, reason, comment);
+        }
+
+        final Tags allTags = killBillClient.getTags();
+        Assert.assertEquals(allTags.size(), ControlTagType.values().length);
+
+        for (final ControlTagType controlTagType : ControlTagType.values()) {
+            Assert.assertEquals(killBillClient.searchTags(controlTagType.toString()).size(), 1);
+            Assert.assertEquals(killBillClient.searchTags(controlTagType.getDescription()).size(), 1);
+        }
+    }
+
     @Test(groups = "slow", description = "Can paginate through all tags")
     public void testTagsPagination() throws Exception {
         final Account account = createAccount();
diff --git a/util/src/main/resources/com/ning/billing/util/tag/dao/TagSqlDao.sql.stg b/util/src/main/resources/com/ning/billing/util/tag/dao/TagSqlDao.sql.stg
index 5bad309..8dbc6dc 100644
--- a/util/src/main/resources/com/ning/billing/util/tag/dao/TagSqlDao.sql.stg
+++ b/util/src/main/resources/com/ning/billing/util/tag/dao/TagSqlDao.sql.stg
@@ -62,7 +62,48 @@ searchTags() ::= <<
 select SQL_CALC_FOUND_ROWS
 <allTableFields("t.")>
 from <tableName()> t
-join tag_definitions td on td.id = t.tag_definition_id
+join (
+  select
+    id
+  , name
+  , description
+  from tag_definitions
+  union
+  select
+    \'00000000-0000-0000-0000-000000000001\' id
+  , \'AUTO_PAY_OFF\' name
+  , \'Suspends payments until removed.\' description
+  union
+  select
+    \'00000000-0000-0000-0000-000000000001\' id
+  , \'AUTO_INVOICING_OFF\' name
+  , \'Suspends invoicing until removed.\' description
+  union
+  select
+    \'00000000-0000-0000-0000-000000000003\' id
+  , \'OVERDUE_ENFORCEMENT_OFF\' name
+  , \'Suspends overdue enforcement behaviour until removed.\' description
+  union
+  select
+    \'00000000-0000-0000-0000-000000000004\' id
+  , \'WRITTEN_OFF\' name
+  , \'Indicates that an invoice is written off. No billing or payment effect.\' description
+  union
+  select
+    \'00000000-0000-0000-0000-000000000005\' id
+  , \'MANUAL_PAY\' name
+  , \'Indicates that Killbill doesn\\\\\'t process payments for that account (external payments only)\' description
+  union
+  select
+    \'00000000-0000-0000-0000-000000000006\' id
+  , \'TEST\' name
+  , \'Indicates that this is a test account\' description
+  union
+  select
+    \'00000000-0000-0000-0000-000000000007\' id
+  , \'PARTNER\' name
+  , \'Indicates that this is a partner account\' description
+) td on td.id = t.tag_definition_id
 where 1 = 1
 and (
      <idField("t.")> = :searchKey