Skip to content

Commit

Permalink
Added comments.
Browse files Browse the repository at this point in the history
Added License.
  • Loading branch information
Manoj Mathai committed Oct 28, 2010
1 parent d676116 commit 7f1f6a5
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 120 deletions.
19 changes: 19 additions & 0 deletions MIT-license.txt
@@ -0,0 +1,19 @@
Copyright (c) 2010, Kwanzoo Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
242 changes: 122 additions & 120 deletions src/com/kwanzoo/recurly/test/RecurlyTest.java
Expand Up @@ -39,24 +39,24 @@ public void setUp(){
}
}

//Create an account that doesn't exist and check if it can be found and check if the updates were applied correctly
//Manipulate Accounts
@Test public void test1() throws Exception{

//create fresh account
final String accountCode = getRandStr(5);
String username = getRandStr(5);
String firstName = getRandStr(5);
String lastName = getRandStr(5);
String email = getRandStr(5)+"@site.com";
String companyName = getRandStr(5);
final String accountCode = getRandStr(5);
String username = getRandStr(5);
String firstName = getRandStr(5);
String lastName = getRandStr(5);
String email = getRandStr(5)+"@site.com";
String companyName = getRandStr(5);

Account account = new Account();

account.accountCode = accountCode;
account.username = username;
account.firstName = firstName;
account.lastName = lastName;
account.email = email;
account.username = username;
account.firstName = firstName;
account.lastName = lastName;
account.email = email;
account.companyName = companyName;

account.create();
Expand All @@ -72,16 +72,16 @@ public void setUp(){
assertEquals(companyName, account.companyName);

//check if update works
username = getRandStr(5);
firstName = getRandStr(5);
lastName = getRandStr(5);
email = getRandStr(5)+"@site.com";
companyName = getRandStr(5);

account.username = username;
account.firstName = firstName;
account.lastName = lastName;
account.email = email;
username = getRandStr(5);
firstName = getRandStr(5);
lastName = getRandStr(5);
email = getRandStr(5)+"@site.com";
companyName = getRandStr(5);

account.username = username;
account.firstName = firstName;
account.lastName = lastName;
account.email = email;
account.companyName = companyName;

account.update();
Expand All @@ -96,62 +96,64 @@ public void setUp(){
assertEquals(companyName, account.companyName);
}

//Manipulate billing info
@Test public void test2() throws Exception{

//create fresh account
final String accountCode = getRandStr(5);
final String username = getRandStr(5);
String firstName = getRandStr(5);
String lastName = getRandStr(5);
final String email = getRandStr(5)+"@site.com";
final String companyName = getRandStr(5);
final String accountCode = getRandStr(5);
final String username = getRandStr(5);
String firstName = getRandStr(5);
String lastName = getRandStr(5);
final String email = getRandStr(5)+"@site.com";
final String companyName = getRandStr(5);

Account account = new Account();

account.accountCode = accountCode;
account.username = username;
account.firstName = firstName;
account.lastName = lastName;
account.email = email;
account.username = username;
account.firstName = firstName;
account.lastName = lastName;
account.email = email;
account.companyName = companyName;

account.create();

account = Account.get(accountCode);

//check if adding billing info for a fresh account works
final String number = "1";
String verificationValue = getRandStr(4);
Integer expirationMonth = (new Random()).nextInt(12);
Integer expirationYear = 2010 + (new Random()).nextInt(20);

firstName = account.firstName;
lastName = account.lastName;
String address1 = getRandStr(10);
String address2 = getRandStr(10);
String city = "San Fransisco";
String state = "CA";
String zip = "20240";
String country = "US";
String ipAddress = "127.0.0.1";
final String number = "1"; //bogus credit card number accepted by test gateway
String verificationValue = getRandStr(4);
Integer expirationMonth = (new Random()).nextInt(12) + 1;
Integer expirationYear = 2011 + (new Random()).nextInt(20);

firstName = account.firstName;
lastName = account.lastName;
String address1 = getRandStr(10);
String address2 = getRandStr(10);
String city = "San Fransisco";
String state = "CA";
String zip = "20240";
String country = "US";
String ipAddress = "127.0.0.1";

CreditCard creditCard = new CreditCard();

creditCard.number = number;
creditCard.verificationValue = verificationValue;
creditCard.expirationMonth = expirationMonth;
creditCard.expirationYear = expirationYear;

BillingInfo billingInfo = new BillingInfo(accountCode);
billingInfo.firstName = firstName;
billingInfo.lastName = lastName;
billingInfo.address1 = address1;
billingInfo.address2 = address2;
billingInfo.city = city;
billingInfo.state = state;
billingInfo.zip = zip;
billingInfo.country = country;
billingInfo.ipAddress = ipAddress;
billingInfo.creditCard = creditCard;
billingInfo.firstName = firstName;
billingInfo.lastName = lastName;
billingInfo.address1 = address1;
billingInfo.address2 = address2;
billingInfo.city = city;
billingInfo.state = state;
billingInfo.zip = zip;
billingInfo.country = country;
billingInfo.ipAddress = ipAddress;
billingInfo.creditCard = creditCard;

billingInfo.update();

Expand All @@ -167,27 +169,27 @@ public void setUp(){
assertEquals(country, billingInfo.country);
assertEquals(ipAddress, billingInfo.ipAddress);

//Recurly somehow returns empty for both the fields below
//Recurly returns empty for both the fields below
//assertEquals(billingInfo.creditCard.number);
//assertEquals(billingInfo.creditCard.verificationValue);

assertEquals(expirationMonth, billingInfo.creditCard.expirationMonth);
assertEquals(expirationYear, billingInfo.creditCard.expirationYear);

//check if updating billing info of an account that already has billing info works
verificationValue = getRandStr(4);
expirationMonth = (new Random()).nextInt(12);
expirationYear = 2010 + (new Random()).nextInt(20);

firstName = account.firstName;
lastName = account.lastName;
address1 = getRandStr(10);
address2 = getRandStr(10);
city = "Some City";
state = "NJ";
zip = "94105";
country = "IN";
ipAddress = "127.0.0.1";
verificationValue = getRandStr(4);
expirationMonth = (new Random()).nextInt(12) + 1;
expirationYear = 2010 + (new Random()).nextInt(20);

firstName = account.firstName;
lastName = account.lastName;
address1 = getRandStr(10);
address2 = getRandStr(10);
city = "Some City";
state = "NJ";
zip = "94105";
country = "IN";
ipAddress = "127.0.0.1";

creditCard = new CreditCard();
creditCard.number = number;
Expand All @@ -196,16 +198,16 @@ public void setUp(){
creditCard.expirationYear = expirationYear;

billingInfo = new BillingInfo(accountCode);
billingInfo.firstName = firstName;
billingInfo.lastName = lastName;
billingInfo.address1 = address1;
billingInfo.address2 = address2;
billingInfo.city = city;
billingInfo.state = state;
billingInfo.zip = zip;
billingInfo.country = country;
billingInfo.ipAddress = ipAddress;
billingInfo.creditCard = creditCard;
billingInfo.firstName = firstName;
billingInfo.lastName = lastName;
billingInfo.address1 = address1;
billingInfo.address2 = address2;
billingInfo.city = city;
billingInfo.state = state;
billingInfo.zip = zip;
billingInfo.country = country;
billingInfo.ipAddress = ipAddress;
billingInfo.creditCard = creditCard;

billingInfo.checkedUpdate();

Expand All @@ -223,43 +225,45 @@ public void setUp(){

}

//Manipulate subscriptions
@Test public void test3() throws Exception{
//create fresh account
final String accountCode = getRandStr(5);
final String username = getRandStr(5);
String firstName = getRandStr(5);
String lastName = getRandStr(5);
final String email = getRandStr(5)+"@site.com";
final String companyName = getRandStr(5);
final String accountCode = getRandStr(5);
final String username = getRandStr(5);
String firstName = getRandStr(5);
String lastName = getRandStr(5);
final String email = getRandStr(5)+"@site.com";
final String companyName = getRandStr(5);

Account account = new Account();

account.accountCode = accountCode;
account.username = username;
account.firstName = firstName;
account.lastName = lastName;
account.email = email;
account.username = username;
account.firstName = firstName;
account.lastName = lastName;
account.email = email;
account.companyName = companyName;

account.create();

account = Account.get(accountCode);

//subscribe to plan1
final String number = "1";
final String verificationValue = getRandStr(4);
final Integer expirationMonth = (new Random()).nextInt(12);
final Integer expirationYear = 2010 + (new Random()).nextInt(20);

firstName = account.firstName;
lastName = account.lastName;
final String address1 = getRandStr(10);
final String address2 = getRandStr(10);
final String city = "San Fransisco";
final String state = "NM";
final String zip = "99546";
final String country = "US";
final String ipAddress = "127.0.0.1";
final String number = "1";
final String verificationValue = getRandStr(4);
final Integer expirationMonth = (new Random()).nextInt(12);
final Integer expirationYear = 2011 + (new Random()).nextInt(20);

firstName = account.firstName;
lastName = account.lastName;

final String address1 = getRandStr(10);
final String address2 = getRandStr(10);
final String city = "San Fransisco";
final String state = "NM";
final String zip = "99546";
final String country = "US";
final String ipAddress = "127.0.0.1";

final CreditCard creditCard = new CreditCard();
creditCard.number = number;
Expand All @@ -268,20 +272,20 @@ public void setUp(){
creditCard.expirationYear = expirationYear;

BillingInfo billingInfo = new BillingInfo(accountCode);
billingInfo.firstName = firstName;
billingInfo.lastName = lastName;
billingInfo.address1 = address1;
billingInfo.address2 = address2;
billingInfo.city = city;
billingInfo.state = state;
billingInfo.zip = zip;
billingInfo.country = country;
billingInfo.ipAddress = ipAddress;
billingInfo.creditCard = creditCard;
billingInfo.firstName = firstName;
billingInfo.lastName = lastName;
billingInfo.address1 = address1;
billingInfo.address2 = address2;
billingInfo.city = city;
billingInfo.state = state;
billingInfo.zip = zip;
billingInfo.country = country;
billingInfo.ipAddress = ipAddress;
billingInfo.creditCard = creditCard;

account.billingInfo = billingInfo;

String planCode = "testplan1";
String planCode = "testplan1"; //one of the plans defined in your recurly account
Integer quantity = 1;

Subscription subscription = new Subscription(accountCode);
Expand Down Expand Up @@ -310,7 +314,7 @@ public void setUp(){
assertEquals(country, billingInfo.country);
assertEquals(ipAddress, billingInfo.ipAddress);

//Recurly somehow returns a null for both the fields below, probably for security purposes.
//Recurly returns a null for both the fields below.
//assertEquals(billingInfo.creditCard.number);
//assertEquals(billingInfo.creditCard.verificationValue);

Expand All @@ -319,7 +323,7 @@ public void setUp(){

//downgrade check

planCode = "testplan0";
planCode = "testplan0"; // a plan with lesser features/rate than testplan1
quantity = 2;

subscription = new Subscription(accountCode);
Expand All @@ -338,11 +342,11 @@ public void setUp(){

//upgrade check

planCode = "testplan2";
planCode = "testplan2"; // a plan with better features/rate than testplan1
quantity = 3;

subscription = new Subscription(accountCode);
subscription.timeframe = "now";
subscription.timeframe = "now"; //immediate upgrade
subscription.planCode = planCode;
subscription.quantity = quantity;

Expand All @@ -362,7 +366,5 @@ public void setUp(){

subscription = Subscription.get(accountCode);
assertEquals("canceled", subscription.state);


}
}

0 comments on commit 7f1f6a5

Please sign in to comment.