|
8 | 8 | import java.util.*; |
9 | 9 |
|
10 | 10 | import static org.hamcrest.CoreMatchers.*; |
| 11 | +import static org.kohsuke.github.GHMarketplaceAccountType.ORGANIZATION; |
11 | 12 |
|
12 | 13 | /** |
13 | 14 | * Unit test for {@link GitHub}. |
@@ -108,4 +109,49 @@ public void getMeta() throws IOException { |
108 | 109 | assertEquals(19, metaExample.getWeb().size()); |
109 | 110 | } |
110 | 111 | } |
| 112 | + |
| 113 | + @Test |
| 114 | + public void getMyMarketplacePurchases() throws IOException { |
| 115 | + List<GHMarketplaceUserPurchase> userPurchases = gitHub.getMyMarketplacePurchases().asList(); |
| 116 | + assertEquals(2, userPurchases.size()); |
| 117 | + |
| 118 | + for (GHMarketplaceUserPurchase userPurchase : userPurchases) { |
| 119 | + assertFalse(userPurchase.isOnFreeTrial()); |
| 120 | + assertNull(userPurchase.getFreeTrialEndsOn()); |
| 121 | + assertEquals("monthly", userPurchase.getBillingCycle()); |
| 122 | + |
| 123 | + GHMarketplacePlan plan = userPurchase.getPlan(); |
| 124 | + // GHMarketplacePlan - Non-nullable fields |
| 125 | + assertNotNull(plan.getUrl()); |
| 126 | + assertNotNull(plan.getAccountsUrl()); |
| 127 | + assertNotNull(plan.getName()); |
| 128 | + assertNotNull(plan.getDescription()); |
| 129 | + assertNotNull(plan.getPriceModel()); |
| 130 | + assertNotNull(plan.getState()); |
| 131 | + |
| 132 | + // GHMarketplacePlan - primitive fields |
| 133 | + assertNotEquals(0L, plan.getId()); |
| 134 | + assertNotEquals(0L, plan.getNumber()); |
| 135 | + assertTrue(plan.getMonthlyPriceInCents() >= 0); |
| 136 | + |
| 137 | + // GHMarketplacePlan - list |
| 138 | + assertEquals(2, plan.getBullets().size()); |
| 139 | + |
| 140 | + GHMarketplaceAccount account = userPurchase.getAccount(); |
| 141 | + // GHMarketplaceAccount - Non-nullable fields |
| 142 | + assertNotNull(account.getLogin()); |
| 143 | + assertNotNull(account.getUrl()); |
| 144 | + assertNotNull(account.getType()); |
| 145 | + |
| 146 | + // GHMarketplaceAccount - primitive fields |
| 147 | + assertNotEquals(0L, account.getId()); |
| 148 | + |
| 149 | + /* logical combination tests */ |
| 150 | + // Rationale: organization_billing_email is only set when account type is ORGANIZATION. |
| 151 | + if (account.getType() == ORGANIZATION) |
| 152 | + assertNotNull(account.getOrganizationBillingEmail()); |
| 153 | + else |
| 154 | + assertNull(account.getOrganizationBillingEmail()); |
| 155 | + } |
| 156 | + } |
111 | 157 | } |
0 commit comments