diff --git a/pom.xml b/pom.xml index 340188e..5850514 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ org.apache.commons commons-lang3 - 3.3 + 3.3.1 commons-beanutils diff --git a/src/main/java/com/paymill/models/Client.java b/src/main/java/com/paymill/models/Client.java index 9d0b2f2..05a9d8c 100755 --- a/src/main/java/com/paymill/models/Client.java +++ b/src/main/java/com/paymill/models/Client.java @@ -263,13 +263,35 @@ public Client.Filter byOfferId( final String offerId ) { return this; } - public Client.Filter byCreatedAt( final Date startCreatedAt, final Date endCreatedAt ) { - this.createdAt = String.valueOf( startCreatedAt.getTime() ) + "-" + String.valueOf( endCreatedAt.getTime() ); + /** + * Creates filter for createdAt date. If endDate is given the filter is set for range from date to endDate. If endDate is + * null the filter search for exact match. + * @param date + * Start or exact date + * @param endDate + * End date for the period or null. + * @throws IllegalArgumentException + * When date is null. + * @return {@link Client.Filter} object with populated filter for createdAt. + */ + public Client.Filter byCreatedAt( final Date date, final Date endDate ) { + this.createdAt = DateRangeBuilder.execute( date, endDate ); return this; } - public Client.Filter byUpdatedAt( final Date startUpdatedAt, final Date endUpdatedAt ) { - this.updatedAt = String.valueOf( startUpdatedAt.getTime() ) + "-" + String.valueOf( endUpdatedAt.getTime() ); + /** + * Creates filter for updatedAt date. If endDate is given the filter is set for range from date to endDate. If endDate is + * null the filter search for exact match. + * @param date + * Start or exact date + * @param endDate + * End date for the period or null. + * @throws IllegalArgumentException + * When date is null. + * @return {@link Client.Filter} object with populated filter for updatedAt. + */ + public Client.Filter byUpdatedAt( final Date date, final Date endDate ) { + this.updatedAt = DateRangeBuilder.execute( date, endDate ); return this; } } diff --git a/src/main/java/com/paymill/models/DateRangeBuilder.java b/src/main/java/com/paymill/models/DateRangeBuilder.java new file mode 100644 index 0000000..f5fc7a2 --- /dev/null +++ b/src/main/java/com/paymill/models/DateRangeBuilder.java @@ -0,0 +1,21 @@ +package com.paymill.models; + +import java.util.Date; + +final class DateRangeBuilder { + + private final static int OFFSET = 1000; + + final static String execute( final Date startDate, final Date endDate ) { + if( startDate == null ) + throw new IllegalArgumentException( "Start date can not be null" ); + + String range = String.valueOf( startDate.getTime() / DateRangeBuilder.OFFSET ); + if( endDate != null ) { + range += "-" + String.valueOf( endDate.getTime() / DateRangeBuilder.OFFSET ); + } + + return range; + } + +} diff --git a/src/main/java/com/paymill/models/Offer.java b/src/main/java/com/paymill/models/Offer.java index 8ae07c3..88b75e3 100755 --- a/src/main/java/com/paymill/models/Offer.java +++ b/src/main/java/com/paymill/models/Offer.java @@ -317,13 +317,35 @@ public Offer.Filter byAmountLessThan( final int amount ) { return this; } - public Offer.Filter byCreatedAt( Date startCreatedAt, Date endCreatedAt ) { - this.createdAt = String.valueOf( startCreatedAt.getTime() ) + "-" + String.valueOf( endCreatedAt.getTime() ); + /** + * Creates filter for createdAt date. If endDate is given the filter is set for range from date to endDate. If endDate is + * null the filter search for exact match. + * @param date + * Start or exact date + * @param endDate + * End date for the period or null. + * @throws IllegalArgumentException + * When date is null. + * @return {@link Offer.Filter} object with populated filter for createdAt. + */ + public Offer.Filter byCreatedAt( final Date date, final Date endDate ) { + this.createdAt = DateRangeBuilder.execute( date, endDate ); return this; } - public Offer.Filter byUpdatedAt( Date startUpdatedAt, Date endUpdatedAt ) { - this.updatedAt = String.valueOf( startUpdatedAt.getTime() ) + "-" + String.valueOf( endUpdatedAt.getTime() ); + /** + * Creates filter for updatedAt date. If endDate is given the filter is set for range from date to endDate. If endDate is + * null the filter search for exact match. + * @param date + * Start or exact date + * @param endDate + * End date for the period or null. + * @throws IllegalArgumentException + * When date is null. + * @return {@link Offer.Filter} object with populated filter for updatedAt. + */ + public Offer.Filter byUpdatedAt( Date date, Date endDate ) { + this.updatedAt = DateRangeBuilder.execute( date, endDate ); return this; } } diff --git a/src/main/java/com/paymill/models/Payment.java b/src/main/java/com/paymill/models/Payment.java index 6aa9baf..ad13915 100755 --- a/src/main/java/com/paymill/models/Payment.java +++ b/src/main/java/com/paymill/models/Payment.java @@ -311,7 +311,8 @@ public void setCreatedAt( final Date createdAt ) { * Creation date representation is seconds. */ public void setCreatedAt( final long seconds ) { - this.createdAt = new Date( seconds * 1000 ); + if( seconds > 0 ) + this.createdAt = new Date( seconds * 1000 ); } /** @@ -423,8 +424,19 @@ public Payment.Filter byCardType( final Payment.CardType cardType ) { return this; } - public Payment.Filter byCreatedAt( final Date startCreatedAt, final Date endCreatedAt ) { - this.createdAt = String.valueOf( startCreatedAt.getTime() ) + "-" + String.valueOf( endCreatedAt.getTime() ); + /** + * Creates filter for createdAt date. If endDate is given the filter is set for range from date to endDate. If endDate is + * null the filter search for exact match. + * @param date + * Start or exact date + * @param endDate + * End date for the period or null. + * @throws IllegalArgumentException + * When date is null. + * @return {@link Payment.Filter} object with populated filter for createdAt. + */ + public Payment.Filter byCreatedAt( final Date date, final Date endDate ) { + this.createdAt = DateRangeBuilder.execute( date, endDate ); return this; } } diff --git a/src/main/java/com/paymill/models/Preauthorization.java b/src/main/java/com/paymill/models/Preauthorization.java index e9cec82..857e7c5 100755 --- a/src/main/java/com/paymill/models/Preauthorization.java +++ b/src/main/java/com/paymill/models/Preauthorization.java @@ -156,7 +156,8 @@ public void setCreatedAt( final Date createdAt ) { * Creation date representation is seconds. */ public void setCreatedAt( final long seconds ) { - this.createdAt = new Date( seconds * 1000 ); + if( seconds > 0 ) + this.createdAt = new Date( seconds * 1000 ); } /** @@ -183,7 +184,8 @@ public void setUpdatedAt( final Date updatedAt ) { * Last update representation is seconds. */ public void setUpdatedAt( final long seconds ) { - this.updatedAt = new Date( seconds * 1000 ); + if( seconds > 0 ) + this.updatedAt = new Date( seconds * 1000 ); } public enum Status { @@ -262,8 +264,19 @@ public Preauthorization.Filter byAmountLessThan( final int amount ) { return this; } - public Preauthorization.Filter byCreatedAt( final Date startCreatedAt, final Date endCreatedAt ) { - this.createdAt = String.valueOf( startCreatedAt.getTime() ) + "-" + String.valueOf( endCreatedAt.getTime() ); + /** + * Creates filter for createdAt date. If endDate is given the filter is set for range from date to endDate. If endDate is + * null the filter search for exact match. + * @param date + * Start or exact date + * @param endDate + * End date for the period or null. + * @throws IllegalArgumentException + * When date is null. + * @return {@link Preauthorization.Filter} object with populated filter for createdAt. + */ + public Preauthorization.Filter byCreatedAt( final Date date, final Date endDate ) { + this.createdAt = DateRangeBuilder.execute( date, endDate ); return this; } } diff --git a/src/main/java/com/paymill/models/Refund.java b/src/main/java/com/paymill/models/Refund.java index 3826504..35b556f 100755 --- a/src/main/java/com/paymill/models/Refund.java +++ b/src/main/java/com/paymill/models/Refund.java @@ -146,7 +146,8 @@ public void setCreatedAt( final Date createdAt ) { * Creation date representation is seconds. */ public void setCreatedAt( final long seconds ) { - this.createdAt = new Date( seconds * 1000 ); + if( seconds > 0 ) + this.createdAt = new Date( seconds * 1000 ); } /** @@ -173,7 +174,8 @@ public void setUpdatedAt( final Date updatedAt ) { * Last update representation is seconds. */ public void setUpdatedAt( final long seconds ) { - this.updatedAt = new Date( seconds * 1000 ); + if( seconds > 0 ) + this.updatedAt = new Date( seconds * 1000 ); } public static Refund.Filter createFilter() { @@ -227,8 +229,19 @@ public Refund.Filter byAmountLessThan( final int amount ) { return this; } - public Refund.Filter byCreatedAt( final Date startCreatedAt, final Date endCreatedAt ) { - this.createdAt = String.valueOf( startCreatedAt.getTime() ) + "-" + String.valueOf( endCreatedAt.getTime() ); + /** + * Creates filter for createdAt date. If endDate is given the filter is set for range from date to endDate. If endDate is + * null the filter search for exact match. + * @param date + * Start or exact date + * @param endDate + * End date for the period or null. + * @throws IllegalArgumentException + * When date is null. + * @return {@link Refund.Filter} object with populated filter for createdAt. + */ + public Refund.Filter byCreatedAt( final Date date, final Date endDate ) { + this.createdAt = DateRangeBuilder.execute( date, endDate ); return this; } } diff --git a/src/main/java/com/paymill/models/Subscription.java b/src/main/java/com/paymill/models/Subscription.java index 5af36e5..72fe363 100755 --- a/src/main/java/com/paymill/models/Subscription.java +++ b/src/main/java/com/paymill/models/Subscription.java @@ -262,7 +262,8 @@ public void setCreatedAt( final Date createdAt ) { * Creation date representation is seconds. */ public void setCreatedAt( final long seconds ) { - this.createdAt = new Date( seconds * 1000 ); + if( seconds > 0 ) + this.createdAt = new Date( seconds * 1000 ); } /** @@ -289,7 +290,8 @@ public void setUpdatedAt( final Date updatedAt ) { * Last update representation is seconds. */ public void setUpdatedAt( final long seconds ) { - this.updatedAt = new Date( seconds * 1000 ); + if( seconds > 0 ) + this.updatedAt = new Date( seconds * 1000 ); } public static Subscription.Filter createFilter() { @@ -317,8 +319,19 @@ public Subscription.Filter byOfferId( final String offerId ) { return this; } - public Subscription.Filter byCreatedAt( final Date startCreatedAt, final Date endCreatedAt ) { - this.createdAt = String.valueOf( startCreatedAt.getTime() ) + "-" + String.valueOf( endCreatedAt.getTime() ); + /** + * Creates filter for createdAt date. If endDate is given the filter is set for range from date to endDate. If endDate is + * null the filter search for exact match. + * @param date + * Start or exact date + * @param endDate + * End date for the period or null. + * @throws IllegalArgumentException + * When date is null. + * @return {@link Subscription.Filter} object with populated filter for createdAt. + */ + public Subscription.Filter byCreatedAt( final Date date, final Date endDate ) { + this.createdAt = DateRangeBuilder.execute( date, endDate ); return this; } diff --git a/src/main/java/com/paymill/models/Transaction.java b/src/main/java/com/paymill/models/Transaction.java index bcaab1d..458c4c0 100755 --- a/src/main/java/com/paymill/models/Transaction.java +++ b/src/main/java/com/paymill/models/Transaction.java @@ -233,7 +233,8 @@ public void setCreatedAt( final Date createdAt ) { * Creation date representation is seconds. */ public void setCreatedAt( final long seconds ) { - this.createdAt = new Date( seconds * 1000 ); + if( seconds > 0 ) + this.createdAt = new Date( seconds * 1000 ); } /** @@ -260,7 +261,8 @@ public void setUpdatedAt( final Date updatedAt ) { * Last update representation is seconds. */ public void setUpdatedAt( final long seconds ) { - this.updatedAt = new Date( seconds * 1000 ); + if( seconds > 0 ) + this.updatedAt = new Date( seconds * 1000 ); } public static Transaction.Filter createFilter() { @@ -328,13 +330,35 @@ public Transaction.Filter byDescription( final String description ) { return this; } - public Transaction.Filter byCreatedAt( final Date startCreatedAt, final Date endCreatedAt ) { - this.createdAt = String.valueOf( startCreatedAt.getTime() ) + "-" + String.valueOf( endCreatedAt.getTime() ); + /** + * Creates filter for createdAt date. If endDate is given the filter is set for range from date to endDate. If endDate is + * null the filter search for exact match. + * @param date + * Start or exact date + * @param endDate + * End date for the period or null. + * @throws IllegalArgumentException + * When date is null. + * @return {@link Transaction.Filter} object with populated filter for createdAt. + */ + public Transaction.Filter byCreatedAt( final Date date, final Date endDate ) { + this.createdAt = DateRangeBuilder.execute( date, endDate ); return this; } - public Transaction.Filter byUpdatedAt( final Date startCreatedAt, final Date endCreatedAt ) { - this.updatedAt = String.valueOf( startCreatedAt.getTime() ) + "-" + String.valueOf( endCreatedAt.getTime() ); + /** + * Creates filter for updatedAt date. If endDate is given the filter is set for range from date to endDate. If endDate is + * null the filter search for exact match. + * @param date + * Start or exact date + * @param endDate + * End date for the period or null. + * @throws IllegalArgumentException + * When date is null. + * @return {@link Transaction.Filter} object with populated filter for updatedAt. + */ + public Transaction.Filter byUpdatedAt( final Date date, final Date endDate ) { + this.updatedAt = DateRangeBuilder.execute( date, endDate ); return this; } diff --git a/src/main/java/com/paymill/models/Webhook.java b/src/main/java/com/paymill/models/Webhook.java index ce3ee1e..30622c1 100755 --- a/src/main/java/com/paymill/models/Webhook.java +++ b/src/main/java/com/paymill/models/Webhook.java @@ -176,7 +176,8 @@ public void setCreatedAt( final Date createdAt ) { * Creation date representation is seconds. */ public void setCreatedAt( final long seconds ) { - this.createdAt = new Date( seconds * 1000 ); + if( seconds > 0 ) + this.createdAt = new Date( seconds * 1000 ); } /** @@ -203,7 +204,8 @@ public void setUpdatedAt( final Date updatedAt ) { * Last update representation is seconds. */ public void setUpdatedAt( final long seconds ) { - this.updatedAt = new Date( seconds * 1000 ); + if( seconds > 0 ) + this.updatedAt = new Date( seconds * 1000 ); } public static Webhook.Filter createFilter() { @@ -239,8 +241,19 @@ public Webhook.Filter byEmail( String email ) { return this; } - public Webhook.Filter byCreatedAt( Date startCreatedAt, Date endCreatedAt ) { - this.createdAt = String.valueOf( startCreatedAt.getTime() ) + "-" + String.valueOf( endCreatedAt.getTime() ); + /** + * Creates filter for createdAt date. If endDate is given the filter is set for range from date to endDate. If endDate is + * null the filter search for exact match. + * @param date + * Start or exact date + * @param endDate + * End date for the period or null. + * @throws IllegalArgumentException + * When date is null. + * @return {@link Webhook.Filter} object with populated filter for createdAt. + */ + public Webhook.Filter byCreatedAt( Date date, Date endDate ) { + this.createdAt = DateRangeBuilder.execute( date, endDate ); return this; } } diff --git a/src/test/java/com/paymill/services/ClientServiceTest.java b/src/test/java/com/paymill/services/ClientServiceTest.java index b68b345..764de77 100644 --- a/src/test/java/com/paymill/services/ClientServiceTest.java +++ b/src/test/java/com/paymill/services/ClientServiceTest.java @@ -1,9 +1,11 @@ package com.paymill.services; +import java.text.ParseException; import java.util.ArrayList; import java.util.Date; import java.util.List; +import org.apache.commons.lang3.time.DateUtils; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -16,7 +18,7 @@ public class ClientServiceTest { - private String email = "john.rambo@qaiware.com"; + private String email = "zz.john.rambo@qaiware.com"; private String description = "Boom, boom, shake the room"; private ClientService clientService; @@ -92,19 +94,18 @@ public void testShow_shouldSecceed() { @Test( dependsOnMethods = "testCreate_WithDescription_shouldSecceed" ) public void testUpdate_shouldSecceed() { - this.clientWithDescriptionAndEmail.setEmail( "john.firstblood.rambo@qaiware.com" ); + this.clientWithDescriptionAndEmail.setEmail( "zz.john.firstblood.rambo@qaiware.com" ); this.clientWithDescriptionAndEmail.setDescription( "Boom, boom, update the room" ); this.clientWithDescriptionAndEmail.setCreatedAt( new Date( System.currentTimeMillis() * 100 ) ); this.clientService.update( this.clientWithDescriptionAndEmail ); this.validateClient( this.clientWithDescriptionAndEmail ); - Assert.assertEquals( this.clientWithDescriptionAndEmail.getEmail(), "john.firstblood.rambo@qaiware.com" ); + Assert.assertEquals( this.clientWithDescriptionAndEmail.getEmail(), "zz.john.firstblood.rambo@qaiware.com" ); Assert.assertEquals( this.clientWithDescriptionAndEmail.getDescription(), "Boom, boom, update the room" ); Assert.assertNull( this.clientWithDescriptionAndEmail.getAppId() ); } - // @Test( dependsOnMethods = "testUpdate_shouldSecceed" ) - // TODO[VNi]: uncomment when API returns null instead of empty array + @Test( dependsOnMethods = "testUpdate_shouldSecceed" ) public void testListOrderByEmailDesc() { Client.Order order = Client.createOrder().byEmail().desc(); @@ -113,13 +114,14 @@ public void testListOrderByEmailDesc() { Assert.assertNotNull( clients ); Assert.assertFalse( clients.isEmpty() ); - Assert.assertEquals( clients.get( 0 ).getEmail(), "john.rambo@qaiware.com" ); + Assert.assertEquals( clients.get( 0 ).getEmail(), "zz.john.rambo@qaiware.com" ); } - // @Test( dependsOnMethods = "testListOrderByEmailDesc" ) - // TODO[VNi]: uncomment when API returns null instead of empty array - public void testListFilterByEmail() { - Client.Filter filter = Client.createFilter().byEmail( "john.rambo@qaiware.com" ); + @Test( dependsOnMethods = "testListOrderByEmailDesc" ) + public void testListFilterByEmailAndCreatedAt() throws ParseException { + Date startCreatedAt = DateUtils.parseDate( "2014-03-13", "yyyy-MM-dd" ); + Date endCreatedAt = DateUtils.parseDate( "2014-03-14", "yyyy-MM-dd" ); + Client.Filter filter = Client.createFilter().byEmail( "john.rambo@qaiware.com" ).byCreatedAt( startCreatedAt, endCreatedAt ); PaymillList wrapper = this.clientService.list( filter, null ); List clients = wrapper.getData(); @@ -129,6 +131,21 @@ public void testListFilterByEmail() { Assert.assertEquals( clients.get( 0 ).getEmail(), "john.rambo@qaiware.com" ); Assert.assertEquals( clients.get( 1 ).getEmail(), "john.rambo@qaiware.com" ); + Assert.assertEquals( clients.size(), 11 ); + } + + @Test( dependsOnMethods = "testListFilterByEmailAndCreatedAt" ) + public void testListFilterByStartCreatedAt() throws ParseException { + Date startCreatedAt = new Date( 1394183537000L ); + System.out.println( startCreatedAt ); + Client.Filter filter = Client.createFilter().byCreatedAt( startCreatedAt, null ); + + PaymillList wrapper = this.clientService.list( filter, null ); + List clients = wrapper.getData(); + + Assert.assertNotNull( clients ); + Assert.assertFalse( clients.isEmpty() ); + Assert.assertEquals( clients.size(), 1 ); } private void validateClient( final Client client ) { diff --git a/src/test/java/com/paymill/services/OfferServiceTest.java b/src/test/java/com/paymill/services/OfferServiceTest.java index cd329c5..9b99414 100644 --- a/src/test/java/com/paymill/services/OfferServiceTest.java +++ b/src/test/java/com/paymill/services/OfferServiceTest.java @@ -13,7 +13,7 @@ public class OfferServiceTest { - private Integer amount = 900; + private Integer amount = 10000; private String currency = "EUR"; private String interval = "1 MONTH"; private String name = "Chuck Testa"; @@ -41,7 +41,7 @@ public void testCreate_WithoutTrial_shouldSecceed() { @Test public void testCreate_WithTrial_shouldSecceed() { - Offer offer = this.offerService.create( amount + 1, currency, interval, name, trialPeriodDays ); + Offer offer = this.offerService.create( this.amount + 1, currency, interval, name, trialPeriodDays ); this.validatesOffer( offer ); Assert.assertEquals( offer.getAmount(), Integer.valueOf( this.amount + 1 ) ); Assert.assertEquals( offer.getName(), this.name ); @@ -69,7 +69,7 @@ public void testUpdate_shouldSucceed() { // Assert.assertEquals( offer.getTrialPeriodDays(), this.trialPeriodDays ); } - // @Test( dependsOnMethods = "testUpdate_shouldSucceed" ) + @Test( dependsOnMethods = "testUpdate_shouldSucceed" ) public void testListOfferByAmountDesc() { Offer.Order order = Offer.createOrder().byAmount().desc(); @@ -79,10 +79,9 @@ public void testListOfferByAmountDesc() { Assert.assertNotNull( offers ); Assert.assertFalse( offers.isEmpty() ); Assert.assertEquals( offers.get( 0 ).getAmount(), Integer.valueOf( this.amount + 1 ) ); - Assert.assertEquals( offers.get( 1 ).getAmount(), this.amount ); } - // @Test( dependsOnMethods = "testListOfferByAmountDesc" ) + @Test( dependsOnMethods = "testListOfferByAmountDesc" ) public void testListFilterByAmount() { Offer.Filter filter = Offer.createFilter().byAmount( this.amount ); @@ -91,8 +90,6 @@ public void testListFilterByAmount() { Assert.assertNotNull( offers ); Assert.assertFalse( offers.isEmpty() ); - Assert.assertEquals( this.offers.size() - 1, offers.size() ); - Assert.assertEquals( offers.get( 0 ).getAmount(), this.amount ); } diff --git a/src/test/java/com/paymill/services/PaymentServiceTest.java b/src/test/java/com/paymill/services/PaymentServiceTest.java index 2d86f7c..c2eb174 100644 --- a/src/test/java/com/paymill/services/PaymentServiceTest.java +++ b/src/test/java/com/paymill/services/PaymentServiceTest.java @@ -100,7 +100,7 @@ public void testListOrderByCreatedAt() throws InterruptedException { Assert.assertNotEquals( paymentsAsc.get( 0 ).getId(), paymentsDesc.get( 0 ).getId() ); } - // @Test( dependsOnMethods = "testListOrderByCreatedAt" ) + @Test( dependsOnMethods = "testListOrderByCreatedAt" ) public void testListFilterByCardType() { Payment.Filter filter = Payment.createFilter().byCardType( Payment.CardType.VISA ); diff --git a/src/test/java/com/paymill/services/PreauthorizationServiceTest.java b/src/test/java/com/paymill/services/PreauthorizationServiceTest.java index 63983ec..cb7044b 100644 --- a/src/test/java/com/paymill/services/PreauthorizationServiceTest.java +++ b/src/test/java/com/paymill/services/PreauthorizationServiceTest.java @@ -72,16 +72,16 @@ public void testListOrderByOffer() { Assert.assertEquals( preauthorizationDesc.get( preauthorizationDesc.size() - 1 ).getId(), preauthorizationAsc.get( 0 ).getId() ); } - // @Test( dependsOnMethods = "testCreateWithPayment_shouldSucceed" ) - // TODO[VNi]: uncomment when API returns null instead of empty array + //TODO[VNi]: uncomment when API returns null instead of empty array + //@Test( dependsOnMethods = "testCreateWithPayment_shouldSucceed" ) public void testListOrderByFilterAmountGreaterThan() { Preauthorization.Filter filter = Preauthorization.createFilter().byAmountGreaterThan( amount - 100 ); List preauthorization = this.preauthorizationService.list( filter, null ).getData(); Assert.assertFalse( preauthorization.isEmpty() ); } - // @Test( dependsOnMethods = "testListOrderByFilterAmountGreaterThan" ) - // TODO[VNi]: uncomment when API returns null instead of empty array + //TODO[VNi]: uncomment when API returns null instead of empty array + //@Test( dependsOnMethods = "testListOrderByFilterAmountGreaterThan" ) public void testListOrderByFilterAmountLessThan() { Preauthorization.Filter filter = Preauthorization.createFilter().byAmountLessThan( amount + 100 ); List preauthorizations = this.preauthorizationService.list( filter, null ).getData(); diff --git a/src/test/java/com/paymill/services/SubscriptionServiceTest.java b/src/test/java/com/paymill/services/SubscriptionServiceTest.java index de654cd..c192506 100644 --- a/src/test/java/com/paymill/services/SubscriptionServiceTest.java +++ b/src/test/java/com/paymill/services/SubscriptionServiceTest.java @@ -6,7 +6,6 @@ import org.apache.commons.lang3.StringUtils; import org.testng.Assert; -import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -59,23 +58,6 @@ public void setUp() { this.subscriptions = new ArrayList(); } - @AfterClass - public void tearDown() { - // for( Subscription subscription : this.subscriptions ) { - // Assert.assertNull( subscription.getCanceledAt() ); - // this.subscriptionService.delete( subscription ); - // } - - //TODO[VNi]: There is an API error, creating a payment results in 2 payments in paymill - // PaymillList wrapper = this.paymentService.list(); - // for( Payment payment : wrapper.getData() ) { - // this.paymentService.delete( payment ); - // } - // this.clientService.delete( this.client ); - // this.offerService.delete( this.offer1 ); - // this.offerService.delete( this.offer2 ); - } - @Test public void testCreateWithPayment() { this.subscription = this.subscriptionService.createWithOfferAndPayment( offer1, payment ); @@ -165,7 +147,8 @@ public void testUpdate() { Assert.assertTrue( this.subscription.getCancelAtPeriodEnd() ); } - // @Test( dependsOnMethods = "testUpdate" ) + //TODO[VNi]: uncomment when API returns null instead of empty array + //@Test( dependsOnMethods = "testUpdate" ) public void testListOrderByOffer() { // TODO[VNi]: There is an API error: No sorting by offer. Subscription.Order orderDesc = Subscription.createOrder().byOffer().desc(); @@ -181,7 +164,8 @@ public void testListOrderByOffer() { Assert.assertEquals( subscriptionsDesc.get( 1 ).getOffer().getId(), subscriptionsAsc.get( 0 ).getOffer().getId() ); } - // @Test( dependsOnMethods = "testUpdate" ) + //TODO[VNi]: uncomment when API returns null instead of empty array + //@Test( dependsOnMethods = "testUpdate" ) public void testListOrderByCreatedAt() { Subscription.Order orderDesc = Subscription.createOrder().byCreatedAt().desc(); Subscription.Order orderAsc = Subscription.createOrder().byCreatedAt().asc();