59
59
import java .util .Set ;
60
60
61
61
import static org .junit .Assert .assertEquals ;
62
+ import static org .mockito .ArgumentMatchers .any ;
62
63
import static org .mockito .Mockito .times ;
63
64
64
65
/**
@@ -85,6 +86,7 @@ public void init() throws Exception {
85
86
bigQueryMock = Mockito .mock (BigQuery .class );
86
87
Table tableMock = Mockito .mock (Table .class );
87
88
Dataset datasetMock = Mockito .mock (Dataset .class );
89
+ Mockito .when (bigQueryMock .getDataset (any (DatasetId .class ))).thenReturn (datasetMock );
88
90
Mockito .when (bigQueryMock .getTable (ArgumentMatchers .any ())).thenReturn (tableMock );
89
91
Mockito .when (bigQueryMock .getDataset ("demodataset" )).thenReturn (datasetMock );
90
92
PowerMockito .spy (BigQueryUtils .class );
@@ -281,7 +283,7 @@ public void testGetMaximumExistingSequenceNumberSingleInvocations() throws Excep
281
283
282
284
// Subtest : One Table
283
285
Set <SourceTable > allTables = generateSourceTableSet (1 );
284
- Mockito .when (bigQueryMock .listTables (ArgumentMatchers . anyString ( ))).thenReturn (generateBQTablesPage (1 ));
286
+ Mockito .when (bigQueryMock .listTables (any ( DatasetId . class ))).thenReturn (generateBQTablesPage (1 ));
285
287
long tableResult = BigQueryUtils .getMaximumExistingSequenceNumber (allTables , PROJECT ,
286
288
null , bigQueryMock , null , 1000 );
287
289
assertEquals (1L , tableResult );
@@ -316,7 +318,7 @@ public void testGetMaximumExistingSequenceNumberDoubleInvocations() throws Excep
316
318
317
319
//Subtest1 : 1001 Tables : Should call bigquery 2 times. 1000+1
318
320
Set <SourceTable > allTables = generateSourceTableSet (1001 );
319
- Mockito .when (bigQueryMock .listTables (ArgumentMatchers . anyString ( ))).thenReturn (generateBQTablesPage (1001 ));
321
+ Mockito .when (bigQueryMock .listTables (any ( DatasetId . class ))).thenReturn (generateBQTablesPage (1001 ));
320
322
long tableResult = BigQueryUtils .getMaximumExistingSequenceNumber (allTables , PROJECT ,
321
323
null , bigQueryMock , null , 1000 );
322
324
assertEquals (2L , tableResult );
@@ -341,7 +343,7 @@ public void testGetMaximumExistingSequenceNumberTripleInvocations() throws Excep
341
343
342
344
//Subtest1 : 2500 Tables : Should call bigquery 3 times. 1000+1000+500
343
345
Set <SourceTable > allTables = generateSourceTableSet (2500 );
344
- Mockito .when (bigQueryMock .listTables (ArgumentMatchers . anyString ( ))).thenReturn (generateBQTablesPage (2500 ));
346
+ Mockito .when (bigQueryMock .listTables (any ( DatasetId . class ))).thenReturn (generateBQTablesPage (2500 ));
345
347
long tableResult = BigQueryUtils .getMaximumExistingSequenceNumber (allTables , PROJECT ,
346
348
null , bigQueryMock , null , 1000 );
347
349
assertEquals (3L , tableResult );
@@ -354,7 +356,7 @@ public void testGetMaximumExistingSequenceNumberTripleInvocations() throws Excep
354
356
@ Test
355
357
public void testGetMaximumExistingSequenceNumberEmptyDatasetName () throws Exception {
356
358
Set <SourceTable > allTables = generateSourceTableSet (1 );
357
- Mockito .when (bigQueryMock .listTables (ArgumentMatchers . anyString ( ))).thenReturn (generateBQTablesPage (1 ));
359
+ Mockito .when (bigQueryMock .listTables (any ( DatasetId . class ))).thenReturn (generateBQTablesPage (1 ));
358
360
long tableResult0 = BigQueryUtils .getMaximumExistingSequenceNumber (allTables , PROJECT ,
359
361
"" , bigQueryMock , null , 1000 );
360
362
assertEquals (1 , tableResult0 );
0 commit comments