killbill-memoizeit
Changes
entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationMemory.java 10(+4 -6)
entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestApiBaseRepair.java 13(+3 -10)
entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestRepairWithAO.java 45(+7 -38)
entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestRepairWithError.java 61(+11 -50)
entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelMemory.java 10(+4 -6)
entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlan.java 38(+0 -38)
entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanMemory.java 15(+6 -9)
entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanSql.java 16(+7 -9)
entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateMemory.java 13(+5 -8)
entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiRecreateMemory.java 6(+2 -4)
entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiRecreateSql.java 5(+2 -3)
entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/MockEntitlementDaoMemory.java 17(+3 -14)
entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/MockEntitlementDaoSql.java 48(+1 -47)
Details
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/alignment/TestPlanAligner.java b/entitlement/src/test/java/com/ning/billing/entitlement/alignment/TestPlanAligner.java
index 6579baa..65df594 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/alignment/TestPlanAligner.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/alignment/TestPlanAligner.java
@@ -28,6 +28,7 @@ import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import com.ning.billing.KillbillTestSuite;
import com.ning.billing.catalog.DefaultCatalogService;
import com.ning.billing.catalog.api.CatalogApiException;
import com.ning.billing.catalog.api.PhaseType;
@@ -39,7 +40,6 @@ import com.ning.billing.entitlement.api.user.DefaultSubscriptionFactory;
import com.ning.billing.entitlement.api.user.EffectiveSubscriptionEvent;
import com.ning.billing.entitlement.api.user.EntitlementUserApiException;
import com.ning.billing.entitlement.api.user.SubscriptionData;
-import com.ning.billing.entitlement.api.user.SubscriptionTransitionData;
import com.ning.billing.entitlement.events.EntitlementEvent;
import com.ning.billing.entitlement.events.user.ApiEventBase;
import com.ning.billing.entitlement.events.user.ApiEventBuilder;
@@ -47,7 +47,7 @@ import com.ning.billing.entitlement.events.user.ApiEventType;
import com.ning.billing.entitlement.exceptions.EntitlementError;
import com.ning.billing.util.clock.DefaultClock;
-public class TestPlanAligner {
+public class TestPlanAligner extends KillbillTestSuite {
private static final String priceList = PriceListSet.DEFAULT_PRICELIST_NAME;
private final DefaultClock clock = new DefaultClock();
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/alignment/TestTimedMigration.java b/entitlement/src/test/java/com/ning/billing/entitlement/alignment/TestTimedMigration.java
index 09740d2..6be543d 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/alignment/TestTimedMigration.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/alignment/TestTimedMigration.java
@@ -24,12 +24,13 @@ import org.mockito.Mockito;
import org.testng.Assert;
import org.testng.annotations.Test;
+import com.ning.billing.KillbillTestSuite;
import com.ning.billing.catalog.api.Plan;
import com.ning.billing.catalog.api.PlanPhase;
import com.ning.billing.entitlement.events.EntitlementEvent;
import com.ning.billing.entitlement.events.user.ApiEventType;
-public class TestTimedMigration {
+public class TestTimedMigration extends KillbillTestSuite {
@Test(groups = "fast")
public void testConstructor() throws Exception {
final DateTime eventTime = new DateTime(DateTimeZone.UTC);
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/alignment/TestTimedPhase.java b/entitlement/src/test/java/com/ning/billing/entitlement/alignment/TestTimedPhase.java
index 75831fa..c75b6c2 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/alignment/TestTimedPhase.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/alignment/TestTimedPhase.java
@@ -22,9 +22,10 @@ import org.mockito.Mockito;
import org.testng.Assert;
import org.testng.annotations.Test;
+import com.ning.billing.KillbillTestSuite;
import com.ning.billing.catalog.api.PlanPhase;
-public class TestTimedPhase {
+public class TestTimedPhase extends KillbillTestSuite {
@Test(groups = "fast")
public void testConstructor() throws Exception {
final PlanPhase planPhase = Mockito.mock(PlanPhase.class);
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigration.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigration.java
index 961923f..a15cd77 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigration.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigration.java
@@ -47,11 +47,7 @@ import static org.testng.Assert.assertTrue;
public abstract class TestMigration extends TestApiBase {
public void testSingleBasePlan() {
-
try {
-
- log.info("Starting testSingleBasePlan");
-
final DateTime startDate = clock.getUTCNow().minusMonths(2);
final DateTime beforeMigration = clock.getUTCNow();
final EntitlementAccountMigration toBeMigrated = createAccountWithRegularBasePlan(startDate);
@@ -84,7 +80,6 @@ public abstract class TestMigration extends TestApiBase {
public void testPlanWithAddOn() {
try {
- log.info("Starting testPlanWithAddOn");
final DateTime beforeMigration = clock.getUTCNow();
final DateTime initalBPStart = clock.getUTCNow().minusMonths(3);
final DateTime initalAddonStart = clock.getUTCNow().minusMonths(1).plusDays(7);
@@ -134,7 +129,6 @@ public abstract class TestMigration extends TestApiBase {
public void testSingleBasePlanFutureCancelled() {
try {
- log.info("Starting testSingleBasePlanFutureCancelled");
final DateTime startDate = clock.getUTCNow().minusMonths(1);
final DateTime beforeMigration = clock.getUTCNow();
final EntitlementAccountMigration toBeMigrated = createAccountWithRegularBasePlanFutreCancelled(startDate);
@@ -159,7 +153,6 @@ public abstract class TestMigration extends TestApiBase {
assertEquals(subscription.getCurrentPlan().getName(), "assault-rifle-annual");
assertEquals(subscription.getChargedThroughDate(), startDate.plusYears(1));
-
testListener.pushExpectedEvent(NextEvent.MIGRATE_BILLING);
testListener.pushExpectedEvent(NextEvent.CANCEL);
@@ -176,17 +169,13 @@ public abstract class TestMigration extends TestApiBase {
assertNull(subscription.getCurrentPlan());
assertListenerStatus();
-
} catch (EntitlementMigrationApiException e) {
Assert.fail("", e);
}
}
public void testSingleBasePlanWithPendingPhase() {
-
try {
-
- log.info("Starting testSingleBasePlanWithPendingPhase");
final DateTime trialDate = clock.getUTCNow().minusDays(10);
final EntitlementAccountMigration toBeMigrated = createAccountFuturePendingPhase(trialDate);
@@ -226,16 +215,13 @@ public abstract class TestMigration extends TestApiBase {
assertEquals(subscription.getCurrentPhase().getName(), "assault-rifle-monthly-evergreen");
assertListenerStatus();
-
} catch (EntitlementMigrationApiException e) {
Assert.fail("", e);
}
}
public void testSingleBasePlanWithPendingChange() {
-
try {
- log.info("Starting testSingleBasePlanWithPendingChange");
final DateTime beforeMigration = clock.getUTCNow();
final EntitlementAccountMigration toBeMigrated = createAccountFuturePendingChange();
final DateTime afterMigration = clock.getUTCNow();
@@ -279,25 +265,19 @@ public abstract class TestMigration extends TestApiBase {
}
}
-
private EntitlementAccountMigration createAccountTest(final List<List<EntitlementSubscriptionMigrationCaseWithCTD>> cases) {
-
return new EntitlementAccountMigration() {
-
private final UUID accountId = UUID.randomUUID();
@Override
public EntitlementBundleMigration[] getBundles() {
final List<EntitlementBundleMigration> bundles = new ArrayList<EntitlementBundleMigration>();
final EntitlementBundleMigration bundle0 = new EntitlementBundleMigration() {
-
@Override
public EntitlementSubscriptionMigration[] getSubscriptions() {
-
final EntitlementSubscriptionMigration[] result = new EntitlementSubscriptionMigration[cases.size()];
for (int i = 0; i < cases.size(); i++) {
-
final List<EntitlementSubscriptionMigrationCaseWithCTD> curCases = cases.get(i);
final EntitlementSubscriptionMigration subscription = new EntitlementSubscriptionMigration() {
@Override
@@ -362,7 +342,6 @@ public abstract class TestMigration extends TestApiBase {
null,
null));
-
final List<List<EntitlementSubscriptionMigrationCaseWithCTD>> input = new ArrayList<List<EntitlementSubscriptionMigrationCaseWithCTD>>();
input.add(cases);
input.add(firstAddOnCases);
@@ -393,7 +372,6 @@ public abstract class TestMigration extends TestApiBase {
return createAccountTest(input);
}
-
private EntitlementAccountMigration createAccountFuturePendingPhase(final DateTime trialDate) {
final List<EntitlementSubscriptionMigrationCaseWithCTD> cases = new LinkedList<EntitlementSubscriptionMigrationCaseWithCTD>();
cases.add(new EntitlementSubscriptionMigrationCaseWithCTD(
@@ -429,9 +407,7 @@ public abstract class TestMigration extends TestApiBase {
return createAccountTest(input);
}
-
public static class EntitlementSubscriptionMigrationCaseWithCTD implements EntitlementSubscriptionMigrationCase {
-
private final PlanPhaseSpecifier pps;
private final DateTime effDt;
private final DateTime cancelDt;
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationMemory.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationMemory.java
index 81c12cd..e07e1c1 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationMemory.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationMemory.java
@@ -23,7 +23,6 @@ import com.google.inject.Injector;
import com.google.inject.Stage;
import com.ning.billing.entitlement.glue.MockEngineModuleMemory;
-@Test(groups = "fast")
public class TestMigrationMemory extends TestMigration {
@Override
protected Injector getInjector() {
@@ -31,26 +30,25 @@ public class TestMigrationMemory extends TestMigration {
}
@Override
- @Test(enabled = true, groups = "fast")
+ @Test(groups = "fast")
public void testSingleBasePlan() {
super.testSingleBasePlan();
}
@Override
- @Test(enabled = true, groups = "fast")
+ @Test(groups = "fast")
public void testSingleBasePlanFutureCancelled() {
super.testSingleBasePlanFutureCancelled();
}
@Override
- @Test(enabled = true, groups = "fast")
+ @Test(groups = "fast")
public void testPlanWithAddOn() {
super.testPlanWithAddOn();
}
-
@Override
- @Test(enabled = true, groups = "fast")
+ @Test(groups = "fast")
public void testSingleBasePlanWithPendingPhase() {
super.testSingleBasePlanWithPendingPhase();
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationSql.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationSql.java
index 82fc7e7..2d0b100 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationSql.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/migration/TestMigrationSql.java
@@ -30,25 +30,25 @@ public class TestMigrationSql extends TestMigration {
}
@Override
- @Test(enabled = true, groups = "slow")
+ @Test(groups = "slow")
public void testSingleBasePlan() {
super.testSingleBasePlan();
}
@Override
- @Test(enabled = true, groups = "slow")
+ @Test(groups = "slow")
public void testPlanWithAddOn() {
super.testPlanWithAddOn();
}
@Override
- @Test(enabled = true, groups = "slow")
+ @Test(groups = "slow")
public void testSingleBasePlanFutureCancelled() {
super.testSingleBasePlanFutureCancelled();
}
@Override
- @Test(enabled = true, groups = "slow")
+ @Test(groups = "slow")
public void testSingleBasePlanWithPendingPhase() {
super.testSingleBasePlanWithPendingPhase();
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/TestApiBase.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/TestApiBase.java
index 1c68f2f..55115be 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/TestApiBase.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/TestApiBase.java
@@ -51,6 +51,7 @@ import com.ning.billing.catalog.api.ProductCategory;
import com.ning.billing.catalog.api.TimeUnit;
import com.ning.billing.config.EntitlementConfig;
import com.ning.billing.dbi.MysqlTestingHelper;
+import com.ning.billing.entitlement.EntitlementTestSuiteWithEmbeddedDB;
import com.ning.billing.entitlement.api.billing.ChargeThruApi;
import com.ning.billing.entitlement.api.migration.EntitlementMigrationApi;
import com.ning.billing.entitlement.api.timeline.EntitlementTimelineApi;
@@ -61,7 +62,6 @@ import com.ning.billing.entitlement.api.user.SubscriptionBundle;
import com.ning.billing.entitlement.api.user.SubscriptionData;
import com.ning.billing.entitlement.engine.core.Engine;
import com.ning.billing.entitlement.engine.dao.EntitlementDao;
-import com.ning.billing.entitlement.engine.dao.MockEntitlementDao;
import com.ning.billing.entitlement.engine.dao.MockEntitlementDaoMemory;
import com.ning.billing.entitlement.events.EntitlementEvent;
import com.ning.billing.entitlement.events.phase.PhaseEvent;
@@ -74,14 +74,13 @@ import com.ning.billing.util.callcontext.TestCallContext;
import com.ning.billing.util.clock.Clock;
import com.ning.billing.util.clock.ClockMock;
import com.ning.billing.util.glue.RealImplementation;
-import com.ning.billing.util.io.IOUtils;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
-public abstract class TestApiBase implements TestListenerStatus {
+public abstract class TestApiBase extends EntitlementTestSuiteWithEmbeddedDB implements TestListenerStatus {
protected static final Logger log = LoggerFactory.getLogger(TestApiBase.class);
protected EntitlementService entitlementService;
@@ -114,7 +113,6 @@ public abstract class TestApiBase implements TestListenerStatus {
//
protected DateTime testStartDate = new DateTime(2012, 5, 7, 0, 3, 42, 0);
-
public static void loadSystemPropertiesFromClasspath(final String resource) {
final URL url = TestApiBase.class.getResource(resource);
assertNotNull(url);
@@ -132,15 +130,11 @@ public abstract class TestApiBase implements TestListenerStatus {
public void tearDown() {
try {
((DefaultBusService) busService).stopBus();
- if (helper != null) {
- helper.stopMysql();
- }
} catch (Exception e) {
log.warn("Failed to tearDown test properly ", e);
}
}
-
@Override
public void failed(final String msg) {
this.isListenerFailed = true;
@@ -155,13 +149,11 @@ public abstract class TestApiBase implements TestListenerStatus {
@BeforeClass(alwaysRun = true)
public void setup() throws Exception {
-
loadSystemPropertiesFromClasspath("/entitlement.properties");
final Injector g = getInjector();
entitlementService = g.getInstance(EntitlementService.class);
- final EntitlementUserApi entApi = (EntitlementUserApi) g.getInstance(Key.get(EntitlementUserApi.class, RealImplementation.class));
- entitlementApi = entApi;
+ entitlementApi = g.getInstance(Key.get(EntitlementUserApi.class, RealImplementation.class));
billingApi = g.getInstance(ChargeThruApi.class);
migrationApi = g.getInstance(EntitlementMigrationApi.class);
repairApi = g.getInstance(EntitlementTimelineApi.class);
@@ -175,9 +167,6 @@ public abstract class TestApiBase implements TestListenerStatus {
}
private void init() throws Exception {
-
- setupDao();
-
((DefaultCatalogService) catalogService).loadCatalog();
accountData = getAccountData();
@@ -187,27 +176,19 @@ public abstract class TestApiBase implements TestListenerStatus {
testListener = new TestApiListener(this);
}
- private void setupDao() throws IOException {
- if (helper != null) {
- final String entitlementDdl = IOUtils.toString(TestApiBase.class.getResourceAsStream("/com/ning/billing/entitlement/ddl.sql"));
- final String utilDdl = IOUtils.toString(TestApiBase.class.getResourceAsStream("/com/ning/billing/util/ddl.sql"));
- helper.startMysql();
- helper.initDb(entitlementDdl);
- helper.initDb(utilDdl);
- }
- }
-
private static boolean isSqlTest(final EntitlementDao theDao) {
return (!(theDao instanceof MockEntitlementDaoMemory));
}
@BeforeMethod(alwaysRun = true)
public void setupTest() throws Exception {
-
- log.warn("RESET TEST FRAMEWORK\n\n");
+ log.warn("RESET TEST FRAMEWORK");
// CLEANUP ALL DB TABLES OR IN MEMORY STRUCTURES
- cleanupDao();
+ if (!isSqlTest(dao)) {
+ // The MySQL testing helper will clean the tables between each test
+ ((MockEntitlementDaoMemory) dao).reset();
+ }
// RESET LIST OF EXPECTED EVENTS
if (testListener != null) {
@@ -237,7 +218,6 @@ public abstract class TestApiBase implements TestListenerStatus {
@AfterMethod(alwaysRun = true)
public void cleanupTest() throws Exception {
-
// UNREGISTER TEST LISTENER AND STOP BUS
busService.getBus().unregister(testListener);
busService.getBus().stop();
@@ -245,7 +225,7 @@ public abstract class TestApiBase implements TestListenerStatus {
// STOP NOTIFICATION QUEUE
((Engine) entitlementService).stop();
- log.warn("DONE WITH TEST\n");
+ log.warn("DONE WITH TEST");
}
protected void assertListenerStatus() {
@@ -255,14 +235,6 @@ public abstract class TestApiBase implements TestListenerStatus {
}
}
- private void cleanupDao() {
- if (helper != null) {
- helper.cleanupAllTables();
- } else {
- ((MockEntitlementDao) dao).reset();
- }
- }
-
protected SubscriptionData createSubscription(final String productName, final BillingPeriod term, final String planSet, final DateTime requestedDate)
throws EntitlementUserApiException {
return createSubscriptionWithBundle(bundle.getId(), productName, term, planSet, requestedDate);
@@ -275,7 +247,6 @@ public abstract class TestApiBase implements TestListenerStatus {
protected SubscriptionData createSubscriptionWithBundle(final UUID bundleId, final String productName, final BillingPeriod term, final String planSet, final DateTime requestedDate)
throws EntitlementUserApiException {
-
testListener.pushExpectedEvent(NextEvent.CREATE);
final SubscriptionData subscription = (SubscriptionData) entitlementApi.createSubscription(bundleId,
new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSet, null),
@@ -286,7 +257,6 @@ public abstract class TestApiBase implements TestListenerStatus {
}
protected void checkNextPhaseChange(final SubscriptionData subscription, final int expPendingEvents, final DateTime expPhaseChange) {
-
final List<EntitlementEvent> events = dao.getPendingEventsForSubscription(subscription.getId());
assertNotNull(events);
printEvents(events);
@@ -367,7 +337,6 @@ public abstract class TestApiBase implements TestListenerStatus {
return result;
}
-
protected Duration getDurationYear(final int years) {
final Duration result = new Duration() {
@Override
@@ -510,5 +479,4 @@ public abstract class TestApiBase implements TestListenerStatus {
log.debug("Transition " + cur);
}
}
-
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/TestEventJson.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/TestEventJson.java
index e53115f..53c266b 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/TestEventJson.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/TestEventJson.java
@@ -13,6 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
+
package com.ning.billing.entitlement.api;
import java.util.UUID;
@@ -21,6 +22,7 @@ import org.joda.time.DateTime;
import org.testng.Assert;
import org.testng.annotations.Test;
+import com.ning.billing.entitlement.EntitlementTestSuite;
import com.ning.billing.entitlement.api.timeline.DefaultRepairEntitlementEvent;
import com.ning.billing.entitlement.api.timeline.RepairEntitlementEvent;
import com.ning.billing.entitlement.api.user.DefaultEffectiveSubscriptionEvent;
@@ -28,25 +30,23 @@ import com.ning.billing.entitlement.api.user.EffectiveSubscriptionEvent;
import com.ning.billing.entitlement.api.user.Subscription.SubscriptionState;
import com.ning.billing.util.jackson.ObjectMapper;
-public class TestEventJson {
+public class TestEventJson extends EntitlementTestSuite {
private final ObjectMapper mapper = new ObjectMapper();
- @Test(groups = {"fast"})
+ @Test(groups = "fast")
public void testSubscriptionEvent() throws Exception {
-
final EffectiveSubscriptionEvent e = new DefaultEffectiveSubscriptionEvent(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), new DateTime(), new DateTime(),
- SubscriptionState.ACTIVE, "pro", "TRIAL", "DEFAULT", SubscriptionState.CANCELLED, null, null, null, 3L, UUID.randomUUID(), SubscriptionTransitionType.CANCEL, 0, new DateTime());
+ SubscriptionState.ACTIVE, "pro", "TRIAL", "DEFAULT", SubscriptionState.CANCELLED, null, null, null, 3L, UUID.randomUUID(), SubscriptionTransitionType.CANCEL, 0, new DateTime());
final String json = mapper.writeValueAsString(e);
final Class<?> claz = Class.forName(DefaultEffectiveSubscriptionEvent.class.getName());
final Object obj = mapper.readValue(json, claz);
Assert.assertTrue(obj.equals(e));
-
}
- @Test(groups = {"fast"})
+ @Test(groups = "fast")
public void testRepairEntitlementEvent() throws Exception {
final RepairEntitlementEvent e = new DefaultRepairEntitlementEvent(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), new DateTime());
@@ -56,6 +56,4 @@ public class TestEventJson {
final Object obj = mapper.readValue(json, claz);
Assert.assertTrue(obj.equals(e));
}
-
-
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestApiBaseRepair.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestApiBaseRepair.java
index 292dc37..449d1e7 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestApiBaseRepair.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestApiBaseRepair.java
@@ -13,6 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
+
package com.ning.billing.entitlement.api.timeline;
import java.util.Collections;
@@ -39,9 +40,7 @@ import com.ning.billing.entitlement.api.user.EntitlementUserApiException;
import static org.testng.Assert.assertEquals;
-
public abstract class TestApiBaseRepair extends TestApiBase {
-
protected static final Logger log = LoggerFactory.getLogger(TestApiBaseRepair.class);
public interface TestWithExceptionCallback {
@@ -59,7 +58,6 @@ public abstract class TestApiBaseRepair extends TestApiBase {
}
}
-
protected SubscriptionTimeline createSubscriptionRepair(final UUID id, final List<DeletedEvent> deletedEvents, final List<NewEvent> newEvents) {
return new SubscriptionTimeline() {
@Override
@@ -111,9 +109,8 @@ public abstract class TestApiBaseRepair extends TestApiBase {
protected ExistingEvent createExistingEventForAssertion(final SubscriptionTransitionType type,
final String productName, final PhaseType phaseType, final ProductCategory category, final String priceListName, final BillingPeriod billingPeriod,
final DateTime effectiveDateTime) {
-
final PlanPhaseSpecifier spec = new PlanPhaseSpecifier(productName, category, billingPeriod, priceListName, phaseType);
- final ExistingEvent ev = new ExistingEvent() {
+ return new ExistingEvent() {
@Override
public SubscriptionTransitionType getSubscriptionTransitionType() {
return type;
@@ -139,7 +136,6 @@ public abstract class TestApiBaseRepair extends TestApiBase {
return effectiveDateTime;
}
};
- return ev;
}
protected SubscriptionTimeline getSubscriptionRepair(final UUID id, final BundleTimeline bundleRepair) {
@@ -148,12 +144,11 @@ public abstract class TestApiBaseRepair extends TestApiBase {
return cur;
}
}
- Assert.fail("Failed to find SubscriptionReapir " + id);
+ Assert.fail("Failed to find SubscriptionRepair " + id);
return null;
}
protected void validateExistingEventForAssertion(final ExistingEvent expected, final ExistingEvent input) {
-
log.info(String.format("Got %s -> Expected %s", input.getPlanPhaseSpecifier().getProductName(), expected.getPlanPhaseSpecifier().getProductName()));
assertEquals(input.getPlanPhaseSpecifier().getProductName(), expected.getPlanPhaseSpecifier().getProductName());
log.info(String.format("Got %s -> Expected %s", input.getPlanPhaseSpecifier().getPhaseType(), expected.getPlanPhaseSpecifier().getPhaseType()));
@@ -178,7 +173,6 @@ public abstract class TestApiBaseRepair extends TestApiBase {
}
protected NewEvent createNewEvent(final SubscriptionTransitionType type, final DateTime requestedDate, final PlanPhaseSpecifier spec) {
-
return new NewEvent() {
@Override
public SubscriptionTransitionType getSubscriptionTransitionType() {
@@ -228,5 +222,4 @@ public abstract class TestApiBaseRepair extends TestApiBase {
}
});
}
-
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestRepairBP.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestRepairBP.java
index af685e4..a81d71b 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestRepairBP.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestRepairBP.java
@@ -13,6 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
+
package com.ning.billing.entitlement.api.timeline;
import java.util.Collections;
@@ -53,17 +54,13 @@ import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
public class TestRepairBP extends TestApiBaseRepair {
-
@Override
public Injector getInjector() {
return Guice.createInjector(Stage.DEVELOPMENT, new MockEngineModuleSql());
}
- @Test(groups = {"slow"})
+ @Test(groups = "slow")
public void testFetchBundleRepair() throws Exception {
-
- log.info("Starting testFetchBundleRepair");
-
final String baseProduct = "Shotgun";
final BillingPeriod baseTerm = BillingPeriod.MONTHLY;
final String basePriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -126,11 +123,8 @@ public class TestRepairBP extends TestApiBaseRepair {
}
//TODO MDW: Temporary disable need to look at this with Stephane
- @Test(groups = {"slow"}, enabled = false)
+ @Test(groups = "slow", enabled = false)
public void testBPRepairWithCancellationOnstart() throws Exception {
-
- log.info("Starting testBPRepairWithCancellationOnstart");
-
final String baseProduct = "Shotgun";
final DateTime startDate = clock.getUTCNow();
@@ -205,7 +199,6 @@ public class TestRepairBP extends TestApiBaseRepair {
final SubscriptionData realRunBaseSubscription = (SubscriptionData) entitlementApi.getSubscriptionFromId(baseSubscription.getId());
assertEquals(realRunBaseSubscription.getAllTransitions().size(), 2);
-
assertEquals(realRunBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
assertEquals(realRunBaseSubscription.getBundleId(), bundle.getId());
assertEquals(realRunBaseSubscription.getStartDate(), startDate);
@@ -215,11 +208,8 @@ public class TestRepairBP extends TestApiBaseRepair {
assertListenerStatus();
}
- @Test(groups = {"slow"})
+ @Test(groups = "slow")
public void testBPRepairReplaceCreateBeforeTrial() throws Exception {
-
- log.info("Starting testBPRepairReplaceCreateBeforeTrial");
-
final String baseProduct = "Shotgun";
final String newBaseProduct = "Assault-Rifle";
@@ -237,11 +227,8 @@ public class TestRepairBP extends TestApiBaseRepair {
assertListenerStatus();
}
- @Test(groups = {"slow"}, enabled = true)
+ @Test(groups = "slow")
public void testBPRepairReplaceCreateInTrial() throws Exception {
-
- log.info("Starting testBPRepairReplaceCreateInTrial");
-
final String baseProduct = "Shotgun";
final String newBaseProduct = "Assault-Rifle";
@@ -283,12 +270,8 @@ public class TestRepairBP extends TestApiBaseRepair {
assertListenerStatus();
}
-
- @Test(groups = {"slow"})
+ @Test(groups = "slow")
public void testBPRepairReplaceCreateAfterTrial() throws Exception {
-
- log.info("Starting testBPRepairReplaceCreateAfterTrial");
-
final String baseProduct = "Shotgun";
final String newBaseProduct = "Assault-Rifle";
@@ -306,12 +289,8 @@ public class TestRepairBP extends TestApiBaseRepair {
assertListenerStatus();
}
-
private UUID testBPRepairCreate(final boolean inTrial, final DateTime startDate, final int clockShift,
final String baseProduct, final String newBaseProduct, final List<ExistingEvent> expectedEvents) throws Exception {
-
- log.info("Starting testBPRepairCreate");
-
// CREATE BP
final Subscription baseSubscription = createSubscription(baseProduct, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, startDate);
@@ -400,7 +379,6 @@ public class TestRepairBP extends TestApiBaseRepair {
final SubscriptionData realRunBaseSubscription = (SubscriptionData) entitlementApi.getSubscriptionFromId(baseSubscription.getId());
assertEquals(realRunBaseSubscription.getAllTransitions().size(), 2);
-
assertEquals(realRunBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
assertEquals(realRunBaseSubscription.getBundleId(), bundle.getId());
assertEquals(realRunBaseSubscription.getStartDate(), newCreateTime);
@@ -418,11 +396,8 @@ public class TestRepairBP extends TestApiBaseRepair {
return baseSubscription.getId();
}
- @Test(groups = {"slow"})
+ @Test(groups = "slow")
public void testBPRepairAddChangeInTrial() throws Exception {
-
- log.info("Starting testBPRepairAddChangeInTrial");
-
final String baseProduct = "Shotgun";
final String newBaseProduct = "Assault-Rifle";
@@ -465,11 +440,8 @@ public class TestRepairBP extends TestApiBaseRepair {
assertListenerStatus();
}
- @Test(groups = {"slow"})
+ @Test(groups = "slow")
public void testBPRepairAddChangeAfterTrial() throws Exception {
-
- log.info("Starting testBPRepairAddChangeAfterTrial");
-
final String baseProduct = "Shotgun";
final String newBaseProduct = "Assault-Rifle";
@@ -489,11 +461,8 @@ public class TestRepairBP extends TestApiBaseRepair {
assertListenerStatus();
}
-
private UUID testBPRepairAddChange(final boolean inTrial, final DateTime startDate, final int clockShift,
final String baseProduct, final String newBaseProduct, final List<ExistingEvent> expectedEvents, final int expectedTransitions) throws Exception {
-
-
// CREATE BP
final Subscription baseSubscription = createSubscription(baseProduct, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, startDate);
@@ -559,7 +528,6 @@ public class TestRepairBP extends TestApiBaseRepair {
assertEquals(currentPhase.getPhaseType(), PhaseType.EVERGREEN);
}
-
// SECOND RE-ISSUE CALL-- NON DRY RUN
dryRun = false;
testListener.pushExpectedEvent(NextEvent.REPAIR_BUNDLE);
@@ -580,7 +548,6 @@ public class TestRepairBP extends TestApiBaseRepair {
final SubscriptionData realRunBaseSubscription = (SubscriptionData) entitlementApi.getSubscriptionFromId(baseSubscription.getId());
assertEquals(realRunBaseSubscription.getAllTransitions().size(), expectedTransitions);
-
assertEquals(realRunBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
assertEquals(realRunBaseSubscription.getBundleId(), bundle.getId());
assertEquals(realRunBaseSubscription.getStartDate(), baseSubscription.getStartDate());
@@ -601,11 +568,8 @@ public class TestRepairBP extends TestApiBaseRepair {
return baseSubscription.getId();
}
- @Test(groups = {"slow"})
- public void testRepairWithFurureCancelEvent() throws Exception {
-
- log.info("Starting testRepairWithFurureCancelEvent");
-
+ @Test(groups = "slow")
+ public void testRepairWithFutureCancelEvent() throws Exception {
final DateTime startDate = clock.getUTCNow();
// CREATE BP
@@ -623,11 +587,9 @@ public class TestRepairBP extends TestApiBaseRepair {
billingApi.setChargedThroughDate(baseSubscription.getId(), newChargedThroughDate, context);
baseSubscription = (SubscriptionData) entitlementApi.getSubscriptionFromId(baseSubscription.getId());
-
final DateTime requestedChange = clock.getUTCNow();
baseSubscription.changePlan("Pistol", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, requestedChange, context);
-
// CHECK CHANGE DID NOT OCCUR YET
Plan currentPlan = baseSubscription.getCurrentPlan();
assertNotNull(currentPlan);
@@ -635,7 +597,6 @@ public class TestRepairBP extends TestApiBaseRepair {
assertEquals(currentPlan.getProduct().getCategory(), ProductCategory.BASE);
assertEquals(currentPlan.getBillingPeriod(), BillingPeriod.MONTHLY);
-
final DateTime repairTime = clock.getUTCNow().minusDays(1);
final BundleTimeline bundleRepair = repairApi.getBundleRepair(bundle.getId());
sortEventsOnBundle(bundleRepair);
@@ -675,13 +636,9 @@ public class TestRepairBP extends TestApiBaseRepair {
assertListenerStatus();
}
-
// Needs real SQL backend to be tested properly
- @Test(groups = {"slow"})
+ @Test(groups = "slow")
public void testENT_REPAIR_VIEW_CHANGED_newEvent() throws Exception {
-
- log.info("Starting testENT_REPAIR_VIEW_CHANGED_newEvent");
-
final TestWithException test = new TestWithException();
final DateTime startDate = clock.getUTCNow();
@@ -713,11 +670,8 @@ public class TestRepairBP extends TestApiBaseRepair {
}, ErrorCode.ENT_REPAIR_VIEW_CHANGED);
}
- @Test(groups = {"slow"}, enabled = false)
+ @Test(groups = "slow", enabled = false)
public void testENT_REPAIR_VIEW_CHANGED_ctd() throws Exception {
-
- log.info("Starting testENT_REPAIR_VIEW_CHANGED_ctd");
-
final TestWithException test = new TestWithException();
final DateTime startDate = clock.getUTCNow();
@@ -748,5 +702,4 @@ public class TestRepairBP extends TestApiBaseRepair {
}
}, ErrorCode.ENT_REPAIR_VIEW_CHANGED);
}
-
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestRepairWithAO.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestRepairWithAO.java
index 85116a3..7757cec 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestRepairWithAO.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestRepairWithAO.java
@@ -13,6 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
+
package com.ning.billing.entitlement.api.timeline;
import java.util.Collections;
@@ -48,17 +49,13 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
public class TestRepairWithAO extends TestApiBaseRepair {
-
@Override
public Injector getInjector() {
return Guice.createInjector(Stage.DEVELOPMENT, new MockEngineModuleSql());
}
- @Test(groups = {"slow"})
+ @Test(groups = "slow")
public void testRepairChangeBPWithAddonIncluded() throws Exception {
-
- log.info("Starting testRepairChangeBPWithAddonIncluded");
-
final String baseProduct = "Shotgun";
final BillingPeriod baseTerm = BillingPeriod.MONTHLY;
final String basePriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -149,7 +146,6 @@ public class TestRepairWithAO extends TestApiBaseRepair {
validateExistingEventForAssertion(e, bpRepair.getExistingEvents().get(index++));
}
-
SubscriptionData newAoSubscription = (SubscriptionData) entitlementApi.getSubscriptionFromId(aoSubscription.getId());
assertEquals(newAoSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newAoSubscription.getAllTransitions().size(), 2);
@@ -160,7 +156,6 @@ public class TestRepairWithAO extends TestApiBaseRepair {
assertEquals(newAoSubscription2.getAllTransitions().size(), 2);
assertEquals(newAoSubscription2.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
-
SubscriptionData newBaseSubscription = (SubscriptionData) entitlementApi.getSubscriptionFromId(baseSubscription.getId());
assertEquals(newBaseSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newBaseSubscription.getAllTransitions().size(), 2);
@@ -171,7 +166,6 @@ public class TestRepairWithAO extends TestApiBaseRepair {
final BundleTimeline realRunBundleRepair = repairApi.repairBundle(bundleRepair, dryRun, context);
assertTrue(testListener.isCompleted(5000));
-
aoRepair = getSubscriptionRepair(aoSubscription.getId(), realRunBundleRepair);
assertEquals(aoRepair.getExistingEvents().size(), 2);
@@ -203,18 +197,14 @@ public class TestRepairWithAO extends TestApiBaseRepair {
assertEquals(newAoSubscription2.getAllTransitions().size(), 2);
assertEquals(newAoSubscription2.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
-
newBaseSubscription = (SubscriptionData) entitlementApi.getSubscriptionFromId(baseSubscription.getId());
assertEquals(newBaseSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newBaseSubscription.getAllTransitions().size(), 3);
assertEquals(newBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
}
- @Test(groups = {"slow"})
+ @Test(groups = "slow")
public void testRepairChangeBPWithAddonNonAvailable() throws Exception {
-
- log.info("Starting testRepairChangeBPWithAddonNonAvailable");
-
final String baseProduct = "Shotgun";
final BillingPeriod baseTerm = BillingPeriod.MONTHLY;
final String basePriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -332,11 +322,8 @@ public class TestRepairWithAO extends TestApiBaseRepair {
assertEquals(newBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
}
- @Test(groups = {"slow"})
+ @Test(groups = "slow")
public void testRepairCancelBP_EOT_WithAddons() throws Exception {
-
- log.info("Starting testRepairCancelBP_EOT_WithAddons");
-
final String baseProduct = "Shotgun";
final BillingPeriod baseTerm = BillingPeriod.MONTHLY;
final String basePriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -348,7 +335,6 @@ public class TestRepairWithAO extends TestApiBaseRepair {
Interval it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(4));
clock.addDeltaFromReality(it.toDurationMillis());
-
final SubscriptionData aoSubscription = createSubscription("Telescopic-Scope", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
// MOVE CLOCK A LITTLE BIT MORE -- AFTER TRIAL
@@ -475,12 +461,8 @@ public class TestRepairWithAO extends TestApiBaseRepair {
assertEquals(newBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
}
-
- @Test(groups = {"slow"})
+ @Test(groups = "slow")
public void testRepairCancelAO() throws Exception {
-
- log.info("Starting testRepairCancelAO");
-
final String baseProduct = "Shotgun";
final BillingPeriod baseTerm = BillingPeriod.MONTHLY;
final String basePriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -508,7 +490,6 @@ public class TestRepairWithAO extends TestApiBaseRepair {
SubscriptionTimeline aoRepair = getSubscriptionRepair(aoSubscription.getId(), bundleRepair);
assertEquals(aoRepair.getExistingEvents().size(), 2);
-
final List<DeletedEvent> des = new LinkedList<SubscriptionTimeline.DeletedEvent>();
des.add(createDeletedEvent(aoRepair.getExistingEvents().get(1).getEventId()));
final DateTime aoCancelDate = aoSubscription.getStartDate().plusDays(1);
@@ -552,7 +533,6 @@ public class TestRepairWithAO extends TestApiBaseRepair {
final BundleTimeline realRunBundleRepair = repairApi.repairBundle(bRepair, dryRun, context);
assertTrue(testListener.isCompleted(5000));
-
aoRepair = getSubscriptionRepair(aoSubscription.getId(), realRunBundleRepair);
assertEquals(aoRepair.getExistingEvents().size(), 2);
index = 0;
@@ -571,12 +551,8 @@ public class TestRepairWithAO extends TestApiBaseRepair {
assertEquals(newBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
}
-
- @Test(groups = {"slow"})
+ @Test(groups = "slow")
public void testRepairRecreateAO() throws Exception {
-
- log.info("Starting testRepairRecreateAO");
-
final String baseProduct = "Shotgun";
final BillingPeriod baseTerm = BillingPeriod.MONTHLY;
final String basePriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -604,7 +580,6 @@ public class TestRepairWithAO extends TestApiBaseRepair {
SubscriptionTimeline aoRepair = getSubscriptionRepair(aoSubscription.getId(), bundleRepair);
assertEquals(aoRepair.getExistingEvents().size(), 2);
-
final List<DeletedEvent> des = new LinkedList<SubscriptionTimeline.DeletedEvent>();
des.add(createDeletedEvent(aoRepair.getExistingEvents().get(0).getEventId()));
des.add(createDeletedEvent(aoRepair.getExistingEvents().get(1).getEventId()));
@@ -623,7 +598,6 @@ public class TestRepairWithAO extends TestApiBaseRepair {
aoRepair = getSubscriptionRepair(aoSubscription.getId(), dryRunBundleRepair);
assertEquals(aoRepair.getExistingEvents().size(), 2);
-
final List<ExistingEvent> expected = new LinkedList<SubscriptionTimeline.ExistingEvent>();
expected.add(createExistingEventForAssertion(SubscriptionTransitionType.CREATE, "Telescopic-Scope", PhaseType.DISCOUNT,
ProductCategory.ADD_ON, PriceListSet.DEFAULT_PRICELIST_NAME, BillingPeriod.MONTHLY, aoRecreateDate));
@@ -668,11 +642,8 @@ public class TestRepairWithAO extends TestApiBaseRepair {
// . Both multi phase
// . Telescopic-Scope (bundle align) and Laser-Scope is Subscription align
//
- @Test(groups = {"slow"})
+ @Test(groups = "slow")
public void testRepairChangeAOOK() throws Exception {
-
- log.info("Starting testRepairChangeAOOK");
-
final String baseProduct = "Shotgun";
final BillingPeriod baseTerm = BillingPeriod.MONTHLY;
final String basePriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -716,7 +687,6 @@ public class TestRepairWithAO extends TestApiBaseRepair {
aoRepair = getSubscriptionRepair(aoSubscription.getId(), dryRunBundleRepair);
assertEquals(aoRepair.getExistingEvents().size(), 3);
-
final List<ExistingEvent> expected = new LinkedList<SubscriptionTimeline.ExistingEvent>();
expected.add(createExistingEventForAssertion(SubscriptionTransitionType.CREATE, "Telescopic-Scope", PhaseType.DISCOUNT,
ProductCategory.ADD_ON, PriceListSet.DEFAULT_PRICELIST_NAME, BillingPeriod.MONTHLY, aoSubscription.getStartDate()));
@@ -751,7 +721,6 @@ public class TestRepairWithAO extends TestApiBaseRepair {
assertEquals(newAoSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newAoSubscription.getAllTransitions().size(), 3);
-
assertEquals(newAoSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
assertEquals(newAoSubscription.getBundleId(), bundle.getId());
assertEquals(newAoSubscription.getStartDate(), aoSubscription.getStartDate());
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestRepairWithError.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestRepairWithError.java
index 7c61f4f..6c1d506 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestRepairWithError.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/timeline/TestRepairWithError.java
@@ -13,6 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
+
package com.ning.billing.entitlement.api.timeline;
import java.util.Collections;
@@ -47,7 +48,6 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
public class TestRepairWithError extends TestApiBaseRepair {
-
private static final String baseProduct = "Shotgun";
private TestWithException test;
private Subscription baseSubscription;
@@ -65,15 +65,11 @@ public class TestRepairWithError extends TestApiBaseRepair {
baseSubscription = createSubscription(baseProduct, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, startDate);
}
- @Test(groups = {"fast"})
+ @Test(groups = "fast")
public void testENT_REPAIR_NEW_EVENT_BEFORE_LAST_BP_REMAINING() throws Exception {
-
- log.info("Starting testENT_REPAIR_NEW_EVENT_BEFORE_LAST_BP_REMAINING");
-
test.withException(new TestWithExceptionCallback() {
@Override
public void doTest() throws EntitlementRepairException {
-
// MOVE AFTER TRIAL
testListener.pushExpectedEvent(NextEvent.PHASE);
@@ -96,11 +92,8 @@ public class TestRepairWithError extends TestApiBaseRepair {
}, ErrorCode.ENT_REPAIR_NEW_EVENT_BEFORE_LAST_BP_REMAINING);
}
- @Test(groups = {"fast"})
+ @Test(groups = "fast")
public void testENT_REPAIR_INVALID_DELETE_SET() throws Exception {
-
- log.info("Starting testENT_REPAIR_INVALID_DELETE_SET");
-
test.withException(new TestWithExceptionCallback() {
@Override
public void doTest() throws EntitlementRepairException, EntitlementUserApiException {
@@ -133,11 +126,8 @@ public class TestRepairWithError extends TestApiBaseRepair {
}, ErrorCode.ENT_REPAIR_INVALID_DELETE_SET);
}
- @Test(groups = {"fast"})
+ @Test(groups = "fast")
public void testENT_REPAIR_NON_EXISTENT_DELETE_EVENT() throws Exception {
-
- log.info("Starting testENT_REPAIR_NON_EXISTENT_DELETE_EVENT");
-
test.withException(new TestWithExceptionCallback() {
@Override
public void doTest() throws EntitlementRepairException {
@@ -156,11 +146,8 @@ public class TestRepairWithError extends TestApiBaseRepair {
}, ErrorCode.ENT_REPAIR_NON_EXISTENT_DELETE_EVENT);
}
- @Test(groups = {"fast"})
+ @Test(groups = "fast")
public void testENT_REPAIR_SUB_RECREATE_NOT_EMPTY() throws Exception {
-
- log.info("Starting testENT_REPAIR_SUB_RECREATE_NOT_EMPTY");
-
test.withException(new TestWithExceptionCallback() {
@Override
public void doTest() throws EntitlementRepairException {
@@ -187,11 +174,8 @@ public class TestRepairWithError extends TestApiBaseRepair {
}, ErrorCode.ENT_REPAIR_SUB_RECREATE_NOT_EMPTY);
}
- @Test(groups = {"fast"})
+ @Test(groups = "fast")
public void testENT_REPAIR_SUB_EMPTY() throws Exception {
-
- log.info("Starting testENT_REPAIR_SUB_EMPTY");
-
test.withException(new TestWithExceptionCallback() {
@Override
@@ -219,16 +203,11 @@ public class TestRepairWithError extends TestApiBaseRepair {
}, ErrorCode.ENT_REPAIR_SUB_EMPTY);
}
- @Test(groups = {"fast"})
+ @Test(groups = "fast")
public void testENT_REPAIR_AO_CREATE_BEFORE_BP_START() throws Exception {
-
- log.info("Starting testENT_REPAIR_AO_CREATE_BEFORE_BP_START");
-
test.withException(new TestWithExceptionCallback() {
@Override
public void doTest() throws EntitlementRepairException, EntitlementUserApiException {
-
-
// MOVE CLOCK A LITTLE BIT-- STILL IN TRIAL
Interval it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(4));
clock.addDeltaFromReality(it.toDurationMillis());
@@ -248,7 +227,6 @@ public class TestRepairWithError extends TestApiBaseRepair {
final SubscriptionTimeline aoRepair = getSubscriptionRepair(aoSubscription.getId(), bundleRepair);
assertEquals(aoRepair.getExistingEvents().size(), 2);
-
final List<DeletedEvent> des = new LinkedList<SubscriptionTimeline.DeletedEvent>();
des.add(createDeletedEvent(aoRepair.getExistingEvents().get(0).getEventId()));
des.add(createDeletedEvent(aoRepair.getExistingEvents().get(1).getEventId()));
@@ -267,16 +245,12 @@ public class TestRepairWithError extends TestApiBaseRepair {
}, ErrorCode.ENT_REPAIR_AO_CREATE_BEFORE_BP_START);
}
- @Test(groups = {"fast"})
+ @Test(groups = "fast")
public void testENT_REPAIR_NEW_EVENT_BEFORE_LAST_AO_REMAINING() throws Exception {
-
- log.info("Starting testENT_REPAIR_NEW_EVENT_BEFORE_LAST_AO_REMAINING");
-
test.withException(new TestWithExceptionCallback() {
@Override
public void doTest() throws EntitlementRepairException, EntitlementUserApiException {
-
// MOVE CLOCK A LITTLE BIT-- STILL IN TRIAL
Interval it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(4));
clock.addDeltaFromReality(it.toDurationMillis());
@@ -296,7 +270,6 @@ public class TestRepairWithError extends TestApiBaseRepair {
final SubscriptionTimeline aoRepair = getSubscriptionRepair(aoSubscription.getId(), bundleRepair);
assertEquals(aoRepair.getExistingEvents().size(), 2);
-
final List<DeletedEvent> des = new LinkedList<SubscriptionTimeline.DeletedEvent>();
//des.add(createDeletedEvent(aoRepair.getExistingEvents().get(1).getEventId()));
final DateTime aoCancelDate = aoSubscription.getStartDate().plusDays(10);
@@ -313,12 +286,8 @@ public class TestRepairWithError extends TestApiBaseRepair {
}, ErrorCode.ENT_REPAIR_NEW_EVENT_BEFORE_LAST_AO_REMAINING);
}
-
- @Test(groups = {"fast"})
+ @Test(groups = "fast")
public void testENT_REPAIR_BP_RECREATE_MISSING_AO() throws Exception {
-
- log.info("Starting testENT_REPAIR_BP_RECREATE_MISSING_AO");
-
test.withException(new TestWithExceptionCallback() {
@Override
public void doTest() throws EntitlementRepairException, EntitlementUserApiException {
@@ -357,11 +326,8 @@ public class TestRepairWithError extends TestApiBaseRepair {
//
// CAN'T seem to trigger such case easily, other errors trigger before...
//
- @Test(groups = {"fast"}, enabled = false)
+ @Test(groups = "fast", enabled = false)
public void testENT_REPAIR_BP_RECREATE_MISSING_AO_CREATE() throws Exception {
-
- log.info("Starting testENT_REPAIR_BP_RECREATE_MISSING_AO_CREATE");
-
test.withException(new TestWithExceptionCallback() {
@Override
public void doTest() throws EntitlementRepairException, EntitlementUserApiException {
@@ -406,16 +372,12 @@ public class TestRepairWithError extends TestApiBaseRepair {
}, ErrorCode.ENT_REPAIR_BP_RECREATE_MISSING_AO_CREATE);
}
- @Test(groups = {"fast"}, enabled = false)
+ @Test(groups = "fast", enabled = false)
public void testENT_REPAIR_MISSING_AO_DELETE_EVENT() throws Exception {
-
- log.info("Starting testENT_REPAIR_MISSING_AO_DELETE_EVENT");
-
test.withException(new TestWithExceptionCallback() {
@Override
public void doTest() throws EntitlementRepairException, EntitlementUserApiException {
-
/*
// MOVE CLOCK -- JUST BEFORE END OF TRIAL
*
@@ -460,5 +422,4 @@ public class TestRepairWithError extends TestApiBaseRepair {
}
}, ErrorCode.ENT_REPAIR_MISSING_AO_DELETE_EVENT);
}
-
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiAddOn.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiAddOn.java
index 182974b..2571b6f 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiAddOn.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiAddOn.java
@@ -49,17 +49,13 @@ import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
public class TestUserApiAddOn extends TestApiBase {
-
@Override
public Injector getInjector() {
return Guice.createInjector(Stage.DEVELOPMENT, new MockEngineModuleSql());
}
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testCreateCancelAddon() {
-
- log.info("Starting testCreateCancelAddon");
-
try {
final String baseProduct = "Shotgun";
final BillingPeriod baseTerm = BillingPeriod.MONTHLY;
@@ -89,13 +85,9 @@ public class TestUserApiAddOn extends TestApiBase {
}
}
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testCancelBPWithAddon() {
-
- log.info("Starting testCancelBPWithAddon");
-
try {
-
final String baseProduct = "Shotgun";
final BillingPeriod baseTerm = BillingPeriod.MONTHLY;
final String basePriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -154,14 +146,9 @@ public class TestUserApiAddOn extends TestApiBase {
}
}
-
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testChangeBPWithAddonIncluded() {
-
- log.info("Starting testChangeBPWithAddonIncluded");
-
try {
-
final String baseProduct = "Shotgun";
final BillingPeriod baseTerm = BillingPeriod.MONTHLY;
final String basePriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -221,13 +208,9 @@ public class TestUserApiAddOn extends TestApiBase {
}
}
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testChangeBPWithAddonNonAvailable() {
-
- log.info("Starting testChangeBPWithAddonNonAvailable");
-
try {
-
final String baseProduct = "Shotgun";
final BillingPeriod baseTerm = BillingPeriod.MONTHLY;
final String basePriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -286,7 +269,6 @@ public class TestUserApiAddOn extends TestApiBase {
clock.addDeltaFromReality(it.toDurationMillis());
assertTrue(testListener.isCompleted(5000));
-
// REFETCH AO SUBSCRIPTION AND CHECK THIS CANCELLED
aoSubscription = (SubscriptionData) entitlementApi.getSubscriptionFromId(aoSubscription.getId());
assertEquals(aoSubscription.getState(), SubscriptionState.CANCELLED);
@@ -297,12 +279,8 @@ public class TestUserApiAddOn extends TestApiBase {
}
}
-
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testAddonCreateWithBundleAlign() {
-
- log.info("Starting testAddonCreateWithBundleAlign");
-
try {
final String aoProduct = "Telescopic-Scope";
final BillingPeriod aoTerm = BillingPeriod.MONTHLY;
@@ -310,9 +288,9 @@ public class TestUserApiAddOn extends TestApiBase {
// This is just to double check our test catalog gives us what we want before we start the test
final PlanSpecifier planSpecifier = new PlanSpecifier(aoProduct,
- ProductCategory.ADD_ON,
- aoTerm,
- aoPriceList);
+ ProductCategory.ADD_ON,
+ aoTerm,
+ aoPriceList);
final PlanAlignmentCreate alignement = catalog.planCreateAlignment(planSpecifier, clock.getUTCNow());
assertEquals(alignement, PlanAlignmentCreate.START_OF_BUNDLE);
@@ -324,11 +302,8 @@ public class TestUserApiAddOn extends TestApiBase {
}
}
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testAddonCreateWithSubscriptionAlign() {
-
- log.info("Starting testAddonCreateWithSubscriptionAlign");
-
try {
final String aoProduct = "Laser-Scope";
final BillingPeriod aoTerm = BillingPeriod.MONTHLY;
@@ -336,9 +311,9 @@ public class TestUserApiAddOn extends TestApiBase {
// This is just to double check our test catalog gives us what we want before we start the test
final PlanSpecifier planSpecifier = new PlanSpecifier(aoProduct,
- ProductCategory.ADD_ON,
- aoTerm,
- aoPriceList);
+ ProductCategory.ADD_ON,
+ aoTerm,
+ aoPriceList);
final PlanAlignmentCreate alignement = catalog.planCreateAlignment(planSpecifier, clock.getUTCNow());
assertEquals(alignement, PlanAlignmentCreate.START_OF_SUBSCRIPTION);
@@ -350,11 +325,8 @@ public class TestUserApiAddOn extends TestApiBase {
}
}
-
private void testAddonCreateInternal(final String aoProduct, final BillingPeriod aoTerm, final String aoPriceList, final PlanAlignmentCreate expAlignement) {
-
try {
-
final String baseProduct = "Shotgun";
final BillingPeriod baseTerm = BillingPeriod.MONTHLY;
final String basePriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -404,7 +376,6 @@ public class TestUserApiAddOn extends TestApiBase {
clock.addDeltaFromReality(it.toDurationMillis());
assertTrue(testListener.isCompleted(5000));
-
// CHECK EVERYTHING AGAIN
aoSubscription = (SubscriptionData) entitlementApi.getSubscriptionFromId(aoSubscription.getId());
@@ -418,11 +389,9 @@ public class TestUserApiAddOn extends TestApiBase {
assertNotNull(aoCurrentPhase);
assertEquals(aoCurrentPhase.getPhaseType(), PhaseType.EVERGREEN);
-
aoSubscription = (SubscriptionData) entitlementApi.getSubscriptionFromId(aoSubscription.getId());
aoPendingTranstion = aoSubscription.getPendingTransition();
assertNull(aoPendingTranstion);
-
} catch (EntitlementUserApiException e) {
Assert.fail(e.getMessage());
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancel.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancel.java
index 879bb90..af1b2f4 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancel.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancel.java
@@ -37,13 +37,8 @@ import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
public abstract class TestUserApiCancel extends TestApiBase {
-
protected void testCancelSubscriptionIMM() {
-
- log.info("Starting testCancelSubscriptionIMM");
-
try {
-
final DateTime init = clock.getUTCNow();
final String prod = "Shotgun";
@@ -76,12 +71,8 @@ public abstract class TestUserApiCancel extends TestApiBase {
}
}
-
protected void testCancelSubscriptionEOTWithChargeThroughDate() throws EntitlementBillingApiException {
- log.info("Starting testCancelSubscriptionEOTWithChargeThroughDate");
-
try {
-
final String prod = "Shotgun";
final BillingPeriod term = BillingPeriod.MONTHLY;
final String planSet = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -139,13 +130,8 @@ public abstract class TestUserApiCancel extends TestApiBase {
}
}
-
protected void testCancelSubscriptionEOTWithNoChargeThroughDate() {
-
- log.info("Starting testCancelSubscriptionEOTWithNoChargeThroughDate");
-
try {
-
final String prod = "Shotgun";
final BillingPeriod term = BillingPeriod.MONTHLY;
final String planSet = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -188,11 +174,7 @@ public abstract class TestUserApiCancel extends TestApiBase {
// are as they used to be and we can move forward without hitting cancellation
//
protected void testUncancel() throws EntitlementBillingApiException {
-
- log.info("Starting testUncancel");
-
try {
-
final String prod = "Shotgun";
final BillingPeriod term = BillingPeriod.MONTHLY;
final String planSet = PriceListSet.DEFAULT_PRICELIST_NAME;
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelMemory.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelMemory.java
index 4b3f54a..60d978f 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelMemory.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelMemory.java
@@ -25,33 +25,31 @@ import com.ning.billing.entitlement.api.billing.EntitlementBillingApiException;
import com.ning.billing.entitlement.glue.MockEngineModuleMemory;
public class TestUserApiCancelMemory extends TestUserApiCancel {
-
-
@Override
protected Injector getInjector() {
return Guice.createInjector(Stage.PRODUCTION, new MockEngineModuleMemory());
}
@Override
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testCancelSubscriptionIMM() {
super.testCancelSubscriptionIMM();
}
@Override
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testCancelSubscriptionEOTWithChargeThroughDate() throws EntitlementBillingApiException {
super.testCancelSubscriptionEOTWithChargeThroughDate();
}
@Override
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testCancelSubscriptionEOTWithNoChargeThroughDate() {
super.testCancelSubscriptionEOTWithNoChargeThroughDate();
}
@Override
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testUncancel() throws EntitlementBillingApiException {
super.testUncancel();
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelSql.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelSql.java
index 2bd3299..535add2 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelSql.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelSql.java
@@ -25,14 +25,12 @@ import com.ning.billing.entitlement.api.billing.EntitlementBillingApiException;
import com.ning.billing.entitlement.glue.MockEngineModuleSql;
public class TestUserApiCancelSql extends TestUserApiCancel {
-
-
@Override
public Injector getInjector() {
return Guice.createInjector(Stage.DEVELOPMENT, new MockEngineModuleSql());
}
- @Test(enabled = false, groups = {"stress"})
+ @Test(enabled = false, groups = {"slow, stress"})
public void stressTest() throws Exception {
final int MAX_STRESS_ITERATIONS = 10;
for (int i = 0; i < MAX_STRESS_ITERATIONS; i++) {
@@ -49,27 +47,26 @@ public class TestUserApiCancelSql extends TestUserApiCancel {
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testCancelSubscriptionIMM() {
super.testCancelSubscriptionIMM();
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testCancelSubscriptionEOTWithChargeThroughDate() throws EntitlementBillingApiException {
super.testCancelSubscriptionEOTWithChargeThroughDate();
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testCancelSubscriptionEOTWithNoChargeThroughDate() {
super.testCancelSubscriptionEOTWithNoChargeThroughDate();
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testUncancel() throws EntitlementBillingApiException {
super.testUncancel();
}
-
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlan.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlan.java
index 59db4d7..72573e3 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlan.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlan.java
@@ -43,8 +43,6 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
public abstract class TestUserApiChangePlan extends TestApiBase {
-
-
private void checkChangePlan(final SubscriptionData subscription, final String expProduct, final ProductCategory expCategory,
final BillingPeriod expBillingPeriod, final PhaseType expPhase) {
@@ -59,19 +57,13 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
assertEquals(currentPhase.getPhaseType(), expPhase);
}
-
protected void testChangePlanBundleAlignEOTWithNoChargeThroughDate() {
tChangePlanBundleAlignEOTWithNoChargeThroughDate("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, "Pistol", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
}
-
private void tChangePlanBundleAlignEOTWithNoChargeThroughDate(final String fromProd, final BillingPeriod fromTerm, final String fromPlanSet,
final String toProd, final BillingPeriod toTerm, final String toPlanSet) {
-
- log.info("Starting testChangePlanBundleAlignEOTWithNoChargeThroughDate");
-
try {
-
// CREATE
final SubscriptionData subscription = createSubscription(fromProd, fromTerm, fromPlanSet);
@@ -102,25 +94,19 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
}
}
-
protected void testChangePlanBundleAlignEOTWithChargeThroughDate() throws EntitlementBillingApiException {
- log.info("Starting testChangePlanBundleAlignEOTWithChargeThroughDate");
testChangePlanBundleAlignEOTWithChargeThroughDate("Shotgun", BillingPeriod.ANNUAL, "gunclubDiscount", "Pistol", BillingPeriod.ANNUAL, "gunclubDiscount");
}
private void testChangePlanBundleAlignEOTWithChargeThroughDate(final String fromProd, final BillingPeriod fromTerm, final String fromPlanSet,
final String toProd, final BillingPeriod toTerm, final String toPlanSet) throws EntitlementBillingApiException {
-
-
try {
-
// CREATE
SubscriptionData subscription = createSubscription(fromProd, fromTerm, fromPlanSet);
final PlanPhase trialPhase = subscription.getCurrentPhase();
final DateTime expectedPhaseTrialChange = DefaultClock.addDuration(subscription.getStartDate(), trialPhase.getDuration());
assertEquals(trialPhase.getPhaseType(), PhaseType.TRIAL);
-
// MOVE TO NEXT PHASE
testListener.pushExpectedEvent(NextEvent.PHASE);
Interval it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(31));
@@ -129,7 +115,6 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
PlanPhase currentPhase = subscription.getCurrentPhase();
assertEquals(currentPhase.getPhaseType(), PhaseType.DISCOUNT);
-
// SET CTD
final Duration ctd = getDurationMonth(1);
final DateTime newChargedThroughDate = DefaultClock.addDuration(expectedPhaseTrialChange, ctd);
@@ -155,7 +140,6 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
final List<EntitlementEvent> events = dao.getPendingEventsForSubscription(subscription.getId());
assertTrue(events.get(0) instanceof ApiEvent);
-
// MOVE TO EOT
testListener.pushExpectedEvent(NextEvent.CHANGE);
it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusMonths(1));
@@ -172,19 +156,14 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
}
}
-
protected void testChangePlanBundleAlignIMM() {
tChangePlanBundleAlignIMM("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, "Assault-Rifle", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
}
-
private void tChangePlanBundleAlignIMM(final String fromProd, final BillingPeriod fromTerm, final String fromPlanSet,
final String toProd, final BillingPeriod toTerm, final String toPlanSet) {
- log.info("Starting testChangePlanBundleAlignIMM");
-
try {
-
final SubscriptionData subscription = createSubscription(fromProd, fromTerm, fromPlanSet);
testListener.pushExpectedEvent(NextEvent.CHANGE);
@@ -217,17 +196,13 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
}
}
-
protected void testChangePlanChangePlanAlignEOTWithChargeThroughDate() throws EntitlementBillingApiException {
- log.info("Starting testChangePlanChangePlanAlignEOTWithChargeThroughDate");
tChangePlanChangePlanAlignEOTWithChargeThroughDate("Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, "Assault-Rifle", BillingPeriod.ANNUAL, "rescue");
}
private void tChangePlanChangePlanAlignEOTWithChargeThroughDate(final String fromProd, final BillingPeriod fromTerm, final String fromPlanSet,
final String toProd, final BillingPeriod toTerm, final String toPlanSet) throws EntitlementBillingApiException {
-
try {
-
DateTime currentTime = clock.getUTCNow();
SubscriptionData subscription = createSubscription(fromProd, fromTerm, fromPlanSet);
@@ -308,8 +283,6 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
}
protected void testMultipleChangeLastIMM() throws EntitlementBillingApiException {
-
- log.info("Starting testMultipleChangeLastIMM");
try {
SubscriptionData subscription = createSubscription("Assault-Rifle", BillingPeriod.MONTHLY, "gunclubDiscount");
final PlanPhase trialPhase = subscription.getCurrentPhase();
@@ -361,10 +334,7 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
}
protected void testMultipleChangeLastEOT() throws EntitlementBillingApiException {
-
- log.info("Starting testMultipleChangeLastEOT");
try {
-
SubscriptionData subscription = createSubscription("Assault-Rifle", BillingPeriod.ANNUAL, "gunclubDiscount");
final PlanPhase trialPhase = subscription.getCurrentPhase();
assertEquals(trialPhase.getPhaseType(), PhaseType.TRIAL);
@@ -425,7 +395,6 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
assertNotNull(currentPhase);
assertEquals(currentPhase.getPhaseType(), PhaseType.DISCOUNT);
-
// MOVE TO NEXT PHASE
testListener.pushExpectedEvent(NextEvent.PHASE);
it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusMonths(6));
@@ -449,13 +418,8 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
}
}
-
protected void testCorrectPhaseAlignmentOnChange() {
-
- log.info("Starting testCorrectPhaseAlignmentOnChange");
-
try {
-
SubscriptionData subscription = createSubscription("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
PlanPhase trialPhase = subscription.getCurrentPhase();
assertEquals(trialPhase.getPhaseType(), PhaseType.TRIAL);
@@ -464,7 +428,6 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
Interval it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(2));
clock.addDeltaFromReality(it.toDurationMillis());
-
// CHANGE IMMEDIATE TO A 3 PHASES PLAN
testListener.reset();
testListener.pushExpectedEvent(NextEvent.CHANGE);
@@ -506,5 +469,4 @@ public abstract class TestUserApiChangePlan extends TestApiBase {
Assert.fail(e.getMessage());
}
}
-
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanMemory.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanMemory.java
index 6bc6864..1bf654b 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanMemory.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanMemory.java
@@ -25,46 +25,43 @@ import com.ning.billing.entitlement.api.billing.EntitlementBillingApiException;
import com.ning.billing.entitlement.glue.MockEngineModuleMemory;
public class TestUserApiChangePlanMemory extends TestUserApiChangePlan {
-
@Override
protected Injector getInjector() {
return Guice.createInjector(Stage.PRODUCTION, new MockEngineModuleMemory());
}
-
@Override
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testChangePlanBundleAlignEOTWithNoChargeThroughDate() {
super.testChangePlanBundleAlignEOTWithNoChargeThroughDate();
}
@Override
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testChangePlanBundleAlignEOTWithChargeThroughDate() throws EntitlementBillingApiException {
super.testChangePlanBundleAlignEOTWithChargeThroughDate();
}
@Override
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testChangePlanBundleAlignIMM() {
super.testChangePlanBundleAlignIMM();
}
@Override
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testMultipleChangeLastIMM() throws EntitlementBillingApiException {
super.testMultipleChangeLastIMM();
}
@Override
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testMultipleChangeLastEOT() throws EntitlementBillingApiException {
super.testMultipleChangeLastEOT();
}
-
@Override
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testCorrectPhaseAlignmentOnChange() {
super.testCorrectPhaseAlignmentOnChange();
}
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 bec359b..406b575 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,13 +25,12 @@ import com.ning.billing.entitlement.api.billing.EntitlementBillingApiException;
import com.ning.billing.entitlement.glue.MockEngineModuleSql;
public class TestUserApiChangePlanSql extends TestUserApiChangePlan {
-
@Override
public Injector getInjector() {
return Guice.createInjector(Stage.DEVELOPMENT, new MockEngineModuleSql());
}
- @Test(enabled = false, groups = {"stress"})
+ @Test(enabled = false, groups = {"slow", "stress"})
public void stressTest() throws Exception {
final int MAX_STRESS_ITERATIONS = 10;
for (int i = 0; i < MAX_STRESS_ITERATIONS; i++) {
@@ -54,37 +53,37 @@ public class TestUserApiChangePlanSql extends TestUserApiChangePlan {
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testCorrectPhaseAlignmentOnChange() {
super.testCorrectPhaseAlignmentOnChange();
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testChangePlanBundleAlignEOTWithNoChargeThroughDate() {
super.testChangePlanBundleAlignEOTWithNoChargeThroughDate();
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testChangePlanBundleAlignEOTWithChargeThroughDate() throws EntitlementBillingApiException {
super.testChangePlanBundleAlignEOTWithChargeThroughDate();
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testChangePlanBundleAlignIMM() {
super.testChangePlanBundleAlignIMM();
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testMultipleChangeLastIMM() throws EntitlementBillingApiException {
super.testMultipleChangeLastIMM();
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testMultipleChangeLastEOT() throws EntitlementBillingApiException {
super.testMultipleChangeLastEOT();
}
@@ -95,5 +94,4 @@ public class TestUserApiChangePlanSql extends TestUserApiChangePlan {
public void testChangePlanChangePlanAlignEOTWithChargeThroughDate() throws EntitlementBillingApiException {
super.testChangePlanChangePlanAlignEOTWithChargeThroughDate();
}
-
}
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 510f55b..9ab3af1 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
@@ -16,7 +16,6 @@
package com.ning.billing.entitlement.api.user;
-
import java.util.List;
import org.joda.time.DateTime;
@@ -42,13 +41,10 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
public abstract class TestUserApiCreate extends TestApiBase {
-
private static final Logger log = LoggerFactory.getLogger(TestUserApiCreate.class);
public void testCreateWithRequestedDate() {
- log.info("Starting testCreateWithRequestedDate");
try {
-
final DateTime init = clock.getUTCNow();
final DateTime requestedDate = init.minusYears(1);
@@ -56,13 +52,11 @@ public abstract class TestUserApiCreate extends TestApiBase {
final BillingPeriod term = BillingPeriod.MONTHLY;
final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
-
testListener.pushExpectedEvent(NextEvent.PHASE);
testListener.pushExpectedEvent(NextEvent.CREATE);
-
final SubscriptionData subscription = (SubscriptionData) entitlementApi.createSubscription(bundle.getId(),
- getProductSpecifier(productName, planSetName, term, null), requestedDate, context);
+ getProductSpecifier(productName, planSetName, term, null), requestedDate, context);
assertNotNull(subscription);
assertEquals(subscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
@@ -80,12 +74,8 @@ public abstract class TestUserApiCreate extends TestApiBase {
}
}
-
protected void testCreateWithInitialPhase() {
- log.info("Starting testCreateWithInitialPhase");
try {
-
-
final DateTime init = clock.getUTCNow();
final String productName = "Shotgun";
@@ -95,7 +85,7 @@ public abstract class TestUserApiCreate extends TestApiBase {
testListener.pushExpectedEvent(NextEvent.CREATE);
final SubscriptionData subscription = (SubscriptionData) entitlementApi.createSubscription(bundle.getId(),
- getProductSpecifier(productName, planSetName, term, PhaseType.EVERGREEN), clock.getUTCNow(), context);
+ getProductSpecifier(productName, planSetName, term, PhaseType.EVERGREEN), clock.getUTCNow(), context);
assertNotNull(subscription);
assertEquals(subscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
@@ -122,10 +112,7 @@ public abstract class TestUserApiCreate extends TestApiBase {
}
protected void testSimpleCreateSubscription() {
-
- log.info("Starting testSimpleCreateSubscription");
try {
-
final DateTime init = clock.getUTCNow();
final String productName = "Shotgun";
@@ -135,8 +122,8 @@ public abstract class TestUserApiCreate extends TestApiBase {
testListener.pushExpectedEvent(NextEvent.CREATE);
final SubscriptionData subscription = (SubscriptionData) entitlementApi.createSubscription(bundle.getId(),
- getProductSpecifier(productName, planSetName, term, null),
- clock.getUTCNow(), context);
+ getProductSpecifier(productName, planSetName, term, null),
+ clock.getUTCNow(), context);
assertNotNull(subscription);
assertEquals(subscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
@@ -180,12 +167,8 @@ public abstract class TestUserApiCreate extends TestApiBase {
}
}
-
protected void testSimpleSubscriptionThroughPhases() {
-
- log.info("Starting testSimpleSubscriptionThroughPhases");
try {
-
final String productName = "Pistol";
final BillingPeriod term = BillingPeriod.ANNUAL;
final String planSetName = "gunclubDiscount";
@@ -211,7 +194,6 @@ public abstract class TestUserApiCreate extends TestApiBase {
assertNotNull(currentPhase);
assertEquals(currentPhase.getPhaseType(), PhaseType.DISCOUNT);
-
// MOVE TO EVERGREEN PHASE + RE-READ SUBSCRIPTION
testListener.pushExpectedEvent(NextEvent.PHASE);
it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusYears(1));
@@ -230,10 +212,7 @@ public abstract class TestUserApiCreate extends TestApiBase {
}
protected void testSubscriptionWithAddOn() {
-
- log.info("Starting testSubscriptionWithAddOn");
try {
-
final String productName = "Shotgun";
final BillingPeriod term = BillingPeriod.ANNUAL;
final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -241,7 +220,7 @@ public abstract class TestUserApiCreate extends TestApiBase {
testListener.pushExpectedEvent(NextEvent.CREATE);
final SubscriptionData subscription = (SubscriptionData) entitlementApi.createSubscription(bundle.getId(),
- getProductSpecifier(productName, planSetName, term, null), clock.getUTCNow(), context);
+ getProductSpecifier(productName, planSetName, term, null), clock.getUTCNow(), context);
assertNotNull(subscription);
assertListenerStatus();
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateMemory.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateMemory.java
index d671d2a..a7cd464 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateMemory.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateMemory.java
@@ -24,41 +24,38 @@ import com.google.inject.Stage;
import com.ning.billing.entitlement.glue.MockEngineModuleMemory;
public class TestUserApiCreateMemory extends TestUserApiCreate {
-
-
@Override
protected Injector getInjector() {
return Guice.createInjector(Stage.PRODUCTION, new MockEngineModuleMemory());
}
@Override
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testCreateWithRequestedDate() {
super.testCreateWithRequestedDate();
}
@Override
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testCreateWithInitialPhase() {
super.testSimpleSubscriptionThroughPhases();
}
@Override
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testSimpleCreateSubscription() {
super.testSimpleCreateSubscription();
}
@Override
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
protected void testSimpleSubscriptionThroughPhases() {
super.testSimpleSubscriptionThroughPhases();
}
@Override
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
protected void testSubscriptionWithAddOn() {
super.testSubscriptionWithAddOn();
}
-
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateSql.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateSql.java
index 135e98c..526d3b2 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateSql.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateSql.java
@@ -24,32 +24,31 @@ import com.google.inject.Stage;
import com.ning.billing.entitlement.glue.MockEngineModuleSql;
public class TestUserApiCreateSql extends TestUserApiCreate {
-
@Override
protected Injector getInjector() {
return Guice.createInjector(Stage.DEVELOPMENT, new MockEngineModuleSql());
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testCreateWithRequestedDate() {
super.testCreateWithRequestedDate();
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testCreateWithInitialPhase() {
super.testCreateWithInitialPhase();
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
public void testSimpleCreateSubscription() {
super.testSimpleCreateSubscription();
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
protected void testSimpleSubscriptionThroughPhases() {
super.testSimpleSubscriptionThroughPhases();
}
@@ -59,5 +58,4 @@ public class TestUserApiCreateSql extends TestUserApiCreate {
protected void testSubscriptionWithAddOn() {
super.testSubscriptionWithAddOn();
}
-
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiDemos.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiDemos.java
index 49e7a59..d2d33c4 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiDemos.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiDemos.java
@@ -46,7 +46,6 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
public class TestUserApiDemos extends TestApiBase {
-
@Override
protected Injector getInjector() {
return Guice.createInjector(Stage.DEVELOPMENT, new MockEngineModuleSql());
@@ -67,10 +66,8 @@ public class TestUserApiDemos extends TestApiBase {
* 7. Move to next Phase
* 8. Cancel EOT
*/
- @Test(enabled = true, groups = "demos")
+ @Test(enabled = false, groups = {"slow", "demos"})
public void testDemo1() throws EntitlementBillingApiException {
-
- log.info("Starting testSubscriptionWithAddOn");
try {
System.out.println("DEMO 1 START");
@@ -173,15 +170,12 @@ public class TestUserApiDemos extends TestApiBase {
}
-
private void displayState(final UUID subscriptionId, final String stepMsg) {
-
System.out.println("");
System.out.println("******\t STEP " + stepMsg + " **************");
try {
final SubscriptionData subscription = (SubscriptionData) entitlementApi.getSubscriptionFromId(subscriptionId);
-
final Plan currentPlan = subscription.getCurrentPlan();
final PlanPhase currentPhase = subscription.getCurrentPhase();
final String priceList = subscription.getCurrentPriceList().getName();
@@ -203,7 +197,7 @@ public class TestUserApiDemos extends TestApiBase {
}
- @Test(enabled = true, groups = {"stress"})
+ @Test(enabled = false, groups = {"slow", "stress"})
public void stressTest() throws Exception {
for (int i = 0; i < 100; i++) {
cleanupTest();
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiError.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiError.java
index fa947f1..afa82d0 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiError.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiError.java
@@ -42,24 +42,17 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
public class TestUserApiError extends TestApiBase {
-
-
@Override
protected Injector getInjector() {
return Guice.createInjector(Stage.DEVELOPMENT, new MockEngineModuleMemory());
}
-
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testCreateSubscriptionBadCatalog() {
-
- log.info("Starting testCreateSubscriptionBadCatalog");
-
// WRONG PRODUCTS
tCreateSubscriptionInternal(bundle.getId(), null, BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.CAT_NULL_PRODUCT_NAME);
tCreateSubscriptionInternal(bundle.getId(), "Whatever", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.CAT_NO_SUCH_PRODUCT);
-
// TODO: MARTIN TO FIX WITH CORRECT ERROR CODE. RIGHT NOW NPE
// WRONG BILLING PERIOD
@@ -69,33 +62,28 @@ public class TestUserApiError extends TestApiBase {
}
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testCreateSubscriptionNoBundle() {
- log.info("Starting testCreateSubscriptionNoBundle");
tCreateSubscriptionInternal(null, "Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_NO_BUNDLE);
}
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testCreateSubscriptionNoBP() {
- log.info("Starting testCreateSubscriptionNoBP");
tCreateSubscriptionInternal(bundle.getId(), "Telescopic-Scope", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_NO_BP);
}
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testCreateSubscriptionBPExists() {
- log.info("Starting testCreateSubscriptionBPExists");
try {
createSubscription("Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME);
tCreateSubscriptionInternal(bundle.getId(), "Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_BP_EXISTS);
} catch (Exception e) {
- e.printStackTrace();
- Assert.assertFalse(true);
+ Assert.fail(e.toString());
}
}
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testRecreateSubscriptionBPNotCancelled() {
- log.info("Starting testRecreateSubscriptionBPNotCancelled");
try {
final SubscriptionData subscription = createSubscription("Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME);
try {
@@ -105,26 +93,23 @@ public class TestUserApiError extends TestApiBase {
assertEquals(e.getCode(), ErrorCode.ENT_RECREATE_BAD_STATE.getCode());
}
} catch (Exception e) {
- e.printStackTrace();
- Assert.assertFalse(true);
+ Assert.fail(e.toString());
}
}
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testCreateSubscriptionAddOnNotAvailable() {
- log.info("Starting testCreateSubscriptionAddOnNotAvailable");
try {
final UUID accountId = UUID.randomUUID();
final SubscriptionBundle aoBundle = entitlementApi.createBundleForAccount(accountId, "myAOBundle", context);
createSubscriptionWithBundle(aoBundle.getId(), "Pistol", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null);
tCreateSubscriptionInternal(aoBundle.getId(), "Telescopic-Scope", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_AO_NOT_AVAILABLE);
} catch (Exception e) {
- e.printStackTrace();
- Assert.assertFalse(true);
+ Assert.fail(e.toString());
}
}
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testCreateSubscriptionAddOnIncluded() {
log.info("Starting testCreateSubscriptionAddOnIncluded");
try {
@@ -133,12 +118,10 @@ public class TestUserApiError extends TestApiBase {
createSubscriptionWithBundle(aoBundle.getId(), "Assault-Rifle", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null);
tCreateSubscriptionInternal(aoBundle.getId(), "Telescopic-Scope", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_AO_ALREADY_INCLUDED);
} catch (Exception e) {
- e.printStackTrace();
- Assert.assertFalse(true);
+ Assert.fail(e.toString());
}
}
-
private void tCreateSubscriptionInternal(@Nullable final UUID bundleId, @Nullable final String productName,
@Nullable final BillingPeriod term, final String planSet, final ErrorCode expected) {
try {
@@ -156,10 +139,8 @@ public class TestUserApiError extends TestApiBase {
}
}
-
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testChangeSubscriptionNonActive() {
- log.info("Starting testChangeSubscriptionNonActive");
try {
final Subscription subscription = createSubscription("Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME);
@@ -176,15 +157,12 @@ public class TestUserApiError extends TestApiBase {
}
}
} catch (Exception e) {
- e.printStackTrace();
- Assert.assertFalse(true);
+ Assert.fail(e.toString());
}
}
-
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testChangeSubscriptionFutureCancelled() {
- log.info("Starting testChangeSubscriptionFutureCancelled");
try {
Subscription subscription = createSubscription("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
final PlanPhase trialPhase = subscription.getCurrentPhase();
@@ -196,7 +174,6 @@ public class TestUserApiError extends TestApiBase {
clock.addDeltaFromReality(it.toDurationMillis());
assertTrue(testListener.isCompleted(5000));
-
// SET CTD TO CANCEL IN FUTURE
final DateTime expectedPhaseTrialChange = DefaultClock.addDuration(subscription.getStartDate(), trialPhase.getDuration());
final Duration ctd = getDurationMonth(1);
@@ -219,20 +196,16 @@ public class TestUserApiError extends TestApiBase {
assertListenerStatus();
} catch (Exception e) {
- e.printStackTrace();
- Assert.assertFalse(true);
+ Assert.fail(e.toString());
}
}
-
- @Test(enabled = false, groups = {"fast"})
+ @Test(enabled = false, groups = "fast")
public void testCancelBadState() {
- log.info("Starting testCancelBadState");
}
- @Test(enabled = true, groups = {"fast"})
+ @Test(groups = "fast")
public void testUncancelBadState() {
- log.info("Starting testUncancelBadState");
try {
final Subscription subscription = createSubscription("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
@@ -248,10 +221,7 @@ public class TestUserApiError extends TestApiBase {
}
assertListenerStatus();
} catch (Exception e) {
- e.printStackTrace();
- Assert.assertFalse(true);
+ Assert.fail(e.toString());
}
-
}
-
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiPriceList.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiPriceList.java
index 36d699d..f2d7f22 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiPriceList.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiPriceList.java
@@ -20,18 +20,14 @@ import com.google.inject.Injector;
import com.ning.billing.entitlement.api.TestApiBase;
public class TestUserApiPriceList extends TestApiBase {
-
@Override
protected Injector getInjector() {
return null;
}
protected void testChangeDefaultToDiscountToDefault() {
-
}
protected void testChangeDiscountToDefaultoDiscount() {
-
}
-
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiRecreate.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiRecreate.java
index cd09fdf..d35c9f3 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiRecreate.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiRecreate.java
@@ -31,12 +31,9 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
public abstract class TestUserApiRecreate extends TestApiBase {
-
private static final Logger log = LoggerFactory.getLogger(TestUserApiRecreate.class);
-
protected void testRecreateWithBPCanceledThroughSubscription() {
- log.info("Starting testRecreateWithBPCanceledThroughSubscription");
try {
testCreateAndRecreate(false);
assertListenerStatus();
@@ -47,7 +44,6 @@ public abstract class TestUserApiRecreate extends TestApiBase {
}
protected void testCreateWithBPCanceledFromUserApi() {
- log.info("Starting testCreateWithBPCanceledFromUserApi");
try {
testCreateAndRecreate(true);
assertListenerStatus();
@@ -57,9 +53,7 @@ public abstract class TestUserApiRecreate extends TestApiBase {
}
}
-
private SubscriptionData testCreateAndRecreate(final boolean fromUserAPi) throws EntitlementUserApiException {
-
final DateTime init = clock.getUTCNow();
final DateTime requestedDate = init.minusYears(1);
@@ -103,12 +97,11 @@ public abstract class TestUserApiRecreate extends TestApiBase {
testListener.pushExpectedEvent(NextEvent.PHASE);
testListener.pushExpectedEvent(NextEvent.RE_CREATE);
- // Avoid ordering issue for events at exact same date; this is actually a real good test, we
+ // Avoid ordering issue for events at exact same date; this is actually a real good test,
// we test it at Beatrix level. At this level that would work for sql tests but not for in memory.
try {
Thread.sleep(1000);
- } catch (InterruptedException e) {
-
+ } catch (InterruptedException ignored) {
}
if (fromUserAPi) {
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiRecreateMemory.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiRecreateMemory.java
index b164d65..fa808b6 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiRecreateMemory.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiRecreateMemory.java
@@ -24,21 +24,19 @@ import com.google.inject.Stage;
import com.ning.billing.entitlement.glue.MockEngineModuleMemory;
public class TestUserApiRecreateMemory extends TestUserApiRecreate {
-
-
@Override
protected Injector getInjector() {
return Guice.createInjector(Stage.PRODUCTION, new MockEngineModuleMemory());
}
@Override
- @Test(enabled = false, groups = {"fast"})
+ @Test(enabled = false, groups = "fast")
protected void testRecreateWithBPCanceledThroughSubscription() {
super.testRecreateWithBPCanceledThroughSubscription();
}
@Override
- @Test(enabled = false, groups = {"fast"})
+ @Test(enabled = false, groups = "fast")
protected void testCreateWithBPCanceledFromUserApi() {
super.testRecreateWithBPCanceledThroughSubscription();
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiRecreateSql.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiRecreateSql.java
index 7b6217c..5dfcea1 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiRecreateSql.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiRecreateSql.java
@@ -24,20 +24,19 @@ import com.google.inject.Stage;
import com.ning.billing.entitlement.glue.MockEngineModuleSql;
public class TestUserApiRecreateSql extends TestUserApiRecreate {
-
@Override
protected Injector getInjector() {
return Guice.createInjector(Stage.DEVELOPMENT, new MockEngineModuleSql());
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
protected void testRecreateWithBPCanceledThroughSubscription() {
super.testRecreateWithBPCanceledThroughSubscription();
}
@Override
- @Test(enabled = true, groups = {"slow"})
+ @Test(groups = "slow")
protected void testCreateWithBPCanceledFromUserApi() {
super.testRecreateWithBPCanceledThroughSubscription();
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiScenarios.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiScenarios.java
index 81aa23b..f679b73 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiScenarios.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiScenarios.java
@@ -39,17 +39,13 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
public class TestUserApiScenarios extends TestApiBase {
-
@Override
protected Injector getInjector() {
return Guice.createInjector(Stage.DEVELOPMENT, new MockEngineModuleSql());
}
- @Test(groups = {"slow"}, enabled = true)
+ @Test(groups = "slow")
public void testChangeIMMCancelUncancelChangeEOT() throws EntitlementBillingApiException {
-
- log.info("Starting testChangeIMMCancelUncancelChangeEOT");
-
try {
SubscriptionData subscription = createSubscription("Assault-Rifle", BillingPeriod.MONTHLY, "gunclubDiscount");
final PlanPhase trialPhase = subscription.getCurrentPhase();
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/MockEntitlementDaoMemory.java b/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/MockEntitlementDaoMemory.java
index c1a2793..3479d0e 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/MockEntitlementDaoMemory.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/MockEntitlementDaoMemory.java
@@ -35,7 +35,6 @@ import com.google.inject.Inject;
import com.ning.billing.catalog.api.CatalogService;
import com.ning.billing.catalog.api.ProductCategory;
import com.ning.billing.catalog.api.TimeUnit;
-import com.ning.billing.config.EntitlementConfig;
import com.ning.billing.entitlement.api.SubscriptionFactory;
import com.ning.billing.entitlement.api.migration.AccountMigrationData;
import com.ning.billing.entitlement.api.migration.AccountMigrationData.BundleMigrationData;
@@ -59,8 +58,7 @@ import com.ning.billing.util.notificationq.NotificationQueue;
import com.ning.billing.util.notificationq.NotificationQueueService;
import com.ning.billing.util.notificationq.NotificationQueueService.NoSuchNotificationQueue;
-public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlementDao {
-
+public class MockEntitlementDaoMemory implements EntitlementDao {
protected static final Logger log = LoggerFactory.getLogger(EntitlementDao.class);
private final List<SubscriptionBundle> bundles;
@@ -71,12 +69,11 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
private final CatalogService catalogService;
@Inject
- public MockEntitlementDaoMemory(final Clock clock, final EntitlementConfig config,
+ public MockEntitlementDaoMemory(final Clock clock,
final NotificationQueueService notificationQueueService,
final CatalogService catalogService) {
super();
this.clock = clock;
- final EntitlementConfig config1 = config;
this.catalogService = catalogService;
this.notificationQueueService = notificationQueueService;
this.bundles = new ArrayList<SubscriptionBundle>();
@@ -84,7 +81,6 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
this.events = new TreeSet<EntitlementEvent>();
}
- @Override
public void reset() {
bundles.clear();
subscriptions.clear();
@@ -154,7 +150,6 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
return Collections.emptyList();
}
-
@Override
public void createSubscription(final SubscriptionData subscription, final List<EntitlementEvent> initialEvents,
final CallContext context) {
@@ -220,7 +215,6 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
}
}
-
@Override
public Subscription getBaseSubscription(final SubscriptionFactory factory, final UUID bundleId) {
for (final Subscription cur : subscriptions) {
@@ -239,7 +233,6 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
insertEvent(nextPhase);
}
-
private Subscription buildSubscription(final SubscriptionFactory factory, final SubscriptionData in) {
if (factory != null) {
return factory.createSubscription(new SubscriptionBuilder(in), getEventsForSubscription(in.getId()));
@@ -299,7 +292,6 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
}
}
-
private void cancelNextPhaseEvent(final UUID subscriptionId) {
final Subscription curSubscription = getSubscriptionFromId(null, subscriptionId);
@@ -326,7 +318,6 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
}
}
-
private void cancelNextChangeEvent(final UUID subscriptionId) {
synchronized (events) {
@@ -374,7 +365,6 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
}
}
-
@Override
public void migrate(final UUID accountId, final AccountMigrationData accountData, final CallContext context) {
synchronized (events) {
@@ -410,7 +400,7 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
private void recordFutureNotificationFromTransaction(final Transmogrifier transactionalDao, final DateTime effectiveDate, final NotificationKey notificationKey) {
try {
final NotificationQueue subscriptionEventQueue = notificationQueueService.getNotificationQueue(Engine.ENTITLEMENT_SERVICE_NAME,
- Engine.NOTIFICATION_QUEUE_NAME);
+ Engine.NOTIFICATION_QUEUE_NAME);
subscriptionEventQueue.recordFutureNotificationFromTransaction(transactionalDao, effectiveDate, null, notificationKey);
} catch (NoSuchNotificationQueue e) {
throw new RuntimeException(e);
@@ -421,7 +411,6 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
@Override
public Map<UUID, List<EntitlementEvent>> getEventsForBundle(final UUID bundleId) {
- // TODO Auto-generated method stub
return null;
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/MockEntitlementDaoSql.java b/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/MockEntitlementDaoSql.java
index 6a93d3c..0c104fc 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/MockEntitlementDaoSql.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/MockEntitlementDaoSql.java
@@ -17,11 +17,6 @@
package com.ning.billing.entitlement.engine.dao;
import org.skife.jdbi.v2.IDBI;
-import org.skife.jdbi.v2.Transaction;
-import org.skife.jdbi.v2.TransactionStatus;
-import org.skife.jdbi.v2.sqlobject.SqlUpdate;
-import org.skife.jdbi.v2.sqlobject.mixins.CloseMe;
-import org.skife.jdbi.v2.sqlobject.mixins.Transactional;
import com.google.inject.Inject;
import com.ning.billing.catalog.api.CatalogService;
@@ -30,51 +25,10 @@ import com.ning.billing.util.bus.Bus;
import com.ning.billing.util.clock.Clock;
import com.ning.billing.util.notificationq.NotificationQueueService;
-public class MockEntitlementDaoSql extends AuditedEntitlementDao implements MockEntitlementDao {
-
- private final ResetSqlDao resetDao;
-
+public class MockEntitlementDaoSql extends AuditedEntitlementDao {
@Inject
public MockEntitlementDaoSql(final IDBI dbi, final Clock clock, final AddonUtils addonUtils, final NotificationQueueService notificationQueueService,
final Bus eventBus, final CatalogService catalogService) {
super(dbi, clock, addonUtils, notificationQueueService, eventBus, catalogService);
- this.resetDao = dbi.onDemand(ResetSqlDao.class);
- }
-
-
- @Override
- public void reset() {
- resetDao.inTransaction(new Transaction<Void, ResetSqlDao>() {
-
- @Override
- public Void inTransaction(final ResetSqlDao dao, final TransactionStatus status)
- throws Exception {
- resetDao.resetEvents();
- resetDao.resetSubscriptions();
- resetDao.resetBundles();
- resetDao.resetClaimedNotifications();
- resetDao.resetNotifications();
- return null;
- }
- });
- }
-
- public static interface ResetSqlDao extends Transactional<ResetSqlDao>, CloseMe {
-
- @SqlUpdate("truncate table subscription_events")
- public void resetEvents();
-
- @SqlUpdate("truncate table subscriptions")
- public void resetSubscriptions();
-
- @SqlUpdate("truncate table bundles")
- public void resetBundles();
-
- @SqlUpdate("truncate table notifications")
- public void resetNotifications();
-
- @SqlUpdate("truncate table claimed_notifications")
- public void resetClaimedNotifications();
-
}
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/EntitlementTestSuiteWithEmbeddedDB.java b/entitlement/src/test/java/com/ning/billing/entitlement/EntitlementTestSuiteWithEmbeddedDB.java
new file mode 100644
index 0000000..0537107
--- /dev/null
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/EntitlementTestSuiteWithEmbeddedDB.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.entitlement;
+
+import com.ning.billing.KillbillTestSuiteWithEmbeddedDB;
+
+public abstract class EntitlementTestSuiteWithEmbeddedDB extends KillbillTestSuiteWithEmbeddedDB {
+}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModuleMemory.java b/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModuleMemory.java
index 148b62d..13a9012 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModuleMemory.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModuleMemory.java
@@ -16,7 +16,6 @@
package com.ning.billing.entitlement.glue;
-
import com.google.inject.name.Names;
import com.ning.billing.entitlement.api.timeline.RepairEntitlementLifecycleDao;
import com.ning.billing.entitlement.engine.dao.EntitlementDao;
@@ -28,7 +27,6 @@ import com.ning.billing.util.notificationq.MockNotificationQueueService;
import com.ning.billing.util.notificationq.NotificationQueueService;
public class MockEngineModuleMemory extends MockEngineModule {
-
@Override
protected void installEntitlementDao() {
bind(EntitlementDao.class).to(MockEntitlementDaoMemory.class).asEagerSingleton();
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModuleSql.java b/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModuleSql.java
index 51a55a0..fd3d266 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModuleSql.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/glue/MockEngineModuleSql.java
@@ -16,11 +16,11 @@
package com.ning.billing.entitlement.glue;
-
import org.skife.config.ConfigurationObjectFactory;
import org.skife.jdbi.v2.IDBI;
import com.google.inject.name.Names;
+import com.ning.billing.KillbillTestSuiteWithEmbeddedDB;
import com.ning.billing.dbi.DBIProvider;
import com.ning.billing.dbi.DbiConfig;
import com.ning.billing.dbi.MysqlTestingHelper;
@@ -34,8 +34,6 @@ import com.ning.billing.util.glue.CustomFieldModule;
import com.ning.billing.util.glue.NotificationQueueModule;
public class MockEngineModuleSql extends MockEngineModule {
-
-
@Override
protected void installEntitlementDao() {
bind(EntitlementDao.class).to(MockEntitlementDaoSql.class).asEagerSingleton();
@@ -44,9 +42,8 @@ public class MockEngineModuleSql extends MockEngineModule {
bind(RepairEntitlementDao.class).asEagerSingleton();
}
-
protected void installDBI() {
- final MysqlTestingHelper helper = new MysqlTestingHelper();
+ final MysqlTestingHelper helper = KillbillTestSuiteWithEmbeddedDB.getMysqlTestingHelper();
bind(MysqlTestingHelper.class).toInstance(helper);
if (helper.isUsingLocalInstance()) {
bind(IDBI.class).toProvider(DBIProvider.class).asEagerSingleton();