@Test
public void testMigrateTask() throws Exception {
//tell the method story as it happens: mock or create dependencies and configure
//those dependencies to get the method under test to completion
DatabaseType databaseType = DatabaseType.Oracle;
DataMigratorConfiguration mockConfig = mock(DataMigratorConfiguration.class);
when(mockConfig.getDatabaseType()).thenReturn(databaseType);
Session mockCassandraSession = mock(Session.class);
when(mockConfig.getSession()).thenReturn(mockCassandraSession);
MetricsIndexMigrator mockMetricsIndexUpdateAccumulator = mock(MetricsIndexMigrator.class);
PowerMockito.whenNew(MetricsIndexMigrator.class)
.withArguments(eq(MigrationTable.ONE_HOUR), eq(mockConfig))
.thenReturn(mockMetricsIndexUpdateAccumulator);
EntityManager mockEntityManager = mock(EntityManager.class);
when(mockConfig.getEntityManager()).thenReturn(mockEntityManager);
org.hibernate.Session mockHibernateSession = mock(org.hibernate.Session.class);
when(mockEntityManager.getDelegate()).thenReturn(mockHibernateSession);
SessionFactory mockSessionFactory = mock(SessionFactory.class);
when(mockHibernateSession.getSessionFactory()).thenReturn(mockSessionFactory);