### Question:
TspDataLoaderFactory implements DataLoaderFactory { @Override public DataLoader create() { if (configuration.getTspDataLoaderFactory() == null) { return createDataLoader(); } else { logger.debug("Using custom TSP data loader factory provided by the configuration"); return configuration.getTspDataLoaderFactory().create(); } } TspDataLoaderFactory(Configuration configuration, String userAgent); @Override DataLoader create();  }### Answer:
@Test public void testDefaultTspDataLoaderCreatedWhenCustomDataLoaderNotConfigured() { DataLoader dataLoader = new TspDataLoaderFactory(configuration, MOCK_USER_AGENT_VALUE).create(); Assert.assertTrue("Data loader should be of type " + SkTimestampDataLoader.class.getSimpleName(), dataLoader instanceof SkTimestampDataLoader); Assert.assertEquals(MOCK_USER_AGENT_VALUE, ((SkTimestampDataLoader) dataLoader).getUserAgent()); }
@Test public void testCustomDataLoaderCreatedWhenCustomDataLoaderConfigured() { DataLoader mockDataLoader = Mockito.mock(DataLoader.class); DataLoaderFactory mockDataLoaderFactory = Mockito.mock(DataLoaderFactory.class); Mockito.doReturn(mockDataLoader).when(mockDataLoaderFactory).create(); configuration.setTspDataLoaderFactory(mockDataLoaderFactory); DataLoader dataLoader = new TspDataLoaderFactory(configuration, MOCK_USER_AGENT_VALUE).create(); Assert.assertSame(mockDataLoader, dataLoader); Mockito.verify(mockDataLoaderFactory, Mockito.times(1)).create(); Mockito.verifyNoMoreInteractions(mockDataLoaderFactory, mockDataLoader); }