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.dao.factory;
 
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
 
 
 
 
 
 
     @Override
     @BeforeMethod(groups = "fast")
     public void setUp() throws Exception {
         super.setUp();
 
         final OSGIKillbillDataSource osgiKillbillDataSource = Mockito.mock(OSGIKillbillDataSource.class);
 
         final DataSource dataSource = Mockito.mock(DataSource.class);
         Mockito.when(osgiKillbillDataSource.getDataSource()).thenReturn(dataSource);
 
         final OSGIKillbillLogService osgiKillbillLogService = Mockito.mock(OSGIKillbillLogService.class);
         Mockito.doAnswer(new Answer() {
             @Override
             public Object answer(final InvocationOnMock invocationthrows Throwable {
                 .info(Arrays.toString(invocation.getArguments()));
                 return null;
             }
         }).when(osgiKillbillLogService).log(Mockito.anyInt(), Mockito.anyString());
 
          = new BusinessBundleSummaryFactory(osgiKillbillLogServicenull, BusinessExecutor.newCachedThreadPool());
     }
 
     @Test(groups = "fast")
     public void testFilterBsts() throws Exception {
         final UUID bundleId1 = UUID.randomUUID();
         final DateTime bundle1StartDate = new DateTime(2012, 1, 1, 1, 1);
         final DateTime bundle1PhaseDate = new DateTime(2012, 2, 2, 1, 1);
         final UUID bundleId2 = UUID.randomUUID();
         final DateTime bundle2StartDate = new DateTime(2012, 2, 1, 1, 1);
         final DateTime bundle2PhaseDate = new DateTime(2012, 3, 2, 1, 1);
         final UUID bundleId3 = UUID.randomUUID();
         final DateTime bundle3StartDate = new DateTime(2012, 3, 1, 1, 1);
 
         // Real order is: bundleId1 ADD_BASE, bundleId2 ADD_BASE, bundleId1 SYSTEM_CHANGE_BASE, bundleId3 ADD_BASE bundleId2 SYSTEM_CHANGE_BASE
                 createBst(bundleId1"ADD_BASE"bundle1StartDate),
                 createBst(bundleId1"SYSTEM_CHANGE_BASE"bundle1PhaseDate),
                 createBst(bundleId2"ADD_BASE"bundle2StartDate),
                 createBst(bundleId2"SYSTEM_CHANGE_BASE"bundle2PhaseDate),
                 createBst(bundleId3"ADD_BASE"bundle3StartDate),
                 createBst(UUID.randomUUID(), "ADD_ADD_ON"new DateTime(.))
                                                                                                                                 );
 
         final Map<UUIDIntegerrankForBundle = new LinkedHashMap<UUIDInteger>();
        .filterBstsForBasePlans(bstsrankForBundlebstForBundle);
        final List<BusinessSubscriptionTransitionModelDaofilteredBsts = ImmutableList.<BusinessSubscriptionTransitionModelDao>copyOf(bstForBundle.values());
        Assert.assertEquals(filteredBsts.size(), 3);
        Assert.assertEquals(filteredBsts.get(0).getBundleId(), bundleId1);
        Assert.assertEquals(filteredBsts.get(0).getNextStartDate(), bundle1PhaseDate);
        Assert.assertEquals(filteredBsts.get(1).getBundleId(), bundleId2);
        Assert.assertEquals(filteredBsts.get(1).getNextStartDate(), bundle2PhaseDate);
        Assert.assertEquals(filteredBsts.get(2).getBundleId(), bundleId3);
        Assert.assertEquals(filteredBsts.get(2).getNextStartDate(), bundle3StartDate);
    }
    private BusinessSubscriptionTransitionModelDao createBst(final UUID bundleIdfinal String eventStringfinal DateTime startDate) {
        final SubscriptionBundle bundle = Mockito.mock(SubscriptionBundle.class);
        Mockito.when(bundle.getId()).thenReturn(bundleId);
        final DateTime requestedTimestamp = new DateTime(2012, 7, 21, 10, 10, 10, .);
        final BusinessSubscriptionEvent event = BusinessSubscriptionEvent.valueOf(eventString);
        final BusinessSubscription previousSubscription = null// We don't look at it
        final Product product = Mockito.mock(Product.class);
        Mockito.when(product.getCategory()).thenReturn(event.getCategory());
        final Plan plan = Mockito.mock(Plan.class);
        Mockito.when(plan.getProduct()).thenReturn(product);
        final BusinessSubscription nextSubscription = new BusinessSubscription(plan,
                                                                               null,
                                                                               null,
                                                                               .,
                                                                               startDate,
                                                                               .);
                                                          ,
                                                          bundle,
                                                          ,
                                                          ,
                                                          requestedTimestamp,
                                                          event,
                                                          previousSubscription,
                                                          nextSubscription,
                                                          ,
                                                          ,
                                                          );
    }
New to GrepCode? Check out our FAQ X