diff --git a/src/main/java/com/invoiced/entity/Subscription.java b/src/main/java/com/invoiced/entity/Subscription.java index 3b756a7..d9061b1 100644 --- a/src/main/java/com/invoiced/entity/Subscription.java +++ b/src/main/java/com/invoiced/entity/Subscription.java @@ -104,7 +104,7 @@ public final class Subscription extends AbstractEntity { @JsonProperty(value = "mrr", access = JsonProperty.Access.WRITE_ONLY) public Long mrr; - @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonProperty("addons") public SubscriptionAddon[] addons; diff --git a/src/test/java/com/invoiced/entity/SubscriptionTest.java b/src/test/java/com/invoiced/entity/SubscriptionTest.java index c587753..bf0cdfd 100644 --- a/src/test/java/com/invoiced/entity/SubscriptionTest.java +++ b/src/test/java/com/invoiced/entity/SubscriptionTest.java @@ -96,6 +96,28 @@ public void testSave() { } } + public void testRemoveAddons() { + Connection conn = new Connection("api_key", "http://localhost:8080"); + + Subscription subscription = conn.newSubscription(); + + try { + subscription = subscription.retrieve(595); + subscription.quantity = 2L; + subscription.save(); + + assertTrue("Subscription addon should not be deleted", subscription.addons.length == 1); + + subscription.addons = new SubscriptionAddon[] {}; + subscription.save(); + + assertTrue("Subscription addon should be deleted", subscription.addons.length == 0); + + } catch (Exception e) { + fail(e.getMessage()); + } + } + @Test public void testCancel() {