//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);
StatelessSession mockStatelessSession = mock(StatelessSession.class);
when(mockSessionFactory.openStatelessSession()).thenReturn(mockStatelessSession);
org.hibernate.SQLQuery mockQuery = mock(org.hibernate.SQLQuery.class);
when(mockStatelessSession.createSQLQuery(any(String.class))).thenReturn(mockQuery);
when(mockQuery.uniqueResult()).thenReturn("1000");
ScrollableDataSource mockDataSource = mock(ScrollableDataSource.class);
PowerMockito.whenNew(ScrollableDataSource.class).withArguments(eq(mockEntityManager), eq(databaseType), any())
.thenReturn(mockDataSource);
List<Object[]> resultList = new ArrayList<Object[]>();
resultList.add(new Object[] { 100, 100, 100, 100, 100 });
resultList.add(new Object[] { 100, System.currentTimeMillis() - 100l, 100, 100, 100 });
for (int index = 0; index < 15; index++) {
when(mockDataSource.getData(eq(0), anyInt())).thenReturn(resultList);
when(mockDataSource.getData(eq(2), anyInt())).thenReturn(new ArrayList<Object[]>());
}
ResultSetFuture mockResultSetFuture = mock(ResultSetFuture.class);
when(mockCassandraSession.executeAsync(any(Query.class))).thenReturn(mockResultSetFuture);
//create object to test and inject required dependencies
AggregateDataMigrator objectUnderTest = new AggregateDataMigrator(MigrationTable.ONE_HOUR, mockConfig);
//run code under test