Source:
<code>public void testCreateTrialExtensionCoupon() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); final Plan planData = TestUtils.createRandomPlan(CURRENCY); final Coupon couponData = TestUtils.createRandomCoupon(); couponData.setName("apitrialext"); couponData.setCouponCode("apitrialext"); couponData.setTrialExtensionAmount(3); couponData.setTrialExtensionUnit("month"); couponData.setDiscountType("trial_extension"); try { final Account account = recurlyClient.createAccount(accountData); final Plan plan = recurlyClient.createPlan(planData); <START> final Coupon coupon = recurlyClient.createCoupon(couponData); <END> billingInfoData.setAccount(account); final BillingInfo billingInfo = recurlyClient.createOrUpdateBillingInfo(billingInfoData); Assert.assertNotNull(billingInfo); final Subscription subscriptionData = new Subscription(); subscriptionData.setPlanCode(plan.getPlanCode()); subscriptionData.setAccount(accountData); subscriptionData.setCurrency(CURRENCY); subscriptionData.setUnitAmountInCents(1242); final Subscription subscription = recurlyClient.createSubscription(subscriptionData); Assert.assertNotNull(subscription); } finally { recurlyClient.clearBillingInfo(accountData.getAccountCode()); recurlyClient.deleteCouponRedemption(accountData.getAccountCode()); recurlyClient.closeAccount(accountData.getAccountCode()); recurlyClient.deletePlan(planData.getPlanCode()); recurlyClient.deleteCoupon(couponData.getCouponCode()); } }</code><technical_language>Is coupon automatically redeemed? applied subscription explicitly</technical_language>

Target:
public void testCreateTrialExtensionCoupon() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); final Plan planData = TestUtils.createRandomPlan(CURRENCY); final Coupon couponData = TestUtils.createRandomCoupon(); couponData.setName("apitrialext"); couponData.setCouponCode("apitrialext"); couponData.setTrialExtensionAmount(3); couponData.setTrialExtensionUnit("month"); couponData.setDiscountType("trial_extension"); final LocalDateTime now = LocalDateTime.now(); try { final Account account = recurlyClient.createAccount(accountData); final Plan plan = recurlyClient.createPlan(planData); final Coupon coupon = recurlyClient.createCoupon(couponData); billingInfoData.setAccount(account); final BillingInfo billingInfo = recurlyClient.createOrUpdateBillingInfo(billingInfoData); Assert.assertNotNull(billingInfo); final Subscription subscriptionData = new Subscription(); subscriptionData.setCouponCode(coupon.getCouponCode()); subscriptionData.setPlanCode(plan.getPlanCode()); subscriptionData.setAccount(accountData); subscriptionData.setCurrency(CURRENCY); subscriptionData.setUnitAmountInCents(1242); final Subscription subscription = recurlyClient.createSubscription(subscriptionData); Assert.assertNotNull(subscription); Assert.assertEquals(subscription.getTrialEndsAt().getMonthOfYear(), now.getMonthOfYear() + 3); } finally { recurlyClient.clearBillingInfo(accountData.getAccountCode()); recurlyClient.deleteCouponRedemption(accountData.getAccountCode()); recurlyClient.closeAccount(accountData.getAccountCode()); recurlyClient.deletePlan(planData.getPlanCode()); recurlyClient.deleteCoupon(couponData.getCouponCode()); } }