Skip to content

Commit

Permalink
Add "recommended" as possible value of Source card[three_d_secure] (#830
Browse files Browse the repository at this point in the history
)

**Motivation**
Introduced in API version `2018-02-06`

**Testing**
Added unit tests
  • Loading branch information
mshafrir-stripe authored Mar 5, 2019
1 parent 4c3058b commit 2196ecb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ public class SourceCardData extends StripeSourceTypeModel {
REQUIRED,
OPTIONAL,
NOT_SUPPORTED,
RECOMMENDED,
UNKNOWN
})
public @interface ThreeDSecureStatus { }
public static final String REQUIRED = "required";
public static final String OPTIONAL = "optional";
public static final String NOT_SUPPORTED = "not_supported";
public static final String RECOMMENDED = "recommended";
public static final String UNKNOWN = "unknown";

private static final String FIELD_ADDRESS_LINE1_CHECK = "address_line1_check";
Expand Down Expand Up @@ -239,11 +241,11 @@ static SourceCardData fromString(String jsonString) {
}
}

@VisibleForTesting
@Nullable
@ThreeDSecureStatus
private static String asThreeDSecureStatus(@Nullable String threeDSecureStatus) {
String nullChecked = StripeJsonUtils.nullIfNullOrEmpty(threeDSecureStatus);
if (nullChecked == null) {
static String asThreeDSecureStatus(@Nullable String threeDSecureStatus) {
if (StripeJsonUtils.nullIfNullOrEmpty(threeDSecureStatus) == null) {
return null;
}

Expand All @@ -253,6 +255,8 @@ private static String asThreeDSecureStatus(@Nullable String threeDSecureStatus)
return OPTIONAL;
} else if (NOT_SUPPORTED.equalsIgnoreCase(threeDSecureStatus)) {
return NOT_SUPPORTED;
} else if (RECOMMENDED.equalsIgnoreCase(threeDSecureStatus)) {
return RECOMMENDED;
} else {
return UNKNOWN;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

/**
* Test class for {@link SourceCardData}.
Expand Down Expand Up @@ -70,4 +71,16 @@ public void testHashCode() {
assertEquals(CARD_DATA.hashCode(),
SourceCardData.fromString(EXAMPLE_JSON_SOURCE_CARD_DATA_WITH_APPLE_PAY).hashCode());
}

@Test
public void testAsThreeDSecureStatus() {
assertEquals(SourceCardData.REQUIRED, SourceCardData.asThreeDSecureStatus("required"));
assertEquals(SourceCardData.OPTIONAL, SourceCardData.asThreeDSecureStatus("optional"));
assertEquals(SourceCardData.NOT_SUPPORTED,
SourceCardData.asThreeDSecureStatus("not_supported"));
assertEquals(SourceCardData.RECOMMENDED,
SourceCardData.asThreeDSecureStatus("recommended"));
assertEquals(SourceCardData.UNKNOWN, SourceCardData.asThreeDSecureStatus("unknown"));
assertNull(SourceCardData.asThreeDSecureStatus(""));
}
}

0 comments on commit 2196ecb

Please sign in to comment.