killbill-aplcache
Changes
entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/AuditedEntitlementDao.java 30(+14 -16)
entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/model/EntitlementEventModelDao.java 52(+34 -18)
entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/model/SubscriptionBundleModelDao.java 10(+5 -5)
entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/BundleSqlDao.sql.stg 2(+2 -0)
entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/EntitlementEventSqlDao.sql.stg 36(+19 -17)
entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/SubscriptionSqlDao.sql.stg 12(+6 -6)
Details
diff --git a/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/AuditedEntitlementDao.java b/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/AuditedEntitlementDao.java
index 0bef958..7303711 100644
--- a/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/AuditedEntitlementDao.java
+++ b/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/AuditedEntitlementDao.java
@@ -60,7 +60,6 @@ import com.ning.billing.entitlement.engine.dao.model.SubscriptionBundleModelDao;
import com.ning.billing.entitlement.engine.dao.model.SubscriptionModelDao;
import com.ning.billing.entitlement.events.EntitlementEvent;
import com.ning.billing.entitlement.events.EntitlementEvent.EventType;
-import com.ning.billing.entitlement.events.user.ApiEvent;
import com.ning.billing.entitlement.events.user.ApiEventBuilder;
import com.ning.billing.entitlement.events.user.ApiEventCancel;
import com.ning.billing.entitlement.events.user.ApiEventChange;
@@ -85,7 +84,6 @@ import com.ning.billing.util.svcsapi.bus.InternalBus.EventBusException;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
-import com.google.common.collect.ImmutableList;
public class AuditedEntitlementDao implements EntitlementDao {
@@ -125,7 +123,8 @@ public class AuditedEntitlementDao implements EntitlementDao {
@Override
public List<SubscriptionBundle> inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception {
final List<SubscriptionBundleModelDao> models = entitySqlDaoWrapperFactory.become(BundleSqlDao.class).getBundleFromAccount(accountId.toString(), context);
- return ImmutableList.<SubscriptionBundle>copyOf(Collections2.transform(models, new Function<SubscriptionBundleModelDao, SubscriptionBundle>() {
+
+ return new ArrayList<SubscriptionBundle>(Collections2.transform(models, new Function<SubscriptionBundleModelDao, SubscriptionBundle>() {
@Override
public SubscriptionBundle apply(@Nullable final SubscriptionBundleModelDao input) {
return SubscriptionBundleModelDao.toSubscriptionbundle(input);
@@ -151,8 +150,8 @@ public class AuditedEntitlementDao implements EntitlementDao {
return transactionalSqlDao.execute(new EntitySqlDaoTransactionWrapper<List<SubscriptionBundle>>() {
@Override
public List<SubscriptionBundle> inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception {
- final List<SubscriptionBundleModelDao> models = entitySqlDaoWrapperFactory.become(BundleSqlDao.class).getBundlesForKey(bundleKey, context);
- return ImmutableList.<SubscriptionBundle>copyOf( Collections2.transform(models, new Function<SubscriptionBundleModelDao, SubscriptionBundle>() {
+ final List<SubscriptionBundleModelDao> models = entitySqlDaoWrapperFactory.become(BundleSqlDao.class).getBundlesForKey(bundleKey, context);
+ return new ArrayList<SubscriptionBundle>(Collections2.transform(models, new Function<SubscriptionBundleModelDao, SubscriptionBundle>() {
@Override
public SubscriptionBundle apply(@Nullable final SubscriptionBundleModelDao input) {
return SubscriptionBundleModelDao.toSubscriptionbundle(input);
@@ -217,7 +216,7 @@ public class AuditedEntitlementDao implements EntitlementDao {
return transactionalSqlDao.execute(new EntitySqlDaoTransactionWrapper<Subscription>() {
@Override
public Subscription inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception {
- final SubscriptionModelDao model = entitySqlDaoWrapperFactory.become(SubscriptionSqlDao.class).getById(subscriptionId.toString(), context);
+ final SubscriptionModelDao model = entitySqlDaoWrapperFactory.become(SubscriptionSqlDao.class).getById(subscriptionId.toString(), context);
return SubscriptionModelDao.toSubscription(model);
}
});
@@ -233,8 +232,8 @@ public class AuditedEntitlementDao implements EntitlementDao {
return transactionalSqlDao.execute(new EntitySqlDaoTransactionWrapper<List<Subscription>>() {
@Override
public List<Subscription> inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception {
- final List<SubscriptionModelDao> models = entitySqlDaoWrapperFactory.become(SubscriptionSqlDao.class).getSubscriptionsFromBundleId(bundleId.toString(), context);
- return ImmutableList.<Subscription>copyOf( Collections2.transform(models, new Function<SubscriptionModelDao, Subscription>() {
+ final List<SubscriptionModelDao> models = entitySqlDaoWrapperFactory.become(SubscriptionSqlDao.class).getSubscriptionsFromBundleId(bundleId.toString(), context);
+ return new ArrayList<Subscription>(Collections2.transform(models, new Function<SubscriptionModelDao, Subscription>() {
@Override
public Subscription apply(@Nullable final SubscriptionModelDao input) {
return SubscriptionModelDao.toSubscription(input);
@@ -245,7 +244,6 @@ public class AuditedEntitlementDao implements EntitlementDao {
}
-
@Override
public List<Subscription> getSubscriptionsForAccountAndKey(final SubscriptionFactory factory, final UUID accountId,
final String bundleKey, final InternalTenantContext context) {
@@ -306,7 +304,7 @@ public class AuditedEntitlementDao implements EntitlementDao {
return transactionalSqlDao.execute(new EntitySqlDaoTransactionWrapper<EntitlementEvent>() {
@Override
public EntitlementEvent inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception {
- EntitlementEventModelDao model = entitySqlDaoWrapperFactory.become(EntitlementEventSqlDao.class).getById(eventId.toString(), context);
+ EntitlementEventModelDao model = entitySqlDaoWrapperFactory.become(EntitlementEventSqlDao.class).getById(eventId.toString(), context);
return EntitlementEventModelDao.toEntitlementEvent(model);
}
});
@@ -319,7 +317,7 @@ public class AuditedEntitlementDao implements EntitlementDao {
public List<EntitlementEvent> inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception {
final List<EntitlementEventModelDao> models = entitySqlDaoWrapperFactory.become(EntitlementEventSqlDao.class).getEventsForSubscription(subscriptionId.toString(), context);
- return ImmutableList.<EntitlementEvent>copyOf( Collections2.transform(models, new Function<EntitlementEventModelDao, EntitlementEvent>() {
+ return new ArrayList<EntitlementEvent>(Collections2.transform(models, new Function<EntitlementEventModelDao, EntitlementEvent>() {
@Override
public EntitlementEvent apply(@Nullable final EntitlementEventModelDao input) {
return EntitlementEventModelDao.toEntitlementEvent(input);
@@ -345,7 +343,7 @@ public class AuditedEntitlementDao implements EntitlementDao {
final Map<UUID, List<EntitlementEvent>> result = new HashMap<UUID, List<EntitlementEvent>>();
for (final SubscriptionModelDao cur : subscriptionModels) {
final List<EntitlementEventModelDao> eventModels = eventsDaoFromSameTransaction.getEventsForSubscription(cur.getId().toString(), context);
- final List<EntitlementEvent> events = ImmutableList.<EntitlementEvent>copyOf(Collections2.transform(eventModels, new Function<EntitlementEventModelDao, EntitlementEvent>() {
+ final List<EntitlementEvent> events = new ArrayList<EntitlementEvent>(Collections2.transform(eventModels, new Function<EntitlementEventModelDao, EntitlementEvent>() {
@Override
public EntitlementEvent apply(@Nullable final EntitlementEventModelDao input) {
return EntitlementEventModelDao.toEntitlementEvent(input);
@@ -366,7 +364,7 @@ public class AuditedEntitlementDao implements EntitlementDao {
@Override
public List<EntitlementEvent> inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception {
final List<EntitlementEventModelDao> eventModels = entitySqlDaoWrapperFactory.become(EntitlementEventSqlDao.class).getFutureActiveEventForSubscription(subscriptionId.toString(), now, context);
- final List<EntitlementEvent> events = ImmutableList.<EntitlementEvent>copyOf(Collections2.transform(eventModels, new Function<EntitlementEventModelDao, EntitlementEvent>() {
+ final List<EntitlementEvent> events = new ArrayList<EntitlementEvent>(Collections2.transform(eventModels, new Function<EntitlementEventModelDao, EntitlementEvent>() {
@Override
public EntitlementEvent apply(@Nullable final EntitlementEventModelDao input) {
return EntitlementEventModelDao.toEntitlementEvent(input);
@@ -450,7 +448,7 @@ public class AuditedEntitlementDao implements EntitlementDao {
final List<EntitlementEventModelDao> eventModels = transactional.getFutureActiveEventForSubscription(subscriptionId.toString(), now, context);
for (final EntitlementEventModelDao cur : eventModels) {
- if (cur.getUserType() == ApiEventType.CANCEL) {
+ if (cur.getUserTypeX() == ApiEventType.CANCEL) {
if (cancelledEvent != null) {
throw new EntitlementError(String.format("Found multiple cancel active events for subscriptions %s", subscriptionId.toString()));
}
@@ -537,8 +535,8 @@ public class AuditedEntitlementDao implements EntitlementDao {
final Date now = clock.getUTCNow().toDate();
final List<EntitlementEventModelDao> eventModels = dao.become(EntitlementEventSqlDao.class).getFutureActiveEventForSubscription(subscriptionId.toString(), now, context);
for (final EntitlementEventModelDao cur : eventModels) {
- if (cur.getEventType() == type &&
- (apiType == null || apiType == cur.getUserType())) {
+ if (cur.getEventTypeX() == type &&
+ (apiType == null || apiType == cur.getUserTypeX())) {
if (futureEvent != null) {
throw new EntitlementError(String.format("Found multiple future events for type %s for subscriptions %s",
type, subscriptionId.toString()));
diff --git a/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/model/EntitlementEventModelDao.java b/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/model/EntitlementEventModelDao.java
index 7972c84..9d6f268 100644
--- a/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/model/EntitlementEventModelDao.java
+++ b/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/model/EntitlementEventModelDao.java
@@ -20,10 +20,10 @@ import java.util.UUID;
import org.joda.time.DateTime;
-import com.ning.billing.entitlement.api.user.EntitlementUserApi;
import com.ning.billing.entitlement.events.EntitlementEvent;
import com.ning.billing.entitlement.events.EntitlementEvent.EventType;
import com.ning.billing.entitlement.events.EventBaseBuilder;
+import com.ning.billing.entitlement.events.phase.PhaseEvent;
import com.ning.billing.entitlement.events.phase.PhaseEventBuilder;
import com.ning.billing.entitlement.events.phase.PhaseEventData;
import com.ning.billing.entitlement.events.user.ApiEvent;
@@ -81,7 +81,7 @@ public class EntitlementEventModelDao extends EntityBase {
this.effectiveDate = src.getEffectiveDate();
this.subscriptionId = src.getSubscriptionId();
this.planName = eventType == EventType.API_USER ? ((ApiEvent) src).getEventPlan() : null;
- this.phaseName = eventType == EventType.API_USER ? ((ApiEvent) src).getEventPlanPhase() : null;
+ this.phaseName = eventType == EventType.API_USER ? ((ApiEvent) src).getEventPlanPhase() : ((PhaseEvent) src).getPhase();
this.priceListName = eventType == EventType.API_USER ? ((ApiEvent) src).getPriceList() : null;
this.currentVersion = src.getActiveVersion();
this.isActive = src.isActive();
@@ -91,11 +91,22 @@ public class EntitlementEventModelDao extends EntityBase {
return totalOrdering;
}
- public EventType getEventType() {
+ public String getEventType() {
+ return eventType != null ? eventType.toString() : null;
+ }
+
+ // TODO required for bindings
+ public String getUserType() {
+ return userType != null ? userType.toString() : null;
+ }
+
+
+ public EventType getEventTypeX() {
return eventType;
}
- public ApiEventType getUserType() {
+
+ public ApiEventType getUserTypeX() {
return userType;
}
@@ -127,13 +138,18 @@ public class EntitlementEventModelDao extends EntityBase {
return currentVersion;
}
+ // TODO required for jdbi binder
+ public boolean getIsActive() {
+ return isActive;
+ }
+
public boolean isActive() {
return isActive;
}
public static EntitlementEvent toEntitlementEvent(EntitlementEventModelDao src) {
- final EventBaseBuilder<?> base = ((src.getEventType() == EventType.PHASE) ?
+ final EventBaseBuilder<?> base = ((src.getEventTypeX() == EventType.PHASE) ?
new PhaseEventBuilder() :
new ApiEventBuilder())
.setTotalOrdering(src.getTotalOrdering())
@@ -148,37 +164,37 @@ public class EntitlementEventModelDao extends EntityBase {
.setActive(src.isActive());
EntitlementEvent result = null;
- if (src.getEventType() == EventType.PHASE) {
+ if (src.getEventTypeX() == EventType.PHASE) {
result = new PhaseEventData(new PhaseEventBuilder(base).setPhaseName(src.getPhaseName()));
- } else if (src.getEventType() == EventType.API_USER) {
+ } else if (src.getEventTypeX() == EventType.API_USER) {
final ApiEventBuilder builder = new ApiEventBuilder(base)
.setEventPlan(src.getPlanName())
.setEventPlanPhase(src.getPhaseName())
.setEventPriceList(src.getPriceListName())
- .setEventType(src.getUserType())
+ .setEventType(src.getUserTypeX())
.setFromDisk(true);
- if (src.getUserType() == ApiEventType.CREATE) {
+ if (src.getUserTypeX() == ApiEventType.CREATE) {
result = new ApiEventCreate(builder);
- } else if (src.getUserType() == ApiEventType.RE_CREATE) {
+ } else if (src.getUserTypeX() == ApiEventType.RE_CREATE) {
result = new ApiEventReCreate(builder);
- } else if (src.getUserType() == ApiEventType.MIGRATE_ENTITLEMENT) {
+ } else if (src.getUserTypeX() == ApiEventType.MIGRATE_ENTITLEMENT) {
result = new ApiEventMigrateEntitlement(builder);
- } else if (src.getUserType() == ApiEventType.MIGRATE_BILLING) {
+ } else if (src.getUserTypeX() == ApiEventType.MIGRATE_BILLING) {
result = new ApiEventMigrateBilling(builder);
- } else if (src.getUserType() == ApiEventType.TRANSFER) {
+ } else if (src.getUserTypeX() == ApiEventType.TRANSFER) {
result = new ApiEventTransfer(builder);
- } else if (src.getUserType() == ApiEventType.CHANGE) {
+ } else if (src.getUserTypeX() == ApiEventType.CHANGE) {
result = new ApiEventChange(builder);
- } else if (src.getUserType() == ApiEventType.CANCEL) {
+ } else if (src.getUserTypeX() == ApiEventType.CANCEL) {
result = new ApiEventCancel(builder);
- } else if (src.getUserType() == ApiEventType.RE_CREATE) {
+ } else if (src.getUserTypeX() == ApiEventType.RE_CREATE) {
result = new ApiEventReCreate(builder);
- } else if (src.getUserType() == ApiEventType.UNCANCEL) {
+ } else if (src.getUserTypeX() == ApiEventType.UNCANCEL) {
result = new ApiEventUncancel(builder);
}
} else {
- throw new EntitlementError(String.format("Can't figure out event %s", src.getEventType()));
+ throw new EntitlementError(String.format("Can't figure out event %s", src.getEventTypeX()));
}
return result;
}
diff --git a/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/model/SubscriptionBundleModelDao.java b/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/model/SubscriptionBundleModelDao.java
index 1f470f2..a287d36 100644
--- a/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/model/SubscriptionBundleModelDao.java
+++ b/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/model/SubscriptionBundleModelDao.java
@@ -26,13 +26,13 @@ import com.ning.billing.util.entity.EntityBase;
public class SubscriptionBundleModelDao extends EntityBase {
- private final String key;
+ private final String externalKey;
private final UUID accountId;
private final DateTime lastSysUpdateDate;
public SubscriptionBundleModelDao(final UUID id, final String key, final UUID accountId, final DateTime lastSysUpdateDate, final DateTime createdDate, final DateTime updateDate) {
super(id, createdDate, updateDate);
- this.key = key;
+ this.externalKey = key;
this.accountId = accountId;
this.lastSysUpdateDate = lastSysUpdateDate;
}
@@ -42,8 +42,8 @@ public class SubscriptionBundleModelDao extends EntityBase {
this(input.getId(), input.getExternalKey(), input.getAccountId(), input.getLastSysUpdateDate(), input.getCreatedDate(), input.getUpdatedDate());
}
- public String getKey() {
- return key;
+ public String getExternalKey() {
+ return externalKey;
}
public UUID getAccountId() {
@@ -58,6 +58,6 @@ public class SubscriptionBundleModelDao extends EntityBase {
if (src == null) {
return null;
}
- return new SubscriptionBundleData(src.getId(), src.getKey(), src.getAccountId(), src.getLastSysUpdateDate());
+ return new SubscriptionBundleData(src.getId(), src.getExternalKey(), src.getAccountId(), src.getLastSysUpdateDate());
}
}
diff --git a/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/BundleSqlDao.sql.stg b/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/BundleSqlDao.sql.stg
index 6c0d371..2ef637e 100644
--- a/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/BundleSqlDao.sql.stg
+++ b/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/BundleSqlDao.sql.stg
@@ -27,6 +27,8 @@ updateBundleLastSysTime() ::= <<
update <tableName()>
set
last_sys_update_date = :lastSysUpdateDate
+, updated_by = :createdBy
+, updated_date = :createdDate
where id = :id
<AND_CHECK_TENANT()>
;
diff --git a/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/EntitlementEventSqlDao.sql.stg b/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/EntitlementEventSqlDao.sql.stg
index 9fd5b30..34433b2 100644
--- a/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/EntitlementEventSqlDao.sql.stg
+++ b/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/EntitlementEventSqlDao.sql.stg
@@ -23,19 +23,19 @@ tableFields(prefix) ::= <<
tableValues() ::= <<
:eventType
, :userType
-, :requested_date
-, :effective_date
-, :subscription_id
-, :plan_name
-, :phase_name
-, :price_list_name
-, :user_token
-, :current_version
-, :is_active
-, :created_by
-, :created_date
-, :updated_by
-, :updated_date
+, :requestedDate
+, :effectiveDate
+, :subscriptionId
+, :planName
+, :phaseName
+, :priceListName
+, :userToken
+, :currentVersion
+, :isActive
+, :createdBy
+, :createdDate
+, :updatedBy
+, :updatedDate
>>
@@ -43,6 +43,8 @@ updateVersion() ::= <<
update <tableName()>
set
current_version = :currentVersion
+, updated_by = :createdBy
+, updated_date = :createdDate
where
id = :id
<AND_CHECK_TENANT()>
@@ -53,8 +55,8 @@ unactiveEvent() ::= <<
update <tableName()>
set
is_active = 0
-, updated_by = :userName
-, updated_date = :updatedDate
+, updated_by = :createdBy
+, updated_date = :createdDate
where
id = :id
<AND_CHECK_TENANT()>
@@ -65,8 +67,8 @@ reactiveEvent() ::= <<
update <tableName()>
set
is_active = 1
-, updated_by = :userName
-, updated_date = :updatedDate
+, updated_by = :createdBy
+, updated_date = :createdDate
where
event_id = :eventId
<AND_CHECK_TENANT()>
diff --git a/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/SubscriptionSqlDao.sql.stg b/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/SubscriptionSqlDao.sql.stg
index 8455c9d..378afef 100644
--- a/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/SubscriptionSqlDao.sql.stg
+++ b/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/SubscriptionSqlDao.sql.stg
@@ -44,8 +44,8 @@ updateChargedThroughDate() ::= <<
update <tableName()>
set
charged_through_date = :chargedThroughDate
-, updated_by = :userName
-, updated_date = :updatedDate
+, updated_by = :createdBy
+, updated_date = :createdDate
where id = :id
<AND_CHECK_TENANT()>
;
@@ -55,8 +55,8 @@ updateActiveVersion() ::= <<
update <tableName()>
set
active_version = :activeVersion
-, updated_by = :userName
-, updated_date = :updatedDate
+, updated_by = :createdBy
+, updated_date = :createdDate
where id = :id
;
>>
@@ -67,8 +67,8 @@ set
active_version = :activeVersion
, start_date = :startDate
, bundle_start_date = :bundleStartDate
-, updated_by = :userName
-, updated_date = :updatedDate
+, updated_by = :createdBy
+, updated_date = :createdDate
where id = :id
<AND_CHECK_TENANT()>
;
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreate.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreate.java
index c6a4362..1925799 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreate.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreate.java
@@ -47,9 +47,6 @@ public abstract class TestUserApiCreate extends TestApiBase {
private static final Logger log = LoggerFactory.getLogger(TestUserApiCreate.class);
- private final InternalTenantContext internalTenantContext = Mockito.mock(InternalTenantContext.class);
- private final TenantContext tenantContext = Mockito.mock(TenantContext.class);
-
public void testCreateWithRequestedDate() {
try {
final DateTime init = clock.getUTCNow();
@@ -150,7 +147,7 @@ public abstract class TestUserApiCreate extends TestApiBase {
assertEquals(currentPhase.getPhaseType(), PhaseType.TRIAL);
assertTrue(testListener.isCompleted(5000));
- final List<EntitlementEvent> events = dao.getPendingEventsForSubscription(subscription.getId(), internalTenantContext);
+ final List<EntitlementEvent> events = dao.getPendingEventsForSubscription(subscription.getId(), internalCallContext);
assertNotNull(events);
printEvents(events);
assertTrue(events.size() == 1);
@@ -207,7 +204,7 @@ public abstract class TestUserApiCreate extends TestApiBase {
clock.addDeltaFromReality(it.toDurationMillis());
assertTrue(testListener.isCompleted(5000));
- subscription = (SubscriptionData) entitlementApi.getSubscriptionFromId(subscription.getId(), tenantContext);
+ subscription = (SubscriptionData) entitlementApi.getSubscriptionFromId(subscription.getId(), callContext);
currentPhase = subscription.getCurrentPhase();
assertNotNull(currentPhase);
assertEquals(currentPhase.getPhaseType(), PhaseType.EVERGREEN);
diff --git a/util/src/main/java/com/ning/billing/util/callcontext/InternalCallContext.java b/util/src/main/java/com/ning/billing/util/callcontext/InternalCallContext.java
index 891c295..1e90911 100644
--- a/util/src/main/java/com/ning/billing/util/callcontext/InternalCallContext.java
+++ b/util/src/main/java/com/ning/billing/util/callcontext/InternalCallContext.java
@@ -31,7 +31,7 @@ public class InternalCallContext extends InternalTenantContext {
private final String createdBy;
private final String updatedBy;
private final CallOrigin callOrigin;
- private final UserType userType;
+ private final UserType contextUserType;
private final String reasonCode;
private final String comments;
private final DateTime createdDate;
@@ -45,7 +45,7 @@ public class InternalCallContext extends InternalTenantContext {
this.createdBy = userName;
this.updatedBy = userName;
this.callOrigin = callOrigin;
- this.userType = userType;
+ this.contextUserType = userType;
this.reasonCode = reasonCode;
this.comments = comment;
this.createdDate = createdDate;
@@ -63,7 +63,7 @@ public class InternalCallContext extends InternalTenantContext {
// Unfortunately not true as some APIs ae hidden in object-- e.g OverdueStateApplicator is doing subscription.cancelWithPolicy(polciy, context);
//
public CallContext toCallContext() {
- return new DefaultCallContext(null, createdBy, callOrigin, userType, reasonCode, comments, userToken, createdDate, updatedDate);
+ return new DefaultCallContext(null, createdBy, callOrigin, contextUserType, reasonCode, comments, userToken, createdDate, updatedDate);
}
public UUID getUserToken() {
@@ -82,8 +82,8 @@ public class InternalCallContext extends InternalTenantContext {
return callOrigin;
}
- public UserType getUserType() {
- return userType;
+ public UserType getContextUserType() {
+ return contextUserType;
}
public String getReasonCode() {
@@ -110,7 +110,7 @@ public class InternalCallContext extends InternalTenantContext {
sb.append(", createdBy='").append(createdBy).append('\'');
sb.append(", updatedBy='").append(updatedBy).append('\'');
sb.append(", callOrigin=").append(callOrigin);
- sb.append(", userType=").append(userType);
+ sb.append(", contextUserType=").append(contextUserType);
sb.append(", reasonCode='").append(reasonCode).append('\'');
sb.append(", comments='").append(comments).append('\'');
sb.append(", createdDate=").append(createdDate);
@@ -157,7 +157,7 @@ public class InternalCallContext extends InternalTenantContext {
if (userToken != null ? !userToken.equals(that.userToken) : that.userToken != null) {
return false;
}
- if (userType != that.userType) {
+ if (contextUserType != that.contextUserType) {
return false;
}
@@ -171,7 +171,7 @@ public class InternalCallContext extends InternalTenantContext {
result = 31 * result + (createdBy != null ? createdBy.hashCode() : 0);
result = 31 * result + (updatedBy != null ? updatedBy.hashCode() : 0);
result = 31 * result + (callOrigin != null ? callOrigin.hashCode() : 0);
- result = 31 * result + (userType != null ? userType.hashCode() : 0);
+ result = 31 * result + (contextUserType != null ? contextUserType.hashCode() : 0);
result = 31 * result + (reasonCode != null ? reasonCode.hashCode() : 0);
result = 31 * result + (comments != null ? comments.hashCode() : 0);
result = 31 * result + (createdDate != null ? createdDate.hashCode() : 0);
diff --git a/util/src/main/java/com/ning/billing/util/callcontext/InternalCallContextFactory.java b/util/src/main/java/com/ning/billing/util/callcontext/InternalCallContextFactory.java
index 8cc1954..afa2926 100644
--- a/util/src/main/java/com/ning/billing/util/callcontext/InternalCallContextFactory.java
+++ b/util/src/main/java/com/ning/billing/util/callcontext/InternalCallContextFactory.java
@@ -199,14 +199,14 @@ public class InternalCallContextFactory {
// Used when we need to re-hydrate the context with the account_record_id (when creating the account)
public InternalCallContext createInternalCallContext(final Long accountRecordId, final InternalCallContext context) {
return new InternalCallContext(context.getTenantRecordId(), accountRecordId, context.getUserToken(), context.getCreatedBy(),
- context.getCallOrigin(), context.getUserType(), context.getReasonCode(), context.getComments(),
+ context.getCallOrigin(), context.getContextUserType(), context.getReasonCode(), context.getComments(),
context.getCreatedDate(), context.getUpdatedDate());
}
// Used when we need to re-hydrate the context with the tenant_record_id and account_record_id (when claiming bus events)
public InternalCallContext createInternalCallContext(final Long tenantRecordId, final Long accountRecordId, final InternalCallContext context) {
return new InternalCallContext(tenantRecordId, accountRecordId, context.getUserToken(), context.getCreatedBy(),
- context.getCallOrigin(), context.getUserType(), context.getReasonCode(), context.getComments(),
+ context.getCallOrigin(), context.getContextUserType(), context.getReasonCode(), context.getComments(),
context.getCreatedDate(), context.getUpdatedDate());
}
diff --git a/util/src/main/java/com/ning/billing/util/entity/dao/EntitySqlDaoWrapperInvocationHandler.java b/util/src/main/java/com/ning/billing/util/entity/dao/EntitySqlDaoWrapperInvocationHandler.java
index 4a989ab..e80acc9 100644
--- a/util/src/main/java/com/ning/billing/util/entity/dao/EntitySqlDaoWrapperInvocationHandler.java
+++ b/util/src/main/java/com/ning/billing/util/entity/dao/EntitySqlDaoWrapperInvocationHandler.java
@@ -165,7 +165,10 @@ public class EntitySqlDaoWrapperInvocationHandler<T extends EntitySqlDao<U>, U e
final Long entityRecordId = Objects.firstNonNull(reHydratedEntityRecordId, entityRecordIds.get(entityId));
final TableName tableName = retrieveTableNameFromEntity(entity);
-
+ // TODO
+ if (tableName == TableName.SUBSCRIPTION_EVENTS) {
+ return;
+ }
// Note: audit entries point to the history record id
final Long historyRecordId;
if (tableName.getHistoryTableName() != null) {
diff --git a/util/src/test/java/com/ning/billing/util/callcontext/TestInternalCallContextFactory.java b/util/src/test/java/com/ning/billing/util/callcontext/TestInternalCallContextFactory.java
index 04f4f7c..20e5d3e 100644
--- a/util/src/test/java/com/ning/billing/util/callcontext/TestInternalCallContextFactory.java
+++ b/util/src/test/java/com/ning/billing/util/callcontext/TestInternalCallContextFactory.java
@@ -102,7 +102,7 @@ public class TestInternalCallContextFactory extends UtilTestSuiteWithEmbeddedDB
Assert.assertEquals(context.getUpdatedDate(), callContext.getUpdatedDate());
Assert.assertEquals(context.getCreatedBy(), callContext.getUserName());
Assert.assertEquals(context.getUserToken(), callContext.getUserToken());
- Assert.assertEquals(context.getUserType(), callContext.getUserType());
+ Assert.assertEquals(context.getContextUserType(), callContext.getUserType());
// Our test callContext doesn't have a tenant id
Assert.assertEquals(context.getTenantRecordId(), (Long) InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID);
}