@Override public Account createAccount(final AccountData data, final CallContext context) throws AccountApiException { final Account result = new MockAccountBuilder(data).build(); accounts.add(result); return result; }
@Test(groups = "slow") public void testAddAndRemoveTagsForAccount() throws Exception { final String name = UUID.randomUUID().toString().substring(0, 20); final String accountKey = UUID.randomUUID().toString(); final Account accountData = new MockAccountBuilder(UUID.randomUUID()) .externalKey(accountKey) .currency(Currency.MXN) .build(); Mockito.when(accountInternalApi.getAccountById(Mockito.eq(accountData.getId()), Mockito.<InternalCallContext>any())).thenReturn(accountData); Mockito.when(accountInternalApi.getAccountByKey(Mockito.eq(accountData.getExternalKey()), Mockito.<InternalCallContext>any())).thenReturn(accountData); final UUID accountId = accountData.getId(); Assert.assertEquals(accountTagSqlDao.getTagsForAccountByKey(accountKey, internalCallContext).size(), 0); tagDao.tagAdded(ObjectType.ACCOUNT, accountId, name, internalCallContext); Assert.assertEquals(accountTagSqlDao.getTagsForAccountByKey(accountKey, internalCallContext).size(), 1); tagDao.tagRemoved(ObjectType.ACCOUNT, accountId, name, internalCallContext); Assert.assertEquals(accountTagSqlDao.getTagsForAccountByKey(accountKey, internalCallContext).size(), 0); }
@Test(groups = "slow") public void testAddAndRemoveTagsForBundle() throws Exception { final String name = UUID.randomUUID().toString().substring(0, 20); final String externalKey = UUID.randomUUID().toString(); final Account accountData = new MockAccountBuilder() .currency(Currency.MXN) .build(); Mockito.when(accountInternalApi.getAccountById(Mockito.eq(accountData.getId()), Mockito.<InternalCallContext>any())).thenReturn(accountData); Mockito.when(accountInternalApi.getAccountByKey(Mockito.eq(accountData.getExternalKey()), Mockito.<InternalCallContext>any())).thenReturn(accountData); final UUID bundleId = UUID.randomUUID(); final SubscriptionBundle bundle = Mockito.mock(SubscriptionBundle.class); Mockito.when(bundle.getId()).thenReturn(bundleId); Mockito.when(bundle.getAccountId()).thenReturn(accountData.getId()); Mockito.when(bundle.getExternalKey()).thenReturn(externalKey); Mockito.when(entitlementInternalApi.getBundleFromId(Mockito.eq(bundleId), Mockito.<InternalCallContext>any())).thenReturn(bundle); Assert.assertEquals(subscriptionTransitionTagSqlDao.getTagsForBusinessSubscriptionTransitionByKey(externalKey, internalCallContext).size(), 0); tagDao.tagAdded(ObjectType.BUNDLE, bundleId, name, internalCallContext); Assert.assertEquals(subscriptionTransitionTagSqlDao.getTagsForBusinessSubscriptionTransitionByKey(externalKey, internalCallContext).size(), 1); tagDao.tagRemoved(ObjectType.BUNDLE, bundleId, name, internalCallContext); Assert.assertEquals(subscriptionTransitionTagSqlDao.getTagsForBusinessSubscriptionTransitionByKey(externalKey, internalCallContext).size(), 0); } }
protected AccountData getAccountData(final int billingDay) { return new MockAccountBuilder().name(UUID.randomUUID().toString().substring(1, 8)) .firstNameLength(6) .email(UUID.randomUUID().toString().substring(1, 8)) .phone(UUID.randomUUID().toString().substring(1, 8)) .migrated(false) .isNotifiedForInvoices(false) .externalKey(UUID.randomUUID().toString().substring(1, 8)) .billingCycleDayLocal(billingDay) .currency(Currency.USD) .paymentMethodId(UUID.randomUUID()) .timeZone(DateTimeZone.UTC) .build(); }
public Account createAccount(final CallContext callContext) throws AccountApiException { final AccountData accountData = new MockAccountBuilder().name(UUID.randomUUID().toString().substring(1, 8)) .firstNameLength(6) .email(UUID.randomUUID().toString().substring(1, 8)) .phone(UUID.randomUUID().toString().substring(1, 8)) .migrated(false) .isNotifiedForInvoices(true) .externalKey(UUID.randomUUID().toString().substring(1, 8)) .billingCycleDayLocal(31) .currency(accountCurrency) .paymentMethodId(UUID.randomUUID()) .timeZone(DateTimeZone.UTC) .build(); return accountUserApi.createAccount(accountData, callContext); }
public AccountData initAccountData() { final AccountData accountData = new MockAccountBuilder().name(UUID.randomUUID().toString()) .firstNameLength(6) .email(UUID.randomUUID().toString()) .phone(UUID.randomUUID().toString()) .migrated(false) .isNotifiedForInvoices(false) .externalKey(UUID.randomUUID().toString()) .billingCycleDayLocal(1) .currency(Currency.USD) .paymentMethodId(UUID.randomUUID()) .timeZone(DateTimeZone.forID("Europe/Paris")) .build(); assertNotNull(accountData); return accountData; }
@BeforeMethod(groups = "slow") public void beforeMethod() throws Exception { super.beforeMethod(); Mockito.when(catalogService.getFullCatalog()).thenReturn(new MockCatalog()); final PaymentMethod paymentMethod = Mockito.mock(PaymentMethod.class); final UUID paymentMethodId = UUID.randomUUID(); Mockito.when(paymentMethod.getId()).thenReturn(paymentMethodId); final Account account = new MockAccountBuilder(UUID.randomUUID()) .externalKey(ACCOUNT_KEY) .currency(ACCOUNT_CURRENCY) .paymentMethodId(paymentMethodId) .build(); Mockito.when(accountInternalApi.getAccountById(Mockito.eq(account.getId()), Mockito.<InternalCallContext>any())).thenReturn(account); try { // Create events for the bus and expected results createSubscriptionTransitionEvent(account); createAccountCreationEvent(account); createInvoiceAndPaymentCreationEvents(account); } catch (Throwable t) { fail("Initializing accounts failed.", t); } }
private BillingEvent createEvent(final SubscriptionBase sub, final DateTime effectiveDate, final SubscriptionBaseTransitionType type, final long totalOrdering) { final int billCycleDay = 1; final Plan shotgun = new MockPlan(); final PlanPhase shotgunMonthly = createMockMonthlyPlanPhase(null, BigDecimal.ZERO, PhaseType.TRIAL); final Account account = new MockAccountBuilder().build(); return new DefaultBillingEvent(account, sub, effectiveDate, shotgun, shotgunMonthly, BigDecimal.ZERO, null, Currency.USD, BillingPeriod.NO_BILLING_PERIOD, billCycleDay, BillingModeType.IN_ADVANCE, "Test Event 1", totalOrdering, type, DateTimeZone.UTC); }
accountBuilder.stateOrProvince(UUID.randomUUID().toString()); accountBuilder.timeZone(DateTimeZone.UTC); final Account account = accountBuilder.build();
.phone(phone) .isNotifiedForInvoices(false) .build(); accounts.add(result); return result;