@Test public void testCreateWithCache() { given( mockCache.contains( anyString() ) ).willReturn( true ); MediaItemDataStore mediaItemDataStore = mediaItemDataStoreFactory.create( FAKE_ID ); assertThat( mediaItemDataStore ) .isNotNull() .isInstanceOf( DiskMediaItemDataStore.class ); verify( mockCache, times( 1 ) ).contains( anyString() ); }
public MediaItemDataStore create( final int id ) { Log.d( TAG, "create : enter" ); if( cache.contains( String.valueOf( id ) ) ) { Log.d( TAG, "create : exit, getting mediaItemEntity from cache" ); return new DiskMediaItemDataStore( this.dvrDataStoreFactory, this.contentDataStoreFactory, cache ); } else { Log.d( TAG, "create : exit, getting mediaItemEntity from master backend" ); return createMasterBackendDataStore(); } }
MediaItemDataStoreFactory { public MediaItemDataStore create( final int id ) { Log.d( TAG, "create : enter" ); if( cache.contains( String.valueOf( id ) ) ) { Log.d( TAG, "create : exit, getting mediaItemEntity from cache" ); return new DiskMediaItemDataStore( this.dvrDataStoreFactory, this.contentDataStoreFactory, cache ); } else { Log.d( TAG, "create : exit, getting mediaItemEntity from master backend" ); return createMasterBackendDataStore(); } } }
MediaItemDataStoreFactory { public MediaItemDataStore create( final int id ) { Log.d( TAG, "create : enter" ); if( cache.contains( String.valueOf( id ) ) ) { Log.d( TAG, "create : exit, getting mediaItemEntity from cache" ); return new DiskMediaItemDataStore( this.dvrDataStoreFactory, this.contentDataStoreFactory, cache ); } else { Log.d( TAG, "create : exit, getting mediaItemEntity from master backend" ); return createMasterBackendDataStore(); } } @Inject  MediaItemDataStoreFactory(
            final DvrDataStoreFactory dvrDataStoreFactory,
            final VideoDataStoreFactory videoDataStoreFactory,
            final ContentDataStoreFactory contentDataStoreFactory,
            final SearchDataStoreFactory searchDataStoreFactory,
            final DualCache<MediaItemEntity> cache
    ); }
MediaItemDataStoreFactory { public MediaItemDataStore create( final int id ) { Log.d( TAG, "create : enter" ); if( cache.contains( String.valueOf( id ) ) ) { Log.d( TAG, "create : exit, getting mediaItemEntity from cache" ); return new DiskMediaItemDataStore( this.dvrDataStoreFactory, this.contentDataStoreFactory, cache ); } else { Log.d( TAG, "create : exit, getting mediaItemEntity from master backend" ); return createMasterBackendDataStore(); } } @Inject  MediaItemDataStoreFactory(
            final DvrDataStoreFactory dvrDataStoreFactory,
            final VideoDataStoreFactory videoDataStoreFactory,
            final ContentDataStoreFactory contentDataStoreFactory,
            final SearchDataStoreFactory searchDataStoreFactory,
            final DualCache<MediaItemEntity> cache
    ); MediaItemDataStore create( final int id ); MediaItemDataStore createMasterBackendDataStore(); }
MediaItemDataStoreFactory { public MediaItemDataStore create( final int id ) { Log.d( TAG, "create : enter" ); if( cache.contains( String.valueOf( id ) ) ) { Log.d( TAG, "create : exit, getting mediaItemEntity from cache" ); return new DiskMediaItemDataStore( this.dvrDataStoreFactory, this.contentDataStoreFactory, cache ); } else { Log.d( TAG, "create : exit, getting mediaItemEntity from master backend" ); return createMasterBackendDataStore(); } } @Inject  MediaItemDataStoreFactory(
            final DvrDataStoreFactory dvrDataStoreFactory,
            final VideoDataStoreFactory videoDataStoreFactory,
            final ContentDataStoreFactory contentDataStoreFactory,
            final SearchDataStoreFactory searchDataStoreFactory,
            final DualCache<MediaItemEntity> cache
    ); MediaItemDataStore create( final int id ); MediaItemDataStore createMasterBackendDataStore();  }