killbill-memoizeit
Changes
account/pom.xml 13(+11 -2)
entitlement/pom.xml 8(+7 -1)
entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/ISubscriptionSqlDao.java 14(+6 -8)
entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/IBundleSqlDao.sql.stg 41(+41 -0)
entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/IEventSqlDao.sql.stg 195(+195 -0)
Details
account/pom.xml 13(+11 -2)
diff --git a/account/pom.xml b/account/pom.xml
index 46078b3..b5c1e6f 100644
--- a/account/pom.xml
+++ b/account/pom.xml
@@ -8,7 +8,8 @@
OR CONDITIONS OF ANY KIND, either express or implied. See the ~ License for
the specific language governing permissions and limitations ~ under the License. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ning.billing</groupId>
@@ -68,11 +69,19 @@
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>stringtemplate</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
-
</dependencies>
<build>
<plugins>
diff --git a/account/src/main/java/com/ning/billing/account/dao/IAccountDaoSql.java b/account/src/main/java/com/ning/billing/account/dao/IAccountDaoSql.java
index c7068c1..1c032aa 100644
--- a/account/src/main/java/com/ning/billing/account/dao/IAccountDaoSql.java
+++ b/account/src/main/java/com/ning/billing/account/dao/IAccountDaoSql.java
@@ -30,26 +30,27 @@ import org.skife.jdbi.v2.sqlobject.SqlUpdate;
import org.skife.jdbi.v2.sqlobject.customizers.Mapper;
import org.skife.jdbi.v2.sqlobject.mixins.CloseMe;
import org.skife.jdbi.v2.sqlobject.mixins.Transactional;
+import org.skife.jdbi.v2.sqlobject.stringtemplate.ExternalizedSqlViaStringTemplate3;
import org.skife.jdbi.v2.tweak.ResultSetMapper;
import com.ning.billing.account.api.Account;
import com.ning.billing.account.api.IAccount;
-
+@ExternalizedSqlViaStringTemplate3()
public interface IAccountDaoSql extends Transactional<IAccountDaoSql>, CloseMe {
- @SqlUpdate("insert into accounts (id, key_name) values (:id, :key_name)")
+ @SqlUpdate
public void insertAccount(@Bind(binder = IAccountSqlBinder.class) IAccount account);
- @SqlQuery("select id, key_name from accounts where key_name = :key_name")
+ @SqlQuery
@Mapper(IAccountSqlMapper.class)
public IAccount getAccountByKey(@Bind("key_name") String key);
- @SqlQuery("select id, key_name from accounts where id = :id")
+ @SqlQuery
@Mapper(IAccountSqlMapper.class)
public IAccount getAccountFromId(@Bind("id") String id);
- @SqlQuery("select id, key_name from accounts")
+ @SqlQuery
@Mapper(IAccountSqlMapper.class)
public List<IAccount> getAccounts();
diff --git a/account/src/main/resources/com/ning/billing/account/dao/IAccountDaoSql.sql.stg b/account/src/main/resources/com/ning/billing/account/dao/IAccountDaoSql.sql.stg
new file mode 100644
index 0000000..b15fc2d
--- /dev/null
+++ b/account/src/main/resources/com/ning/billing/account/dao/IAccountDaoSql.sql.stg
@@ -0,0 +1,40 @@
+group IAccountDaoSql;
+
+insertAccount() ::= <<
+ insert into accounts (
+ id
+ , key_name
+ ) values (
+ :id
+ , :key_name
+ );
+>>
+
+getAccountByKey(key) ::= <<
+ select
+ id
+ , key_name
+ from accounts
+ where
+ key_name = :key_name
+ ;
+>>
+
+getAccountFromId(id) ::= <<
+ select
+ id
+ , key_name
+ from accounts
+ where
+ id = :id
+ ;
+>>
+
+
+getAccounts() ::= <<
+ select
+ id
+ , key_name
+ from accounts
+ ;
+>>
diff --git a/account/src/test/java/com/ning/billing/account/dao/TestSimpleAccountDao.java b/account/src/test/java/com/ning/billing/account/dao/TestSimpleAccountDao.java
index 20d082f..3feae9d 100644
--- a/account/src/test/java/com/ning/billing/account/dao/TestSimpleAccountDao.java
+++ b/account/src/test/java/com/ning/billing/account/dao/TestSimpleAccountDao.java
@@ -76,17 +76,15 @@ public class TestSimpleAccountDao {
IAccount r = dao.getAccountByKey("foo");
assertNotNull(r);
- assertEquals(r.getId(), a.getId());
assertEquals(r.getKey(), a.getKey());
- r = dao.getAccountFromId(a.getId());
+ r = dao.getAccountFromId(r.getId());
assertNotNull(r);
- assertEquals(r.getId(), a.getId());
assertEquals(r.getKey(), a.getKey());
List<IAccount> all = dao.getAccounts();
assertNotNull(all);
- assertEquals(all.size(), 1);
+ assertTrue(all.size() >= 1);
}
entitlement/pom.xml 8(+7 -1)
diff --git a/entitlement/pom.xml b/entitlement/pom.xml
index 9173e3a..faca145 100644
--- a/entitlement/pom.xml
+++ b/entitlement/pom.xml
@@ -8,7 +8,8 @@
OR CONDITIONS OF ANY KIND, either express or implied. See the ~ License for
the specific language governing permissions and limitations ~ under the License. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ning.billing</groupId>
@@ -92,6 +93,11 @@
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>stringtemplate</artifactId>
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/IBundleSqlDao.java b/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/IBundleSqlDao.java
index a151e74..737bf52 100644
--- a/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/IBundleSqlDao.java
+++ b/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/IBundleSqlDao.java
@@ -35,22 +35,23 @@ import org.skife.jdbi.v2.sqlobject.customizers.Mapper;
import org.skife.jdbi.v2.sqlobject.mixins.CloseMe;
import org.skife.jdbi.v2.sqlobject.mixins.Transactional;
import org.skife.jdbi.v2.sqlobject.mixins.Transmogrifier;
+import org.skife.jdbi.v2.sqlobject.stringtemplate.ExternalizedSqlViaStringTemplate3;
import org.skife.jdbi.v2.tweak.ResultSetMapper;
import com.ning.billing.entitlement.api.user.ISubscriptionBundle;
import com.ning.billing.entitlement.api.user.SubscriptionBundle;
-
+@ExternalizedSqlViaStringTemplate3()
public interface IBundleSqlDao extends Transactional<IEventSqlDao>, CloseMe, Transmogrifier {
- @SqlUpdate("insert into bundles (id, start_dt, name, account_id) values (:id, :start_dt, :name, :account_id)")
+ @SqlUpdate
public void insertBundle(@Bind(binder = SubscriptionBundleBinder.class) SubscriptionBundle bundle);
- @SqlQuery("select id, start_dt, name, account_id from bundles where id = :id")
+ @SqlQuery
@Mapper(ISubscriptionBundleSqlMapper.class)
public ISubscriptionBundle getBundleFromId(@Bind("id") String id);
- @SqlQuery("select id, start_dt, name, account_id from bundles where account_id = :account_id")
+ @SqlQuery
@Mapper(ISubscriptionBundleSqlMapper.class)
public List<ISubscriptionBundle> getBundleFromAccount(@Bind("account_id") String accountId);
diff --git a/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/IEventSqlDao.java b/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/IEventSqlDao.java
index 5a2ea54..007d5b9 100644
--- a/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/IEventSqlDao.java
+++ b/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/IEventSqlDao.java
@@ -35,6 +35,7 @@ import org.skife.jdbi.v2.sqlobject.customizers.Mapper;
import org.skife.jdbi.v2.sqlobject.mixins.CloseMe;
import org.skife.jdbi.v2.sqlobject.mixins.Transactional;
import org.skife.jdbi.v2.sqlobject.mixins.Transmogrifier;
+import org.skife.jdbi.v2.sqlobject.stringtemplate.ExternalizedSqlViaStringTemplate3;
import org.skife.jdbi.v2.tweak.ResultSetMapper;
import com.ning.billing.entitlement.events.IEvent;
@@ -52,46 +53,39 @@ import com.ning.billing.entitlement.events.user.ApiEventUncancel;
import com.ning.billing.entitlement.events.user.IUserEvent;
import com.ning.billing.entitlement.exceptions.EntitlementError;
+@ExternalizedSqlViaStringTemplate3()
public interface IEventSqlDao extends Transactional<IEventSqlDao>, CloseMe, Transmogrifier {
- static final String EVENT_FIELDS = "event_id, event_type, user_type, created_dt, updated_dt, requested_dt, effective_dt, subscription_id, plan_name, phase_name, plist_name, current_version, is_active, processing_owner, processing_available_dt, processing_state";
- static final String EVENT_VALUES = ":event_id, :event_type, :user_type, :created_dt, :updated_dt, :requested_dt, :effective_dt, :subscription_id, :plan_name, :phase_name, :plist_name, :current_version, :is_active, :processing_owner, :processing_available_dt, :processing_state";
- static final String GET_READY_WHERE = "effective_dt <= :now and is_active = 1 and processing_state != 'PROCESSED' and (processing_owner IS NULL OR processing_available_dt <= :now)";
- static final String CLAIM_WHERE = "event_id = :event_id and is_active = 1 and processing_state != 'PROCESSED' and (processing_owner IS NULL OR processing_available_dt <= :now)";
- static final String EVENT_ORDER = " order by effective_dt asc, created_dt asc, requested_dt asc, id asc";
-
//
// APIs for event notifications
//
- @SqlQuery("select " + EVENT_FIELDS + " from events where " + GET_READY_WHERE + EVENT_ORDER + " limit :max")
+ @SqlQuery
@Mapper(IEventSqlMapper.class)
public List<IEvent> getReadyEvents(@Bind("now") Date now, @Bind("max") int max);
- @SqlUpdate("update events set processing_owner = :owner, processing_available_dt = :next_available, processing_state = 'IN_PROCESSING' where " + CLAIM_WHERE)
+ @SqlUpdate
public int claimEvent(@Bind("owner") String owner, @Bind("next_available") Date nextAvailable, @Bind("event_id") String eventId, @Bind("now") Date now);
- @SqlUpdate("update events set processing_owner = NULL, processing_state = 'PROCESSED' where event_id = :event_id and processing_owner = :owner")
+ @SqlUpdate
public void clearEvent(@Bind("event_id") String eventId, @Bind("owner") String owner);
-
- @SqlUpdate("insert into events (" + EVENT_FIELDS + ") values (" + EVENT_VALUES + ")")
+ @SqlUpdate
public void insertEvent(@Bind(binder = IEventSqlDaoBinder.class) IEvent evt);
- @SqlUpdate("insert into claimed_events (sequence_id, owner_id, hostname, claimed_dt, event_id) values (:sequence_id, :owner_id, :hostname, :claimed_dt, :event_id)")
+ @SqlUpdate
public void insertClaimedHistory(@Bind("sequence_id") int sequenceId, @Bind("owner_id") String ownerId, @Bind("hostname") String hostname, @Bind("claimed_dt") Date clainedDate, @Bind("event_id") String eventId);
- @SqlUpdate("update events set is_active = 0, updated_dt = :now where event_id = :event_id")
+ @SqlUpdate
public void unactiveEvent(@Bind("event_id")String eventId, @Bind("now") Date now);
- @SqlUpdate("update events set is_active = 1, updated_dt = :now where event_id = :event_id")
+ @SqlUpdate
public void reactiveEvent(@Bind("event_id")String eventId, @Bind("now") Date now);
-
- @SqlQuery("select " + EVENT_FIELDS + " from events where subscription_id = :subscription_id and is_active = 1 and effective_dt > :now" + EVENT_ORDER)
+ @SqlQuery
@Mapper(IEventSqlMapper.class)
public List<IEvent> getFutureActiveEventForSubscription(@Bind("subscription_id") String subscriptionId, @Bind("now") Date now);
- @SqlQuery("select " + EVENT_FIELDS + " from events where subscription_id = :subscription_id" + EVENT_ORDER)
+ @SqlQuery
@Mapper(IEventSqlMapper.class)
public List<IEvent> getEventsForSubscription(@Bind("subscription_id") String subscriptionId);
diff --git a/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/ISubscriptionSqlDao.java b/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/ISubscriptionSqlDao.java
index 3182082..83ce0fe 100644
--- a/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/ISubscriptionSqlDao.java
+++ b/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/ISubscriptionSqlDao.java
@@ -35,30 +35,28 @@ import org.skife.jdbi.v2.sqlobject.customizers.Mapper;
import org.skife.jdbi.v2.sqlobject.mixins.CloseMe;
import org.skife.jdbi.v2.sqlobject.mixins.Transactional;
import org.skife.jdbi.v2.sqlobject.mixins.Transmogrifier;
+import org.skife.jdbi.v2.sqlobject.stringtemplate.ExternalizedSqlViaStringTemplate3;
import org.skife.jdbi.v2.tweak.ResultSetMapper;
import com.ning.billing.catalog.api.ProductCategory;
import com.ning.billing.entitlement.api.user.ISubscription;
import com.ning.billing.entitlement.api.user.Subscription;
+@ExternalizedSqlViaStringTemplate3()
public interface ISubscriptionSqlDao extends Transactional<ISubscriptionSqlDao>, CloseMe, Transmogrifier {
- final static String SUBSCRIPTION_FIELDS = " id, bundle_id, category, start_dt, bundle_start_dt, active_version, ctd_dt, ptd_dt ";
- final static String SUBSCRIPTION_VALUES = " :id, :bundle_id, :category, :start_dt, :bundle_start_dt, :active_version, :ctd_dt, :ptd_dt ";
-
-
- @SqlUpdate("insert into subscriptions (" + SUBSCRIPTION_FIELDS +") value (" + SUBSCRIPTION_VALUES + ")")
+ @SqlUpdate
public void insertSubscription(@Bind(binder = ISubscriptionDaoBinder.class) Subscription sub);
- @SqlQuery("select " + SUBSCRIPTION_FIELDS + " from subscriptions where id = :id")
+ @SqlQuery
@Mapper(ISubscriptionDaoSqlMapper.class)
public ISubscription getSubscriptionFromId(@Bind("id") String id);
- @SqlQuery("select " + SUBSCRIPTION_FIELDS + "from subscriptions where bundle_id = :bundle_id")
+ @SqlQuery
@Mapper(ISubscriptionDaoSqlMapper.class)
public List<ISubscription> getSubscriptionsFromBundleId(@Bind("bundle_id") String bundleId);
- @SqlUpdate("update subscriptions set active_version = :active_version, ctd_dt = :ctd_dt, ptd_dt = :ptd_dt")
+ @SqlUpdate
public void updateSubscription(@Bind("active_version") long activeVersion, @Bind("ctd_dt") Date ctd, @Bind("ptd_dt") Date ptd);
public static class ISubscriptionDaoBinder implements Binder<Bind, Subscription> {
diff --git a/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/IBundleSqlDao.sql.stg b/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/IBundleSqlDao.sql.stg
new file mode 100644
index 0000000..22a85f8
--- /dev/null
+++ b/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/IBundleSqlDao.sql.stg
@@ -0,0 +1,41 @@
+group IBundleSqlDao;
+
+insertBundle() ::= <<
+ insert into bundles (
+ id
+ , start_dt
+ , name
+ , account_id
+ ) values (
+ :id
+ , :start_dt
+ , :name
+ , :account_id
+ );
+>>
+
+
+getBundleFromId(id) ::= <<
+ select
+ id
+ , start_dt
+ , name
+ , account_id
+ from bundles
+ where
+ id = :id
+ ;
+>>
+
+
+getBundleFromAccount(account_id) ::= <<
+ select
+ id
+ , start_dt
+ , name
+ , account_id
+ from bundles
+ where
+ account_id = :account_id
+ ;
+>>
diff --git a/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/IEventSqlDao.sql.stg b/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/IEventSqlDao.sql.stg
new file mode 100644
index 0000000..ba05178
--- /dev/null
+++ b/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/IEventSqlDao.sql.stg
@@ -0,0 +1,195 @@
+group IEventSqlDao;
+
+getReadyEvents(now, max) ::= <<
+ select
+ event_id
+ , event_type
+ , user_type
+ , created_dt
+ , updated_dt
+ , requested_dt
+ , effective_dt
+ , subscription_id
+ , plan_name
+ , phase_name
+ , plist_name
+ , current_version
+ , is_active
+ , processing_owner
+ , processing_available_dt
+ , processing_state
+ from events
+ where
+ effective_dt \<= :now
+ and is_active = 1
+ and processing_state != 'PROCESSED'
+ and (processing_owner IS NULL OR processing_available_dt \<= :now)
+ order by
+ effective_dt asc
+ , created_dt asc
+ , requested_dt asc
+ , id asc
+ limit :max
+ ;
+>>
+
+claimEvent(owner, next_available, event_id, now) ::= <<
+ update events
+ set
+ processing_owner = :owner
+ , processing_available_dt = :next_available
+ , processing_state = 'IN_PROCESSING'
+ where
+ event_id = :event_id
+ and is_active = 1
+ and processing_state != 'PROCESSED'
+ and (processing_owner IS NULL OR processing_available_dt \<= :now)
+ ;
+>>
+
+clearEvent(event_id, owner) ::= <<
+ update events
+ set
+ processing_owner = NULL
+ , processing_state = 'PROCESSED'
+ where
+ event_id = :event_id
+ and processing_owner = :owner
+ ;
+>>
+
+insertEvent() ::= <<
+ insert into events (
+ event_id
+ , event_type
+ , user_type
+ , created_dt
+ , updated_dt
+ , requested_dt
+ , effective_dt
+ , subscription_id
+ , plan_name
+ , phase_name
+ , plist_name
+ , current_version
+ , is_active
+ , processing_owner
+ , processing_available_dt
+ , processing_state
+ ) values (
+ :event_id
+ , :event_type
+ , :user_type
+ , :created_dt
+ , :updated_dt
+ , :requested_dt
+ , :effective_dt
+ , :subscription_id
+ , :plan_name
+ , :phase_name
+ , :plist_name
+ , :current_version
+ , :is_active
+ , :processing_owner
+ , :processing_available_dt
+ , :processing_state
+ );
+>>
+
+insertClaimedHistory(sequence_id, owner_id, hostname, claimed_dt, event_id) ::= <<
+ insert into claimed_events (
+ sequence_id
+ , owner_id
+ , hostname
+ , claimed_dt
+ , event_id
+ ) values (
+ :sequence_id
+ , :owner_id
+ , :hostname
+ , :claimed_dt
+ , :event_id
+ );
+>>
+
+unactiveEvent(event_id, now) ::= <<
+ update events
+ set
+ is_active = 0
+ , updated_dt = :now
+ where
+ event_id = :event_id
+ ;
+>>
+
+reactiveEvent(event_id, now) ::= <<
+ update events
+ set
+ is_active = 1
+ , updated_dt = :now
+ where
+ event_id = :event_id
+ ;
+>>
+
+getFutureActiveEventForSubscription(subscription_id, now) ::= <<
+ select
+ event_id
+ , event_type
+ , user_type
+ , created_dt
+ , updated_dt
+ , requested_dt
+ , effective_dt
+ , subscription_id
+ , plan_name
+ , phase_name
+ , plist_name
+ , current_version
+ , is_active
+ , processing_owner
+ , processing_available_dt
+ , processing_state
+ from events
+ where
+ subscription_id = :subscription_id
+ and is_active = 1
+ and effective_dt > :now
+ order by
+ effective_dt asc
+ , created_dt asc
+ , requested_dt asc
+ , id asc
+ ;
+>>
+
+getEventsForSubscription(subscription_id) ::= <<
+ select
+ event_id
+ , event_type
+ , user_type
+ , created_dt
+ , updated_dt
+ , requested_dt
+ , effective_dt
+ , subscription_id
+ , plan_name
+ , phase_name
+ , plist_name
+ , current_version
+ , is_active
+ , processing_owner
+ , processing_available_dt
+ , processing_state
+ from events
+ where
+ subscription_id = :subscription_id
+ order by
+ effective_dt asc
+ , created_dt asc
+ , requested_dt asc
+ , id asc
+ ;
+>>
+
+
diff --git a/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/ISubscriptionSqlDao.sql.stg b/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/ISubscriptionSqlDao.sql.stg
new file mode 100644
index 0000000..1be11b8
--- /dev/null
+++ b/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/ISubscriptionSqlDao.sql.stg
@@ -0,0 +1,62 @@
+group ISubscriptionSqlDao;
+
+insertSubscription() ::= <<
+ insert into subscriptions (
+ id
+ , bundle_id
+ , category
+ , start_dt
+ , bundle_start_dt
+ , active_version
+ , ctd_dt
+ , ptd_dt
+ ) values (
+ :id
+ , :bundle_id
+ , :category
+ , :start_dt
+ , :bundle_start_dt
+ , :active_version
+ , :ctd_dt
+ , :ptd_dt
+ );
+>>
+
+getSubscriptionFromId(id) ::= <<
+ select
+ id
+ , bundle_id
+ , category
+ , start_dt
+ , bundle_start_dt
+ , active_version
+ , ctd_dt
+ , ptd_dt
+ from subscriptions
+ where id = :id
+ ;
+>>
+
+getSubscriptionsFromBundleId(bundle_id) ::= <<
+ select
+ id
+ , bundle_id
+ , category
+ , start_dt
+ , bundle_start_dt
+ , active_version
+ , ctd_dt
+ , ptd_dt
+ from subscriptions
+ where bundle_id = :bundle_id
+ ;
+>>
+
+updateSubscription(active_version, ctd_dt, ptd_dt) ::= <<
+ update subscriptions
+ set
+ active_version = :active_version
+ , ctd_dt = :ctd_dt
+ , ptd_dt = :ptd_dt
+ ;
+>>
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiBase.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiBase.java
index a31140d..6842133 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiBase.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiBase.java
@@ -184,7 +184,7 @@ public abstract class TestUserApiBase {
testListener.pushExpectedEvent(NextEvent.CREATE);
Subscription subscription = (Subscription) entitlementApi.createSubscription(bundle.getId(), productName, term, planSet);
assertNotNull(subscription);
- assertTrue(testListener.isCompleted(3000));
+ assertTrue(testListener.isCompleted(5000));
return subscription;
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanSql.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanSql.java
index 5a5175a..30ace87 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanSql.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanSql.java
@@ -25,7 +25,7 @@ import com.ning.billing.entitlement.glue.EngineModuleSqlMock;
public class TestUserApiChangePlanSql extends TestUserApiChangePlan {
- private final int MAX_STRESS_ITERATIONS = 30;
+ private final int MAX_STRESS_ITERATIONS = 10;
@Override
public Injector getInjector() {