Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2013 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.osgi.bundles.analytics;
 
 import java.util.UUID;
 
 import  javax.annotation.Nullable;
 
 
 
 
 public abstract class AnalyticsTestSuiteNoDB {
 
     private static final DateTime INVOICE_CREATED_DATE = new DateTime(2016, 1, 22, 10, 56, 53, .);
     protected final Logger logger = LoggerFactory.getLogger(AnalyticsTestSuiteNoDB.class);
 
     protected final Long accountRecordId = 1L;
     protected final Long subscriptionEventRecordId = 2L;
     protected final Long invoiceRecordId = 3L;
     protected final Long invoiceItemRecordId = 4L;
     protected final Long secondInvoiceItemRecordId = 24L;
     protected final Long invoicePaymentRecordId = 5L;
     protected final Long blockingStateRecordId = 6L;
     protected final Long fieldRecordId = 7L;
     protected final Long tagRecordId = 8L;
     protected final Long tenantRecordId = 9L;
     protected final Long bundleRecordId = 10L;
 
     protected final ReportGroup reportGroup = .;
     protected final ItemSource itemSource = .;
    protected Account account;
    protected SubscriptionBundle bundle;
    protected Plan plan;
    protected PlanPhase phase;
    protected PriceList priceList;
    protected BlockingState blockingState;
    protected Invoice invoice;
    protected InvoiceItem invoiceItem;
    protected InvoicePayment invoicePayment;
    protected PaymentAttempt paymentAttempt;
    protected PaymentMethod paymentMethod;
    protected Payment payment;
    protected Refund refund;
    protected CustomField customField;
    protected Tag tag;
    protected TagDefinition tagDefinition;
    protected AuditLog auditLog;
    protected CallContext callContext;
    protected OSGIKillbillAPI killbillAPI;
    protected void verifyBusinessEntityBase(final BusinessEntityBase businessEntityBase) {
        Assert.assertEquals(businessEntityBase.getCreatedBy(), .getUserName());
        Assert.assertEquals(businessEntityBase.getCreatedReasonCode(), .getReasonCode());
        Assert.assertEquals(businessEntityBase.getCreatedComments(), .getComment());
        Assert.assertEquals(businessEntityBase.getAccountId(), .getId());
        Assert.assertEquals(businessEntityBase.getAccountName(), .getName());
        Assert.assertEquals(businessEntityBase.getAccountExternalKey(), .getExternalKey());
        Assert.assertEquals(businessEntityBase.getReportGroup(), .toString());
    }
    protected void verifyBusinessModelDaoBase(final BusinessModelDaoBase businessModelDaoBase,
                                              final Long accountRecordId,
                                              final Long tenantRecordId) {
        Assert.assertEquals(businessModelDaoBase.getCreatedBy(), .getUserName());
        Assert.assertEquals(businessModelDaoBase.getCreatedReasonCode(), .getReasonCode());
        Assert.assertEquals(businessModelDaoBase.getCreatedComments(), .getComment());
        Assert.assertEquals(businessModelDaoBase.getAccountId(), .getId());
        Assert.assertEquals(businessModelDaoBase.getAccountName(), .getName());
        Assert.assertEquals(businessModelDaoBase.getAccountExternalKey(), .getExternalKey());
        Assert.assertEquals(businessModelDaoBase.getAccountRecordId(), accountRecordId);
        Assert.assertEquals(businessModelDaoBase.getTenantRecordId(), tenantRecordId);
        Assert.assertEquals(businessModelDaoBase.getReportGroup(), .toString());
    }
    protected InvoiceItem createInvoiceItem(final UUID invoiceIdfinal InvoiceItemType type) {
        return createInvoiceItem(invoiceIdtype.);
    }
    protected InvoiceItem createInvoiceItem(final UUID invoiceIdfinal InvoiceItemType typefinal BigDecimal amount) {
        return createInvoiceItem(invoiceIdtype, UUID.randomUUID(), new LocalDate(2013, 1, 2), new LocalDate(2013, 2, 5), amountnull);
    }
    protected InvoiceItem createInvoiceItem(final UUID invoiceId,
                                            final InvoiceItemType invoiceItemType,
                                            final UUID subscriptionId,
                                            final LocalDate startDate,
                                            final LocalDate endDate,
                                            final BigDecimal amount,
                                            @Nullable final UUID linkedItemId) {
        final UUID invoiceItemId = UUID.randomUUID();
        final InvoiceItem invoiceItem = Mockito.mock(InvoiceItem.class);
        Mockito.when(invoiceItem.getId()).thenReturn(invoiceItemId);
        Mockito.when(invoiceItem.getInvoiceItemType()).thenReturn(invoiceItemType);
        Mockito.when(invoiceItem.getInvoiceId()).thenReturn(invoiceId);
        Mockito.when(invoiceItem.getAccountId()).thenReturn(UUID.randomUUID());
        Mockito.when(invoiceItem.getStartDate()).thenReturn(startDate);
        Mockito.when(invoiceItem.getEndDate()).thenReturn(endDate);
        Mockito.when(invoiceItem.getAmount()).thenReturn(amount);
        Mockito.when(invoiceItem.getCurrency()).thenReturn(.);
        Mockito.when(invoiceItem.getDescription()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(invoiceItem.getBundleId()).thenReturn(UUID.randomUUID());
        Mockito.when(invoiceItem.getSubscriptionId()).thenReturn(subscriptionId);
        Mockito.when(invoiceItem.getPlanName()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(invoiceItem.getPhaseName()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(invoiceItem.getRate()).thenReturn(new BigDecimal("1203"));
        Mockito.when(invoiceItem.getLinkedItemId()).thenReturn(linkedItemId);
        Mockito.when(invoiceItem.getCreatedDate()).thenReturn();
        return invoiceItem;
    }
    @BeforeMethod(groups = "fast")
    public void setUp() throws Exception {
         = Mockito.mock(Account.class);
        Mockito.when(.getId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getExternalKey()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getName()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getFirstNameLength()).thenReturn(4);
        Mockito.when(.getEmail()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getBillCycleDayLocal()).thenReturn(2);
        Mockito.when(.getCurrency()).thenReturn(.);
        Mockito.when(.getPaymentMethodId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getTimeZone()).thenReturn(DateTimeZone.forID("Europe/London"));
        Mockito.when(.getLocale()).thenReturn(UUID.randomUUID().toString().substring(0, 5));
        Mockito.when(.getAddress1()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getAddress2()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getCompanyName()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getCity()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getStateOrProvince()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getPostalCode()).thenReturn(UUID.randomUUID().toString().substring(0, 16));
        Mockito.when(.getCountry()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getPhone()).thenReturn(UUID.randomUUID().toString().substring(0, 25));
        Mockito.when(.isMigrated()).thenReturn(true);
        Mockito.when(.isNotifiedForInvoices()).thenReturn(true);
        Mockito.when(.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 47, .));
        Mockito.when(.getUpdatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 48, .));
        final UUID accountId = .getId();
         = Mockito.mock(SubscriptionBundle.class);
        Mockito.when(.getId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getAccountId()).thenReturn(accountId);
        Mockito.when(.getExternalKey()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 48, .));
        final UUID bundleId = .getId();
        final Product product = Mockito.mock(Product.class);
        Mockito.when(product.getName()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(product.isRetired()).thenReturn(true);
        Mockito.when(product.getCategory()).thenReturn(.);
        Mockito.when(product.getCatalogName()).thenReturn(UUID.randomUUID().toString());
         = Mockito.mock(Plan.class);
        Mockito.when(.getProduct()).thenReturn(product);
        Mockito.when(.getName()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.isRetired()).thenReturn(true);
        Mockito.when(.getEffectiveDateForExistingSubscriptons()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 59, .).toDate());
        final String planName = .getName();
         = Mockito.mock(PlanPhase.class);
        Mockito.when(.getName()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getPlan()).thenReturn();
        Mockito.when(.getPhaseType()).thenReturn(.);
        final String phaseName = .getName();
         = Mockito.mock(PriceList.class);
        Mockito.when(.getName()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.isRetired()).thenReturn(false);
         = Mockito.mock(SubscriptionTransition.class);
        Mockito.when(.getBundleId()).thenReturn(bundleId);
        Mockito.when(.getRequestedTransitionTime()).thenReturn(new DateTime(2010, 1, 2, 3, 4, 5, .));
        Mockito.when(.getEffectiveTransitionTime()).thenReturn(new DateTime(2011, 2, 3, 4, 5, 6, .));
        Mockito.when(.getNextEventCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 49, .));
        final UUID subscriptionId = .getSubscriptionId();
        final UUID nextEventId = .getNextEventId();
         = Mockito.mock(BlockingState.class);
        Mockito.when(.getId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getBlockedId()).thenReturn(bundleId);
        Mockito.when(.getStateName()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getTimestamp()).thenReturn(new DateTime(2010, 2, 2, 4, 22, 22, .));
        Mockito.when(.isBlockBilling()).thenReturn(true);
        Mockito.when(.isBlockChange()).thenReturn(false);
        Mockito.when(.isBlockEntitlement()).thenReturn(true);
        Mockito.when(.getDescription()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getService()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 0, .));
        final UUID blockingStateId = .getId();
         = Mockito.mock(InvoiceItem.class);
        Mockito.when(.getId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getInvoiceId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getAccountId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getStartDate()).thenReturn(new LocalDate(1999, 9, 9));
        Mockito.when(.getEndDate()).thenReturn(new LocalDate(2048, 1, 1));
        Mockito.when(.getAmount()).thenReturn(new BigDecimal("12000"));
        Mockito.when(.getCurrency()).thenReturn(.);
        Mockito.when(.getDescription()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getBundleId()).thenReturn(bundleId);
        Mockito.when(.getSubscriptionId()).thenReturn(subscriptionId);
        Mockito.when(.getPlanName()).thenReturn(planName);
        Mockito.when(.getPhaseName()).thenReturn(phaseName);
        Mockito.when(.getRate()).thenReturn(new BigDecimal("1203"));
        Mockito.when(.getLinkedItemId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 51, .));
        final UUID invoiceItemId = .getId();
        final UUID invoiceId = UUID.randomUUID();
         = Mockito.mock(InvoicePayment.class);
        Mockito.when(.getId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getPaymentId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getInvoiceId()).thenReturn(invoiceId);
        Mockito.when(.getPaymentDate()).thenReturn(new DateTime(2003, 4, 12, 3, 34, 52, .));
        Mockito.when(.getPaymentCookieId()).thenReturn(UUID.randomUUID());
        final UUID invoicePaymentId = .getId();
         = Mockito.mock(Invoice.class);
        Mockito.when(.getId()).thenReturn(invoiceId);
        Mockito.when(.getInvoiceItems()).thenReturn(ImmutableList.<InvoiceItem>of());
        Mockito.when(.getNumberOfItems()).thenReturn(1);
        Mockito.when(.getPayments()).thenReturn(ImmutableList.<InvoicePayment>of());
        Mockito.when(.getNumberOfPayments()).thenReturn(1);
        Mockito.when(.getAccountId()).thenReturn(accountId);
        Mockito.when(.getInvoiceNumber()).thenReturn(42);
        Mockito.when(.getInvoiceDate()).thenReturn(new LocalDate(1954, 12, 1));
        Mockito.when(.getTargetDate()).thenReturn(new LocalDate(2017, 3, 4));
        Mockito.when(.getCurrency()).thenReturn(.);
        Mockito.when(.getPaidAmount()).thenReturn(.);
        Mockito.when(.getOriginalChargedAmount()).thenReturn(new BigDecimal("1922"));
        Mockito.when(.getChargedAmount()).thenReturn(new BigDecimal("100293"));
        Mockito.when(.getCreditedAmount()).thenReturn(new BigDecimal("283"));
        Mockito.when(.getRefundedAmount()).thenReturn(new BigDecimal("384"));
        Mockito.when(.getBalance()).thenReturn(new BigDecimal("18376"));
        Mockito.when(.isMigrationInvoice()).thenReturn(false);
         = Mockito.mock(PaymentAttempt.class);
        Mockito.when(.getId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getEffectiveDate()).thenReturn(new DateTime(2019, 12, 30, 10, 10, 10, .));
        Mockito.when(.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 54, .));
        final PaymentMethodPlugin paymentMethodPlugin = Mockito.mock(PaymentMethodPlugin.class);
        Mockito.when(paymentMethodPlugin.getExternalPaymentMethodId()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(paymentMethodPlugin.isDefaultPaymentMethod()).thenReturn(true);
         = Mockito.mock(PaymentMethod.class);
        Mockito.when(.getId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getAccountId()).thenReturn(accountId);
        Mockito.when(.isActive()).thenReturn(true);
        Mockito.when(.getPluginName()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getPluginDetail()).thenReturn(paymentMethodPlugin);
        Mockito.when(.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 55, .));
        final UUID paymentMethodId = .getId();
         = Mockito.mock(Payment.class);
        Mockito.when(.getId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getAccountId()).thenReturn(accountId);
        Mockito.when(.getInvoiceId()).thenReturn(invoiceId);
        Mockito.when(.getPaymentMethodId()).thenReturn(paymentMethodId);
        Mockito.when(.getPaymentNumber()).thenReturn(1);
        Mockito.when(.getAmount()).thenReturn(new BigDecimal("199999"));
        Mockito.when(.getPaidAmount()).thenReturn(new BigDecimal("199998"));
        Mockito.when(.getEffectiveDate()).thenReturn(new DateTime(2019, 2, 3, 12, 12, 12, .));
        Mockito.when(.getCurrency()).thenReturn(.);
        Mockito.when(.getAttempts()).thenReturn(ImmutableList.<PaymentAttempt>of());
        Mockito.when(.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 56, .));
         = Mockito.mock(Refund.class);
        Mockito.when(.getId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getPaymentId()).thenReturn(UUID.randomUUID());
        Mockito.when(.isAdjusted()).thenReturn(true);
        Mockito.when(.getRefundAmount()).thenReturn(.);
        Mockito.when(.getCurrency()).thenReturn(.);
        Mockito.when(.getEffectiveDate()).thenReturn(new DateTime(2015, 2, 2, 10, 56, 5, .));
         = Mockito.mock(CustomField.class);
        Mockito.when(.getId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getObjectId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getFieldName()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getFieldValue()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 57, .));
        final UUID fieldId = .getId();
         = Mockito.mock(Tag.class);
        Mockito.when(.getObjectId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getObjectType()).thenReturn(.);
        Mockito.when(.getTagDefinitionId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 58, .));
        final UUID tagId = .getId();
         = Mockito.mock(TagDefinition.class);
        Mockito.when(.getId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getName()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getDescription()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.isControlTag()).thenReturn(false);
        Mockito.when(.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 59, .));
         = Mockito.mock(AuditLog.class);
        Mockito.when(.getId()).thenReturn(UUID.randomUUID());
        Mockito.when(.getUserName()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getCreatedDate()).thenReturn(new DateTime(2012, 12, 31, 23, 59, 59, .));
        Mockito.when(.getReasonCode()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getUserToken()).thenReturn(UUID.randomUUID().toString());
        Mockito.when(.getComment()).thenReturn(UUID.randomUUID().toString());
        // Real class for the binding to work with JDBI
         = new TestCallContext();
        final UUID tenantId = .getTenantId();
        final RecordIdApi recordIdApi = Mockito.mock(RecordIdApi.class);
        Mockito.when(recordIdApi.getRecordId(accountId.)).thenReturn();
        Mockito.when(recordIdApi.getRecordId(nextEventId.)).thenReturn();
        Mockito.when(recordIdApi.getRecordId(invoiceId.)).thenReturn();
        Mockito.when(recordIdApi.getRecordId(invoiceItemId.)).thenReturn();
        Mockito.when(recordIdApi.getRecordId(invoicePaymentId.)).thenReturn();
        Mockito.when(recordIdApi.getRecordId(blockingStateId.)).thenReturn();
        Mockito.when(recordIdApi.getRecordId(fieldId.)).thenReturn();
        Mockito.when(recordIdApi.getRecordId(tagId.)).thenReturn();
        Mockito.when(recordIdApi.getRecordId(tenantId.)).thenReturn();
         = Mockito.mock(OSGIKillbillAPI.class);
        Mockito.when(.getRecordIdApi()).thenReturn(recordIdApi);
         = Mockito.mock(OSGIKillbillDataSource.class);
        final DataSource dataSource = Mockito.mock(DataSource.class);
        Mockito.when(.getDataSource()).thenReturn(dataSource);
    }
New to GrepCode? Check out our FAQ X