Search in sources :

Example 1 with MockDataLoadManager

use of com.amazon.dataloader.testResources.MockDataLoadManager in project zype-firebuilder by zype.

the class DataLoadManagerTest method testUpdaterListenerRegisterationAndDeregistration.

/**
 * Tests successful registration and de-registration of {@link com.amazon.dataloader
 * .dataloadmanager.DataLoadManager.IDataUpdateListener}s.
 */
@Test
public void testUpdaterListenerRegisterationAndDeregistration() throws Exception {
    MockDataLoadManager.IDataUpdateListener dataUpdateListener = mock(DataLoadManager.IDataUpdateListener.class);
    MockDataLoadManager testDataLoadManager = new MockDataLoadManager(InstrumentationRegistry.getTargetContext());
    // Register update listener and validate successful registration
    testDataLoadManager.registerUpdateListener(dataUpdateListener);
    assertTrue("Listener not registered ", testDataLoadManager.isUpdateListenerRegistered(dataUpdateListener));
    // Deregister update listener and validate successful de-registration
    testDataLoadManager.deregisterUpdateListener(dataUpdateListener);
    assertFalse("Listener still registered ", testDataLoadManager.isUpdateListenerRegistered(dataUpdateListener));
}
Also used : MockDataLoadManager(com.amazon.dataloader.testResources.MockDataLoadManager) MockDataLoadManager(com.amazon.dataloader.testResources.MockDataLoadManager) Test(org.junit.Test)

Example 2 with MockDataLoadManager

use of com.amazon.dataloader.testResources.MockDataLoadManager in project zype-firebuilder by zype.

the class DataUpdaterModuleTest method setUpManager.

/**
 * Sets up DataLoadManager as MockDataLoadManager
 */
private void setUpManager() throws Exception {
    mTestDataLoadManager = new MockDataLoadManager(InstrumentationRegistry.getTargetContext());
    mTestDataLoadManager.registerUpdateListener(mUpdateListener);
}
Also used : MockDataLoadManager(com.amazon.dataloader.testResources.MockDataLoadManager)

Example 3 with MockDataLoadManager

use of com.amazon.dataloader.testResources.MockDataLoadManager in project zype-firebuilder by zype.

the class DataUpdaterModuleTest method testNonScheduledDataUpdater.

/**
 * Tests non-scheduled data updater, verifying that DataUpdaterTask is not executed by
 * Scheduler
 */
@Test
public void testNonScheduledDataUpdater() throws Exception {
    MockDataLoadManager testDataLoadManagerNoUpdater = new MockDataLoadManagerWithoutDataUpdater(InstrumentationRegistry.getTargetContext());
    testDataLoadManagerNoUpdater.registerUpdateListener(mUpdateListener);
    Thread.sleep(5000);
    verify(MockCacheManagerAdapter.mockCacheManagerAdapter, never()).clearCache();
    verify(mUpdateListener, never()).onSuccess(any(Data.class));
}
Also used : MockDataLoadManagerWithoutDataUpdater(com.amazon.dataloader.testResources.MockDataLoadManagerWithoutDataUpdater) MockDataLoadManager(com.amazon.dataloader.testResources.MockDataLoadManager) Data(com.amazon.utils.model.Data) Test(org.junit.Test)

Example 4 with MockDataLoadManager

use of com.amazon.dataloader.testResources.MockDataLoadManager in project zype-firebuilder by zype.

the class DataLoadManagerTest method runRecipeOnTestDataLoadManager.

/**
 * Calls the {@link MockDataLoadManager#cookRecipe(Recipe, Object, IRecipeCookerCallbacks,
 * Bundle, String[])} with the mock recipe and the param recipeCallback. It also verifies that
 * the {@link VerifyUtil#verified()} is called the required number of times.
 *
 * @param recipeCallback    The recipe callback handler to be passed to the {@link
 *                          DataLoadManager}.
 * @param verifyCalledCount Number of times the verified call should have been called.
 */
private void runRecipeOnTestDataLoadManager(IRecipeCookerCallbacks recipeCallback, int verifyCalledCount) throws Exception {
    new MockDataLoadManager(mContext).cookRecipe(recipe, null, recipeCallback, null, null);
    Thread.sleep(1000);
    verify(verifyUtil, times(verifyCalledCount)).verified();
}
Also used : MockDataLoadManager(com.amazon.dataloader.testResources.MockDataLoadManager)

Aggregations

MockDataLoadManager (com.amazon.dataloader.testResources.MockDataLoadManager)4 Test (org.junit.Test)2 MockDataLoadManagerWithoutDataUpdater (com.amazon.dataloader.testResources.MockDataLoadManagerWithoutDataUpdater)1 Data (com.amazon.utils.model.Data)1