31
31
import static fr .free .nrw .commons .contributions .Contribution .SOURCE_GALLERY ;
32
32
import static fr .free .nrw .commons .contributions .Contribution .STATE_COMPLETED ;
33
33
import static fr .free .nrw .commons .contributions .Contribution .STATE_QUEUED ;
34
- import static fr .free .nrw .commons .contributions .ContributionDao .* ;
34
+ import static fr .free .nrw .commons .contributions .ContributionDao .Table ;
35
35
import static fr .free .nrw .commons .contributions .ContributionsContentProvider .BASE_URI ;
36
36
import static fr .free .nrw .commons .contributions .ContributionsContentProvider .uriForId ;
37
- import static org .junit .Assert .*;
37
+ import static org .junit .Assert .assertEquals ;
38
+ import static org .junit .Assert .assertFalse ;
39
+ import static org .junit .Assert .assertNull ;
40
+ import static org .junit .Assert .assertTrue ;
38
41
import static org .mockito .Matchers .any ;
39
42
import static org .mockito .Matchers .eq ;
40
43
import static org .mockito .Matchers .isA ;
@@ -49,22 +52,22 @@ public class ContributionDaoTest {
49
52
50
53
private static final String LOCAL_URI = "http://example.com/" ;
51
54
@ Mock
52
- ContentProviderClient client ;
55
+ private ContentProviderClient client ;
53
56
@ Mock
54
- SQLiteDatabase database ;
57
+ private SQLiteDatabase database ;
55
58
@ Captor
56
- ArgumentCaptor <ContentValues > captor ;
59
+ private ArgumentCaptor <ContentValues > captor ;
57
60
58
61
private Uri contentUri ;
59
62
private ContributionDao testObject ;
60
63
61
64
@ Before
62
- public void setUp () throws Exception {
65
+ public void setUp () {
63
66
MockitoAnnotations .initMocks (this );
64
67
65
68
contentUri = uriForId (111 );
66
69
67
- testObject = new ContributionDao (client );
70
+ testObject = new ContributionDao (() -> client );
68
71
}
69
72
70
73
@ Test
@@ -288,7 +291,7 @@ public void createFromCursor() {
288
291
long uploaded = 456L ;
289
292
MatrixCursor mc = createCursor (created , uploaded , false , LOCAL_URI );
290
293
291
- Contribution c = ContributionDao .fromCursor (mc );
294
+ Contribution c = testObject .fromCursor (mc );
292
295
293
296
assertEquals (uriForId (111 ), c .getContentUri ());
294
297
assertEquals ("file" , c .getFilename ());
@@ -312,7 +315,7 @@ public void createFromCursor() {
312
315
public void createFromCursor_nullableTimestamps () {
313
316
MatrixCursor mc = createCursor (0L , 0L , false , LOCAL_URI );
314
317
315
- Contribution c = ContributionDao .fromCursor (mc );
318
+ Contribution c = testObject .fromCursor (mc );
316
319
317
320
assertNull (c .getTimestamp ());
318
321
assertNull (c .getDateCreated ());
@@ -323,7 +326,7 @@ public void createFromCursor_nullableTimestamps() {
323
326
public void createFromCursor_nullableLocalUri () {
324
327
MatrixCursor mc = createCursor (0L , 0L , false , "" );
325
328
326
- Contribution c = ContributionDao .fromCursor (mc );
329
+ Contribution c = testObject .fromCursor (mc );
327
330
328
331
assertNull (c .getLocalUri ());
329
332
assertNull (c .getDateCreated ());
@@ -333,10 +336,10 @@ public void createFromCursor_nullableLocalUri() {
333
336
@ Test
334
337
public void createFromCursor_booleanEncoding () {
335
338
MatrixCursor mcFalse = createCursor (0L , 0L , false , LOCAL_URI );
336
- assertFalse (ContributionDao .fromCursor (mcFalse ).getMultiple ());
339
+ assertFalse (testObject .fromCursor (mcFalse ).getMultiple ());
337
340
338
341
MatrixCursor mcHammer = createCursor (0L , 0L , true , LOCAL_URI );
339
- assertTrue (ContributionDao .fromCursor (mcHammer ).getMultiple ());
342
+ assertTrue (testObject .fromCursor (mcHammer ).getMultiple ());
340
343
}
341
344
342
345
@ NonNull
0 commit comments