-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also create `Supplier` interface to be able to use a fake `UidSupplier` in tests to ensure that a non-null id is returned.
- Loading branch information
1 parent
3db7504
commit 4682f37
Showing
12 changed files
with
124 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.stripe.android; | ||
|
||
import android.support.annotation.NonNull; | ||
|
||
final class StripeUid { | ||
@NonNull final String value; | ||
|
||
@NonNull | ||
static StripeUid create(@NonNull String uid) { | ||
return new StripeUid(uid); | ||
} | ||
|
||
private StripeUid(@NonNull String value) { | ||
this.value = value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.stripe.android; | ||
|
||
import android.support.annotation.NonNull; | ||
|
||
interface Supplier<T> { | ||
@NonNull T get(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.stripe.android; | ||
|
||
import android.content.ContentResolver; | ||
import android.content.Context; | ||
import android.provider.Settings; | ||
import android.support.annotation.NonNull; | ||
|
||
final class UidSupplier implements Supplier<StripeUid> { | ||
@NonNull private final ContentResolver mContentResolver; | ||
|
||
UidSupplier(@NonNull Context context) { | ||
mContentResolver = context.getApplicationContext().getContentResolver(); | ||
} | ||
|
||
@SuppressWarnings("HardwareIds") | ||
@NonNull | ||
public StripeUid get() { | ||
return StripeUid.create( | ||
Settings.Secure.getString(mContentResolver, Settings.Secure.ANDROID_ID)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
stripe/src/test/java/com/stripe/android/FakeUidSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.stripe.android; | ||
|
||
import android.support.annotation.NonNull; | ||
|
||
import java.util.UUID; | ||
|
||
final class FakeUidSupplier implements Supplier<StripeUid> { | ||
@NonNull private final String mValue; | ||
|
||
FakeUidSupplier() { | ||
this(UUID.randomUUID().toString()); | ||
} | ||
|
||
FakeUidSupplier(@NonNull String mValue) { | ||
this.mValue = mValue; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public StripeUid get() { | ||
return StripeUid.create(mValue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters