Skip to content

Commit

Permalink
catalog: See #481. Renaming of effectiveDateForExistingSubscriptons -…
Browse files Browse the repository at this point in the history
…> effectiveDateForExistingSubscriptions
  • Loading branch information
sbrossie committed Mar 24, 2016
1 parent d413b0a commit bc3efa7
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
Expand Up @@ -96,7 +96,7 @@

<plans>
<plan name="pistol-monthly">
<effectiveDateForExistingSubscriptons>2011-03-14T00:00:00+00:00</effectiveDateForExistingSubscriptons>
<effectiveDateForExistingSubscriptions>2011-03-14T00:00:00+00:00</effectiveDateForExistingSubscriptions>
<product>Pistol</product>
<initialPhases>
<phase type="TRIAL">
Expand Down
30 changes: 15 additions & 15 deletions catalog/src/main/java/org/killbill/billing/catalog/DefaultPlan.java
Expand Up @@ -56,9 +56,9 @@ public class DefaultPlan extends ValidatingConfig<StandaloneCatalog> implements
@XmlID
private String name;

//TODO MDW Validation - effectiveDateForExistingSubscriptons > catalog effectiveDate
//TODO MDW Validation - effectiveDateForExistingSubscriptions > catalog effectiveDate
@XmlElement(required = false)
private Date effectiveDateForExistingSubscriptons;
private Date effectiveDateForExistingSubscriptions;

@XmlElement(required = true)
@XmlIDREF
Expand Down Expand Up @@ -86,7 +86,7 @@ public DefaultPlan() {

public DefaultPlan(final String planName, final DefaultPlan in, final PlanPhasePriceOverride[] overrides) {
this.name = planName;
this.effectiveDateForExistingSubscriptons = in.getEffectiveDateForExistingSubscriptons();
this.effectiveDateForExistingSubscriptions = in.getEffectiveDateForExistingSubscriptions();
this.product = (DefaultProduct) in.getProduct();
this.initialPhases = new DefaultPlanPhase[in.getInitialPhases().length];
for (int i = 0; i < overrides.length - 1; i++) {
Expand All @@ -98,8 +98,8 @@ public DefaultPlan(final String planName, final DefaultPlan in, final PlanPhaseP
}

@Override
public Date getEffectiveDateForExistingSubscriptons() {
return effectiveDateForExistingSubscriptons;
public Date getEffectiveDateForExistingSubscriptions() {
return effectiveDateForExistingSubscriptions;
}

@Override
Expand Down Expand Up @@ -190,10 +190,10 @@ public void initialize(final StandaloneCatalog catalog, final URI sourceURI) {

@Override
public ValidationErrors validate(final StandaloneCatalog catalog, final ValidationErrors errors) {
if (effectiveDateForExistingSubscriptons != null &&
catalog.getEffectiveDate().getTime() > effectiveDateForExistingSubscriptons.getTime()) {
if (effectiveDateForExistingSubscriptions != null &&
catalog.getEffectiveDate().getTime() > effectiveDateForExistingSubscriptions.getTime()) {
errors.add(new ValidationError(String.format("Price effective date %s is before catalog effective date '%s'",
effectiveDateForExistingSubscriptons,
effectiveDateForExistingSubscriptions,
catalog.getEffectiveDate().getTime()),
catalog.getCatalogURI(), DefaultInternationalPrice.class, ""));
}
Expand All @@ -203,9 +203,9 @@ public ValidationErrors validate(final StandaloneCatalog catalog, final Validati
return errors;
}

public void setEffectiveDateForExistingSubscriptons(
final Date effectiveDateForExistingSubscriptons) {
this.effectiveDateForExistingSubscriptons = effectiveDateForExistingSubscriptons;
public void setEffectiveDateForExistingSubscriptions(
final Date effectiveDateForExistingSubscriptions) {
this.effectiveDateForExistingSubscriptions = effectiveDateForExistingSubscriptions;
}

public DefaultPlan setName(final String name) {
Expand Down Expand Up @@ -274,7 +274,7 @@ public boolean equals(final Object o) {

final DefaultPlan that = (DefaultPlan) o;

if (effectiveDateForExistingSubscriptons != null ? !effectiveDateForExistingSubscriptons.equals(that.effectiveDateForExistingSubscriptons) : that.effectiveDateForExistingSubscriptons != null) {
if (effectiveDateForExistingSubscriptions != null ? !effectiveDateForExistingSubscriptions.equals(that.effectiveDateForExistingSubscriptions) : that.effectiveDateForExistingSubscriptions != null) {
return false;
}
if (finalPhase != null ? !finalPhase.equals(that.finalPhase) : that.finalPhase != null) {
Expand All @@ -298,7 +298,7 @@ public boolean equals(final Object o) {
@Override
public int hashCode() {
int result = name != null ? name.hashCode() : 0;
result = 31 * result + (effectiveDateForExistingSubscriptons != null ? effectiveDateForExistingSubscriptons.hashCode() : 0);
result = 31 * result + (effectiveDateForExistingSubscriptions != null ? effectiveDateForExistingSubscriptions.hashCode() : 0);
result = 31 * result + (initialPhases != null ? Arrays.hashCode(initialPhases) : 0);
result = 31 * result + (finalPhase != null ? finalPhase.hashCode() : 0);
result = 31 * result + (plansAllowedInBundle != null ? plansAllowedInBundle.hashCode() : 0);
Expand All @@ -307,8 +307,8 @@ public int hashCode() {

@Override
public String toString() {
return "DefaultPlan [name=" + name + ", effectiveDateForExistingSubscriptons="
+ effectiveDateForExistingSubscriptons + ", product=" + product + ", initialPhases="
return "DefaultPlan [name=" + name + ", effectiveDateForExistingSubscriptions="
+ effectiveDateForExistingSubscriptions + ", product=" + product + ", initialPhases="
+ Arrays.toString(initialPhases) + ", finalPhase=" + finalPhase + ", plansAllowedInBundle="
+ plansAllowedInBundle + "]";
}
Expand Down
Expand Up @@ -176,8 +176,8 @@ private Plan findPlan(final PlanRequestWrapper wrapper,
if (!subscriptionStartDate.isBefore(catalogEffectiveDate)) { // Its a new subscription this plan always applies
return plan;
} else { //Its an existing subscription
if (plan.getEffectiveDateForExistingSubscriptons() != null) { //if it is null any change to this does not apply to existing subscriptions
final DateTime existingSubscriptionDate = CatalogDateHelper.toUTCDateTime(plan.getEffectiveDateForExistingSubscriptons());
if (plan.getEffectiveDateForExistingSubscriptions() != null) { //if it is null any change to this does not apply to existing subscriptions
final DateTime existingSubscriptionDate = CatalogDateHelper.toUTCDateTime(plan.getEffectiveDateForExistingSubscriptions());
if (requestedDate.isAfter(existingSubscriptionDate)) { // this plan is now applicable to existing subs
return plan;
}
Expand Down
Expand Up @@ -427,7 +427,7 @@ public boolean apply(final DefaultPlan predicateInput) {
}
final DefaultPlan result = new DefaultPlan();
result.setName(input.getName());
result.setEffectiveDateForExistingSubscriptons(input.getEffectiveDateForExistingSubscriptons());
result.setEffectiveDateForExistingSubscriptions(input.getEffectiveDateForExistingSubscriptions());
result.setFinalPhase(toDefaultPlanPhase(input.getFinalPhase()));
result.setInitialPhases(toDefaultPlanPhases(ImmutableList.copyOf(input.getInitialPhases())));
result.setPlansAllowedInBundle(input.getPlansAllowedInBundle());
Expand Down
Expand Up @@ -64,8 +64,8 @@ public void testBasic() throws Exception {

assertEquals(overriddenPlan.getProduct().getName(), plan.getProduct().getName());
assertEquals(overriddenPlan.getRecurringBillingPeriod(), plan.getRecurringBillingPeriod());
if (plan.getEffectiveDateForExistingSubscriptons() != null) {
assertEquals(overriddenPlan.getEffectiveDateForExistingSubscriptons().compareTo(plan.getEffectiveDateForExistingSubscriptons()), 0);
if (plan.getEffectiveDateForExistingSubscriptions() != null) {
assertEquals(overriddenPlan.getEffectiveDateForExistingSubscriptions().compareTo(plan.getEffectiveDateForExistingSubscriptions()), 0);
}
assertNotEquals(overriddenPlan.getFinalPhase().getName(), plan.getFinalPhase().getName());
assertEquals(overriddenPlan.getPlansAllowedInBundle(), plan.getPlansAllowedInBundle());
Expand Down Expand Up @@ -131,8 +131,8 @@ public void testGetOverriddenPlan() throws Exception {

assertEquals(overriddenPlan.getProduct().getName(), plan.getProduct().getName());
assertEquals(overriddenPlan.getRecurringBillingPeriod(), plan.getRecurringBillingPeriod());
if (plan.getEffectiveDateForExistingSubscriptons() != null) {
assertEquals(overriddenPlan.getEffectiveDateForExistingSubscriptons().compareTo(plan.getEffectiveDateForExistingSubscriptons()), 0);
if (plan.getEffectiveDateForExistingSubscriptions() != null) {
assertEquals(overriddenPlan.getEffectiveDateForExistingSubscriptions().compareTo(plan.getEffectiveDateForExistingSubscriptions()), 0);
}
assertNotEquals(overriddenPlan.getFinalPhase().getName(), plan.getFinalPhase().getName());
assertEquals(overriddenPlan.getPlansAllowedInBundle(), plan.getPlansAllowedInBundle());
Expand Down
Expand Up @@ -32,7 +32,7 @@ public void testDateValidation() {
final StandaloneCatalog c = new MockCatalog();
c.setSupportedCurrencies(new Currency[]{Currency.GBP, Currency.EUR, Currency.USD, Currency.BRL, Currency.MXN});
final DefaultPlan p1 = MockPlan.createBicycleTrialEvergreen1USD();
p1.setEffectiveDateForExistingSubscriptons(new Date((new Date().getTime()) - (1000 * 60 * 60 * 24)));
p1.setEffectiveDateForExistingSubscriptions(new Date((new Date().getTime()) - (1000 * 60 * 60 * 24)));
final ValidationErrors errors = p1.validate(c, new ValidationErrors());
Assert.assertEquals(errors.size(), 1);
errors.log(log);
Expand Down
Expand Up @@ -87,7 +87,7 @@

<plans>
<plan name="pistol-monthly">
<effectiveDateForExistingSubscriptons>2011-02-14T00:00:00+00:00</effectiveDateForExistingSubscriptons>
<effectiveDateForExistingSubscriptions>2011-02-14T00:00:00+00:00</effectiveDateForExistingSubscriptions>

<product>Pistol</product>
<initialPhases>
Expand Down
Expand Up @@ -87,7 +87,7 @@

<plans>
<plan name="pistol-monthly">
<effectiveDateForExistingSubscriptons>2011-03-14T00:00:00+00:00</effectiveDateForExistingSubscriptons>
<effectiveDateForExistingSubscriptions>2011-03-14T00:00:00+00:00</effectiveDateForExistingSubscriptions>
<product>Pistol</product>
<initialPhases>
<phase type="TRIAL">
Expand Down
2 changes: 1 addition & 1 deletion util/src/test/java/org/killbill/billing/mock/MockPlan.java
Expand Up @@ -63,7 +63,7 @@ public String getName() {
}

@Override
public Date getEffectiveDateForExistingSubscriptons() {
public Date getEffectiveDateForExistingSubscriptions() {
return new Date();
}

Expand Down

1 comment on commit bc3efa7

@pierre
Copy link
Member

@pierre pierre commented on bc3efa7 Mar 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Also: reminder for the migration wiki page.

Please sign in to comment.