### Question:
PentahoSessionHolderRepositoryProvider implements KettleRepositoryProvider { @Override public Repository getRepository() { IPentahoSession session = pentahoSessionSupplier.get(); if ( session == null ) { LOGGER.debug( "No active Pentaho Session, attempting to load PDI repository unauthenticated." ); return null; } ICacheManager cacheManager = cacheManagerFunction.apply( session ); String sessionName = session.getName(); Repository repository = (Repository) cacheManager.getFromRegionCache( REGION, sessionName ); if ( repository == null ) { LOGGER.debug( "Repository not cached for user: " + sessionName + "." ); return null; } return repository; } PentahoSessionHolderRepositoryProvider();  PentahoSessionHolderRepositoryProvider( Supplier<IPentahoSession> pentahoSessionSupplier,
                                                 Function<IPentahoSession, ICacheManager> cacheManagerFunction ); @Override Repository getRepository(); static final String REGION; }### Answer:
@Test public void testGetRepositoryNullSession() { when( pentahoSessionSupplier.get() ).thenReturn(null ); assertNull( pentahoSessionHolderRepositoryProvider.getRepository() ); }
@Test public void testGetRepositoryNull() { when( pentahoSessionSupplier.get() ).thenReturn( pentahoSession ); when( cacheManager.getFromRegionCache( PentahoSessionHolderRepositoryProvider.REGION, SESSION_TEST_NAME ) ).thenReturn( null ); assertNull( pentahoSessionHolderRepositoryProvider.getRepository() ); }
@Test public void testGetRepositorySuccess() { Repository repository = mock( Repository.class ); when( pentahoSessionSupplier.get() ).thenReturn( pentahoSession ); when( cacheManager.getFromRegionCache( PentahoSessionHolderRepositoryProvider.REGION, SESSION_TEST_NAME ) ) .thenReturn( repository ); assertEquals( repository, pentahoSessionHolderRepositoryProvider.getRepository() ); }