Skip to content

Commit

Permalink
use default naming strategy for parameterized tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshgngwr committed Jun 23, 2022
1 parent e60e334 commit b79f1b7
Showing 8 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ class AccountControllerTest {
@MockBean
private SignInTokenDispatchStrategy signInTokenDispatchStrategy;

@ParameterizedTest(name = "{displayName} - email={0} name={1} responseStatus={2} expectingSignInTokenDispatch={3}")
@ParameterizedTest
@MethodSource("signUpTestCases")
void signUp(String email, String name, int expectedResponseStatus, boolean isExpectingSignInTokenDispatch) throws Exception {
doNothing()
@@ -113,7 +113,7 @@ static Stream<Arguments> signUpTestCases() {
);
}

@ParameterizedTest(name = "{displayName} - email={0} responseStatus={1} expectingSignInTokenDispatch={2}")
@ParameterizedTest
@MethodSource("signInTestCases")
void signIn(String email, int expectedResponseStatus, boolean isExpectingSignInTokenDispatch) throws Exception {
// create auth user for test-cases that expect it.
@@ -158,7 +158,7 @@ static Stream<Arguments> signInTestCases() {
);
}

@ParameterizedTest(name = "{displayName} - tokenType={0} responseStatus={1}")
@ParameterizedTest
@MethodSource("signOutTestCases")
void signOut_withHeader(JwtType tokenType, int expectedResponseStatus) throws Exception {
// create signed refresh-tokens as expected by various test cases.
@@ -182,7 +182,7 @@ void signOut_withHeader(JwtType tokenType, int expectedResponseStatus) throws Ex
}
}

@ParameterizedTest(name = "{displayName} - tokenType={0} responseStatus={1}")
@ParameterizedTest
@MethodSource("signOutTestCases")
void signOut_withCookie(JwtType tokenType, int expectedResponseStatus) throws Exception {
// create signed refresh-tokens as expected by various test cases.
@@ -218,7 +218,7 @@ static Stream<Arguments> signOutTestCases() {
);
}

@ParameterizedTest(name = "{displayName} - tokenType={0} userAgent={1} responseStatus={2}")
@ParameterizedTest
@MethodSource("issueCredentialsTestCases")
void issueCredentials(JwtType tokenType, String userAgent, int expectedResponseStatus) throws Exception {
// create signed refresh-tokens as expected by various test cases.
@@ -256,7 +256,7 @@ static Stream<Arguments> issueCredentialsTestCases() {
);
}

@ParameterizedTest(name = "{displayName} - incompleteSignInAttempts={0} lastSignInAttemptAt={1} responseStatus={2}")
@ParameterizedTest
@MethodSource("emailBlacklistingTestCases")
void emailBlacklisting(int incompleteSignInAttempts, OffsetDateTime lastSignInAttemptAt, int expectedResponseStatus) throws Exception {
val user = createAuthUser(entityManager);
@@ -308,7 +308,7 @@ void getProfile() throws Exception {
assertEquals(authUser.getEmail(), profile.findValue("email").asText());
}

@ParameterizedTest(name = "{displayName} - updatedName={0} updatedEmail={1} responseStatus={2}")
@ParameterizedTest
@MethodSource("updateProfileTestCases")
void updateProfile(String updatedName, String updatedEmail, int expectedResponseStatus) throws Exception {
val authUser = createAuthUser(entityManager);
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ public class BearerTokenAuthFilterTest {
@Autowired
private MockMvc mockMvc;

@ParameterizedTest(name = "{displayName} - tokenType={0} requestPath={1} responseStatus={2}")
@ParameterizedTest
@MethodSource("authTestCases")
void auth(JwtType tokenType, String requestPath, int responseStatus) throws Exception {
val authUser = createAuthUser(entityManager);
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ public class CookieAuthFilterTest {
@Autowired
private MockMvc mockMvc;

@ParameterizedTest(name = "{displayName} - refresh={0} access={1} path={2} responseStatus={3} expectingNewCookies={4}")
@ParameterizedTest
@MethodSource("authTestCases")
void doFilter(
JwtType refreshTokenType,
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ public class SoundControllerTest {
@Autowired
private MockMvc mockMvc;

@ParameterizedTest(name = "{displayName} - isSignedIn={0} isSubscribed={1} isPaymentPending={2} responseStatus={3}")
@ParameterizedTest
@MethodSource("authorizeSegmentRequestTestCases")
void authorizeSegmentRequest(
boolean isSignedIn,
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ public class SubscriptionControllerTest {
@Autowired
private MockMvc mockMvc;

@ParameterizedTest(name = "{displayName} - provider={0} responseStatus={1}")
@ParameterizedTest
@MethodSource("listPlansTestCases")
void listPlans(String provider, int expectedResponseStatus) throws Exception {
val request = get("/v1/subscriptions/plans");
@@ -142,7 +142,7 @@ static Stream<Arguments> listPlansTestCases() {
);
}

@ParameterizedTest(name = "{displayName} - provider={0} wasSubscriptionActive={1} expectedResponseStatus={2}")
@ParameterizedTest
@MethodSource("createSubscriptionTestCases")
void createSubscription(
@NonNull SubscriptionPlan.Provider provider,
@@ -328,7 +328,7 @@ private ResultActions doGetSubscriptionRequest(String accessToken, long subscrip
.header("Authorization", "Bearer " + accessToken));
}

@ParameterizedTest(name = "{displayName} - provider={0} isSubscriptionActive={1} expectedResponseStatus={2}")
@ParameterizedTest
@MethodSource("cancelSubscriptionTestCases")
void cancelSubscription(
@NonNull SubscriptionPlan.Provider provider,
@@ -380,7 +380,7 @@ static Stream<Arguments> cancelSubscriptionTestCases() {
);
}

@ParameterizedTest(name = "{displayName} - session.status={0} session.paymentStatus={1} isSubscriptionActive={2}")
@ParameterizedTest
@MethodSource("handleStripeWebhookEvent_checkoutSessionCompleteTestCases")
void handleStripeWebhookEvent_checkoutSessionComplete(
@NonNull String sessionStatus,
@@ -422,7 +422,7 @@ static Stream<Arguments> handleStripeWebhookEvent_checkoutSessionCompleteTestCas
);
}

@ParameterizedTest(name = "{displayName} - stripeStatus={0} isSubscriptionActive={3} isPaymentPending={4}")
@ParameterizedTest
@MethodSource("handleStripeWebhookEvent_subscriptionEventsTestCases")
void handleStripeWebhookEvent_subscriptionEvents(
@NonNull String stripeSubscriptionStatus,
@@ -550,7 +550,7 @@ void handleStripeWebhookEvent_customerDeletedEvent() throws Exception {
assertNull(customerRepository.findById(authUser.getId()).orElseThrow().getStripeId());
}

@ParameterizedTest(name = "{displayName} - exists={0} owned={1} expectedResponseStatus={2}")
@ParameterizedTest
@MethodSource("getGiftCardTestCases")
void getGiftCard(boolean exists, Boolean owned, int expectedResponseStatus) throws Exception {
val code = "test-gift-card-1";
@@ -577,7 +577,7 @@ static Stream<Arguments> getGiftCardTestCases() {
);
}

@ParameterizedTest(name = "{displayName} - exists={0} owned={1} redeemed={2} expired={3} subscribed={4} expectedResponseStatus={5}")
@ParameterizedTest
@MethodSource("redeemGiftCardTestCases")
void redeemGiftCard(
boolean exists,
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ public class SubscriptionServiceTest {
@Autowired
private SubscriptionService service;

@ParameterizedTest(name = "{displayName} - expectedIsActive={3} expectedIsPaymentPending={4}")
@ParameterizedTest
@MethodSource("handleGooglePlayWebhookEventTestCases")
void handleGooglePlayWebhookEvent(
@NonNull GooglePlaySubscriptionPurchase purchase,
2 changes: 1 addition & 1 deletion src/test/java/com/trynoice/api/sound/SoundServiceTest.java
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ void setUp() {
service = new SoundService(soundConfig, libraryManifestRepository, subscriptionServiceContract);
}

@ParameterizedTest(name = "{displayName} - isSubscribed={1} isRequestingPremiumSegment={2} requestedAudioBitrate={3} hasAccess={4}")
@ParameterizedTest
@MethodSource("authorizeSegmentRequestTestCases")
void authorizeSegmentRequest(
Long principalId,
Original file line number Diff line number Diff line change
@@ -281,7 +281,7 @@ void getSubscription() {
// skipped unit tests, wrote integration tests instead.
}

@ParameterizedTest(name = "{displayName} #{index}")
@ParameterizedTest
@MethodSource("cancelSubscriptionTestCases")
<T extends Throwable> void cancelSubscription(
@NonNull Subscription subscription,

0 comments on commit b79f1b7

Please sign in to comment.